--- --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by PZM. --- DateTime: 2024/7/23 9:13 ---外部自定义Lua的入口,编写同名文件GUIUtil.lua进行二进制覆盖。工程内的GUIUtil里面不要添加其他任何逻辑 require "dev/CustomMsgDef" require "dev/OutEnum" require "dev/info/InfoManager" require "dev/manager/GlobalLuaEventManager" require "dev/manager/PrivilegeCardManager" require "dev/manager/MainUiStateManager" require "dev/Logic/Common/shortcutOutMgr" require "dev/Logic/Common/SL_Out" require "dev/Logic/Common/EquipFunc" require "dev/CfgPost/CfgPostRequire" require "dev/OutEvent" require "dev/manager/KLGuideManager" require "dev/Condition/ConditionManager" require "dev/Logic/BT/BTMgr" GUIUtil = {} local this = GUIUtil function this.Init() InfoManager:Init() GlobalLuaEventManager.Init() this.updtSch = SL:Schedule(this.updtSch, 0, 0.02, math.maxinteger, this.UpdateTest) PrivilegeCardManager.Init() KLGuideManager.Init() MainUiStateManager.Init() EquipFunc.Init() --SL:Schedule(0,0.02,math.maxinteger,this.UpdateTest) end function this.PreLoad() --GUI:SetUICacheTime("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel",-1) --GUI:SetUICacheTime("dev/ui/Bag/Panel/KLUIBag/KLUIBagPanel",-1) GUI:PreLoadUI("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel", 1) --GUI:PreLoadUI("dev/ui/Bag/Panel/KLUIBag/KLUIBagPanel",1) end function this.Reset() InfoManager:Reset() GlobalLuaEventManager.Reset() PrivilegeCardManager.Reset() EquipFunc.Reset() end function this.Update() PrivilegeCardManager.Update() end function this.UpdateTest() if Input.GetKeyDown(KeyCode.U) then logError("当前开服天数:" .. SL:GetOpenServerDay()) end if Input.GetKeyDown(KeyCode.K) then --GUI:UIPanel_Open("dev/outui/Activity/Panel/KLRedFort/KLRedFortPanel") --GUI:UIPanel_Open("dev/outui/Activity/Panel/KLGoldChallenge/KLGoldChallengePanel") end end function this.GetColorText(msg, color) return string.format("%s", color, msg) end --艺术字 时分 function this.FormatTimeHMAndDW(time) time = math.modf(time) local hour = math.modf(time / 3600) local minute = math.modf(time % 3600 / 60) local fmtTime = string.format("%02sh%02sm", hour, minute) return fmtTime end --时分 function this.FormatTimeHM(time) time = math.modf(time) local hour = math.modf(time / 3600) local minute = math.modf(time % 3600 / 60) local fmtTime = string.format("%02s小时%02s分钟", hour, minute) return fmtTime end --时分秒 function this.FormatTimeHMS(time) time = math.modf(time) local hour = math.modf(time / 3600) local minute = math.modf(time % 3600 / 60) local second = time % 60 local fmtTime = string.format("%02s:%02s:%02s", hour, minute, second) return fmtTime end --时分秒 function this.FormatTimeHMSD(time) time = math.modf(time) local minute = time // 60 % 60 local hour = time // 3600 % 24 local second = time % 60 local day = time // 86400 if day >= 1 then return string.format("%s天:%02s时:%02s分", day, hour, minute) else return string.format("%02s:%02s:%02s", hour, minute, second) end end --时分秒 function this.FormatTimeHMSD_S(time) time = math.modf(time) local minute = time // 60 % 60 local hour = time // 3600 % 24 local second = time % 60 local day = time // 86400 if day >= 1 then return string.format("%s天:%02s时:%02s分", day, hour, minute) else return string.format("%02s时:%02s分:%02s秒", hour, minute, second) end end --分秒 function this.FormatTimeMS(time) time = math.modf(time) local minute = math.modf(time / 60) local second = time % 60 local fmtTime = string.format("%02s:%02s", minute, second) return fmtTime end --秒(剩余秒数倒计时) function this.FormatTimeDHM(time) local m = time // 60 % 60 local h = time // 3600 % 24 local d = time // 86400 if tonumber(d) < 10 then return string.format("%s天%02s小时%02s分钟", d, h, m); else return string.format("%02s天%02s小时%02s分钟", d, h, m); end end --秒(剩余秒数倒计时) function this.FormatTimeDHMN(time) local m = time // 60 % 60 local h = time // 3600 % 24 local d = time // 86400 return string.format("%02s:%02s:%02s", d, h, m); end --秒(剩余秒数倒计时) function this.FormatTimeD(time) local d = math.modf(time // 86400) return string.format("%s天", d); end --将数字转为中文数字 function this.ToNumberString(num) if num == 1 then return "一" elseif num == 2 then return "二" elseif num == 3 then return "三" elseif num == 4 then return "四" elseif num == 5 then return "五" elseif num == 6 then return "六" elseif num == 7 then return "七" elseif num == 8 then return "八" elseif num == 9 then return "九" elseif num == 10 then return "十" end return "" end function this.GetSampleNumberString(numArg) local num = tonumber(numArg) if not num then return numArg end if num < 10000 then --5位 return num elseif num < 100000000 then --9位 return math.floor(num / 1000 + 0.5) / 10 .. "万" elseif num < 1000000000000 then --13位 return math.floor(num / 10000000 + 0.5) / 10 .. "亿" elseif num < 10000000000000000 then --17位 return math.floor(num / 100000000000 + 0.5) / 10 .. "兆" else return math.floor(num / 100000000000 + 0.5) / 10 .. "兆" end return "" end --秒(剩余秒数倒计时) function this.FormatTimeDHM_S(time) local m = time // 60 % 60 local h = time // 3600 % 24 local d = time // 86400 if tonumber(d) < 10 then return string.format("%s天%02s时%02s分", d, h, m); else return string.format("%02s天%02s时%02s分", d, h, m); end end ---格式化数据 function this.FormatNumber(count, integer_bit_notZero, isReplace_chinese_character) if not integer_bit_notZero then local str = count count = tonumber(count) if count >= 100000 and count < 10000000 then local num = string.format("%0.1f", count / 10000) str = num .. (isReplace_chinese_character and "w" or "万") elseif count > 10000000 then local num = string.format("%0.1f", count / 100000000) str = num .. (isReplace_chinese_character and "y" or "亿") end return str else local str = count if count >= 10000 and count < 100000000 then local num = string.format("%0.1f", count / 10000) if tonumber(num) == math.floor(num) then num = math.floor(num) end str = num .. (isReplace_chinese_character and "w" or "万") elseif count >= 100000000 then local num = tonumber(string.format("%0.1f", count / 100000000)) if num < 10000 then str = (isReplace_chinese_character and "y" or "亿") elseif num >= 10000 and num < 100000000 then num = string.format("%0.1f", num / 10000) str = (isReplace_chinese_character and "z" or "兆") elseif num >= 100000000 then num = string.format("%0.1f", num / 100000000) str = (isReplace_chinese_character and "j" or "京") end if tonumber(num) == math.floor(num) then num = math.floor(num) end str = num .. str end return str end end --代币id local coinId --获得代币id local function GetCoinId() if coinId then return coinId end ---默认代币id coinId = 30510308 local tbl = SL:GetConfigTable("cfg_item") for _, v in pairs(tbl) do if v.type == 3 and v.subType == 51 then coinId = v.id return coinId end end return coinId end ---@充值通用接口(需要使用代币调用这个) ---@param rechargeTbl cfg_recharge_column @充值表 ---@param count number @充值数量 ---@param extraParams table @透传参数(可选参数 function this.SDKPay(rechargeTbl, count, extraParams) if not rechargeTbl then logError("Not found rechargeTbl") return end local haveCount = SL:GetBagItemCount(GetCoinId()) local needCount = rechargeTbl.amount if haveCount >= needCount then ---有代币 SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE, { rechargeId = rechargeTbl.id, count = count, extraParams = extraParams }) return end SL:SDKPay(rechargeTbl, count, extraParams) end