raze/source/games/duke/src/d_menu.cpp

165 lines
4.1 KiB
C++
Raw Normal View History

//-------------------------------------------------------------------------
/*
2020-07-02 08:59:22 +00:00
Copyright (C) 1996, 2003 - 3D Realms Entertainment
Copyright (C) 2020 - Christoph Oelckers
2020-07-02 08:59:22 +00:00
This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
2020-07-02 08:59:22 +00:00
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
2020-07-02 08:59:22 +00:00
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "g_input.h"
2020-06-21 20:18:12 +00:00
#include "duke3d.h"
#include "superfasthash.h"
#include "gamecvars.h"
#include "gamecontrol.h"
#include "c_bind.h"
#include "razemenu.h"
#include "gstrings.h"
#include "version.h"
#include "names.h"
#include "mapinfo.h"
#include "gamestate.h"
#include "dukeactor.h"
BEGIN_DUKE_NS
//----------------------------------------------------------------------------
//
// Menu related game interface functions
//
//----------------------------------------------------------------------------
void GameInterface::MenuOpened()
{
StopCommentary();
2020-07-05 22:54:06 +00:00
if (ud.multimode < 2)
{
screenpeek = myconnectindex;
}
}
void GameInterface::MenuSound(EMenuSounds snd)
{
switch (snd)
{
case ActivateSound:
S_MenuSound();
break;
case ChooseSound:
case CursorSound:
S_PlaySound(isRR() ? 335 : KICK_HIT, CHAN_AUTO, CHANF_UI);
break;
case AdvanceSound:
S_PlaySound(isRR() ? 341 : PISTOL_BODYHIT, CHAN_AUTO, CHANF_UI);
break;
case CloseSound:
2020-08-02 20:14:58 +00:00
case BackSound:
S_PlaySound(EXITMENUSOUND, CHAN_AUTO, CHANF_UI);
break;
default:
return;
}
}
bool GameInterface::CanSave()
{
if (ud.recstat == 2 || gamestate != GS_LEVEL) return false;
2020-07-07 21:01:34 +00:00
auto &myplayer = ps[myconnectindex];
2020-10-23 15:44:45 +00:00
return (myplayer.GetActor()->s.extra > 0);
}
bool GameInterface::StartGame(FNewGameStartup& gs)
{
if (gs.Episode >= 1)
{
if (g_gameType & GAMEFLAG_SHAREWARE)
{
M_StartMessage(GStrings("BUYDUKE"), 1, NAME_None);
return false;
}
}
int32_t skillsound = PISTOL_BODYHIT;
soundEngine->StopAllChannels();
2020-07-02 08:59:22 +00:00
static const short sounds_d[] = { JIBBED_ACTOR6, BONUS_SPEECH1, DUKE_GETWEAPON2, JIBBED_ACTOR5, JIBBED_ACTOR5 };
static const short sounds_r[] = { 427, 428, 196, 195, 197 };
if (gs.Skill >=0 && gs.Skill <= 5) skillsound = isRR()? sounds_r[gs.Skill] : sounds_d[gs.Skill];
if (menu_sounds && skillsound >= 0 && SoundEnabled() && !netgame)
{
2020-07-02 08:59:22 +00:00
S_PlaySound(skillsound, CHAN_AUTO, CHANF_UI);
2020-07-02 08:59:22 +00:00
while (S_CheckSoundPlaying(skillsound))
{
gi->UpdateSounds();
soundEngine->UpdateSounds(I_GetTime());
I_GetEvent();
}
Net_ClearFifo();
}
2020-10-07 18:32:43 +00:00
auto map = FindMapByLevelNum(levelnum(gs.Episode, gs.Level));
if (map)
{
DeferedStartGame(map, gs.Skill);
return true;
}
return false;
}
FSavegameInfo GameInterface::GetSaveSig()
{
2020-09-26 15:50:19 +00:00
return { SAVESIG_DN3D, MINSAVEVER_DN3D, SAVEVER_DN3D };
}
void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam)
{
int mclock = I_GetBuildTime();
int color = TRANSLATION(Translation_Remap, playercolor2lookup(playercolor));
int tile = isRR() ? 3845 + 36 - ((((8 - (mclock >> 4))) & 7) * 5) : 1441 - ((((4 - (mclock >> 4))) & 3) * 5);
auto tex = tileGetTexture(tile);
if (!tex) return;
double x = origin.X + 250, y = origin.Y + tex->GetDisplayHeight() * (isRR()? 0.25 : 0.5);
double scale = isRR() ? 0.375 : 0.75;
DrawTexture(twod, tex, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TranslationIndex, color, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
}
void GameInterface::QuitToTitle()
{
gameaction = ga_startup;
}
END_DUKE_NS