2006-04-13 20:47:06 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
2016-02-07 02:38:08 +00:00
|
|
|
Copyright (C) 2016 EDuke32 developers and contributors
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-25 10:56:00 +00:00
|
|
|
This file is part of EDuke32.
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
EDuke32 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
|
2014-07-20 08:55:56 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-04-13 20:47:06 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2019-09-21 18:59:54 +00:00
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
#include "duke3d.h"
|
|
|
|
#include "scriplib.h"
|
2008-06-30 01:03:51 +00:00
|
|
|
#include "osdcmds.h"
|
2016-02-13 21:06:12 +00:00
|
|
|
#include "renderlayer.h"
|
2017-02-19 22:15:32 +00:00
|
|
|
#include "cmdline.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2019-03-01 08:51:50 +00:00
|
|
|
#include "vfs.h"
|
|
|
|
|
2018-06-14 21:25:20 +00:00
|
|
|
#if defined RENDERTYPESDL && defined SDL_TARGET && SDL_TARGET > 1
|
|
|
|
# include "sdl_inc.h"
|
2014-04-15 19:02:48 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
// we load this in to get default button and key assignments
|
|
|
|
// as well as setting up function mappings
|
|
|
|
|
|
|
|
#define __SETUP__ // JBF 20031211
|
|
|
|
#include "_functio.h"
|
|
|
|
|
2019-09-21 20:53:00 +00:00
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2019-08-13 09:15:49 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
void CONFIG_SetDefaults(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.scripthandle = -1;
|
2018-11-18 18:08:53 +00:00
|
|
|
|
2018-06-14 17:49:46 +00:00
|
|
|
# if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1
|
2018-02-26 14:46:52 +00:00
|
|
|
uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO);
|
|
|
|
if (inited == 0)
|
|
|
|
SDL_Init(SDL_INIT_VIDEO);
|
|
|
|
else if (!(inited & SDL_INIT_VIDEO))
|
|
|
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
|
|
|
|
|
|
SDL_DisplayMode dm;
|
|
|
|
if (SDL_GetDesktopDisplayMode(0, &dm) == 0)
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
ud.setup.xdim = dm.w;
|
|
|
|
ud.setup.ydim = dm.h;
|
2018-02-26 14:46:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
# endif
|
|
|
|
{
|
2018-11-18 18:13:02 +00:00
|
|
|
ud.setup.xdim = 1024;
|
|
|
|
ud.setup.ydim = 768;
|
2018-02-26 14:46:52 +00:00
|
|
|
}
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
ud.setup.bpp = 32;
|
2018-11-18 18:08:44 +00:00
|
|
|
|
2019-10-22 23:04:07 +00:00
|
|
|
|
|
|
|
ud.camera_time = 0;//4;
|
2014-04-17 20:00:24 +00:00
|
|
|
|
2018-11-18 18:08:44 +00:00
|
|
|
g_player[0].ps->aim_mode = 1;
|
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
ud.setup.fullscreen = 1;
|
|
|
|
|
2018-11-18 18:08:44 +00:00
|
|
|
ud.althud = 1;
|
|
|
|
ud.angleinterpolation = 0;
|
|
|
|
ud.brightness = 8;
|
|
|
|
ud.camerasprite = -1;
|
|
|
|
ud.color = 0;
|
|
|
|
ud.config.ShowWeapons = 0;
|
|
|
|
ud.default_skill = 1;
|
|
|
|
ud.detail = 0;
|
|
|
|
ud.display_bonus_screen = 1;
|
2019-10-22 23:04:07 +00:00
|
|
|
|
2019-10-23 23:30:33 +00:00
|
|
|
hud_position = 0;
|
2018-11-18 18:08:44 +00:00
|
|
|
ud.lockout = 0;
|
|
|
|
ud.m_marker = 1;
|
|
|
|
ud.menu_scrollbartilenum = -1;
|
|
|
|
ud.menu_scrollbarz = 65536;
|
|
|
|
ud.menu_scrollcursorz = 65536;
|
|
|
|
ud.menu_slidebarmargin = 65536;
|
|
|
|
ud.menu_slidebarz = 65536;
|
|
|
|
ud.menu_slidecursorz = 65536;
|
|
|
|
ud.menubackground = 1;
|
|
|
|
ud.pwlockout[0] = '\0';
|
|
|
|
ud.runkey_mode = 0;
|
|
|
|
ud.screen_size = 4;
|
|
|
|
ud.screen_tilting = 1;
|
|
|
|
ud.screenfade = 1;
|
|
|
|
ud.shadow_pal = 4;
|
|
|
|
ud.show_level_text = 1;
|
|
|
|
ud.slidebar_paldisabled = 1;
|
2019-10-22 21:31:46 +00:00
|
|
|
ud.statusbarflags = 0;//STATUSBAR_NOSHRINK;
|
2018-11-18 18:08:44 +00:00
|
|
|
ud.statusbarmode = 1;
|
|
|
|
ud.statusbarscale = 100;
|
|
|
|
ud.team = 0;
|
2009-03-14 02:55:39 +00:00
|
|
|
|
2018-02-16 08:33:44 +00:00
|
|
|
Bstrcpy(ud.rtsname, G_DefaultRtsFile());
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2017-06-24 21:18:18 +00:00
|
|
|
Bstrcpy(szPlayerName, "Player");
|
|
|
|
|
2017-12-12 05:13:46 +00:00
|
|
|
VM_OnEvent(EVENT_SETDEFAULTS, g_player[myconnectindex].ps->i, myconnectindex);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-18 18:08:44 +00:00
|
|
|
int CONFIG_ReadSetup(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-08-25 10:27:18 +00:00
|
|
|
char tempbuf[1024];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
CONFIG_SetDefaults();
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.setupread = 1;
|
2007-01-22 02:49:58 +00:00
|
|
|
pathsearchmode = 1;
|
2017-07-08 05:18:51 +00:00
|
|
|
|
|
|
|
if (ud.config.scripthandle < 0)
|
2008-08-12 12:50:20 +00:00
|
|
|
{
|
2019-03-01 08:51:50 +00:00
|
|
|
if (buildvfs_exists(g_setupFileName)) // JBF 20031211
|
2017-07-08 05:18:51 +00:00
|
|
|
ud.config.scripthandle = SCRIPT_Load(g_setupFileName);
|
|
|
|
#if !defined(EDUKE32_TOUCH_DEVICES) && !defined(EDUKE32_STANDALONE)
|
2019-03-01 08:51:50 +00:00
|
|
|
else if (buildvfs_exists(SETUPFILENAME))
|
2017-07-08 05:18:51 +00:00
|
|
|
{
|
2018-11-18 18:08:44 +00:00
|
|
|
int const i = wm_ynbox("Import Configuration Settings",
|
|
|
|
"The configuration file \"%s\" was not found. "
|
|
|
|
"Import configuration data from \"%s\"?",
|
|
|
|
g_setupFileName, SETUPFILENAME);
|
|
|
|
if (i)
|
|
|
|
ud.config.scripthandle = SCRIPT_Load(SETUPFILENAME);
|
2017-07-08 05:18:51 +00:00
|
|
|
}
|
2014-04-15 19:02:48 +00:00
|
|
|
#endif
|
2017-07-08 05:18:51 +00:00
|
|
|
}
|
2014-04-15 19:02:48 +00:00
|
|
|
|
2007-01-22 02:49:58 +00:00
|
|
|
pathsearchmode = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
if (ud.config.scripthandle < 0)
|
|
|
|
return -1;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
Bmemset(tempbuf, 0, sizeof(tempbuf));
|
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","PlayerName",&tempbuf[0]);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
char nameBuf[64];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
while (Bstrlen(OSD_StripColors(nameBuf, tempbuf)) > 10)
|
|
|
|
tempbuf[Bstrlen(tempbuf) - 1] = '\0';
|
2006-05-10 21:00:56 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
Bstrncpyz(szPlayerName, tempbuf, sizeof(szPlayerName));
|
2006-05-01 22:49:09 +00:00
|
|
|
|
2018-02-16 08:33:44 +00:00
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
if (g_noSetup == 0 && g_modDir[0] == '/')
|
|
|
|
{
|
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]);
|
2008-12-17 01:59:36 +00:00
|
|
|
|
2019-03-01 08:51:50 +00:00
|
|
|
if (!buildvfs_isdir(g_modDir))
|
2017-07-08 05:18:51 +00:00
|
|
|
{
|
2019-03-01 08:51:50 +00:00
|
|
|
initprintf("Invalid mod dir in cfg!\n");
|
|
|
|
Bsprintf(g_modDir,"/");
|
2008-12-17 01:59:36 +00:00
|
|
|
}
|
2017-07-08 05:18:51 +00:00
|
|
|
}
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
if (g_grpNamePtr == NULL && g_addonNum == 0)
|
|
|
|
{
|
2018-11-18 18:08:44 +00:00
|
|
|
SCRIPT_GetStringPtr(ud.config.scripthandle, "Setup", "SelectedGRP", &g_grpNamePtr);
|
2017-07-08 05:18:51 +00:00
|
|
|
if (g_grpNamePtr && !Bstrlen(g_grpNamePtr))
|
|
|
|
g_grpNamePtr = dup_filename(G_DefaultGrpFile());
|
|
|
|
}
|
2006-12-01 04:22:16 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
if (!NAM_WW2GI)
|
|
|
|
{
|
2018-11-18 18:08:44 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out", &ud.lockout);
|
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "Password", &ud.pwlockout[0]);
|
2017-07-08 05:18:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
windowx = -1;
|
|
|
|
windowy = -1;
|
2013-04-08 18:30:52 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", (int32_t *)&maxrefreshfreq);
|
2018-11-18 18:13:02 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight", &ud.setup.ydim);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode", &ud.setup.fullscreen);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth", &ud.setup.xdim);
|
2018-11-18 18:08:44 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32_t *)&windowx);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32_t *)&windowy);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32_t *)&windowpos);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-11-18 18:13:02 +00:00
|
|
|
if (ud.setup.bpp < 8) ud.setup.bpp = 32;
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.setupread = 1;
|
2006-07-01 01:40:18 +00:00
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-20 07:15:01 +00:00
|
|
|
void CONFIG_WriteSettings(void) // save binds and aliases to <cfgname>_settings.cfg
|
2008-06-29 12:29:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-14 05:25:27 +00:00
|
|
|
|
2015-12-20 05:18:59 +00:00
|
|
|
static const char *CONFIG_GetMapEntryName(char m[], char const * const mapname)
|
2006-10-23 21:47:28 +00:00
|
|
|
{
|
|
|
|
strcpy(m, mapname);
|
2015-05-16 14:27:01 +00:00
|
|
|
|
|
|
|
char *p = strrchr(m, '/');
|
2006-10-23 21:47:28 +00:00
|
|
|
if (!p) p = strrchr(m, '\\');
|
2015-05-16 14:27:01 +00:00
|
|
|
if (p) Bmemmove(m, p, Bstrlen(p)+1);
|
2009-02-19 16:47:54 +00:00
|
|
|
for (p=m; *p; p++) *p = tolower(*p);
|
2006-10-23 21:47:28 +00:00
|
|
|
|
2008-09-26 04:20:08 +00:00
|
|
|
// cheap hack because SCRIPT_GetNumber doesn't like the slashes
|
|
|
|
p = m;
|
|
|
|
while (*p == '/') p++;
|
|
|
|
|
2015-05-16 14:27:01 +00:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2015-12-20 05:18:59 +00:00
|
|
|
static void CONFIG_GetMD4EntryName(char m[], uint8_t const * const md4)
|
|
|
|
{
|
|
|
|
sprintf(m, "MD4_%08x%08x%08x%08x",
|
|
|
|
B_BIG32(B_UNBUF32(&md4[0])), B_BIG32(B_UNBUF32(&md4[4])),
|
|
|
|
B_BIG32(B_UNBUF32(&md4[8])), B_BIG32(B_UNBUF32(&md4[12])));
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CONFIG_GetMapBestTime(char const * const mapname, uint8_t const * const mapmd4)
|
2015-05-16 14:27:01 +00:00
|
|
|
{
|
2017-06-24 21:18:18 +00:00
|
|
|
if (!ud.config.setupread || ud.config.scripthandle < 0)
|
|
|
|
return -1;
|
2006-10-23 21:47:28 +00:00
|
|
|
|
2015-12-20 05:18:59 +00:00
|
|
|
char m[37];
|
2018-11-18 18:08:44 +00:00
|
|
|
|
2015-12-20 05:18:59 +00:00
|
|
|
CONFIG_GetMD4EntryName(m, mapmd4);
|
2015-05-16 14:27:01 +00:00
|
|
|
|
|
|
|
int32_t t = -1;
|
2015-12-20 05:18:59 +00:00
|
|
|
if (SCRIPT_GetNumber(ud.config.scripthandle, "MapTimes", m, &t))
|
|
|
|
{
|
|
|
|
// fall back to map filenames
|
|
|
|
char m2[BMAX_PATH];
|
2018-11-18 18:08:44 +00:00
|
|
|
auto p = CONFIG_GetMapEntryName(m2, mapname);
|
|
|
|
|
2015-12-20 05:18:59 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "MapTimes", p, &t);
|
|
|
|
}
|
2018-11-18 18:08:44 +00:00
|
|
|
|
2006-10-23 21:47:28 +00:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2018-11-18 18:08:44 +00:00
|
|
|
int CONFIG_SetMapBestTime(uint8_t const * const mapmd4, int32_t tm)
|
2006-10-23 21:47:28 +00:00
|
|
|
{
|
2018-11-18 18:08:44 +00:00
|
|
|
if (ud.config.scripthandle < 0 && (ud.config.scripthandle = SCRIPT_Init(g_setupFileName)) < 0)
|
|
|
|
return -1;
|
2006-10-23 21:47:28 +00:00
|
|
|
|
2015-12-20 05:18:59 +00:00
|
|
|
char m[37];
|
2015-05-16 14:27:01 +00:00
|
|
|
|
2018-11-18 18:08:44 +00:00
|
|
|
CONFIG_GetMD4EntryName(m, mapmd4);
|
2015-12-20 05:18:59 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "MapTimes", m, tm, FALSE, FALSE);
|
2018-11-18 18:08:44 +00:00
|
|
|
|
2006-10-23 21:47:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-09-21 20:53:00 +00:00
|
|
|
END_DUKE_NS
|