GUI Compendium

The Lua scripting language allows you to give your plugin more advanced features.
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3756
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Re: GUI Compendium

Post by Lobby » 22 Nov 2021, 08:00

image.png
I see there are two listboxes created here. So my assumption is the first one is the one seen in your image while the second one will actually be populated with entries.
You do not have the required permissions to view the files attached to this post.
User avatar
Yakka Works
Inhabitant of a Conurbation
Reactions:
Posts: 412
Joined: 06 Jan 2020, 07:57
Location: Java-indonesia
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: GUI Compendium

Post by Yakka Works » 22 Nov 2021, 10:27

Screenshot_2021-11-22-17-37-22-475_info.flowersoft.theotown.theotown.jpg
Still doesn't show up

Code: Select all    Reset

--Show the test dialong local function showitptestdialog() local function createIconPreview(parent, frame) end local dialog = GUI.createDialog{ icon = Icon.PEOPLE_OFFICEWORKER, title = 'Credits', width = 240, height = 300 } local listBox = dialog.content:addListBox{} local entry = listBox:addCanvas{h=30} entry:addLabel{ text = 'TestTest', x = height + 5, w = -30 }:setFont(Font.SMALL) local lbl = entry:addLabel{ text = 'Terima Kasih Kepada:', width = -30 } local cmd = entry:addButton{ x = -35, width = 30, icon = Icon.OK, onClick = function() Debug.toast('Clicked on entry '..i) end } end --GUI Example plugin -- Show the menu with the close action closing the provided dialog local 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 Credits list dialog window local function showcreditsDialog() local dialog = GUI.createDialog{ icon = Icon.PEOPLE_OFFICEWORKER, title = 'Credits', text = [[Credits Kiki012,Kingtut101,Matthew Fillbert,Akunbaru123,Pederont,mdk_813, theotheorich,lobbydivinus,and justanyone Non Forum Member Chris (Discord),and Alan (FTTI) License CC BY ]], height = 250, width =250 } end --Show the info Menu local function showinfoMenu(dialog) local parent = GUI.get'$menuparent' GUI.createMenu{ source = parent, actions = { { icon = Icon.COPY, text = 'Discord', onClick = function() Runtime.setClipboard('https://discord.gg/UEDRUnFbEJ') Debug.toast('Put the Discord invite link into clipboard') end, autoClose = false }, { icon = Icon.COPY, text = 'Whatsapp (indonesian Only)', onClick = function() Runtime.setClipboard('https://chat.whatsapp.com/Bv4EIv7Jvjb8ViXeSJK0WS') Debug.toast('Link Grup Tersimpan di Clipboard') end, autoClose = false }, { icon = Icon.COPY, text = 'Website', onClick = function() Runtime.setClipboard('https://kiki012184.github.io/K012-Theot ... lugin.html') Debug.toast('Put the website link into clipboard') end, autoClose = false } } } end --https://kiki012184.github.io/K012-Theot ... lugin.html -- Show the main dialog window local function showDialog() local dialog dialog = GUI.createDialog{ icon = Icon.INFO, title = 'Plugin Manual', text = [[Welcome to Indonesia Transportation Pack! This plugin add New Content Related to Transportation in Indonesia. You can unlock the road section if your city have enough ranks. Unlocking Train is bit more complicated,you need station headmaster house first,then it time for your decision,either unlocking local made trains,you just need to build an train factory,or imported trains,by building dedicated port,most of Indonesian train are imported. Sadly, some features are limited,And Some Bugged. There Are Patch or addon for this plugin such as normal rail compability,remove roads,and much more,click more info and get the link to my website. if you got a bug or a problem, or have an idea, please post it in comments. to be honest being an plugin creator is hard,especialy managing an huge plugin like this.]], width = 250, height = 400, actions = { { icon = Icon.PEOPLE_OFFICEWORKER, text = 'Credits', onClick = showcreditsDialog, autoClose = false }, { id = '$menuparent', icon = Icon.INFO, text = 'More Info', onClick = function() showinfoMenu(dialog) end, autoClose = false }, { icon = Icon.PEOPLE_OFFICEWORKER, text = 'Test', onClick = showitptestdialog, autoClose = false } } } closeDialog = dialog.close end -- Rebuild dialog after code changes function script:init() if closeDialog then closeDialog() closeDialog = nil showDialog() end end -- Let's cheat a little by closing the tool immediately after it was opened function script:event(_, _, _, event) if event == Script.EVENT_TOOL_ENTER then GUI.get('cmdCloseTool'):click() showDialog() end end
Lua editor
Run
You do not have the required permissions to view the files attached to this post.
My plugins,up to date and it's free on my website. So check it out.
My website
Community/Creators Discord Server List
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3756
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Re: GUI Compendium

