/* 文件名:ItemData.nut 路径:Base/_Z_Data/ItemData.nut 创建日期:2024-08-06 23:58 文件用途:用于存放Item数据 */ if (!getroottable().rawin("Rindro_ItemInfoObject")) Rindro_ItemInfoObject <- {}; if (!getroottable().rawin("Rindro_ItemInfoBuf")) Rindro_ItemInfoBuf <- ""; if (!getroottable().rawin("RINDRO_INIT_FLAG")) RINDRO_INIT_FLAG <- false; //获取本地配置 function Rindro_GetLocalConfig() { local Buf = L_sq_GetLocalConfig(); if (!Buf) { return { md5 = -1 }; } else return Json.Decode(Buf); } // if (!getroottable().rawin("RINDRO_CONFIG")) RINDRO_CONFIG <- Rindro_GetLocalConfig(); //获取本地信息版本 function Rindro_GetMd5() { return RINDRO_CONFIG.md5; } //初始化各种信息 function Rindro_Init() { //道具信息 local ItemArray = getroottable().RINDRO_CONFIG.itemInfo; Rindro_ItemInfoBuf = ""; foreach(Value in ItemArray) { if (Value.Name2.len() == 0) Value.Name2 = "Rindro-Team"; getroottable().Rindro_ItemInfoObject[Value.Id] <- Value; } RINDRO_INIT_FLAG = true; } //更新本地配置 function Rindro_ItemInfoCallBack(Chunk) { local Jso = Json.Decode(Chunk); if ("ZipSEnd" in Jso) { getroottable().Rindro_ItemInfoObject <- {}; Rindro_ItemInfoBuf += Jso.ZipS; local ZlibStrBuf = L_sq_Dezlib(Rindro_ItemInfoBuf); if (ZlibStrBuf == "null") { Rindro_ItemInfoBuf = ""; return; } L_sq_SetLocalConfig(ZlibStrBuf); getroottable().RINDRO_CONFIG <- Json.Decode(ZlibStrBuf); Rindro_Init(); } else { Rindro_ItemInfoBuf += Jso.ZipS; } } Pack_Control.rawset(20240422, Rindro_ItemInfoCallBack); //无需更新本地配置 Pack_Control.rawset(20240424, function(Chunk) { Rindro_Init(); }); //道具绘制类 class ItemInfoClass { //Gm模式 GmModel = true; Info = null; PageLength = 0; //静态品级颜色 static RarityColor = [ 0xFFFFFFFF, //白 0xFFEDD568, //蓝 0xFFFF6BB3, //紫 0xFFF000FF, //粉 0xFF00B1FF, //黄 0xFF6666FF, //红 0xFF0055FF, //橙 ]; //我的品级颜色 MyRarityColor = null; //我的售价长度 MyPriceLength = null; //我的冷却时间长度 MyCoolTimeLength = null; //获取真实类型 function GetRealType(Type) { switch (Type) { case "[material]": return "材料"; case "[recipe]": return "设计图"; case "[upgradable legacy]": return "袖珍罐"; case "[quest]": return "任务"; case "[booster random]": case "[multi upgradable legacy]": case "[booster selection]": case "[cera booster]": case "[unlimited waste]": case "[usable cera package]": case "[only effect]": return "消耗品"; case "[weapon]": return "武器"; case "[title name]": return "称号"; case "[coat]": return "上衣"; case "[pants]": return "下衣"; case "[hat]": return "帽子"; case "[shoulder]": return "护肩"; case "[waist]": return "腰带"; case "[shoes]": return "鞋子"; case "[amulet]": return "项链"; case "[wrist]": return "手镯"; case "[ring]": return "戒指"; case "[support]": return "辅助装备"; case "[aurora avatar]": return "光环"; case "[magic stone]": return "魔法石"; case "[creature]": return "寵物"; case "[artifact red]": return "宠物装备 红"; case "[artifact blue]": return "宠物装备 蓝"; case "[artifact green]": return "宠物装备 绿"; case "[skin avatar]": return "皮肤"; case "[hair avatar]": return "头部装扮"; case "[waist avatar]": return "腰部装扮"; case "[hat avatar]": return "帽子装扮"; case "[coat avatar]": return "上衣装扮"; case "[face avatar]": return "脸部装扮"; case "[breast avatar]": return "胸部装扮"; case "[pants avatar]": return "下装装扮"; case "[shoes avatar]": return "鞋装扮"; default: return "道具"; } } constructor(gInfo) { Info = clone(gInfo); //Gm模式显示编号 if (GmModel) Info.Name += "[" + Info.Id + "]"; //配置品级颜色 if (Info.Rarity< 0 || Info.Rarity > 6) { MyRarityColor = Info.Rarity; } else { MyRarityColor = RarityColor[Info.Rarity]; } //配置售价长度 if ("Price" in Info) { MyPriceLength = LenheartTextClass.GetStringLength(Info.Price.tostring()); } //配置冷却时间长度 if ("CoolTime" in Info) { MyCoolTimeLength = LenheartTextClass.GetStringLength((Info.CoolTime / 1000.0).tostring()); } //配置类型 if ("Type" in Info) { Info.Type = GetRealType(Info.Type); } //配置装备类型 else if ("EquipmentType" in Info) { Info.Type <- GetRealType(Info.EquipmentType); } PageLength += 72; CheckStrLength(); } function CheckInfoLength(TableKey, AddLength) { if (TableKey in Info) { PageLength += AddLength; } } function CheckStrLength() { if ("Explain" in Info) { // local Buf = LenheartTextClass.GetStringLength(Info.Explain.tostring()); // local Pn = (Buf / 211.0); // if (Pn< 1) PageLength += 12; // if (Pn > 1) Pn = Pn.tointeger() + 1; // PageLength += (16 * Pn); local Buf = L_sq_GetStringDrawArray(Info.Explain, 220); PageLength += (Buf.len() * 16); // PageLength += 12; } } //高级绘制文字(带换行) function L_sq_DrawCode_Ex(str, x, y, rgba, mb, jc, hl) { local strarr = []; if (str.find("\n") == null) L_sq_DrawCode(str, x, y, rgba, mb, jc); else { local Bpos = 0; while (true) { local Npos = str.find("\n", Bpos); if (!Npos) { local strbuff = str.slice(Bpos, str.len()); strarr.append(strbuff); break; } local strbuff = str.slice(Bpos, Npos); strarr.append(strbuff); Bpos = Npos + 1; } for (local z = 0; z< strarr.len(); z++) { L_sq_DrawCode(strarr[z], x, y + (z * 14), rgba, mb, jc); } } } function Show(X, Y) { if (X< 0) X = 0; if ((X + 211) > 800) X = (800 - 211); if (Y< 0) Y = 0; if (Y + PageLength > 600) Y = 600 - PageLength; //Item信息框一般为211的宽度 L_sq_DrawWindow(X, Y, 211, PageLength, "interface2/popup/popup.img", 134, 6, 12, 6, 13); //绘制名字 和 图标 if ("Id" in Info) L_Sq_DrawItem(X + 8 + 174, Y + 8, Info.Id, 1, 0, 0, 0); if ("Name2" in Info) L_sq_DrawCode(Info.Name2, X + 8, Y + 9, MyRarityColor, 1, 1); if ("Name" in Info) L_sq_DrawCode(Info.Name, X + 8, Y + 23, MyRarityColor, 1, 1); //绘制线 L_sq_DrawImg("interface2/popup/popup.img", 270, X + 7, Y + 26 + 16); //绘制重量 if ("Weight" in Info) { L_sq_DrawCode((Info.Weight.tofloat() / 1000.0).tostring() + "kg", X + 7, Y + 24 + 24, 0xFFFFFFFF, 1, 1); } //绘制售价 if ("Price" in Info) { L_sq_DrawCode("金币", X + 186, Y + 24 + 24, 0xFFFFFFFF, 1, 1); L_sq_DrawCode(Info.Price.tostring(), X - MyPriceLength + 186, Y + 24 + 24, 0xFFFFFFFF, 1, 1); } //绘制类型 if ("Type" in Info) { L_sq_DrawCode(Info.Type.tostring(), X + 7, Y + 48 + 16, 0xFFFFFFFF, 1, 1); } //绘制冷却时间 if ("CoolTime" in Info) { L_sq_DrawCode("秒", X + 186 + 12, Y + 48 + 16, 0xFFFFFFFF, 1, 1); L_sq_DrawCode((Info.CoolTime / 1000.0).tostring(), X - MyCoolTimeLength + 214 - 18, Y + 48 + 16, 0xFFFFFFFF, 1, 1); } //绘制普通描述 if ("Explain" in Info) { local a = L_sq_GetStringDrawArray(Info.Explain, 220); foreach(Pos, va in a) { L_sq_DrawCode(va, X + 7, Y + 48 + 12 + 24 + (Pos * 16), 0xFFEDD568, 1, 1); } } } }