Menus/Online: light redesign

- Mostly hijacks the gamemode menu format (Local Play)
- Host
  - Select gametype (Race, Battle)
  - Shortcuts to Gameplay Options and Server Options
  - Select map
- Browser
  - Unchanged
- Direct Join
  - Press A to enter an IP address
  - Press C to reconnect to the last joined server
  - Left/right cycles through the server history
This commit is contained in:
James R 2024-03-05 12:44:22 -08:00
parent 0b3d1ac705
commit 179597e70d
8 changed files with 237 additions and 35 deletions

View file

@ -926,6 +926,7 @@ consvar_t cv_dummygpdifficulty = MenuDummy("dummygpdifficulty", "Normal").values
consvar_t cv_dummygpencore = MenuDummy("dummygpencore", "Off").on_off();
consvar_t cv_dummyip = MenuDummy("dummyip", "");
consvar_t cv_dummyipselect = MenuDummy("dummyipselect", "0").min_max(0, 2);
extern CV_PossibleValue_t dummykartspeed_cons_t[];
consvar_t cv_dummykartspeed = MenuDummy("dummykartspeed", "Gear 2").values(dummykartspeed_cons_t);

View file

@ -295,10 +295,26 @@ extern menu_t PLAY_MP_OptSelectDef;
typedef enum
{
mp_host = 0,
mp_browse,
mp_directjoin,
mp_back,
} mp_e;
typedef enum
{
mhost_gametype = 0,
mhost_gameplay_options,
mhost_server_options,
mhost_boxend,
mhost_mapselect = mhost_boxend,
mhost_back,
// TODO, remove these (old code)
mhost_sname = 0,
mhost_public,
mhost_maxp,
mhost_gametype,
//mhost_gametype,
mhost_go,
} mhost_e;
@ -1058,6 +1074,8 @@ void M_OptionsChangeBGColour(INT16 newcolour); // changes the background colour
void M_VideoOptions(INT32 choice);
void M_SoundOptions(INT32 choice);
void M_GameplayOptions(INT32 choice);
void M_ServerOptions(INT32 choice);
void M_HandleItemToggles(INT32 choice); // For item toggling
void M_EraseData(INT32 choice); // For data erasing
@ -1091,6 +1109,9 @@ void M_HandleVideoModes(INT32 ch);
// data stuff
void M_HandleProfileErase(INT32 choice);
// Draws "List via" at the bottom of the screen.
void M_DrawMasterServerReminder(void);
// Draws the EGGA CHANNEL background.
void M_DrawEggaChannel(void);

View file

