diff --git a/guides/Add-Menus.md b/guides/Add-Menus.md new file mode 100644 index 0000000..d3039c8 --- /dev/null +++ b/guides/Add-Menus.md @@ -0,0 +1,75 @@ +# Adding menus to this decomp +1. Go into the charmap.txt to get a list of characters needed. +2. Add a menu into options_menu.c: + +### To enable the below features: +Add my custom code define under s32 l_counter = 0 in options_menu.c, example: +``` +// Enable my custom menus, and other features in this file. +// kelson8 +#define _CUSTOM_CODE +``` + + +### To add a menu into options_menu.c: +1. Define a string using the charmap.txt into text_options_strings.h, for example to make the word "Test" add this into that file: +``` +#define TEXT_OPT_TEST 0x1D,0x0E,0x1C,0x1D,0xFF +``` + +2. Add a string for the menu in menuStr, and define that in the text_options_strings.h, for example if the menu OPT is test add this into there +``` + #ifdef _CUSTOM_CODE + { TEXT_OPT_TEST }, + #endif //_CUSTOM_CODE +``` + +3. Add a string for the option under bindStr in options_menu.c, example: +``` +#ifdef _CUSTOM_CODE +static const u8 testStr[][8] = { + { TEXT_OPT_TEST } +}; +#endif //_CUSTOM_CODE + +``` + +4. Add a new option in options_menu.c, example: +``` +#ifdef _CUSTOM_CODE +static struct Option optsTest[] = { + // TODO Fix this to do something else. + // First option is the value of the testStr defined + DEF_OPT_SCROLL( testStr[0], &configMasterVolume, 0, MAX_VOLUME, 1 ) +}; +#endif //_CUSTOM_CODE +``` + +5. Add the menu to the SubMenu struct under menuAudio in options_menu.c, example: +``` +#ifdef _CUSTOM_CODE +// Get the value from the menuStr +static struct SubMenu menuTest = DEF_SUBMENU( menuStr[9], optsTest ); +static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[10], optsCheats ); +#else +static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[9], optsCheats ); +#endif //_CUSTOM_CODE +``` + +6. Finally, add this under optmenu_act_exit within optsMain in options_menu.c, example: +``` + #ifdef _CUSTOM_CODE + DEF_OPT_SUBMENU( menuStr[9], &menuTest ), + DEF_OPT_SUBMENU( menuStr[10], &menuCheats ) + #else + DEF_OPT_SUBMENU( menuStr[9], &menuCheats ) + #endif //_CUSTOM_CODE +``` + +### To add a title for the menu: +1. Go into include/text_options_strings.h.in +2. Add this into that file under cheats or wherever: +``` +// Add the text for the test menu +#define TEXT_OPT_TEST _("TEST") +``` \ No newline at end of file diff --git a/include/text_options_strings.h.in b/include/text_options_strings.h.in index a1ce481..8f73501 100644 --- a/include/text_options_strings.h.in +++ b/include/text_options_strings.h.in @@ -11,6 +11,10 @@ #define TEXT_OPT_VIDEO _("DISPLAY") #define TEXT_OPT_AUDIO _("SOUND") #define TEXT_OPT_CHEATS _("CHEATS") +// Add the text for the test menu +// #ifdef _CUSTOM_CODE +#define TEXT_OPT_TEST _("TEST") +// #endif //_CUSTOM_CODE // Markers diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 56dba61..0ef2539 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -1,3 +1,7 @@ + +// Add this to enable intellisense in this file, +// it is already defined in the Makefile. +#define EXT_OPTIONS_MENU #ifdef EXT_OPTIONS_MENU #include "sm64.h" @@ -40,6 +44,10 @@ static s32 l_counter = 0; // menus: add a new submenu definition and a new // option to the optsMain list +// Enable my custom menus, and other features in this file. +// kelson8 +#define _CUSTOM_CODE + static const u8 toggleStr[][16] = { { TEXT_OPT_DISABLED }, { TEXT_OPT_ENABLED }, @@ -55,7 +63,12 @@ static const u8 menuStr[][32] = { { TEXT_OPT_VIDEO }, { TEXT_OPT_AUDIO }, { TEXT_EXIT_GAME }, - { TEXT_OPT_CHEATS }, + + #ifdef _CUSTOM_CODE + { TEXT_OPT_TEST }, + #endif //_CUSTOM_CODE + + { TEXT_OPT_CHEATS } }; @@ -125,6 +138,12 @@ static const u8 bindStr[][32] = { { TEXT_OPT_RUMBLE } }; +#ifdef _CUSTOM_CODE +static const u8 testStr[][8] = { + { TEXT_OPT_TEST } +}; +#endif //_CUSTOM_CODE + static const u8 *filterChoices[] = { optsVideoStr[2], optsVideoStr[3], @@ -269,6 +288,13 @@ static struct Option optsAudio[] = { DEF_OPT_SCROLL( optsAudioStr[3], &configEnvVolume, 0, MAX_VOLUME, 1), }; +#ifdef _CUSTOM_CODE +static struct Option optsTest[] = { + // TODO Fix this to do something else. + DEF_OPT_SCROLL( testStr[0], &configMasterVolume, 0, MAX_VOLUME, 1 ) +}; +#endif //_CUSTOM_CODE + static struct Option optsCheats[] = { DEF_OPT_TOGGLE( optsCheatsStr[0], &Cheats.EnableCheats ), DEF_OPT_TOGGLE( optsCheatsStr[1], &Cheats.MoonJump ), @@ -290,7 +316,17 @@ static struct SubMenu menuCamera = DEF_SUBMENU( menuStr[4], optsCamera ); static struct SubMenu menuControls = DEF_SUBMENU( menuStr[5], optsControls ); static struct SubMenu menuVideo = DEF_SUBMENU( menuStr[6], optsVideo ); static struct SubMenu menuAudio = DEF_SUBMENU( menuStr[7], optsAudio ); + +// Test, this works! +#ifdef _CUSTOM_CODE +// Get the value from the menuStr +static struct SubMenu menuTest = DEF_SUBMENU( menuStr[9], optsTest ); +static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[10], optsCheats ); +#else static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[9], optsCheats ); +#endif //_CUSTOM_CODE + + /* main options menu definition */ @@ -302,8 +338,17 @@ static struct Option optsMain[] = { DEF_OPT_SUBMENU( menuStr[6], &menuVideo ), DEF_OPT_SUBMENU( menuStr[7], &menuAudio ), DEF_OPT_BUTTON ( menuStr[8], optmenu_act_exit ), - // NOTE: always keep cheats the last option here because of the half-assed way I toggle them + + // Test, this works! + #ifdef _CUSTOM_CODE + DEF_OPT_SUBMENU( menuStr[9], &menuTest ), + DEF_OPT_SUBMENU( menuStr[10], &menuCheats ) + #else DEF_OPT_SUBMENU( menuStr[9], &menuCheats ) + #endif //_CUSTOM_CODE + + // NOTE: always keep cheats the last option here because of the half-assed way I toggle them + // DEF_OPT_SUBMENU( menuStr[10], &menuCheats ) }; static struct SubMenu menuMain = DEF_SUBMENU( menuStr[3], optsMain );