2019-12-01 09:18:38 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
2020-10-06 21:49:34 +00:00
|
|
|
Copyright (C) 2020 Christoph Oelckers
|
2019-12-01 09:18:38 +00:00
|
|
|
|
2020-10-06 21:49:34 +00:00
|
|
|
This file is part of Raze.
|
2019-12-01 09:18:38 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
|
|
|
#include "build.h"
|
|
|
|
#include "compat.h"
|
2020-07-31 19:05:09 +00:00
|
|
|
#include "mmulti.h"
|
|
|
|
#include "c_bind.h"
|
2020-10-04 16:31:48 +00:00
|
|
|
#include "razemenu.h"
|
2020-07-31 19:05:09 +00:00
|
|
|
#include "gamestate.h"
|
2020-08-14 19:01:27 +00:00
|
|
|
#include "v_video.h"
|
2020-10-04 16:31:48 +00:00
|
|
|
#include "v_draw.h"
|
2020-10-06 21:49:34 +00:00
|
|
|
#include "vm.h"
|
2020-12-09 14:56:32 +00:00
|
|
|
#include "blood.h"
|
2019-12-01 09:18:38 +00:00
|
|
|
|
|
|
|
bool ShowOptionMenu();
|
|
|
|
|
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2019-12-01 14:31:08 +00:00
|
|
|
class CGameMenuItemQAV
|
2019-12-01 09:18:38 +00:00
|
|
|
{
|
2019-12-01 14:31:08 +00:00
|
|
|
public:
|
|
|
|
int m_nX, m_nY;
|
|
|
|
TArray<uint8_t> raw;
|
2020-11-21 14:45:37 +00:00
|
|
|
int duration;
|
2019-12-01 14:31:08 +00:00
|
|
|
int lastTick;
|
|
|
|
bool bWideScreen;
|
|
|
|
bool bClearBackground;
|
|
|
|
CGameMenuItemQAV(int, int, const char*, bool widescreen = false, bool clearbackground = false);
|
|
|
|
void Draw(void);
|
|
|
|
};
|
2019-12-01 09:18:38 +00:00
|
|
|
|
2019-12-01 14:31:08 +00:00
|
|
|
CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widescreen, bool clearbackground)
|
2019-12-01 09:18:38 +00:00
|
|
|
{
|
2019-12-01 14:31:08 +00:00
|
|
|
m_nY = a4;
|
|
|
|
m_nX = a3;
|
|
|
|
bWideScreen = widescreen;
|
|
|
|
bClearBackground = clearbackground;
|
2019-12-01 09:18:38 +00:00
|
|
|
|
2019-12-01 14:31:08 +00:00
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
// NBlood read this directly from the file system cache, but let's better store the data locally for robustness.
|
2019-12-07 09:31:27 +00:00
|
|
|
raw = fileSystem.LoadFile(name, 0);
|
2019-12-01 14:31:08 +00:00
|
|
|
if (raw.Size() != 0)
|
|
|
|
{
|
|
|
|
auto data = (QAV*)raw.Data();
|
|
|
|
data->nSprite = -1;
|
|
|
|
data->x = m_nX;
|
|
|
|
data->y = m_nY;
|
|
|
|
data->Preload();
|
2020-11-21 14:45:37 +00:00
|
|
|
duration = data->duration;
|
2020-08-25 23:10:14 +00:00
|
|
|
lastTick = I_GetBuildTime();
|
2019-12-01 14:31:08 +00:00
|
|
|
}
|
|
|
|
}
|
2019-12-01 09:18:38 +00:00
|
|
|
}
|
|
|
|
|
2019-12-01 14:31:08 +00:00
|
|
|
void CGameMenuItemQAV::Draw(void)
|
2019-12-01 09:18:38 +00:00
|
|
|
{
|
2019-12-01 14:31:08 +00:00
|
|
|
if (bClearBackground)
|
2020-06-12 18:31:23 +00:00
|
|
|
twod->ClearScreen();
|
2019-12-01 09:18:38 +00:00
|
|
|
|
2019-12-01 14:31:08 +00:00
|
|
|
if (raw.Size() > 0)
|
2019-12-01 09:18:38 +00:00
|
|
|
{
|
2019-12-01 14:31:08 +00:00
|
|
|
auto data = (QAV*)raw.Data();
|
2021-02-18 10:46:36 +00:00
|
|
|
int backFC = PlayClock;
|
2020-08-25 23:10:14 +00:00
|
|
|
int currentclock = I_GetBuildTime();
|
2021-02-18 10:46:36 +00:00
|
|
|
PlayClock = currentclock;
|
2020-08-25 23:10:14 +00:00
|
|
|
int nTicks = currentclock - lastTick;
|
|
|
|
lastTick = currentclock;
|
2020-11-21 14:45:37 +00:00
|
|
|
duration -= nTicks;
|
|
|
|
if (duration <= 0 || duration > data->duration)
|
2019-12-01 14:31:08 +00:00
|
|
|
{
|
2020-11-21 14:45:37 +00:00
|
|
|
duration = data->duration;
|
2019-12-01 14:31:08 +00:00
|
|
|
}
|
2020-11-21 14:45:37 +00:00
|
|
|
data->Play(data->duration - duration - nTicks, data->duration - duration, -1, NULL);
|
2020-08-14 19:12:32 +00:00
|
|
|
|
2019-12-01 14:31:08 +00:00
|
|
|
if (bWideScreen)
|
|
|
|
{
|
|
|
|
int xdim43 = scale(ydim, 4, 3);
|
2021-02-27 11:33:47 +00:00
|
|
|
int nCount = (twod->GetWidth() + xdim43 - 1) / xdim43;
|
2019-12-01 14:31:08 +00:00
|
|
|
int backX = data->x;
|
|
|
|
for (int i = 0; i < nCount; i++)
|
|
|
|
{
|
2020-11-21 14:45:37 +00:00
|
|
|
data->Draw(data->duration - duration, 10 + kQavOrientationLeft, 0, 0, false);
|
2019-12-01 14:31:08 +00:00
|
|
|
data->x += 320;
|
|
|
|
}
|
|
|
|
data->x = backX;
|
|
|
|
}
|
2019-12-01 09:18:38 +00:00
|
|
|
else
|
2020-11-21 14:45:37 +00:00
|
|
|
data->Draw(data->duration - duration, 10, 0, 0, false);
|
2019-12-01 14:31:08 +00:00
|
|
|
|
2021-02-18 10:46:36 +00:00
|
|
|
PlayClock = backFC;
|
2019-12-01 09:18:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-01 14:31:08 +00:00
|
|
|
|
|
|
|
static std::unique_ptr<CGameMenuItemQAV> itemBloodQAV; // This must be global to ensure that the animation remains consistent across menus.
|
|
|
|
|
2019-12-01 09:18:38 +00:00
|
|
|
void UpdateNetworkMenus(void)
|
|
|
|
{
|
2020-10-06 21:49:34 +00:00
|
|
|
// For now disable the network menu item as it is not functional.
|
2020-04-11 22:02:48 +00:00
|
|
|
for (auto name : { NAME_Mainmenu, NAME_IngameMenu })
|
2019-12-01 09:18:38 +00:00
|
|
|
{
|
2020-10-06 21:49:34 +00:00
|
|
|
DMenuDescriptor** desc = MenuDescriptors.CheckKey(name);
|
|
|
|
if (desc != NULL && (*desc)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor)))
|
2019-12-01 21:54:52 +00:00
|
|
|
{
|
2020-10-06 21:49:34 +00:00
|
|
|
DListMenuDescriptor* ld = static_cast<DListMenuDescriptor*>(*desc);
|
2019-12-01 21:54:52 +00:00
|
|
|
for (auto& li : ld->mItems)
|
|
|
|
{
|
2020-10-06 21:49:34 +00:00
|
|
|
if (li->mAction == NAME_MultiMenu)
|
2019-12-01 21:54:52 +00:00
|
|
|
{
|
2020-10-06 22:50:26 +00:00
|
|
|
li->mEnabled = -1;
|
2019-12-01 21:54:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-01 09:18:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-01 14:31:08 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Menu related game interface functions
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void GameInterface::MenuOpened()
|
|
|
|
{
|
|
|
|
itemBloodQAV.reset(new CGameMenuItemQAV(160, 100, "BDRIP.QAV", true));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameInterface::MenuClosed()
|
|
|
|
{
|
|
|
|
itemBloodQAV.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GameInterface::CanSave()
|
|
|
|
{
|
2020-07-29 21:18:08 +00:00
|
|
|
return (gamestate == GS_LEVEL && gPlayer[myconnectindex].pXSprite->health != 0);
|
2019-12-01 14:31:08 +00:00
|
|
|
}
|
|
|
|
|
2020-09-25 17:36:50 +00:00
|
|
|
bool GameInterface::StartGame(FNewGameStartup& gs)
|
2019-12-01 14:31:08 +00:00
|
|
|
{
|
2020-09-25 17:36:50 +00:00
|
|
|
if (gs.Episode >= 1)
|
|
|
|
{
|
|
|
|
if (g_gameType & GAMEFLAG_SHAREWARE)
|
|
|
|
{
|
2020-10-04 16:31:48 +00:00
|
|
|
M_StartMessage(GStrings("BUYBLOOD"), 1, NAME_None); // unreachable because we do not support Blood SW versions yet.
|
2020-09-25 17:36:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:43:58 +00:00
|
|
|
sfxKillAllSounds();
|
2020-09-04 18:46:44 +00:00
|
|
|
auto map = FindMapByLevelNum(levelnum(gs.Episode, gs.Level));
|
|
|
|
DeferedStartGame(map, gs.Skill);
|
2020-09-25 17:36:50 +00:00
|
|
|
return true;
|
2019-12-01 14:31:08 +00:00
|
|
|
}
|
2019-12-01 09:18:38 +00:00
|
|
|
|
|
|
|
FSavegameInfo GameInterface::GetSaveSig()
|
|
|
|
{
|
|
|
|
return { SAVESIG_BLD, MINSAVEVER_BLD, SAVEVER_BLD };
|
|
|
|
}
|
|
|
|
|
2019-12-06 17:36:49 +00:00
|
|
|
void GameInterface::QuitToTitle()
|
|
|
|
{
|
2020-09-05 17:20:25 +00:00
|
|
|
Mus_Stop();
|
2020-09-04 18:46:44 +00:00
|
|
|
gameaction = ga_mainmenu;
|
2019-12-05 22:17:55 +00:00
|
|
|
}
|
2019-12-01 09:18:38 +00:00
|
|
|
|
2020-10-10 08:11:22 +00:00
|
|
|
END_BLD_NS
|
|
|
|
|
|
|
|
using namespace Blood;
|
2020-10-08 22:50:21 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2020-10-10 08:11:22 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(DListMenuItemBloodDripDrawer, Draw)
|
|
|
|
{
|
|
|
|
// For narrow screens this would be mispositioned so skip drawing it there.
|
2021-01-18 11:25:04 +00:00
|
|
|
double ratio = ActiveRatio(screen->GetWidth(), screen->GetHeight());
|
2020-10-10 08:11:22 +00:00
|
|
|
if (ratio > 1.32) itemBloodQAV->Draw();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-08 22:50:21 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(_ImageScrollerPageQavDrawer, LoadQav)
|
|
|
|
{
|
|
|
|
PARAM_PROLOGUE;
|
|
|
|
PARAM_STRING(str);
|
|
|
|
auto qav = new CGameMenuItemQAV(160, 100, str, false, true);
|
|
|
|
ACTION_RETURN_POINTER(qav);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(_ImageScrollerPageQavDrawer, DestroyQav)
|
|
|
|
{
|
|
|
|
PARAM_PROLOGUE;
|
|
|
|
PARAM_POINTER(qav, CGameMenuItemQAV);
|
|
|
|
if (qav) delete qav;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(_ImageScrollerPageQavDrawer, DrawQav)
|
|
|
|
{
|
|
|
|
PARAM_PROLOGUE;
|
|
|
|
PARAM_POINTER(qav, CGameMenuItemQAV);
|
|
|
|
qav->Draw();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-01 14:31:08 +00:00
|
|
|
|