@ -1222,6 +1222,38 @@ void M_DrawGenericMenu(void)
static tic_t gm_flipStart;
static INT32 M_DrawRejoinIP(INT32 x, INT32 y, INT32 tx)
{
extern consvar_t cv_dummyipselect;
char (*ip)[MAX_LOGIP] = joinedIPlist[cv_dummyipselect.value];
if (!*ip[0])
return 0;
INT16 shift = 20;
x -= shift;
INT16 j = 0;
for (j=0; j <= (GM_YOFFSET + 10) / 2; j++)
{
// Draw rectangles that look like the current selected item starting from the top of the actual selection graphic and going up to where it's supposed to go.
// With colour 169 (that's the index of the shade of black the plague colourization gives us. ...No I don't like using a magic number either.
V_DrawFill((x-1) + j, y + (2*j), 226, 2, 169);
}
x += GM_XOFFSET + 14;
y += GM_YOFFSET;
const char *text = ip[0];
INT32 w = V_ThinStringWidth(text, 0);
INT32 f = highlightflags;
V_DrawMenuString(x - 10 - (skullAnimCounter/5), y, f, "\x1C"); // left arrow
V_DrawMenuString(x + w + 2+ (skullAnimCounter/5), y, f, "\x1D"); // right arrow
V_DrawThinString(x, y, f, text);
V_DrawRightAlignedThinString(BASEVIDWIDTH + 4 + tx, y, V_ORANGEMAP, "\xAC Rejoin");
return shift;
}
//
// M_DrawKartGamemodeMenu
//
@ -1266,10 +1298,19 @@ void M_DrawKartGamemodeMenu(void)
}
INT32 cx = x;
boolean selected = (i == itemOn && menutransition.tics == menutransition.dest);
if (i == itemOn && menutransition.tics == menutransition.dest)
if (selected)
{
cx -= Easing_OutSine(M_DueFrac(gm_flipStart, GM_FLIPTIME), 0, GM_XOFFSET / 2);
fixed_t f = M_DueFrac(gm_flipStart, GM_FLIPTIME);
cx -= Easing_OutSine(f, 0, (GM_XOFFSET / 2));
// Direct Join
if (currentMenu == &PLAY_MP_OptSelectDef && i == mp_directjoin)
{
INT32 shift = M_DrawRejoinIP(cx, y, cx - x);
cx -= Easing_OutSine(f, 0, shift);
}
}
type = (currentMenu->menuitems[i].status & IT_DISPLAY);
@ -1281,7 +1322,7 @@ void M_DrawKartGamemodeMenu(void)
{
UINT8 *colormap = NULL;
if (i == itemOn && menutransition.tics == menutransition.dest)
if (selected)
{
colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_PLAGUE, GTC_CACHE);
}
@ -2550,7 +2591,7 @@ void M_DrawRaceDifficulty(void)
for (i = 0; i < currentMenu->numitems; i++)
{
if (i >= drace_boxend)
if (i >= currentMenu->extra1)
{
x = GM_STARTX + (GM_XOFFSET * 5 / 2);
y = GM_STARTY + (GM_YOFFSET * 5 / 2);
@ -2615,7 +2656,7 @@ void M_DrawRaceDifficulty(void)
{
colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_PLAGUE, GTC_CACHE);
if (i >= drace_boxend)
if (i >= currentMenu->extra1)
{
cx -= Easing_OutSine(M_DueFrac(gm_flipStart, GM_FLIPTIME), 0, GM_XOFFSET / 2);
}
@ -2626,17 +2667,21 @@ void M_DrawRaceDifficulty(void)
}
if (currentMenu->menuitems[i].status & IT_CVAR)
if (currentMenu->menuitems[i].status & (IT_CVAR | IT_ARROWS))
{
INT32 fx = (cx - tx);
INT32 centx = fx + (320-fx)/2 + (tx); // undo the menutransition movement to redo it here otherwise the text won't move at the same speed lole.
// implicitely we'll only take care of normal consvars
consvar_t *cv = currentMenu->menuitems[i].itemaction.cvar;
const char *val = currentMenu->menuitems[i].text;
if (currentMenu->menuitems[i].status & IT_CVAR)
{
consvar_t *cv = currentMenu->menuitems[i].itemaction.cvar;
val = cv->string;
}
V_DrawFixedPatch(cx*FRACUNIT, y*FRACUNIT, FRACUNIT, 0, W_CachePatchName("MENUSHRT", PU_CACHE), colormap);
V_DrawCenteredGamemodeString(centx, y - 3, 0, colormap, cv->string);
V_DrawCenteredGamemodeString(centx, y - 3, 0, colormap, val);
if (i == itemOn)
{
@ -2656,7 +2701,7 @@ void M_DrawRaceDifficulty(void)
x += GM_XOFFSET;
y += GM_YOFFSET;
if (i < drace_boxend)
if (i < currentMenu->extra1)
{
y += 2; // extra spacing for Match Race options
}
@ -3715,7 +3760,7 @@ void M_DrawTimeAttack(void)
// NOTE: This is pretty rigid and only intended for use with the multiplayer options menu which has *3* choices.
static void M_DrawMasterServerReminder(void)
void M_DrawMasterServerReminder(void)
{
// Did you change the Server Browser address? Have a little reminder.
@ -3725,7 +3770,7 @@ static void M_DrawMasterServerReminder(void)
else
mservflags = warningflags;
INT32 y = BASEVIDHEIGHT - 24;
INT32 y = BASEVIDHEIGHT - 10;
V_DrawFadeFill(0, y-1, BASEVIDWIDTH, 10+1, 0, 31, 5);
V_DrawCenteredThinString(BASEVIDWIDTH/2, y,
@ -3785,7 +3830,7 @@ void M_DrawEggaChannel(void)
patch_t *background = W_CachePatchName("M_EGGACH", PU_CACHE);
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 25);
V_DrawFixedPatch(160<<FRACBITS, 104<<FRACBITS, FRACUNIT, 0, background, NULL);
V_DrawFixedPatch((menuactive ? 75 : 160)<<FRACBITS, 104<<FRACBITS, FRACUNIT, 0, background, NULL);
V_DrawVhsEffect(false); // VHS the background! (...sorry OGL my love)
}

View file

@ -23,11 +23,11 @@ menuitem_t OPTIONS_Main[] =
{IT_STRING | IT_SUBMENU, "HUD Options", "Options related to the Heads-Up Display.",
NULL, {.submenu = &OPTIONS_HUDDef}, 0, 0},
{IT_STRING | IT_SUBMENU, "Gameplay Options", "Change various game related options",
NULL, {.submenu = &OPTIONS_GameplayDef}, 0, 0},
{IT_STRING | IT_CALL, "Gameplay Options", "Change various game related options",
NULL, {.routine = M_GameplayOptions}, 0, 0},
{IT_STRING | IT_SUBMENU, "Server Options", "Change various specific options for your game server.",
NULL, {.submenu = &OPTIONS_ServerDef}, 0, 0},
{IT_STRING | IT_CALL, "Server Options", "Change various specific options for your game server.",
NULL, {.routine = M_ServerOptions}, 0, 0},
{IT_STRING | IT_SUBMENU, "Data Options", "Miscellaneous data options such as the screenshot format.",
NULL, {.submenu = &OPTIONS_DataDef}, 0, 0},
@ -90,8 +90,8 @@ void M_InitOptions(INT32 choice)
if (gamestate == GS_MENU
|| ((server || IsPlayerAdmin(consoleplayer)) && K_CanChangeRules(false)))
{
OPTIONS_MainDef.menuitems[mopt_gameplay].status = IT_STRING | IT_SUBMENU;
OPTIONS_MainDef.menuitems[mopt_server].status = IT_STRING | IT_SUBMENU;
OPTIONS_MainDef.menuitems[mopt_gameplay].status = IT_STRING | IT_CALL;
OPTIONS_MainDef.menuitems[mopt_server].status = IT_STRING | IT_CALL;
OPTIONS_GameplayDef.menuitems[gopt_encore].status =
(M_SecretUnlocked(SECRET_ENCORE, false) ? (IT_STRING | IT_CVAR) : IT_DISABLED);
}
@ -228,6 +228,18 @@ void M_SoundOptions(INT32 choice)
M_GonerResetLooking(GDGONER_SOUND);
}
void M_GameplayOptions(INT32 choice)
{
(void)choice;
M_OptionsMenuGoto(&OPTIONS_GameplayDef);
}
void M_ServerOptions(INT32 choice)
{
(void)choice;
M_OptionsMenuGoto(&OPTIONS_ServerDef);
}
boolean M_OptionsInputs(INT32 ch)
{

View file

@ -94,7 +94,7 @@ menu_t PLAY_RaceDifficultyDef = {
0,
PLAY_RaceDifficulty,
0, 0,
0, 0,
drace_boxend, 0,
0,
NULL,
1, 5,

View file

@ -5,6 +5,7 @@
#include "../m_cond.h"
#include "../s_sound.h"
#include "../mserv.h" // cv_masterserver
#include "../m_misc.h"
#if defined (TESTERS)
#define IT_STRING_CALL_NOTESTERS IT_DISABLED
@ -73,20 +74,117 @@ static void M_PreMPRoomSelectInit(INT32 choice)
M_MPRoomSelectInit(0);
}
static const char *query_ip(const char *replace)
{
if (replace)
M_JoinIP(replace);
return "";
}
static boolean uses_gamepad;
static void ip_entry(void)
{
M_OpenVirtualKeyboard(uses_gamepad, MAXSTRINGLENGTH, query_ip, NULL);
}
static consvar_t *ip_cvar(void)
{
extern consvar_t cv_dummyipselect;
return &cv_dummyipselect;
}
static void confirm_ip_select(INT32 choice)
{
if (choice == MA_YES)
{
consvar_t *cv = ip_cvar();
M_JoinIP(joinedIPlist[cv->value][0]);
}
}
static void find_ip(INT32 add)
{
consvar_t *cv = ip_cvar();
for (int i = 0; i < NUMLOGIP; ++i)
{
CV_AddValue(cv, add);
if (*joinedIPlist[cv->value][0])
break;
}
}
static void direct_join_routine(INT32 choice)
{
consvar_t *cv = ip_cvar();
INT32 index = cv->value;
if (choice == 2)
ip_entry();
else if (choice == -1)
{
const char *ip = joinedIPlist[index][0];
if (*ip)
{
M_StartMessage("Direct Join", va("Connect to %s?", joinedIPlist[index][0]),
&confirm_ip_select, MM_YESNO, "Connect", "Back");
}
}
else
find_ip(choice ? 1 : -1);
}
// mp_e
menuitem_t PLAY_MP_OptSelect[] =
{
{IT_STRING_CALL_NOTESTERS, "Host Game", "Start your own online game!",
NULL, {.routine = M_PreMPHostInit}, 0, 0},
{IT_STRING | IT_CALL, "Server Browser", "Search for game servers to play in.",
{IT_STRING | IT_CALL, "Browse", "Search for game servers to play in.",
NULL, {.routine = M_PreMPRoomSelectInit}, 0, 0},
{IT_STRING | IT_CALL, "Join by IP", "Join an online game by its IP address.",
NULL, {.routine = M_MPJoinIPInit}, 0, 0},
{IT_STRING | IT_ARROWS, "Direct Join", "Join an online game by its IP address.",
NULL, {.routine = direct_join_routine}, 0, 0},
{IT_STRING | IT_CALL, "Back", NULL, NULL, {.routine = M_GoBack}, 0, 0},
};
#undef IT_STRING_CALL_NOTESTERS
static void draw_routine(void)
{
M_DrawKartGamemodeMenu();
M_DrawMasterServerReminder();
}
static boolean any_stored_ips(void)
{
for (int i = 0; i < NUMLOGIP; ++i)
{
if (*joinedIPlist[i][0])
return true;
}
return false;
}
static void init_routine(void)
{
menuitem_t *it = &PLAY_MP_OptSelect[mp_directjoin];
CV_SetValue(ip_cvar(), 0);
if (any_stored_ips())
{
it->status = IT_STRING | IT_ARROWS;
find_ip(1);
}
else
it->status = IT_STRING | IT_CALL;
}
static boolean input_routine(INT32 key)
{
uses_gamepad = (key == -1);
return false;
}
menu_t PLAY_MP_OptSelectDef = {
sizeof (PLAY_MP_OptSelect) / sizeof (menuitem_t),
@ -101,13 +199,13 @@ menu_t PLAY_MP_OptSelectDef = {
0, 0,
0,
"NETMD2",
-1, 1,
M_DrawMPOptSelect,
4, 5,
draw_routine,
M_DrawEggaChannel,
M_MPOptSelectTick,
NULL,
init_routine,
NULL,
NULL
input_routine
};
struct mpmenu_s mpmenu;

View file

@ -6,9 +6,21 @@
#include "../z_zone.h"
#include "../mserv.h"
static void draw_routine(void)
{
M_DrawRaceDifficulty();
M_DrawMasterServerReminder();
}
static void tick_routine(void)
{
PLAY_MP_Host[mhost_gametype].text = gametypes[menugametype]->name;
}
// MULTIPLAYER HOST SCREEN -- see mhost_e
menuitem_t PLAY_MP_Host[] =
{
#if 0
//{IT_NOTHING | IT_KEYHANDLER, NULL, NULL, NULL, M_MPOptSelect, 0, 0},
{IT_STRING | IT_CVAR | IT_CV_STRING, "Server Name", "Display name for your game online. Other players will see this.",
@ -25,7 +37,21 @@ menuitem_t PLAY_MP_Host[] =
{IT_STRING | IT_CALL, "GO", "Select a map with the currently selected gamemode",
NULL, {.routine = M_MPSetupNetgameMapSelect}, 0, 0},
#endif
{IT_STRING | IT_ARROWS, "Gametype", "Choose the type of play on your serer.",
NULL, {.routine = M_HandleHostMenuGametype}, 0, 0},
{IT_STRING2 | IT_CALL, "Gameplay Options...", "Adjust settings pertaining to gameplay.",
NULL, {.routine = M_GameplayOptions}, 0, 0},
{IT_STRING2 | IT_CALL, "Server Options...", "Adjust settings pertaining to online play.",
NULL, {.routine = M_ServerOptions}, 0, 0},
{IT_STRING | IT_CALL, "Map Select", "Go on and select a level!",
NULL, {.routine = M_MPSetupNetgameMapSelect}, 0, 0},
{IT_STRING | IT_CALL, "Back", NULL,
NULL, {.routine = M_GoBack}, 0, 0},
};
menu_t PLAY_MP_HostDef = {
@ -34,13 +60,13 @@ menu_t PLAY_MP_HostDef = {
0,
PLAY_MP_Host,
0, 0,
0, 0,
mhost_boxend, 0,
0,
"NETMD2",
-1, 1, // 1 frame transition.... This is really just because I don't want the black fade when we press esc, hehe
M_DrawMPHost,
4, 5,
draw_routine,
M_DrawEggaChannel,
M_MPOptSelectTick, // This handles the unfolding options
tick_routine,
NULL,
M_MPResetOpts,
NULL
@ -66,8 +92,8 @@ void M_MPHostInit(INT32 choice)
{
(void)choice;
mpmenu.modewinextend[0][0] = 1;
M_SetupNextMenu(&PLAY_MP_HostDef, true);
itemOn = mhost_go;
PLAY_MP_HostDef.lastOn = mhost_mapselect;
M_SetupNextMenu(&PLAY_MP_HostDef, false);
Get_rules();
// There's one downside to doing it this way:

View file

@ -77,7 +77,6 @@ void M_JoinIP(const char *ipa)
{
if (*(ipa) == '\0') // Jack shit
{
M_StartMessage("Online Play", "Please specify an address.\n", NULL, MM_NOTHING, NULL, NULL);
return;
}