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 "compat.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "sequence.h"
|
|
|
|
#include "names.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "ps_input.h"
|
|
|
|
#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"
|
|
|
|
#include "screenjob.h"
|
|
|
|
#include "c_console.h"
|
|
|
|
#include "cheathandler.h"
|
|
|
|
#include "statistics.h"
|
2020-08-26 14:47:30 +00:00
|
|
|
#include "g_input.h"
|
2020-08-22 20:40:22 +00:00
|
|
|
#include "core/menu/menu.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-08-22 20:40:22 +00:00
|
|
|
|
|
|
|
BEGIN_PS_NS
|
|
|
|
|
|
|
|
short nBestLevel;
|
|
|
|
|
2020-08-23 10:26:52 +00:00
|
|
|
extern uint8_t nCinemaSeen;
|
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-04 19:59:38 +00:00
|
|
|
static void FinishLevel(int lnum, TArray<JobDesc> &jobs)
|
2020-08-22 20:40:22 +00:00
|
|
|
{
|
|
|
|
StopAllSounds();
|
|
|
|
|
|
|
|
bCamera = false;
|
2020-08-24 17:54:26 +00:00
|
|
|
automapMode = am_off;
|
2020-08-22 20:40:22 +00:00
|
|
|
|
2020-08-23 14:24:54 +00:00
|
|
|
STAT_Update(lnum == kMap20);
|
2020-09-11 18:56:46 +00:00
|
|
|
if (lnum == kMap20)
|
|
|
|
nPlayerLives[0] = 0;
|
2020-08-22 20:40:22 +00:00
|
|
|
|
2020-09-07 21:03:18 +00:00
|
|
|
DoAfterCinemaScene(lnum-1, jobs);
|
2020-08-22 20:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-23 10:59:01 +00:00
|
|
|
static void showmap(short nLevel, short nLevelNew, short nLevelBest, TArray<JobDesc> &jobs)
|
2020-08-22 20:40:22 +00:00
|
|
|
{
|
2020-08-23 10:26:52 +00:00
|
|
|
if (nLevelNew == 5 && !(nCinemaSeen & 1)) {
|
|
|
|
nCinemaSeen |= 1;
|
|
|
|
DoBeforeCinemaScene(5, jobs);
|
2020-08-22 20:40:22 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 10:26:52 +00:00
|
|
|
menu_DrawTheMap(nLevel, nLevelNew, nLevelBest, jobs);
|
2020-08-22 20:40:22 +00:00
|
|
|
|
2020-08-23 10:26:52 +00:00
|
|
|
if (nLevelNew == 11 && !(nCinemaSeen & 2)) {
|
|
|
|
DoBeforeCinemaScene(11, jobs);
|
2020-08-22 20:40:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-02 20:55:57 +00:00
|
|
|
void GameInterface::Render()
|
2020-08-22 20:40:22 +00:00
|
|
|
{
|
2020-09-02 20:55:57 +00:00
|
|
|
CheckKeys2();
|
2020-08-28 07:07:36 +00:00
|
|
|
drawtime.Reset();
|
|
|
|
drawtime.Clock();
|
|
|
|
|
2020-08-30 19:45:21 +00:00
|
|
|
if (currentLevel && currentLevel->levelNumber == kMap20)
|
2020-08-22 20:40:22 +00:00
|
|
|
{
|
|
|
|
DoEnergyTile();
|
|
|
|
DrawClock();
|
|
|
|
}
|
|
|
|
|
2020-09-21 10:37:09 +00:00
|
|
|
double const smoothratio = calc_smoothratio();
|
|
|
|
double const look_anghalf = getHalfLookAng(PlayerList[nLocalPlayer].oq16look_ang, PlayerList[nLocalPlayer].q16look_ang, cl_syncinput, smoothratio);
|
|
|
|
|
|
|
|
DrawView(smoothratio);
|
2020-08-22 20:40:22 +00:00
|
|
|
DrawStatusBar();
|
2020-09-21 10:37:09 +00:00
|
|
|
DrawCrosshair(MAXTILES, PlayerList[nLocalPlayer].nHealth >> 3, -look_anghalf, 1);
|
|
|
|
|
2020-08-22 20:40:22 +00:00
|
|
|
if (paused && !M_Active())
|
|
|
|
{
|
|
|
|
auto tex = GStrings("TXTB_PAUSED");
|
|
|
|
int nStringWidth = SmallFont->StringWidth(tex);
|
2020-08-24 18:25:53 +00:00
|
|
|
DrawText(twod, SmallFont, 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
|
|
|
{
|
|
|
|
auto nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo;
|
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();
|
|
|
|
|
|
|
|
DrawRel(kSkullHead, 160, 100, 32);
|
|
|
|
DrawRel(kSkullJaw, 161, 130, 32);
|
|
|
|
DrawRel(nLogoTile, 160, 40, 32);
|
|
|
|
|
|
|
|
// draw the fire urn/lamp thingies
|
|
|
|
DrawRel(kTile3512 + dword_9AB5F, 50, 150, 32);
|
|
|
|
DrawRel(kTile3512 + ((dword_9AB5F + 2) & 3), 270, 150, 32);
|
|
|
|
}
|
|
|
|
|
2020-08-23 10:26:52 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-08-23 07:11:32 +00:00
|
|
|
|
2020-09-04 19:59:38 +00:00
|
|
|
static void Intermission(MapRecord *from_map, MapRecord *to_map)
|
2020-08-23 07:11:32 +00:00
|
|
|
{
|
2020-08-23 10:26:52 +00:00
|
|
|
TArray<JobDesc> jobs;
|
|
|
|
|
2020-09-04 19:59:38 +00:00
|
|
|
if (to_map && to_map->levelNumber != 0)
|
|
|
|
{
|
|
|
|
nBestLevel = to_map->levelNumber - 1;
|
|
|
|
FinishLevel(to_map->levelNumber, jobs);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (to_map->levelNumber > -1 && to_map->levelNumber < kMap20)
|
|
|
|
{
|
|
|
|
// start a new game at the given level
|
|
|
|
if (!nNetPlayerCount && to_map->levelNumber > 0)
|
|
|
|
{
|
|
|
|
showmap(from_map? from_map->levelNumber : -1, to_map->levelNumber, nBestLevel, jobs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
jobs.Push({ Create<DScreenJob>() }); // we need something in here even in the multiplayer case.
|
|
|
|
}
|
|
|
|
if (jobs.Size() > 0)
|
|
|
|
{
|
|
|
|
RunScreenJob(jobs.Data(), jobs.Size(), [=](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;
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameInterface::NextLevel(MapRecord *map, int skill)
|
|
|
|
{
|
|
|
|
InitLevel(map->levelNumber);
|
|
|
|
|
|
|
|
if (map->levelNumber > nBestLevel)
|
|
|
|
{
|
|
|
|
nBestLevel = selectedlevelnew;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map->levelNumber == 11) nCinemaSeen |= 2;
|
|
|
|
STAT_NewLevel(currentLevel->labelName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameInterface::NewGame(MapRecord *map, int skill)
|
|
|
|
{
|
|
|
|
// start a new game on the given level
|
|
|
|
InitNewGame();
|
|
|
|
if (map->levelNumber == 1) STAT_StartNewGame("Exhumed", 1);
|
|
|
|
Intermission(nullptr, map);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameInterface::LevelCompleted(MapRecord *map, int skill)
|
|
|
|
{
|
2020-09-05 13:43:34 +00:00
|
|
|
if (currentLevel->levelNumber == 0) gameaction = ga_mainmenu;
|
2020-09-04 19:59:38 +00:00
|
|
|
else Intermission(currentLevel, map);
|
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;
|
2020-09-02 20:55:57 +00:00
|
|
|
|
|
|
|
if (userConfig.CommandMap.IsNotEmpty())
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
auto map = FindMapByName(userConfig.CommandMap);
|
2020-09-04 19:59:38 +00:00
|
|
|
if (map) DeferedStartMap(map, 0);
|
2020-09-02 20:55:57 +00:00
|
|
|
userConfig.CommandMap = "";
|
|
|
|
goto again;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-05 13:43:34 +00:00
|
|
|
if (!userConfig.nologo) DoTitle([](bool) { gameaction = ga_mainmenu; });
|
|
|
|
else gameaction = ga_mainmenu;
|
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
|