From c377ea1186183429d18f875a6b08cf3a00b185b0 Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Fri, 26 Nov 2021 16:36:15 +0100 Subject: [PATCH 1/3] options: data & manual --- src/k_menu.h | 49 +++++++++- src/k_menudef.c | 248 ++++++++++++++++++++++++++++++++++++++++++++++- src/k_menudraw.c | 6 +- src/k_menufunc.c | 77 +++++++++++++-- 4 files changed, 359 insertions(+), 21 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index fea9b40e5..99f651713 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -234,6 +234,26 @@ extern menuitem_t OPTIONS_ServerAdvanced[]; extern menu_t OPTIONS_ServerAdvancedDef; #endif +extern menuitem_t OPTIONS_Data[]; +extern menu_t OPTIONS_DataDef; + +extern menuitem_t OPTIONS_DataScreenshot[]; +extern menu_t OPTIONS_DataScreenshotDef; + +extern menuitem_t OPTIONS_DataAddon[]; +extern menu_t OPTIONS_DataAddonDef; + +extern menuitem_t OPTIONS_DataReplay[]; +extern menu_t OPTIONS_DataReplayDef; + +#ifdef HAVE_DISCORDRPC +extern menuitem_t OPTIONS_DataDiscord[]; +extern menu_t OPTIONS_DataDiscordDef; +#endif + +extern menuitem_t OPTIONS_DataErase[]; +extern menu_t OPTIONS_DataEraseDef; + // PAUSE extern menuitem_t PAUSE_Main[]; extern menu_t PAUSE_MainDef; @@ -241,6 +261,10 @@ extern menu_t PAUSE_MainDef; extern menuitem_t MISC_Addons[]; extern menu_t MISC_AddonsDef; +// MANUAL +extern menuitem_t MISC_Manual[]; +extern menu_t MISC_ManualDef; + // We'll need this since we're gonna have to dynamically enable and disable options depending on which state we're in. typedef enum { @@ -327,8 +351,6 @@ extern menu_t MessageDef; void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtype); void M_StopMessage(INT32 choice); -void M_HandleImageDef(INT32 choice); - void M_QuitResponse(INT32 ch); void M_QuitSRB2(INT32 choice); @@ -506,15 +528,16 @@ extern struct optionsmenu_s { INT32 vidm_column_size; modedesc_t modedescs[MAXMODEDESCS]; + + UINT8 erasecontext; } optionsmenu; void M_InitOptions(INT32 choice); // necessary for multiplayer since there's some options we won't want to access void M_OptionsTick(void); boolean M_OptionsInputs(INT32 ch); - boolean M_OptionsQuit(void); // resets buttons when you quit the options. - void M_HandleItemToggles(INT32 choice); // For item toggling +void M_EraseData(INT32 choice); // For data erasing // video modes menu (resolution) @@ -571,6 +594,9 @@ boolean M_AddonsRefresh(void); void M_HandleAddons(INT32 choice); char *M_AddonsHeaderPath(void); +void M_Manual(INT32 choice); +void M_HandleImageDef(INT32 choice); + // M_MENUDRAW.C // flags for text highlights @@ -648,4 +674,19 @@ void M_DrawAddons(void); NULL\ } +#define IMAGEDEF(source)\ +{\ + sizeof(source) / sizeof(menuitem_t),\ + NULL,\ + 0,\ + source,\ + 0, 0,\ + 1, 10,\ + M_DrawImageDef,\ + NULL,\ + NULL,\ + NULL\ +} + + #endif //__K_MENU__ diff --git a/src/k_menudef.c b/src/k_menudef.c index cf4f131d8..824facbd6 100644 --- a/src/k_menudef.c +++ b/src/k_menudef.c @@ -9,6 +9,9 @@ #include "s_sound.h" // sounds consvars #include "g_game.h" // cv_chatnotifications #include "console.h" // console cvars +#include "filesrch.h" // addons cvars +#include "m_misc.h" // screenshot cvars +#include "discord.h" // discord rpc cvars // ========================================================================== // ORGANIZATION START. @@ -320,10 +323,10 @@ menuitem_t OPTIONS_Main[] = NULL, &OPTIONS_ServerDef, 0, 0}, {IT_STRING | IT_SUBMENU, "Data Options", "Miscellaneous data options such as the screenshot format.", - NULL, NULL, 0, 0}, + NULL, &OPTIONS_DataDef, 0, 0}, - {IT_STRING | IT_SUBMENU, "Tricks & Secrets", "Those who bother reading a game manual always get the edge over those who don't!", - NULL, NULL, 0, 0}, + {IT_STRING | IT_CALL, "Tricks & Secrets", "Those who bother reading a game manual always get the edge over those who don't!", + NULL, M_Manual, 0, 0}, }; menu_t OPTIONS_MainDef = { @@ -429,7 +432,7 @@ menuitem_t OPTIONS_VideoOGL[] = {IT_SPACE | IT_NOTHING, NULL, NULL, NULL, NULL, 0, 0}, - {IT_SPACE | IT_NOTHING | IT_STRING, "OPTIONS BELOW ARE OPENGL ONLY!", "Watch people get confused anyway!!", + {IT_HEADER, "OPTIONS BELOW ARE OPENGL ONLY!", "Watch people get confused anyway!!", NULL, NULL, 0, 0}, {IT_STRING | IT_CVAR, "3D Models", "Use 3D models instead of sprites when applicable.", @@ -803,7 +806,7 @@ menu_t OPTIONS_ServerDef = { menuitem_t OPTIONS_ServerAdvanced[] = { - {IT_STRING | IT_CVAR | IT_CV_STRING, "Server Browser Address", "Default is \'https://ms.kartkew.org/ms/api\'", + {IT_STRING | IT_CVAR | IT_CV_STRING, "Server Browser Address", "Default is \'https://ms.kartkrew.org/ms/api\'", NULL, &cv_masterserver, 0, 0}, {IT_STRING | IT_CVAR, "Resynch. Attempts", "How many times to attempt sending data to desynchronized players.", @@ -857,6 +860,221 @@ menu_t OPTIONS_ServerAdvancedDef = { }; #endif +menuitem_t OPTIONS_Data[] = +{ + + {IT_STRING | IT_SUBMENU, "Screenshot Options...", "Set options relative to screenshot and GIF capture.", + NULL, &OPTIONS_DataScreenshotDef, 0, 0}, + + {IT_STRING | IT_SUBMENU, "Addon Options...", "Set options relative to the addons menu.", + NULL, &OPTIONS_DataAddonDef, 0, 0}, + + {IT_STRING | IT_SUBMENU, "Replay Options...", "Set options relative to replays.", + NULL, &OPTIONS_DataReplayDef, 0, 0}, + +#ifdef HAVE_DISCORDRPC + {IT_STRING | IT_SUBMENU, "Discord Options...", "Set options relative to Discord Rich Presence.", + NULL, &OPTIONS_DataDiscordDef, 0, 0}, +#endif + + {IT_SPACE | IT_NOTHING, NULL, NULL, + NULL, NULL, 0, 0}, + + // escape sequences don't like any letter from A to E following them... So let's also put E as an escape sequence lol. E is 69 (nice) which is 45 in hex. + {IT_STRING | IT_SUBMENU, "\x85\x45rase Data...", "Erase specific data. Be careful, what's deleted is gone forever!", + NULL, &OPTIONS_DataEraseDef, 0, 0}, + +}; + +menu_t OPTIONS_DataDef = { + sizeof (OPTIONS_Data) / sizeof (menuitem_t), + &OPTIONS_MainDef, + 0, + OPTIONS_Data, + 48, 80, + 2, 10, + M_DrawGenericOptions, + M_OptionsTick, + NULL, + NULL, +}; + +menuitem_t OPTIONS_DataAddon[] = +{ + + {IT_HEADER, "MENU", NULL, + NULL, NULL, 0, 0}, + + {IT_STRING | IT_CVAR, "Location", "Where to start searching addons from in the menu.", + NULL, &cv_addons_option, 0, 0}, + + {IT_STRING | IT_CVAR | IT_CV_STRING, "Custom Folder", "Specify which folder to start searching from if the location is set to custom.", + NULL, &cv_addons_folder, 24, 0}, + + {IT_STRING | IT_CVAR, "Identify Addons via", "Set whether to consider the extension or contents of a file.", + NULL, &cv_addons_md5, 0, 0}, + + {IT_STRING | IT_CVAR, "Show Unsupported Files", "Sets whether non-addon files should be shown.", + NULL, &cv_addons_showall, 0, 0}, + + {IT_SPACE | IT_NOTHING, NULL, NULL, + NULL, NULL, 0, 0}, + + {IT_HEADER, "SEARCH", NULL, + NULL, NULL, 0, 0}, + + {IT_STRING | IT_CVAR, "Matching", "Set where to check for the text pattern when looking up addons via name.", + NULL, &cv_addons_search_type, 0, 0}, + + {IT_STRING | IT_CVAR, "Case Sensitivity", "Set whether to consider the case when searching for addons..", + NULL, &cv_addons_search_case, 0, 0}, + +}; + +menu_t OPTIONS_DataAddonDef = { + sizeof (OPTIONS_DataAddon) / sizeof (menuitem_t), + &OPTIONS_DataDef, + 0, + OPTIONS_DataAddon, + 48, 80, + 2, 10, + M_DrawGenericOptions, + M_OptionsTick, + NULL, + NULL, +}; + +menuitem_t OPTIONS_DataScreenshot[] = +{ + + {IT_HEADER, "SCREENSHOTS (F8)", NULL, + NULL, NULL, 0, 0}, + + {IT_STRING | IT_CVAR, "Storage Location", "Sets where to store screenshots.", + NULL, &cv_screenshot_option, 0, 0}, + + {IT_STRING | IT_CVAR | IT_CV_STRING, "Custom Folder", "Specify which folder to save screenshots in.", + NULL, &cv_screenshot_folder, 24, 0}, + + {IT_SPACE | IT_NOTHING, NULL, NULL, + NULL, NULL, 0, 0}, + + {IT_HEADER, "GIF RECORDING (F9)", NULL, + NULL, NULL, 0, 0}, + + {IT_STRING | IT_CVAR, "Storage Location", "Sets where to store GIFs", + NULL, &cv_movie_option, 0, 0}, + + {IT_STRING | IT_CVAR | IT_CV_STRING, "Custom Folder", "Specify which folder to save GIFs in.", + NULL, &cv_movie_folder, 24, 0}, + +}; + +menu_t OPTIONS_DataScreenshotDef = { + sizeof (OPTIONS_DataScreenshot) / sizeof (menuitem_t), + &OPTIONS_DataDef, + 0, + OPTIONS_DataScreenshot, + 48, 80, + 2, 10, + M_DrawGenericOptions, + M_OptionsTick, + NULL, + NULL, +}; + +menuitem_t OPTIONS_DataReplay[] = +{ + + {IT_STRING | IT_CVAR, "Rich Presence", "Allow Discord to display game info on your status.", + NULL, &cv_discordrp, 0, 0}, + + {IT_STRING | IT_CVAR, "Synch. Check Interval", "How often to check for synchronization while playing back a replay.", + NULL, &cv_netdemosyncquality, 0, 0}, +}; + +menu_t OPTIONS_DataReplayDef = { + sizeof (OPTIONS_DataReplay) / sizeof (menuitem_t), + &OPTIONS_DataDef, + 0, + OPTIONS_DataReplay, + 48, 80, + 2, 10, + M_DrawGenericOptions, + M_OptionsTick, + NULL, + NULL, +}; + +#ifdef HAVE_DISCORDRPC +menuitem_t OPTIONS_DataDiscord[] = +{ + + {IT_STRING | IT_CVAR, "Record Replays", "Select when to save replays.", + NULL, &cv_recordmultiplayerdemos, 0, 0}, + + {IT_SPACE | IT_NOTHING, NULL, NULL, + NULL, NULL, 0, 0}, + + {IT_HEADER, "RICH PRESENCE SETTINGS", NULL, + NULL, NULL, 0, 0}, + + {IT_STRING | IT_CVAR, "Streamer Mode", "Prevents the logging of some account information such as your tag in the console.", + NULL, &cv_discordstreamer, 0, 0}, + + {IT_STRING | IT_CVAR, "Allow Ask to Join", "Allow other people to request joining your game from Discord.", + NULL, &cv_discordasks, 0, 0}, + + {IT_STRING | IT_CVAR, "Allow Invites", "Set who is allowed to generate Discord invites to your game.", + NULL, &cv_discordinvites, 0, 0}, + +}; + +menu_t OPTIONS_DataDiscordDef = { + sizeof (OPTIONS_DataDiscord) / sizeof (menuitem_t), + &OPTIONS_DataDef, + 0, + OPTIONS_DataDiscord, + 48, 80, + 2, 10, + M_DrawGenericOptions, + M_OptionsTick, + NULL, + NULL, +}; +#endif + + +menuitem_t OPTIONS_DataErase[] = +{ + + {IT_STRING | IT_CALL, "Erase Time Attack Data", "Be careful! What's deleted is gone forever!", + NULL, M_EraseData, 0, 0}, + + {IT_STRING | IT_CALL, "Erase Unlockable Data", "Be careful! What's deleted is gone forever!", + NULL, M_EraseData, 0, 0}, + + {IT_SPACE | IT_NOTHING, NULL, NULL, + NULL, NULL, 0, 0}, + + {IT_STRING | IT_CALL, "\x85\x45rase all Data", "Be careful! What's deleted is gone forever!", + NULL, M_EraseData, 0, 0}, + +}; + +menu_t OPTIONS_DataEraseDef = { + sizeof (OPTIONS_DataErase) / sizeof (menuitem_t), + &OPTIONS_DataDef, + 0, + OPTIONS_DataErase, + 48, 80, + 2, 10, + M_DrawGenericOptions, + M_OptionsTick, + NULL, + NULL, +}; + // ------------------- // In-game/pause menus // ------------------- @@ -968,6 +1186,26 @@ menu_t PAUSE_PlaybackMenuDef = { // Other misc menus: +// Manual +menuitem_t MISC_Manual[] = { + {IT_NOTHING | IT_KEYHANDLER, "MANUAL00", NULL, NULL, M_HandleImageDef, 0, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL01", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL02", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL03", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL04", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL05", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL06", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL07", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL08", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL09", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL10", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL11", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL12", NULL, NULL, M_HandleImageDef, 1, 0}, + {IT_NOTHING | IT_KEYHANDLER, "MANUAL99", NULL, NULL, M_HandleImageDef, 0, 0}, +}; + +menu_t MISC_ManualDef = IMAGEDEF(MISC_Manual); + // Addons menu! (Just a straight port for now) menuitem_t MISC_AddonsMenu[] = { diff --git a/src/k_menudraw.c b/src/k_menudraw.c index e8e242c87..748a57c70 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -1797,13 +1797,13 @@ void M_DrawGenericOptions(void) /* FALLTHRU */ case IT_DYLITLSPACE: case IT_SPACE: - y += SMALLLINEHEIGHT; + y += (currentMenu->menuitems[i].mvar1 ? : SMALLLINEHEIGHT); break; case IT_GRAYPATCH: if (currentMenu->menuitems[i].patch && currentMenu->menuitems[i].patch[0]) V_DrawMappedPatch(x, y, 0, W_CachePatchName(currentMenu->menuitems[i].patch,PU_CACHE), graymap); - y += LINEHEIGHT; + y += (currentMenu->menuitems[i].mvar1 ? : SMALLLINEHEIGHT); break; case IT_TRANSTEXT: if (currentMenu->menuitems[i].mvar1) @@ -2591,4 +2591,4 @@ void M_DrawAddons(void) if (modifiedgame) V_DrawSmallScaledPatch(x, y + 4, 0, addonsp[NUM_EXT+2]); -} +} \ No newline at end of file diff --git a/src/k_menufunc.c b/src/k_menufunc.c index b91276feb..86e5325bd 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -323,10 +323,10 @@ static void Dummystaff_OnChange(void) void Screenshot_option_Onchange(void) { -#if 0 - OP_ScreenshotOptionsMenu[op_screenshot_folder].status = + // Screenshot opt is at #3, 0 based array obv. + OPTIONS_DataScreenshot[2].status = (cv_screenshot_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED); -#endif + } void Moviemode_mode_Onchange(void) @@ -356,18 +356,17 @@ void Moviemode_mode_Onchange(void) void Moviemode_option_Onchange(void) { -#if 0 - OP_ScreenshotOptionsMenu[op_movie_folder].status = + // opt 7 in a 0 based array, you get the idea... + OPTIONS_DataScreenshot[6].status = (cv_movie_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED); -#endif } void Addons_option_Onchange(void) { -#if 0 - OP_AddonsOptionsMenu[op_addons_folder].status = + // Option 2 will always be the textbar. + // (keep in mind this is a 0 indexed array and the first element is a header...) + OPTIONS_DataAddon[2].status = (cv_addons_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED); -#endif } void M_SortServerList(void) @@ -399,6 +398,50 @@ void M_SortServerList(void) #endif } +static void M_EraseDataResponse(INT32 ch) +{ + UINT8 i; + + if (ch != 'y' && ch != KEY_ENTER) + return; + + S_StartSound(NULL, sfx_itrole); // bweh heh heh + + // Delete the data + if (optionsmenu.erasecontext == 2) + { + // SRB2Kart: This actually needs to be done FIRST, so that you don't immediately regain playtime/matches secrets + totalplaytime = 0; + matchesplayed = 0; + for (i = 0; i < PWRLV_NUMTYPES; i++) + vspowerlevel[i] = PWRLVRECORD_START; + } + if (optionsmenu.erasecontext != 1) + G_ClearRecords(); + if (optionsmenu.erasecontext != 0) + M_ClearSecrets(); + + F_StartIntro(); + M_ClearMenus(true); +} + +void M_EraseData(INT32 choice) +{ + const char *eschoice, *esstr = M_GetText("Are you sure you want to erase\n%s?\n\n(Press 'Y' to confirm)\n"); + + optionsmenu.erasecontext = (UINT8)choice; + + if (choice == 0) + eschoice = M_GetText("Time Attack data"); + else if (choice == 1) + eschoice = M_GetText("Secrets data"); + else + eschoice = M_GetText("ALL game data"); + + M_StartMessage(va(esstr, eschoice),M_EraseDataResponse,MM_YESNO); +} + + // ========================================================================= // BASIC MENU HANDLING // ========================================================================= @@ -2960,8 +3003,15 @@ void M_InitOptions(INT32 choice) optionsmenu.toptx = 0; optionsmenu.topty = 0; + // So that pause doesn't go to the main menu... OPTIONS_MainDef.prevMenu = currentMenu; + // This will disable or enable the textboxes of the affected menus before we get to them. + Screenshot_option_Onchange(); + Moviemode_mode_Onchange(); + Moviemode_option_Onchange(); + Addons_option_Onchange(); + M_SetupNextMenu(&OPTIONS_MainDef, false); } @@ -3937,3 +3987,12 @@ void M_HandleAddons(INT32 choice) M_ClearMenus(true); } } + +// Opening manual +void M_Manual(INT32 choice) +{ + (void)choice; + + MISC_ManualDef.prevMenu = (choice == INT32_MAX ? NULL : currentMenu); + M_SetupNextMenu(&MISC_ManualDef, true); +} \ No newline at end of file From 2e875eb3f09e2e6ba6024f971a5520a02b68cabb Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Sat, 27 Nov 2021 21:11:00 +0100 Subject: [PATCH 2/3] Options menu background + sounds --- src/k_menu.h | 23 +++++++++++++++++++++++ src/k_menudef.c | 31 ++++++++++++++++++++++++++++++- src/k_menudraw.c | 36 ++++++++++++++++++++++++++++++++---- src/k_menufunc.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 125 insertions(+), 7 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 99f651713..f5f4f20e7 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -126,6 +126,7 @@ typedef struct menu_s menuitem_t *menuitems; // menu items INT16 x, y; // x, y of menu + INT16 extra1, extra2; // Can be whatever really! Options menu uses extra1 for bg colour. INT16 transitionID; // only transition if IDs match INT16 transitionTics; // tics for transitions out @@ -200,6 +201,19 @@ extern menu_t PLAY_BattleGamemodesDef; extern menuitem_t OPTIONS_Main[]; extern menu_t OPTIONS_MainDef; +// We'll need this since we're gonna have to dynamically enable and disable options depending on which state we're in. +typedef enum +{ + mopt_controls = 0, + mopt_video, + mopt_sound, + mopt_hud, + mopt_gameplay, + mopt_server, + mopt_data, + mopt_manual, +} mopt_e; + extern menuitem_t OPTIONS_Video[]; extern menu_t OPTIONS_VideoDef; @@ -530,12 +544,19 @@ extern struct optionsmenu_s { modedesc_t modedescs[MAXMODEDESCS]; UINT8 erasecontext; + + // background: + INT16 currcolour; + INT16 lastcolour; + tic_t fade; } optionsmenu; void M_InitOptions(INT32 choice); // necessary for multiplayer since there's some options we won't want to access void M_OptionsTick(void); boolean M_OptionsInputs(INT32 ch); boolean M_OptionsQuit(void); // resets buttons when you quit the options. +void M_OptionsChangeBGColour(INT16 newcolour); // changes the background colour for options + void M_HandleItemToggles(INT32 choice); // For item toggling void M_EraseData(INT32 choice); // For data erasing @@ -667,6 +688,7 @@ void M_DrawAddons(void); 0,\ source,\ 0, 0,\ + 0, 0, \ 1, 10,\ M_DrawKartGamemodeMenu,\ NULL,\ @@ -681,6 +703,7 @@ void M_DrawAddons(void); 0,\ source,\ 0, 0,\ + 0, 0, \ 1, 10,\ M_DrawImageDef,\ NULL,\ diff --git a/src/k_menudef.c b/src/k_menudef.c index 824facbd6..0e2e26111 100644 --- a/src/k_menudef.c +++ b/src/k_menudef.c @@ -62,6 +62,7 @@ menu_t PLAY_CharSelectDef = { PLAY_CharSelect, 0, 0, 0, 0, + 0, 0, M_DrawCharacterSelect, M_CharacterSelectTick, M_CharacterSelectQuit, @@ -123,6 +124,7 @@ menu_t PLAY_CupSelectDef = { 0, PLAY_CupSelect, 0, 0, + 0, 0, 2, 10, M_DrawCupSelect, M_CupSelectTick, @@ -141,6 +143,7 @@ menu_t PLAY_LevelSelectDef = { 0, PLAY_LevelSelect, 0, 0, + 0, 0, 2, 10, M_DrawLevelSelect, M_LevelSelectTick, @@ -162,6 +165,7 @@ menu_t PLAY_TimeAttackDef = { 0, PLAY_TimeAttack, 0, 0, + 0, 0, 2, 10, M_DrawTimeAttack, NULL, @@ -204,6 +208,7 @@ menu_t PLAY_MP_OptSelectDef = { 0, PLAY_MP_OptSelect, 0, 0, + 0, 0, -1, 1, M_DrawMPOptSelect, M_MPOptSelectTick, @@ -239,6 +244,7 @@ menu_t PLAY_MP_HostDef = { 0, PLAY_MP_Host, 0, 0, + 0, 0, -1, 1, // 1 frame transition.... This is really just because I don't want the black fade when we press esc, hehe M_DrawMPHost, M_MPOptSelectTick, // This handles the unfolding options @@ -274,6 +280,7 @@ menu_t PLAY_MP_JoinIPDef = { 0, PLAY_MP_JoinIP, 0, 0, + 0, 0, -1, 1, // 1 frame transition.... This is really just because I don't want the black fade when we press esc, hehe M_DrawMPJoinIP, M_MPOptSelectTick, // This handles the unfolding options @@ -294,6 +301,7 @@ menu_t PLAY_MP_RoomSelectDef = { PLAY_MP_RoomSelect, 0, 0, 0, 0, + 0, 0, M_DrawMPRoomSelect, M_MPRoomSelectTick, NULL, @@ -304,7 +312,7 @@ menu_t PLAY_MP_RoomSelectDef = { menuitem_t OPTIONS_Main[] = { - {IT_STRING | IT_SUBMENU, "Control Setup", "Remap keys & buttons to your likings.", + {IT_STRING | IT_TRANSTEXT, "Profile Setup", "Remap keys & buttons to your likings.", NULL, NULL, 0, 0}, {IT_STRING | IT_SUBMENU, "Video Options", "Change video settings such as the resolution.", @@ -329,12 +337,14 @@ menuitem_t OPTIONS_Main[] = NULL, M_Manual, 0, 0}, }; +// For options menu, the 'extra1' field will determine the background colour to use for... the background! (What a concept!) menu_t OPTIONS_MainDef = { sizeof (OPTIONS_Main) / sizeof (menuitem_t), &MainDef, 0, OPTIONS_Main, 0, 0, + SKINCOLOR_SLATE, 0, 2, 10, M_DrawOptions, M_OptionsTick, @@ -395,6 +405,7 @@ menu_t OPTIONS_VideoDef = { 0, OPTIONS_Video, 32, 80, + SKINCOLOR_PLAGUE, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -415,6 +426,7 @@ menu_t OPTIONS_VideoModesDef = { 0, OPTIONS_VideoModes, 48, 80, + SKINCOLOR_PLAGUE, 0, 2, 10, M_DrawVideoModes, M_OptionsTick, @@ -472,6 +484,7 @@ menu_t OPTIONS_VideoOGLDef = { 0, OPTIONS_VideoOGL, 32, 80, + SKINCOLOR_PLAGUE, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -534,6 +547,7 @@ menu_t OPTIONS_SoundDef = { 0, OPTIONS_Sound, 48, 80, + SKINCOLOR_THUNDER, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -588,6 +602,7 @@ menu_t OPTIONS_HUDDef = { 0, OPTIONS_HUD, 48, 80, + SKINCOLOR_SUNSLAM, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -636,6 +651,7 @@ menu_t OPTIONS_HUDOnlineDef = { 0, OPTIONS_HUDOnline, 48, 80, + SKINCOLOR_SUNSLAM, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -688,6 +704,7 @@ menu_t OPTIONS_GameplayDef = { 0, OPTIONS_Gameplay, 48, 80, + SKINCOLOR_SCARLET, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -732,6 +749,7 @@ menu_t OPTIONS_GameplayItemsDef = { 0, OPTIONS_GameplayItems, 0, 75, + SKINCOLOR_SCARLET, 0, 2, 10, M_DrawItemToggles, M_OptionsTick, @@ -795,6 +813,7 @@ menu_t OPTIONS_ServerDef = { 0, OPTIONS_Server, 48, 70, // This menu here is slightly higher because there's a lot of options... + SKINCOLOR_VIOLET, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -852,6 +871,7 @@ menu_t OPTIONS_ServerAdvancedDef = { 0, OPTIONS_ServerAdvanced, 48, 70, // This menu here is slightly higher because there's a lot of options... + SKINCOLOR_VIOLET, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -892,6 +912,7 @@ menu_t OPTIONS_DataDef = { 0, OPTIONS_Data, 48, 80, + SKINCOLOR_BLUEBERRY, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -937,6 +958,7 @@ menu_t OPTIONS_DataAddonDef = { 0, OPTIONS_DataAddon, 48, 80, + SKINCOLOR_BLUEBERRY, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -976,6 +998,7 @@ menu_t OPTIONS_DataScreenshotDef = { 0, OPTIONS_DataScreenshot, 48, 80, + SKINCOLOR_BLUEBERRY, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -999,6 +1022,7 @@ menu_t OPTIONS_DataReplayDef = { 0, OPTIONS_DataReplay, 48, 80, + SKINCOLOR_BLUEBERRY, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -1036,6 +1060,7 @@ menu_t OPTIONS_DataDiscordDef = { 0, OPTIONS_DataDiscord, 48, 80, + SKINCOLOR_BLUEBERRY, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -1068,6 +1093,7 @@ menu_t OPTIONS_DataEraseDef = { 0, OPTIONS_DataErase, 48, 80, + SKINCOLOR_BLUEBERRY, 0, 2, 10, M_DrawGenericOptions, M_OptionsTick, @@ -1127,6 +1153,7 @@ menu_t PAUSE_MainDef = { 0, PAUSE_Main, 0, 0, + 0, 0, 1, 10, // For transition with some menus! M_DrawPause, M_PauseTick, @@ -1177,6 +1204,7 @@ menu_t PAUSE_PlaybackMenuDef = { PAUSE_PlaybackMenu, BASEVIDWIDTH/2 - 88, 2, 0, 0, + 0, 0, M_DrawPlaybackMenu, NULL, NULL, @@ -1220,6 +1248,7 @@ menu_t MISC_AddonsDef = { MISC_AddonsMenu, 50, 28, 0, 0, + 0, 0, M_DrawAddons, NULL, NULL, diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 748a57c70..f529585d2 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -1652,10 +1652,34 @@ void M_DrawMPRoomSelect(void) // OPTIONS MENU +// Draws the cogs and also the options background! static void M_DrawOptionsCogs(void) { - patch_t *back[3] = {W_CachePatchName("OPT_BAK1", PU_CACHE), W_CachePatchName("OPT_BAK2", PU_CACHE), W_CachePatchName("OPT_BAK3", PU_CACHE)}; - V_DrawFixedPatch(0, 0, FRACUNIT, 0, back[(optionsmenu.ticker/10) %3], NULL); + // the background isn't drawn outside of being in the main menu state. + if (gamestate == GS_MENU) + { + patch_t *back[3] = {W_CachePatchName("OPT_BG1", PU_CACHE), W_CachePatchName("OPT_BG2", PU_CACHE), W_CachePatchName("OPT_BG3", PU_CACHE)}; + INT32 tflag = 0; + UINT8 *c; + UINT8 *c2; // colormap for the one we're changing + + if (optionsmenu.fade) + { + c2 = R_GetTranslationColormap(TC_DEFAULT, optionsmenu.lastcolour, GTC_CACHE); + V_DrawFixedPatch(0, 0, FRACUNIT, 0, back[(optionsmenu.ticker/10) %3], c2); + + // prepare fade flag: + tflag = min(V_90TRANS, (optionsmenu.fade)<menuitems[i].status & IT_TRANSTEXT) + tflag = V_TRANSLUCENT; + if (!(menutransition.tics && i == itemOn)) { V_DrawFixedPatch(px*FRACUNIT, py*FRACUNIT, FRACUNIT, 0, buttback, c); - V_DrawCenteredGamemodeString(px-3, py - 16, V_ALLOWLOWERCASE, (i == itemOn ? c : NULL), currentMenu->menuitems[i].text); + V_DrawCenteredGamemodeString(px-3, py - 16, V_ALLOWLOWERCASE|tflag, (i == itemOn ? c : NULL), currentMenu->menuitems[i].text); } y += 48; @@ -2076,7 +2104,7 @@ void M_DrawItemToggles(void) if (shitsfree) shitsfree--; - V_DrawCenteredString(BASEVIDWIDTH/2, currentMenu->y, highlightflags, va("* %s *", currentMenu->menuitems[itemOn].text)); + V_DrawCenteredString(BASEVIDWIDTH/2 + menutransition.tics*48, currentMenu->y, highlightflags, va("* %s *", currentMenu->menuitems[itemOn].text)); } diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 86e5325bd..7adff19d6 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -1663,6 +1663,7 @@ menu_t MessageDef = 0, // lastOn, flags (TO HACK) MessageMenu, // menuitem_t -> 0, 0, // x, y (TO HACK) + 0, 0, // extra1, extra2 0, 0, // transition tics M_DrawMessageMenu, // drawing routine -> NULL, // ticker routine @@ -2993,7 +2994,15 @@ void M_InitOptions(INT32 choice) { (void)choice; - // @TODO: Change options when you do them from a netgame. + OPTIONS_MainDef.menuitems[mopt_gameplay].status = IT_STRING | IT_SUBMENU; + OPTIONS_MainDef.menuitems[mopt_server].status = IT_STRING | IT_SUBMENU; + + // disable gameplay & server options if you aren't an admin in netgames. (GS_MENU check maybe unecessary but let's not take any chances) + if (netgame && gamestate != GS_MENU && !IsPlayerAdmin(consoleplayer)) + { + OPTIONS_MainDef.menuitems[mopt_gameplay].status = IT_STRING | IT_TRANSTEXT; + OPTIONS_MainDef.menuitems[mopt_server].status = IT_STRING | IT_TRANSTEXT; + } optionsmenu.ticker = 0; optionsmenu.offset = 0; @@ -3003,6 +3012,11 @@ void M_InitOptions(INT32 choice) optionsmenu.toptx = 0; optionsmenu.topty = 0; + // BG setup: + optionsmenu.currcolour = OPTIONS_MainDef.extra1; + optionsmenu.lastcolour = 0; + optionsmenu.fade = 0; + // So that pause doesn't go to the main menu... OPTIONS_MainDef.prevMenu = currentMenu; @@ -3015,6 +3029,14 @@ void M_InitOptions(INT32 choice) M_SetupNextMenu(&OPTIONS_MainDef, false); } +// Prepares changing the colour of the background +void M_OptionsChangeBGColour(INT16 newcolour) +{ + optionsmenu.fade = 10; + optionsmenu.lastcolour = optionsmenu.currcolour; + optionsmenu.currcolour = newcolour; +} + boolean M_OptionsQuit(void) { optionsmenu.toptx = 140-1; @@ -3037,7 +3059,7 @@ void M_OptionsTick(void) optionsmenu.opty = optionsmenu.topty; // Avoid awkward 1 px errors. } - // Garbage: + // Move the button for cool animations if (currentMenu == &OPTIONS_MainDef) { M_OptionsQuit(); // ...So now this is used here. @@ -3048,6 +3070,14 @@ void M_OptionsTick(void) optionsmenu.topty = 50; } + // Handle the background stuff: + if (optionsmenu.fade) + optionsmenu.fade--; + + // change the colour if we aren't matching the current menu colour + if (optionsmenu.currcolour != currentMenu->extra1) + M_OptionsChangeBGColour(currentMenu->extra1); + } boolean M_OptionsInputs(INT32 ch) @@ -3059,6 +3089,7 @@ boolean M_OptionsInputs(INT32 ch) { optionsmenu.offset += 48; M_NextOpt(); + S_StartSound(NULL, sfx_menu1); if (itemOn == 0) optionsmenu.offset -= currentMenu->numitems*48; @@ -3069,6 +3100,7 @@ boolean M_OptionsInputs(INT32 ch) { optionsmenu.offset -= 48; M_PrevOpt(); + S_StartSound(NULL, sfx_menu1); if (itemOn == currentMenu->numitems-1) optionsmenu.offset += currentMenu->numitems*48; @@ -3077,6 +3109,10 @@ boolean M_OptionsInputs(INT32 ch) } case KEY_ENTER: { + + if (currentMenu->menuitems[itemOn].status & IT_TRANSTEXT) + return true; // No. + optionsmenu.optx = 140; optionsmenu.opty = 70; // Default position for the currently selected option. @@ -3450,6 +3486,7 @@ boolean M_PauseInputs(INT32 ch) case KEY_UPARROW: { pausemenu.offset -= 50; // Each item is spaced by 50 px + S_StartSound(NULL, sfx_menu1); M_PrevOpt(); return true; } @@ -3457,6 +3494,7 @@ boolean M_PauseInputs(INT32 ch) case KEY_DOWNARROW: { pausemenu.offset += 50; // Each item is spaced by 50 px + S_StartSound(NULL, sfx_menu1); M_NextOpt(); return true; } From 74288a4de1ad52cc8b88560b0a0052962bba0432 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 3 Dec 2021 14:59:22 -0800 Subject: [PATCH 3/3] Fix compiling errors - Replace itoa with sprintf (itoa is a nonstandard function). - Guard one instance of Discord Rich Presence. --- src/k_menudef.c | 2 ++ src/k_menufunc.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/k_menudef.c b/src/k_menudef.c index 0e2e26111..9754ae366 100644 --- a/src/k_menudef.c +++ b/src/k_menudef.c @@ -1009,8 +1009,10 @@ menu_t OPTIONS_DataScreenshotDef = { menuitem_t OPTIONS_DataReplay[] = { +#ifdef HAVE_DISCORDRPC {IT_STRING | IT_CVAR, "Rich Presence", "Allow Discord to display game info on your status.", NULL, &cv_discordrp, 0, 0}, +#endif {IT_STRING | IT_CVAR, "Synch. Check Interval", "How often to check for synchronization while playing back a replay.", NULL, &cv_netdemosyncquality, 0, 0}, diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 7adff19d6..902a38d33 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -2243,7 +2243,7 @@ static void M_MPConfirmCharacterSelection(void) // colour // (convert the number that's saved to a string we can use) col = setup_player[i].color; - itoa(col, colstr, 10); + sprintf(colstr, "%d", col); strcpy(cmd, commandnames[i][1]); strcat(cmd, colstr); @@ -4033,4 +4033,4 @@ void M_Manual(INT32 choice) MISC_ManualDef.prevMenu = (choice == INT32_MAX ? NULL : currentMenu); M_SetupNextMenu(&MISC_ManualDef, true); -} \ No newline at end of file +}