2008-03-22 09:26:59 +00:00
|
|
|
/*
|
|
|
|
** sbarinfo_display.cpp
|
|
|
|
**
|
|
|
|
** Contains all functions required for the display of custom statusbars.
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 2008 Braden Obrzut
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2008-03-19 09:53:23 +00:00
|
|
|
#include "doomtype.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "v_font.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "sbar.h"
|
|
|
|
#include "r_defs.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
#include "st_stuff.h"
|
|
|
|
#include "r_local.h"
|
|
|
|
#include "m_swap.h"
|
|
|
|
#include "a_keys.h"
|
|
|
|
#include "templates.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "sbarinfo.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "r_translate.h"
|
|
|
|
#include "r_main.h"
|
|
|
|
|
|
|
|
static FRandom pr_chainwiggle; //use the same method of chain wiggling as heretic.
|
|
|
|
|
|
|
|
#define ST_RAMPAGETIME (TICRATE*2)
|
|
|
|
#define ARTIFLASH_OFFSET (invBarOffset+6)
|
|
|
|
|
|
|
|
EXTERN_CVAR(Int, fraglimit)
|
|
|
|
EXTERN_CVAR(Int, screenblocks)
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
imgARTIBOX,
|
|
|
|
imgSELECTBOX,
|
|
|
|
imgINVLFGEM1,
|
|
|
|
imgINVLFGEM2,
|
|
|
|
imgINVRTGEM1,
|
|
|
|
imgINVRTGEM2,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Custom Mug Shot Stuff (Find mug shot state functions are with the parser).
|
|
|
|
MugShotFrame::MugShotFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MugShotFrame::~MugShotFrame()
|
|
|
|
{
|
|
|
|
graphic.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
//Assemble a graphic name with the specified prefix and return the FTexture.
|
2008-03-24 17:48:55 +00:00
|
|
|
FTexture *MugShotFrame::getTexture(FString &defaultFace, FPlayerSkin *skin, int random, int level, int direction, bool usesLevels, bool health2, bool healthspecial, bool directional)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
int index = !directional ? random % graphic.Size() : direction;
|
|
|
|
if(index > (signed int) (graphic.Size()-1))
|
|
|
|
index = graphic.Size()-1;
|
2008-04-20 00:23:07 +00:00
|
|
|
FString sprite(skin->face[0] != 0 ? skin->face : &defaultFace[0], 3);
|
|
|
|
sprite += graphic[index];
|
2008-03-19 09:53:23 +00:00
|
|
|
if(usesLevels) //change the last character to the level
|
|
|
|
{
|
|
|
|
if(!health2 && (!healthspecial || index == 1))
|
2008-04-20 00:23:07 +00:00
|
|
|
sprite.LockBuffer()[2 + graphic[index].Len()] += level;
|
2008-03-19 09:53:23 +00:00
|
|
|
else
|
2008-04-20 00:23:07 +00:00
|
|
|
sprite.LockBuffer()[1 + graphic[index].Len()] += level;
|
|
|
|
sprite.UnlockBuffer();
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
return TexMan[TexMan.CheckForTexture(sprite, 0, true)];
|
|
|
|
}
|
|
|
|
|
|
|
|
MugShotState::MugShotState()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
MugShotState::MugShotState(FString name)
|
|
|
|
{
|
|
|
|
name.ToLower();
|
|
|
|
state = FName(name);
|
|
|
|
usesLevels = false;
|
|
|
|
health2 = false;
|
|
|
|
healthspecial = false;
|
|
|
|
directional = false;
|
|
|
|
random = M_Random();
|
|
|
|
}
|
|
|
|
|
|
|
|
MugShotState::~MugShotState()
|
|
|
|
{
|
|
|
|
frames.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MugShotState::tick()
|
|
|
|
{
|
|
|
|
if(time == -1) //When the delay is negative 1 stay on this frame indefinitely
|
|
|
|
return;
|
|
|
|
if(time != 0)
|
|
|
|
{
|
|
|
|
time--;
|
|
|
|
}
|
|
|
|
else if(position != frames.Size()-1)
|
|
|
|
{
|
|
|
|
position++;
|
|
|
|
time = frames[position].delay;
|
|
|
|
random = M_Random();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
finished = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MugShotState::reset()
|
|
|
|
{
|
|
|
|
time = frames[0].delay;
|
|
|
|
position = 0;
|
|
|
|
finished = false;
|
|
|
|
random = M_Random();
|
|
|
|
}
|
|
|
|
|
|
|
|
//Used for shading
|
|
|
|
FBarShader::FBarShader(bool vertical, bool reverse) //make an alpha map
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
Width = vertical ? 2 : 256;
|
|
|
|
Height = vertical ? 256 : 2;
|
|
|
|
CalcBitSize();
|
|
|
|
|
|
|
|
// Fill the column/row with shading values.
|
|
|
|
// Vertical shaders have have minimum alpha at the top
|
|
|
|
// and maximum alpha at the bottom, unless flipped by
|
|
|
|
// setting reverse to true. Horizontal shaders are just
|
|
|
|
// the opposite.
|
|
|
|
if (vertical)
|
|
|
|
{
|
|
|
|
if (!reverse)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 256; ++i)
|
|
|
|
{
|
|
|
|
Pixels[i] = i;
|
|
|
|
Pixels[256+i] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < 256; ++i)
|
|
|
|
{
|
|
|
|
Pixels[i] = 255 - i;
|
|
|
|
Pixels[256+i] = 255 -i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!reverse)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 256; ++i)
|
|
|
|
{
|
|
|
|
Pixels[i*2] = 255 - i;
|
|
|
|
Pixels[i*2+1] = 255 - i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < 256; ++i)
|
|
|
|
{
|
|
|
|
Pixels[i*2] = i;
|
|
|
|
Pixels[i*2+1] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DummySpan[0].TopOffset = 0;
|
2008-05-14 23:39:40 +00:00
|
|
|
DummySpan[0].Length = vertical ? 256 : 2;
|
2008-03-19 09:53:23 +00:00
|
|
|
DummySpan[1].TopOffset = 0;
|
|
|
|
DummySpan[1].Length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BYTE *FBarShader::GetColumn(unsigned int column, const Span **spans_out)
|
|
|
|
{
|
|
|
|
if (spans_out != NULL)
|
|
|
|
{
|
|
|
|
*spans_out = DummySpan;
|
|
|
|
}
|
2008-05-14 23:39:40 +00:00
|
|
|
return Pixels + ((column & WidthMask) << HeightBits);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const BYTE *FBarShader::GetPixels()
|
|
|
|
{
|
|
|
|
return Pixels;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FBarShader::Unload()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//SBarInfo Display
|
|
|
|
DSBarInfo::DSBarInfo () : DBaseStatusBar (SBarInfoScript->height),
|
|
|
|
shader_horz_normal(false, false),
|
|
|
|
shader_horz_reverse(false, true),
|
|
|
|
shader_vert_normal(true, false),
|
|
|
|
shader_vert_reverse(true, true)
|
|
|
|
{
|
|
|
|
static const char *InventoryBarLumps[] =
|
|
|
|
{
|
|
|
|
"ARTIBOX", "SELECTBO", "INVGEML1",
|
|
|
|
"INVGEML2", "INVGEMR1", "INVGEMR2",
|
|
|
|
"USEARTIA", "USEARTIB", "USEARTIC", "USEARTID",
|
|
|
|
};
|
|
|
|
TArray<const char *> patchnames;
|
|
|
|
patchnames.Resize(SBarInfoScript->Images.Size()+10);
|
|
|
|
unsigned int i = 0;
|
|
|
|
for(i = 0;i < SBarInfoScript->Images.Size();i++)
|
|
|
|
{
|
|
|
|
patchnames[i] = SBarInfoScript->Images[i];
|
|
|
|
}
|
|
|
|
for(i = 0;i < 10;i++)
|
|
|
|
{
|
|
|
|
patchnames[i+SBarInfoScript->Images.Size()] = InventoryBarLumps[i];
|
|
|
|
}
|
2008-03-26 08:50:54 +00:00
|
|
|
for (i = 0;i < numskins;i++)
|
|
|
|
{
|
|
|
|
AddFaceToImageCollection (&skins[i], &Images);
|
|
|
|
}
|
2008-03-19 09:53:23 +00:00
|
|
|
invBarOffset = SBarInfoScript->Images.Size();
|
|
|
|
Images.Init(&patchnames[0], patchnames.Size());
|
|
|
|
drawingFont = V_GetFont("ConFont");
|
|
|
|
rampageTimer = 0;
|
|
|
|
oldHealth = 0;
|
|
|
|
oldArmor = 0;
|
|
|
|
mugshotHealth = -1;
|
|
|
|
lastPrefix = "";
|
|
|
|
weaponGrin = false;
|
|
|
|
damageFaceActive = false;
|
|
|
|
lastDamageAngle = 1;
|
|
|
|
chainWiggle = 0;
|
|
|
|
artiflash = 4;
|
|
|
|
currentState = NULL;
|
2008-04-09 07:32:33 +00:00
|
|
|
currentPopup = POP_None;
|
|
|
|
pendingPopup = POP_None;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DSBarInfo::~DSBarInfo ()
|
|
|
|
{
|
|
|
|
Images.Uninit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSBarInfo::Draw (EHudState state)
|
|
|
|
{
|
|
|
|
DBaseStatusBar::Draw(state);
|
2008-03-22 09:26:59 +00:00
|
|
|
int hud = STBAR_NORMAL;
|
2008-03-19 09:53:23 +00:00
|
|
|
if(state == HUD_StatusBar)
|
|
|
|
{
|
|
|
|
if(SBarInfoScript->completeBorder) //Fill the statusbar with the border before we draw.
|
|
|
|
{
|
|
|
|
FTexture *b = TexMan[gameinfo.border->b];
|
|
|
|
R_DrawBorder(viewwindowx, viewwindowy + realviewheight + b->GetHeight(), viewwindowx + realviewwidth, SCREENHEIGHT);
|
|
|
|
if(screenblocks == 10)
|
|
|
|
screen->FlatFill(viewwindowx, viewwindowy + realviewheight, viewwindowx + realviewwidth, viewwindowy + realviewheight + b->GetHeight(), b, true);
|
|
|
|
}
|
|
|
|
if(SBarInfoScript->automapbar && automapactive)
|
|
|
|
{
|
2008-03-22 09:26:59 +00:00
|
|
|
hud = STBAR_AUTOMAP;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-22 09:26:59 +00:00
|
|
|
hud = STBAR_NORMAL;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(state == HUD_Fullscreen)
|
|
|
|
{
|
2008-03-22 09:26:59 +00:00
|
|
|
hud = STBAR_FULLSCREEN;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-22 09:26:59 +00:00
|
|
|
hud = STBAR_NONE;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
if(SBarInfoScript->huds[hud].forceScaled) //scale the statusbar
|
|
|
|
{
|
|
|
|
SetScaled(true);
|
|
|
|
setsizeneeded = true;
|
|
|
|
}
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(SBarInfoScript->huds[hud], 0, 0, SBarInfoScript->huds[hud].alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
if(CPlayer->inventorytics > 0 && !(level.flags & LEVEL_NOINVENTORYBAR))
|
|
|
|
{
|
|
|
|
if(state == HUD_StatusBar)
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(SBarInfoScript->huds[STBAR_INVENTORY], 0, 0, SBarInfoScript->huds[STBAR_INVENTORY].alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
else if(state == HUD_Fullscreen)
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(SBarInfoScript->huds[STBAR_INVENTORYFULLSCREEN], 0, 0, SBarInfoScript->huds[STBAR_INVENTORYFULLSCREEN].alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
2008-03-24 17:48:55 +00:00
|
|
|
if(currentPopup != POP_None)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
int popbar = 0;
|
2008-03-24 17:48:55 +00:00
|
|
|
if(currentPopup == POP_Log)
|
2008-04-25 09:40:08 +00:00
|
|
|
popbar = STBAR_POPUPLOG;
|
2008-03-24 17:48:55 +00:00
|
|
|
else if(currentPopup == POP_Keys)
|
2008-04-25 09:40:08 +00:00
|
|
|
popbar = STBAR_POPUPKEYS;
|
2008-03-24 17:48:55 +00:00
|
|
|
else if(currentPopup == POP_Status)
|
2008-04-25 09:40:08 +00:00
|
|
|
popbar = STBAR_POPUPSTATUS;
|
|
|
|
doCommands(SBarInfoScript->huds[popbar], SBarInfoScript->popups[currentPopup].getXOffset(), SBarInfoScript->popups[currentPopup].getYOffset(),
|
|
|
|
SBarInfoScript->popups[currentPopup].getAlpha(SBarInfoScript->huds[popbar].alpha));
|
2008-03-24 17:48:55 +00:00
|
|
|
}
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DSBarInfo::NewGame ()
|
|
|
|
{
|
|
|
|
if (CPlayer != NULL)
|
|
|
|
{
|
|
|
|
AttachToPlayer (CPlayer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSBarInfo::AttachToPlayer (player_t *player)
|
|
|
|
{
|
|
|
|
player_t *oldplayer = CPlayer;
|
2008-03-22 09:26:59 +00:00
|
|
|
currentState = NULL;
|
2008-03-19 09:53:23 +00:00
|
|
|
DBaseStatusBar::AttachToPlayer(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSBarInfo::Tick ()
|
|
|
|
{
|
|
|
|
DBaseStatusBar::Tick();
|
|
|
|
if(level.time & 1)
|
|
|
|
chainWiggle = pr_chainwiggle() & 1;
|
|
|
|
if(!SBarInfoScript->interpolateHealth)
|
|
|
|
{
|
|
|
|
oldHealth = CPlayer->health;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(oldHealth > CPlayer->health)
|
|
|
|
{
|
|
|
|
oldHealth -= clamp((oldHealth - CPlayer->health) >> 2, 1, SBarInfoScript->interpolationSpeed);
|
|
|
|
}
|
|
|
|
else if(oldHealth < CPlayer->health)
|
|
|
|
{
|
|
|
|
oldHealth += clamp((CPlayer->health - oldHealth) >> 2, 1, SBarInfoScript->interpolationSpeed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AInventory *armor = CPlayer->mo->FindInventory<ABasicArmor>();
|
|
|
|
if(armor == NULL)
|
|
|
|
{
|
|
|
|
oldArmor = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!SBarInfoScript->interpolateArmor)
|
|
|
|
{
|
|
|
|
oldArmor = armor->Amount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(oldArmor > armor->Amount)
|
|
|
|
{
|
|
|
|
oldArmor -= clamp((oldArmor - armor->Amount) >> 2, 1, SBarInfoScript->armorInterpolationSpeed);
|
|
|
|
}
|
|
|
|
else if(oldArmor < armor->Amount)
|
|
|
|
{
|
|
|
|
oldArmor += clamp((armor->Amount - oldArmor) >> 2, 1, SBarInfoScript->armorInterpolationSpeed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(artiflash)
|
|
|
|
{
|
|
|
|
artiflash--;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Do some stuff related to the mug shot that has to be done at 35fps
|
|
|
|
if(currentState != NULL)
|
|
|
|
{
|
|
|
|
currentState->tick();
|
|
|
|
if(currentState->finished)
|
|
|
|
currentState = NULL;
|
|
|
|
}
|
|
|
|
if((CPlayer->cmd.ucmd.buttons & (BT_ATTACK|BT_ALTATTACK)) && !(CPlayer->cheats & (CF_FROZEN | CF_TOTALLYFROZEN)))
|
|
|
|
{
|
|
|
|
if(rampageTimer != ST_RAMPAGETIME)
|
|
|
|
{
|
|
|
|
rampageTimer++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rampageTimer = 0;
|
|
|
|
}
|
|
|
|
mugshotHealth = CPlayer->health;
|
2008-04-09 07:32:33 +00:00
|
|
|
if(currentPopup != POP_None)
|
|
|
|
{
|
|
|
|
SBarInfoScript->popups[currentPopup].tick();
|
|
|
|
if(SBarInfoScript->popups[currentPopup].opened == false && SBarInfoScript->popups[currentPopup].isDoneMoving())
|
|
|
|
{
|
|
|
|
currentPopup = pendingPopup;
|
|
|
|
if(currentPopup != POP_None)
|
|
|
|
SBarInfoScript->popups[currentPopup].open();
|
|
|
|
}
|
|
|
|
}
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DSBarInfo::ReceivedWeapon (AWeapon *weapon)
|
|
|
|
{
|
|
|
|
weaponGrin = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSBarInfo::FlashItem(const PClass *itemtype)
|
|
|
|
{
|
|
|
|
artiflash = 4;
|
|
|
|
}
|
|
|
|
|
2008-03-24 17:48:55 +00:00
|
|
|
void DSBarInfo::ShowPop(int popnum)
|
|
|
|
{
|
|
|
|
DBaseStatusBar::ShowPop(popnum);
|
|
|
|
if(popnum != currentPopup)
|
2008-04-09 07:32:33 +00:00
|
|
|
{
|
|
|
|
pendingPopup = popnum;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pendingPopup = POP_None;
|
|
|
|
if(currentPopup != POP_None)
|
|
|
|
SBarInfoScript->popups[currentPopup].close();
|
2008-03-24 17:48:55 +00:00
|
|
|
else
|
2008-04-09 07:32:33 +00:00
|
|
|
{
|
|
|
|
currentPopup = pendingPopup;
|
|
|
|
pendingPopup = POP_None;
|
|
|
|
if(currentPopup != POP_None)
|
|
|
|
SBarInfoScript->popups[currentPopup].open();
|
|
|
|
}
|
2008-03-24 17:48:55 +00:00
|
|
|
}
|
|
|
|
|
2008-03-19 09:53:23 +00:00
|
|
|
//Public so it can be called by ACS
|
|
|
|
//Sets the mug shot state and resets it if it is not the state we are already on.
|
|
|
|
//waitTillDone is basically a priority variable when just to true the state won't change unless the previous state is finished.
|
|
|
|
void DSBarInfo::SetMugShotState(const char* stateName, bool waitTillDone)
|
|
|
|
{
|
|
|
|
MugShotState *state = (MugShotState *) FindMugShotState(stateName);
|
|
|
|
if(state != currentState)
|
|
|
|
{
|
|
|
|
if(!waitTillDone || currentState == NULL || currentState->finished)
|
|
|
|
{
|
|
|
|
currentState = state;
|
|
|
|
state->reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-25 09:40:08 +00:00
|
|
|
void DSBarInfo::doCommands(SBarInfoBlock &block, int xOffset, int yOffset, int alpha)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
//prepare ammo counts
|
|
|
|
AAmmo *ammo1, *ammo2;
|
|
|
|
int ammocount1, ammocount2;
|
|
|
|
GetCurrentAmmo(ammo1, ammo2, ammocount1, ammocount2);
|
|
|
|
ABasicArmor *armor = CPlayer->mo->FindInventory<ABasicArmor>();
|
|
|
|
int health = CPlayer->mo->health;
|
|
|
|
int armorAmount = armor != NULL ? armor->Amount : 0;
|
|
|
|
if(SBarInfoScript->interpolateHealth)
|
|
|
|
{
|
|
|
|
health = oldHealth;
|
|
|
|
}
|
|
|
|
if(SBarInfoScript->interpolateArmor)
|
|
|
|
{
|
|
|
|
armorAmount = oldArmor;
|
|
|
|
}
|
|
|
|
for(unsigned int i = 0;i < block.commands.Size();i++)
|
|
|
|
{
|
|
|
|
SBarInfoCommand& cmd = block.commands[i];
|
|
|
|
switch(cmd.type) //read and execute all the commands
|
|
|
|
{
|
|
|
|
case SBARINFO_DRAWSWITCHABLEIMAGE: //draw the alt image if we don't have the item else this is like a normal drawimage
|
|
|
|
{
|
|
|
|
int drawAlt = 0;
|
|
|
|
if((cmd.flags & DRAWIMAGE_WEAPONSLOT)) //weaponslots
|
|
|
|
{
|
|
|
|
drawAlt = 1; //draw off state until we know we have something.
|
|
|
|
for (int i = 0; i < MAX_WEAPONS_PER_SLOT; i++)
|
|
|
|
{
|
|
|
|
const PClass *weap = LocalWeapons.Slots[cmd.value].GetWeapon(i);
|
|
|
|
if(weap == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(CPlayer->mo->FindInventory(weap) != NULL)
|
|
|
|
{
|
|
|
|
drawAlt = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if((cmd.flags & DRAWIMAGE_INVULNERABILITY))
|
|
|
|
{
|
|
|
|
if(CPlayer->cheats&CF_GODMODE)
|
|
|
|
{
|
|
|
|
drawAlt = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else //check the inventory items and draw selected sprite
|
|
|
|
{
|
|
|
|
AInventory* item = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[0]));
|
|
|
|
if(item == NULL || item->Amount == 0)
|
|
|
|
drawAlt = 1;
|
|
|
|
if((cmd.flags & DRAWIMAGE_SWITCHABLE_AND))
|
|
|
|
{
|
|
|
|
item = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[1]));
|
|
|
|
if((item != NULL && item->Amount != 0) && drawAlt == 0) //both
|
|
|
|
{
|
|
|
|
drawAlt = 0;
|
|
|
|
}
|
|
|
|
else if((item != NULL && item->Amount != 0) && drawAlt == 1) //2nd
|
|
|
|
{
|
|
|
|
drawAlt = 3;
|
|
|
|
}
|
|
|
|
else if((item == NULL || item->Amount == 0) && drawAlt == 0) //1st
|
|
|
|
{
|
|
|
|
drawAlt = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(drawAlt != 0) //draw 'off' image
|
|
|
|
{
|
|
|
|
if(cmd.special != -1 && drawAlt == 1)
|
2008-04-25 09:50:43 +00:00
|
|
|
DrawGraphic(Images[cmd.special], cmd.x, cmd.y, xOffset, yOffset, alpha, !!(cmd.flags & DRAWIMAGE_TRANSLATABLE), false, !!(cmd.flags & DRAWIMAGE_OFFSET_CENTER));
|
2008-03-19 09:53:23 +00:00
|
|
|
else if(cmd.special2 != -1 && drawAlt == 2)
|
2008-04-25 09:50:43 +00:00
|
|
|
DrawGraphic(Images[cmd.special2], cmd.x, cmd.y, xOffset, yOffset, alpha, !!(cmd.flags & DRAWIMAGE_TRANSLATABLE), false, !!(cmd.flags & DRAWIMAGE_OFFSET_CENTER));
|
2008-03-19 09:53:23 +00:00
|
|
|
else if(cmd.special3 != -1 && drawAlt == 3)
|
2008-04-25 09:50:43 +00:00
|
|
|
DrawGraphic(Images[cmd.special3], cmd.x, cmd.y, xOffset, yOffset, alpha, !!(cmd.flags & DRAWIMAGE_TRANSLATABLE), false, !!(cmd.flags & DRAWIMAGE_OFFSET_CENTER));
|
2008-03-19 09:53:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case SBARINFO_DRAWIMAGE:
|
2008-04-25 09:40:08 +00:00
|
|
|
{
|
|
|
|
FTexture *texture = NULL;
|
2008-03-19 09:53:23 +00:00
|
|
|
if((cmd.flags & DRAWIMAGE_PLAYERICON))
|
2008-04-25 09:40:08 +00:00
|
|
|
texture = TexMan[CPlayer->mo->ScoreIcon];
|
2008-03-19 09:53:23 +00:00
|
|
|
else if((cmd.flags & DRAWIMAGE_AMMO1))
|
|
|
|
{
|
|
|
|
if(ammo1 != NULL)
|
2008-04-25 09:40:08 +00:00
|
|
|
texture = TexMan[ammo1->Icon];
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else if((cmd.flags & DRAWIMAGE_AMMO2))
|
|
|
|
{
|
|
|
|
if(ammo2 != NULL)
|
2008-04-25 09:40:08 +00:00
|
|
|
texture = TexMan[ammo2->Icon];
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else if((cmd.flags & DRAWIMAGE_ARMOR))
|
|
|
|
{
|
|
|
|
if(armor != NULL && armor->Amount != 0)
|
2008-04-25 09:40:08 +00:00
|
|
|
texture = TexMan(armor->Icon);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else if((cmd.flags & DRAWIMAGE_WEAPONICON))
|
|
|
|
{
|
|
|
|
AWeapon *weapon = CPlayer->ReadyWeapon;
|
|
|
|
if(weapon != NULL && weapon->Icon > 0)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
texture = TexMan[weapon->Icon];
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if((cmd.flags & DRAWIMAGE_INVENTORYICON))
|
2008-04-25 09:40:08 +00:00
|
|
|
texture = TexMan[cmd.sprite];
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.sprite != -1)
|
2008-04-25 09:40:08 +00:00
|
|
|
texture = Images[cmd.sprite];
|
|
|
|
|
2008-04-25 09:50:43 +00:00
|
|
|
DrawGraphic(texture, cmd.x, cmd.y, xOffset, yOffset, alpha, !!(cmd.flags & DRAWIMAGE_TRANSLATABLE), false, !!(cmd.flags & DRAWIMAGE_OFFSET_CENTER));
|
2008-03-19 09:53:23 +00:00
|
|
|
break;
|
2008-04-25 09:40:08 +00:00
|
|
|
}
|
2008-03-19 09:53:23 +00:00
|
|
|
case SBARINFO_DRAWNUMBER:
|
2008-03-24 17:48:55 +00:00
|
|
|
{
|
|
|
|
int value = cmd.value;
|
2008-03-19 09:53:23 +00:00
|
|
|
if(drawingFont != cmd.font)
|
|
|
|
{
|
|
|
|
drawingFont = cmd.font;
|
|
|
|
}
|
2008-04-05 07:06:26 +00:00
|
|
|
if(cmd.flags & DRAWNUMBER_HEALTH)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = health;
|
|
|
|
if(SBarInfoScript->lowerHealthCap && cmd.value < 0) //health shouldn't display negatives
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = 0;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_ARMOR)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = armorAmount;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_AMMO1)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = ammocount1;
|
2008-03-19 09:53:23 +00:00
|
|
|
if(ammo1 == NULL) //no ammo, do not draw
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_AMMO2)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = ammocount2;
|
2008-03-19 09:53:23 +00:00
|
|
|
if(ammo2 == NULL) //no ammo, do not draw
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_AMMO)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
const PClass* ammo = PClass::FindClass(cmd.string[0]);
|
|
|
|
AInventory* item = CPlayer->mo->FindInventory(ammo);
|
|
|
|
if(item != NULL)
|
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = item->Amount;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = 0;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_AMMOCAPACITY)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
const PClass* ammo = PClass::FindClass(cmd.string[0]);
|
|
|
|
AInventory* item = CPlayer->mo->FindInventory(ammo);
|
|
|
|
if(item != NULL)
|
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = item->MaxAmount;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = ((AInventory *)GetDefaultByType(ammo))->MaxAmount;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_FRAGS)
|
2008-03-24 17:48:55 +00:00
|
|
|
value = CPlayer->fragcount;
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_KILLS)
|
2008-03-24 17:48:55 +00:00
|
|
|
value = level.killed_monsters;
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_MONSTERS)
|
2008-03-24 17:48:55 +00:00
|
|
|
value = level.total_monsters;
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_ITEMS)
|
2008-03-24 17:48:55 +00:00
|
|
|
value = level.found_items;
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_TOTALITEMS)
|
2008-03-24 17:48:55 +00:00
|
|
|
value = level.total_items;
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_SECRETS)
|
2008-03-24 17:48:55 +00:00
|
|
|
value = level.found_secrets;
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_TOTALSECRETS)
|
2008-03-24 17:48:55 +00:00
|
|
|
value = level.total_secrets;
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_ARMORCLASS)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
AHexenArmor *harmor = CPlayer->mo->FindInventory<AHexenArmor>();
|
|
|
|
if(harmor != NULL)
|
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = harmor->Slots[0] + harmor->Slots[1] +
|
2008-03-19 09:53:23 +00:00
|
|
|
harmor->Slots[2] + harmor->Slots[3] + harmor->Slots[4];
|
|
|
|
}
|
|
|
|
//Hexen counts basic armor also so we should too.
|
|
|
|
if(armor != NULL)
|
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value += armor->SavePercent;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
2008-03-24 17:48:55 +00:00
|
|
|
value /= (5*FRACUNIT);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_GLOBALVAR)
|
2008-03-24 17:48:55 +00:00
|
|
|
value = ACS_GlobalVars[cmd.value];
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.flags & DRAWNUMBER_GLOBALARRAY)
|
|
|
|
value = ACS_GlobalArrays[cmd.value][consoleplayer];
|
|
|
|
else if(cmd.flags & DRAWNUMBER_INVENTORY)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
AInventory* item = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[0]));
|
|
|
|
if(item != NULL)
|
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = item->Amount;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 17:48:55 +00:00
|
|
|
value = 0;
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-05 07:06:26 +00:00
|
|
|
bool fillzeros = !!(cmd.flags & DRAWNUMBER_FILLZEROS);
|
2008-04-25 09:40:08 +00:00
|
|
|
EColorRange translation = cmd.translation;
|
2008-04-05 07:06:26 +00:00
|
|
|
if(cmd.special3 != -1 && value <= cmd.special3) //low
|
2008-04-25 09:40:08 +00:00
|
|
|
translation = cmd.translation2;
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(cmd.special4 != -1 && value >= cmd.special4) //high
|
2008-04-25 09:40:08 +00:00
|
|
|
translation = cmd.translation3;
|
|
|
|
DrawNumber(value, cmd.special, cmd.x, cmd.y, xOffset, yOffset, alpha, translation, cmd.special2, fillzeros);
|
2008-03-19 09:53:23 +00:00
|
|
|
break;
|
2008-03-24 17:48:55 +00:00
|
|
|
}
|
2008-03-19 09:53:23 +00:00
|
|
|
case SBARINFO_DRAWMUGSHOT:
|
|
|
|
{
|
|
|
|
bool xdth = false;
|
|
|
|
bool animatedgodmode = false;
|
|
|
|
if(cmd.flags & DRAWMUGSHOT_XDEATHFACE)
|
|
|
|
xdth = true;
|
|
|
|
if(cmd.flags & DRAWMUGSHOT_ANIMATEDGODMODE)
|
|
|
|
animatedgodmode = true;
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawFace(cmd.string[0], cmd.special, xdth, animatedgodmode, cmd.x, cmd.y, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBARINFO_DRAWSELECTEDINVENTORY:
|
|
|
|
if(CPlayer->mo->InvSel != NULL && !(level.flags & LEVEL_NOINVENTORYBAR))
|
|
|
|
{
|
|
|
|
if((cmd.flags & DRAWSELECTEDINVENTORY_ARTIFLASH) && artiflash)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(Images[ARTIFLASH_OFFSET+(4-artiflash)], cmd.x, cmd.y, xOffset, yOffset, alpha, false, CPlayer->mo->InvSel->Amount <= 0);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(TexMan(CPlayer->mo->InvSel->Icon), cmd.x, cmd.y, xOffset, yOffset, alpha, false, CPlayer->mo->InvSel->Amount <= 0);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
if((cmd.flags & DRAWSELECTEDINVENTORY_ALWAYSSHOWCOUNTER) || CPlayer->mo->InvSel->Amount != 1)
|
|
|
|
{
|
|
|
|
if(drawingFont != cmd.font)
|
|
|
|
{
|
|
|
|
drawingFont = cmd.font;
|
|
|
|
}
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawNumber(CPlayer->mo->InvSel->Amount, 3, cmd.special2, cmd.special3, xOffset, yOffset, alpha, cmd.translation, cmd.special4);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if((cmd.flags & DRAWSELECTEDINVENTORY_ALTERNATEONEMPTY))
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SBARINFO_DRAWINVENTORYBAR:
|
|
|
|
{
|
|
|
|
bool alwaysshow = false;
|
|
|
|
bool artibox = true;
|
|
|
|
bool noarrows = false;
|
|
|
|
bool alwaysshowcounter = false;
|
|
|
|
if((cmd.flags & DRAWINVENTORYBAR_ALWAYSSHOW))
|
|
|
|
alwaysshow = true;
|
|
|
|
if((cmd.flags & DRAWINVENTORYBAR_NOARTIBOX))
|
|
|
|
artibox = false;
|
|
|
|
if((cmd.flags & DRAWINVENTORYBAR_NOARROWS))
|
|
|
|
noarrows = true;
|
|
|
|
if((cmd.flags & DRAWINVENTORYBAR_ALWAYSSHOWCOUNTER))
|
|
|
|
alwaysshowcounter = true;
|
|
|
|
if(drawingFont != cmd.font)
|
|
|
|
{
|
|
|
|
drawingFont = cmd.font;
|
|
|
|
}
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawInventoryBar(cmd.special, cmd.value, cmd.x, cmd.y, xOffset, yOffset, alpha, alwaysshow, cmd.special2, cmd.special3, cmd.translation, artibox, noarrows, alwaysshowcounter);
|
2008-03-19 09:53:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBARINFO_DRAWBAR:
|
|
|
|
{
|
|
|
|
if(cmd.sprite == -1 || Images[cmd.sprite] == NULL)
|
|
|
|
break; //don't draw anything.
|
|
|
|
bool horizontal = !!((cmd.special2 & DRAWBAR_HORIZONTAL));
|
|
|
|
bool reverse = !!((cmd.special2 & DRAWBAR_REVERSE));
|
|
|
|
fixed_t value = 0;
|
|
|
|
int max = 0;
|
|
|
|
if(cmd.flags == DRAWNUMBER_HEALTH)
|
|
|
|
{
|
|
|
|
value = health;
|
|
|
|
if(value < 0) //health shouldn't display negatives
|
|
|
|
{
|
|
|
|
value = 0;
|
|
|
|
}
|
|
|
|
if(!(cmd.special2 & DRAWBAR_COMPAREDEFAULTS))
|
|
|
|
{
|
|
|
|
AInventory* item = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[0])); //max comparer
|
|
|
|
if(item != NULL)
|
|
|
|
{
|
|
|
|
max = item->Amount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
max = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else //default to the class's health
|
|
|
|
{
|
|
|
|
max = CPlayer->mo->GetDefault()->health;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(cmd.flags == DRAWNUMBER_ARMOR)
|
|
|
|
{
|
|
|
|
value = armorAmount;
|
|
|
|
if(!((cmd.special2 & DRAWBAR_COMPAREDEFAULTS) == DRAWBAR_COMPAREDEFAULTS))
|
|
|
|
{
|
|
|
|
AInventory* item = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[0])); //max comparer
|
|
|
|
if(item != NULL)
|
|
|
|
{
|
|
|
|
max = item->Amount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
max = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else //default to 100
|
|
|
|
{
|
|
|
|
max = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(cmd.flags == DRAWNUMBER_AMMO1)
|
|
|
|
{
|
|
|
|
value = ammocount1;
|
|
|
|
if(ammo1 == NULL) //no ammo, draw as empty
|
|
|
|
{
|
|
|
|
value = 0;
|
|
|
|
max = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
max = ammo1->MaxAmount;
|
|
|
|
}
|
|
|
|
else if(cmd.flags == DRAWNUMBER_AMMO2)
|
|
|
|
{
|
|
|
|
value = ammocount2;
|
|
|
|
if(ammo2 == NULL) //no ammo, draw as empty
|
|
|
|
{
|
|
|
|
value = 0;
|
|
|
|
max = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
max = ammo2->MaxAmount;
|
|
|
|
}
|
|
|
|
else if(cmd.flags == DRAWNUMBER_AMMO)
|
|
|
|
{
|
|
|
|
const PClass* ammo = PClass::FindClass(cmd.string[0]);
|
|
|
|
AInventory* item = CPlayer->mo->FindInventory(ammo);
|
|
|
|
if(item != NULL)
|
|
|
|
{
|
|
|
|
value = item->Amount;
|
|
|
|
max = item->MaxAmount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(cmd.flags == DRAWNUMBER_FRAGS)
|
|
|
|
{
|
|
|
|
value = CPlayer->fragcount;
|
|
|
|
max = fraglimit;
|
|
|
|
}
|
|
|
|
else if(cmd.flags == DRAWNUMBER_KILLS)
|
|
|
|
{
|
|
|
|
value = level.killed_monsters;
|
|
|
|
max = level.total_monsters;
|
|
|
|
}
|
|
|
|
else if(cmd.flags == DRAWNUMBER_ITEMS)
|
|
|
|
{
|
|
|
|
value = level.found_items;
|
|
|
|
max = level.total_items;
|
|
|
|
}
|
|
|
|
else if(cmd.flags == DRAWNUMBER_SECRETS)
|
|
|
|
{
|
|
|
|
value = level.found_secrets;
|
|
|
|
max = level.total_secrets;
|
|
|
|
}
|
|
|
|
else if(cmd.flags == DRAWNUMBER_INVENTORY)
|
|
|
|
{
|
|
|
|
AInventory* item = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[0]));
|
|
|
|
if(item != NULL)
|
|
|
|
{
|
|
|
|
value = item->Amount;
|
|
|
|
max = item->MaxAmount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(cmd.special3 != 0)
|
|
|
|
value = max - value; //invert since the new drawing method requires drawing the bg on the fg.
|
|
|
|
if(max != 0 && value > 0)
|
|
|
|
{
|
|
|
|
value = (value << FRACBITS) / max;
|
|
|
|
if(value > FRACUNIT)
|
|
|
|
value = FRACUNIT;
|
|
|
|
}
|
|
|
|
else if(cmd.special3 != 0 && max == 0 && value <= 0)
|
|
|
|
{
|
|
|
|
value = FRACUNIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = 0;
|
|
|
|
}
|
|
|
|
assert(Images[cmd.sprite] != NULL);
|
|
|
|
|
|
|
|
FTexture *fg = Images[cmd.sprite];
|
|
|
|
FTexture *bg = (cmd.special != -1) ? Images[cmd.special] : NULL;
|
|
|
|
int x, y, w, h;
|
|
|
|
int cx, cy, cw, ch, cr, cb;
|
|
|
|
|
|
|
|
// Calc real screen coordinates for bar
|
2008-04-25 09:40:08 +00:00
|
|
|
x = cmd.x + ST_X + xOffset;
|
|
|
|
y = cmd.y + ST_Y + yOffset;
|
2008-03-19 09:53:23 +00:00
|
|
|
w = fg->GetScaledWidth();
|
|
|
|
h = fg->GetScaledHeight();
|
|
|
|
if (Scaled)
|
|
|
|
{
|
|
|
|
screen->VirtualToRealCoordsInt(x, y, w, h, 320, 200, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cmd.special3 != 0)
|
|
|
|
{
|
|
|
|
//Draw the whole foreground
|
|
|
|
screen->DrawTexture(fg, x, y,
|
|
|
|
DTA_DestWidth, w,
|
|
|
|
DTA_DestHeight, h,
|
2008-04-25 09:40:08 +00:00
|
|
|
DTA_Alpha, alpha,
|
2008-03-19 09:53:23 +00:00
|
|
|
TAG_DONE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Draw background
|
|
|
|
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
|
|
|
|
{
|
|
|
|
screen->DrawTexture(bg, x, y,
|
|
|
|
DTA_DestWidth, w,
|
|
|
|
DTA_DestHeight, h,
|
2008-04-25 09:40:08 +00:00
|
|
|
DTA_Alpha, alpha,
|
2008-03-19 09:53:23 +00:00
|
|
|
TAG_DONE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
screen->Clear(x, y, x + w, y + h, GPalette.BlackIndex, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calc clipping rect for background
|
2008-04-25 09:40:08 +00:00
|
|
|
cx = cmd.x + ST_X + cmd.special3 + xOffset;
|
|
|
|
cy = cmd.y + ST_Y + cmd.special3 + yOffset;
|
2008-03-22 09:26:59 +00:00
|
|
|
cw = fg->GetScaledWidth() - fg->GetScaledLeftOffset() - cmd.special3 * 2;
|
|
|
|
ch = fg->GetScaledHeight() - fg->GetScaledTopOffset() - cmd.special3 * 2;
|
2008-03-19 09:53:23 +00:00
|
|
|
if (Scaled)
|
|
|
|
{
|
|
|
|
screen->VirtualToRealCoordsInt(cx, cy, cw, ch, 320, 200, true);
|
|
|
|
}
|
2008-03-22 09:26:59 +00:00
|
|
|
|
2008-03-19 09:53:23 +00:00
|
|
|
if (horizontal)
|
|
|
|
{
|
|
|
|
if ((cmd.special3 != 0 && reverse) || (cmd.special3 == 0 && !reverse))
|
|
|
|
{ // left to right
|
|
|
|
cr = cx + FixedMul(cw, value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // right to left
|
|
|
|
cr = cx + cw;
|
|
|
|
cx += FixedMul(cw, FRACUNIT - value);
|
|
|
|
}
|
|
|
|
cb = cy + ch;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((cmd.special3 != 0 && reverse) || (cmd.special3 == 0 && !reverse))
|
|
|
|
{ // bottom to top
|
|
|
|
cb = cy + ch;
|
|
|
|
cy += FixedMul(ch, FRACUNIT - value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // top to bottom
|
|
|
|
cb = cy + FixedMul(ch, value);
|
|
|
|
}
|
|
|
|
cr = cx + cw;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw background
|
|
|
|
if(cmd.special3 != 0)
|
|
|
|
{
|
|
|
|
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
|
|
|
|
{
|
|
|
|
screen->DrawTexture(bg, x, y,
|
|
|
|
DTA_DestWidth, w,
|
|
|
|
DTA_DestHeight, h,
|
|
|
|
DTA_ClipLeft, cx,
|
|
|
|
DTA_ClipTop, cy,
|
|
|
|
DTA_ClipRight, cr,
|
|
|
|
DTA_ClipBottom, cb,
|
2008-04-25 09:40:08 +00:00
|
|
|
DTA_Alpha, alpha,
|
2008-03-19 09:53:23 +00:00
|
|
|
TAG_DONE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
screen->Clear(cx, cy, cr, cb, GPalette.BlackIndex, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
screen->DrawTexture(fg, x, y,
|
|
|
|
DTA_DestWidth, w,
|
|
|
|
DTA_DestHeight, h,
|
|
|
|
DTA_ClipLeft, cx,
|
|
|
|
DTA_ClipTop, cy,
|
|
|
|
DTA_ClipRight, cr,
|
|
|
|
DTA_ClipBottom, cb,
|
2008-04-25 09:40:08 +00:00
|
|
|
DTA_Alpha, alpha,
|
2008-03-19 09:53:23 +00:00
|
|
|
TAG_DONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBARINFO_DRAWGEM:
|
|
|
|
{
|
|
|
|
int value = (cmd.flags & DRAWGEM_ARMOR) ? armorAmount : health;
|
|
|
|
int max = 100;
|
|
|
|
bool wiggle = false;
|
|
|
|
bool translate = !!(cmd.flags & DRAWGEM_TRANSLATABLE);
|
|
|
|
if(max != 0 || value < 0)
|
|
|
|
{
|
|
|
|
value = (value*100)/max;
|
|
|
|
if(value > 100)
|
|
|
|
value = 100;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = 0;
|
|
|
|
}
|
|
|
|
value = (cmd.flags & DRAWGEM_REVERSE) ? 100 - value : value;
|
|
|
|
if(health != CPlayer->health)
|
|
|
|
{
|
|
|
|
wiggle = !!(cmd.flags & DRAWGEM_WIGGLE);
|
|
|
|
}
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGem(Images[cmd.special], Images[cmd.sprite], value, cmd.x, cmd.y, xOffset, yOffset, alpha, cmd.special2, cmd.special3, cmd.special4+1, wiggle, translate);
|
2008-03-19 09:53:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBARINFO_DRAWSHADER:
|
|
|
|
{
|
|
|
|
FBarShader *const shaders[4] =
|
|
|
|
{
|
|
|
|
&shader_horz_normal, &shader_horz_reverse,
|
|
|
|
&shader_vert_normal, &shader_vert_reverse
|
|
|
|
};
|
|
|
|
bool vertical = !!(cmd.flags & DRAWSHADER_VERTICAL);
|
|
|
|
bool reverse = !!(cmd.flags & DRAWSHADER_REVERSE);
|
2008-04-25 09:40:08 +00:00
|
|
|
screen->DrawTexture (shaders[(vertical << 1) + reverse], ST_X+cmd.x+xOffset, ST_Y+cmd.y+yOffset,
|
2008-03-19 09:53:23 +00:00
|
|
|
DTA_DestWidth, cmd.special,
|
|
|
|
DTA_DestHeight, cmd.special2,
|
|
|
|
DTA_Bottom320x200, Scaled,
|
2008-04-25 09:40:08 +00:00
|
|
|
DTA_Alpha, alpha,
|
2008-03-19 09:53:23 +00:00
|
|
|
DTA_AlphaChannel, true,
|
|
|
|
DTA_FillColor, 0,
|
|
|
|
TAG_DONE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBARINFO_DRAWSTRING:
|
|
|
|
if(drawingFont != cmd.font)
|
|
|
|
{
|
|
|
|
drawingFont = cmd.font;
|
|
|
|
}
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawString(cmd.string[0], cmd.x - drawingFont->StringWidth(cmd.string[0]), cmd.y, xOffset, yOffset, alpha, cmd.translation, cmd.special);
|
2008-03-19 09:53:23 +00:00
|
|
|
break;
|
|
|
|
case SBARINFO_DRAWKEYBAR:
|
|
|
|
{
|
|
|
|
bool vertical = !!(cmd.flags & DRAWKEYBAR_VERTICAL);
|
|
|
|
AInventory *item = CPlayer->mo->Inventory;
|
|
|
|
if(item == NULL)
|
|
|
|
break;
|
|
|
|
for(int i = 0;i < cmd.value;i++)
|
|
|
|
{
|
|
|
|
while(item->Icon <= 0 || item->GetClass() == RUNTIME_CLASS(AKey) || !item->IsKindOf(RUNTIME_CLASS(AKey)))
|
|
|
|
{
|
|
|
|
item = item->Inventory;
|
|
|
|
if(item == NULL)
|
|
|
|
goto FinishDrawKeyBar;
|
|
|
|
}
|
|
|
|
if(!vertical)
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(TexMan[item->Icon], cmd.x+(cmd.special*i), cmd.y, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
else
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(TexMan[item->Icon], cmd.x, cmd.y+(cmd.special*i), xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
item = item->Inventory;
|
|
|
|
if(item == NULL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
FinishDrawKeyBar:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBARINFO_GAMEMODE:
|
|
|
|
if(((cmd.flags & GAMETYPE_SINGLEPLAYER) && !multiplayer) ||
|
|
|
|
((cmd.flags & GAMETYPE_DEATHMATCH) && deathmatch) ||
|
|
|
|
((cmd.flags & GAMETYPE_COOPERATIVE) && multiplayer && !deathmatch) ||
|
|
|
|
((cmd.flags & GAMETYPE_TEAMGAME) && teamplay))
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SBARINFO_PLAYERCLASS:
|
|
|
|
{
|
2008-03-22 09:26:59 +00:00
|
|
|
if(CPlayer->cls == NULL) break; //No class so we can not continue
|
2008-03-19 09:53:23 +00:00
|
|
|
int spawnClass = CPlayer->cls->ClassIndex;
|
|
|
|
if(cmd.special == spawnClass || cmd.special2 == spawnClass || cmd.special3 == spawnClass)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-03-24 17:48:55 +00:00
|
|
|
case SBARINFO_ASPECTRATIO:
|
|
|
|
if(CheckRatio(screen->GetWidth(), screen->GetHeight()) == cmd.value)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-24 17:48:55 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-04-05 07:06:26 +00:00
|
|
|
case SBARINFO_ISSELECTED:
|
|
|
|
if(CPlayer->ReadyWeapon != NULL)
|
|
|
|
{
|
|
|
|
const PClass *weapon1 = PClass::FindClass(cmd.string[0]);
|
|
|
|
const PClass *weapon2 = PClass::FindClass(cmd.string[1]);
|
|
|
|
if(weapon2 != NULL)
|
|
|
|
{
|
|
|
|
if((cmd.flags & SBARINFOEVENT_NOT) && (weapon1 != CPlayer->ReadyWeapon->GetSpecies() && weapon2 != CPlayer->ReadyWeapon->GetSpecies()))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-04-05 07:06:26 +00:00
|
|
|
else if(!(cmd.flags & SBARINFOEVENT_NOT) && (weapon1 == CPlayer->ReadyWeapon->GetSpecies() || weapon2 == CPlayer->ReadyWeapon->GetSpecies()))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-04-05 07:06:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!(cmd.flags & SBARINFOEVENT_NOT) && weapon1 == CPlayer->ReadyWeapon->GetSpecies())
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-04-05 07:06:26 +00:00
|
|
|
else if((cmd.flags & SBARINFOEVENT_NOT) && weapon1 != CPlayer->ReadyWeapon->GetSpecies())
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-04-05 07:06:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2008-03-19 09:53:23 +00:00
|
|
|
case SBARINFO_WEAPONAMMO:
|
|
|
|
if(CPlayer->ReadyWeapon != NULL)
|
|
|
|
{
|
|
|
|
const PClass *AmmoType1 = CPlayer->ReadyWeapon->AmmoType1;
|
|
|
|
const PClass *AmmoType2 = CPlayer->ReadyWeapon->AmmoType2;
|
|
|
|
const PClass *IfAmmo1 = PClass::FindClass(cmd.string[0]);
|
|
|
|
const PClass *IfAmmo2 = (cmd.flags & SBARINFOEVENT_OR) || (cmd.flags & SBARINFOEVENT_AND) ?
|
|
|
|
PClass::FindClass(cmd.string[1]) : NULL;
|
|
|
|
bool usesammo1 = (AmmoType1 != NULL);
|
|
|
|
bool usesammo2 = (AmmoType2 != NULL);
|
|
|
|
if(!(cmd.flags & SBARINFOEVENT_NOT) && !usesammo1 && !usesammo2) //if the weapon doesn't use ammo don't go though the trouble.
|
|
|
|
{
|
2008-04-09 07:32:33 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset);
|
2008-03-19 09:53:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
//Or means only 1 ammo type needs to match and means both need to match.
|
|
|
|
if((cmd.flags & SBARINFOEVENT_OR) || (cmd.flags & SBARINFOEVENT_AND))
|
|
|
|
{
|
|
|
|
bool match1 = ((usesammo1 && (AmmoType1 == IfAmmo1 || AmmoType1 == IfAmmo2)) || !usesammo1);
|
|
|
|
bool match2 = ((usesammo2 && (AmmoType2 == IfAmmo1 || AmmoType2 == IfAmmo2)) || !usesammo2);
|
|
|
|
if(((cmd.flags & SBARINFOEVENT_OR) && (match1 || match2)) || ((cmd.flags & SBARINFOEVENT_AND) && (match1 && match2)))
|
|
|
|
{
|
|
|
|
if(!(cmd.flags & SBARINFOEVENT_NOT))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else if(cmd.flags & SBARINFOEVENT_NOT)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else //Every thing here could probably be one long if statement but then it would be more confusing.
|
|
|
|
{
|
|
|
|
if((usesammo1 && (AmmoType1 == IfAmmo1)) || (usesammo2 && (AmmoType2 == IfAmmo1)))
|
|
|
|
{
|
|
|
|
if(!(cmd.flags & SBARINFOEVENT_NOT))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else if(cmd.flags & SBARINFOEVENT_NOT)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2008-03-24 17:48:55 +00:00
|
|
|
case SBARINFO_ININVENTORY:
|
|
|
|
{
|
|
|
|
AInventory *item1 = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[0]));
|
|
|
|
AInventory *item2 = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[1]));
|
|
|
|
if(cmd.flags & SBARINFOEVENT_AND)
|
|
|
|
{
|
|
|
|
if((item1 != NULL && item2 != NULL) && !(cmd.flags & SBARINFOEVENT_NOT))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-24 17:48:55 +00:00
|
|
|
else if((item1 == NULL || item2 == NULL) && (cmd.flags & SBARINFOEVENT_NOT))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-24 17:48:55 +00:00
|
|
|
}
|
|
|
|
else if(cmd.flags & SBARINFOEVENT_OR)
|
|
|
|
{
|
|
|
|
if((item1 != NULL || item2 != NULL) && !(cmd.flags & SBARINFOEVENT_NOT))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-24 17:48:55 +00:00
|
|
|
else if((item1 == NULL && item2 == NULL) && (cmd.flags & SBARINFOEVENT_NOT))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-24 17:48:55 +00:00
|
|
|
}
|
|
|
|
else if((item1 != NULL) && !(cmd.flags & SBARINFOEVENT_NOT))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-24 17:48:55 +00:00
|
|
|
else if((item1 == NULL) && (cmd.flags & SBARINFOEVENT_NOT))
|
2008-04-25 09:40:08 +00:00
|
|
|
doCommands(cmd.subBlock, xOffset, yOffset, alpha);
|
2008-03-24 17:48:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//draws an image with the specified flags
|
2008-04-25 09:40:08 +00:00
|
|
|
void DSBarInfo::DrawGraphic(FTexture* texture, int x, int y, int xOffset, int yOffset, int alpha,
|
|
|
|
bool translate, bool dim, bool center) //flags
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
2008-04-05 12:14:33 +00:00
|
|
|
if (texture == NULL)
|
|
|
|
return;
|
2008-04-25 09:40:08 +00:00
|
|
|
|
|
|
|
if(center)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
x -= (texture->GetWidth()/2)-texture->LeftOffset;
|
|
|
|
y -= (texture->GetHeight()/2)-texture->TopOffset;
|
|
|
|
}
|
2008-04-25 09:40:08 +00:00
|
|
|
|
|
|
|
x += ST_X + xOffset;
|
|
|
|
y += ST_Y + yOffset;
|
2008-03-24 17:48:55 +00:00
|
|
|
int w = texture->GetScaledWidth();
|
2008-04-05 07:06:26 +00:00
|
|
|
int h = texture->GetScaledHeight() + y;
|
2008-04-09 07:32:33 +00:00
|
|
|
if(Scaled)
|
|
|
|
screen->VirtualToRealCoordsInt(x, y, w, h, 320, 200, true);
|
2008-04-05 07:06:26 +00:00
|
|
|
h -= y;
|
2008-04-25 09:40:08 +00:00
|
|
|
screen->DrawTexture(texture, x, y,
|
|
|
|
DTA_DestWidth, w,
|
|
|
|
DTA_DestHeight, h,
|
|
|
|
DTA_Translation, translate ? getTranslation() : 0,
|
|
|
|
DTA_ColorOverlay, dim ? DIM_OVERLAY : 0,
|
|
|
|
DTA_Alpha, alpha,
|
|
|
|
TAG_DONE);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 09:40:08 +00:00
|
|
|
void DSBarInfo::DrawString(const char* str, int x, int y, int xOffset, int yOffset, int alpha, EColorRange translation, int spacing)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
x += spacing;
|
|
|
|
while(*str != '\0')
|
|
|
|
{
|
|
|
|
if(*str == ' ')
|
|
|
|
{
|
|
|
|
x += drawingFont->GetSpaceWidth();
|
|
|
|
str++;
|
|
|
|
continue;
|
|
|
|
}
|
2008-03-22 09:26:59 +00:00
|
|
|
int width;
|
|
|
|
if(SBarInfoScript->spacingCharacter == '\0') //No monospace?
|
|
|
|
width = drawingFont->GetCharWidth((int) *str);
|
|
|
|
else
|
|
|
|
width = drawingFont->GetCharWidth((int) SBarInfoScript->spacingCharacter);
|
2008-03-19 09:53:23 +00:00
|
|
|
FTexture* character = drawingFont->GetChar((int) *str, &width);
|
|
|
|
if(character == NULL) //missing character.
|
|
|
|
{
|
|
|
|
str++;
|
|
|
|
continue;
|
|
|
|
}
|
2008-03-22 09:26:59 +00:00
|
|
|
if(SBarInfoScript->spacingCharacter == '\0') //If we are monospaced lets use the offset
|
|
|
|
x += (character->LeftOffset+1); //ignore x offsets since we adapt to character size
|
2008-04-25 09:40:08 +00:00
|
|
|
int rx = x + ST_X + xOffset;
|
|
|
|
int ry = y + ST_Y + yOffset;
|
2008-03-24 17:48:55 +00:00
|
|
|
int rw = character->GetScaledWidth();
|
|
|
|
int rh = character->GetScaledHeight();
|
2008-04-09 07:32:33 +00:00
|
|
|
if(Scaled)
|
|
|
|
screen->VirtualToRealCoordsInt(rx, ry, rw, rh, 320, 200, true);
|
2008-03-24 17:48:55 +00:00
|
|
|
screen->DrawTexture(character, rx, ry,
|
|
|
|
DTA_DestWidth, rw,
|
|
|
|
DTA_DestHeight, rh,
|
|
|
|
DTA_Translation, drawingFont->GetColorTranslation(translation),
|
2008-04-25 09:40:08 +00:00
|
|
|
DTA_Alpha, alpha,
|
2008-03-24 17:48:55 +00:00
|
|
|
TAG_DONE);
|
2008-03-22 09:26:59 +00:00
|
|
|
if(SBarInfoScript->spacingCharacter == '\0')
|
2008-03-24 17:48:55 +00:00
|
|
|
x += width + spacing - (character->LeftOffset+1);
|
|
|
|
else //width gets changed at the call to GetChar()
|
|
|
|
x += drawingFont->GetCharWidth((int) SBarInfoScript->spacingCharacter) + spacing;
|
2008-03-19 09:53:23 +00:00
|
|
|
str++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//draws the specified number up to len digits
|
2008-04-25 09:40:08 +00:00
|
|
|
void DSBarInfo::DrawNumber(int num, int len, int x, int y, int xOffset, int yOffset, int alpha, EColorRange translation, int spacing, bool fillzeros)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
FString value;
|
|
|
|
int maxval = (int) ceil(pow(10., len))-1;
|
2008-04-05 07:06:26 +00:00
|
|
|
if(!fillzeros || len == 1)
|
|
|
|
num = clamp(num, -maxval, maxval);
|
|
|
|
else //The community wanted negatives to take the last digit, but we can only do this if there is room
|
|
|
|
num = clamp(num, (int) -(ceil(pow(10., len-1))-1), maxval);
|
2008-03-19 09:53:23 +00:00
|
|
|
value.Format("%d", num);
|
2008-04-05 07:06:26 +00:00
|
|
|
if(fillzeros)
|
|
|
|
{
|
|
|
|
if(num < 0) //We don't want the negative just yet
|
|
|
|
value.Format("%d", -num);
|
|
|
|
while(fillzeros && value.Len() < (unsigned int) len)
|
|
|
|
{
|
|
|
|
if(num < 0 && value.Len() == (unsigned int) (len-1))
|
|
|
|
value.Insert(0, "-");
|
|
|
|
else
|
|
|
|
value.Insert(0, "0");
|
|
|
|
}
|
|
|
|
}
|
2008-03-22 09:26:59 +00:00
|
|
|
if(SBarInfoScript->spacingCharacter == '\0')
|
|
|
|
x -= int(drawingFont->StringWidth(value)+(spacing * value.Len()));
|
|
|
|
else //monospaced so just multiplay the character size
|
|
|
|
x -= int((drawingFont->GetCharWidth((int) SBarInfoScript->spacingCharacter) + spacing) * value.Len());
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawString(value, x, y, xOffset, yOffset, alpha, translation, spacing);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//draws the mug shot
|
2008-04-25 09:40:08 +00:00
|
|
|
void DSBarInfo::DrawFace(FString &defaultFace, int accuracy, bool xdth, bool animatedgodmode, int x, int y, int xOffset, int yOffset, int alpha)
|
2008-03-19 09:53:23 +00:00
|
|
|
{
|
|
|
|
int angle = updateState(xdth, animatedgodmode);
|
|
|
|
int level = 0;
|
|
|
|
for(level = 0;CPlayer->health < (accuracy-level-1)*(CPlayer->mo->GetMaxHealth()/accuracy);level++);
|
|
|
|
if(currentState != NULL)
|
|
|
|
{
|
2008-04-05 12:14:33 +00:00
|
|
|
FPlayerSkin *skin = &skins[CPlayer->morphTics ? CPlayer->MorphedPlayerClass : CPlayer->userinfo.skin];
|
|
|
|
FTexture *face = currentState->getCurrentFrameTexture(defaultFace, skin, level, angle);
|
|
|
|
if (face != NULL)
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(face, x, y, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int DSBarInfo::updateState(bool xdth, bool animatedgodmode)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
angle_t badguyangle;
|
|
|
|
angle_t diffang;
|
|
|
|
|
|
|
|
if(CPlayer->health > 0)
|
|
|
|
{
|
|
|
|
if(weaponGrin)
|
|
|
|
{
|
|
|
|
weaponGrin = false;
|
|
|
|
if(CPlayer->bonuscount)
|
|
|
|
{
|
|
|
|
SetMugShotState("grin", false);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CPlayer->damagecount)
|
|
|
|
{
|
|
|
|
int damageAngle = 1;
|
|
|
|
if(CPlayer->attacker && CPlayer->attacker != CPlayer->mo)
|
|
|
|
{
|
|
|
|
if(CPlayer->mo != NULL)
|
|
|
|
{
|
|
|
|
//The next 12 lines is from the Doom statusbar code.
|
|
|
|
badguyangle = R_PointToAngle2(CPlayer->mo->x, CPlayer->mo->y, CPlayer->attacker->x, CPlayer->attacker->y);
|
|
|
|
if(badguyangle > CPlayer->mo->angle)
|
|
|
|
{
|
|
|
|
// whether right or left
|
|
|
|
diffang = badguyangle - CPlayer->mo->angle;
|
|
|
|
i = diffang > ANG180;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// whether left or right
|
|
|
|
diffang = CPlayer->mo->angle - badguyangle;
|
|
|
|
i = diffang <= ANG180;
|
|
|
|
} // confusing, aint it?
|
|
|
|
if(i && diffang >= ANG45)
|
|
|
|
{
|
|
|
|
damageAngle = 0;
|
|
|
|
}
|
|
|
|
else if(!i && diffang >= ANG45)
|
|
|
|
{
|
|
|
|
damageAngle = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const char* stateName = new char[5];
|
|
|
|
if (mugshotHealth != -1 && CPlayer->health - mugshotHealth > 20)
|
|
|
|
stateName = "ouch";
|
|
|
|
else
|
|
|
|
stateName = "pain";
|
|
|
|
char* fullStateName = new char[sizeof(stateName)+sizeof((const char*) CPlayer->LastDamageType) + 1];
|
|
|
|
sprintf(fullStateName, "%s.%s", stateName, (const char*) CPlayer->LastDamageType);
|
|
|
|
if(FindMugShotState(fullStateName) != NULL)
|
|
|
|
SetMugShotState(fullStateName);
|
|
|
|
else
|
|
|
|
SetMugShotState(stateName);
|
|
|
|
damageFaceActive = !(currentState == NULL);
|
|
|
|
lastDamageAngle = damageAngle;
|
|
|
|
return damageAngle;
|
|
|
|
}
|
|
|
|
if(damageFaceActive)
|
|
|
|
{
|
|
|
|
if(currentState == NULL)
|
|
|
|
damageFaceActive = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char* stateName = new char[5];
|
|
|
|
if (mugshotHealth != -1 && CPlayer->health - mugshotHealth > 20)
|
|
|
|
stateName = "ouch";
|
|
|
|
else
|
|
|
|
stateName = "pain";
|
|
|
|
char* fullStateName = new char[sizeof(stateName)+sizeof((const char*) CPlayer->LastDamageType) + 1];
|
|
|
|
sprintf(fullStateName, "%s.%s", stateName, (const char*) CPlayer->LastDamageType);
|
|
|
|
if(FindMugShotState(fullStateName) != NULL)
|
|
|
|
SetMugShotState(fullStateName);
|
|
|
|
else
|
|
|
|
SetMugShotState(stateName);
|
|
|
|
return lastDamageAngle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(rampageTimer == ST_RAMPAGETIME)
|
|
|
|
{
|
|
|
|
SetMugShotState("rampage", true);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((CPlayer->cheats & CF_GODMODE) || (CPlayer->mo != NULL && CPlayer->mo->flags2 & MF2_INVULNERABLE))
|
|
|
|
{
|
|
|
|
if(animatedgodmode)
|
|
|
|
SetMugShotState("godanimated", true);
|
|
|
|
else
|
|
|
|
SetMugShotState("god", true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetMugShotState("normal", true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char* stateName = new char[7];
|
|
|
|
if(!xdth || !(CPlayer->cheats & CF_EXTREMELYDEAD))
|
|
|
|
stateName = "death";
|
|
|
|
else
|
|
|
|
stateName = "xdeath";
|
|
|
|
//new string the size of stateName and the damage type put together
|
|
|
|
char* fullStateName = new char[sizeof(stateName)+sizeof((const char*) CPlayer->LastDamageType) + 1];
|
|
|
|
sprintf(fullStateName, "%s.%s", stateName, (const char*) CPlayer->LastDamageType);
|
|
|
|
if(FindMugShotState(fullStateName) != NULL)
|
|
|
|
SetMugShotState(fullStateName);
|
|
|
|
else
|
|
|
|
SetMugShotState(stateName);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-25 09:40:08 +00:00
|
|
|
void DSBarInfo::DrawInventoryBar(int type, int num, int x, int y, int xOffset, int yOffset, int alpha, bool alwaysshow,
|
2008-03-19 09:53:23 +00:00
|
|
|
int counterx, int countery, EColorRange translation, bool drawArtiboxes, bool noArrows, bool alwaysshowcounter)
|
|
|
|
{ //yes, there is some Copy & Paste here too
|
|
|
|
AInventory *item;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// If the player has no artifacts, don't draw the bar
|
|
|
|
CPlayer->mo->InvFirst = ValidateInvFirst(num);
|
|
|
|
if(CPlayer->mo->InvFirst != NULL || alwaysshow)
|
|
|
|
{
|
|
|
|
for(item = CPlayer->mo->InvFirst, i = 0; item != NULL && i < num; item = item->NextInv(), ++i)
|
|
|
|
{
|
|
|
|
if(drawArtiboxes)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(Images[invBarOffset + imgARTIBOX], x+i*31, y, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(TexMan(item->Icon), x+i*31, y, xOffset, yOffset, alpha, false, item->Amount <= 0);
|
2008-03-19 09:53:23 +00:00
|
|
|
if(alwaysshowcounter || item->Amount != 1)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawNumber(item->Amount, 3, counterx+i*31, countery, xOffset, yOffset, alpha, translation);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
if(item == CPlayer->mo->InvSel)
|
|
|
|
{
|
|
|
|
if(type == GAME_Heretic)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(Images[invBarOffset + imgSELECTBOX], x+i*31, y+29, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(Images[invBarOffset + imgSELECTBOX], x+i*31, y, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; i < num && drawArtiboxes; ++i)
|
|
|
|
{
|
2008-04-25 09:40:08 +00:00
|
|
|
DrawGraphic(Images[invBarOffset + imgARTIBOX], x+i*31, y, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
// Is there something to the left?
|
|
|
|
if (!noArrows && CPlayer->mo->FirstInv() != CPlayer->mo->InvFirst)
|
|
|
|
{
|
2008-04-05 07:06:26 +00:00
|
|
|
DrawGraphic(Images[!(gametic & 4) ?
|
2008-04-25 09:40:08 +00:00
|
|
|
invBarOffset + imgINVLFGEM1 : invBarOffset + imgINVLFGEM2], x-12, y, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
// Is there something to the right?
|
|
|
|
if (!noArrows && item != NULL)
|
|
|
|
{
|
2008-04-05 07:06:26 +00:00
|
|
|
DrawGraphic(Images[!(gametic & 4) ?
|
2008-04-25 09:40:08 +00:00
|
|
|
invBarOffset + imgINVRTGEM1 : invBarOffset + imgINVRTGEM2], x+num*31+2, y, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//draws heretic/hexen style life gems
|
2008-04-25 09:40:08 +00:00
|
|
|
void DSBarInfo::DrawGem(FTexture* chain, FTexture* gem, int value, int x, int y, int xOffset, int yOffset, int alpha, int padleft, int padright, int chainsize,
|
2008-03-19 09:53:23 +00:00
|
|
|
bool wiggle, bool translate)
|
|
|
|
{
|
2008-04-20 00:23:07 +00:00
|
|
|
if(chain == NULL)
|
|
|
|
return;
|
2008-03-19 09:53:23 +00:00
|
|
|
if(value > 100)
|
|
|
|
value = 100;
|
|
|
|
else if(value < 0)
|
|
|
|
value = 0;
|
|
|
|
if(wiggle)
|
|
|
|
y += chainWiggle;
|
|
|
|
int chainWidth = chain->GetWidth();
|
|
|
|
int offset = (int) (((double) (chainWidth-padleft-padright)/100)*value);
|
2008-04-25 09:50:43 +00:00
|
|
|
DrawGraphic(chain, x+(offset%chainsize), y, xOffset, yOffset, alpha);
|
2008-03-19 09:53:23 +00:00
|
|
|
if(gem != NULL)
|
2008-04-25 09:50:43 +00:00
|
|
|
DrawGraphic(gem, x+padleft+offset, y, xOffset, yOffset, alpha, translate);
|
2008-03-19 09:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FRemapTable* DSBarInfo::getTranslation()
|
|
|
|
{
|
|
|
|
if(gameinfo.gametype & GAME_Raven)
|
|
|
|
return translationtables[TRANSLATION_PlayersExtra][int(CPlayer - players)];
|
|
|
|
return translationtables[TRANSLATION_Players][int(CPlayer - players)];
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS(DSBarInfo);
|
|
|
|
|
|
|
|
DBaseStatusBar *CreateCustomStatusBar ()
|
|
|
|
{
|
|
|
|
return new DSBarInfo;
|
|
|
|
}
|