local SPELLS_OPCODE = 205 local spellsWindow = nil function init() g_ui.importStyle('spellswindow') ProtocolGame.registerExtendedJSONOpcode(SPELLS_OPCODE, onExtendedJSONOpcode) end function terminate() ProtocolGame.unregisterExtendedJSONOpcode(SPELLS_OPCODE) destroyWindow() end function destroyWindow() if spellsWindow then spellsWindow:destroy() spellsWindow = nil end end function onExtendedJSONOpcode(protocol, opcode, data) if not data then return end print('[SpellsWindow] Abrindo lista de magias') destroyWindow() spellsWindow = g_ui.createWidget('SpellsWindow', rootWidget) spellsWindow:setText(data.title or 'Magias') spellsWindow:getChildById('header'):setText(data.title or 'Magias') local textEdit = spellsWindow:getChildById('spellsText') textEdit:setText(data.text or '') textEdit:setEditable(false) textEdit:setCursorVisible(false) spellsWindow:getChildById('okButton').onClick = destroyWindow spellsWindow.onEnter = destroyWindow spellsWindow.onEscape = destroyWindow spellsWindow:raise() spellsWindow:focus() end