- expanded names for view border elements. Also fixed the horribly bad implementation of custom borders which modified the DoomBorder elements without ever checking the game being used.

This commit is contained in:
Christoph Oelckers 2014-05-13 13:40:02 +02:00
parent a05e62f3f7
commit a22670626c
4 changed files with 57 additions and 31 deletions

View File

@ -1090,14 +1090,14 @@ void DBaseStatusBar::RefreshBackground () const
if (setblocks >= 10)
{
const gameborder_t *border = gameinfo.border;
FTexture *p;
p = TexMan[border->b];
FTexture *p = TexMan[gameinfo.Border.b];
if (p != NULL)
{
screen->FlatFill(0, y, x, y + p->GetHeight(), p, true);
screen->FlatFill(x2, y, SCREENWIDTH, y + p->GetHeight(), p, true);
}
}
}
}
//---------------------------------------------------------------------------

View File

@ -51,7 +51,7 @@ const char *GameNames[17] =
};
static gameborder_t DoomBorder =
static staticgameborder_t DoomBorder =
{
8, 8,
"brdr_tl", "brdr_t", "brdr_tr",
@ -59,7 +59,7 @@ static gameborder_t DoomBorder =
"brdr_bl", "brdr_b", "brdr_br"
};
static gameborder_t HereticBorder =
static staticgameborder_t HereticBorder =
{
4, 16,
"bordtl", "bordt", "bordtr",
@ -67,7 +67,7 @@ static gameborder_t HereticBorder =
"bordbl", "bordb", "bordbr"
};
static gameborder_t StrifeBorder =
static staticgameborder_t StrifeBorder =
{
8, 8,
"brdr_tl", "brdr_t", "brdr_tr",
@ -231,40 +231,37 @@ void FMapInfoParser::ParseGameInfo()
}
else if(nextKey.CompareNoCase("border") == 0)
{
if(sc.CheckToken(TK_Identifier))
staticgameborder_t *b;
if (sc.CheckToken(TK_Identifier))
{
switch(sc.MustMatchString(GameInfoBorders))
{
default:
gameinfo.border = &DoomBorder;
b = &DoomBorder;
break;
case 1:
gameinfo.border = &HereticBorder;
b = &HereticBorder;
break;
case 2:
gameinfo.border = &StrifeBorder;
b = &StrifeBorder;
break;
}
gameinfo.Border = *b;
}
else
{
// border = {size, offset, tr, t, tl, r, l ,br, b, bl};
char *graphics[8] = {DoomBorder.tr, DoomBorder.t, DoomBorder.tl, DoomBorder.r, DoomBorder.l, DoomBorder.br, DoomBorder.b, DoomBorder.bl};
FString *graphics[8] = { &gameinfo.Border.tr, &gameinfo.Border.t, &gameinfo.Border.tl, &gameinfo.Border.r, &gameinfo.Border.l, &gameinfo.Border.br, &gameinfo.Border.b, &gameinfo.Border.bl };
sc.MustGetToken(TK_IntConst);
DoomBorder.offset = sc.Number;
gameinfo.Border.offset = sc.Number;
sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst);
DoomBorder.size = sc.Number;
gameinfo.Border.size = sc.Number;
for(int i = 0;i < 8;i++)
{
sc.MustGetToken(',');
sc.MustGetToken(TK_StringConst);
int len = int(strlen(sc.String));
if(len > 8)
sc.ScriptError("Border graphic can not be more than 8 characters long.\n");
memcpy(graphics[i], sc.String, len);
if(len < 8) // end with a null byte if the string is less than 8 chars.
graphics[i][len] = 0;
(*graphics[i]) = sc.String;
}
}
}

View File

@ -52,7 +52,7 @@
extern const char *GameNames[17];
struct gameborder_t
struct staticgameborder_t
{
BYTE offset;
BYTE size;
@ -66,6 +66,35 @@ struct gameborder_t
char br[8];
};
struct gameborder_t
{
BYTE offset;
BYTE size;
FString tl;
FString t;
FString tr;
FString l;
FString r;
FString bl;
FString b;
FString br;
gameborder_t &operator=(staticgameborder_t &other)
{
offset = other.offset;
size = other.size;
tl = other.tl;
t = other.t;
tr = other.tr;
l = other.l;
r = other.r;
bl = other.bl;
b = other.b;
br = other.br;
return *this;
}
};
struct FGIFont
{
FName fontname;
@ -107,7 +136,7 @@ struct gameinfo_t
FString Endoom;
fixed_t Armor2Percent;
FString quitSound;
gameborder_t *border;
gameborder_t Border;
int telefogheight;
int defKickback;
FString translator;

View File

@ -1407,7 +1407,7 @@ void V_SetBorderNeedRefresh()
void V_DrawFrame (int left, int top, int width, int height)
{
FTexture *p;
const gameborder_t *border = gameinfo.border;
const gameborder_t *border = &gameinfo.Border;
// Sanity check for incomplete gameinfo
if (border == NULL)
return;
@ -1513,28 +1513,28 @@ static void V_DrawTopBorder ()
if (viewwidth == SCREENWIDTH)
return;
offset = gameinfo.border->offset;
offset = gameinfo.Border.offset;
if (viewwindowy < 34)
{
V_DrawBorder (0, 0, viewwindowx, 34);
V_DrawBorder (viewwindowx, 0, viewwindowx + viewwidth, viewwindowy);
V_DrawBorder (viewwindowx + viewwidth, 0, SCREENWIDTH, 34);
p = TexMan(gameinfo.border->t);
p = TexMan(gameinfo.Border.t);
screen->FlatFill(viewwindowx, viewwindowy - p->GetHeight(),
viewwindowx + viewwidth, viewwindowy, p, true);
p = TexMan(gameinfo.border->l);
p = TexMan(gameinfo.Border.l);
screen->FlatFill(viewwindowx - p->GetWidth(), viewwindowy,
viewwindowx, 35, p, true);
p = TexMan(gameinfo.border->r);
p = TexMan(gameinfo.Border.r);
screen->FlatFill(viewwindowx + viewwidth, viewwindowy,
viewwindowx + viewwidth + p->GetWidth(), 35, p, true);
p = TexMan(gameinfo.border->tl);
p = TexMan(gameinfo.Border.tl);
screen->DrawTexture (p, viewwindowx - offset, viewwindowy - offset, TAG_DONE);
p = TexMan(gameinfo.border->tr);
p = TexMan(gameinfo.Border.tr);
screen->DrawTexture (p, viewwindowx + viewwidth, viewwindowy - offset, TAG_DONE);
}
else