Skip to content

Commit

Permalink
Fixed Heretic/Hexen: Ensure the inventory widget is closed upon enter…
Browse files Browse the repository at this point in the history
…ing a new map or on player death if open.

Fixed Heretic/Hexen: Horizontal placement of the fullscreen inventory widget sub-elements calculated incorrectly.
  • Loading branch information
danij-deng committed Sep 23, 2010
1 parent 72d7e3b commit 5db8995
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 26 deletions.
8 changes: 7 additions & 1 deletion doomsday/plugins/common/src/d_netcl.c
Expand Up @@ -50,6 +50,7 @@
#include "g_common.h"
#include "p_actor.h"
#include "p_inventory.h"
#include "hu_inventory.h"

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -605,9 +606,14 @@ void NetCl_Intermission(byte* data)
{
uint i;

// Close any automaps left open at the end of the previous map.
// Close any HUDs left open at the end of the previous map.
for(i = 0; i < MAXPLAYERS; ++i)
{
AM_Open(AM_MapForPlayer(i), false, true);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(i, false);
#endif
}

GL_SetFilter(false);

Expand Down
24 changes: 21 additions & 3 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -1447,6 +1447,10 @@ boolean G_StartFinale(const char* script, int flags, finale_mode_t mode)

// Close the automap for all local players.
AM_Open(AM_MapForPlayer(i), false, true);

#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(i, false);
#endif
}}
FI_StackExecute(script, flags, mode);
return true;
Expand Down Expand Up @@ -2437,6 +2441,10 @@ void G_DoMapCompleted(void)
{
AM_Open(AM_MapForPlayer(i), false, true);

#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(i, false);
#endif

G_PlayerLeaveMap(i); // take away cards and stuff

// Update this client's stats.
Expand Down Expand Up @@ -2738,8 +2746,14 @@ void G_InitNew(skillmode_t skill, uint episode, uint map)

// Close any open automaps.
for(i = 0; i < MAXPLAYERS; ++i)
if(players[i].plr->inGame)
AM_Open(AM_MapForPlayer(i), false, true);
{
if(!players[i].plr->inGame)
continue;
AM_Open(AM_MapForPlayer(i), false, true);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(i, false);
#endif
}

// If there are any InFine scripts running, they must be stopped.
FI_StackClear();
Expand Down Expand Up @@ -3362,8 +3376,12 @@ int Hook_DemoStop(int hookType, int val, void* paramaters)

{int i;
for(i = 0; i < MAXPLAYERS; ++i)
{
AM_Open(AM_MapForPlayer(i), false, true);
}
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(i, false);
#endif
}}
return true;
}

Expand Down
31 changes: 11 additions & 20 deletions doomsday/plugins/common/src/hu_inventory.c
Expand Up @@ -278,6 +278,9 @@ static void inventoryIndexes(const player_t* plr, const hud_inventory_t* inv,
first = 0;
}

if(from < 0)
from = 0;

if(firstVisible)
*firstVisible = (unsigned) first;
if(cursorPos)
Expand Down Expand Up @@ -365,7 +368,7 @@ Draw_BeginZoom(invScale, x, y + ST_INVENTORYHEIGHT);
a = i == selected? .5f : light / 2;

DGL_Color4f(light, light, light, a * iconAlpha);
GL_DrawPatch(dpInvItemBox, x + slot * ST_INVSLOTWIDTH + ST_INVSLOTOFFX, y);
GL_DrawPatch(dpInvItemBox, x + slot * ST_INVSLOTWIDTH + (slot > 1? (slot-1) * ST_INVSLOTOFFX : 0), y);

if(i >= startSlot && i < endSlot)
{
Expand All @@ -375,9 +378,9 @@ Draw_BeginZoom(invScale, x, y + ST_INVENTORYHEIGHT);
if((count = P_InventoryCount(player, item->type)))
{
#if __JHEXEN__
int posX = x + slot * ST_INVSLOTWIDTH - 1;
int posX = x + slot * ST_INVSLOTWIDTH + (slot > 1? (slot-1) * ST_INVSLOTOFFX : 0) - 1;
#else
int posX = x + slot * ST_INVSLOTWIDTH;
int posX = x + slot * ST_INVSLOTWIDTH + (slot > 1? (slot-1) * ST_INVSLOTOFFX : 0);
#endif
DGL_Color4f(1, 1, 1, slot == selected? iconAlpha : iconAlpha / 2);
GL_DrawPatch(item->patchId, posX, y + ST_INVICONOFFY);
Expand All @@ -387,7 +390,7 @@ Draw_BeginZoom(invScale, x, y + ST_INVENTORYHEIGHT);
char buf[20];
DGL_Color4f(defFontRGB3[CR], defFontRGB3[CG], defFontRGB3[CB], slot == selected? textAlpha : textAlpha / 2);
dd_snprintf(buf, 20, "%i", count);
GL_DrawTextFragment4(buf, x + slot * ST_INVSLOTWIDTH + ST_INVCOUNTOFFX, y + ST_INVCOUNTOFFY, GF_SMALLIN, DTF_ALIGN_TOPRIGHT|DTF_NO_EFFECTS, TRACKING);
GL_DrawTextFragment4(buf, posX + ST_INVCOUNTOFFX, y + ST_INVCOUNTOFFY, GF_SMALLIN, DTF_ALIGN_TOPRIGHT|DTF_NO_EFFECTS, TRACKING);
}
}

Expand All @@ -398,7 +401,7 @@ Draw_BeginZoom(invScale, x, y + ST_INVENTORYHEIGHT);
}

DGL_Color4f(1, 1, 1, iconAlpha);
GL_DrawPatch(dpInvSelectBox, x + selected * ST_INVSLOTWIDTH, y + ST_INVSELECTOFFY - BORDER);
GL_DrawPatch(dpInvSelectBox, x + selected * ST_INVSLOTWIDTH + (selected > 1? (selected-1) * ST_INVSLOTOFFX : 0), y + ST_INVSELECTOFFY - BORDER);

if(inv->numUsedSlots > maxVisSlots)
{
Expand All @@ -414,7 +417,7 @@ Draw_BeginZoom(invScale, x, y + ST_INVENTORYHEIGHT);
if(cfg.inventoryWrap || inv->numUsedSlots - first > numVisSlots)
{
DGL_Color4f(1, 1, 1, iconAlpha);
GL_DrawPatch(dpInvPageRight[!(mapTime & 4)? 1 : 0], x + numVisSlots * ST_INVSLOTWIDTH + ARROW_RELXOFF + 1, y + ARROW_YOFFSET);
GL_DrawPatch(dpInvPageRight[!(mapTime & 4)? 1 : 0], x + numVisSlots * ST_INVSLOTWIDTH + (numVisSlots > 1? (numVisSlots-1) * ST_INVSLOTOFFX : 0) + ARROW_RELXOFF - 2, y + ARROW_YOFFSET);
}

#undef ARROW_XOFFSET
Expand Down Expand Up @@ -497,26 +500,14 @@ void Hu_InventoryDraw2(int player, int x, int y, float alpha)
if(cfg.inventoryWrap || first != 0)
{
DGL_Color4f(1, 1, 1, alpha);
GL_DrawPatch(dpInvPageLeft[!(mapTime & 4)? 1 : 0],
#if __JHEXEN__
42, 163
#else
x - 12, y - 1
#endif
);
GL_DrawPatch(dpInvPageLeft[!(mapTime & 4)? 1 : 0], x - 12, y - 1);
}

// Draw more right indicator.
if(cfg.inventoryWrap || inv->numUsedSlots - first > NUMVISINVSLOTS)
{
DGL_Color4f(1, 1, 1, alpha);
GL_DrawPatch(dpInvPageRight[!(mapTime & 4)? 1 : 0], 269,
#if __JHEXEN__
163
#else
y - 1
#endif
);
GL_DrawPatch(dpInvPageRight[!(mapTime & 4)? 1 : 0], x + NUMVISINVSLOTS * ST_INVSLOTWIDTH + (NUMVISINVSLOTS-1) * ST_INVSLOTOFFX - 2, y - 1);
}
}

Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jdoom/src/p_inter.c
Expand Up @@ -938,6 +938,9 @@ void P_KillMobj(mobj_t *source, mobj_t *target, boolean stomping)

// Don't die with the automap open.
AM_Open(AM_MapForPlayer(target->player - players), false, false);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(target->player - players, false);
#endif
}

if(target->health < -target->info->spawnHealth &&
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jdoom64/src/p_inter.c
Expand Up @@ -950,6 +950,9 @@ void P_KillMobj(mobj_t *source, mobj_t *target, boolean stomping)

// Don't die with the automap open.
AM_Open(AM_MapForPlayer(target->player - players), false, false);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(target->player - players, false);
#endif
}

if((state = P_GetState(target->type, SN_XDEATH)) != S_NULL &&
Expand Down
4 changes: 4 additions & 0 deletions doomsday/plugins/jheretic/src/p_inter.c
Expand Up @@ -36,6 +36,7 @@
#include "dmu_lib.h"
#include "p_player.h"
#include "p_inventory.h"
#include "hu_inventory.h"
#include "p_tick.h"
#include "p_user.h"
#include "p_mapsetup.h"
Expand Down Expand Up @@ -968,6 +969,9 @@ void P_KillMobj(mobj_t* source, mobj_t* target)

// Don't die with the automap open.
AM_Open(AM_MapForPlayer(target->player - players), false, false);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(target->player - players, false);
#endif
}

if((state = P_GetState(target->type, SN_XDEATH)) != S_NULL &&
Expand Down
9 changes: 7 additions & 2 deletions doomsday/plugins/jhexen/src/m_cheat.c
Expand Up @@ -44,6 +44,7 @@
#include "p_user.h"
#include "p_start.h"
#include "p_inventory.h"
#include "hu_inventory.h"
#include "g_eventsequence.h"

// MACROS ------------------------------------------------------------------
Expand Down Expand Up @@ -390,8 +391,12 @@ int Cht_WarpFunc(const int* args, int player)

// Close any open automaps.
for(i = 0; i < MAXPLAYERS; ++i)
if(players[i].plr->inGame)
AM_Open(AM_MapForPlayer(i), false, true);
{
if(!players[i].plr->inGame)
continue;
AM_Open(AM_MapForPlayer(i), false, true);
Hu_InventoryOpen(i, false);
}

// So be it.
if(userGame)
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jhexen/src/p_inter.c
Expand Up @@ -1463,6 +1463,9 @@ void P_KillMobj(mobj_t* source, mobj_t* target)

// Don't die with the automap open.
AM_Open(AM_MapForPlayer(target->player - players), false, false);
#if __JHERETIC__ || __JHEXEN__
Hu_InventoryOpen(target->player - players, false);
#endif
}
else
{ // Target is some monster or an object.
Expand Down

0 comments on commit 5db8995

Please sign in to comment.