- 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) if (setblocks >= 10)
{ {
const gameborder_t *border = gameinfo.border; FTexture *p = TexMan[gameinfo.Border.b];
FTexture *p; if (p != NULL)
{
p = TexMan[border->b];
screen->FlatFill(0, y, x, y + p->GetHeight(), p, true); screen->FlatFill(0, y, x, y + p->GetHeight(), p, true);
screen->FlatFill(x2, y, SCREENWIDTH, 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, 8, 8,
"brdr_tl", "brdr_t", "brdr_tr", "brdr_tl", "brdr_t", "brdr_tr",
@ -59,7 +59,7 @@ static gameborder_t DoomBorder =
"brdr_bl", "brdr_b", "brdr_br" "brdr_bl", "brdr_b", "brdr_br"
}; };
static gameborder_t HereticBorder = static staticgameborder_t HereticBorder =
{ {
4, 16, 4, 16,
"bordtl", "bordt", "bordtr", "bordtl", "bordt", "bordtr",
@ -67,7 +67,7 @@ static gameborder_t HereticBorder =
"bordbl", "bordb", "bordbr" "bordbl", "bordb", "bordbr"
}; };
static gameborder_t StrifeBorder = static staticgameborder_t StrifeBorder =
{ {
8, 8, 8, 8,
"brdr_tl", "brdr_t", "brdr_tr", "brdr_tl", "brdr_t", "brdr_tr",
@ -231,40 +231,37 @@ void FMapInfoParser::ParseGameInfo()
} }
else if(nextKey.CompareNoCase("border") == 0) else if(nextKey.CompareNoCase("border") == 0)
{ {
if(sc.CheckToken(TK_Identifier)) staticgameborder_t *b;
if (sc.CheckToken(TK_Identifier))
{ {
switch(sc.MustMatchString(GameInfoBorders)) switch(sc.MustMatchString(GameInfoBorders))
{ {
default: default:
gameinfo.border = &DoomBorder; b = &DoomBorder;
break; break;
case 1: case 1:
gameinfo.border = &HereticBorder; b = &HereticBorder;
break; break;
case 2: case 2:
gameinfo.border = &StrifeBorder; b = &StrifeBorder;
break; break;
} }
gameinfo.Border = *b;
} }
else else
{ {
// border = {size, offset, tr, t, tl, r, l ,br, b, bl}; // 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); sc.MustGetToken(TK_IntConst);
DoomBorder.offset = sc.Number; gameinfo.Border.offset = sc.Number;
sc.MustGetToken(','); sc.MustGetToken(',');
sc.MustGetToken(TK_IntConst); sc.MustGetToken(TK_IntConst);
DoomBorder.size = sc.Number; gameinfo.Border.size = sc.Number;
for(int i = 0;i < 8;i++) for(int i = 0;i < 8;i++)
{ {
sc.MustGetToken(','); sc.MustGetToken(',');
sc.MustGetToken(TK_StringConst); sc.MustGetToken(TK_StringConst);
int len = int(strlen(sc.String)); (*graphics[i]) = 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;
} }
} }
} }

View file

@ -52,7 +52,7 @@
extern const char *GameNames[17]; extern const char *GameNames[17];
struct gameborder_t struct staticgameborder_t
{ {
BYTE offset; BYTE offset;
BYTE size; BYTE size;
@ -66,6 +66,35 @@ struct gameborder_t
char br[8]; 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 struct FGIFont
{ {
FName fontname; FName fontname;
@ -107,7 +136,7 @@ struct gameinfo_t
FString Endoom; FString Endoom;
fixed_t Armor2Percent; fixed_t Armor2Percent;
FString quitSound; FString quitSound;
gameborder_t *border; gameborder_t Border;
int telefogheight; int telefogheight;
int defKickback; int defKickback;
FString translator; FString translator;

View file

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