FreeKill/lua/ui_emu/popupbox.lua
notify 30df075db2
Some checks failed
Check Whitespace and New Line / check (push) Has been cancelled
Deploy Doxygen to Pages / build (push) Has been cancelled
Deploy Doxygen to Pages / deploy (push) Has been cancelled
Changelog: v0.4.20
2024-10-22 01:14:01 +08:00

43 lines
1.3 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local base = require 'ui_emu.base'
local control = require 'ui_emu.control'
local Scene = base.Scene
-- 一种模拟具体qml框的处理机构
-- 具体是什么东西全靠继承子类处理
-- 理论上来说这就是一个小scene
-- 会向其父场景传输其应有的变化
-- 同理UI改变也由父场景传输至这里
---@class PopupBox: Scene
local PopupBox = Scene:subclass("PopupBox")
-- 打开qml框后的初始化对应request打开qml框的操作
function PopupBox:initialize(parent, data)
Scene.initialize(self, parent)
self.data = data
self.change = {}
end
-- 模拟一次UI交互修改相关item的属性即可
-- 同时修改自己parent的changeData
function PopupBox:update(elemType, id, newData)
local item = self.items[elemType][id]
local changed = item:setData(newData)
local changeData = self.change
if changed and changeData then
changeData[elemType] = changeData[elemType] or {}
table.insert(changeData[elemType], item:toData())
end
end
-- 由父RequestHandler调用用以将本qml变化传至父RequestHandler
-- 调用者需要维护changeData确保传给UI的数据最少
function PopupBox:notifyUI()
if not ClientInstance then return nil end
self.parent.change["_type"] = self.class.name
ClientInstance:notifyUI("UpdateRequestUI", self.parent.change)
end
return PopupBox