Last active
October 8, 2019 03:34
-
-
Save Jigoku/6c15195216322ee2aa5a8cbf2e408bbc to your computer and use it in GitHub Desktop.
dynamically populate skyboxes in editor menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- config/ui/editing.cfg.orig 2019-10-07 18:04:42.231178909 +0100 | |
+++ config/ui/editing.cfg 2019-10-07 20:53:22.208977263 +0100 | |
@@ -95,6 +95,22 @@ | |
//for prefabs ui | |
ui_prefabs = "" | |
+//for skybox ui | |
+ui_skyboxes = "" //list of skyboxes | |
+ui_skyboxes_find = [ //search directory for skybox files | |
+ loop i ($numargs) [ | |
+ arg = $[arg@(+ $i 1)] | |
+ loopfiles f $arg png [ | |
+ if ( >= (strstr $f "_lf") 0) [ | |
+ ui_skyboxes = (concat $ui_skyboxes (concatword $arg / (substring $f 0 (strstr $f "_")))) | |
+ ] | |
+ ] | |
+ ] | |
+] | |
+ui_glob_files = "" //glob the top level files | |
+loopfiles f "./" "" [ ui_glob_files = (concat $ui_glob_files $f) ] | |
+loop z (listlen $ui_glob_files) [ ui_skyboxes_find (at $ui_glob_files $z) ] //check all top level directories | |
+ | |
//UI menus in this file (in order), formatted as menuname@[linenumber] | |
// textures@104 materials_getbindicon,materials@269,283 liquids_rgbsliders,liquids_horzsliders,liquids_water_body,liquids_lava_body,liquids@402,415,441,464,480 | |
// skybox_entry,skybox_body,skybox@536,549,570 altskybox@574 edit@578 editsettings@604 environment@777 map@953 obituaries@1122 coopedit@1141 | |
@@ -529,42 +545,36 @@ | |
] | |
//This is the normal skybox menu {forcemapvariant 1} | |
-//All skyboxes here and in uimenu altskybox are hard coded and any new skyboxes need to be added here in order to show up. | |
-//Follow the argument description for ui_skybox_entry for info on how to add entries. Each ui_skybox_entry is designed for two skyboxes. | |
-//The UI closes after selecting each option. This can be changed by removing the >uiclose @arg5 line from each button. | |
+//Follow the argument description for ui_skybox_entry for info on how to add entries. | |
+//The UI closes after selecting each option. This can be changed by removing the >uiclose @arg3 line from each button. | |
//ui_skybox_entry describes individual rows | |
-ui_skybox_entry = [//arg1: desc1 arg2: path1 arg3: desc2 arg4: path2 arg5: ui to close arg6:path to icon1 arg7:path to icon2 | |
+ui_skybox_entry = [//arg1: desc arg2: path arg3: ui to close arg4: path to icon | |
uihlist $ui_padbutton [ // making each row contain two entries | |
- uichecktextbutton $arg1 $arg6 0 $ui_buttonw $ui_buttonh [ | |
- @arg5 = $arg2 | |
- uiclose @arg5 | |
- ] $colourwhite $ui_default | |
- uichecktextbutton $arg3 $arg7 0 $ui_buttonw $ui_buttonh [ | |
- @arg5 = $arg4 | |
- uiclose @arg5 | |
+ uichecktextbutton $arg1 $arg4 0 $ui_buttonw $ui_buttonh [ | |
+ @arg3 = $arg2 | |
+ uiclose @arg3 | |
] $colourwhite $ui_default | |
] | |
] | |
+ | |
+ | |
//contents of the skybox uis (done so that the same code can cover both the normal and alt cases) | |
ui_skybox_body = [//arg1: ui to close | |
- uivlist $ui_padsmaller [ | |
- uichecktextbutton "None" "" 0 $ui_buttonw $ui_buttonh [ //leaving the no-skybox option in its own row (rest are 2 entry rows) | |
- skybox = "" | |
- uiclose $arg1 | |
- ] $colourwhite $ui_default | |
- ui_skybox_entry "Arch3" "elyvisions/arch3" "Cave3" "elyvisions/cave3" $arg1 "elyvisions/arch3_lf" "elyvisions/cave3_up" | |
- ui_skybox_entry "Clouds" "skyboxes/clouds2" "Dark" "elyvisions/dark" $arg1 "skyboxes/clouds2_up" "elyvisions/dark_rt" | |
- ui_skybox_entry "Gradient" "skyboxes/gradient" "Grey" "skyboxes/grey" $arg1 "skyboxes/gradient_up" "skyboxes/grey_up" | |
- ui_skybox_entry "Hot" "elyvisions/hot" "Interstellar" "skyboxes/interstellar" $arg1 "elyvisions/hot_rt" "skyboxes/interstellar_up" | |
- ui_skybox_entry "Miramar" "skyboxes/miramar" "Rainbow" "elyvisions/rainbow" $arg1 "skyboxes/miramar_up" "elyvisions/rainbow_rt" | |
- ui_skybox_entry "Sh" "elyvisions/sh" "Skyast" "elyvisions/skyast" $arg1 "elyvisions/sh_up" "elyvisions/skyast_up" | |
- ui_skybox_entry "Skyhigh" "skyboxes/skyhigh" "Skyhsky" "elyvisions/skyhsky" $arg1 "skyboxes/skyhigh_up" "elyvisions/skyhsky_rt" | |
- ui_skybox_entry "Skylump" "skyboxes/skylump" "Skylump2" "skyboxes/skylump2" $arg1 "skyboxes/skylump_up" "skyboxes/skylump2_up" | |
- ui_skybox_entry "Skype" "elyvisions/skype" "Sp2" "elyvisions/sp2" $arg1 "elyvisions/skype_up" "elyvisions/sp2_up" | |
- ui_skybox_entry "Sp3" "elyvisions/sp3" "Stars" "skyboxes/stars" $arg1 "elyvisions/sp3_rt" "skyboxes/stars" | |
- ui_skybox_entry "Stormydays" "skyboxes/stormydays" "Sunset" "skyboxes/sunsetflat" $arg1 "skyboxes/stormydays_up" "skyboxes/sunsetflat_up" | |
- ui_skybox_entry "Tron" "elyvisions/tron" "Yellow" "skyboxes/yellow" $arg1 "elyvisions/tron_up" "skyboxes/yellow_up" | |
- ] | |
+ uiscroll 0.35 0.5 [ | |
+ uifill 0.35 0.5 [ | |
+ uivlist $ui_padsmaller [ | |
+ uichecktextbutton "None" "" 0 $ui_buttonw $ui_buttonh [ //leaving the no-skybox option in its own row | |
+ skybox = "" | |
+ uiclose $arg1 | |
+ ] $colourwhite $ui_default | |
+ //populate list of skyboxes | |
+ loop i (listlen $ui_skyboxes) [ | |
+ ui_skybox_entry (at $ui_skyboxes $i) (at $ui_skyboxes $i) $arg1 (concatword (at $ui_skyboxes $i) "_lf") | |
+ ] | |
+ ] | |
+ ] | |
+ ] | |
+ uihlist 0 [uivscroll $ui_slidersize 0.5 3; uialign 1 0; uiclamp 0 1] //scrollbar | |
] | |
//This is the skybox menu, which just tells ui_skybox_body to execute with "skybox" as its exit command | |
uimenu "skybox" "Choose Skybox" $questiontex [ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment