- Applied Blzut3's sbarinfo update #12:

* When the drawbar code was optimized border was accidently used as how many
  pixels to reserve from the background instead of the foreground.  I've
  reversed how the code works (bg over fg instead of fg over bg).
* Added armorclass to drawnumber.
* Added an interpolateArmor variable which acts just like interpolateHealth
  except the effect is applied to armor.
* Added armor flag to drawgem since we can interpolate armor now.
* Added a reverse flag to drawgem.
* Fixed drawgem didn't allow for '|' to separate the flags.

- Fixed: Menu texts for skill definitions unconditionally interpreted
  the given text as an index into the string table.


SVN r752 (trunk)
This commit is contained in:
Christoph Oelckers 2008-02-18 22:40:39 +00:00
parent 133350fb9c
commit 2a77ea0155
7 changed files with 171 additions and 80 deletions

View File

@ -1,3 +1,18 @@
February 18, 2008 (Changes by Graf Zahl)
- Applied Blzut3's sbarinfo update #12:
* When the drawbar code was optimized border was accidently used as how many
pixels to reserve from the background instead of the foreground. I've
reversed how the code works (bg over fg instead of fg over bg).
* Added armorclass to drawnumber.
* Added an interpolateArmor variable which acts just like interpolateHealth
except the effect is applied to armor.
* Added armor flag to drawgem since we can interpolate armor now.
* Added a reverse flag to drawgem.
* Fixed drawgem didn't allow for '|' to separate the flags.
- Fixed: Menu texts for skill definitions unconditionally interpreted
the given text as an index into the string table.
February 16, 2008
- Fixed AInventory::PickupFlash setting with GCC.
- Fixed: The MusicVolumes list was allocated with M_Malloc but freed with

View File

@ -2609,11 +2609,11 @@ void G_MakeEpisodes ()
static const char *hepinames[5] =
{
"MNU_COTD",
"MNU_HELLSMAW",
"MNU_DOME",
"MNU_OSSUARY",
"MNU_DEMESNE",
"$MNU_COTD",
"$MNU_HELLSMAW",
"$MNU_DOME",
"$MNU_OSSUARY",
"$MNU_DEMESNE",
};
static const char hepikeys[5] = { 'c', 'h', 'd', 'o', 's' };

View File

