2019-12-14 11:39:18 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2016 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Christoph Oelckers
|
|
|
|
|
|
|
|
This 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 "exhumed.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "names.h"
|
|
|
|
#include "version.h"
|
2020-04-12 06:09:38 +00:00
|
|
|
#include "raze_sound.h"
|
2019-12-14 11:39:18 +00:00
|
|
|
|
|
|
|
|
2020-06-14 16:57:55 +00:00
|
|
|
#include "menu/menu.h" // to override the local menu.h
|
2019-12-14 11:39:18 +00:00
|
|
|
|
|
|
|
#include "../../glbackend/glbackend.h"
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_PS_NS
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Implements the native looking menu used for the main menu
|
|
|
|
// and the episode/skill selection screens, i.e. the parts
|
|
|
|
// that need to look authentic
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void menu_DoPlasma();
|
2020-08-24 07:11:51 +00:00
|
|
|
double zoomsize = 0;
|
2019-12-14 11:39:18 +00:00
|
|
|
|
|
|
|
class PSMainMenu : public DListMenu
|
|
|
|
{
|
|
|
|
|
|
|
|
void Init(DMenu* parent, FListMenuDescriptor* desc) override
|
|
|
|
{
|
|
|
|
DListMenu::Init(parent, desc);
|
2020-02-23 19:40:45 +00:00
|
|
|
PlayLocalSound(StaticSound[kSound31], 0, false, CHANF_UI);
|
2019-12-14 11:39:18 +00:00
|
|
|
}
|
|
|
|
|
2020-01-07 00:11:19 +00:00
|
|
|
void Ticker() override
|
2019-12-14 11:39:18 +00:00
|
|
|
{
|
|
|
|
// handle the menu zoom-in
|
2020-08-24 07:11:51 +00:00
|
|
|
if (zoomsize < 1.)
|
2019-12-14 11:39:18 +00:00
|
|
|
{
|
2020-08-24 07:11:51 +00:00
|
|
|
zoomsize += 0.0625;
|
|
|
|
if (zoomsize >= 1.) {
|
|
|
|
zoomsize = 1.;
|
2019-12-14 11:39:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreDraw() override
|
|
|
|
{
|
2020-04-11 22:02:48 +00:00
|
|
|
if (mDesc->mMenuName == NAME_Mainmenu)
|
2020-03-01 15:32:41 +00:00
|
|
|
menu_DoPlasma();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo;
|
2020-08-21 20:40:09 +00:00
|
|
|
DrawRel(nLogoTile, 160, 40);
|
2020-03-01 15:32:41 +00:00
|
|
|
}
|
2019-12-14 11:39:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Menu related game interface functions
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void GameInterface::DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags)
|
|
|
|
{
|
|
|
|
int tilenum = (int)strtoll(text, nullptr, 0);
|
|
|
|
double y = ypos - tilesiz[tilenum].y / 2;
|
|
|
|
|
|
|
|
int8_t shade;
|
|
|
|
|
|
|
|
if (state == NIT_SelectedState)
|
|
|
|
{ // currently selected menu item
|
|
|
|
shade = Sin((int)totalclock << 4) >> 9;
|
|
|
|
}
|
|
|
|
else if (state == NIT_ActiveState) {
|
|
|
|
shade = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
shade = 25;
|
|
|
|
}
|
|
|
|
|
2020-08-23 11:57:56 +00:00
|
|
|
// Todo: Replace the boxes with an empty one and draw the text with a font.
|
|
|
|
auto tex = tileGetTexture(tilenum);
|
|
|
|
|
2020-08-24 18:25:53 +00:00
|
|
|
DrawTexture(twod, tex, 160, y + tex->GetDisplayHeight(), DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffset, true, DTA_ScaleX, zoomsize, DTA_ScaleY, zoomsize,
|
2020-08-23 11:57:56 +00:00
|
|
|
DTA_Color, shadeToLight(shade), TAG_DONE);
|
2019-12-14 11:39:18 +00:00
|
|
|
|
|
|
|
// tilesizx is 51
|
|
|
|
// tilesizy is 33
|
|
|
|
|
|
|
|
if (state == NIT_SelectedState)
|
|
|
|
{
|
2020-08-23 11:57:56 +00:00
|
|
|
tex = tileGetTexture(kMenuCursorTile);
|
2020-08-24 18:25:53 +00:00
|
|
|
DrawTexture(twod, tex, 62, ypos - 12, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TopLeft, true, TAG_DONE);
|
|
|
|
DrawTexture(twod, tex, 207, ypos - 12, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TopLeft, true, DTA_FlipX, true, TAG_DONE);
|
2019-12-14 11:39:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GameInterface::MenuOpened()
|
|
|
|
{
|
|
|
|
GrabPalette();
|
|
|
|
zoomsize = 0;
|
|
|
|
StopAllSounds();
|
|
|
|
StopLocalSound();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameInterface::MenuSound(EMenuSounds snd)
|
|
|
|
{
|
|
|
|
switch (snd)
|
|
|
|
{
|
|
|
|
case CursorSound:
|
2020-02-23 19:40:45 +00:00
|
|
|
PlayLocalSound(StaticSound[kSound35], 0, false, CHANF_UI);
|
2019-12-14 11:39:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AdvanceSound:
|
|
|
|
case BackSound:
|
2020-02-23 19:40:45 +00:00
|
|
|
PlayLocalSound(StaticSound[kSound33], 0, false, CHANF_UI);
|
2019-12-14 11:39:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameInterface::MenuClosed()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-23 19:18:40 +00:00
|
|
|
void GameInterface::StartGame(FNewGameStartup& gs)
|
2019-12-14 11:39:18 +00:00
|
|
|
{
|
2020-08-23 10:26:52 +00:00
|
|
|
GameAction = gs.Episode; // 0 is training, 1 is the regular game
|
2019-12-14 11:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FSavegameInfo GameInterface::GetSaveSig()
|
|
|
|
{
|
|
|
|
return { SAVESIG_PS, MINSAVEVER_PS, SAVEVER_PS };
|
|
|
|
}
|
|
|
|
|
2019-12-26 16:42:45 +00:00
|
|
|
void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text)
|
|
|
|
{
|
2020-08-24 18:25:53 +00:00
|
|
|
// Fixme: should use the extracted font from the menu items (i.e. BigFont) and a stretched box for the menu items.
|
|
|
|
DrawText(twod, SmallFont, CR_UNTRANSLATED, 160 - SmallFont->StringWidth(text), 10, text, DTA_FullscreenScale, FSMode_Fit320x200Top, TAG_DONE);
|
2019-12-26 16:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-12-14 11:39:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
END_PS_NS
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Class registration
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
static TMenuClassDescriptor<Powerslave::PSMainMenu> _mm("Exhumed.MainMenu");
|
|
|
|
|
|
|
|
void RegisterPSMenus()
|
|
|
|
{
|
|
|
|
menuClasses.Push(&_mm);
|
|
|
|
}
|