SBarInfo Update #17:

- Fixed: SBarInfo tried to calculate scaled offsets on unscaled status bars.
- Added: createpopup to SBarInfo.  No we don't have custom popups yet.  It only
  defines the transition effect.  Currently none or slideinbottom.
- Made the first argument of DrawMugShot optional (think of it as an overloaded
  function).  The use of the first argument is deprecated due to the event of
  per player class faces.
- More changes from DrawImage to screen->DrawTexture().  I guess I didn't get
  them all just yet.


SVN r897 (trunk)
This commit is contained in:
Christoph Oelckers 2008-04-09 07:32:33 +00:00
commit a0356a45cd
4 changed files with 229 additions and 34 deletions

View file

@ -60,6 +60,7 @@ static const char *SBarInfoTopLevel[] =
"lowerhealthcap",
"statusbar",
"mugshot",
"createpopup",
NULL
};
@ -305,6 +306,43 @@ void SBarInfo::ParseSBarInfo(int lump)
MugShotStates.Push(state);
break;
}
case SBARINFO_CREATEPOPUP:
{
int pop = 0;
sc.MustGetToken(TK_Identifier);
if(sc.Compare("keys"))
pop = 0;
else if(sc.Compare("log"))
pop = 1;
else if(sc.Compare("status"))
pop = 2;
else
sc.ScriptError("Unkown popup: '%s'", sc.String);
Popup &popup = popups[pop];
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
popup.width = sc.Number;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
popup.height = sc.Number;
sc.MustGetToken(',');
if(!sc.CheckToken(TK_None))
{
sc.MustGetToken(TK_Identifier);
if(sc.Compare("slideinbottom"))
{
popup.transition = TRANSITION_SLIDEINBOTTOM;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
popup.speed = sc.Number;
}
else
sc.ScriptError("Unkown transition type: '%s'", sc.String);
}
popup.init();
sc.MustGetToken(';');
break;
}
}
}
}
@ -553,9 +591,11 @@ void SBarInfo::ParseSBarInfoBlock(FScanner &sc, SBarInfoBlock &block)
sc.MustGetToken(';');
break;
case SBARINFO_DRAWMUGSHOT:
sc.MustGetToken(TK_StringConst);
cmd.setString(sc, sc.String, 0, 3, true);
sc.MustGetToken(',');
if(sc.CheckToken(TK_StringConst))
{
cmd.setString(sc, sc.String, 0, 3, true);
sc.MustGetToken(',');
}
sc.MustGetToken(TK_IntConst); //accuracy
if(sc.Number < 1 || sc.Number > 9)
sc.ScriptError("Expected a number between 1 and 9, got %d instead.", sc.Number);
@ -1237,6 +1277,88 @@ const MugShotState *FindMugShotState(FString state)
return NULL;
}
//Popup
Popup::Popup()
{
transition = TRANSITION_NONE;
height = 320;
width = 200;
speed = 0;
x = 320;
y = 200;
opened = false;
moving = false;
}
void Popup::init()
{
x = width;
y = height;
if(transition == TRANSITION_SLIDEINBOTTOM)
{
x = 0;
}
}
void Popup::tick()
{
if(transition == TRANSITION_SLIDEINBOTTOM)
{
if(moving)
{
if(opened)
y -= clamp(height + (y - height), 1, speed);
else
y += clamp(height - y, 1, speed);
}
if(y != 0 && y != height)
moving = true;
else
moving = false;
}
else
{
moving = false;
if(opened)
{
y = 0;
x = 0;
}
else
{
y = height;
x = width;
}
}
}
bool Popup::isDoneMoving()
{
return !moving;
}
int Popup::getXOffset()
{
return x;
}
int Popup::getYOffset()
{
return y;
}
void Popup::open()
{
opened = true;
moving = true;
}
void Popup::close()
{
opened = false;
moving = true;
}
//Used to allow replacements of states
int FindMugShotStateIndex(FName state)
{