Chili - Toggle window visiblity?

Chili - Toggle window visiblity?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
Nerris
Posts: 6
Joined: 10 Feb 2012, 23:20

Chili - Toggle window visiblity?

Post 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?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Chili - Toggle window visiblity?

Post 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.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Chili - Toggle window visiblity?

Post by jK »

Code: Select all

window0:Hide()
window1:Show()
when you got latest github chili repo (https://github.com/jk3064/chiliui/blob/ ... t.lua#L390)

Note, these changes were never commited to ZK.
Last edited by jK on 20 Mar 2012, 17:24, edited 1 time in total.
Nerris
Posts: 6
Joined: 10 Feb 2012, 23:20

Re: Chili - Toggle window visiblity?

Post 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.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Chili - Toggle window visiblity?

Post 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.
Nerris
Posts: 6
Joined: 10 Feb 2012, 23:20

Re: Chili - Toggle window visiblity?

Post 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?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Chili - Toggle window visiblity?

Post by smoth »

Create then hide
Post Reply

Return to “Game Development”