Page 2 of 2

Re: GUI Compendium

Posted: 07 Apr 2021, 20:33
by Eiyu
thank’s i used it for this:

Code: Select all

  local function text()
  	local iconFrame=Draft.getDraft('$pickle_kets_icon'):getFrame()
  local dialog = GUI.createDialog{
    icon = iconFrame,   -- Icon of the dialog
    title = 'Ket Options',        -- Title of the dialog
			    text = 'Here are the ket ontions{Other[*send a gift to pickle(50 kets)tiping kets(10)]Geting kets[*Buy 15 kets for 20 theos]seveces[*fire deparment28 coses 30 kets]buying rockets[*get Pmars for 5000 kets*get Trocket for 900 kets*get a shuttle for 1,000,000 kets]}On the text feld enter your command.',          
    width = 300,            
    height = 180,          
    closeable = true,       
    pause = false,           
    onUpdate = function() end,   
    onCancel = function() end,  
    onClose = function() end,
    actions = {
      
      {
        id = '$cmdOk',  
        icon = Icon.PLUS,     
        text = "Done",      
        onClick = function() end,
        golden = false
      }
    }
  }
  
local parent = dialog.controls:getFirstPart()

local textField = parent:addTextField{
  text = 'Enter Command',
  height = 30,
  width = 200
}
textField:setText('')
textField:getChild(1):setColor(255,0,255)
end


function script:buildCityGUI()
	--Debug.toast('In buildCityGUI in Kets.lua')
	--Debug.toast('Hi Charles!')
	local iconFrame=Draft.getDraft('$pickle_kets_icon'):getFrame()
	local budget = GUI.get('cmdBudget')
	local bottomBar = budget:getParent()
	local width = budget:getWidth()
	local height = budget:getHeight()
	local button=bottomBar:getCenterPart():addButton{
		width=width,
		height=height,
		icon=iconFrame,
		text='Ket options',
		golden=true,
		--frameDefault=Icon.NP_BLUE_BUTTON,
		onClick=function(self)
			-- Debug.toast('clicked')
			text()
		end
	}
end
Note from Bearbear76: You can use the code tag for code. It look prettier doesn't it? :)

Re: GUI Compendium

Posted: 24 Jun 2021, 16:21
by 1Code
Lobby wrote:
03 Dec 2020, 23:29
Yeah, you would have to implement your own dialog or try to add a GUI object that covers it and draws something else. An easier option would probably be to use privileged placing features to change look of dialogs in general.
What do you mean about privileged placing features?

Re: GUI Compendium

Posted: 04 Sep 2021, 15:55
by opschnecke
Can i Use own pictures as for example Button Icons? :lua:

Re: GUI Compendium

Posted: 22 Nov 2021, 04:28
by Yakka
I need some help to make an list box because the list content didn't show up on the game.
Screenshot_2021-11-22-09-23-20-279_info.flowersoft.theotown.theotown.jpg

Code: Select all    Reset

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 listBox = parent:addListBox{ x = 10, y = 10, width = -10, height = -10 } for i = 0, 10 do local entry = listBox:addCanvas{h=30} entry:addLabel{ text = name, x = height + 5, w = -30 }:setFont(Font.SMALL) entry:addButton{ icon = Icon.COPY, x = -30, w = 26, onClick = function() Runtime.setClipboard(name) Debug.toast('Put '..name..' into clipboard') end } 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 addItems(Icon, Icon.keys, 'Icon', 26, function(item, x, y, w, h) Drawing.drawImage(item, x, y) end) addItems(NinePatch, NinePatch.keys, 'NinePatch', 26, function(item, x, y, w, h) Drawing.drawNinePatch(item, x, y, w, h) end) addItems(Font, Font.keys, 'Font', 26, function(item, x, y, w, h) Drawing.setColor(0, 0, 0) Drawing.drawText('Abc', x+w/2, y+h/2, item, 0.5, 0.5) Drawing.reset() end) end
Lua editor
Run

Re: GUI Compendium

Posted: 22 Nov 2021, 10:00
by Lobby
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.

Re: GUI Compendium

Posted: 22 Nov 2021, 12:27
by Yakka
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

Re: GUI Compendium

Posted: 22 Nov 2021, 23:40
by Lobby
Did you use "strict lua":true in your json? I assume the script crashed, eg. in line 17 height is not defined.

Re: GUI Compendium

Posted: 24 Nov 2021, 12:09
by Wepf
I guess it actually a time to put my brain in garbage incerator

Re: GUI Compendium

Posted: 25 Dec 2021, 17:51
by Yakka
Is there a way to add translation on custom gui,
I mean i want GUI A text and title translated into English and indonesian.

Re: GUI Compendium

Posted: 11 Jul 2022, 03:40
by Marvel
Lobby wrote:
05 Sep 2020, 10:42
<the original post>
Ok So where we need to place the file are iys need json or something like that?

Re: GUI Compendium

Posted: 03 Jan 2023, 11:12
by erksmit
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

Re: GUI Compendium

Posted: 13 Jan 2023, 07:17
by Guest
erksmit wrote:
03 Jan 2023, 11:12
See above me
It isn't possible

Re: GUI Compendium

Posted: 14 Jan 2023, 23:08
by Guest
Kiki012 wrote:
25 Dec 2021, 17:51
Click or scroll up
https://doc.theotown.com/modules/TheoTo ... lateInline

Re: GUI Compendium

Posted: 17 Jan 2023, 21:12
by erksmit
Theotronic Arts wrote:
13 Jan 2023, 07:17
erksmit wrote:
03 Jan 2023, 11:12
See above me
It isn't possible
Why isn't it possible.

Re: GUI Compendium

Posted: 09 Feb 2023, 16:01
by erksmit
Can i pass a ninepatch to use when creating a panel object? The examples don't include any mention of this.

Re: GUI Compendium

Posted: 09 Feb 2023, 17:10
by erksmit
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.

Re: GUI Compendium

Posted: 10 Mar 2023, 15:30
by NotPFA

Re: GUI Compendium

Posted: 19 Mar 2023, 20:03
by erksmit
its no matter, i will just draw the ninepatch

Re: GUI Compendium

Posted: 15 Apr 2024, 21:29
by Armin Hpj
Lobby wrote:
05 Dec 2020, 13: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

Re: GUI Compendium

Posted: 15 Apr 2024, 21:41
by Armin Hpj
: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