Post by Lobby » 22 Nov 2021, 21:40

Did you use "strict lua":true in your json? I assume the script crashed, eg. in line 17 height is not defined.
User avatar
Wepf
Inhabitant of a Megacity
Reactions:
Posts: 256
Joined: 14 Oct 2021, 08:19
Location: Your lucid dream
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: GUI Compendium

Post by Wepf » 24 Nov 2021, 10:09

I guess it actually a time to put my brain in garbage incerator
I play music and create theotown plugin (rarely)


Btw I'm from 🇹🇭 and I'm 13
User avatar
Yakka Works
Inhabitant of a Conurbation
Reactions:
Posts: 412
Joined: 06 Jan 2020, 07:57
Location: Java-indonesia
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: GUI Compendium

Post by Yakka Works » 25 Dec 2021, 15:51

Is there a way to add translation on custom gui,
I mean i want GUI A text and title translated into English and indonesian.
My plugins,up to date and it's free on my website. So check it out.
My website
Community/Creators Discord Server List
User avatar
Marvel
Metropolitan
Reactions:
Posts: 111
Joined: 29 Nov 2020, 06:47
Location: Indonesia
Plugins: Showcase Store
Version: Beta

Re: GUI Compendium

Post by Marvel » 11 Jul 2022, 01:40

Lobby wrote: 05 Sep 2020, 08:42 <the original post>
Ok So where we need to place the file are iys need json or something like that?
:space I LOVE THEOTOWN :space
User avatar
erksmit
Villager
Reactions:
Posts: 24
Joined: 02 Mar 2018, 10:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

Post by erksmit » 03 Jan 2023, 09:12

Is there a way to create a panel with a diffrent ninepatch? Currently i am simply using a canvas with onDraw but i was wondering whether panels support it out of the box
Guest
Reactions:

Re: GUI Compendium

Post by Guest » 13 Jan 2023, 05:17

erksmit wrote: 03 Jan 2023, 09:12See above me
It isn't possible
Guest
Reactions:

Re: GUI Compendium

Post by Guest » 14 Jan 2023, 21:08

Kiki012 wrote: 25 Dec 2021, 15:51Click ↑ or scroll up
https://doc.theotown.com/modules/TheoTo ... lateInline
User avatar
erksmit
Villager
Reactions:
Posts: 24
Joined: 02 Mar 2018, 10:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

Post by erksmit » 17 Jan 2023, 19:12

Theotronic Arts wrote: 13 Jan 2023, 05:17
erksmit wrote: 03 Jan 2023, 09:12See above me
It isn't possible
Why isn't it possible.
User avatar
erksmit
Villager
Reactions:
Posts: 24
Joined: 02 Mar 2018, 10:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

Post by erksmit » 09 Feb 2023, 14:01

Can i pass a ninepatch to use when creating a panel object? The examples don't include any mention of this.
User avatar
erksmit
Villager
Reactions:
Posts: 24
Joined: 02 Mar 2018, 10:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

Post by erksmit » 09 Feb 2023, 15:10

