- use global variables to track automap state

So far implemented in Duke/RR.
This commit is contained in:
Christoph Oelckers 2020-08-24 19:31:43 +02:00
parent 89a15335df
commit 7859a29e95
17 changed files with 55 additions and 51 deletions

View File

@ -991,7 +991,6 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize)
return { top, 25 };
}
::GameInterface* CreateInterface()
{
return new GameInterface;

View File

@ -126,7 +126,7 @@ struct GameInterface : ::GameInterface
FString GetCoordString() override;
void clearlocalinputstate() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override;
GameStats getStats() override;
};

View File

@ -210,7 +210,7 @@ void ctrlGetInput(void)
hud_scale = hud_scale - 4;
}
}
if (gViewMode == 2 || gViewMode == 4)
if (gViewMode == 4)
{
gZoom = ClipLow(gZoom - (gZoom >> 4), 64);
gViewMap.nZoom = gZoom;
@ -231,7 +231,8 @@ void ctrlGetInput(void)
hud_scale = hud_scale + 4;
}
}
if (gViewMode == 2 || gViewMode == 4)
if (
gViewMode == 4)
{
gZoom = ClipHigh(gZoom + (gZoom >> 4), 4096);
gViewMap.nZoom = gZoom;

View File

@ -94,7 +94,6 @@ static uint32_t conshade;
static bool conline;
extern int gametic;
extern bool automapactive; // in AM_map.c
extern bool advancedemo;
extern FBaseCVar *CVars;

View File

@ -100,6 +100,17 @@ static ClockTicks lastototalclk;
static uint64_t elapsedTime;
static uint64_t lastTime;
int automapMode;
bool automapFollow;
CCMD(togglemap)
{
automapMode++;
if (automapMode == am_count) automapMode = am_off;
if ((g_gameType & GAMEFLAG_BLOOD) && automapMode == am_overlay) automapMode = am_full; // todo: investigate if this can be re-enabled
}
glcycle_t thinktime, actortime, gameupdatetime, drawtime;
gamestate_t gamestate = GS_STARTUP;

View File

@ -210,3 +210,18 @@ void updatePauseStatus();
void updatePauseStatus(bool state, bool multiplayer);
extern int paused;
extern int chatmodeon;
enum AM_Mode
{
am_off,
am_overlay,
am_full,
am_count
};
extern int automapMode;
extern bool automapFollow;
inline bool automapControlsActive()
{
return automapMode != am_off;
}

View File

@ -63,7 +63,6 @@ struct GameInterface
virtual void clearlocalinputstate() {}
virtual void UpdateScreenSize() {}
virtual void FreeGameData() {}
virtual bool automapActive() { return false; }
virtual void PlayHudSound() {}
virtual FString statFPS() { return "FPS display not available"; }
virtual GameStats getStats() { return {}; }

View File

@ -307,8 +307,8 @@ struct GameInterface : ::GameInterface
bool SaveGame(FSaveGameNode* sv) override;
bool CanSave() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override { return { 0, 24 }; }
void clearlocalinputstate();
void clearlocalinputstate() override;
FString statFPS() override;
::GameStats getStats() override;
};

View File

@ -414,7 +414,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
#if 0
for (TRAVERSE_CONNECT(p))
{
if (ud.scrollmode && p == screenpeek) continue;
if (automapFollow && p == screenpeek) continue;
auto const pPlayer = &ps[p];
auto const pSprite = (uspriteptr_t)&sprite[pPlayer->i];

View File

@ -277,6 +277,7 @@ enum EQuote
QUOTE_MIGHTY_FOOT = 80 ,
QUOTE_WEAPON_MODE_OFF = 82 ,
QUOTE_MAP_FOLLOW_OFF = 83 ,
QUOTE_MAP_FOLLOW_ON = 84 ,
QUOTE_RUN_MODE_OFF = 85 ,
QUOTE_JETPACK = 88 ,
QUOTE_SCUBA = 89 ,

View File

@ -39,7 +39,6 @@ struct GameInterface : public ::GameInterface
void clearlocalinputstate() override;
bool GenerateSavePic() override;
void PlayHudSound() override;
bool automapActive() override;
FString statFPS() override;
GameStats getStats() override;
void DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) override;
@ -58,7 +57,8 @@ struct GameInterface : public ::GameInterface
bool CheatAllowed(bool printmsg) override;
void ExitFromMenu() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override;
void DrawPlayerSprite(const DVector2& origin, bool onteam);
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
};
struct Dispatcher

View File

@ -282,7 +282,7 @@ void displayrest(double smoothratio)
if (ud.camerasprite == -1)
{
if (ud.overhead_on != 2)
if (automapMode != am_full)
{
if (!isRR() && pp->newowner >= 0)
cameratext(pp->newowner);
@ -296,11 +296,11 @@ void displayrest(double smoothratio)
moveclouds();
}
if (ud.overhead_on > 0)
if (automapMode != am_off)
{
dointerpolations(smoothratio);
if (ud.scrollmode == 0)
if (!automapFollow)
{
if (pp->newowner == -1 && playrunning())
{
@ -337,7 +337,7 @@ void displayrest(double smoothratio)
cang = ud.fola;
}
if (ud.overhead_on == 2)
if (automapMode == am_full)
{
twod->ClearScreen();
renderDrawMapView(cposx, cposy, pp->zoom, cang);
@ -352,7 +352,7 @@ void displayrest(double smoothratio)
if (isRR()) drawstatusbar_r(screenpeek);
else drawstatusbar_d(screenpeek);
if (ps[myconnectindex].newowner == -1 && ud.overhead_on == 0 && cl_crosshair && ud.camerasprite == -1)
if (ps[myconnectindex].newowner == -1 && automapMode == am_off && cl_crosshair && ud.camerasprite == -1)
{
int32_t a = TILE_CROSSHAIR;
@ -621,7 +621,7 @@ void drawoverheadmap(int cposx, int cposy, int czoom, int cang)
for (p = connecthead; p >= 0; p = connectpoint2[p])
{
if (ud.scrollmode && p == screenpeek) continue;
if (automapFollow && p == screenpeek) continue;
ox = sprite[ps[p].i].x - cposx;
oy = sprite[ps[p].i].y - cposy;
@ -734,11 +734,6 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize)
return { 0, sbar };
}
bool GameInterface::automapActive()
{
return ud.overhead_on != 0;
}
::GameInterface* CreateInterface()
{
return new GameInterface;

View File

@ -65,7 +65,7 @@ void nonsharedkeys(void)
if (System_WantGuiCapture())
return;
if (!ALT_IS_PRESSED && ud.overhead_on == 0)
if (!ALT_IS_PRESSED && automapMode == am_off)
{
if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
{
@ -117,17 +117,17 @@ void nonsharedkeys(void)
FTA(QUOTE_WEAPON_MODE_OFF - ud.showweapons, &ps[screenpeek]);
}
if (ud.overhead_on && buttonMap.ButtonDown(gamefunc_Map_Follow_Mode))
if (automapMode != am_off && buttonMap.ButtonDown(gamefunc_Map_Follow_Mode))
{
buttonMap.ClearButton(gamefunc_Map_Follow_Mode);
ud.scrollmode = 1 - ud.scrollmode;
if (ud.scrollmode)
automapFollow = !automapFollow;
if (automapFollow)
{
ud.folx = ps[screenpeek].oposx;
ud.foly = ps[screenpeek].oposy;
ud.fola = ps[screenpeek].getoang();
}
FTA(QUOTE_MAP_FOLLOW_OFF + ud.scrollmode, &ps[myconnectindex]);
FTA(automapFollow? QUOTE_MAP_FOLLOW_ON : QUOTE_MAP_FOLLOW_OFF, &ps[myconnectindex]);
}
// Fixme: This really should be done via CCMD, not via hard coded key checks - but that needs alternative Shift and Alt bindings.
@ -181,7 +181,7 @@ void nonsharedkeys(void)
}
}
if (ud.overhead_on != 0)
if (automapMode != am_off)
{
int j;
if (nonsharedtimer > 0 || totalclock < nonsharedtimer)
@ -203,22 +203,6 @@ void nonsharedkeys(void)
ps[myconnectindex].zoom = clamp(ps[myconnectindex].zoom, 48, 2048);
}
}
if (buttonMap.ButtonDown(gamefunc_Map))
{
buttonMap.ClearButton(gamefunc_Map);
if (ud.last_overhead != ud.overhead_on && ud.last_overhead)
{
ud.overhead_on = ud.last_overhead;
ud.last_overhead = 0;
}
else
{
ud.overhead_on++;
if (ud.overhead_on == 3) ud.overhead_on = 0;
ud.last_overhead = ud.overhead_on;
}
}
}
//---------------------------------------------------------------------------
@ -1152,9 +1136,9 @@ static void FinalizeInput(int playerNum, input_t& input, bool vehicle)
auto p = &ps[playerNum];
bool blocked = movementBlocked(playerNum) || sprite[p->i].extra <= 0 || (p->dead_flag && !ud.god);
if ((ud.scrollmode && ud.overhead_on) || blocked)
if ((automapFollow && automapMode != am_off) || blocked)
{
if (ud.scrollmode && ud.overhead_on)
if (automapFollow && automapMode != am_off)
{
ud.folfvel = input.fvel;
ud.folavel = fix16_to_int(input.q16avel);

View File

@ -472,7 +472,7 @@ void displayrooms(int snum, int smoothratio)
p = &ps[snum];
if (ud.overhead_on == 2 || p->cursectnum == -1)
if (automapMode == am_full || p->cursectnum == -1)
return;
// Do not light up the fog in RRRA's E2L1. Ideally this should apply to all foggy levels but all others use lookup table hacks for their fog.

View File

@ -179,7 +179,7 @@ PalEntry DDukeCommonStatusBar::LightForShade(int shade)
void DDukeCommonStatusBar::PrintLevelStats(int bottomy)
{
if (ud.overhead_on == 2)
if (automapMode == am_full)
{
// Automap label printer moved here so that it is on top of the screen border.
FString mapname;
@ -194,7 +194,7 @@ void DDukeCommonStatusBar::PrintLevelStats(int bottomy)
font = isNamWW2GI() ? ConFont : SmallFont;
if (isNamWW2GI()) color = CR_ORANGE;
}
int top = am_nameontop ? 0 : 200 - Scale(bottomy < 0 ? RelTop : bottomy, hud_scale, 100) - isRR()? 25 : 20;
int top = am_nameontop ? 0 : ( 200 - Scale(bottomy < 0 ? RelTop : bottomy, hud_scale, 100) - (isRR()? 25 : 20));
if (!(currentLevel->flags & MI_USERMAP))
DrawText(twod, font, color, 5, top + 6, GStrings.localize(gVolumeNames[volfromlevelnum(currentLevel->levelNumber)]),
DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE);

View File

@ -59,7 +59,7 @@ struct user_defs
unsigned char god, cashman, eog;
unsigned char show_help, scrollmode, clipping;
char user_name[MAXPLAYERS][32];
unsigned char overhead_on, last_overhead, showweapons;
unsigned char showweapons;
unsigned char user_pals[MAXPLAYERS];
short from_bonus;

View File

@ -2384,7 +2384,7 @@ struct GameInterface : ::GameInterface
ReservedSpace GetReservedScreenSpace(int viewsize) override;
void clearlocalinputstate() override;
void QuitToTitle() override;
FString statFPS() override;
GameStats getStats() override;
};