@ -78,6 +78,7 @@ enum //drawnumber flags
DRAWNUMBER_TOTALITEMS = 2048,
DRAWNUMBER_SECRETS = 4096,
DRAWNUMBER_TOTALSECRETS = 8192,
DRAWNUMBER_ARMORCLASS = 16384,
};
enum //drawbar flags (will go into special2)
@ -106,6 +107,8 @@ enum //drawgem flags
{
DRAWGEM_WIGGLE = 1,
DRAWGEM_TRANSLATABLE = 2,
DRAWGEM_ARMOR = 4,
DRAWGEM_REVERSE = 8,
};
enum //drawshader flags
@ -137,6 +140,7 @@ static const char *SBarInfoTopLevel[] =
"base",
"height",
"interpolatehealth",
"interpolatearmor",
"completeborder",
"statusbar",
NULL
@ -146,6 +150,7 @@ enum
SBARINFO_BASE,
SBARINFO_HEIGHT,
SBARINFO_INTERPOLATEHEALTH,
SBARINFO_INTERPOLATEARMOR,
SBARINFO_COMPLETEBORDER,
SBARINFO_STATUSBAR,
};
@ -215,7 +220,7 @@ void FreeSBarInfoScript()
}
}
//Laz Bar Script Reader
//SBarInfo Script Reader
void SBarInfo::ParseSBarInfo(int lump)
{
FScanner sc(lump, Wads.GetLumpFullName(lump));
@ -276,6 +281,23 @@ void SBarInfo::ParseSBarInfo(int lump)
}
sc.MustGetToken(';');
break;
case SBARINFO_INTERPOLATEARMOR: //Since interpolatehealth is such a popular command
if(sc.CheckToken(TK_True))
{
interpolateArmor = true;
}
else
{
sc.MustGetToken(TK_False);
interpolateArmor = false;
}
if(sc.CheckToken(',')) //speed
{
sc.MustGetToken(TK_IntConst);
this->armorInterpolationSpeed = sc.Number;
}
sc.MustGetToken(';');
break;
case SBARINFO_COMPLETEBORDER: //draws the border instead of an HOM
if(sc.CheckToken(TK_True))
{
@ -492,6 +514,8 @@ void SBarInfo::ParseSBarInfoBlock(FScanner &sc, SBarInfoBlock &block)
cmd.flags += DRAWNUMBER_SECRETS;
else if(sc.Compare("totalsecrets"))
cmd.flags += DRAWNUMBER_TOTALSECRETS;
else if(sc.Compare("armorclass"))
cmd.flags += DRAWNUMBER_ARMORCLASS;
else
{
cmd.flags = DRAWNUMBER_INVENTORY;
@ -796,9 +820,14 @@ void SBarInfo::ParseSBarInfoBlock(FScanner &sc, SBarInfoBlock &block)
cmd.flags += DRAWGEM_WIGGLE;
else if(sc.Compare("translatable"))
cmd.flags += DRAWGEM_TRANSLATABLE;
else if(sc.Compare("armor"))
cmd.flags += DRAWGEM_ARMOR;
else if(sc.Compare("reverse"))
cmd.flags += DRAWGEM_REVERSE;
else
sc.ScriptError("Unknown drawgem flag '%s'.", sc.String);
sc.MustGetToken(',');
if(!sc.CheckToken('|'))
sc.MustGetToken(',');
}
sc.MustGetToken(TK_StringConst); //chain
cmd.special = newImage(sc.String);
@ -994,10 +1023,6 @@ int SBarInfo::newImage(const char* patchname)
{
return -1;
}
// if(strlen(patchname) > 8)
// {
// sc.ScriptError("Graphic names can not be greater then 8 characters long.");
// }
for(unsigned int i = 0;i < this->Images.Size();i++) //did we already load it?
{
if(stricmp(this->Images[i], patchname) == 0)
@ -1038,8 +1063,10 @@ void SBarInfo::Init()
{
automapbar = false;
interpolateHealth = false;
interpolateArmor = false;
completeBorder = false;
interpolationSpeed = 8;
armorInterpolationSpeed = 8;
height = 0;
}
@ -1243,10 +1270,8 @@ public:
faceTimer = ST_FACETIME;
rampageTimer = 0;
faceIndex = 0;
if(SBarInfoScript->interpolateHealth)
{
oldHealth = 0;
}
oldHealth = 0;
oldArmor = 0;
mugshotHealth = -1;
lastPrefix = "";
weaponGrin = false;
@ -1337,11 +1362,34 @@ public:
{
if(oldHealth > CPlayer->health)
{
oldHealth -= clamp((oldHealth - CPlayer->health) >> 2, 1, 8);
oldHealth -= clamp((oldHealth - CPlayer->health) >> 2, 1, SBarInfoScript->interpolationSpeed);
}
else if(oldHealth < CPlayer->health)
{
oldHealth += clamp((CPlayer->health - oldHealth) >> 2, 1, 8);
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)
@ -1437,11 +1485,17 @@ private:
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];
@ -1522,7 +1576,6 @@ private:
}
else if((cmd.flags & DRAWIMAGE_ARMOR))
{
ABasicArmor *armor = CPlayer->mo->FindInventory<ABasicArmor>();
if(armor != NULL && armor->Amount != 0)
DrawGraphic(TexMan(armor->Icon), cmd.x, cmd.y, cmd.flags);
}
@ -1558,8 +1611,7 @@ private:
}
else if(cmd.flags == DRAWNUMBER_ARMOR)
{
AInventory *armor = CPlayer->mo->FindInventory<ABasicArmor>();
cmd.value = armor != NULL ? armor->Amount : 0;
cmd.value = armorAmount;
}
else if(cmd.flags == DRAWNUMBER_AMMO1)
{
@ -1617,6 +1669,21 @@ private:
cmd.value = level.found_secrets;
else if(cmd.flags == DRAWNUMBER_TOTALSECRETS)
cmd.value = level.total_secrets;
else if(cmd.flags == DRAWNUMBER_ARMORCLASS)
{
AHexenArmor *harmor = CPlayer->mo->FindInventory<AHexenArmor>();
if(harmor != NULL)
{
cmd.value = harmor->Slots[0] + harmor->Slots[1] +
harmor->Slots[2] + harmor->Slots[3] + harmor->Slots[4];
}
//Hexen counts basic armor also so we should too.
if(armor != NULL)
{
cmd.value += armor->SavePercent;
}
cmd.value /= (5*FRACUNIT);
}
else if(cmd.flags == DRAWNUMBER_INVENTORY)
{
AInventory* item = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[0]));
@ -1728,8 +1795,7 @@ private:
}
else if(cmd.flags == DRAWNUMBER_ARMOR)
{
AInventory *armor = CPlayer->mo->FindInventory<ABasicArmor>();
value = armor != NULL ? armor->Amount : 0;
value = armorAmount;
if(!((cmd.special2 & DRAWBAR_COMPAREDEFAULTS) == DRAWBAR_COMPAREDEFAULTS))
{
AInventory* item = CPlayer->mo->FindInventory(PClass::FindClass(cmd.string[0])); //max comparer
@ -1816,12 +1882,17 @@ private:
value = 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(max == 0 && value <= 0)
{
value = FRACUNIT;
}
else
{
value = 0;
@ -1843,20 +1914,13 @@ private:
screen->VirtualToRealCoordsInt(x, y, w, h, 320, 200, true);
}
// Draw background
if (bg != NULL && bg->GetWidth() == fg->GetWidth() && bg->GetHeight() == fg->GetHeight())
{
screen->DrawTexture(bg, x, y,
DTA_DestWidth, w,
DTA_DestHeight, h,
TAG_DONE);
}
else
{
screen->Clear(x, y, x + w, y + h, GPalette.BlackIndex, 0);
}
//Draw the whole foreground
screen->DrawTexture(fg, x, y,
DTA_DestWidth, w,
DTA_DestHeight, h,
TAG_DONE);
// Calc clipping rect for foreground
// Calc clipping rect for background
cx = cmd.x + ST_X + cmd.special3;
cy = cmd.y + ST_Y + cmd.special3;
cw = fg->GetWidth() - cmd.special3 * 2;
@ -1867,7 +1931,7 @@ private:
}
if (horizontal)
{
if (!reverse)
if (reverse)
{ // left to right
cr = cx + FixedMul(cw, value);
}
@ -1880,7 +1944,7 @@ private:
}
else
{
if (!reverse)
if (reverse)
{ // bottom to top
cb = cy + ch;
cy += FixedMul(ch, FRACUNIT - value);
@ -1892,20 +1956,27 @@ private:
cr = cx + cw;
}
// Draw foreground
screen->DrawTexture(fg, x, y,
DTA_DestWidth, w,
DTA_DestHeight, h,
DTA_ClipLeft, cx,
DTA_ClipTop, cy,
DTA_ClipRight, cr,
DTA_ClipBottom, cb,
TAG_DONE);
// Draw background
if (bg != NULL && bg->GetWidth() == fg->GetWidth() && bg->GetHeight() == fg->GetHeight())
{
screen->DrawTexture(bg, x, y,
DTA_DestWidth, w,
DTA_DestHeight, h,
DTA_ClipLeft, cx,
DTA_ClipTop, cy,
DTA_ClipRight, cr,
DTA_ClipBottom, cb,
TAG_DONE);
}
else
{
screen->Clear(cx, cy, cr, cb, GPalette.BlackIndex, 0);
}
break;
}
case SBARINFO_DRAWGEM:
{
int value = health;
int value = (cmd.flags & DRAWGEM_ARMOR) ? armorAmount : health;
int max = 100;
bool wiggle = false;
bool translate = !!(cmd.flags & DRAWGEM_TRANSLATABLE);
@ -1919,6 +1990,7 @@ private:
{
value = 0;
}
value = (cmd.flags & DRAWGEM_REVERSE) ? 100 - value : value;
if(health != CPlayer->health)
{
wiggle = !!(cmd.flags & DRAWGEM_WIGGLE);
@ -2325,6 +2397,7 @@ private:
int rampageTimer;
int faceIndex;
int oldHealth;
int oldArmor;
int mugshotHealth;
int chainWiggle;
int artiflash;

View File

@ -46,8 +46,10 @@ struct SBarInfo
SBarInfoBlock huds[6];
bool automapbar;
bool interpolateHealth;
bool interpolateArmor;
bool completeBorder;
int interpolationSpeed;
int armorInterpolationSpeed;
int height;
int gameType;

View File

@ -291,11 +291,11 @@ static oldmenu_t MainDef =
//
static oldmenuitem_t HereticMainMenu[] =
{
{1,1,'n',"MNU_NEWGAME",M_NewGame, CR_UNTRANSLATED},
{1,1,'o',"MNU_OPTIONS",M_Options, CR_UNTRANSLATED},
{1,1,'f',"MNU_GAMEFILES",M_GameFiles, CR_UNTRANSLATED},
{1,1,'i',"MNU_INFO",M_ReadThis, CR_UNTRANSLATED},
{1,1,'q',"MNU_QUITGAME",M_QuitGame, CR_UNTRANSLATED}
{1,1,'n',"$MNU_NEWGAME",M_NewGame, CR_UNTRANSLATED},
{1,1,'o',"$MNU_OPTIONS",M_Options, CR_UNTRANSLATED},
{1,1,'f',"$MNU_GAMEFILES",M_GameFiles, CR_UNTRANSLATED},
{1,1,'i',"$MNU_INFO",M_ReadThis, CR_UNTRANSLATED},
{1,1,'q',"$MNU_QUITGAME",M_QuitGame, CR_UNTRANSLATED}
};
static oldmenu_t HereticMainDef =
@ -312,10 +312,10 @@ static oldmenu_t HereticMainDef =
//
static oldmenuitem_t ClassItems[] =
{
{ 1,1, 'f', "MNU_FIGHTER", SCClass, CR_UNTRANSLATED },
{ 1,1, 'c', "MNU_CLERIC", SCClass, CR_UNTRANSLATED },
{ 1,1, 'm', "MNU_MAGE", SCClass, CR_UNTRANSLATED },
{ 1,1, 'r', "MNU_RANDOM", SCClass, CR_UNTRANSLATED } // [RH]
{ 1,1, 'f', "$MNU_FIGHTER", SCClass, CR_UNTRANSLATED },
{ 1,1, 'c', "$MNU_CLERIC", SCClass, CR_UNTRANSLATED },
{ 1,1, 'm', "$MNU_MAGE", SCClass, CR_UNTRANSLATED },
{ 1,1, 'r', "$MNU_RANDOM", SCClass, CR_UNTRANSLATED } // [RH]
};
static oldmenu_t ClassMenu =
@ -382,8 +382,8 @@ oldmenu_t EpiDef =
//
static oldmenuitem_t FilesItems[] =
{
{1,1,'l',"MNU_LOADGAME",M_LoadGame, CR_UNTRANSLATED},
{1,1,'s',"MNU_SAVEGAME",M_SaveGame, CR_UNTRANSLATED}
{1,1,'l',"$MNU_LOADGAME",M_LoadGame, CR_UNTRANSLATED},
{1,1,'s',"$MNU_SAVEGAME",M_SaveGame, CR_UNTRANSLATED}
};
static oldmenu_t FilesMenu =
@ -3208,8 +3208,9 @@ void M_Drawer ()
color = CR_RED;
}
}
screen->DrawText (color, x, y,
GStrings(currentMenu->menuitems[i].name),
const char *text = currentMenu->menuitems[i].name;
if (*text == '$') text = GStrings(text+1);
screen->DrawText (color, x, y, text,
DTA_Clean, true, TAG_DONE);
}
else

View File

@ -6,22 +6,22 @@ skill baby
DamageFactor 0.5
EasyBossBrain
SpawnFilter "Easy"
Name "MNU_WETNURSE"
Name "$MNU_WETNURSE"
skill easy
DoubleAmmoFactor 1.5
SpawnFilter "Easy"
Name "MNU_YELLOWBELLIES"
Name "$MNU_YELLOWBELLIES"
skill normal
DoubleAmmoFactor 1.5
SpawnFilter "Normal"
Name "MNU_BRINGEST"
Name "$MNU_BRINGEST"
skill hard
DoubleAmmoFactor 1.5
SpawnFilter "Hard"
Name "MNU_SMITE"
Name "$MNU_SMITE"
skill nightmare
AmmoFactor 1.5
@ -29,7 +29,7 @@ skill nightmare
FastMonsters
DisableCheats
SpawnFilter "Hard"
Name "MNU_BLACKPLAGUE"
Name "$MNU_BLACKPLAGUE"

View File

@ -8,34 +8,34 @@ skill baby
EasyBossBrain
SpawnFilter "Easy"
Name "MNU_WETNURSE"
PlayerClassName "fighter" "MNU_SQUIRE"
PlayerClassName "cleric" "MNU_ALTARBOY"
PlayerClassName "mage" "MNU_APPRENTICE"
PlayerClassName "fighter" "$MNU_SQUIRE"
PlayerClassName "cleric" "$MNU_ALTARBOY"
PlayerClassName "mage" "$MNU_APPRENTICE"
skill easy
DoubleAmmoFactor 1.5
SpawnFilter "Easy"
Name "MNU_YELLOWBELLIES"
PlayerClassName "fighter" "MNU_KNIGHT"
PlayerClassName "cleric" "MNU_ACOLYTE"
PlayerClassName "mage" "MNU_ENCHANTER"
PlayerClassName "fighter" "$MNU_KNIGHT"
PlayerClassName "cleric" "$MNU_ACOLYTE"
PlayerClassName "mage" "$MNU_ENCHANTER"
skill normal
DoubleAmmoFactor 1.5
SpawnFilter "Normal"
Name "MNU_BRINGEST"
PlayerClassName "fighter" "MNU_WARRIOR"
PlayerClassName "cleric" "MNU_PRIEST"
PlayerClassName "mage" "MNU_SORCERER"
PlayerClassName "fighter" "$MNU_WARRIOR"
PlayerClassName "cleric" "$MNU_PRIEST"
PlayerClassName "mage" "$MNU_SORCERER"
skill hard
DoubleAmmoFactor 1.5
SpawnFilter "Hard"
Name "MNU_SMITE"
PlayerClassName "fighter" "MNU_BERSERKER"
PlayerClassName "cleric" "MNU_CARDINAL"
PlayerClassName "mage" "MNU_WARLOCK"
PlayerClassName "fighter" "$MNU_BERSERKER"
PlayerClassName "cleric" "$MNU_CARDINAL"
PlayerClassName "mage" "$MNU_WARLOCK"
skill nightmare
AmmoFactor 1.5
@ -44,9 +44,9 @@ skill nightmare
DisableCheats
SpawnFilter "Hard"
Name "MNU_BLACKPLAGUE"
PlayerClassName "fighter" "MNU_TITAN"
PlayerClassName "cleric" "MNU_POPE"
PlayerClassName "mage" "MNU_ARCHMAGE"
PlayerClassName "fighter" "$MNU_TITAN"
PlayerClassName "cleric" "$MNU_POPE"
PlayerClassName "mage" "$MNU_ARCHMAGE"
clusterdef 1