2020-06-11 07:22:16 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
2020-07-02 08:59:22 +00:00
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
|
|
|
Copyright (C) 2020 - Christoph Oelckers
|
2020-06-11 07:22:16 +00:00
|
|
|
|
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.
|
2020-06-11 07:22:16 +00:00
|
|
|
|
|
|
|
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.
|
2020-06-11 07:22:16 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-06-11 07:22:16 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2020-08-16 07:46:37 +00:00
|
|
|
#include "g_input.h"
|
2020-06-21 20:18:12 +00:00
|
|
|
#include "duke3d.h"
|
2020-06-11 07:22:16 +00:00
|
|
|
|
|
|
|
#include "superfasthash.h"
|
|
|
|
#include "gamecvars.h"
|
|
|
|
#include "gamecontrol.h"
|
|
|
|
#include "c_bind.h"
|
2020-10-04 16:31:48 +00:00
|
|
|
#include "razemenu.h"
|
2020-06-11 07:22:16 +00:00
|
|
|
#include "gstrings.h"
|
|
|
|
#include "version.h"
|
2020-07-03 21:56:14 +00:00
|
|
|
#include "names.h"
|
2020-07-07 18:27:21 +00:00
|
|
|
#include "mapinfo.h"
|
2020-07-21 20:59:24 +00:00
|
|
|
#include "gamestate.h"
|
2020-06-11 07:22:16 +00:00
|
|
|
#include "../../glbackend/glbackend.h"
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Menu related game interface functions
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void GameInterface::MenuOpened()
|
|
|
|
{
|
2020-09-26 15:43:34 +00:00
|
|
|
StopCommentary();
|
2020-07-05 22:54:06 +00:00
|
|
|
if (ud.multimode < 2)
|
2020-06-11 07:22:16 +00:00
|
|
|
{
|
|
|
|
screenpeek = myconnectindex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameInterface::MenuSound(EMenuSounds snd)
|
|
|
|
{
|
|
|
|
switch (snd)
|
|
|
|
{
|
|
|
|
case ActivateSound:
|
|
|
|
S_MenuSound();
|
|
|
|
break;
|
|
|
|
|
2020-08-04 22:32:29 +00:00
|
|
|
case ChooseSound:
|
2020-06-11 07:22:16 +00:00
|
|
|
case CursorSound:
|
2020-07-01 23:17:45 +00:00
|
|
|
S_PlaySound(isRR() ? 335 : KICK_HIT, CHAN_AUTO, CHANF_UI);
|
2020-06-11 07:22:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AdvanceSound:
|
2020-07-01 23:17:45 +00:00
|
|
|
S_PlaySound(isRR() ? 341 : PISTOL_BODYHIT, CHAN_AUTO, CHANF_UI);
|
2020-06-11 07:22:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CloseSound:
|
2020-08-02 20:14:58 +00:00
|
|
|
case BackSound:
|
2020-06-11 07:22:16 +00:00
|
|
|
S_PlaySound(EXITMENUSOUND, CHAN_AUTO, CHANF_UI);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GameInterface::CanSave()
|
|
|
|
{
|
2020-08-14 20:41:32 +00:00
|
|
|
if (ud.recstat == 2 || gamestate != GS_LEVEL) return false;
|
2020-07-07 21:01:34 +00:00
|
|
|
auto &myplayer = ps[myconnectindex];
|
2020-08-14 20:41:32 +00:00
|
|
|
return (sprite[myplayer.i].extra > 0);
|
2020-08-31 18:25:08 +00:00
|
|
|
}
|
2020-06-11 07:22:16 +00:00
|
|
|
|
2020-09-25 17:36:50 +00:00
|
|
|
bool GameInterface::StartGame(FNewGameStartup& gs)
|
2020-06-11 07:22:16 +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("BUYDUKE"), 1, NAME_None);
|
2020-09-25 17:36:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 07:22:16 +00:00
|
|
|
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];
|
2020-06-11 07:22:16 +00:00
|
|
|
|
2020-09-02 08:00:07 +00:00
|
|
|
if (menu_sounds && skillsound >= 0 && SoundEnabled() && !netgame)
|
2020-06-11 07:22:16 +00:00
|
|
|
{
|
2020-07-02 08:59:22 +00:00
|
|
|
S_PlaySound(skillsound, CHAN_AUTO, CHANF_UI);
|
2020-06-11 07:22:16 +00:00
|
|
|
|
2020-07-02 08:59:22 +00:00
|
|
|
while (S_CheckSoundPlaying(skillsound))
|
2020-06-11 07:22:16 +00:00
|
|
|
{
|
2020-08-29 22:55:49 +00:00
|
|
|
gi->UpdateSounds();
|
2020-08-26 02:15:33 +00:00
|
|
|
soundEngine->UpdateSounds(I_GetTime());
|
2020-08-16 07:46:37 +00:00
|
|
|
I_GetEvent();
|
2020-06-11 07:22:16 +00:00
|
|
|
}
|
2020-09-02 08:00:07 +00:00
|
|
|
Net_ClearFifo();
|
2020-06-11 07:22:16 +00:00
|
|
|
}
|
2020-10-07 18:32:43 +00:00
|
|
|
|
2020-07-07 18:27:21 +00:00
|
|
|
auto map = FindMapByLevelNum(levelnum(gs.Episode, gs.Level));
|
|
|
|
if (map)
|
|
|
|
{
|
2020-09-03 21:10:28 +00:00
|
|
|
DeferedStartGame(map, gs.Skill);
|
2020-09-25 17:36:50 +00:00
|
|
|
return true;
|
2020-07-07 18:27:21 +00:00
|
|
|
}
|
2020-09-25 17:36:50 +00:00
|
|
|
return false;
|
2020-06-11 07:22:16 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FSavegameInfo GameInterface::GetSaveSig()
|
|
|
|
{
|
2020-09-26 15:50:19 +00:00
|
|
|
return { SAVESIG_DN3D, MINSAVEVER_DN3D, SAVEVER_DN3D };
|
2020-06-11 07:22:16 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 18:44:17 +00:00
|
|
|
void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam)
|
|
|
|
{
|
2020-08-25 18:20:35 +00:00
|
|
|
int mclock = I_GetBuildTime();
|
2020-08-23 18:44:17 +00:00
|
|
|
int color = TRANSLATION(Translation_Remap, playercolor2lookup(playercolor));
|
2020-08-25 18:20:35 +00:00
|
|
|
int tile = isRR() ? 3845 + 36 - ((((8 - (mclock >> 4))) & 7) * 5) : 1441 - ((((4 - (mclock >> 4))) & 3) * 5);
|
2020-08-23 18:44:17 +00:00
|
|
|
auto tex = tileGetTexture(tile);
|
|
|
|
if (!tex) return;
|
2020-10-11 05:50:41 +00:00
|
|
|
double x = origin.X + 250, y = origin.Y + tex->GetDisplayHeight() * (isRR()? 0.25 : 0.5);
|
2020-08-23 18:44:17 +00:00
|
|
|
double scale = isRR() ? 0.375 : 0.75;
|
|
|
|
|
2020-08-24 18:25:53 +00:00
|
|
|
DrawTexture(twod, tex, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TranslationIndex, color, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
|
2020-08-23 18:44:17 +00:00
|
|
|
}
|
2020-06-11 07:22:16 +00:00
|
|
|
|
|
|
|
void GameInterface::QuitToTitle()
|
|
|
|
{
|
2020-09-04 18:46:44 +00:00
|
|
|
gameaction = ga_startup;
|
2020-06-11 07:22:16 +00:00
|
|
|
}
|
|
|
|
|
2020-09-25 18:22:30 +00:00
|
|
|
|
2020-06-11 07:22:16 +00:00
|
|
|
END_DUKE_NS
|