Skip to content

Commit

Permalink
Changed DOOM: Draw all owned keys on the statusbar if not cvar "hud-k…
Browse files Browse the repository at this point in the history
…eys-combine" (e.g., if the player owns both the Blue Keycard and the Blue Skull they will both be drawn in slot 1).
  • Loading branch information
danij-deng committed May 20, 2010
1 parent de9001e commit 11236c3
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions doomsday/plugins/jdoom/src/st_stuff.c
Expand Up @@ -184,7 +184,6 @@ typedef struct {

boolean statusbarActive; // Whether the statusbar is active.
int currentFragsCount; // Number of frags so far in deathmatch.
int keyBoxes[3]; // Holds key-type for each key box on bar.
int readyAmmo;
int health;
int armor;
Expand Down Expand Up @@ -742,15 +741,6 @@ void ST_updateWidgets(int player)
hud->readyAmmo = 1994; // Means "n/a".
}

// Update keycard multiple widgets.
for(i = 0; i < 3; ++i)
{
hud->keyBoxes[i] = plr->keys[i] ? i : -1;

if(plr->keys[i + 3])
hud->keyBoxes[i] = i + 3;
}

// Refresh everything if this is him coming back to life.
ST_updateFaceWidget(player);

Expand Down Expand Up @@ -1234,18 +1224,28 @@ void drawSBarKeysWidget(int player, float textAlpha, float iconAlpha,
DGL_Translatef(0, yOffset, 0);
for(i = 0; i < 3; ++i)
{
const loc_t* element = &elements[i];
const patchinfo_t* patch;
const loc_t* element;
uint key;
if(hud->keyBoxes[i] == -1)
continue;
key = hud->keyBoxes[i];
element = &elements[key%3];
patch = &keys[key];
WI_DrawPatch4(patch->id, element->x, element->y, NULL, GF_FONTB, false, DPF_ALIGN_TOPLEFT, 1, 1, 1, iconAlpha);
if(patch->width > *drawnWidth)
*drawnWidth = patch->width;
*drawnHeight += patch->height;
int offset = ((!cfg.hudKeysCombine && plr->keys[i] && plr->keys[i+3])? -1 : 0);

if(plr->keys[i+3] || (cfg.hudKeysCombine && plr->keys[i]))
{
patch = &keys[i+3];
WI_DrawPatch4(patch->id, element->x + offset, element->y + offset, NULL, GF_FONTB, false, DPF_ALIGN_TOPLEFT, 1, 1, 1, iconAlpha);
if(patch->width > *drawnWidth)
*drawnWidth = patch->width;
*drawnHeight += patch->height;
}

if(!cfg.hudKeysCombine && plr->keys[i])
{
patch = &keys[i];
WI_DrawPatch4(patch->id, element->x - offset, element->y - offset, NULL, GF_FONTB, false, DPF_ALIGN_TOPLEFT, 1, 1, 1, iconAlpha);
if(patch->width + 2 > *drawnWidth)
*drawnWidth = patch->width + 2;
if(patch->height + 2 > *drawnHeight)
*drawnHeight = patch->height + 2;
}
}
DGL_MatrixMode(DGL_MODELVIEW);
DGL_Translatef(0, -yOffset, 0);
Expand Down Expand Up @@ -2004,11 +2004,6 @@ static void initData(hudstate_t* hud)
hud->lastAttackDown = -1;
hud->showBar = 1;

for(i = 0; i < 3; ++i)
{
hud->keyBoxes[i] = -1;
}

for(i = 0; i < NUM_WEAPON_TYPES; ++i)
{
hud->oldWeaponsOwned[i] = plr->weapons[i].owned;
Expand Down

0 comments on commit 11236c3

Please sign in to comment.