Merge branch 'master' of https://github.com/rheit/zdoom into zscript

This commit is contained in:
Christoph Oelckers 2016-11-12 09:46:09 +01:00
commit 62a259bb36
8 changed files with 508 additions and 389 deletions

File diff suppressed because it is too large Load diff

View file

@ -241,7 +241,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
applyscale = false; applyscale = false;
} }
if(type == PLAYERICON) if(type == PLAYERICON)
texture = TexMan[statusBar->CPlayer->mo->ScoreIcon]; texture = TexMan(statusBar->CPlayer->mo->ScoreIcon);
else if(type == AMMO1) else if(type == AMMO1)
{ {
AAmmo *ammo = statusBar->ammo1; AAmmo *ammo = statusBar->ammo1;
@ -270,7 +270,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
{ {
AInventory *item = statusBar->CPlayer->mo->FindInventory<ASigil>(); AInventory *item = statusBar->CPlayer->mo->FindInventory<ASigil>();
if (item != NULL) if (item != NULL)
texture = TexMan[item->Icon]; texture = TexMan(item->Icon);
} }
else if(type == HEXENARMOR_ARMOR || type == HEXENARMOR_SHIELD || type == HEXENARMOR_HELM || type == HEXENARMOR_AMULET) else if(type == HEXENARMOR_ARMOR || type == HEXENARMOR_SHIELD || type == HEXENARMOR_HELM || type == HEXENARMOR_AMULET)
{ {
@ -290,7 +290,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
} }
} }
else if(type == INVENTORYICON) else if(type == INVENTORYICON)
texture = TexMan[sprite]; texture = TexMan(sprite);
else if(type == SELECTEDINVENTORYICON && statusBar->CPlayer->mo->InvSel != NULL) else if(type == SELECTEDINVENTORYICON && statusBar->CPlayer->mo->InvSel != NULL)
texture = TexMan(statusBar->CPlayer->mo->InvSel->Icon); texture = TexMan(statusBar->CPlayer->mo->InvSel->Icon);
else if(image >= 0) else if(image >= 0)
@ -312,7 +312,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
spawnScaleY = item->Scale.Y; spawnScaleY = item->Scale.Y;
} }
texture = TexMan[icon]; texture = TexMan(icon);
} }
enum ImageType enum ImageType
@ -2436,22 +2436,22 @@ class CommandDrawKeyBar : public SBarInfoCommand
{ {
if(!vertical) if(!vertical)
{ {
statusBar->DrawGraphic(TexMan[item->Icon], x+slotOffset, y+rowOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); statusBar->DrawGraphic(TexMan(item->Icon), x+slotOffset, y+rowOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
rowWidth = rowIconSize == -1 ? TexMan[item->Icon]->GetScaledHeight()+2 : rowIconSize; rowWidth = rowIconSize == -1 ? TexMan(item->Icon)->GetScaledHeight()+2 : rowIconSize;
} }
else else
{ {
statusBar->DrawGraphic(TexMan[item->Icon], x+rowOffset, y+slotOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); statusBar->DrawGraphic(TexMan(item->Icon), x+rowOffset, y+slotOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
rowWidth = rowIconSize == -1 ? TexMan[item->Icon]->GetScaledWidth()+2 : rowIconSize; rowWidth = rowIconSize == -1 ? TexMan(item->Icon)->GetScaledWidth()+2 : rowIconSize;
} }
// If cmd.special is -1 then the slot size is auto detected // If cmd.special is -1 then the slot size is auto detected
if(iconSize == -1) if(iconSize == -1)
{ {
if(!vertical) if(!vertical)
slotOffset += (reverse ? -1 : 1) * (TexMan[item->Icon]->GetScaledWidth() + 2); slotOffset += (reverse ? -1 : 1) * (TexMan(item->Icon)->GetScaledWidth() + 2);
else else
slotOffset += (reverse ? -1 : 1) * (TexMan[item->Icon]->GetScaledHeight() + 2); slotOffset += (reverse ? -1 : 1) * (TexMan(item->Icon)->GetScaledHeight() + 2);
} }
else else
slotOffset += (reverse ? -iconSize : iconSize); slotOffset += (reverse ? -iconSize : iconSize);

View file

@ -122,6 +122,7 @@ CUSTOM_CVAR(Int, am_showmaplabel, 2, CVAR_ARCHIVE)
} }
CVAR (Bool, idmypos, false, 0); CVAR (Bool, idmypos, false, 0);
CVAR(Float, underwater_fade_scalar, 1.0f, CVAR_ARCHIVE) // [Nash] user-settable underwater blend intensity
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
@ -1547,7 +1548,10 @@ void DBaseStatusBar::DrawPowerups ()
void DBaseStatusBar::BlendView (float blend[4]) void DBaseStatusBar::BlendView (float blend[4])
{ {
V_AddBlend (BaseBlendR / 255.f, BaseBlendG / 255.f, BaseBlendB / 255.f, BaseBlendA, blend); // [Nash] Allow user to set blend intensity
float cnt = (BaseBlendA * underwater_fade_scalar);
V_AddBlend (BaseBlendR / 255.f, BaseBlendG / 255.f, BaseBlendB / 255.f, cnt, blend);
V_AddPlayerBlend(CPlayer, blend, 1.0f, 228); V_AddPlayerBlend(CPlayer, blend, 1.0f, 228);
if (screen->Accel2D || (CPlayer->camera != NULL && menuactive == MENU_Off && ConsoleState == c_up)) if (screen->Accel2D || (CPlayer->camera != NULL && menuactive == MENU_Off && ConsoleState == c_up))

View file

@ -877,8 +877,6 @@ void DFrameBuffer::DrawRateStuff ()
int rate_x; int rate_x;
int textScale = active_con_scale(); int textScale = active_con_scale();
if (textScale == 0)
textScale = CleanXfac;
chars = mysnprintf (fpsbuff, countof(fpsbuff), "%2u ms (%3u fps)", howlong, LastCount); chars = mysnprintf (fpsbuff, countof(fpsbuff), "%2u ms (%3u fps)", howlong, LastCount);
rate_x = Width / textScale - ConFont->StringWidth(&fpsbuff[0]); rate_x = Width / textScale - ConFont->StringWidth(&fpsbuff[0]);

View file

@ -343,28 +343,74 @@ FString &FString::operator += (char tail)
FString &FString::AppendCStrPart (const char *tail, size_t tailLen) FString &FString::AppendCStrPart (const char *tail, size_t tailLen)
{ {
size_t len1 = Len(); if (tailLen > 0)
ReallocBuffer (len1 + tailLen); {
StrCopy (Chars + len1, tail, tailLen); size_t len1 = Len();
ReallocBuffer(len1 + tailLen);
StrCopy(Chars + len1, tail, tailLen);
}
return *this; return *this;
} }
FString &FString::CopyCStrPart(const char *tail, size_t tailLen) FString &FString::CopyCStrPart(const char *tail, size_t tailLen)
{ {
ReallocBuffer(tailLen); if (tailLen > 0)
StrCopy(Chars, tail, tailLen); {
ReallocBuffer(tailLen);
StrCopy(Chars, tail, tailLen);
}
else
{
Data()->Release();
NullString.RefCount++;
Chars = &NullString.Nothing[0];
}
return *this; return *this;
} }
void FString::Truncate(long newlen) void FString::Truncate(long newlen)
{ {
if (newlen >= 0 && newlen < (long)Len()) if (newlen <= 0)
{
Data()->Release();
NullString.RefCount++;
Chars = &NullString.Nothing[0];
}
else if (newlen < (long)Len())
{ {
ReallocBuffer (newlen); ReallocBuffer (newlen);
Chars[newlen] = '\0'; Chars[newlen] = '\0';
} }
} }
void FString::Remove(size_t index, size_t remlen)
{
if (index < Len())
{
if (index + remlen >= Len())
{
Truncate((long)index);
}
else
{
remlen = Len() - remlen < remlen ? Len() - remlen : remlen;
if (Data()->RefCount == 1)
{ // Can do this in place
memmove(Chars + index, Chars + index + remlen, Len() - index - remlen);
Data()->Len -= remlen;
}
else
{ // Must do it in a copy
FStringData *old = Data();
AllocBuffer(old->Len - remlen);
StrCopy(Chars, old->Chars(), index);
StrCopy(Chars + index, old->Chars() + index + remlen, old->Len - index - remlen);
old->Release();
}
}
}
}
FString FString::Left (size_t numChars) const FString FString::Left (size_t numChars) const
{ {
size_t len = Len(); size_t len = Len();
@ -589,6 +635,10 @@ void FString::StripLeft ()
if (!isspace(Chars[i])) if (!isspace(Chars[i]))
break; break;
} }
if (i == 0)
{ // Nothing to strip.
return;
}
if (Data()->RefCount <= 1) if (Data()->RefCount <= 1)
{ {
for (j = 0; i <= max; ++j, ++i) for (j = 0; i <= max; ++j, ++i)
@ -620,6 +670,10 @@ void FString::StripLeft (const char *charset)
if (!strchr (charset, Chars[i])) if (!strchr (charset, Chars[i]))
break; break;
} }
if (i == 0)
{ // Nothing to strip.
return;
}
if (Data()->RefCount <= 1) if (Data()->RefCount <= 1)
{ {
for (j = 0; i <= max; ++j, ++i) for (j = 0; i <= max; ++j, ++i)
@ -640,11 +694,16 @@ void FString::StripLeft (const char *charset)
void FString::StripRight () void FString::StripRight ()
{ {
size_t max = Len(), i; size_t max = Len(), i;
for (i = max; i-- > 0; ) if (max == 0) return;
for (i = --max; i-- > 0; )
{ {
if (!isspace(Chars[i])) if (!isspace(Chars[i]))
break; break;
} }
if (i == max)
{ // Nothing to strip.
return;
}
if (Data()->RefCount <= 1) if (Data()->RefCount <= 1)
{ {
Chars[i+1] = '\0'; Chars[i+1] = '\0';
@ -668,11 +727,15 @@ void FString::StripRight (const char *charset)
{ {
size_t max = Len(), i; size_t max = Len(), i;
if (max == 0) return; if (max == 0) return;
for (i = max; i-- > 0; ) for (i = --max; i-- > 0; )
{ {
if (!strchr (charset, Chars[i])) if (!strchr (charset, Chars[i]))
break; break;
} }
if (i == max)
{ // Nothing to strip.
return;
}
if (Data()->RefCount <= 1) if (Data()->RefCount <= 1)
{ {
Chars[i+1] = '\0'; Chars[i+1] = '\0';
@ -701,6 +764,10 @@ void FString::StripLeftRight ()
if (!isspace(Chars[j])) if (!isspace(Chars[j]))
break; break;
} }
if (i == 0 && j == max - 1)
{ // Nothing to strip.
return;
}
if (Data()->RefCount <= 1) if (Data()->RefCount <= 1)
{ {
for (k = 0; i <= j; ++i, ++k) for (k = 0; i <= j; ++i, ++k)
@ -713,8 +780,8 @@ void FString::StripLeftRight ()
else else
{ {
FStringData *old = Data(); FStringData *old = Data();
AllocBuffer (j - i); AllocBuffer(j - i + 1);
StrCopy (Chars, old->Chars(), j - i); StrCopy(Chars, old->Chars(), j - i + 1);
old->Release(); old->Release();
} }
} }
@ -768,25 +835,28 @@ void FString::Insert (size_t index, const char *instr)
void FString::Insert (size_t index, const char *instr, size_t instrlen) void FString::Insert (size_t index, const char *instr, size_t instrlen)
{ {
size_t mylen = Len(); if (instrlen > 0)
if (index > mylen)
{ {
index = mylen; size_t mylen = Len();
} if (index >= mylen)
if (Data()->RefCount <= 1) {
{ AppendCStrPart(instr, instrlen);
ReallocBuffer (mylen + instrlen); }
memmove (Chars + index + instrlen, Chars + index, (mylen - index + 1)*sizeof(char)); else if (Data()->RefCount <= 1)
memcpy (Chars + index, instr, instrlen*sizeof(char)); {
} ReallocBuffer(mylen + instrlen);
else memmove(Chars + index + instrlen, Chars + index, (mylen - index + 1) * sizeof(char));
{ memcpy(Chars + index, instr, instrlen * sizeof(char));
FStringData *old = Data(); }
AllocBuffer (mylen + instrlen); else
StrCopy (Chars, old->Chars(), index); {
StrCopy (Chars + index, instr, instrlen); FStringData *old = Data();
StrCopy (Chars + index + instrlen, old->Chars() + index, mylen - index); AllocBuffer(mylen + instrlen);
old->Release(); StrCopy(Chars, old->Chars(), index);
StrCopy(Chars + index, instr, instrlen);
StrCopy(Chars + index + instrlen, old->Chars() + index, mylen - index);
old->Release();
}
} }
} }

View file

@ -268,6 +268,7 @@ public:
bool IsNotEmpty() const { return Len() != 0; } bool IsNotEmpty() const { return Len() != 0; }
void Truncate (long newlen); void Truncate (long newlen);
void Remove(size_t index, size_t remlen);
int Compare (const FString &other) const { return strcmp (Chars, other.Chars); } int Compare (const FString &other) const { return strcmp (Chars, other.Chars); }
int Compare (const char *other) const { return strcmp (Chars, other); } int Compare (const char *other) const { return strcmp (Chars, other); }

View file

@ -1784,6 +1784,7 @@ DSPLYMNU_WIPETYPE = "Screen wipe style";
DSPLYMNU_SHOWENDOOM = "Show ENDOOM screen"; DSPLYMNU_SHOWENDOOM = "Show ENDOOM screen";
DSPLYMNU_BLOODFADE = "Blood Flash Intensity"; DSPLYMNU_BLOODFADE = "Blood Flash Intensity";
DSPLYMNU_PICKUPFADE = "Pickup Flash Intensity"; DSPLYMNU_PICKUPFADE = "Pickup Flash Intensity";
DSPLYMNU_WATERFADE = "Underwater Blend Intensity";
DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used
DSPLYMNU_ATTACHEDSURFACES = "Use attached surfaces"; // Not used DSPLYMNU_ATTACHEDSURFACES = "Use attached surfaces"; // Not used
DSPLYMNU_SKYMODE = "Sky render mode"; DSPLYMNU_SKYMODE = "Sky render mode";

View file

@ -669,6 +669,7 @@ OptionMenu "VideoOptions"
Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn"
Slider "$DSPLYMNU_BLOODFADE", "blood_fade_scalar", 0.0, 1.0, 0.05, 2 Slider "$DSPLYMNU_BLOODFADE", "blood_fade_scalar", 0.0, 1.0, 0.05, 2
Slider "$DSPLYMNU_PICKUPFADE", "pickup_fade_scalar", 0.0, 1.0, 0.05, 2 Slider "$DSPLYMNU_PICKUPFADE", "pickup_fade_scalar", 0.0, 1.0, 0.05, 2
Slider "$DSPLYMNU_WATERFADE", "underwater_fade_scalar", 0.0, 1.0, 0.05, 2
Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods"
StaticText " " StaticText " "