123 lines
3.7 KiB
Lua
123 lines
3.7 KiB
Lua
AutoXunHangOBJ = {}
|
|
|
|
AutoXunHangOBJ.__cname = "AutoXunHangOBJ"
|
|
AutoXunHangOBJ.data = {}
|
|
|
|
function AutoXunHangOBJ:isWidgetValid(widget)
|
|
return widget and GUI:Win_IsNotNull(widget)
|
|
end
|
|
|
|
function AutoXunHangOBJ:addClick(widget, callback)
|
|
if self:isWidgetValid(widget) then
|
|
GUI:addOnClickEvent(widget, callback)
|
|
end
|
|
end
|
|
|
|
function AutoXunHangOBJ:main()
|
|
if self._parent and GUI:Win_IsNotNull(self._parent) then
|
|
GUI:Win_Close(self._parent)
|
|
return
|
|
end
|
|
|
|
local parent = GUI:Win_Create(self.__cname, 0, 0, 0, 0, false, false, true, false)
|
|
GUI:LoadExport(parent, "game/Tongyong/AutoXunHangUI")
|
|
|
|
self._parent = parent
|
|
self.ui = GUI:ui_delegate(parent)
|
|
|
|
ssrUIManager:OpenAlgin(self)
|
|
self:bindEvent()
|
|
|
|
ssrMessage:SubLink(self.__cname .. "_sync")
|
|
end
|
|
|
|
function AutoXunHangOBJ:bindEvent()
|
|
self:addClick(self.ui.bg_close, function()
|
|
GUI:Win_Close(self._parent)
|
|
end)
|
|
|
|
self:addClick(self.ui.btn_close, function()
|
|
GUI:Win_Close(self._parent)
|
|
end)
|
|
|
|
|
|
|
|
for i = 1, 3 do
|
|
self:addClick(self.ui["delBtn" .. i], function()
|
|
ssrMessage:SubLink(self.__cname .. "_delMap", { index = i })
|
|
end)
|
|
self:addClick(self.ui["recordBtn" .. i], function()
|
|
ssrMessage:SubLink(self.__cname .. "_recordMap", { index = i })
|
|
end)
|
|
end
|
|
|
|
self:addClick(self.ui.toggleBtn, function()
|
|
if tonumber(self.data.isOpen) == 1 then
|
|
ssrMessage:SubLink(self.__cname .. "_stop")
|
|
else
|
|
ssrMessage:SubLink(self.__cname .. "_start")
|
|
end
|
|
end)
|
|
|
|
self:addClick(self.ui.saveBtn, function()
|
|
self:saveSetting()
|
|
end)
|
|
end
|
|
|
|
function AutoXunHangOBJ:saveSetting()
|
|
local data = {
|
|
autoKuangBao = GUI:CheckBox_isSelected(self.ui.autoKuangBao) and 1 or 0,
|
|
orderMode = GUI:CheckBox_isSelected(self.ui.orderMode) and 1 or 0,
|
|
dieStop = tonumber(GUI:TextInput_getString(self.ui.dieInput)) or 0,
|
|
noAttackSec = tonumber(GUI:TextInput_getString(self.ui.noAtkInput)) or 0,
|
|
}
|
|
ssrMessage:SubLink(self.__cname .. "_saveSetting", data)
|
|
end
|
|
|
|
function AutoXunHangOBJ:refresh()
|
|
if not self._parent or GUI:Win_IsNull(self._parent) or not self.ui then
|
|
return
|
|
end
|
|
|
|
local isOpen = tonumber(self.data.isOpen) == 1
|
|
if self:isWidgetValid(self.ui.statusText) then
|
|
GUI:Text_setString(self.ui.statusText, isOpen and "巡航中" or "未开启")
|
|
GUI:Text_setTextColor(self.ui.statusText, isOpen and "#00ff00" or "#c0c0c0")
|
|
end
|
|
|
|
if self:isWidgetValid(self.ui.toggleBtn) then
|
|
GUI:Button_loadTextureNormal(self.ui.toggleBtn, string.format("res/custom/37/btn_%d.png", isOpen and 5 or 1))
|
|
end
|
|
|
|
if self:isWidgetValid(self.ui.autoKuangBao) then
|
|
GUI:CheckBox_setSelected(self.ui.autoKuangBao, tonumber(self.data.autoKuangBao) == 1)
|
|
end
|
|
|
|
if self:isWidgetValid(self.ui.orderMode) then
|
|
GUI:CheckBox_setSelected(self.ui.orderMode, tonumber(self.data.orderMode) == 1)
|
|
end
|
|
|
|
if self:isWidgetValid(self.ui.dieInput) then
|
|
GUI:TextInput_setString(self.ui.dieInput, tostring(tonumber(self.data.dieStop) or 0))
|
|
end
|
|
|
|
if self:isWidgetValid(self.ui.noAtkInput) then
|
|
GUI:TextInput_setString(self.ui.noAtkInput, tostring(tonumber(self.data.noAttackSec) or 0))
|
|
end
|
|
|
|
local maps = self.data.maps or {}
|
|
for i = 1, 3 do
|
|
local name = maps[i] and tostring(maps[i]) or "空"
|
|
local mapText = self.ui["mapText" .. i]
|
|
if self:isWidgetValid(mapText) then
|
|
GUI:Text_setString(mapText, i .. ". " .. name)
|
|
end
|
|
end
|
|
end
|
|
|
|
function AutoXunHangOBJ:syncData(arg1, arg2, arg3, data)
|
|
self.data = data or {}
|
|
self:refresh()
|
|
end
|
|
|
|
return AutoXunHangOBJ
|