mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- split the intermission background handling into its own class.
This means that 1/3 of wi_stuff can be left as-is when scriptifying the rest.
This commit is contained in:
parent
b2a1e03d7e
commit
89a43feb7a
1 changed files with 281 additions and 262 deletions
479
src/wi_stuff.cpp
479
src/wi_stuff.cpp
|
@ -59,6 +59,14 @@ CVAR(Bool, wi_showtotaltime, true, CVAR_ARCHIVE)
|
|||
CVAR(Bool, wi_noautostartmap, false, CVAR_USERINFO | CVAR_ARCHIVE)
|
||||
CVAR(Int, wi_autoadvance, 0, CVAR_SERVERINFO)
|
||||
|
||||
// States for the intermission
|
||||
enum EState
|
||||
{
|
||||
NoState = -1,
|
||||
StatCount,
|
||||
ShowNextLoc,
|
||||
LeavingIntermission
|
||||
};
|
||||
|
||||
static const char *WI_Cmd[] = {
|
||||
"Background",
|
||||
|
@ -83,67 +91,8 @@ static const char *WI_Cmd[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
|
||||
struct FPatchInfo
|
||||
struct FInterBackground
|
||||
{
|
||||
FFont *mFont;
|
||||
FTexture *mPatch;
|
||||
EColorRange mColor;
|
||||
|
||||
void Init(FGIFont &gifont)
|
||||
{
|
||||
if (gifont.color == NAME_Null)
|
||||
{
|
||||
mPatch = TexMan[gifont.fontname]; // "entering"
|
||||
mColor = mPatch == NULL ? CR_UNTRANSLATED : CR_UNDEFINED;
|
||||
mFont = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
mFont = V_GetFont(gifont.fontname);
|
||||
mColor = V_FindFontColor(gifont.color);
|
||||
mPatch = NULL;
|
||||
}
|
||||
if (mFont == NULL)
|
||||
{
|
||||
mFont = BigFont;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class FIntermissionScreen
|
||||
{
|
||||
public:
|
||||
// States for the intermission
|
||||
enum EState
|
||||
{
|
||||
NoState = -1,
|
||||
StatCount,
|
||||
ShowNextLoc,
|
||||
LeavingIntermission
|
||||
};
|
||||
|
||||
|
||||
enum EValues
|
||||
{
|
||||
// GLOBAL LOCATIONS
|
||||
WI_TITLEY = 2,
|
||||
|
||||
// SINGPLE-PLAYER STUFF
|
||||
SP_STATSX = 50,
|
||||
SP_STATSY = 50,
|
||||
|
||||
SP_TIMEX = 8,
|
||||
SP_TIMEY = (200 - 32),
|
||||
|
||||
// NET GAME STUFF
|
||||
NG_STATSY = 50,
|
||||
};
|
||||
|
||||
|
||||
|
||||
// These animation variables, structures, etc. are used for the
|
||||
// DOOM/Ultimate DOOM intermission screen animations. This is
|
||||
// totally different from any sprite or texture/flat animations
|
||||
|
@ -167,18 +116,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
// States for single-player
|
||||
enum ESPState
|
||||
{
|
||||
SP_KILLS = 0,
|
||||
SP_ITEMS = 2,
|
||||
SP_SECRET = 4,
|
||||
SP_FRAGS = 6,
|
||||
SP_TIME = 8,
|
||||
};
|
||||
|
||||
static const int SHOWNEXTLOCDELAY = 4; // in seconds
|
||||
|
||||
struct yahpt_t
|
||||
{
|
||||
int x, y;
|
||||
|
@ -188,16 +125,9 @@ public:
|
|||
{
|
||||
int x; // x/y coordinate pair structure
|
||||
int y;
|
||||
char level[9];
|
||||
FString Level;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Animation.
|
||||
// There is another anim_t used in p_spec.
|
||||
// (which is why I have renamed this one!)
|
||||
//
|
||||
|
||||
struct in_anim_t
|
||||
{
|
||||
int type; // Made an int so I can use '|'
|
||||
|
@ -223,71 +153,21 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
private:
|
||||
TArray<lnode_t> lnodes;
|
||||
TArray<in_anim_t> anims;
|
||||
|
||||
int acceleratestage; // used to accelerate or skip a stage
|
||||
bool playerready[MAXPLAYERS];
|
||||
int me; // wbs->pnum
|
||||
EState state; // specifies current state
|
||||
wbstartstruct_t *wbs; // contains information passed into intermission
|
||||
wbplayerstruct_t* Plrs[MAXPLAYERS]; // wbs->plyr[]
|
||||
int cnt; // used for general timing
|
||||
int bcnt; // used for timing of background animation
|
||||
int cnt_kills[MAXPLAYERS];
|
||||
int cnt_items[MAXPLAYERS];
|
||||
int cnt_secret[MAXPLAYERS];
|
||||
int cnt_frags[MAXPLAYERS];
|
||||
int cnt_deaths[MAXPLAYERS];
|
||||
int cnt_time;
|
||||
int cnt_total_time;
|
||||
int cnt_par;
|
||||
int cnt_pause;
|
||||
int total_frags;
|
||||
int total_deaths;
|
||||
bool noautostartmap;
|
||||
int dofrags;
|
||||
int ng_state;
|
||||
|
||||
//
|
||||
// GRAPHICS
|
||||
//
|
||||
|
||||
FPatchInfo mapname;
|
||||
FPatchInfo finished;
|
||||
FPatchInfo entering;
|
||||
|
||||
int bcnt = 0; // used for timing of background animation
|
||||
TArray<FTexture *> yah; // You Are Here graphic
|
||||
FTexture* splat; // splat
|
||||
FTexture* sp_secret; // "secret"
|
||||
FTexture* kills; // "Kills", "Scrt", "Items", "Frags"
|
||||
FTexture* secret;
|
||||
FTexture* items;
|
||||
FTexture* frags;
|
||||
FTexture* timepic; // Time sucks.
|
||||
FTexture* par;
|
||||
FTexture* sucks;
|
||||
FTexture* killers; // "killers", "victims"
|
||||
FTexture* victims;
|
||||
FTexture* total; // "Total", your face, your dead face
|
||||
FTexture* p; // Player graphic
|
||||
FTexture* lnames[2]; // Name graphics of each level (centered)
|
||||
|
||||
// [RH] Info to dynamically generate the level name graphics
|
||||
FString lnametexts[2];
|
||||
|
||||
FTexture *background;
|
||||
|
||||
bool snl_pointeron = false;
|
||||
|
||||
int player_deaths[MAXPLAYERS];
|
||||
int sp_state;
|
||||
|
||||
//
|
||||
// CODE
|
||||
//
|
||||
FTexture* splat = nullptr; // splat
|
||||
FTexture *background = nullptr;
|
||||
wbstartstruct_t *wbs;
|
||||
public:
|
||||
|
||||
FInterBackground(wbstartstruct_t *wbst)
|
||||
{
|
||||
wbs = wbst;
|
||||
|
||||
};
|
||||
//====================================================================
|
||||
//
|
||||
// Loads the background - either from a single texture
|
||||
|
@ -297,20 +177,21 @@ public:
|
|||
// MAPINFO.
|
||||
//
|
||||
//====================================================================
|
||||
static bool IsExMy(const char * name)
|
||||
bool IsExMy(const char * name)
|
||||
{
|
||||
// Only check for the first 3 episodes. They are the only ones with default intermission scripts.
|
||||
// Level names can be upper- and lower case so use tolower to check!
|
||||
return (tolower(name[0]) == 'e' && name[1] >= '1' && name[1] <= '3' && tolower(name[2]) == 'm');
|
||||
}
|
||||
|
||||
void WI_LoadBackground(bool isenterpic)
|
||||
bool LoadBackground(bool isenterpic)
|
||||
{
|
||||
const char *lumpname = NULL;
|
||||
char buffer[10];
|
||||
in_anim_t an;
|
||||
lnode_t pt;
|
||||
FTextureID texture;
|
||||
bool noautostartmap = false;
|
||||
|
||||
bcnt = 0;
|
||||
|
||||
|
@ -350,16 +231,16 @@ public:
|
|||
// If going from E1-E3 to E4 the default should be used, not the exit pic.
|
||||
|
||||
// Not if the exit pic is user defined!
|
||||
if (level.info->ExitPic.IsNotEmpty()) return;
|
||||
if (level.info->ExitPic.IsNotEmpty()) return false;
|
||||
|
||||
// E1-E3 need special treatment when playing Doom 1.
|
||||
if (!(gameinfo.flags & GI_MAPxx))
|
||||
{
|
||||
// not if the last level is not from the first 3 episodes
|
||||
if (!IsExMy(wbs->current)) return;
|
||||
if (!IsExMy(wbs->current)) return false;
|
||||
|
||||
// not if the next level is one of the first 3 episodes
|
||||
if (IsExMy(wbs->next)) return;
|
||||
if (IsExMy(wbs->next)) return false;
|
||||
}
|
||||
}
|
||||
lumpname = "INTERPIC";
|
||||
|
@ -377,20 +258,20 @@ public:
|
|||
}
|
||||
if (!lumpname)
|
||||
{
|
||||
if (isenterpic) return;
|
||||
if (isenterpic) return false;
|
||||
lumpname = "FLOOR16";
|
||||
}
|
||||
break;
|
||||
|
||||
case GAME_Hexen:
|
||||
if (isenterpic) return;
|
||||
if (isenterpic) return false;
|
||||
lumpname = "INTERPIC";
|
||||
break;
|
||||
|
||||
case GAME_Strife:
|
||||
default:
|
||||
// Strife doesn't have an intermission pic so choose something neutral.
|
||||
if (isenterpic) return;
|
||||
if (isenterpic) return false;
|
||||
lumpname = gameinfo.BorderFlat;
|
||||
break;
|
||||
}
|
||||
|
@ -399,7 +280,7 @@ public:
|
|||
{
|
||||
// shouldn't happen!
|
||||
background = NULL;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
lnodes.Clear();
|
||||
|
@ -448,8 +329,7 @@ public:
|
|||
while (!sc.CheckString("}"))
|
||||
{
|
||||
sc.MustGetString();
|
||||
strncpy(pt.level, sc.String,8);
|
||||
pt.level[8] = 0;
|
||||
pt.Level = sc.String;
|
||||
sc.MustGetNumber();
|
||||
pt.x = sc.Number;
|
||||
sc.MustGetNumber();
|
||||
|
@ -569,6 +449,7 @@ public:
|
|||
}
|
||||
}
|
||||
background = TexMan[texture];
|
||||
return noautostartmap;
|
||||
}
|
||||
|
||||
//====================================================================
|
||||
|
@ -578,10 +459,11 @@ public:
|
|||
//
|
||||
//====================================================================
|
||||
|
||||
void WI_updateAnimatedBack()
|
||||
void updateAnimatedBack()
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
bcnt++;
|
||||
for (i = 0; i<anims.Size(); i++)
|
||||
{
|
||||
in_anim_t * a = &anims[i];
|
||||
|
@ -613,7 +495,7 @@ public:
|
|||
//
|
||||
//====================================================================
|
||||
|
||||
void WI_drawBackground()
|
||||
void drawBackground(int state, bool drawsplat, bool snl_pointeron)
|
||||
{
|
||||
unsigned int i;
|
||||
double animwidth = 320; // For a flat fill or clear background scale animations to 320x200
|
||||
|
@ -688,7 +570,211 @@ public:
|
|||
screen->DrawTexture(a->frames[a->ctr], a->loc.x, a->loc.y,
|
||||
DTA_VirtualWidthF, animwidth, DTA_VirtualHeightF, animheight, TAG_DONE);
|
||||
}
|
||||
|
||||
if (drawsplat)
|
||||
{
|
||||
for (i = 0; i<lnodes.Size(); i++)
|
||||
{
|
||||
level_info_t * li = FindLevelInfo(lnodes[i].Level);
|
||||
if (li && li->flags & LEVEL_VISITED) drawOnLnode(i, &splat, 1); // draw a splat on taken cities.
|
||||
}
|
||||
}
|
||||
|
||||
// draw flashing ptr
|
||||
if (snl_pointeron && yah.Size())
|
||||
{
|
||||
unsigned int v = MapToIndex(wbs->next);
|
||||
// Draw only if it points to a valid level on the current screen!
|
||||
if (v<lnodes.Size()) drawOnLnode(v, &yah[0], yah.Size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
//====================================================================
|
||||
//
|
||||
// Draws the splats and the 'You are here' arrows
|
||||
//
|
||||
//====================================================================
|
||||
|
||||
int MapToIndex(const char *map)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < lnodes.Size(); i++)
|
||||
{
|
||||
if (!lnodes[i].Level.CompareNoCase(map))
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
//====================================================================
|
||||
//
|
||||
// Draws the splats and the 'You are here' arrows
|
||||
//
|
||||
//====================================================================
|
||||
|
||||
void drawOnLnode(int n, FTexture * c[], int numc)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i<numc; i++)
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
|
||||
|
||||
right = c[i]->GetScaledWidth();
|
||||
bottom = c[i]->GetScaledHeight();
|
||||
left = lnodes[n].x - c[i]->GetScaledLeftOffset();
|
||||
top = lnodes[n].y - c[i]->GetScaledTopOffset();
|
||||
right += left;
|
||||
bottom += top;
|
||||
|
||||
if (left >= 0 && right < 320 && top >= 0 && bottom < 200)
|
||||
{
|
||||
screen->DrawTexture(c[i], lnodes[n].x, lnodes[n].y, DTA_320x200, true, TAG_DONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
struct FPatchInfo
|
||||
{
|
||||
FFont *mFont;
|
||||
FTexture *mPatch;
|
||||
EColorRange mColor;
|
||||
|
||||
void Init(FGIFont &gifont)
|
||||
{
|
||||
if (gifont.color == NAME_Null)
|
||||
{
|
||||
mPatch = TexMan[gifont.fontname]; // "entering"
|
||||
mColor = mPatch == NULL ? CR_UNTRANSLATED : CR_UNDEFINED;
|
||||
mFont = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
mFont = V_GetFont(gifont.fontname);
|
||||
mColor = V_FindFontColor(gifont.color);
|
||||
mPatch = NULL;
|
||||
}
|
||||
if (mFont == NULL)
|
||||
{
|
||||
mFont = BigFont;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class FIntermissionScreen
|
||||
{
|
||||
public:
|
||||
|
||||
enum EValues
|
||||
{
|
||||
// GLOBAL LOCATIONS
|
||||
WI_TITLEY = 2,
|
||||
|
||||
// SINGPLE-PLAYER STUFF
|
||||
SP_STATSX = 50,
|
||||
SP_STATSY = 50,
|
||||
|
||||
SP_TIMEX = 8,
|
||||
SP_TIMEY = (200 - 32),
|
||||
|
||||
// NET GAME STUFF
|
||||
NG_STATSY = 50,
|
||||
};
|
||||
|
||||
|
||||
|
||||
// States for single-player
|
||||
enum ESPState
|
||||
{
|
||||
SP_KILLS = 0,
|
||||
SP_ITEMS = 2,
|
||||
SP_SECRET = 4,
|
||||
SP_FRAGS = 6,
|
||||
SP_TIME = 8,
|
||||
};
|
||||
|
||||
static const int SHOWNEXTLOCDELAY = 4; // in seconds
|
||||
|
||||
//
|
||||
// Animation.
|
||||
// There is another anim_t used in p_spec.
|
||||
// (which is why I have renamed this one!)
|
||||
//
|
||||
|
||||
|
||||
FInterBackground *bg;
|
||||
int acceleratestage; // used to accelerate or skip a stage
|
||||
bool playerready[MAXPLAYERS];
|
||||
int me; // wbs->pnum
|
||||
int bcnt;
|
||||
EState state; // specifies current state
|
||||
wbstartstruct_t *wbs; // contains information passed into intermission
|
||||
wbplayerstruct_t* Plrs[MAXPLAYERS]; // wbs->plyr[]
|
||||
int cnt; // used for general timing
|
||||
int cnt_kills[MAXPLAYERS];
|
||||
int cnt_items[MAXPLAYERS];
|
||||
int cnt_secret[MAXPLAYERS];
|
||||
int cnt_frags[MAXPLAYERS];
|
||||
int cnt_deaths[MAXPLAYERS];
|
||||
int cnt_time;
|
||||
int cnt_total_time;
|
||||
int cnt_par;
|
||||
int cnt_pause;
|
||||
int total_frags;
|
||||
int total_deaths;
|
||||
bool noautostartmap;
|
||||
int dofrags;
|
||||
int ng_state;
|
||||
|
||||
//
|
||||
// GRAPHICS
|
||||
//
|
||||
|
||||
FPatchInfo mapname;
|
||||
FPatchInfo finished;
|
||||
FPatchInfo entering;
|
||||
|
||||
FTexture* sp_secret; // "secret"
|
||||
FTexture* kills; // "Kills", "Scrt", "Items", "Frags"
|
||||
FTexture* secret;
|
||||
FTexture* items;
|
||||
FTexture* frags;
|
||||
FTexture* timepic; // Time sucks.
|
||||
FTexture* par;
|
||||
FTexture* sucks;
|
||||
FTexture* killers; // "killers", "victims"
|
||||
FTexture* victims;
|
||||
FTexture* total; // "Total", your face, your dead face
|
||||
FTexture* p; // Player graphic
|
||||
FTexture* lnames[2]; // Name graphics of each level (centered)
|
||||
|
||||
// [RH] Info to dynamically generate the level name graphics
|
||||
FString lnametexts[2];
|
||||
|
||||
|
||||
bool snl_pointeron = false;
|
||||
|
||||
int player_deaths[MAXPLAYERS];
|
||||
int sp_state;
|
||||
|
||||
//
|
||||
// CODE
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
//====================================================================
|
||||
|
@ -870,57 +956,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
//====================================================================
|
||||
//
|
||||
// Draws the splats and the 'You are here' arrows
|
||||
//
|
||||
//====================================================================
|
||||
|
||||
int WI_MapToIndex (const char *map)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < lnodes.Size(); i++)
|
||||
{
|
||||
if (!strnicmp (lnodes[i].level, map, 8))
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
//====================================================================
|
||||
//
|
||||
// Draws the splats and the 'You are here' arrows
|
||||
//
|
||||
//====================================================================
|
||||
|
||||
void WI_drawOnLnode( int n, FTexture * c[] ,int numc)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<numc;i++)
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
|
||||
|
||||
right = c[i]->GetScaledWidth();
|
||||
bottom = c[i]->GetScaledHeight();
|
||||
left = lnodes[n].x - c[i]->GetScaledLeftOffset();
|
||||
top = lnodes[n].y - c[i]->GetScaledTopOffset();
|
||||
right += left;
|
||||
bottom += top;
|
||||
|
||||
if (left >= 0 && right < 320 && top >= 0 && bottom < 200)
|
||||
{
|
||||
screen->DrawTexture (c[i], lnodes[n].x, lnodes[n].y, DTA_320x200, true, TAG_DONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//====================================================================
|
||||
//
|
||||
// Draws a number.
|
||||
|
@ -1133,7 +1168,7 @@ public:
|
|||
state = ShowNextLoc;
|
||||
acceleratestage = 0;
|
||||
cnt = SHOWNEXTLOCDELAY * TICRATE;
|
||||
WI_LoadBackground(true);
|
||||
bg->LoadBackground(true);
|
||||
}
|
||||
|
||||
void WI_updateShowNextLoc ()
|
||||
|
@ -1146,26 +1181,7 @@ public:
|
|||
|
||||
void WI_drawShowNextLoc(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
WI_drawBackground();
|
||||
|
||||
if (splat)
|
||||
{
|
||||
for (i=0 ; i<lnodes.Size() ; i++)
|
||||
{
|
||||
level_info_t * li = FindLevelInfo (lnodes[i].level);
|
||||
if (li && li->flags & LEVEL_VISITED) WI_drawOnLnode(i, &splat,1); // draw a splat on taken cities.
|
||||
}
|
||||
}
|
||||
|
||||
// draw flashing ptr
|
||||
if (snl_pointeron && yah.Size())
|
||||
{
|
||||
unsigned int v = WI_MapToIndex (wbs->next);
|
||||
// Draw only if it points to a valid level on the current screen!
|
||||
if (v<lnodes.Size()) WI_drawOnLnode (v, &yah[0], yah.Size());
|
||||
}
|
||||
bg->drawBackground(state, true, snl_pointeron);
|
||||
|
||||
// draws which level you are entering..
|
||||
WI_drawEL ();
|
||||
|
@ -1344,7 +1360,7 @@ public:
|
|||
player_t *sortedplayers[MAXPLAYERS];
|
||||
|
||||
// draw animated background
|
||||
WI_drawBackground();
|
||||
bg->drawBackground(state, false, false);
|
||||
|
||||
y = WI_drawLF();
|
||||
|
||||
|
@ -1648,7 +1664,7 @@ public:
|
|||
FTexture *readyico = TexMan.FindTexture("READYICO");
|
||||
|
||||
// draw animated background
|
||||
WI_drawBackground();
|
||||
bg->drawBackground(state, false, false);
|
||||
|
||||
y = WI_drawLF();
|
||||
|
||||
|
@ -1898,7 +1914,7 @@ public:
|
|||
lh = IntermissionFont->GetHeight() * 3 / 2;
|
||||
|
||||
// draw animated background
|
||||
WI_drawBackground();
|
||||
bg->drawBackground(state, false, false);
|
||||
|
||||
WI_drawLF();
|
||||
|
||||
|
@ -2089,12 +2105,15 @@ public:
|
|||
if (li) lnametexts[1] = li->LookupLevelName();
|
||||
else lnametexts[1] = "";
|
||||
|
||||
WI_LoadBackground(false);
|
||||
bg = new FInterBackground(wbs);
|
||||
noautostartmap = bg->LoadBackground(false);
|
||||
}
|
||||
|
||||
void WI_unloadData ()
|
||||
{
|
||||
// [RH] The texture data gets unloaded at pre-map time, so there's nothing to do here
|
||||
if (bg != nullptr) delete bg;
|
||||
bg = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2155,7 +2174,7 @@ static FIntermissionScreen WI_Screen;
|
|||
|
||||
void WI_Ticker()
|
||||
{
|
||||
WI_Screen.WI_updateAnimatedBack();
|
||||
WI_Screen.bg->updateAnimatedBack();
|
||||
WI_Screen.WI_Ticker();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue