- Consolidated the mug shot code shared by DSBarInfo and DDoomStatusBar
into a single place. - Fixed: Setting an invalid mug shot state crashed the game. - Fixed my attempts to be clever with strings yesterday. SVN r1009 (trunk)
This commit is contained in:
parent
ccf123407a
commit
4850a98c13
9 changed files with 758 additions and 710 deletions
|
|
@ -38,8 +38,8 @@
|
|||
#include "sc_man.h"
|
||||
#include "v_font.h"
|
||||
#include "w_wad.h"
|
||||
#include "sbar.h"
|
||||
#include "d_player.h"
|
||||
#include "sbar.h"
|
||||
#include "sbarinfo.h"
|
||||
#include "templates.h"
|
||||
#include "m_random.h"
|
||||
|
|
@ -47,7 +47,6 @@
|
|||
#include "i_system.h"
|
||||
|
||||
SBarInfo *SBarInfoScript;
|
||||
TArray<MugShotState> MugShotStates;
|
||||
|
||||
static const char *SBarInfoTopLevel[] =
|
||||
{
|
||||
|
|
@ -287,28 +286,28 @@ void SBarInfo::ParseSBarInfo(int lump)
|
|||
case SBARINFO_MUGSHOT:
|
||||
{
|
||||
sc.MustGetToken(TK_StringConst);
|
||||
MugShotState state(sc.String);
|
||||
FMugShotState state(sc.String);
|
||||
if(sc.CheckToken(',')) //first loop must be a comma
|
||||
{
|
||||
do
|
||||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(sc.Compare("health"))
|
||||
state.usesLevels = true;
|
||||
state.bUsesLevels = true;
|
||||
else if(sc.Compare("health2"))
|
||||
state.usesLevels = state.health2 = true;
|
||||
state.bUsesLevels = state.bHealth2 = true;
|
||||
else if(sc.Compare("healthspecial"))
|
||||
state.usesLevels = state.healthspecial = true;
|
||||
state.bUsesLevels = state.bHealthSpecial = true;
|
||||
else if(sc.Compare("directional"))
|
||||
state.directional = true;
|
||||
state.bDirectional = true;
|
||||
else
|
||||
sc.ScriptError("Unknown MugShot state flag '%s'.", sc.String);
|
||||
}
|
||||
while(sc.CheckToken(',') || sc.CheckToken('|'));
|
||||
}
|
||||
ParseMugShotBlock(sc, state);
|
||||
int index = 0;
|
||||
if((index = FindMugShotStateIndex(state.state)) != -1) //We already had this state, remove the old one.
|
||||
int index;
|
||||
if((index = FindMugShotStateIndex(state.State)) != -1) //We already had this state, remove the old one.
|
||||
{
|
||||
MugShotStates.Delete(index);
|
||||
}
|
||||
|
|
@ -1152,12 +1151,12 @@ void SBarInfo::ParseSBarInfoBlock(FScanner &sc, SBarInfoBlock &block)
|
|||
sc.MustGetToken('}');
|
||||
}
|
||||
|
||||
void SBarInfo::ParseMugShotBlock(FScanner &sc, MugShotState &state)
|
||||
void SBarInfo::ParseMugShotBlock(FScanner &sc, FMugShotState &state)
|
||||
{
|
||||
sc.MustGetToken('{');
|
||||
while(!sc.CheckToken('}'))
|
||||
{
|
||||
MugShotFrame frame;
|
||||
FMugShotFrame frame;
|
||||
bool multiframe = false;
|
||||
if(sc.CheckToken('{'))
|
||||
multiframe = true;
|
||||
|
|
@ -1165,15 +1164,15 @@ void SBarInfo::ParseMugShotBlock(FScanner &sc, MugShotState &state)
|
|||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(strlen(sc.String) > 5)
|
||||
sc.ScriptError("MugShot frames can not exceed 5 characters.");
|
||||
frame.graphic.Push(sc.String);
|
||||
sc.ScriptError("MugShot frames cannot exceed 5 characters.");
|
||||
frame.Graphic.Push(sc.String);
|
||||
}
|
||||
while(multiframe && sc.CheckToken(','));
|
||||
if(multiframe)
|
||||
sc.MustGetToken('}');
|
||||
frame.delay = getSignedInteger(sc);
|
||||
frame.Delay = getSignedInteger(sc);
|
||||
sc.MustGetToken(';');
|
||||
state.frames.Push(frame);
|
||||
state.Frames.Push(frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1315,17 +1314,6 @@ SBarInfoBlock::SBarInfoBlock()
|
|||
alpha = FRACUNIT;
|
||||
}
|
||||
|
||||
const MugShotState *FindMugShotState(FString state)
|
||||
{
|
||||
state.ToLower();
|
||||
for(unsigned int i = 0;i < MugShotStates.Size();i++)
|
||||
{
|
||||
if(MugShotStates[i].state == state)
|
||||
return &MugShotStates[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Popup
|
||||
Popup::Popup()
|
||||
{
|
||||
|
|
@ -1435,14 +1423,3 @@ void Popup::close()
|
|||
opened = false;
|
||||
moving = true;
|
||||
}
|
||||
|
||||
//Used to allow replacements of states
|
||||
int FindMugShotStateIndex(FName state)
|
||||
{
|
||||
for(unsigned int i = 0;i < MugShotStates.Size();i++)
|
||||
{
|
||||
if(MugShotStates[i].state == state)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue