2020-08-22 20:40:22 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
#include "ns.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "sequence.h"
|
|
|
|
#include "names.h"
|
|
|
|
#include "player.h"
|
2021-01-01 22:38:15 +00:00
|
|
|
#include "input.h"
|
2020-08-22 20:40:22 +00:00
|
|
|
#include "sound.h"
|
|
|
|
#include "view.h"
|
|
|
|
#include "status.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "aistuff.h"
|
|
|
|
#include "mapinfo.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include "gamecvars.h"
|
|
|
|
#include "savegamehelp.h"
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "raze_sound.h"
|
|
|
|
#include "gamestate.h"
|
2021-05-21 23:34:00 +00:00
|
|
|
#include "screenjob_.h"
|
2020-08-22 20:40:22 +00:00
|
|
|
#include "c_console.h"
|
|
|
|
#include "cheathandler.h"
|
|
|
|
#include "statistics.h"
|
2020-08-26 14:47:30 +00:00
|
|
|
#include "g_input.h"
|
2020-10-04 16:31:48 +00:00
|
|
|
#include "razemenu.h"
|
2020-09-02 08:00:07 +00:00
|
|
|
#include "d_net.h"
|
2020-09-06 18:49:43 +00:00
|
|
|
#include "automap.h"
|
2020-09-27 18:42:55 +00:00
|
|
|
#include "raze_music.h"
|
2020-10-04 16:31:48 +00:00
|
|
|
#include "v_draw.h"
|
2021-04-30 14:21:37 +00:00
|
|
|
#include "vm.h"
|
2020-08-22 20:40:22 +00:00
|
|
|
|
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2021-11-21 19:34:15 +00:00
|
|
|
int nBestLevel;
|
2020-08-22 20:40:22 +00:00
|
|
|
|
|
|
|
void RunCinemaScene(int num);
|
|
|
|
void GameMove(void);
|
|
|
|
void DrawClock();
|
2020-08-25 22:49:25 +00:00
|
|
|
double calc_smoothratio();
|
2020-08-22 20:40:22 +00:00
|
|
|
void DoTitle(CompletionFunc completion);
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-02 20:55:57 +00:00
|
|
|
void GameInterface::Render()
|
2020-08-22 20:40:22 +00:00
|
|
|
{
|
2020-08-28 07:07:36 +00:00
|
|
|
drawtime.Reset();
|
|
|
|
drawtime.Clock();
|
|
|
|
|
2021-05-02 13:54:19 +00:00
|
|
|
if (currentLevel && (currentLevel->gameflags & LEVEL_EX_COUNTDOWN))
|
2020-08-22 20:40:22 +00:00
|
|
|
{
|
|
|
|
DoEnergyTile();
|
|
|
|
DrawClock();
|
|
|
|
}
|
|
|
|
|
2020-09-21 10:37:09 +00:00
|
|
|
double const smoothratio = calc_smoothratio();
|
|
|
|
|
|
|
|
|
2022-01-03 19:53:21 +00:00
|
|
|
|
|
|
|
DrawView(smoothratio);
|
|
|
|
if (nFreeze != 2) // Hide when Ramses is talking.
|
2020-08-22 20:40:22 +00:00
|
|
|
{
|
2022-01-03 19:53:21 +00:00
|
|
|
DrawStatusBar();
|
|
|
|
DrawCrosshair(kCrosshairTile, PlayerList[nLocalPlayer].nHealth >> 3, -PlayerList[nLocalPlayer].angle.look_anghalf(smoothratio), 0, 1);
|
|
|
|
|
|
|
|
if (paused && !M_Active())
|
|
|
|
{
|
|
|
|
auto tex = GStrings("TXTB_PAUSED");
|
|
|
|
auto font = PickSmallFont(tex);
|
|
|
|
int nStringWidth = font->StringWidth(tex);
|
|
|
|
DrawText(twod, font, CR_UNTRANSLATED, 160 - nStringWidth / 2, 100, tex, DTA_FullscreenScale, FSMode_Fit320x200, TAG_DONE);
|
|
|
|
}
|
2020-08-22 20:40:22 +00:00
|
|
|
}
|
2020-08-28 07:07:36 +00:00
|
|
|
|
|
|
|
drawtime.Unclock();
|
2020-08-22 20:40:22 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 07:11:32 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-09-02 20:55:57 +00:00
|
|
|
void GameInterface::DrawBackground()
|
2020-08-23 07:11:32 +00:00
|
|
|
{
|
2020-10-11 11:21:54 +00:00
|
|
|
auto nLogoTile = GameLogo();
|
2020-08-25 22:49:25 +00:00
|
|
|
int dword_9AB5F = (I_GetBuildTime() / 16) & 3;
|
2020-08-23 07:11:32 +00:00
|
|
|
|
|
|
|
twod->ClearScreen();
|
|
|
|
|
2020-10-25 08:22:17 +00:00
|
|
|
DrawRel(kSkullHead, 160, 100, 0);
|
|
|
|
DrawRel(kSkullJaw, 161, 130, 0);
|
|
|
|
DrawRel(nLogoTile, 160, 40, 0);
|
2020-08-23 07:11:32 +00:00
|
|
|
|
|
|
|
// draw the fire urn/lamp thingies
|
2020-10-25 08:22:17 +00:00
|
|
|
DrawRel(kTile3512 + dword_9AB5F, 50, 150, 0);
|
|
|
|
DrawRel(kTile3512 + ((dword_9AB5F + 2) & 3), 270, 150, 0);
|
2020-08-23 07:11:32 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 19:59:38 +00:00
|
|
|
void GameInterface::NextLevel(MapRecord *map, int skill)
|
|
|
|
{
|
2021-04-30 14:21:37 +00:00
|
|
|
InitLevel(map);
|
2020-09-04 19:59:38 +00:00
|
|
|
|
2021-04-30 14:21:37 +00:00
|
|
|
if (map->levelNumber >= nBestLevel)
|
2020-09-04 19:59:38 +00:00
|
|
|
{
|
2021-04-30 14:21:37 +00:00
|
|
|
nBestLevel = map->levelNumber - 1;
|
2020-09-04 19:59:38 +00:00
|
|
|
}
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-09-04 19:59:38 +00:00
|
|
|
STAT_NewLevel(currentLevel->labelName);
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2020-09-04 19:59:38 +00:00
|
|
|
}
|
|
|
|
|
2021-04-30 14:21:37 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2021-04-25 18:02:40 +00:00
|
|
|
|
2021-04-15 16:50:48 +00:00
|
|
|
void GameInterface::NewGame(MapRecord *map, int skill, bool frommenu)
|
2020-09-04 19:59:38 +00:00
|
|
|
{
|
|
|
|
// start a new game on the given level
|
|
|
|
InitNewGame();
|
2021-04-30 14:21:37 +00:00
|
|
|
InitLevel(map);
|
|
|
|
gameaction = ga_level;
|
|
|
|
}
|
|
|
|
|
2021-07-20 08:50:46 +00:00
|
|
|
int GameInterface::GetCurrentSkill()
|
|
|
|
{
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2021-04-30 14:21:37 +00:00
|
|
|
int selectedlevelnew;
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(DMapScreen, SetNextLevel)
|
|
|
|
{
|
|
|
|
PARAM_PROLOGUE;
|
|
|
|
PARAM_INT(v);
|
|
|
|
selectedlevelnew = v;
|
|
|
|
return 0;
|
2020-09-04 19:59:38 +00:00
|
|
|
}
|
|
|
|
|
2021-04-30 14:21:37 +00:00
|
|
|
void GameInterface::LevelCompleted(MapRecord *to_map, int skill)
|
2020-09-04 19:59:38 +00:00
|
|
|
{
|
2020-09-27 18:42:55 +00:00
|
|
|
Mus_Stop();
|
2021-05-02 13:54:19 +00:00
|
|
|
if (currentLevel->gameflags & LEVEL_EX_TRAINING)
|
2021-04-30 14:21:37 +00:00
|
|
|
{
|
|
|
|
gameaction = ga_mainmenu;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
StopAllSounds();
|
|
|
|
bCamera = false;
|
|
|
|
automapMode = am_off;
|
|
|
|
|
|
|
|
STAT_Update(to_map == nullptr);
|
|
|
|
if (to_map)
|
|
|
|
{
|
|
|
|
if (to_map->levelNumber > nBestLevel) nBestLevel = to_map->levelNumber - 1;
|
|
|
|
|
2021-05-13 17:06:38 +00:00
|
|
|
if (to_map->gameflags & LEVEL_EX_COUNTDOWN) PlayerList[0].nLives = 0;
|
2021-05-02 13:54:19 +00:00
|
|
|
if (to_map->gameflags & LEVEL_EX_TRAINING)
|
2021-04-30 14:21:37 +00:00
|
|
|
{
|
|
|
|
gameaction = ga_nextlevel;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SummaryInfo info{};
|
|
|
|
info.kills = nCreaturesKilled;
|
|
|
|
info.maxkills = nCreaturesTotal;
|
|
|
|
info.supersecrets = nBestLevel;
|
|
|
|
info.time = PlayClock * GameTicRate / 120;
|
2021-08-14 08:40:14 +00:00
|
|
|
if (to_map) selectedlevelnew = to_map->levelNumber;
|
2021-04-30 14:21:37 +00:00
|
|
|
ShowIntermission(currentLevel, to_map, &info, [=](bool)
|
|
|
|
{
|
|
|
|
if (!to_map) gameaction = ga_startup; // this was the end of the game
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (to_map->levelNumber != selectedlevelnew)
|
|
|
|
{
|
|
|
|
// User can switch destination on the scrolling map.
|
|
|
|
g_nextmap = FindMapByLevelNum(selectedlevelnew);
|
|
|
|
STAT_Cancel();
|
|
|
|
}
|
|
|
|
gameaction = ga_nextlevel;
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2020-08-23 07:11:32 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 10:26:52 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-08-23 07:11:32 +00:00
|
|
|
|
2020-09-02 20:55:57 +00:00
|
|
|
void GameInterface::Startup()
|
|
|
|
{
|
|
|
|
resettiming();
|
2020-09-04 19:59:38 +00:00
|
|
|
EndLevel = 0;
|
2021-04-27 18:04:11 +00:00
|
|
|
PlayLogos(ga_mainmenu, ga_mainmenu, false);
|
2020-09-02 20:55:57 +00:00
|
|
|
}
|
|
|
|
|
2020-08-29 22:55:49 +00:00
|
|
|
void GameInterface::ErrorCleanup()
|
|
|
|
{
|
|
|
|
// Clear all progression sensitive variables here.
|
2020-09-04 19:59:38 +00:00
|
|
|
EndLevel = 0;
|
2020-08-23 15:47:05 +00:00
|
|
|
}
|
2020-08-22 20:40:22 +00:00
|
|
|
|
|
|
|
END_PS_NS
|