So I figured I'd do a quick walkthrough of my Menu.
First is the 'Info' page, which I'll probably rename. I have a lot of todos for this but for now it is what comes up when the user presses 'Shift+Esc'.
If there's a credits.txt in the root of the game archive (or folder) it'll also show that. I mostly wanted this for BAR so I could put music credits since it's least I could do for the artists.
Next is the 'Interface' tab which can be brought up with 'F11'.
It has the widget list and should contain any settings pertaining to the UI.
Right now I have skins, which list all available chili skins (dynamically, so user skins too).
And cursors which is only static right now, so it has a hardcoded list.
Then there's the 'Graphics' tab, which contains any graphic related options.
The options on the left are all engine settings and hardcoded.
The options on the right (in the red box) are settings added by widgets. I'll get to that in a sec.
It also handles different sizes/resizing gracefully
I wanted to make it easy to add options without actually touching Menu's code so I added some global functions to handle that.
For a quick example, the settings on the right in the that red box were added with this.
Code: Select all
-- WIP
function widget:GetInfo()
return {
name = 'Main Menu API? examples',
desc = 'Some examples of how to add options (and eventually tabs) to Funks Main Menu',
author = 'Funkencool',
date = '2014',
license = 'GNU GPL v2',
layer = 0,
enabled = true
}
end
local Chili
local Menu
local function change(obj)
Spring.Echo(obj.caption..' Toggled')
end
function widget:Initialize()
Chili = WG.Chili
Menu = WG.MainMenu
local widgetOptions = Chili.Control:New{
x = 0,
width = '100%',
height = 70,
padding = {0,0,0,0},
children = {
Chili.Label:New{caption='Widget Option Example',x=0,y=0},
Chili.Checkbox:New{caption='Setting 1:',width = 80,y=15,right=0,checked=false,OnChange = {change}},
Chili.Checkbox:New{caption='Setting 2:',width = 80,y=30,right=0,checked=false,OnChange = {change}},
Chili.Checkbox:New{caption='Setting 3:',width = 80,y=45,right=0,checked=false,OnChange = {change}},
Chili.Line:New{y=60,width='100%'}
}
}
Menu.AddToStack('Graphics', widgetOptions)
end
AddToStack() will add a control to a stackpanel where the red box is. This means there's no fighting with other widgets for room, since chili will handle it. The only downfall is they will only be organized depending on the order in which they're added by the widgets.
There's more to it but I'm going to work on some examples first.