Skip to content

Instantly share code, notes, and snippets.

@mrwonko
Created May 25, 2012 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrwonko/2786928 to your computer and use it in GitHub Desktop.
Save mrwonko/2786928 to your computer and use it in GitHub Desktop.
Draft of my UI definitions
-- main menu layout:
-- title on top, buttons below
local margin = width * 0.05
local titleHeight = 100
local menuWidth = 400
Layout
{
name = "main",
-- title
VerticalLayout -- vertical layout means the items in here will be put below one another
{
name = "title",
position = { margin, margin },
size = { width - 2 * margin, titleHeight },
-- style "class" could go here (e.g.: border, bg color, bg image) - I'm postponing styles though, KISS.
},
-- main menu buttons
VerticalLayout
{
name = "mainmenu",
position = { width / 2 - menuWidth / 2, titleHeight + 2 * margin },
size = { menuWidth, height - 3 * margin - titleHeight },
},
}
-- main menu controls - title text, buttons and where they go (and in which order)
Menu
{
name = "main",
layout = "main",
Text
{
text = "Main Menu",
container = "title", -- in which layout container this goes
order = 100, -- for ordering in the container
-- style information could go here - e.g. a "class", whose properties are set via style file
},
Button
{
text = "Buttön!",
container = "mainmenu",
order = 100,
OnClick = function(self, menu)
print("Buttön has been pressed!")
end,
},
Button
{
text = "Quit!",
container = "mainmenu",
order = 200,
OnClick = function(self, menu)
EndGame()
end,
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment