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
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#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
|
|
|
|
2014-04-15 19:02:48 +00:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
#include "android.h"
|
|
|
|
#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"
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
hashtable_t h_gamefuncs = { NUMGAMEFUNCTIONS<<1, NULL };
|
2008-08-25 02:33:25 +00:00
|
|
|
|
2012-07-01 22:11:33 +00:00
|
|
|
int32_t CONFIG_FunctionNameToNum(const char *func)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-12-18 18:16:16 +00:00
|
|
|
if (!func)
|
|
|
|
return -1;
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
i = hash_find(&h_gamefuncs,func);
|
2008-12-31 09:07:49 +00:00
|
|
|
|
|
|
|
if (i < 0)
|
|
|
|
{
|
2014-05-30 00:02:19 +00:00
|
|
|
char *str = Bstrtolower(Xstrdup(func));
|
2010-05-02 23:27:30 +00:00
|
|
|
i = hash_find(&h_gamefuncs,str);
|
2008-12-31 09:07:49 +00:00
|
|
|
Bfree(str);
|
|
|
|
|
2008-08-25 02:33:25 +00:00
|
|
|
return i;
|
2008-12-31 09:07:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
char *CONFIG_FunctionNumToName(int32_t func)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS)
|
|
|
|
return NULL;
|
2006-12-23 02:38:47 +00:00
|
|
|
return gamefunctions[func];
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-01 22:11:33 +00:00
|
|
|
int32_t CONFIG_AnalogNameToNum(const char *func)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2014-12-18 18:16:16 +00:00
|
|
|
if (!func)
|
|
|
|
return -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
if (!Bstrcasecmp(func,"analog_turning"))
|
|
|
|
{
|
|
|
|
return analog_turning;
|
|
|
|
}
|
|
|
|
if (!Bstrcasecmp(func,"analog_strafing"))
|
|
|
|
{
|
|
|
|
return analog_strafing;
|
|
|
|
}
|
|
|
|
if (!Bstrcasecmp(func,"analog_moving"))
|
|
|
|
{
|
|
|
|
return analog_moving;
|
|
|
|
}
|
|
|
|
if (!Bstrcasecmp(func,"analog_lookingupanddown"))
|
|
|
|
{
|
|
|
|
return analog_lookingupanddown;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-01 22:11:33 +00:00
|
|
|
const char *CONFIG_AnalogNumToName(int32_t func)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-15 01:16:55 +00:00
|
|
|
switch (func)
|
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case analog_turning:
|
|
|
|
return "analog_turning";
|
|
|
|
case analog_strafing:
|
|
|
|
return "analog_strafing";
|
|
|
|
case analog_moving:
|
|
|
|
return "analog_moving";
|
|
|
|
case analog_lookingupanddown:
|
|
|
|
return "analog_lookingupanddown";
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-08 22:09:00 +00:00
|
|
|
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN])
|
2007-02-13 09:50:58 +00:00
|
|
|
{
|
2008-06-30 09:00:33 +00:00
|
|
|
Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys));
|
2012-11-06 23:06:44 +00:00
|
|
|
|
2012-11-18 15:44:18 +00:00
|
|
|
CONTROL_ClearAllBinds();
|
2007-02-14 00:22:12 +00:00
|
|
|
|
2017-06-17 21:53:28 +00:00
|
|
|
for (size_t i=0; i < ARRAY_SIZE(gamefunctions); ++i)
|
2007-02-13 09:50:58 +00:00
|
|
|
{
|
2017-06-17 11:41:59 +00:00
|
|
|
if (gamefunctions[i][0] == '\0')
|
|
|
|
continue;
|
|
|
|
|
2017-06-17 21:53:28 +00:00
|
|
|
ud.config.KeyboardKeys[i][0] = KB_StringToScanCode(keyptr[i<<1]);
|
|
|
|
ud.config.KeyboardKeys[i][1] = KB_StringToScanCode(keyptr[(i<<1)+1]);
|
2007-02-13 09:50:58 +00:00
|
|
|
|
2017-06-17 21:53:28 +00:00
|
|
|
if (i == gamefunc_Show_Console)
|
|
|
|
OSD_CaptureKey(ud.config.KeyboardKeys[i][0]);
|
|
|
|
else
|
|
|
|
CONFIG_MapKey(i, ud.config.KeyboardKeys[i][0], 0, ud.config.KeyboardKeys[i][1], 0);
|
2007-02-13 09:50:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-26 14:46:52 +00:00
|
|
|
#if defined SDL_TARGET && SDL_TARGET > 1
|
|
|
|
# include "sdl_inc.h"
|
|
|
|
#endif
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
void CONFIG_SetDefaults(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
// JBF 20031211
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.scripthandle = -1;
|
2014-03-22 09:25:51 +00:00
|
|
|
#ifdef __ANDROID__
|
2015-02-11 05:22:32 +00:00
|
|
|
droidinput.forward_sens = 5.f;
|
|
|
|
droidinput.strafe_sens = 5.f;
|
|
|
|
droidinput.pitch_sens = 5.f;
|
|
|
|
droidinput.yaw_sens = 5.f;
|
|
|
|
droidinput.hideStick = 0;
|
|
|
|
droidinput.gameControlsAlpha = 0.5;
|
|
|
|
droidinput.toggleCrouch = 1;
|
|
|
|
droidinput.quickSelectWeapon = 1;
|
|
|
|
|
2014-04-13 03:20:17 +00:00
|
|
|
ud.config.ScreenWidth = droidinfo.screen_width;
|
|
|
|
ud.config.ScreenHeight = droidinfo.screen_height;
|
2014-03-22 09:25:51 +00:00
|
|
|
#else
|
2018-02-26 14:46:52 +00:00
|
|
|
# if defined SDL_MAJOR_VERSION && SDL_MAJOR_VERSION > 1
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
ud.config.ScreenWidth = dm.w;
|
|
|
|
ud.config.ScreenHeight = dm.h;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
# endif
|
|
|
|
{
|
|
|
|
ud.config.ScreenWidth = 1024;
|
|
|
|
ud.config.ScreenHeight = 768;
|
|
|
|
}
|
2014-03-22 09:25:51 +00:00
|
|
|
#endif
|
|
|
|
|
2018-02-26 14:46:52 +00:00
|
|
|
ud.config.ScreenMode = 1;
|
2014-03-22 09:25:51 +00:00
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2008-02-18 08:10:54 +00:00
|
|
|
ud.config.ScreenBPP = 32;
|
|
|
|
#else
|
|
|
|
ud.config.ScreenBPP = 8;
|
|
|
|
#endif
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.useprecache = 1;
|
|
|
|
ud.config.ForceSetup = 1;
|
2009-05-22 23:49:25 +00:00
|
|
|
ud.config.NoAutoLoad = 1;
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.AmbienceToggle = 1;
|
|
|
|
ud.config.AutoAim = 1;
|
2013-08-06 23:53:55 +00:00
|
|
|
ud.config.MasterVolume = 255;
|
2010-06-07 09:03:16 +00:00
|
|
|
ud.config.FXVolume = 225;
|
2008-06-30 07:30:48 +00:00
|
|
|
#if defined(_WIN32)
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MixRate = 44100;
|
2014-04-13 03:20:17 +00:00
|
|
|
#elif defined __ANDROID__
|
|
|
|
ud.config.MixRate = droidinfo.audio_sample_rate;
|
2008-06-30 07:30:48 +00:00
|
|
|
#else
|
|
|
|
ud.config.MixRate = 48000;
|
|
|
|
#endif
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MouseBias = 0;
|
2008-10-13 01:16:40 +00:00
|
|
|
ud.config.MouseDeadZone = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MusicToggle = 1;
|
2010-06-07 09:03:16 +00:00
|
|
|
ud.config.MusicVolume = 195;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_myAimMode = g_player[0].ps->aim_mode = 1;
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.NumBits = 16;
|
|
|
|
ud.config.NumChannels = 2;
|
2017-07-27 09:13:09 +00:00
|
|
|
#if defined GEKKO || defined __OPENDINGUX__
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.NumVoices = 32;
|
2017-07-27 09:13:09 +00:00
|
|
|
#else
|
|
|
|
ud.config.NumVoices = 256;
|
|
|
|
#endif
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.ReverseStereo = 0;
|
2010-05-19 10:02:35 +00:00
|
|
|
ud.auto_run = 1;
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.ShowOpponentWeapons = 0;
|
|
|
|
ud.config.SmoothInput = 1;
|
|
|
|
ud.config.SoundToggle = 1;
|
2008-08-07 07:52:36 +00:00
|
|
|
ud.althud = 1;
|
2006-05-09 23:55:42 +00:00
|
|
|
ud.automsg = 0;
|
|
|
|
ud.autovote = 0;
|
2006-07-18 21:08:38 +00:00
|
|
|
ud.brightness = 8;
|
2007-08-31 06:18:56 +00:00
|
|
|
ud.camerasprite = -1;
|
2014-04-17 20:00:24 +00:00
|
|
|
|
2014-10-25 03:33:38 +00:00
|
|
|
#if defined GEKKO || defined __OPENDINGUX__
|
2014-04-17 20:00:24 +00:00
|
|
|
ud.camera_time = 11;
|
2015-02-11 05:22:32 +00:00
|
|
|
#elif defined(__ANDROID__)
|
|
|
|
ud.camera_time = 7;
|
2014-04-17 20:00:24 +00:00
|
|
|
#else
|
2014-10-25 03:33:38 +00:00
|
|
|
ud.camera_time = 4;
|
2014-04-17 20:00:24 +00:00
|
|
|
#endif
|
|
|
|
|
2006-05-09 23:55:42 +00:00
|
|
|
ud.color = 0;
|
2008-07-21 09:05:53 +00:00
|
|
|
ud.crosshair = 1;
|
|
|
|
ud.crosshairscale = 50;
|
2008-07-31 10:35:23 +00:00
|
|
|
ud.obituaries = 1;
|
2006-05-09 23:55:42 +00:00
|
|
|
ud.democams = 1;
|
2016-11-01 01:35:24 +00:00
|
|
|
ud.detail = 0;
|
2006-05-09 23:55:42 +00:00
|
|
|
ud.drawweapon = 1;
|
|
|
|
ud.idplayers = 1;
|
|
|
|
ud.levelstats = 0;
|
|
|
|
ud.lockout = 0;
|
|
|
|
ud.m_ffire = 1;
|
|
|
|
ud.m_marker = 1;
|
2018-01-26 04:35:02 +00:00
|
|
|
ud.menu_slidebarz = 65536;
|
|
|
|
ud.menu_slidebarmargin = 65536;
|
|
|
|
ud.menu_slidecursorz = 65536;
|
2006-04-13 20:47:06 +00:00
|
|
|
ud.mouseaiming = 0;
|
2006-04-25 01:56:24 +00:00
|
|
|
ud.mouseflip = 1;
|
2006-05-09 23:55:42 +00:00
|
|
|
ud.msgdisptime = 120;
|
|
|
|
ud.pwlockout[0] = '\0';
|
2006-04-13 20:47:06 +00:00
|
|
|
ud.runkey_mode = 0;
|
2006-04-25 01:56:24 +00:00
|
|
|
ud.screen_size = 4;
|
2006-04-13 20:47:06 +00:00
|
|
|
ud.screen_tilting = 1;
|
|
|
|
ud.shadows = 1;
|
2018-01-26 04:34:51 +00:00
|
|
|
ud.statusbarflags = STATUSBAR_NOSHRINK;
|
2013-01-17 21:59:11 +00:00
|
|
|
ud.statusbarmode = 1;
|
2008-11-26 02:43:47 +00:00
|
|
|
ud.statusbarscale = 100;
|
2006-08-18 23:52:26 +00:00
|
|
|
ud.team = 0;
|
2007-02-23 22:27:22 +00:00
|
|
|
ud.viewbob = 1;
|
|
|
|
ud.weaponsway = 1;
|
2006-05-09 23:55:42 +00:00
|
|
|
ud.weaponswitch = 3; // new+empty
|
2007-03-24 23:17:56 +00:00
|
|
|
ud.angleinterpolation = 0;
|
2012-05-06 20:23:20 +00:00
|
|
|
#ifdef GEKKO
|
|
|
|
ud.config.UseJoystick = 1;
|
|
|
|
#else
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.UseJoystick = 0;
|
2012-05-06 20:23:20 +00:00
|
|
|
#endif
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.UseMouse = 1;
|
2008-07-28 21:23:10 +00:00
|
|
|
ud.config.VoiceToggle = 5; // bitfield, 1 = local, 2 = dummy, 4 = other players in DM
|
2008-08-19 11:05:21 +00:00
|
|
|
ud.display_bonus_screen = 1;
|
2008-09-29 02:12:53 +00:00
|
|
|
ud.show_level_text = 1;
|
2008-08-20 08:39:07 +00:00
|
|
|
ud.configversion = 0;
|
2008-10-05 11:51:59 +00:00
|
|
|
ud.weaponscale = 100;
|
2017-06-23 09:17:07 +00:00
|
|
|
ud.textscale = 200;
|
2017-12-12 05:13:53 +00:00
|
|
|
ud.screenfade = 1;
|
2018-01-26 04:34:43 +00:00
|
|
|
ud.menubackground = 1;
|
2018-01-26 04:34:57 +00:00
|
|
|
ud.hudontop = 0;
|
2018-01-26 04:35:33 +00:00
|
|
|
ud.default_skill = 1;
|
2018-01-29 02:14:16 +00:00
|
|
|
ud.slidebar_paldisabled = 1;
|
2018-01-29 11:14:17 +00:00
|
|
|
ud.shadow_pal = 4;
|
2018-02-22 13:34:34 +00:00
|
|
|
ud.menu_scrollbartilenum = -1;
|
|
|
|
ud.menu_scrollbarz = 65536;
|
|
|
|
ud.menu_scrollcursorz = 65536;
|
2006-05-01 06:30:33 +00:00
|
|
|
|
2009-03-14 02:55:39 +00:00
|
|
|
ud.config.CheckForUpdates = 1;
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
#ifndef EDUKE32_STANDALONE
|
2006-04-13 20:47:06 +00:00
|
|
|
Bstrcpy(ud.ridecule[0], "An inspiration for birth control.");
|
|
|
|
Bstrcpy(ud.ridecule[1], "You're gonna die for that!");
|
|
|
|
Bstrcpy(ud.ridecule[2], "It hurts to be you.");
|
2014-05-17 12:36:40 +00:00
|
|
|
Bstrcpy(ud.ridecule[3], "Lucky son of a bitch.");
|
|
|
|
Bstrcpy(ud.ridecule[4], "Hmmm... payback time.");
|
2006-04-13 20:47:06 +00:00
|
|
|
Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker.");
|
|
|
|
Bstrcpy(ud.ridecule[6], "Damn, you're ugly.");
|
2014-05-17 12:36:40 +00:00
|
|
|
Bstrcpy(ud.ridecule[7], "Ha ha ha... wasted!");
|
2006-04-13 20:47:06 +00:00
|
|
|
Bstrcpy(ud.ridecule[8], "You suck!");
|
|
|
|
Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!");
|
2017-06-24 21:18:18 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
// JBF 20031211
|
2006-04-25 05:01:27 +00:00
|
|
|
|
2017-06-17 11:41:54 +00:00
|
|
|
CONFIG_SetDefaultKeys(keydefaults);
|
2007-02-23 22:27:22 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
memset(ud.config.MouseFunctions, -1, sizeof(ud.config.MouseFunctions));
|
2006-11-15 01:16:55 +00:00
|
|
|
for (i=0; i<MAXMOUSEBUTTONS; i++)
|
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]);
|
|
|
|
CONTROL_MapButton(ud.config.MouseFunctions[i][0], i, 0, controldevice_mouse);
|
2006-04-25 22:50:57 +00:00
|
|
|
if (i>=4) continue;
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MouseFunctions[i][1] = CONFIG_FunctionNameToNum(mouseclickeddefaults[i]);
|
|
|
|
CONTROL_MapButton(ud.config.MouseFunctions[i][1], i, 1, controldevice_mouse);
|
2006-04-25 05:01:27 +00:00
|
|
|
}
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
memset(ud.config.MouseDigitalFunctions, -1, sizeof(ud.config.MouseDigitalFunctions));
|
2006-11-15 01:16:55 +00:00
|
|
|
for (i=0; i<MAXMOUSEAXES; i++)
|
|
|
|
{
|
2012-06-03 16:11:22 +00:00
|
|
|
ud.config.MouseAnalogueScale[i] = DEFAULTMOUSEANALOGUESCALE;
|
2007-08-27 00:20:15 +00:00
|
|
|
CONTROL_SetAnalogAxisScale(i, ud.config.MouseAnalogueScale[i], controldevice_mouse);
|
2006-04-25 05:01:27 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i*2]);
|
|
|
|
ud.config.MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i*2+1]);
|
|
|
|
CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][0], 0, controldevice_mouse);
|
|
|
|
CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][1], 1, controldevice_mouse);
|
2006-04-25 05:01:27 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(mouseanalogdefaults[i]);
|
|
|
|
CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
|
2006-04-25 05:01:27 +00:00
|
|
|
}
|
2009-04-29 19:43:51 +00:00
|
|
|
CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY;
|
2006-04-25 05:01:27 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
memset(ud.config.JoystickFunctions, -1, sizeof(ud.config.JoystickFunctions));
|
2014-12-18 18:15:51 +00:00
|
|
|
for (i=0; i<MAXJOYBUTTONSANDHATS; i++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdefaults[i]);
|
|
|
|
ud.config.JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(joystickclickeddefaults[i]);
|
|
|
|
CONTROL_MapButton(ud.config.JoystickFunctions[i][0], i, 0, controldevice_joystick);
|
|
|
|
CONTROL_MapButton(ud.config.JoystickFunctions[i][1], i, 1, controldevice_joystick);
|
2006-04-25 05:01:27 +00:00
|
|
|
}
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
memset(ud.config.JoystickDigitalFunctions, -1, sizeof(ud.config.JoystickDigitalFunctions));
|
2006-11-15 01:16:55 +00:00
|
|
|
for (i=0; i<MAXJOYAXES; i++)
|
|
|
|
{
|
2012-06-03 16:11:22 +00:00
|
|
|
ud.config.JoystickAnalogueScale[i] = DEFAULTJOYSTICKANALOGUESCALE;
|
|
|
|
ud.config.JoystickAnalogueDead[i] = DEFAULTJOYSTICKANALOGUEDEAD;
|
|
|
|
ud.config.JoystickAnalogueSaturate[i] = DEFAULTJOYSTICKANALOGUESATURATE;
|
2007-08-27 00:20:15 +00:00
|
|
|
CONTROL_SetAnalogAxisScale(i, ud.config.JoystickAnalogueScale[i], controldevice_joystick);
|
2007-08-26 10:35:52 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdigitaldefaults[i*2]);
|
|
|
|
ud.config.JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(joystickdigitaldefaults[i*2+1]);
|
|
|
|
CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][0], 0, controldevice_joystick);
|
|
|
|
CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][1], 1, controldevice_joystick);
|
2007-08-26 10:35:52 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(joystickanalogdefaults[i]);
|
|
|
|
CONTROL_MapAnalogAxis(i, ud.config.JoystickAnalogueAxes[i], controldevice_joystick);
|
2006-04-25 05:01:27 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-04 01:15:32 +00:00
|
|
|
// wrapper for CONTROL_MapKey(), generates key bindings to reflect changes to keyboard setup
|
2009-04-26 05:57:42 +00:00
|
|
|
void CONFIG_MapKey(int32_t which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2)
|
2008-06-30 09:00:33 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, k;
|
|
|
|
int32_t ii[] = { key1, key2, oldkey1, oldkey2 };
|
2012-11-18 15:44:18 +00:00
|
|
|
char buf[2*MAXGAMEFUNCLEN];
|
2008-06-30 09:00:33 +00:00
|
|
|
|
2012-11-06 23:06:34 +00:00
|
|
|
UNREFERENCED_PARAMETER(which);
|
|
|
|
// CONTROL_MapKey(which, key1, key2);
|
2008-06-30 11:01:58 +00:00
|
|
|
|
2012-11-08 17:00:31 +00:00
|
|
|
if (which == gamefunc_Show_Console)
|
|
|
|
OSD_CaptureKey(key1);
|
|
|
|
|
2014-03-22 09:25:15 +00:00
|
|
|
for (k = 0; (unsigned)k < ARRAY_SIZE(ii); k++)
|
2008-06-30 09:00:33 +00:00
|
|
|
{
|
2012-11-18 15:44:18 +00:00
|
|
|
if (ii[k] == 0xff || !ii[k])
|
|
|
|
continue;
|
2008-07-04 01:15:32 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; ConsoleKeys[j].name; j++)
|
2009-01-10 07:38:50 +00:00
|
|
|
if (ii[k] == ConsoleKeys[j].id)
|
2008-06-30 09:00:33 +00:00
|
|
|
break;
|
2012-11-17 16:47:58 +00:00
|
|
|
|
2008-07-04 01:15:32 +00:00
|
|
|
tempbuf[0] = 0;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=NUMGAMEFUNCTIONS-1; i>=0; i--)
|
2008-06-30 11:01:58 +00:00
|
|
|
{
|
2008-07-04 01:15:32 +00:00
|
|
|
if (ud.config.KeyboardKeys[i][0] == ii[k] || ud.config.KeyboardKeys[i][1] == ii[k])
|
|
|
|
{
|
|
|
|
Bsprintf(buf,"gamefunc_%s; ",CONFIG_FunctionNumToName(i));
|
|
|
|
Bstrcat(tempbuf,buf);
|
|
|
|
}
|
2008-06-30 11:01:58 +00:00
|
|
|
}
|
2012-03-28 19:43:21 +00:00
|
|
|
|
2012-11-18 15:44:18 +00:00
|
|
|
i = Bstrlen(tempbuf);
|
|
|
|
if (i >= 2)
|
|
|
|
{
|
|
|
|
tempbuf[i-2] = 0; // cut off the trailing "; "
|
|
|
|
CONTROL_BindKey(ii[k], tempbuf, 1, ConsoleKeys[j].name ? ConsoleKeys[j].name : "<?>");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CONTROL_FreeKeyBind(ii[k]);
|
|
|
|
}
|
2008-06-30 09:00:33 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
void CONFIG_SetupMouse(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t i;
|
2006-04-22 22:33:52 +00:00
|
|
|
char str[80];
|
2006-04-13 20:47:06 +00:00
|
|
|
char temp[80];
|
2009-04-29 19:43:51 +00:00
|
|
|
int32_t scale;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.scripthandle < 0) return;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXMOUSEBUTTONS; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"MouseButton%d",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
|
2008-06-01 01:57:01 +00:00
|
|
|
ud.config.MouseFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"MouseButtonClicked%d",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
|
2008-06-01 01:57:01 +00:00
|
|
|
ud.config.MouseFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// map over the axes
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXMOUSEAXES; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"MouseAnalogAxes%d",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
|
2006-12-17 21:20:35 +00:00
|
|
|
if (CONFIG_AnalogNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"MouseDigitalAxes%d_0",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
|
2006-12-17 21:20:35 +00:00
|
|
|
if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"MouseDigitalAxes%d_1",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
|
2006-12-17 21:20:35 +00:00
|
|
|
if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"MouseAnalogScale%d",i);
|
2007-08-27 00:20:15 +00:00
|
|
|
scale = ud.config.MouseAnalogueScale[i];
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
|
|
|
|
ud.config.MouseAnalogueScale[i] = scale;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-04-29 19:43:51 +00:00
|
|
|
{
|
|
|
|
tempbuf[0] = 0;
|
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Controls","Mouse_Sensitivity",&tempbuf[0]);
|
|
|
|
if (tempbuf[0]) CONTROL_MouseSensitivity = atof(tempbuf);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
for (i=0; i<MAXMOUSEBUTTONS; i++)
|
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
CONTROL_MapButton(ud.config.MouseFunctions[i][0], i, 0, controldevice_mouse);
|
|
|
|
CONTROL_MapButton(ud.config.MouseFunctions[i][1], i, 1, controldevice_mouse);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<MAXMOUSEAXES; i++)
|
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
|
|
|
|
CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][0], 0,controldevice_mouse);
|
|
|
|
CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][1], 1,controldevice_mouse);
|
|
|
|
CONTROL_SetAnalogAxisScale(i, ud.config.MouseAnalogueScale[i], controldevice_mouse);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
void CONFIG_SetupJoystick(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t i;
|
2006-04-22 22:33:52 +00:00
|
|
|
char str[80];
|
2006-04-13 20:47:06 +00:00
|
|
|
char temp[80];
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t scale;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.scripthandle < 0) return;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-12-18 18:15:51 +00:00
|
|
|
for (i=0; i<MAXJOYBUTTONSANDHATS; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"JoystickButton%d",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
|
2008-06-01 01:57:01 +00:00
|
|
|
ud.config.JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"JoystickButtonClicked%d",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle,"Controls", str,temp))
|
2008-06-01 01:57:01 +00:00
|
|
|
ud.config.JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// map over the axes
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXJOYAXES; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"JoystickAnalogAxes%d",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
|
2006-12-17 21:20:35 +00:00
|
|
|
if (CONFIG_AnalogNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"JoystickDigitalAxes%d_0",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
|
2006-12-17 21:20:35 +00:00
|
|
|
if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"JoystickDigitalAxes%d_1",i);
|
2006-11-15 01:16:55 +00:00
|
|
|
temp[0] = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp))
|
2006-12-17 21:20:35 +00:00
|
|
|
if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1))
|
2007-08-27 00:20:15 +00:00
|
|
|
ud.config.JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"JoystickAnalogScale%d",i);
|
2007-08-27 00:20:15 +00:00
|
|
|
scale = ud.config.JoystickAnalogueScale[i];
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
|
|
|
|
ud.config.JoystickAnalogueScale[i] = scale;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"JoystickAnalogDead%d",i);
|
2007-08-27 00:20:15 +00:00
|
|
|
scale = ud.config.JoystickAnalogueDead[i];
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
|
|
|
|
ud.config.JoystickAnalogueDead[i] = scale;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(str,"JoystickAnalogSaturate%d",i);
|
2007-08-27 00:20:15 +00:00
|
|
|
scale = ud.config.JoystickAnalogueSaturate[i];
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Controls", str,&scale);
|
|
|
|
ud.config.JoystickAnalogueSaturate[i] = scale;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2014-12-18 18:15:51 +00:00
|
|
|
for (i=0; i<MAXJOYBUTTONSANDHATS; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
CONTROL_MapButton(ud.config.JoystickFunctions[i][0], i, 0, controldevice_joystick);
|
|
|
|
CONTROL_MapButton(ud.config.JoystickFunctions[i][1], i, 1, controldevice_joystick);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXJOYAXES; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
CONTROL_MapAnalogAxis(i, ud.config.JoystickAnalogueAxes[i], controldevice_joystick);
|
|
|
|
CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][0], 0, controldevice_joystick);
|
|
|
|
CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][1], 1, controldevice_joystick);
|
|
|
|
CONTROL_SetAnalogAxisScale(i, ud.config.JoystickAnalogueScale[i], controldevice_joystick);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-12 00:51:50 +00:00
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t CONFIG_ReadSetup(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-01-12 10:31:19 +00:00
|
|
|
int32_t dummy;
|
2006-04-13 20:47:06 +00:00
|
|
|
char commmacro[] = "CommbatMacro# ";
|
2008-08-25 10:27:18 +00:00
|
|
|
char tempbuf[1024];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
CONTROL_ClearAssignments();
|
|
|
|
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
|
|
|
{
|
2017-07-08 05:18:51 +00:00
|
|
|
if (SafeFileExists(g_setupFileName)) // JBF 20031211
|
|
|
|
ud.config.scripthandle = SCRIPT_Load(g_setupFileName);
|
|
|
|
#if !defined(EDUKE32_TOUCH_DEVICES) && !defined(EDUKE32_STANDALONE)
|
|
|
|
else if (SafeFileExists(SETUPFILENAME))
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
else if (SafeFileExists("duke3d.cfg"))
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. "
|
|
|
|
"Import configuration data from \"duke3d.cfg\"?", g_setupFileName);
|
|
|
|
if (i) ud.config.scripthandle = SCRIPT_Load("duke3d.cfg");
|
|
|
|
}
|
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
|
|
|
for (dummy = 0; dummy < MAXRIDECULE; dummy++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2017-07-08 05:18:51 +00:00
|
|
|
commmacro[13] = dummy+'0';
|
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
|
|
|
|
}
|
2008-10-14 08:40:59 +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
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ConfigVersion", &ud.configversion);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup", &ud.config.ForceSetup);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", &ud.config.NoAutoLoad);
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
if (g_noSetup == 0 && g_modDir[0] == '/')
|
|
|
|
{
|
|
|
|
struct Bstat st;
|
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]);
|
2008-12-17 01:59:36 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
if (Bstat(g_modDir, &st))
|
|
|
|
{
|
|
|
|
if ((st.st_mode & S_IFDIR) != S_IFDIR)
|
2008-12-17 01:59:36 +00:00
|
|
|
{
|
2017-07-08 05:18:51 +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)
|
|
|
|
{
|
|
|
|
SCRIPT_GetStringPtr(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out",&ud.lockout);
|
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Screen Setup","Password",&ud.pwlockout[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",&ud.config.ScreenHeight);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",&ud.config.ScreenMode);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",&ud.config.ScreenWidth);
|
2006-07-22 23:02:08 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32_t *)&windowpos);
|
2008-10-01 04:38:14 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
windowx = -1;
|
|
|
|
windowy = -1;
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32_t *)&windowx);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32_t *)&windowy);
|
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);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
if (ud.config.ScreenBPP < 8) ud.config.ScreenBPP = 32;
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
#ifdef POLYMER
|
2017-07-08 05:18:51 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Polymer", &dummy);
|
|
|
|
if (dummy > 0 && ud.config.ScreenBPP >= 16) glrendmode = REND_POLYMER;
|
|
|
|
else glrendmode = REND_POLYMOST;
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2006-08-07 19:57:53 +00:00
|
|
|
|
2017-07-08 05:18:51 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions);
|
2010-01-24 23:33:17 +00:00
|
|
|
|
2006-12-18 08:37:12 +00:00
|
|
|
#ifdef _WIN32
|
2017-07-08 05:18:51 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", &ud.config.CheckForUpdates);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", &ud.config.LastUpdateCheck);
|
2006-12-14 03:34:55 +00:00
|
|
|
#endif
|
2008-08-08 05:03:56 +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
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2012-06-03 16:08:27 +00:00
|
|
|
BFILE *fp;
|
2016-08-27 01:42:01 +00:00
|
|
|
char *ptr = Xstrdup(g_setupFileName);
|
2008-08-25 10:27:18 +00:00
|
|
|
char tempbuf[128];
|
2008-08-12 12:50:20 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (!Bstrcmp(g_setupFileName, SETUPFILENAME))
|
2010-05-02 23:27:30 +00:00
|
|
|
Bsprintf(tempbuf, "settings.cfg");
|
|
|
|
else Bsprintf(tempbuf, "%s_settings.cfg", strtok(ptr, "."));
|
|
|
|
|
2012-06-03 16:08:27 +00:00
|
|
|
fp = Bfopen(tempbuf, "wt");
|
2008-06-29 12:29:42 +00:00
|
|
|
|
|
|
|
if (fp)
|
|
|
|
{
|
2017-07-05 05:42:54 +00:00
|
|
|
Bfprintf(fp,"// this file is automatically generated by %s\n", AppProperName);
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfprintf(fp,"unbindall\n");
|
2010-05-07 20:45:40 +00:00
|
|
|
|
2017-07-05 05:42:54 +00:00
|
|
|
for (i=0; i<MAXBOUNDKEYS+MAXMOUSEBUTTONS; i++)
|
2012-11-18 15:44:18 +00:00
|
|
|
if (CONTROL_KeyIsBound(i))
|
2012-11-17 16:47:58 +00:00
|
|
|
Bfprintf(fp,"bind \"%s\"%s \"%s\"\n",CONTROL_KeyBinds[i].key,
|
|
|
|
CONTROL_KeyBinds[i].repeat?"":" norepeat",CONTROL_KeyBinds[i].cmdstr);
|
2008-06-30 00:18:59 +00:00
|
|
|
|
2013-12-24 09:44:24 +00:00
|
|
|
OSD_WriteAliases(fp);
|
2015-10-20 07:15:01 +00:00
|
|
|
|
2016-12-26 06:01:24 +00:00
|
|
|
if (g_crosshairSum != -1 && g_crosshairSum != DefaultCrosshairColors.r+(DefaultCrosshairColors.g<<8)+(DefaultCrosshairColors.b<<16))
|
2015-10-20 07:15:01 +00:00
|
|
|
Bfprintf(fp, "crosshaircolor %d %d %d\n", CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
|
|
|
|
|
2009-04-30 21:09:44 +00:00
|
|
|
OSD_WriteCvars(fp);
|
2013-12-24 09:44:24 +00:00
|
|
|
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfclose(fp);
|
2013-12-24 09:44:24 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (!Bstrcmp(g_setupFileName, SETUPFILENAME))
|
2010-12-19 22:47:10 +00:00
|
|
|
OSD_Printf("Wrote settings.cfg\n");
|
|
|
|
else OSD_Printf("Wrote %s_settings.cfg\n",ptr);
|
|
|
|
|
2008-08-12 12:50:20 +00:00
|
|
|
Bfree(ptr);
|
2008-07-08 04:52:39 +00:00
|
|
|
return;
|
2008-06-29 12:29:42 +00:00
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (!Bstrcmp(g_setupFileName, SETUPFILENAME))
|
2010-12-19 22:47:10 +00:00
|
|
|
OSD_Printf("Error writing settings.cfg: %s\n", strerror(errno));
|
|
|
|
else OSD_Printf("Error writing %s_settings.cfg: %s\n",ptr,strerror(errno));
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2008-08-12 12:50:20 +00:00
|
|
|
Bfree(ptr);
|
2008-06-29 12:29:42 +00:00
|
|
|
}
|
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
void CONFIG_WriteSetup(uint32_t flags)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t dummy;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!ud.config.setupread) return;
|
|
|
|
|
|
|
|
if (ud.config.scripthandle < 0)
|
2016-08-27 01:42:01 +00:00
|
|
|
ud.config.scripthandle = SCRIPT_Init(g_setupFileName);
|
2007-08-27 00:20:15 +00:00
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions",++ud.executions,FALSE,FALSE);
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2016-01-21 19:35:30 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Setup","ConfigVersion",BYTEVERSION_EDUKE32,FALSE,FALSE);
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup",ud.config.ForceSetup,FALSE,FALSE);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "NoAutoLoad",ud.config.NoAutoLoad,FALSE,FALSE);
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2013-05-17 03:44:09 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Polymer",glrendmode == REND_POLYMER,FALSE,FALSE);
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP",ud.config.ScreenBPP,FALSE,FALSE); // JBF 20040523
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",ud.config.ScreenHeight,FALSE,FALSE); // JBF 20031206
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",ud.config.ScreenMode,FALSE,FALSE); // JBF 20031206
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",ud.config.ScreenWidth,FALSE,FALSE); // JBF 20031206
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2016-08-27 01:41:33 +00:00
|
|
|
if (g_grpNamePtr && !g_addonNum)
|
2013-03-29 15:59:17 +00:00
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Setup","SelectedGRP",g_grpNamePtr);
|
2011-03-04 08:50:58 +00:00
|
|
|
|
2017-06-24 21:18:18 +00:00
|
|
|
#ifdef STARTUP_SETUP_WINDOW
|
2011-03-04 08:50:58 +00:00
|
|
|
if (g_noSetup == 0)
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]);
|
2012-08-24 18:55:06 +00:00
|
|
|
#endif
|
2011-03-04 08:50:58 +00:00
|
|
|
// exit early after only updating the values that can be changed from the startup window
|
|
|
|
if (flags & 1)
|
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
SCRIPT_Save(ud.config.scripthandle, g_setupFileName);
|
2011-03-04 08:50:58 +00:00
|
|
|
SCRIPT_Free(ud.config.scripthandle);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", windowpos, FALSE, FALSE);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", windowx, FALSE, FALSE);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, FALSE, FALSE);
|
2013-04-08 18:30:52 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", maxrefreshfreq, FALSE, FALSE);
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2015-11-25 12:08:24 +00:00
|
|
|
if (!NAM_WW2GI)
|
2011-03-04 08:50:58 +00:00
|
|
|
{
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Out",ud.lockout,FALSE,FALSE);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "Password",ud.pwlockout);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-12-14 03:34:55 +00:00
|
|
|
#ifdef _WIN32
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", ud.config.CheckForUpdates, FALSE, FALSE);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", ud.config.LastUpdateCheck, FALSE, FALSE);
|
2006-12-14 03:34:55 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (ud.config.UseMouse)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2015-03-24 00:39:52 +00:00
|
|
|
for (dummy=0; dummy<MAXMOUSEBUTTONS; dummy++)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][0]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "MouseButton%d", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][0]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (dummy >= (MAXMOUSEBUTTONS-2)) continue;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][1]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "MouseButtonClicked%d", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][1]));
|
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
}
|
2008-02-02 16:38:30 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
for (dummy=0; dummy<MAXMOUSEAXES; dummy++)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_AnalogNumToName(ud.config.MouseAnalogueAxes[dummy]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "MouseAnalogAxes%d", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_AnalogNumToName(ud.config.MouseAnalogueAxes[dummy]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[dummy][0]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "MouseDigitalAxes%d_0", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[dummy][0]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[dummy][1]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "MouseDigitalAxes%d_1", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseDigitalFunctions[dummy][1]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (ud.config.MouseAnalogueScale[dummy] != DEFAULTMOUSEANALOGUESCALE)
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "MouseAnalogScale%d", dummy);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.MouseAnalogueScale[dummy], FALSE, FALSE);
|
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2009-04-29 19:43:51 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (ud.config.UseJoystick)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2015-03-24 00:39:52 +00:00
|
|
|
for (dummy=0; dummy<MAXJOYBUTTONSANDHATS; dummy++)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_FunctionNumToName(ud.config.JoystickFunctions[dummy][0]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "JoystickButton%d", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickFunctions[dummy][0]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_FunctionNumToName(ud.config.JoystickFunctions[dummy][1]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "JoystickButtonClicked%d", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickFunctions[dummy][1]));
|
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
}
|
2015-03-24 00:39:52 +00:00
|
|
|
for (dummy=0; dummy<MAXJOYAXES; dummy++)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_AnalogNumToName(ud.config.JoystickAnalogueAxes[dummy]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "JoystickAnalogAxes%d", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_AnalogNumToName(ud.config.JoystickAnalogueAxes[dummy]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[dummy][0]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "JoystickDigitalAxes%d_0", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[dummy][0]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[dummy][1]))
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "JoystickDigitalAxes%d_1", dummy);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(ud.config.JoystickDigitalFunctions[dummy][1]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (ud.config.JoystickAnalogueScale[dummy] != DEFAULTJOYSTICKANALOGUESCALE)
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "JoystickAnalogScale%d", dummy);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueScale[dummy], FALSE, FALSE);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (ud.config.JoystickAnalogueDead[dummy] != DEFAULTJOYSTICKANALOGUEDEAD)
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "JoystickAnalogDead%d", dummy);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueDead[dummy], FALSE, FALSE);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
if (ud.config.JoystickAnalogueSaturate[dummy] != DEFAULTJOYSTICKANALOGUESATURATE)
|
|
|
|
{
|
|
|
|
Bsprintf(buf, "JoystickAnalogSaturate%d", dummy);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueSaturate[dummy], FALSE, FALSE);
|
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","PlayerName",&szPlayerName[0]);
|
2015-03-24 00:39:52 +00:00
|
|
|
|
2018-02-16 08:33:44 +00:00
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
|
2007-02-13 09:50:58 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
char commmacro[] = "CommbatMacro# ";
|
2006-04-22 06:10:28 +00:00
|
|
|
|
2015-03-24 00:39:52 +00:00
|
|
|
for (dummy = 0; dummy < MAXRIDECULE; dummy++)
|
|
|
|
{
|
|
|
|
commmacro[13] = dummy+'0';
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
|
2006-04-22 06:10:28 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
SCRIPT_Save(ud.config.scripthandle, g_setupFileName);
|
2013-04-03 17:26:49 +00:00
|
|
|
|
|
|
|
if ((flags & 2) == 0)
|
|
|
|
SCRIPT_Free(ud.config.scripthandle);
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
OSD_Printf("Wrote %s\n",g_setupFileName);
|
2015-10-20 07:15:01 +00:00
|
|
|
CONFIG_WriteSettings();
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfflush(NULL);
|
2006-04-13 20:47:06 +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];
|
|
|
|
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];
|
|
|
|
char const * const p = CONFIG_GetMapEntryName(m2, mapname);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "MapTimes", p, &t);
|
|
|
|
}
|
2006-10-23 21:47:28 +00:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2015-12-20 05:18:59 +00:00
|
|
|
int32_t CONFIG_SetMapBestTime(uint8_t const * const mapmd4, int32_t const tm)
|
2006-10-23 21:47:28 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
if (ud.config.scripthandle < 0) ud.config.scripthandle = SCRIPT_Init(g_setupFileName);
|
2007-08-27 00:20:15 +00:00
|
|
|
if (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];
|
|
|
|
CONFIG_GetMD4EntryName(m, mapmd4);
|
2015-05-16 14:27:01 +00:00
|
|
|
|
2015-12-20 05:18:59 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "MapTimes", m, tm, FALSE, FALSE);
|
2006-10-23 21:47:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|