Page 1 of 1
Chili - Toggle window visiblity?
Posted: 20 Mar 2012, 16:43
by Nerris
Hey all,
I was wondering if anybody had a way to toggle the visibility of certain portions of a Chili interface? I have several sub-menus that need to be accessed during the course of gameplay and was looking at Chili as a means to implement this. The issue is of course that many of the menus should only be visible at certain times.
Currently the only way I see of doing this is to set all Chili elements to null, then redefine the whole interface. I was looking for a cleaner way of handling this, hopefully a simple 'visible' field that I can toggle.
Does anything like this exist already?
Re: Chili - Toggle window visiblity?
Posted: 20 Mar 2012, 17:13
by smoth
Code: Select all
local function HideShowResearch()
if WG.uiElementRegistry["research"] == true then
researchItemsClosed = false
end
if researchItemsClosed == true then
img_researcharrow.file = "bitmaps/ui/arrow_right.png";
img_researcharrow:Invalidate();
if WG.myFaction == "zeon" then
(Chili.Screen0):AddChild(researchBarZeon)
else
(Chili.Screen0):AddChild(researchBarFed)
end
newItems = false
NewItemGlow()
researchItemsClosed = false
else
img_researcharrow.file = "bitmaps/ui/arrow_left.png";
img_researcharrow:Invalidate();
(Chili.Screen0):RemoveChild(researchBarZeon);
(Chili.Screen0):RemoveChild(researchBarFed);
researchItemsClosed = true
end
end
from my research widget.
look at add and remove child calls.
Re: Chili - Toggle window visiblity?
Posted: 20 Mar 2012, 17:15
by jK
when you got latest github chili repo (
https://github.com/jk3064/chiliui/blob/ ... t.lua#L390)
Note, these changes were never commited to ZK.
Re: Chili - Toggle window visiblity?
Posted: 20 Mar 2012, 17:20
by Nerris
That was extremely fast, and extremely useful.
I clearly need to rethink how I'm using Chili a little, as I've been basing my work mostly of the tutorial and not the Chili code itself. Your use of AddChild/RemoveChild has answered a lot of questions/issues I was having.
Thanks for your time.
I expect I'll be releasing a beta to the community in the near future.
Re: Chili - Toggle window visiblity?
Posted: 20 Mar 2012, 17:41
by smoth
Use JK's method if you can manage getting the newer version of Chili. JK is the Developer of Chili, as such his advice is more sound than mine.
Re: Chili - Toggle window visiblity?
Posted: 20 Mar 2012, 19:49
by Nerris
Good Advice.
The Show(), Hide() method is working much cleaner as I jump back and forth between menus. Any chance there's a way to initialize a window as hidden, or should I simply create the object and then call Hide() immediately?
Re: Chili - Toggle window visiblity?
Posted: 20 Mar 2012, 21:44
by smoth
Create then hide