2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood 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.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "build.h"
|
2020-07-31 18:39:02 +00:00
|
|
|
#include "v_draw.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "mmulti.h"
|
|
|
|
#include "common_game.h"
|
|
|
|
#include "blood.h"
|
|
|
|
#include "endgame.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "levels.h"
|
|
|
|
#include "loadsave.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "view.h"
|
2019-09-19 06:10:18 +00:00
|
|
|
#include "messages.h"
|
2019-11-12 21:59:51 +00:00
|
|
|
#include "statistics.h"
|
2019-12-09 01:01:30 +00:00
|
|
|
#include "gstrings.h"
|
2020-07-29 21:18:08 +00:00
|
|
|
#include "gamestate.h"
|
2020-04-12 06:09:38 +00:00
|
|
|
#include "raze_sound.h"
|
2020-09-01 17:49:05 +00:00
|
|
|
#include "d_net.h"
|
2020-09-01 19:27:32 +00:00
|
|
|
#include "screenjob.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2020-08-02 15:45:03 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
kLoadScreenCRC = -2051908571,
|
|
|
|
kLoadScreenWideBackWidth = 256,
|
|
|
|
kLoadScreenWideSideWidth = 128,
|
2020-08-02 15:45:03 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static int bLoadScreenCrcMatch = -1;
|
|
|
|
|
|
|
|
static void drawTextScreenBackground(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
if (bLoadScreenCrcMatch == -1) bLoadScreenCrcMatch = tileGetCRC32(kLoadScreen) == kLoadScreenCRC;
|
|
|
|
|
|
|
|
if (bLoadScreenCrcMatch)
|
|
|
|
{
|
|
|
|
if (ActiveRatio(twod->GetWidth(), twod->GetHeight()) < 1.34f)
|
|
|
|
{
|
|
|
|
DrawTexture(twod, tileGetTexture(kLoadScreen), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int width = scale(xdim, 240, ydim);
|
|
|
|
int nCount = (width + kLoadScreenWideBackWidth - 1) / kLoadScreenWideBackWidth;
|
|
|
|
for (int i = 0; i < nCount; i++)
|
|
|
|
{
|
|
|
|
DrawTexture(twod, tileGetTexture(kLoadScreenWideBack), (i * kLoadScreenWideBackWidth), 0,
|
|
|
|
DTA_VirtualWidth, width, DTA_VirtualHeight, 200, DTA_KeepRatio, true, TAG_DONE);
|
|
|
|
}
|
|
|
|
DrawTexture(twod, tileGetTexture(kLoadScreenWideLeft), 0, 0, DTA_VirtualWidth, width, DTA_VirtualHeight, 200, DTA_KeepRatio, true, DTA_TopLeft, true, TAG_DONE);
|
|
|
|
DrawTexture(twod, tileGetTexture(kLoadScreenWideRight), width - tileWidth(kLoadScreenWideRight), 0, DTA_TopLeft, true,
|
|
|
|
DTA_VirtualWidth, width, DTA_VirtualHeight, 200, DTA_KeepRatio, true, TAG_DONE);
|
|
|
|
DrawTexture(twod, tileGetTexture(kLoadScreenWideMiddle), (width - tileWidth(kLoadScreenWideMiddle)) / 2, 0, DTA_TopLeft, true,
|
|
|
|
DTA_VirtualWidth, width, DTA_VirtualHeight, 200, DTA_KeepRatio, true, TAG_DONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawTexture(twod, tileGetTexture(kLoadScreen), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
|
|
|
|
}
|
2020-08-02 15:45:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-05 19:47:53 +00:00
|
|
|
// One these screens get scriptified this should use the version in menuCustomizerBlood.
|
|
|
|
static void DrawCaption(const char* text)
|
|
|
|
{
|
|
|
|
double scalex = 1.; // Expand the box if the text is longer
|
|
|
|
int width = BigFont->StringWidth(text);
|
|
|
|
int boxwidth = tileWidth(2038);
|
|
|
|
if (boxwidth - 10 < width) scalex = double(width) / (boxwidth - 10);
|
|
|
|
|
|
|
|
DrawTexture(twod, tileGetTexture(2038, true), 160, 20, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffsetRel, true, DTA_ScaleX, scalex, TAG_DONE);
|
|
|
|
DrawText(twod, BigFont, CR_UNDEFINED, 160 - width / 2, 20 - tileHeight(4193) / 2, text, DTA_FullscreenScale, FSMode_Fit320x200Top, TAG_DONE);
|
|
|
|
}
|
|
|
|
|
2020-08-02 15:45:03 +00:00
|
|
|
|
2020-09-01 19:27:32 +00:00
|
|
|
class DBloodSummaryScreen : public DScreenJob
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
void DrawKills(void)
|
|
|
|
{
|
|
|
|
char pBuffer[40];
|
|
|
|
if (gGameOptions.nGameType == 0)
|
|
|
|
{
|
|
|
|
viewDrawText(1, FStringf("%s:", GStrings("KILLS")), 75, 50, -128, 0, 0, 1);
|
|
|
|
mysnprintf(pBuffer, 40,"%2d", gKillMgr.Kills);
|
|
|
|
viewDrawText(1, pBuffer, 160, 50, -128, 0, 0, 1);
|
|
|
|
viewDrawText(1, GStrings("OF"), 190, 50, -128, 0, 0, 1);
|
|
|
|
mysnprintf(pBuffer, 40, "%2d", gKillMgr.TotalKills);
|
|
|
|
viewDrawText(1, pBuffer, 220, 50, -128, 0, 0, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
viewDrawText(3, "#", 85, 35, -128, 0, 0, 1);
|
|
|
|
viewDrawText(3, GStrings("NAME"), 100, 35, -128, 0, 0, 1);
|
|
|
|
viewDrawText(3, GStrings("FRAGS"), 210, 35, -128, 0, 0, 1);
|
|
|
|
int nStart = 0;
|
|
|
|
int nEnd = kMaxPlayers;
|
|
|
|
|
|
|
|
for (int i = nStart; i < nEnd; i++) if (playeringame[i])
|
|
|
|
{
|
|
|
|
mysnprintf(pBuffer, 40, "%-2d", i);
|
|
|
|
viewDrawText(3, pBuffer, 85, 50 + 8 * i, -128, 0, 0, 1);
|
|
|
|
mysnprintf(pBuffer, 40, "%s", gProfile[i].name);
|
|
|
|
viewDrawText(3, pBuffer, 100, 50 + 8 * i, -128, 0, 0, 1);
|
|
|
|
mysnprintf(pBuffer, 40, "%d", gPlayer[i].fragCount);
|
|
|
|
viewDrawText(3, pBuffer, 210, 50 + 8 * i, -128, 0, 0, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawSecrets(void)
|
|
|
|
{
|
|
|
|
char pBuffer[40];
|
|
|
|
viewDrawText(1, FStringf("%s:", GStrings("TXT_SECRETS")), 75, 70, -128, 0, 0, 1);
|
|
|
|
mysnprintf(pBuffer, 40, "%2d", gSecretMgr.Founds);
|
|
|
|
viewDrawText(1, pBuffer, 160, 70, -128, 0, 0, 1);
|
|
|
|
viewDrawText(1, GStrings("OF"), 190, 70, -128, 0, 0, 1);
|
|
|
|
mysnprintf(pBuffer, 40, "%2d", gSecretMgr.Total);
|
|
|
|
viewDrawText(1, pBuffer, 220, 70, -128, 0, 0, 1);
|
|
|
|
if (gSecretMgr.Super > 0)
|
|
|
|
viewDrawText(1, GStrings("TXT_SUPERSECRET"), 160, 100, -128, 2, 1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Frame(uint64_t clock, bool skiprequest)
|
|
|
|
{
|
|
|
|
drawTextScreenBackground();
|
|
|
|
if (gGameOptions.nGameType == 0)
|
|
|
|
{
|
2020-10-05 19:47:53 +00:00
|
|
|
DrawCaption(GStrings("TXTB_LEVELSTATS"));
|
2020-09-01 19:27:32 +00:00
|
|
|
if (bPlayerCheated)
|
|
|
|
{
|
2020-09-29 20:20:25 +00:00
|
|
|
auto text = GStrings("TXTB_CHEATED");
|
|
|
|
int font = 3;
|
|
|
|
if (!SmallFont2->CanPrint(text)) font = 0;
|
|
|
|
viewDrawText(font, text, 160, 32, -128, 0, 1, font == 3);
|
2020-09-01 19:27:32 +00:00
|
|
|
}
|
|
|
|
DrawKills();
|
|
|
|
DrawSecrets();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-05 19:47:53 +00:00
|
|
|
DrawCaption(GStrings("TXTB_FRAGSTATS"));
|
2020-09-01 19:27:32 +00:00
|
|
|
DrawKills();
|
|
|
|
}
|
|
|
|
int myclock = int(clock * 120 / 1'000'000'000);
|
|
|
|
if ((myclock & 32))
|
|
|
|
{
|
2020-09-29 20:20:25 +00:00
|
|
|
auto text = GStrings("PRESSKEY");
|
|
|
|
int font = 3;
|
|
|
|
if (!SmallFont2->CanPrint(text)) font = 0;
|
|
|
|
viewDrawText(font, text, 160, 134, -128, 0, 1, font == 3);
|
2020-09-01 19:27:32 +00:00
|
|
|
}
|
|
|
|
return skiprequest ? -1 : 1;
|
|
|
|
}
|
|
|
|
};
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-09-04 18:46:44 +00:00
|
|
|
void GameInterface::LevelCompleted(MapRecord *map, int skill)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
JobDesc job = { Create<DBloodSummaryScreen>() };
|
2020-09-05 17:20:25 +00:00
|
|
|
sndStartSample(268, 128, -1, false, CHANF_UI);
|
2020-09-27 18:42:55 +00:00
|
|
|
Mus_Stop();
|
2020-09-04 18:46:44 +00:00
|
|
|
RunScreenJob(&job, 1, [=](bool)
|
2020-09-01 19:27:32 +00:00
|
|
|
{
|
|
|
|
soundEngine->StopAllChannels();
|
2020-09-04 18:46:44 +00:00
|
|
|
gameaction = ga_nextlevel;
|
2020-09-01 19:27:32 +00:00
|
|
|
});
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-09-04 18:46:44 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
CKillMgr::CKillMgr()
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Clear();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKillMgr::SetCount(int nCount)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
TotalKills = nCount;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 19:27:32 +00:00
|
|
|
void CKillMgr::AddNewKill(int nCount)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
TotalKills += nCount;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-10-13 22:29:19 +00:00
|
|
|
void CKillMgr::AddKill(spritetype* pSprite)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
if (pSprite->statnum == kStatDude && pSprite->type != kDudeBat && pSprite->type != kDudeRat && pSprite->type != kDudeInnocent && pSprite->type != kDudeBurningInnocent)
|
|
|
|
Kills++;
|
2019-10-13 22:29:19 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 19:27:32 +00:00
|
|
|
void CKillMgr::CountTotalKills(void)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
TotalKills = 0;
|
|
|
|
for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite])
|
|
|
|
{
|
|
|
|
spritetype* pSprite = &sprite[nSprite];
|
|
|
|
if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax)
|
|
|
|
ThrowError("Non-enemy sprite (%d) in the enemy sprite list.", nSprite);
|
|
|
|
if (pSprite->statnum == kStatDude && pSprite->type != kDudeBat && pSprite->type != kDudeRat && pSprite->type != kDudeInnocent && pSprite->type != kDudeBurningInnocent)
|
|
|
|
TotalKills++;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKillMgr::Clear(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
TotalKills = Kills = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSecretMgr::CSecretMgr(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Clear();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSecretMgr::SetCount(int nCount)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Total = nCount;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSecretMgr::Found(int nType)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
if (nType == 0) Founds++;
|
|
|
|
else if (nType < 0) {
|
|
|
|
viewSetSystemMessage("Invalid secret type %d triggered.", nType);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else Super++;
|
|
|
|
|
|
|
|
if (gGameOptions.nGameType == 0) {
|
|
|
|
viewSetMessage(GStrings(FStringf("TXTB_SECRET%d", Random(2))), 0, MESSAGE_PRIORITY_SECRET);
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSecretMgr::Clear(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Total = Founds = Super = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class EndGameLoadSave : public LoadSave {
|
|
|
|
public:
|
2020-09-01 19:27:32 +00:00
|
|
|
virtual void Load(void);
|
|
|
|
virtual void Save(void);
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void EndGameLoadSave::Load(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Read(&gSecretMgr.Total, 4);
|
|
|
|
Read(&gSecretMgr.Founds, 4);
|
|
|
|
Read(&gSecretMgr.Super, 4);
|
|
|
|
Read(&gKillMgr.TotalKills, 4);
|
|
|
|
Read(&gKillMgr.Kills, 4);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EndGameLoadSave::Save(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
Write(&gSecretMgr.Total, 4);
|
|
|
|
Write(&gSecretMgr.Founds, 4);
|
|
|
|
Write(&gSecretMgr.Super, 4);
|
|
|
|
Write(&gKillMgr.TotalKills, 4);
|
|
|
|
Write(&gKillMgr.Kills, 4);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSecretMgr gSecretMgr;
|
|
|
|
CKillMgr gKillMgr;
|
2020-09-01 19:27:32 +00:00
|
|
|
static EndGameLoadSave* myLoadSave;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
void EndGameLoadSaveConstruct(void)
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
myLoadSave = new EndGameLoadSave();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
2020-08-02 15:45:03 +00:00
|
|
|
|
|
|
|
class DBloodLoadScreen : public DScreenJob
|
|
|
|
{
|
2020-09-01 19:27:32 +00:00
|
|
|
const char* pzLoadingScreenText1;
|
|
|
|
MapRecord* rec;
|
2020-08-02 15:45:03 +00:00
|
|
|
|
|
|
|
public:
|
2020-09-09 20:42:01 +00:00
|
|
|
DBloodLoadScreen(const char* caption, MapRecord* maprec) : DScreenJob(), rec(maprec)
|
2020-09-01 19:27:32 +00:00
|
|
|
{
|
|
|
|
if (gGameOptions.nGameType == 0) pzLoadingScreenText1 = GStrings("TXTB_LLEVEL");
|
|
|
|
else pzLoadingScreenText1 = GStrings(FStringf("TXTB_NETGT%d", gGameOptions.nGameType));
|
|
|
|
}
|
|
|
|
|
|
|
|
int Frame(uint64_t clock, bool skiprequest)
|
|
|
|
{
|
|
|
|
twod->ClearScreen();
|
|
|
|
drawTextScreenBackground();
|
2020-10-05 19:47:53 +00:00
|
|
|
DrawCaption(pzLoadingScreenText1);
|
2020-09-01 19:27:32 +00:00
|
|
|
viewDrawText(1, rec->DisplayName(), 160, 50, -128, 0, 1, 1);
|
2020-09-29 20:20:25 +00:00
|
|
|
|
|
|
|
auto text = GStrings("TXTB_PLSWAIT");
|
|
|
|
int font = 3;
|
|
|
|
if (!SmallFont2->CanPrint(text)) font = 0;
|
|
|
|
|
|
|
|
viewDrawText(font, GStrings("TXTB_PLSWAIT"), 160, 134, -128, 0, 1, font == 3);
|
2020-09-09 20:42:01 +00:00
|
|
|
return 0;
|
2020-09-01 19:27:32 +00:00
|
|
|
}
|
2020-08-02 15:45:03 +00:00
|
|
|
};
|
|
|
|
|
2020-09-09 22:05:10 +00:00
|
|
|
void loadscreen(const char *caption, MapRecord* rec, CompletionFunc func)
|
2020-09-09 20:42:01 +00:00
|
|
|
{
|
2020-09-09 22:05:10 +00:00
|
|
|
JobDesc job = { Create<DBloodLoadScreen>(caption, rec) };
|
2020-09-09 20:42:01 +00:00
|
|
|
RunScreenJob(&job, 1, func);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
END_BLD_NS
|