Skip to content

Instantly share code, notes, and snippets.

@acerspyro
Created July 28, 2017 17:58
Show Gist options
  • Save acerspyro/25d648ade8462947727723f08941375b to your computer and use it in GitHub Desktop.
Save acerspyro/25d648ade8462947727723f08941375b to your computer and use it in GitHub Desktop.
ui_settings_tab_active = 0
// Temporary storage area
// Create a nested sidebar on the left of the window.
// Used primarily for the Settings menus.
// usage: uisidebar [
// [tabname tabtooltip]
// ] [tabcontentslist]
// uisidebar 1:[tabname tabtooltip] 2:[tabchildren]
uisidebar = [
uihlist 0 [
uiclamp 1 1 1 1
uivlist 0 [
uiclamp 1 1 1 1
loop i (>> (listlen $arg1) 1) [
uiskinborder 0 0 $ui_main1 $ui_main2 $ui_main3 $ui_line $colourred $colourpink [
uialign 1
uirelease [ui_settings_tab_active = $i]
uihlist 0 [
uispace 0 0.010
uivlist 0 [
uispace 0.075 0
uitext (at $arg1 (<< $i 1)) $ui_textlarge
]
]
uitooltip (at $arg1 (+ (<< $i 1) 1))
]
]
]
uivlist 0 [
uiclamp 1 1 1 1
doargs (at $arg2 $ui_settings_tab_active)
]
]
]
uimenu "selector" "Configure item" "textures/icons/settings" [
uivlist 0 [
uitext $selectorlabel
loop i (getchoicecount) [
uichecktext (getchoicelabel $i) (= (getchoice) $i) $ui_buttonw $ui_buttonh [
setchoice $i
uiclose "selector"
] $colouryellow $ui_default
]
]
] [] [] [] 2 [] 0 8
// This function generates a fancy dropdown / selector UI element.
// Usage: ui_settings_selector [variables] [choiceval (...) choicename choicecolour] <label> (width)
// ^-- One choiceval per variable
// Example:
// ui_settings_selector "shaderdetail soundvol" [
// 1 255 Low @colourgreen
// 2 128 Medium @colouryellow
// 3 0 High @colourred
// ] "Shaders and volume" 0.050
//
// Doesn't make sense. Doesn't have to.
//
// The first argument is a list of all variables that need to be changed. In this
// case, shaderdetail and soundvol.
//
// Second argument is a list with all of the available options, each row containing
// as many values as there are variables, plus the label for the individual option
// and the colour of that label. In this case, we have two variables to change for
// each. The first row tells us to set shaderdetail to 1 and soundvol to 255.
//
// The third and fourth arguments are the button label and the button width,
// respectively.
ui_settings_selector = [
if $arg4 [] [arg4 = 0]
varlist = $arg1
vallist = $arg2
selectorlabel = $arg3
// Shorthand to return the current value of the given variable ID
// Usage: getvarat <ID>
getvarat = [
$(result (at $varlist $arg1))
]
lastid = [
- (listlen $arg1) 1
]
// Stores the amount of choices available to the user
// Usage: $getchoicecount
getchoicecount = (div (listlen $vallist) (+ (listlen $varlist) 2))
// Compares the values found in $vallist against the current variable values to find out which choice is currently active
// Usage: getchoice
getchoice = [
curchoice = -1
loop i $getchoicecount [
tempischoice = 1
loop j (listlen $varlist) [
if (!= (getvarat $j) (at $vallist (+ (* $i (+ (listlen $varlist) 2)) $j))) [
if (!=f (getvarat $j) (at $vallist (+ (* $i (+ (listlen $varlist) 2)) $j))) [
tempischoice = 0
]
]
]
if ($tempischoice) [
curchoice = $i
]
]
result $curchoice
]
// Applies a choice's values, designated by its choice ID
// Usage: setchoice <ID>
setchoice = [
loop i (listlen $varlist) [
(at $varlist $i) (at $vallist (+ (* $arg1 (+ (listlen $varlist) 2)) $i))
]
]
// Grabs the given choice ID's label and returns it
// Usage: getchoicelabel <ID>
getchoicelabel = [
tempval = (at $vallist (+ (* $arg1 (+ (listlen $varlist) 2)) (listlen $varlist)))
if (|| (=s $tempval "") (= $arg1 -1)) [
tempval = "Custom"
]
result $tempval
]
// Grabs the given choice ID's label colour and returns it
// Usage: getchoicecolour <ID>
getchoicecolour = [
tempval = (at $vallist (+ (* $arg1 (+ (listlen $varlist) 2)) (+ (listlen $varlist) 1)))
if (|| (= $tempval "") (= $arg1 -1)) [
tempval = @colourgrey
]
result $tempval
]
uihlist 0 [
uibuttonarea 0 0 [
setchoice (- (getchoice) 1)
] 0 [
uivlist 0 [
uispace 0.010 0
uitext "-" $ui_text
]
] (? (= (getchoice) 0) 1 0)
uibuttonarea 0 0 [
uiopen "selector" 0
] 0 [
uivlist 0 [
uispace $arg4 0
uitext (format "^f[%1]%2" (getchoicecolour (getchoice)) (getchoicelabel (getchoice))) $ui_text
]
]
uibuttonarea 0 0 [
setchoice (+ (getchoice) 1)
] 0 [
uivlist 0 [
uispace 0.010 0
uitext "+" $ui_text
]
] (? (< (getchoice) (- $getchoicecount 1)) 0 1)
]
]
uimenu "settings" "Settings" "textures/icons/settings" [
uihlist 0 [
uitable $ui_padbutton $ui_padbutton [
uitablerow [
uiskinborder 0 0 $ui_main1 $ui_main2 $ui_main3 $ui_line $colourred $colourpink [
uiclamp 1 1 1 1
uirelease [uiopen "videosettings" 0]
uihlist 0 [
uispace 0 0.075
uivlist 0 [
uispace 0.100 0
uiimage "textures/icons/video" $ui_default 0 $ui_imglist $ui_imglist
uitext "Video" $ui_textlarge
]
]
] [uiclamp 1 1 1 1]
uispace $ui_padtiny 0
uiskinborder 0 0 $ui_main1 $ui_main2 $ui_main3 $ui_line $colourred $colourpink [
uiclamp 1 1 1 1
uirelease [uiopen "audiosettings" 0]
uihlist 0 [
uispace 0 0.075
uivlist 0 [
uispace 0.100 0
uiimage "textures/icons/audio" $ui_default 0 $ui_imglist $ui_imglist
uitext "Audio" $ui_textlarge
]
]
] [uiclamp 1 1 1 1]
]
uitablerow [
uiskinborder 0 0 $ui_main1 $ui_main2 $ui_main3 $ui_line $colourred $colourpink [
uiclamp 1 1 1 1
uirelease [uiopen "gamesettings" 0]
uihlist 0 [
uispace 0 0.075
uivlist 0 [
uispace 0.100 0
uiimage "textures/icons/game" $ui_default 0 $ui_imglist $ui_imglist
uitext "Game" $ui_textlarge
]
]
] [uiclamp 1 1 1 1]
uispace $ui_padtiny 0
uiskinborder 0 0 $ui_main1 $ui_main2 $ui_main3 $ui_line $colourred $colourpink [
uiclamp 1 1 1 1
uirelease [uiopen "advancedsettings" 0]
uihlist 0 [
uispace 0 0.075
uivlist 0 [
uispace 0.100 0
uiimage "textures/icons/settings" $ui_default 0 $ui_imglist $ui_imglist
uitext "Advanced" $ui_textlarge
]
]
] [uiclamp 1 1 1 1]
]
]
]
]
uimenu "videosettings" "Video Settings" "textures/icons/video" [
uisidebar [
"Graphics" "Configure visual quality."
"Display" "Configure display output."
] [
[
uivlist 0 [
uihlist $ui_padsmall [
uiclamp 1 1
uitext "Shaders: "
ui_settings_selector "shaderdetail" [
1 Low @colourgreen
2 Medium @colouryellow
3 High @colourred
] "Shaders" 0.050
]
uihlist 0 [
uivlist $ui_padsmall [
uialign -1 -1
uihlist 0 [uialign -1; uitext "Water:"]
uispace $ui_padbutton 0 [
uivlist 0 [
uicheckbox "Refraction" (getvar waterrefract) $ui_checksize [waterrefract (? (getvar waterrefract) 0 1)] $colourred 0 $ui_default [uialign -1] 0 $ui_text
uicheckbox "Reflection" (getvar waterreflect) $ui_checksize [waterreflect (? (getvar waterreflect) 0 1)] $colourred 0 $ui_default [uialign -1] 0 $ui_text
uicheckbox "Environment Map" (getvar waterenvmap) $ui_checksize [waterenvmap (? (getvar waterenvmap) 0 1)] $colourred 0 $ui_default [uialign -1] 0 $ui_text
]
]
]
uivlist $ui_padsmall [
uialign -1 -1
uihlist 0 [uialign -1; uitext "Waterfalls:"]
uispace $ui_padbutton 0 [
uivlist 0 [
uicheckbox "Refraction" (getvar waterfallrefract) $ui_checksize [waterfallrefract (? (getvar waterfallrefract) 0 1)] $colourred 0 $ui_default [uialign -1] 0 $ui_text
uicheckbox "Reflection" (getvar waterfallenv) $ui_checksize [waterfallenv (? (getvar waterfallenv) 0 1)] $colourred 0 $ui_default [uialign -1] 0 $ui_text
]
]
]
]
uihlist $ui_padsmall [
uiclamp 1 1
uitext "Shadows: "
ui_settings_selector [
shadowmap
shadowmapsize
blurshadowmap
blobs
] [
0 9 1 0 Off @colourgrey
0 9 1 1 Low @colourgreen
1 9 1 0 Medium @colouryellow
1 10 2 0 High @colourred
] "Shadows" 0.050
]
uihlist $ui_padsmall [
uiclamp 1 1
uitext "Glare: "
ui_settings_selector [
blurglare
glarescale
] [
0 0 Off @colourgrey
4 1 Subtle @colouryellow
3 2 Glowy @colourred
7 1 Soft @colouryellow
7 2 Intense @colourred
] "Glare" 0.050
]
uihlist $ui_padsmall [
uiclamp 1 1
uitext "Motion Blur: "
ui_settings_selector [
motionblur
motionblurscale
] [
0 0 Off @colourgrey
1 0.5 Low @colourgreen
1 1 High @colourred
] "Motion Blur" 0.050
]
uihlist $ui_padsmall [
uiclamp 1 1
uitext "Dynamic Lights: "
ui_settings_selector [
maxdynlights
] [
0 Off @colourgrey
3 Low @colourgreen
4 Medium @colouryellow
5 High @colourred
] "Dynamic Lights" 0.050
]
uihlist $ui_padsmall [
uiclamp 1 1
uitext "Soft Particles: "
ui_settings_selector [
depthfx
depthfxsize
blurdepthfx
] [
0 7 1 Off @colourgrey
1 7 1 Low @colourgreen
1 10 0 Medium @colouryellow
1 12 0 High @colourred
] "Soft Particles" 0.050
]
uihlist $ui_padsmall [
uiclamp 1 1
uicheckbox "Glass Reflections" (getvar glassenv) $ui_checksize [glassenv (? (getvar glassenv) 0 1)] $colourred 0 $ui_default [uialign -1] 0 $ui_text
]
]
]
[]
]
] [ui_settings_tab_active = 0]
uimenu "audiosettings" "Audio Settings" "textures/icons/audio" [
]
uimenu "gamesettings" "Game Settings" "textures/icons/game" [
]
uimenu "advancedsettings" "Advanced Settings" "textures/icons/settings" [
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment