Skip to content

Commit

Permalink
Extensive changes to the various game-side HUD displays to consider m…
Browse files Browse the repository at this point in the history
…ultiple local players.

* G_Display is now used for in-viewport displays where as G_Display2 is for over-viewport displays.
* Fixed all issues with the various HUD displays when multiple local players are present.
* Reworked all game HUD displays so that there is no need to inform HUD/statusbar code when a player changes class (we don't handle resources like DOOM.exe any more so this was unnecessary). Changed resource management accordingly and patches are cached using R_CachePatch.
* The engine-side view offset and psprite bob positions are now set in one place (the game-side rendPlayerView) before calling R_RenderPlayerView.
* Automatically un-hide the statusbar when changing it's size and alpha via the menu.
* Removed the unused detail paramater with R_SetViewSize.

Part 1 of 5.
  • Loading branch information
danij committed Aug 26, 2008
1 parent 74bde8c commit c5735cb
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 73 deletions.
8 changes: 0 additions & 8 deletions doomsday/plugins/common/src/d_net.c
Expand Up @@ -175,10 +175,6 @@ int D_NetServerStarted(int before)
randomClassParm = cfg.netRandomClass;
#endif

#if __JDOOM__ || __JDOOM64__
ST_updateGraphics();
#endif

// Hexen has translated map numbers.
#if __JHEXEN__
netMap = P_TranslateMap(cfg.netMap);
Expand Down Expand Up @@ -695,10 +691,6 @@ DEFCC(CCmdSetColor)

cfg.playerColor[player] = PLR_COLOR(player, cfg.netColor);

#if __JDOOM__ || __JDOOM64__
ST_updateGraphics();
#endif

// Change the color of the mobj (translation flags).
players[player].plr->mo->flags &= ~MF_TRANSLATION;

Expand Down
46 changes: 18 additions & 28 deletions doomsday/plugins/common/src/d_netcl.c
Expand Up @@ -301,9 +301,8 @@ void NetCl_UpdatePlayerState2(byte *data, int plrNum)
val = (k & (1 << i)) != 0;

// Maybe unhide the HUD?
if(val == true && pl->weapons[i].owned == false &&
pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_WEAPON);
if(val == true && pl->weapons[i].owned == false)
ST_HUDUnHide(pl - players, HUE_ON_PICKUP_WEAPON);

pl->weapons[i].owned = val;
}
Expand Down Expand Up @@ -381,8 +380,8 @@ void NetCl_UpdatePlayerState(byte *data, int plrNum)
{
int health = NetCl_ReadByte();

if(health < pl->health && pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_DAMAGE);
if(health < pl->health)
ST_HUDUnHide(plrNum, HUE_ON_DAMAGE);

pl->health = health;
pl->plr->mo->health = pl->health;
Expand All @@ -399,16 +398,16 @@ void NetCl_UpdatePlayerState(byte *data, int plrNum)
// Maybe unhide the HUD?
if(ap >= pl->armorPoints[i] &&
pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_ARMOR);
ST_HUDUnHide(plrNum, HUE_ON_PICKUP_ARMOR);

pl->armorPoints[i] = ap;
}
#else
ap = NetCl_ReadByte();

// Maybe unhide the HUD?
if(ap >= pl->armorPoints && pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_ARMOR);
if(ap >= pl->armorPoints)
ST_HUDUnHide(plrNum, HUE_ON_PICKUP_ARMOR);

pl->armorPoints = ap;
#endif
Expand Down Expand Up @@ -437,8 +436,7 @@ void NetCl_UpdatePlayerState(byte *data, int plrNum)
pl->artifactCount += pl->inventory[i].count;

// Maybe unhide the HUD?
if(pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_INVITEM);
ST_HUDUnHide(pl - players, HUE_ON_PICKUP_INVITEM);
}
}

Expand All @@ -459,9 +457,8 @@ void NetCl_UpdatePlayerState(byte *data, int plrNum)
byte val = ((b & (1 << i))? (NetCl_ReadByte() * 35) : 0);

// Maybe unhide the HUD?
if(val > pl->powers[i] &&
pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_POWER);
if(val > pl->powers[i])
ST_HUDUnHide(pl - players, HUE_ON_PICKUP_POWER);

pl->powers[i + 1] = val;
}
Expand All @@ -476,9 +473,8 @@ void NetCl_UpdatePlayerState(byte *data, int plrNum)
int val = ((b & (1 << i))? (NetCl_ReadByte() * 35) : 0);

// Maybe unhide the HUD?
if(val > pl->powers[i] &&
pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_POWER);
if(val > pl->powers[i])
ST_HUDUnHide(plrNum, HUE_ON_PICKUP_POWER);

pl->powers[i] = val;
}
Expand All @@ -495,8 +491,8 @@ void NetCl_UpdatePlayerState(byte *data, int plrNum)
boolean val = (b & (1 << i)) != 0;

// Maybe unhide the HUD?
if(val && !pl->keys[i] && pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_KEY);
if(val && !pl->keys[i])
ST_HUDUnHide(plrNum, HUE_ON_PICKUP_KEY);

pl->keys[i] = val;
}
Expand Down Expand Up @@ -530,9 +526,8 @@ void NetCl_UpdatePlayerState(byte *data, int plrNum)
val = (b & (1 << i)) != 0;

// Maybe unhide the HUD?
if(val == true && pl->weapons[i].owned == false &&
pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_WEAPON);
if(val == true && pl->weapons[i].owned == false)
ST_HUDUnHide(plrNum, HUE_ON_PICKUP_WEAPON);

pl->weapons[i].owned = val;
}
Expand All @@ -548,8 +543,8 @@ void NetCl_UpdatePlayerState(byte *data, int plrNum)
int val = NetCl_ReadShort();
#endif
// Maybe unhide the HUD?
if(val > pl->ammo[i].owned && pl == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_AMMO);
if(val > pl->ammo[i].owned)
ST_HUDUnHide(plrNum, HUE_ON_PICKUP_AMMO);

pl->ammo[i].owned = val;
}
Expand Down Expand Up @@ -761,11 +756,6 @@ void NetCl_UpdatePlayerInfo(byte *data)
#if __JHEXEN__ || __JHERETIC__
cfg.playerClass[num] = NetCl_ReadByte();
players[num].class = cfg.playerClass[num];
if(num == CONSOLEPLAYER)
SB_SetClassData();
#endif
#if __JDOOM__ || __JDOOM64__
ST_updateGraphics();
#endif

#if __JDOOM__ || __JSTRIFE__ || __JDOOM64__
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/g_controls.c
Expand Up @@ -821,7 +821,7 @@ static void G_UpdateCmdControls(ticcmd_t *cmd, int pnum,
{
plr->readyArtifact = plr->inventory[plr->invPtr].type;

ST_Inventory(false); // close the inventory
ST_Inventory(plr - players, false); // close the inventory

if(cfg.chooseAndUse)
cmd->arti = plr->inventory[plr->invPtr].type;
Expand Down
14 changes: 2 additions & 12 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -495,13 +495,13 @@ void G_CommonPostInit(void)
// Init the save system and create the game save directory
SV_Init();

#ifndef __JHEXEN__
#if __JDOOM__ || __JDOOM64__ || __JHERETIC__ || __WOLFTC__
XG_ReadTypes();
XG_Register(); // Register XG classnames.
#endif

DD_SetVariable(DD_SKYMASKMATERIAL_NAME, SKYFLATNAME);
R_SetViewSize(cfg.screenBlocks, 0);
R_SetViewSize(cfg.screenBlocks);

Con_Message("P_Init: Init Playloop state.\n");
P_Init();
Expand Down Expand Up @@ -1090,8 +1090,6 @@ void G_PlayerExitMap(int player)

// Misc
#if __JHERETIC__
playerKeys = 0;

p->rain1 = NULL;
p->rain2 = NULL;
#endif
Expand Down Expand Up @@ -1268,12 +1266,6 @@ void G_PlayerReborn(int player)

#if __JHERETIC__ || __JHEXEN__ || __JSTRIFE__
P_InventoryResetCursor(p);
if(p == &players[CONSOLEPLAYER])
{
# if __JHEXEN__ || __JSTRIFE__
SB_state = -1; // Refresh the status bar.
# endif
}
#endif

// We'll need to update almost everything.
Expand Down Expand Up @@ -1836,7 +1828,6 @@ void G_DoSingleReborn(void)
{
G_SetGameAction(GA_NONE);
SV_LoadGame(SV_HxGetRebornSlot());
SB_SetClassData();
}
#endif

Expand Down Expand Up @@ -1874,7 +1865,6 @@ void G_DoLoadGame(void)
{ // Copy the base slot to the reborn slot
SV_HxUpdateRebornSlot();
}
SB_SetClassData();
#else
SV_LoadGame(saveName);
#endif
Expand Down
33 changes: 17 additions & 16 deletions doomsday/plugins/common/src/hu_menu.c
Expand Up @@ -345,10 +345,10 @@ int menusnds[] = {

// PRIVATE DATA DEFINITIONS ------------------------------------------------

static boolean menuActive;
static boolean menuActive;

float menuAlpha = 0; // Alpha level for the entire menu.
static float menuTargetAlpha = 0; // Target alpha for the entire UI.
static float menuAlpha = 0; // Alpha level for the entire menu.
static float menuTargetAlpha = 0; // Target alpha for the entire UI.

#if __JHERETIC__ || __JHEXEN__ || __JSTRIFE__
static int SkullBaseLump;
Expand Down Expand Up @@ -1517,7 +1517,7 @@ void Hu_MenuInit(void)
EpiDef.y = 50 - ITEM_HEIGHT;
}
#endif

M_InitControlsMenu();
}

Expand Down Expand Up @@ -1911,12 +1911,12 @@ void Hu_MenuDrawer(void)

if(!menuActive && !(menuAlpha > 0) && !(menuFogData.alpha > 0))
goto end_draw_menu;

if(allowScaling && currentMenu->unscaled.numVisItems)
{
currentMenu->numVisItems = currentMenu->unscaled.numVisItems / cfg.menuScale;
currentMenu->y = 110 - (110 - currentMenu->unscaled.y) / cfg.menuScale;

if(currentMenu->firstItem && currentMenu->firstItem < currentMenu->numVisItems)
{
// Make sure all pages are divided correctly.
Expand Down Expand Up @@ -2078,12 +2078,12 @@ void Hu_MenuCommand(menucommand_e cmd)
menuActive = false;
fadingOut = true;
outFade = 0;

// Disable the menu binding class
DD_Execute(true, "deactivatebclass menu");
return;
}

if(!menuActive)
{
if(cmd == MCMD_OPEN)
Expand Down Expand Up @@ -2251,7 +2251,7 @@ void Hu_MenuCommand(menucommand_e cmd)
}
}
break;

case MCMD_SELECT:
if(item->type == ITT_SETMENU)
{
Expand Down Expand Up @@ -3458,12 +3458,16 @@ void M_SizeStatusBar(int option, void *data)
else if(cfg.statusbarScale > 1)
cfg.statusbarScale--;

R_SetViewSize(cfg.screenBlocks, 0);
ST_HUDUnHide(CONSOLEPLAYER, HUE_FORCE);

R_SetViewSize(cfg.screenBlocks);
}

void M_StatusBarAlpha(int option, void *data)
{
M_FloatMod10(&cfg.statusbarAlpha, option);

ST_HUDUnHide(CONSOLEPLAYER, HUE_FORCE);
}
#endif

Expand Down Expand Up @@ -3639,6 +3643,7 @@ void M_HUDScale(int option, void *data)
val--;

cfg.hudScale = val / 10.0f;
ST_HUDUnHide(CONSOLEPLAYER, HUE_FORCE);
}

#if __JDOOM__ || __JDOOM64__
Expand Down Expand Up @@ -3808,13 +3813,8 @@ boolean M_VerifyNightmare(int option, void *data)
void M_ChooseSkill(int option, void *data)
{
#if __JHEXEN__
extern int SB_state;

cfg.playerClass[CONSOLEPLAYER] = MenuPClass;
G_DeferredNewGame(option);
SB_SetClassData();
SB_state = -1;

#else
# if __JDOOM__ || __JSTRIFE__
if(option == SM_NIGHTMARE)
Expand Down Expand Up @@ -3899,7 +3899,8 @@ void M_SizeDisplay(int option, void *data)
{
cfg.screenBlocks--;
}
R_SetViewSize(cfg.screenBlocks, 0);

R_SetViewSize(cfg.screenBlocks);
}

void M_OpenDCP(int option, void *data)
Expand Down
13 changes: 7 additions & 6 deletions doomsday/plugins/common/src/p_inventory.c
Expand Up @@ -169,8 +169,7 @@ boolean P_GiveArtifact(player_t *player, artitype_e arti, mobj_t *mo)
player->artifactCount++;

// Maybe unhide the HUD?
if(player == &players[CONSOLEPLAYER])
ST_HUDUnHide(HUE_ON_PICKUP_INVITEM);
ST_HUDUnHide(player - players, HUE_ON_PICKUP_INVITEM);

return true;
}
Expand Down Expand Up @@ -315,7 +314,7 @@ boolean P_InventoryUseArtifact(player_t *player, artitype_e arti)
S_ConsoleSound(SFX_PUZZLE_SUCCESS, NULL, player - players);
}
# endif
ST_InventoryFlashCurrent(player);
ST_InventoryFlashCurrent(player - players);
}
else if(cfg.inventoryNextOnUnuse)
{
Expand Down Expand Up @@ -618,13 +617,15 @@ boolean P_UseArtifactOnPlayer(player_t *player, artitype_e arti)
*/
static boolean P_InventoryMove(player_t* plr, int dir)
{
if(!ST_IsInventoryVisible())
int player = plr - players;

if(!ST_IsInventoryVisible(player))
{
ST_Inventory(true);
ST_Inventory(player, true);
return false;
}

ST_Inventory(true); // reset the inventory auto-hide timer
ST_Inventory(player, true); // Reset the inventory auto-hide timer.

if(dir == 0)
{
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/src/p_user.c
Expand Up @@ -1292,11 +1292,11 @@ void P_PlayerThinkItems(player_t *player)
else
{
// If the inventory is visible, just close it (depending on cfg.chooseAndUse).
if(ST_IsInventoryVisible())
if(ST_IsInventoryVisible(player - players))
{
player->readyArtifact = player->inventory[player->invPtr].type;

ST_Inventory(false); // close the inventory
ST_Inventory(player - players, false); // close the inventory

if(cfg.chooseAndUse)
arti = player->inventory[player->invPtr].type;
Expand Down

0 comments on commit c5735cb

Please sign in to comment.