Chief this is false information that does not work, please test it before giving me an incorrect answer.
20230209161553_1.jpg
As you can see it does not change the background whatsoever, it will still be the default panel.
You do not have the required permissions to view the files attached to this post.
NotPFA
Townsman
Reactions:
Posts: 65
Joined: 28 Jan 2023, 15:34
Plugins: Showcase Store

Plugin Creator

Platform

Re: GUI Compendium

Post by NotPFA » 10 Mar 2023, 13:30

Subscribe: https://bit.ly/40vXeWP
Join (and share) this discord server: https://discord.gg/geuMNCVbth
Download this plugin: https://bit.ly/3kZ6XVI
User avatar
erksmit
Villager
Reactions:
Posts: 24
Joined: 02 Mar 2018, 10:39
Plugins: Showcase Store
Version: Beta

Plugin Creator

Re: GUI Compendium

Post by erksmit » 19 Mar 2023, 18:03

its no matter, i will just draw the ninepatch
User avatar
Armin Hpj
Metropolitan
Reactions:
Posts: 148
Joined: 11 Jan 2024, 07:47

Plugin Creator

Platform

Re: GUI Compendium

Post by Armin Hpj » 15 Apr 2024, 19:29

Lobby wrote: 05 Dec 2020, 11:03 Thanks!

Although it's kind of a hack you can actually get the GUI object of the dialog window by calling dialog.content:getParent()

Here's how it would look like to add a color to a dialog:

Code: Select all    Reset

local function decorateDialog(dialog) local panelRoot = dialog.content:getParent() local pl, pt, pr, pb = panelRoot:getPadding() -- Extract padding information to place overlay panel correctly local panelOverlay = panelRoot:addPanel{onDraw = function(self, x, y, w, h) Drawing.setColor(100, 255, 200) Drawing.drawNinePatch(NinePatch.PANEL, x, y, w, h) -- Here the drawing of the overlay happens end} panelOverlay:setChildIndex(1) -- Ensure that the overlay is drawn directly on top of the window before other stuff panelOverlay:setPosition(-pl, -pt) panelOverlay:setSize(panelOverlay:getWidth()+pl+pr, panelOverlay:getHeight()+pt+pb) end function script:buildCityGUI() local dialog = GUI.createDialog{ icon = Icon.SETTINGS, title = 'Title', text = 'Text', width = 180, height = 100, closable = true, pause = true, actions = { {icon = Icon.CANCEL, text = Translation.control_cancel}, {icon = Icon.OK, text = Translation.control_ok, golden = true} } } decorateDialog(dialog) end
Lua editor
Run
The result:
image.png
width and height write a 1000, lock, that is a full dialog
User avatar
Armin Hpj
Metropolitan
Reactions:
Posts: 148
Joined: 11 Jan 2024, 07:47

Plugin Creator

Platform

Re: GUI Compendium

Post by Armin Hpj » 15 Apr 2024, 19:41

:lua: allow click tool to open dialog

lock at this lua script

Code: Select all    Reset

local function dialog() local dialog = GUI.createDialog{ icon = Icon.SETTINGS, title = 'Title', text = 'Text', width = 1000, height = 1000, closable = true, pause = true, actions = { {icon = Icon.CANCEL, text = Translation.control_cancel}, {icon = Icon.OK, text = Translation.control_ok, golden = true} } } end function script:event(_, _, _, event) if event == Script.EVENT_TOOL_ENTER then GUI.get('cmdCloseTool'):click() dialog() end end
Lua editor
Run
User avatar
Syn
Small-town resident
Reactions:
Posts: 29
Joined: 07 Jan 2021, 05:55

Plugin Creator

Platform

Re: GUI Compendium

Post by Syn » 28 Mar 2026, 04:12

Have a question if I basically want to overhaul the game main GUI does that mean I basically code it by myself from scratch like say I need to rebuild it myself, because if yes then the project is scrapped before it even began