Skip to content

Instantly share code, notes, and snippets.

@Broxzier
Created April 22, 2024 09:24
Show Gist options
  • Save Broxzier/8f6fac81d225a3694bdb76ac209ba23c to your computer and use it in GitHub Desktop.
Save Broxzier/8f6fac81d225a3694bdb76ac209ba23c to your computer and use it in GitHub Desktop.
Window layout language
var Element={x=0,y=0,width=0,height=0,ratio=1.0f,};var Button:Element={class="Button",width=256,height=48,text="Default text",colour={r=0.5f,g=0.5f,b=0.5f,},};var GUI={class="HorizontalBox",x=0,y=0,width=640,height=480,margin=15.0f,Left={class="VerticalBox",margin=5.0f,ratio=1.0f,Btn_home:Button={text="Home",},Button_2:Button={text="Something else",},Button_exit:Button={text="Exit",colour={r=1.0f,g=0.3f,b=0.3f,},action="Exit",},Button:Button={text="This is a very big button",ratio=3.0f,},},Right={class="VerticalBox",margin=0.0f,ratio=1.5f,Top={class="VerticalBox",ratio=1.0f,margin=5.0f,ButtonA:Button,ButtonB:Button,},Middle={class="HorizontalBox",ratio=2.0f,margin=5.0f,ButtonA:Button={colour={r=0.2f,g=0.2f,b=0.2f,},text="I am original!",},ButtonB:Button,},Bottom={class="VerticalBox",ratio=1.0f,margin=5.0f,ButtonA:Button={action="Toggle",text="Toggle me",colour={r=0.3f,g=0.3f,b=1.0f,},toggle_colour={r=0.3f,g=1.0f,b=0.3f,},},ButtonB:Button,},},};
// Some default colours
var black = { r = 0.0f, g = 0.0f, b = 0.0f, };
var white = { r = 1.0f, g = 1.0f, b = 1.0f, };
var grey = { r = 0.5f, g = 0.5f, b = 0.5f, };
var lightgrey = { r = 0.8f, g = 0.8f, b = 0.8f, };
var darkgrey = { r = 0.3f, g = 0.3f, b = 0.3f, };
var red = { r = 1.0f, g = 0.0f, b = 0.0f, };
var green = { r = 0.0f, g = 0.5f, b = 0.0f, };
var blue = { r = 0.0f, g = 0.0f, b = 1.0f, };
var lightred : red = { g = 0.2f, b = 0.2f, };
var lightgreen : green = { r = 0.2f, b = 0.2f, };
var lightblue : blue = { r = 0.2f, g = 0.2f, };
var ink = { r = 0.2f, g = 0.2f, b = 0.2f, };
var maroon : red = { r = 0.5f, };
var navy : blue = { b = 0.5f, };
var aqua = { r = 0.0f, g = 1.0f, b = 1.0f, };
var gold = { r = 1.0f, g = 0.8431372f, b = 0.0f, };
var darkmagenta = { r = 0.55f, g = 0.0f, b = 0.55f, };
var gray : grey;
var lightgray : lightgrey;
var darkgray : darkgrey;
/*****************************
* Base Object For UI Elements
*/
// A standalone object
var Element = {
x = 0,
y = 0,
width = 0,
height = 0,
ratio = 1.0f,
};
// Default button object
var Button : Element = {
class = "Button",
width = 256,
height = 48,
text = "Default text",
colour : darkgrey,
};
// The GUI element
var GUI = {
class = "HorizontalBox",
x = 0,
y = 0,
width = 640,
height = 480,
margin = 15.0f,
Left = {
class = "VerticalBox",
margin = 5.0f,
ratio = 1.0f,
Btn_home : Button = { text = "Home", },
Button_2 : Button = { text = "Something else", },
Button_exit : Button = {
text = "Exit",
colour : lightred,
action = "Exit",
},
Button : Button = {
text = "This is a very big button",
ratio = 3.0f,
},
},
Right = {
class = "VerticalBox",
//x = 440,
//y = 20,
//width = 180,
//height = 440,
margin = 0.0f,
ratio = 1.5f,
Top = {
class="VerticalBox",
ratio = 2.0f,
margin = 5.0f,
ButtonA : Button = { colour : lightgrey, },
ButtonB : Button,
},
Middle = {
class="HorizontalBox",
ratio = 3.0f,
margin = 5.0f,
ButtonA : Button = {
ratio = 2.0f,
colour : darkmagenta,
text = "I am original!",
},
Right = {
class = "VerticalBox",
ratio = 1.0f,
margin = 5.0f,
AButton : Button = { colour : red, text = "Red", },
BButton : Button = { colour : green, text = "Green", },
CButton : Button = { colour : blue, text = "Blue", },
},
},
Bottom = {
class="VerticalBox",
ratio = 2.0f,
margin = 5.0f,
ButtonA : Button = {
action = "Toggle",
text = "Toggle me",
ratio = 2.0f,
colour : lightblue,
toggle_colour : lightgreen,
},
ButtonB : Button,
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment