SW: Fix NUMGAMEFUNCTIONS and mouse button select menu

git-svn-id: https://svn.eduke32.com/eduke32@8340 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/sw/src/function.h
#	source/sw/src/menus.cpp
This commit is contained in:
hendricks266 2019-11-30 06:10:44 +00:00 committed by Christoph Oelckers
parent 15b8bc959f
commit 361a964067

View file

@ -836,7 +836,7 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
// Todo: Branch off to the generic keybind menu. // Todo: Branch off to the generic keybind menu.
const int PGSIZ = 9; const int PGSIZ = 9;
const char *strs[] = { "Select the function to assign to", "%s", "or ESCAPE to cancel." }; const char *strs[] = { "Select the function to assign to", "%s", "or ESCAPE to cancel." };
int topitem = 0, botitem = NUMGAMEFUNCTIONS-1; int topitem = 0, botitem = NUMGAMEFUNCTIONS;
int i, j, y; int i, j, y;
short w, h=0; short w, h=0;
int returnval = 0; int returnval = 0;
@ -853,13 +853,13 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
} }
else if (inputState.GetKeyStatus(sc_End)) else if (inputState.GetKeyStatus(sc_End))
{ {
*currentfunc = NUMGAMEFUNCTIONS-1; // -1 because the last one is the console and the top is 'none' *currentfunc = NUMGAMEFUNCTIONS;
inputState.ClearKeyStatus(sc_End); inputState.ClearKeyStatus(sc_End);
} }
else if (inputState.GetKeyStatus(sc_PgDn)) else if (inputState.GetKeyStatus(sc_PgDn))
{ {
*currentfunc += PGSIZ; *currentfunc += PGSIZ;
if (*currentfunc >= NUMGAMEFUNCTIONS) *currentfunc = NUMGAMEFUNCTIONS-1; if (*currentfunc > NUMGAMEFUNCTIONS) *currentfunc = NUMGAMEFUNCTIONS;
inputState.ClearKeyStatus(sc_PgDn); inputState.ClearKeyStatus(sc_PgDn);
} }
else if (inputState.GetKeyStatus(sc_PgUp)) else if (inputState.GetKeyStatus(sc_PgUp))
@ -881,11 +881,11 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
else if (I_MenuDown()) else if (I_MenuDown())
{ {
I_MenuDownClear(); I_MenuDownClear();
*currentfunc = min(NUMGAMEFUNCTIONS - 1, *currentfunc + 1); *currentfunc = min(NUMGAMEFUNCTIONS, *currentfunc + 1);
} }
if (NUMGAMEFUNCTIONS-1 > PGSIZ) if (NUMGAMEFUNCTIONS > PGSIZ)
{ {
topitem = *currentfunc - PGSIZ/2; topitem = *currentfunc - PGSIZ/2;
botitem = topitem + PGSIZ; botitem = topitem + PGSIZ;
@ -895,9 +895,9 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
botitem += -topitem; botitem += -topitem;
topitem = 0; topitem = 0;
} }
else if (botitem >= NUMGAMEFUNCTIONS) else if (botitem > NUMGAMEFUNCTIONS)
{ {
botitem = NUMGAMEFUNCTIONS-1; botitem = NUMGAMEFUNCTIONS;
topitem = botitem - PGSIZ; topitem = botitem - PGSIZ;
} }
} }
@ -941,7 +941,7 @@ static int MNU_SelectButtonFunction(const char *buttonname, int *currentfunc)
MNU_MeasureSmallString(morestr,&dx,&dy); MNU_MeasureSmallString(morestr,&dx,&dy);
if (topitem > 0) if (topitem > 0)
MNU_DrawSmallString(XDIM - OPT_XS - dx, OPT_LINE(4), morestr, 8,16); MNU_DrawSmallString(XDIM - OPT_XS - dx, OPT_LINE(4), morestr, 8,16);
if (botitem < NUMGAMEFUNCTIONS-1) if (botitem < NUMGAMEFUNCTIONS)
MNU_DrawSmallString(XDIM - OPT_XS - dx, OPT_LINE(4)+PGSIZ*8, morestr, 8,16); MNU_DrawSmallString(XDIM - OPT_XS - dx, OPT_LINE(4)+PGSIZ*8, morestr, 8,16);
} }