- floatification of g_shared.
- rewrote FraggleScript's movecamera function because it was utterly incomprehensible.
This commit is contained in:
parent
6557f3b8c8
commit
4a79602325
30 changed files with 281 additions and 416 deletions
|
|
@ -48,7 +48,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
translatable(false), type(NORMAL_IMAGE), image(-1), maxwidth(-1),
|
||||
maxheight(-1), spawnScaleX(1.0f), spawnScaleY(1.0f), flags(0),
|
||||
applyscale(false), offset(static_cast<Offset> (TOP|LEFT)),
|
||||
texture(NULL), alpha(OPAQUE)
|
||||
texture(NULL), alpha(1.)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
int w = maxwidth, h = maxheight;
|
||||
|
||||
// We must calculate this per frame in order to prevent glitches with cl_capfps true.
|
||||
fixed_t frameAlpha = FixedMul(block->Alpha(), alpha);
|
||||
double frameAlpha = block->Alpha() * alpha;
|
||||
|
||||
if(flags & DI_DRAWINBOX)
|
||||
{
|
||||
|
|
@ -234,7 +234,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged);
|
||||
|
||||
texture = NULL;
|
||||
alpha = OPAQUE;
|
||||
alpha = 1.;
|
||||
if (applyscale)
|
||||
{
|
||||
spawnScaleX = spawnScaleY = 1.0f;
|
||||
|
|
@ -282,7 +282,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
if (harmor->Slots[armorType] > 0 && harmor->SlotsIncrement[armorType] > 0)
|
||||
{
|
||||
//combine the alpha values
|
||||
alpha = int(alpha * MIN(1., harmor->Slots[armorType] / harmor->SlotsIncrement[armorType]));
|
||||
alpha *= MIN(1., harmor->Slots[armorType] / harmor->SlotsIncrement[armorType]);
|
||||
texture = statusBar->Images[image];
|
||||
}
|
||||
else
|
||||
|
|
@ -350,7 +350,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
Offset offset;
|
||||
|
||||
FTexture *texture;
|
||||
int alpha;
|
||||
double alpha;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -641,7 +641,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
|||
|
||||
// Since we're not going to call our parent's tick() method,
|
||||
// be sure to set the alpha value properly.
|
||||
alpha = FRACUNIT;
|
||||
alpha = 1.;
|
||||
return;
|
||||
}
|
||||
CommandDrawImage::Tick(block, statusBar, hudChanged);
|
||||
|
|
@ -1641,9 +1641,9 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
|
|||
}
|
||||
else
|
||||
{
|
||||
if(itemflash && itemflashFade)
|
||||
if(itemflash && itemflashFade != 0)
|
||||
{
|
||||
fixed_t flashAlpha = FixedMul(block->Alpha(), itemflashFade);
|
||||
double flashAlpha = block->Alpha() * itemflashFade;
|
||||
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgCURSOR], imgx-4, imgy+2, block->XOffset(), block->YOffset(), flashAlpha, block->FullScreenOffsets(),
|
||||
translatable, false, offset);
|
||||
}
|
||||
|
|
@ -1736,7 +1736,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
|
|||
artiflashTick--;
|
||||
if(itemflashFade > 0)
|
||||
{
|
||||
itemflashFade -= FRACUNIT/14;
|
||||
itemflashFade -= 1./14;
|
||||
if(itemflashFade < 0)
|
||||
itemflashFade = 0;
|
||||
}
|
||||
|
|
@ -1747,7 +1747,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
|
|||
CommandDrawNumber::Tick(block, statusBar, hudChanged);
|
||||
}
|
||||
|
||||
static void Flash() { artiflashTick = 4; itemflashFade = FRACUNIT*3/4; }
|
||||
static void Flash() { artiflashTick = 4; itemflashFade = 0.75; }
|
||||
protected:
|
||||
bool alternateOnEmpty;
|
||||
bool artiflash;
|
||||
|
|
@ -1755,10 +1755,10 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
|
|||
bool itemflash;
|
||||
|
||||
static int artiflashTick;
|
||||
static fixed_t itemflashFade;
|
||||
static double itemflashFade;
|
||||
};
|
||||
int CommandDrawSelectedInventory::artiflashTick = 0;
|
||||
int CommandDrawSelectedInventory::itemflashFade = FRACUNIT*3/4;
|
||||
double CommandDrawSelectedInventory::itemflashFade = 0.75;
|
||||
|
||||
void DSBarInfo::FlashItem(const PClass *itemtype)
|
||||
{
|
||||
|
|
@ -2110,9 +2110,9 @@ class CommandDrawInventoryBar : public SBarInfoCommand
|
|||
{
|
||||
int spacing = GetCounterSpacing(statusBar);
|
||||
|
||||
int bgalpha = block->Alpha();
|
||||
double bgalpha = block->Alpha();
|
||||
if(translucent)
|
||||
bgalpha = fixed_t(block->Alpha() * HX_SHADOW);
|
||||
bgalpha *= HX_SHADOW;
|
||||
|
||||
AInventory *item;
|
||||
unsigned int i = 0;
|
||||
|
|
@ -2492,10 +2492,10 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
FTexture *fg = statusBar->Images[foreground];
|
||||
FTexture *bg = (background != -1) ? statusBar->Images[background] : NULL;
|
||||
|
||||
fixed_t value = drawValue;
|
||||
double value = drawValue;
|
||||
if(border != 0)
|
||||
{
|
||||
value = FRACUNIT - value; //invert since the new drawing method requires drawing the bg on the fg.
|
||||
value = 1. - value; //invert since the new drawing method requires drawing the bg on the fg.
|
||||
|
||||
//Draw the whole foreground
|
||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
|
|
@ -2506,27 +2506,27 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
|
||||
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
else
|
||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, 0, 0, 0, 0, true);
|
||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, nulclip, true);
|
||||
}
|
||||
|
||||
// {cx, cy, cr, cb}
|
||||
fixed_t clip[4] = {0, 0, 0, 0};
|
||||
double Clip[4] = {0, 0, 0, 0};
|
||||
|
||||
fixed_t sizeOfImage = (horizontal ? fg->GetScaledWidth()-border*2 : fg->GetScaledHeight()-border*2)<<FRACBITS;
|
||||
clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - FixedMul(sizeOfImage, value);
|
||||
int sizeOfImage = (horizontal ? fg->GetScaledWidth()-border*2 : fg->GetScaledHeight()-border*2);
|
||||
Clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - sizeOfImage *value;
|
||||
// Draw background
|
||||
if(border != 0)
|
||||
{
|
||||
for(unsigned int i = 0;i < 4;i++)
|
||||
clip[i] += border<<FRACBITS;
|
||||
Clip[i] += border;
|
||||
|
||||
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
|
||||
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, clip[0], clip[1], clip[2], clip[3]);
|
||||
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip);
|
||||
else
|
||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, clip[0], clip[1], clip[2], clip[3], true);
|
||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip, true);
|
||||
}
|
||||
else
|
||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, clip[0], clip[1], clip[2], clip[3]);
|
||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip);
|
||||
}
|
||||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
|
|
@ -2651,7 +2651,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
}
|
||||
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
||||
{
|
||||
fixed_t value = 0;
|
||||
double value = 0;
|
||||
int max = 0;
|
||||
switch(type)
|
||||
{
|
||||
|
|
@ -2791,9 +2791,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
|
||||
if(max != 0 && value > 0)
|
||||
{
|
||||
value = (value << FRACBITS) / max;
|
||||
if(value > FRACUNIT)
|
||||
value = FRACUNIT;
|
||||
value = MIN(value / max, 1.);
|
||||
}
|
||||
else
|
||||
value = 0;
|
||||
|
|
@ -2802,14 +2800,14 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
// [BL] Since we used a percentage (in order to get the most fluid animation)
|
||||
// we need to establish a cut off point so the last pixel won't hang as the animation slows
|
||||
if(pixel == -1 && statusBar->Images[foreground])
|
||||
pixel = MAX(1, FRACUNIT/statusBar->Images[foreground]->GetWidth());
|
||||
pixel = MAX(1., 1./statusBar->Images[foreground]->GetWidth());
|
||||
|
||||
if(abs(drawValue - value) < pixel)
|
||||
if(fabs(drawValue - value) < pixel)
|
||||
drawValue = value;
|
||||
else if(value < drawValue)
|
||||
drawValue -= clamp<fixed_t>((drawValue - value) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100));
|
||||
else if(drawValue < value)
|
||||
drawValue += clamp<fixed_t>((value - drawValue) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100));
|
||||
else if (value < drawValue)
|
||||
drawValue -= clamp<double>((drawValue - value) / 4, 1 / 65536., interpolationSpeed / 100.);
|
||||
else if (drawValue < value)
|
||||
drawValue += clamp<double>((value - drawValue) / 4, 1 / 65536., interpolationSpeed / 100.);
|
||||
}
|
||||
else
|
||||
drawValue = value;
|
||||
|
|
@ -2883,8 +2881,8 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
SBarInfoCoordinate y;
|
||||
|
||||
int interpolationSpeed;
|
||||
fixed_t drawValue;
|
||||
fixed_t pixel;
|
||||
double drawValue;
|
||||
double pixel;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -3448,7 +3446,7 @@ class CommandAlpha : public SBarInfoMainBlock
|
|||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
sc.MustGetToken(TK_FloatConst);
|
||||
alpha = fixed_t(FRACUNIT * sc.Float);
|
||||
alpha = sc.Float;
|
||||
|
||||
// We don't want to allow all the options of a regular main block
|
||||
// so skip to the SBarInfoCommandFlowControl.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue