Skip to content

Commit

Permalink
Fixed various problems with the draw routine for the text entry backg…
Browse files Browse the repository at this point in the history
…rounds seen in the menu (e.g., for save/load menus).

Close the menu fast when replying to a message that was asked while not actually in the menu (previously it would appear instantly and then fade away).
  • Loading branch information
danij committed Nov 15, 2008
1 parent 4d29483 commit 764771b
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 58 deletions.
101 changes: 62 additions & 39 deletions doomsday/plugins/common/src/hu_menu.c
Expand Up @@ -242,9 +242,9 @@ boolean (*messageRoutine) (int response, void* data);
char tempstring[80];

// Old save description before edit.
char saveOldString[SAVESTRINGSIZE];
char saveOldString[SAVESTRINGSIZE+1];

char savegamestrings[10][SAVESTRINGSIZE];
char savegamestrings[10][SAVESTRINGSIZE+1];

// We are going to be entering a savegame string.
int saveStringEnter;
Expand Down Expand Up @@ -392,6 +392,9 @@ static dpatch_t m_saveg;
static dpatch_t m_rdthis;
static dpatch_t m_quitg;
static dpatch_t m_optttl;
static dpatch_t dpLSLeft;
static dpatch_t dpLSRight;
static dpatch_t dpLSCntr;
# if __JDOOM__
static dpatch_t credit;
static dpatch_t help;
Expand All @@ -402,6 +405,7 @@ static dpatch_t help2;

#if __JHERETIC__ || __JHEXEN__
static dpatch_t m_htic;
static dpatch_t dpFSlot;
#endif

menuitem_t MainItems[] = {
Expand Down Expand Up @@ -670,7 +674,7 @@ static menuitem_t LoadItems[] = {
static menu_t LoadDef = {
0,
#if __JDOOM__ || __JDOOM64__
80, 54,
80, 44,
#else
80, 30,
#endif
Expand Down Expand Up @@ -700,7 +704,7 @@ static menuitem_t SaveItems[] = {
static menu_t SaveDef = {
0,
#if __JDOOM__ || __JDOOM64__
80, 54,
80, 44,
#else
80, 30,
#endif
Expand Down Expand Up @@ -1382,6 +1386,9 @@ void M_LoadData(void)
R_CachePatch(&m_rdthis, "M_RDTHIS");
R_CachePatch(&m_quitg, "M_QUITG");
R_CachePatch(&m_optttl, "M_OPTTTL");
R_CachePatch(&dpLSLeft, "M_LSLEFT");
R_CachePatch(&dpLSRight, "M_LSRGHT");
R_CachePatch(&dpLSCntr, "M_LSCNTR");
# if __JDOOM__
if(gameMode == retail || gameMode == commercial)
R_CachePatch(&credit, "CREDIT");
Expand All @@ -1396,6 +1403,7 @@ void M_LoadData(void)

#if __JHERETIC__ || __JHEXEN__
R_CachePatch(&m_htic, "M_HTIC");
R_CachePatch(&dpFSlot, "M_FSLOT");
#endif

if(!menuFogData.texture && !Get(DD_NOVIDEO))
Expand Down Expand Up @@ -2396,9 +2404,9 @@ boolean M_EditResponder(event_t *ev)

if(saveStringEnter)
{
if(saveCharIndex < SAVESTRINGSIZE - 1 &&
if(saveCharIndex < SAVESTRINGSIZE &&
M_StringWidth(savegamestrings[saveSlot], huFontA)
< (SAVESTRINGSIZE - 2) * 8)
< (SAVESTRINGSIZE - 1) * 8)
{
savegamestrings[saveSlot][saveCharIndex++] = ch;
savegamestrings[saveSlot][saveCharIndex] = 0;
Expand Down Expand Up @@ -2688,7 +2696,7 @@ void M_SaveSelect(int option, void* data)
saveCharIndex = strlen(savegamestrings[option]);
}

void M_StartMessage(char *string, void *routine, boolean input)
void M_StartMessage(char* string, void* routine, boolean input)
{
messageResponse = 0;
messageLastMenuActive = menuActive;
Expand All @@ -2705,10 +2713,12 @@ void M_StartMessage(char *string, void *routine, boolean input)

void M_StopMessage(void)
{
menuActive = messageLastMenuActive;
messageToPrint = 0;

// Disable the menu binding class
if(!messageLastMenuActive)
Hu_MenuCommand(MCMD_CLOSEFAST);

// Disable the message binding class
DD_Executef(true, "deactivatebclass message");
}

Expand Down Expand Up @@ -2872,74 +2882,88 @@ void M_ReadSaveStrings(void)

void M_DrawLoad(void)
{
int i;
menu_t *menu = &LoadDef;
int i;
menu_t* menu = &LoadDef;
int width =
M_StringWidth("a", menu->font) * (SAVESTRINGSIZE - 1);

#if __JHERETIC__ || __JHEXEN__ || __JSTRIFE__
M_DrawTitle("LOAD GAME", 4);
#else
WI_DrawPatch(72, 28, menu->color[0], menu->color[1], menu->color[2], menuAlpha,
WI_DrawPatch(72, 24, menu->color[0], menu->color[1], menu->color[2], menuAlpha,
&m_loadg, "{case}LOAD GAME", true, ALIGN_LEFT);
#endif
for(i = 0; i < NUMSAVESLOTS; ++i)
{
M_DrawSaveLoadBorder(LoadDef.x, SAVEGAME_BOX_YOFFSET + LoadDef.y +
(menu->itemHeight * i));
M_WriteText2(LoadDef.x, SAVEGAME_BOX_YOFFSET + LoadDef.y +
M_DrawSaveLoadBorder(LoadDef.x - 8, SAVEGAME_BOX_YOFFSET + LoadDef.y +
(menu->itemHeight * i), width + 8);
M_WriteText2(LoadDef.x, SAVEGAME_BOX_YOFFSET + LoadDef.y + 1 +
(menu->itemHeight * i),
savegamestrings[i], menu->font, menu->color[0], menu->color[1],
menu->color[2], menuAlpha);
}

}

void M_DrawSave(void)
{
int i;
menu_t *menu = &SaveDef;
int i;
menu_t* menu = &SaveDef;
int width =
M_StringWidth("a", menu->font) * (SAVESTRINGSIZE - 1);

#if __JHERETIC__ || __JHEXEN__ || __JSTRIFE__
M_DrawTitle("SAVE GAME", 4);
#else
WI_DrawPatch(72, 28, menu->color[0], menu->color[1], menu->color[2], menuAlpha,
WI_DrawPatch(72, 24, menu->color[0], menu->color[1], menu->color[2], menuAlpha,
&m_saveg, "{case}SAVE GAME", true, ALIGN_LEFT);
#endif

for(i = 0; i < NUMSAVESLOTS; ++i)
{
M_DrawSaveLoadBorder(SaveDef.x, SAVEGAME_BOX_YOFFSET + SaveDef.y +
(menu->itemHeight * i));
M_WriteText2(SaveDef.x, SAVEGAME_BOX_YOFFSET + SaveDef.y + (menu->itemHeight * i),
M_DrawSaveLoadBorder(SaveDef.x - 8, SAVEGAME_BOX_YOFFSET + SaveDef.y +
(menu->itemHeight * i), width + 8);
M_WriteText2(SaveDef.x, SAVEGAME_BOX_YOFFSET + SaveDef.y + 1 +
(menu->itemHeight * i),
savegamestrings[i], menu->font, menu->color[0], menu->color[1],
menu->color[2], menuAlpha);
}

if(saveStringEnter)
{
i = M_StringWidth(savegamestrings[saveSlot], huFontA);
M_WriteText2(SaveDef.x + i, SAVEGAME_BOX_YOFFSET + SaveDef.y +
(menu->itemHeight * saveSlot), "_", huFontA, menu->color[0],
menu->color[1], menu->color[2], menuAlpha);
}
size_t len = strlen(savegamestrings[saveSlot]);

//if(len < SAVESTRINGSIZE)
{
i = M_StringWidth(savegamestrings[saveSlot], huFontA);
M_WriteText2(SaveDef.x + i, SAVEGAME_BOX_YOFFSET + SaveDef.y + 1 +
(menu->itemHeight * saveSlot), "_", huFontA,
menu->color[0], menu->color[1], menu->color[2],
menuAlpha);
}
}
}

/**
* Draw border for the savegame description
*/
void M_DrawSaveLoadBorder(int x, int y)
void M_DrawSaveLoadBorder(int x, int y, int width)
{
#if __JHERETIC__ || __JHEXEN__ || __JSTRIFE__
DGL_Color4f( 1, 1, 1, menuAlpha);
GL_DrawPatch_CS(x - 8, y - 4, W_GetNumForName("M_FSLOT"));
DGL_Color4f(1, 1, 1, menuAlpha);
GL_DrawPatch_CS(x - 8, y - 4, dpFSlot.lump);
#else
DGL_Color4f( 1, 1, 1, menuAlpha);
GL_DrawPatch_CS(x - 8, y + 8, W_GetNumForName("M_LSLEFT"));
GL_DrawPatch_CS(x + 8 * 24, y + 8, W_GetNumForName("M_LSRGHT"));
DGL_Color4f(1, 1, 1, menuAlpha);

GL_SetPatch(W_GetNumForName("M_LSCNTR"), DGL_REPEAT, DGL_REPEAT);
DGL_Color4f( 1, 1, 1, menuAlpha);
GL_DrawRectTiled(x - 3, y - 3, 24 * 8, 14, 8, 14);
GL_SetPatch(dpLSLeft.lump, DGL_CLAMP, DGL_CLAMP);
GL_DrawRect(x, y - 3, dpLSLeft.width, dpLSLeft.height, 1, 1, 1, menuAlpha);
GL_SetPatch(dpLSRight.lump, DGL_CLAMP, DGL_CLAMP);
GL_DrawRect(x + width - dpLSRight.width, y - 3, dpLSRight.width,
dpLSRight.height, 1, 1, 1, menuAlpha);

GL_SetPatch(dpLSCntr.lump, DGL_REPEAT, DGL_REPEAT);
GL_DrawRectTiled(x + dpLSLeft.width, y - 3,
width - dpLSLeft.width - dpLSRight.width,
14, 8, 14);
#endif
}

Expand Down Expand Up @@ -2997,7 +3021,7 @@ static void M_QuickSave(void)
Hu_MenuCommand(MCMD_OPEN);
M_ReadSaveStrings();
M_SetupNextMenu(&SaveDef);
quickSaveSlot = -2; // means to pick a slot now
quickSaveSlot = -2; // Means to pick a slot now.
return;
}
sprintf(tempstring, QSPROMPT, savegamestrings[quickSaveSlot]);
Expand Down Expand Up @@ -3751,6 +3775,7 @@ void M_SaveGame(int option, void *data)
return;
}

Hu_MenuCommand(MCMD_OPEN);
M_SetupNextMenu(&SaveDef);;
M_ReadSaveStrings();
}
Expand Down Expand Up @@ -3855,7 +3880,6 @@ boolean M_VerifyNightmare(int option, void *data)
else if(messageResponse == -1 || messageResponse == -2)
{
M_StopMessage();
Hu_MenuCommand(MCMD_CLOSE);
S_LocalSound(menusnds[1], NULL);
return true;
}
Expand Down Expand Up @@ -4284,7 +4308,6 @@ DEFCC(CCmdMenuAction)
#endif
if(!stricmp(argv[0], "SaveGame")) // F2
{
Hu_MenuCommand(MCMD_OPEN);
menuTime = 0;
//S_LocalSound(menusnds[2], NULL);
M_SaveGame(0, NULL);
Expand Down
23 changes: 12 additions & 11 deletions doomsday/plugins/common/src/m_multi.c
Expand Up @@ -75,7 +75,7 @@ void SCEnterGameSetup(int option, void* data);
void SCSetProtocol(int option, void* data);
void SCGameSetupFunc(int option, void* data);
void SCGameSetupEpisode(int option, void* data);
void SCGameSetupMission(int option, void* data);
void SCGameSetupMap(int option, void* data);
void SCGameSetupSkill(int option, void* data);
void SCGameSetupDeathmatch(int option, void* data);
void SCGameSetupDamageMod(int option, void* data);
Expand Down Expand Up @@ -140,7 +140,7 @@ menu_t MultiplayerMenu = {
# define NUM_GAMESETUP_ITEMS 11

menuitem_t GameSetupItems1[] = {
{ITT_LRFUNC, 0, "MAP:", SCGameSetupMission, 0},
{ITT_LRFUNC, 0, "MAP:", SCGameSetupMap, 0},
{ITT_EMPTY, 0, NULL, NULL, 0},
{ITT_LRFUNC, 0, "SKILL:", SCGameSetupSkill, 0},
{ITT_EFUNC, 0, "DEATHMATCH:", SCGameSetupFunc, 0, NULL, &cfg.netDeathmatch },
Expand All @@ -162,7 +162,7 @@ menuitem_t GameSetupItems1[] = {
menuitem_t GameSetupItems1[] = // for Heretic
{
{ITT_LRFUNC, 0, "EPISODE :", SCGameSetupEpisode, 0},
{ITT_LRFUNC, 0, "MISSION :", SCGameSetupMission, 0},
{ITT_LRFUNC, 0, "MAP :", SCGameSetupMap, 0},
{ITT_LRFUNC, 0, "SKILL :", SCGameSetupSkill, 0},
{ITT_LRFUNC, 0, "DEATHMATCH :", SCGameSetupDeathmatch, 0},
{ITT_EFUNC, 0, "MONSTERS :", SCGameSetupFunc, 0, NULL, &cfg.netNoMonsters },
Expand All @@ -184,7 +184,7 @@ menuitem_t GameSetupItems1[] = // for Heretic
menuitem_t GameSetupItems1[] = // for Doom 1
{
{ITT_LRFUNC, 0, "EPISODE :", SCGameSetupEpisode, 0},
{ITT_LRFUNC, 0, "MISSION :", SCGameSetupMission, 0},
{ITT_LRFUNC, 0, "MAP :", SCGameSetupMap, 0},
{ITT_LRFUNC, 0, "SKILL :", SCGameSetupSkill, 0},
{ITT_LRFUNC, 0, "MODE :", SCGameSetupDeathmatch, 0},
{ITT_EFUNC, 0, "MONSTERS :", SCGameSetupFunc, 0, NULL, &cfg.netNoMonsters },
Expand All @@ -206,7 +206,7 @@ menuitem_t GameSetupItems1[] = // for Doom 1

menuitem_t GameSetupItems2[] = // for Doom 2
{
{ITT_LRFUNC, 0, "LEVEL :", SCGameSetupMission, 0},
{ITT_LRFUNC, 0, "MAP :", SCGameSetupMap, 0},
{ITT_LRFUNC, 0, "SKILL :", SCGameSetupSkill, 0},
{ITT_LRFUNC, 0, "MODE :", SCGameSetupDeathmatch, 0},
{ITT_EFUNC, 0, "MONSTERS :", SCGameSetupFunc, 0, NULL, &cfg.netNoMonsters },
Expand All @@ -232,7 +232,7 @@ menuitem_t GameSetupItems2[] = // for Doom 2

menuitem_t GameSetupItems1[] =
{
{ITT_LRFUNC, 0, "LEVEL :", SCGameSetupMission, 0},
{ITT_LRFUNC, 0, "MAP :", SCGameSetupMap, 0},
{ITT_LRFUNC, 0, "SKILL :", SCGameSetupSkill, 0},
{ITT_LRFUNC, 0, "MODE :", SCGameSetupDeathmatch, 0},
{ITT_EFUNC, 0, "MONSTERS :", SCGameSetupFunc, 0, NULL, &cfg.netNoMonsters },
Expand Down Expand Up @@ -573,7 +573,7 @@ void SCEnterJoinMenu(int option, void* data)

void SCEnterGameSetup(int option, void* data)
{
// See to it that the episode and mission numbers are correct.
// See to it that the episode and map numbers are correct.
#if __JDOOM64__
if(cfg.netMap < 1)
cfg.netMap = 1;
Expand Down Expand Up @@ -683,7 +683,7 @@ void SCGameSetupEpisode(int option, void* data)
}
#endif

void SCGameSetupMission(int option, void* data)
void SCGameSetupMap(int option, void* data)
{
if(option == RIGHT_DIR)
{
Expand Down Expand Up @@ -724,7 +724,7 @@ void SCOpenServer(int option, void* data)
{
if(IS_NETGAME)
{
// Game already running, just change level.
// Game already running, just change map.
#if __JHEXEN__ || __JSTRIFE__
Executef(false, "setmap %i", cfg.netMap);
#elif __JDOOM64__
Expand Down Expand Up @@ -909,17 +909,18 @@ void DrawEditField(menu_t* menu, int index, editfield_t* ef)
int y = menu->y + menu->itemHeight * index;
int vis;
char buf[MAX_EDIT_LEN + 1], *text;
int width = M_StringWidth("a", huFontA) * 27;

M_DrawSaveLoadBorder(x + 11, y + 5);
strcpy(buf, ef->text);
strupr(buf);
if(ActiveEdit == ef && menuTime & 0x8)
strcat(buf, "_");
text = buf + ef->firstVisible;
vis = Ed_VisibleSlotChars(text, M_StringWidth);
text[vis] = 0;
M_WriteText2(x + 8, y + 5, text, huFontA, 1, 1, 1, Hu_MenuAlpha());

M_DrawSaveLoadBorder(x - 8, y + 2, width);
M_WriteText2(x, y + 3, text, huFontA, 1, 1, 1, Hu_MenuAlpha());
}

void SCEditField(int efptr, void* data)
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/jdoom/include/mn_def.h
Expand Up @@ -103,16 +103,16 @@ extern menu_t MultiplayerMenu;
extern menu_t GameSetupMenu;
extern menu_t PlayerSetupMenu;

void M_DrawTitle(char *text, int y);
void M_DrawTitle(char* text, int y);
void M_WriteMenuText(const menu_t* menu, int index, const char* text);

// Color widget.
void DrawColorWidget();
void SCColorWidget(int index, void* data);
void M_WGCurrentColor(int option, void* data);

void M_DrawSaveLoadBorder(int x, int y);
void M_SetupNextMenu(menu_t *menu);
void M_DrawSaveLoadBorder(int x, int y, int width);
void M_SetupNextMenu(menu_t* menu);
void M_DrawThermo(int x, int y, int thermWidth, int thermDot);
void MN_DrawSlider(const menu_t* menu, int item, int width, int slot);
void MN_DrawColorBox(const menu_t* menu, int index, float r,
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom64/include/mn_def.h
Expand Up @@ -112,7 +112,7 @@ void DrawColorWidget();
void SCColorWidget(int index, void *data);
void M_WGCurrentColor(int option, void *data);

void M_DrawSaveLoadBorder(int x, int y);
void M_DrawSaveLoadBorder(int x, int y, int width);
void M_SetupNextMenu(menu_t *menu);
void M_DrawThermo(int x, int y, int thermWidth, int thermDot);
void MN_DrawSlider(const menu_t *menu, int item, int width, int slot);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/include/mn_def.h
Expand Up @@ -112,7 +112,7 @@ void DrawColorWidget();
void SCColorWidget(int index, void *data);
void M_WGCurrentColor(int option, void *data);

void M_DrawSaveLoadBorder(int x, int y);
void M_DrawSaveLoadBorder(int x, int y, int width);
void M_SetupNextMenu(menu_t* menudef);
void M_DrawThermo(int x, int y, int thermWidth, int thermDot);
void MN_DrawSlider(const menu_t * menu, int item, int width, int slot);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jhexen/include/mn_def.h
Expand Up @@ -103,7 +103,7 @@ extern menu_t GameSetupMenu;
extern menu_t PlayerSetupMenu;

void M_StartControlPanel(void);
void M_DrawSaveLoadBorder(int x, int y);
void M_DrawSaveLoadBorder(int x, int y, int width);
void M_WriteMenuText(const menu_t *menu, int index, const char *text);

void M_StartMessage(char *string, void *routine, boolean input);
Expand Down

0 comments on commit 764771b

Please sign in to comment.