2016-03-31 02:38:57 +02:00
|
|
|
/* Copyright (c) 2002-2012 Croteam Ltd.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of version 2 of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation
|
|
|
|
|
2016-04-01 00:12:10 +02:00
|
|
|
|
2016-03-31 02:38:57 +02:00
|
|
|
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. */
|
2016-03-13 22:52:32 +01:00
|
|
|
|
2016-04-03 05:56:12 +02:00
|
|
|
#include "SeriousSam/StdH.h"
|
2016-03-13 22:52:32 +01:00
|
|
|
#include <Engine/Build.h>
|
|
|
|
|
|
|
|
#include "MenuStuff.h"
|
|
|
|
|
2016-03-14 23:03:22 +01:00
|
|
|
#define RADIOTRANS(str) ("ETRS" str)
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrNoYes[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("No"),
|
|
|
|
RADIOTRANS("Yes"),
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrComputerInvoke[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("Use"),
|
|
|
|
RADIOTRANS("Double-click use"),
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrWeapon[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("Only if new"),
|
|
|
|
RADIOTRANS("Never"),
|
|
|
|
RADIOTRANS("Always"),
|
|
|
|
RADIOTRANS("Only if stronger"),
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
PIX apixWidths[][2] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
320, 240,
|
|
|
|
400, 300,
|
|
|
|
512, 384,
|
|
|
|
640, 240,
|
|
|
|
640, 480,
|
|
|
|
720, 540,
|
|
|
|
800, 300,
|
|
|
|
800, 600,
|
|
|
|
960, 720,
|
|
|
|
1024, 384,
|
|
|
|
1024, 768,
|
|
|
|
1152, 864,
|
|
|
|
1280, 480,
|
|
|
|
1280, 960,
|
|
|
|
1600, 600,
|
|
|
|
1600, 1200,
|
|
|
|
1920, 720,
|
|
|
|
1920, 1440,
|
|
|
|
2048, 786,
|
|
|
|
2048, 1536,
|
2016-03-30 18:23:12 +02:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrCrosshair[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
"",
|
|
|
|
"Textures\\Interface\\Crosshairs\\Crosshair1.tex",
|
|
|
|
"Textures\\Interface\\Crosshairs\\Crosshair2.tex",
|
|
|
|
"Textures\\Interface\\Crosshairs\\Crosshair3.tex",
|
|
|
|
"Textures\\Interface\\Crosshairs\\Crosshair4.tex",
|
|
|
|
"Textures\\Interface\\Crosshairs\\Crosshair5.tex",
|
|
|
|
"Textures\\Interface\\Crosshairs\\Crosshair6.tex",
|
|
|
|
"Textures\\Interface\\Crosshairs\\Crosshair7.tex",
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrMaxPlayersRadioTexts[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("2"),
|
|
|
|
RADIOTRANS("3"),
|
|
|
|
RADIOTRANS("4"),
|
|
|
|
RADIOTRANS("5"),
|
|
|
|
RADIOTRANS("6"),
|
|
|
|
RADIOTRANS("7"),
|
|
|
|
RADIOTRANS("8"),
|
|
|
|
RADIOTRANS("9"),
|
|
|
|
RADIOTRANS("10"),
|
|
|
|
RADIOTRANS("11"),
|
|
|
|
RADIOTRANS("12"),
|
|
|
|
RADIOTRANS("13"),
|
|
|
|
RADIOTRANS("14"),
|
|
|
|
RADIOTRANS("15"),
|
|
|
|
RADIOTRANS("16"),
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
// here, we just reserve space for up to 16 different game types
|
|
|
|
// actual names are added later
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrGameTypeRadioTexts[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
"", "", "", "", "",
|
|
|
|
"", "", "", "", "",
|
|
|
|
"", "", "", "", "",
|
|
|
|
"", "", "", "", "",
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
INDEX ctGameTypeRadioTexts = 1;
|
2016-03-14 23:03:22 +01:00
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrDifficultyRadioTexts[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("Tourist"),
|
|
|
|
RADIOTRANS("Easy"),
|
|
|
|
RADIOTRANS("Normal"),
|
|
|
|
RADIOTRANS("Hard"),
|
|
|
|
RADIOTRANS("Serious"),
|
|
|
|
RADIOTRANS("Mental"),
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrSplitScreenRadioTexts[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("1"),
|
|
|
|
RADIOTRANS("2 - split screen"),
|
|
|
|
RADIOTRANS("3 - split screen"),
|
|
|
|
RADIOTRANS("4 - split screen"),
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrDisplayPrefsRadioTexts[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("Speed"),
|
|
|
|
RADIOTRANS("Normal"),
|
|
|
|
RADIOTRANS("Quality"),
|
|
|
|
RADIOTRANS("Custom"),
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrDisplayAPIRadioTexts[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("OpenGL"),
|
2016-04-03 05:56:12 +02:00
|
|
|
#ifdef SE1_D3D
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("Direct3D"),
|
2016-04-03 05:56:12 +02:00
|
|
|
#endif
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrBitsPerPixelRadioTexts[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("Desktop"),
|
|
|
|
RADIOTRANS("16 BPP"),
|
|
|
|
RADIOTRANS("32 BPP"),
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrFrequencyRadioTexts[] = {
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("No sound"),
|
|
|
|
RADIOTRANS("11kHz"),
|
|
|
|
RADIOTRANS("22kHz"),
|
|
|
|
RADIOTRANS("44kHz"),
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-04-04 08:34:07 +02:00
|
|
|
CTString astrSoundAPIRadioTexts[] = {
|
2016-04-03 05:56:12 +02:00
|
|
|
#ifdef PLATFORM_WIN32
|
2016-03-31 22:27:11 +02:00
|
|
|
RADIOTRANS("WaveOut"),
|
|
|
|
RADIOTRANS("DirectSound"),
|
|
|
|
RADIOTRANS("EAX"),
|
2016-04-03 05:56:12 +02:00
|
|
|
#else
|
|
|
|
RADIOTRANS("Simple Directmedia Layer"),
|
|
|
|
#endif
|
2016-03-14 23:03:22 +01:00
|
|
|
};
|
|
|
|
|
2016-03-13 22:52:32 +01:00
|
|
|
ULONG GetSpawnFlagsForGameType(INDEX iGameType)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
if (iGameType == -1) return SPF_SINGLEPLAYER;
|
|
|
|
|
|
|
|
// get function that will provide us the flags
|
|
|
|
CShellSymbol *pss = _pShell->GetSymbol("GetSpawnFlagsForGameTypeSS", /*bDeclaredOnly=*/ TRUE);
|
|
|
|
// if none
|
|
|
|
if (pss == NULL) {
|
|
|
|
// error
|
|
|
|
ASSERT(FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG(*pFunc)(INDEX) = (ULONG(*)(INDEX))pss->ss_pvValue;
|
|
|
|
return pFunc(iGameType);
|
2016-03-13 22:52:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL IsMenuEnabled(const CTString &strMenuName)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
// get function that will provide us the flags
|
|
|
|
CShellSymbol *pss = _pShell->GetSymbol("IsMenuEnabledSS", /*bDeclaredOnly=*/ TRUE);
|
|
|
|
// if none
|
|
|
|
if (pss == NULL) {
|
|
|
|
// error
|
|
|
|
ASSERT(FALSE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL(*pFunc)(const CTString &) = (BOOL(*)(const CTString &))pss->ss_pvValue;
|
|
|
|
return pFunc(strMenuName);
|
2016-03-15 22:24:35 +01:00
|
|
|
}
|
|
|
|
|
2016-03-16 19:43:05 +01:00
|
|
|
// initialize game type strings table
|
|
|
|
void InitGameTypes(void)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
// get function that will provide us the info about gametype
|
|
|
|
CShellSymbol *pss = _pShell->GetSymbol("GetGameTypeNameSS", /*bDeclaredOnly=*/ TRUE);
|
|
|
|
// if none
|
|
|
|
if (pss == NULL) {
|
|
|
|
// error
|
2016-04-03 05:56:12 +02:00
|
|
|
astrGameTypeRadioTexts[0] = "<\?\?\?>";
|
2016-03-31 22:27:11 +02:00
|
|
|
ctGameTypeRadioTexts = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// for each mode
|
|
|
|
for (ctGameTypeRadioTexts = 0; ctGameTypeRadioTexts<ARRAYCOUNT(astrGameTypeRadioTexts); ctGameTypeRadioTexts++) {
|
|
|
|
// get the text
|
|
|
|
CTString(*pFunc)(INDEX) = (CTString(*)(INDEX))pss->ss_pvValue;
|
|
|
|
CTString strMode = pFunc(ctGameTypeRadioTexts);
|
|
|
|
// if no mode modes
|
|
|
|
if (strMode == "") {
|
|
|
|
// stop
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// add that mode
|
|
|
|
astrGameTypeRadioTexts[ctGameTypeRadioTexts] = strMode;
|
|
|
|
}
|
2016-03-16 19:43:05 +01:00
|
|
|
}
|
|
|
|
|
2016-03-15 22:24:35 +01:00
|
|
|
int qsort_CompareFileInfos_NameUp(const void *elem1, const void *elem2)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
const CFileInfo &fi1 = **(CFileInfo **)elem1;
|
|
|
|
const CFileInfo &fi2 = **(CFileInfo **)elem2;
|
|
|
|
return strcmp(fi1.fi_strName, fi2.fi_strName);
|
2016-03-15 22:24:35 +01:00
|
|
|
}
|
2016-03-29 22:49:32 +02:00
|
|
|
|
2016-03-15 22:24:35 +01:00
|
|
|
int qsort_CompareFileInfos_NameDn(const void *elem1, const void *elem2)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
const CFileInfo &fi1 = **(CFileInfo **)elem1;
|
|
|
|
const CFileInfo &fi2 = **(CFileInfo **)elem2;
|
|
|
|
return -strcmp(fi1.fi_strName, fi2.fi_strName);
|
2016-03-15 22:24:35 +01:00
|
|
|
}
|
2016-03-29 22:49:32 +02:00
|
|
|
|
2016-03-15 22:24:35 +01:00
|
|
|
int qsort_CompareFileInfos_FileUp(const void *elem1, const void *elem2)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
const CFileInfo &fi1 = **(CFileInfo **)elem1;
|
|
|
|
const CFileInfo &fi2 = **(CFileInfo **)elem2;
|
|
|
|
return strcmp(fi1.fi_fnFile, fi2.fi_fnFile);
|
2016-03-15 22:24:35 +01:00
|
|
|
}
|
2016-03-29 22:49:32 +02:00
|
|
|
|
2016-03-15 22:24:35 +01:00
|
|
|
int qsort_CompareFileInfos_FileDn(const void *elem1, const void *elem2)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
const CFileInfo &fi1 = **(CFileInfo **)elem1;
|
|
|
|
const CFileInfo &fi2 = **(CFileInfo **)elem2;
|
|
|
|
return -strcmp(fi1.fi_fnFile, fi2.fi_fnFile);
|
2016-03-30 18:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
INDEX APIToSwitch(enum GfxAPIType gat)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
switch (gat) {
|
|
|
|
case GAT_OGL: return 0;
|
2016-03-30 18:23:12 +02:00
|
|
|
#ifdef SE1_D3D
|
2016-03-31 22:27:11 +02:00
|
|
|
case GAT_D3D: return 1;
|
2016-03-30 18:23:12 +02:00
|
|
|
#endif // SE1_D3D
|
2016-03-31 22:27:11 +02:00
|
|
|
default: ASSERT(FALSE); return 0;
|
|
|
|
}
|
2016-03-30 18:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
enum GfxAPIType SwitchToAPI(INDEX i)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
switch (i) {
|
|
|
|
case 0: return GAT_OGL;
|
2016-03-30 18:23:12 +02:00
|
|
|
#ifdef SE1_D3D
|
2016-03-31 22:27:11 +02:00
|
|
|
case 1: return GAT_D3D;
|
2016-03-30 18:23:12 +02:00
|
|
|
#endif // SE1_D3D
|
2016-03-31 22:27:11 +02:00
|
|
|
default: ASSERT(FALSE); return GAT_OGL;
|
|
|
|
}
|
2016-03-30 18:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
INDEX DepthToSwitch(enum DisplayDepth dd)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
switch (dd) {
|
|
|
|
case DD_DEFAULT: return 0;
|
|
|
|
case DD_16BIT: return 1;
|
|
|
|
case DD_32BIT: return 2;
|
|
|
|
default: ASSERT(FALSE); return 0;
|
|
|
|
}
|
2016-03-30 18:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
enum DisplayDepth SwitchToDepth(INDEX i)
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
switch (i) {
|
|
|
|
case 0: return DD_DEFAULT;
|
|
|
|
case 1: return DD_16BIT;
|
|
|
|
case 2: return DD_32BIT;
|
|
|
|
default: ASSERT(FALSE); return DD_DEFAULT;
|
|
|
|
}
|
2016-03-30 22:09:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// controls that are currently customized
|
|
|
|
CTFileName _fnmControlsToCustomize = CTString("");
|
|
|
|
|
|
|
|
void ControlsMenuOn()
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
_pGame->SavePlayersAndControls();
|
|
|
|
try {
|
2016-04-03 05:56:12 +02:00
|
|
|
_pGame->gm_ctrlControlsExtra->Load_t(_fnmControlsToCustomize);
|
2016-03-31 22:27:11 +02:00
|
|
|
}
|
|
|
|
catch (char *strError) {
|
|
|
|
WarningMessage(strError);
|
|
|
|
}
|
2016-03-30 22:09:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ControlsMenuOff()
|
|
|
|
{
|
2016-03-31 22:27:11 +02:00
|
|
|
try {
|
2016-04-03 05:56:12 +02:00
|
|
|
if (_pGame->gm_ctrlControlsExtra->ctrl_lhButtonActions.Count()>0) {
|
2016-04-04 08:34:07 +02:00
|
|
|
_pGame->gm_ctrlControlsExtra->Save_t(_fnmControlsToCustomize);
|
2016-03-31 22:27:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (char *strError) {
|
|
|
|
FatalError(strError);
|
|
|
|
}
|
2016-04-04 08:34:07 +02:00
|
|
|
|
|
|
|
_pGame->gm_ctrlControlsExtra->DeleteAllButtonActions();
|
|
|
|
|
2016-03-31 22:27:11 +02:00
|
|
|
_pGame->LoadPlayersAndControls();
|
2016-04-03 05:56:12 +02:00
|
|
|
}
|
|
|
|
|