GUI example in Plugin Creator Tools
Posted: 28 Aug 2020, 21:34
Actually useful is this window that shows the Icon, Font and NinePatch resources that are available within the game. A tap on the "copy" button copies the code used to access something into the clipboard, e.g. "Icon.OK" for the ok icon.
Here you can see how various aspects of this tool were implemented

Code: Select all Reset
-- Show the menu with the close action closing the provided dialoglocal function showMenu(dialog)local parent = GUI.get'$menuparent'GUI.createMenu{source = parent,actions = {{icon = Icon.OK, text = 'A', onClick = function() Debug.toast('yo') end},{icon = Icon.CANCEL, text = 'B', enabled = false},{},{icon = Icon.CLOSE, text = 'Close', onClick = dialog.close}}}end-- Show the dialog window that contains various GUI object usage exampleslocal function showObjectsDialog()local dialog = GUI.createDialog{icon = Icon.REGION_SPLIT,title = 'Objects',height = 240}local layout = dialog.content:addLayout{vertical = true}local function addLine(label, height)local line = layout:addLayout{height = height}line:addLabel{text = label, w = 60}return line:addLayout{ x = 62 }endlocal sliderValue = 0.5
Lua editor
Here the plugin is of type tool and uses real-time scripting for testing purposes

Code: Select all Reset
[{"once":true,"id":"$devtool_showguiexample00","type":"tool","category":"$devtool_category00","preview frames":[{"bmp":"guiicon.png"}],"title":"GUI preview","text":"This tool provides an example for what can be done in regard to UI using Lua.","script":"#LuaWrapper","meta":{"luawrapper":{"script":"GUIExample.lua","dev":true}}}]
JSON checker