Jump to content

Game menu Tabber


Slimwaffle
 Share

Recommended Posts

So I am wanting to know how I go about showing different panels based on the item selected in the tabber widget. So basically if I select the buildings2 tab it shows a different panel that is blank. Because right now it shows the same panel regardless of what I choose.

I will post the code I have.

  

	--Create a Crafting panel (CRAFTING SCREEN)
	widget = Widget:Tabber(indent,indent,craftingpanel:GetClientSize().x-indent*2,craftingpanel:GetClientSize().y-indent*2,craftingpanel)
	widget:AddItem("Buildings1",false)
	widget:AddItem("Buildings2",false)
	craftingpanel:SetObject("backgroundcolor",Vec4(0.15,0.15,0.15,1))
	
	GameMenu.tabber = widget

	local indent = 12
	cpanel = Widget:Panel(indent,indent,widget:GetClientSize().x-indent*2,widget:GetClientSize().y-indent*2-30,widget)
	cpanel:SetBool("border",false)
	
	cpanel2 = Widget:Panel(indent,indent,widget:GetClientSize().x-indent*2,widget:GetClientSize().y-indent*2-30,widget)
	cpanel2:SetBool("border",false)
	cpanel2:Hide()
	GameMenu.cpanel={}
	GameMenu.cpanel.general=ipanel

	GameMenu.closecrafting = Widget:Button("Close",widget:GetClientSize().x-72-indent,widget:GetClientSize().y-28-5,72,28,widget)
	
	local y=20
	local sep=40

	--CRAFTING TAB START
	
Widget:Label("Wood Buildings",20,y,200,16,cpanel)
	y=y+16
	
	GameMenu.wbase = Widget:Button("Foundation",10,y,80,30,cpanel)
	GameMenu.wwall = Widget:Button("Wall",100,y,80,30,cpanel)
	GameMenu.wroof = Widget:Button("Roof",190,y,80,30,cpanel)
	GameMenu.wdoorway = Widget:Button("Doorway",280,y,80,30,cpanel)
	GameMenu.wwindow = Widget:Button("Window",370,y,80,30,cpanel)
	y=y+sep

 

Link to comment
Share on other sites

I could be wrong but I believe the tabber is an illusion of sorts that requires the programmer to create the effect of changing tabs by showing and hiding the other gui elements depending on which tab is selected.

EDITED -- Added panels to allow for grouping of gui elements to make showing and hiding for the different tabs easier.

example:

local window = Window:Create("tabber example",0,0,400,300,Window.Titlebar+Window.Center)
local context = Context:Create(window)
local gui = GUI:Create(context)

tabber = Widget:Tabber(20,20,300,150,gui:GetBase())
tabber:AddItem("Buildings1", true)
tabber:AddItem("Buildings2",false)
tabber:AddItem("Buildings3",false)

panel0 = Widget:Panel(0,0,300,150,tabber)
wbase = Widget:Button("Foundation",10,60,80,30,panel0)

panel1 = Widget:Panel(0,0,300,150,tabber) 
wwall = Widget:Button("Wall",100,60,80,30,panel1)
checkbox = Widget:Button("Checkbox",10,60,76,26,panel1)
checkbox:SetString("style","Checkbox")
panel1:Hide()

panel2 = Widget:Panel(0,0,300,150,tabber)
wroof = Widget:Button("Roof",190,60,80,30,panel2)
panel2:Hide()

while not window:KeyHit(Key.Escape) do
	if window:Closed() then return false end
        
	while EventQueue:Peek() do
		local event = EventQueue:Wait()
		if event.source == tabber then 
			if event.data == 0 then 
				panel0:Show()
				panel1:Hide()
				panel2:Hide()
			elseif event.data == 1 then
				panel0:Hide()
				panel1:Show()
				panel2:Hide()
			else
				panel0:Hide()
				panel1:Hide()
				panel2:Show()
			end
		end
	end
	context:Sync()
end

 

tabber2.jpg

  • Like 2
  • Thanks 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...