2006-04-13 20:47:06 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
2010-05-25 10:56:00 +00:00
|
|
|
Copyright (C) 2010 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
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
*/
|
|
|
|
|
2008-07-25 04:33:33 +00:00
|
|
|
#include "baselayer.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
#include "duke3d.h"
|
2012-01-27 15:03:55 +00:00
|
|
|
#include "game.h"
|
2012-06-03 16:09:33 +00:00
|
|
|
#include "common_game.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
#include "scriplib.h"
|
|
|
|
#include "osd.h"
|
2008-06-30 01:03:51 +00:00
|
|
|
#include "osdcmds.h"
|
2008-07-25 04:33:33 +00:00
|
|
|
#include "osdfuncs.h"
|
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"
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= CONFIG_FunctionNameToNum
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
{
|
2010-05-16 22:53:08 +00:00
|
|
|
char *str = Bstrtolower(Bstrdup(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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= CONFIG_FunctionNumToName
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= CONFIG_AnalogNameToNum
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-07-01 22:11:33 +00:00
|
|
|
int32_t CONFIG_AnalogNameToNum(const char *func)
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= CONFIG_SetDefaults
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
2012-11-08 22:09:00 +00:00
|
|
|
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN])
|
2007-02-13 09:50:58 +00:00
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t i,f;
|
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
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
for (i=0; i < (int32_t)(sizeof(keydefaults)/sizeof(keydefaults[0])); i+=3)
|
2007-02-13 09:50:58 +00:00
|
|
|
{
|
2012-11-08 17:00:31 +00:00
|
|
|
f = CONFIG_FunctionNameToNum(keyptr[i+0]);
|
2007-02-13 09:50:58 +00:00
|
|
|
if (f == -1) continue;
|
2012-11-08 17:00:31 +00:00
|
|
|
ud.config.KeyboardKeys[f][0] = KB_StringToScanCode(keyptr[i+1]);
|
|
|
|
ud.config.KeyboardKeys[f][1] = KB_StringToScanCode(keyptr[i+2]);
|
2007-02-13 09:50:58 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (f == gamefunc_Show_Console) OSD_CaptureKey(ud.config.KeyboardKeys[f][0]);
|
2008-07-09 23:25:38 +00:00
|
|
|
else CONFIG_MapKey(f, ud.config.KeyboardKeys[f][0], 0, ud.config.KeyboardKeys[f][1], 0);
|
2007-02-13 09:50:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2008-02-18 08:10:54 +00:00
|
|
|
ud.config.ScreenWidth = 1024;
|
|
|
|
ud.config.ScreenHeight = 768;
|
|
|
|
ud.config.ScreenMode = 0;
|
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;
|
|
|
|
ud.config.FXDevice = 0;
|
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;
|
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.MusicDevice = 0;
|
|
|
|
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;
|
|
|
|
ud.config.NumVoices = 32;
|
|
|
|
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;
|
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;
|
|
|
|
ud.detail = 1;
|
|
|
|
ud.drawweapon = 1;
|
|
|
|
ud.idplayers = 1;
|
|
|
|
ud.levelstats = 0;
|
|
|
|
ud.lockout = 0;
|
|
|
|
ud.m_ffire = 1;
|
|
|
|
ud.m_marker = 1;
|
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;
|
2006-04-30 01:39:58 +00:00
|
|
|
ud.statusbarmode = 0;
|
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;
|
2008-10-11 09:20:04 +00:00
|
|
|
ud.textscale = 100;
|
2006-05-01 06:30:33 +00:00
|
|
|
|
2009-03-14 02:55:39 +00:00
|
|
|
ud.config.CheckForUpdates = 1;
|
|
|
|
|
2012-03-05 07:24:34 +00:00
|
|
|
if (g_rtsNamePtr == NULL)
|
2012-06-03 16:09:33 +00:00
|
|
|
Bstrcpy(ud.rtsname, G_DefaultRtsFile());
|
2008-11-20 14:06:36 +00:00
|
|
|
Bstrcpy(szPlayerName, "Duke");
|
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.");
|
|
|
|
Bstrcpy(ud.ridecule[3], "Lucky Son of a Bitch.");
|
|
|
|
Bstrcpy(ud.ridecule[4], "Hmmm....Payback time.");
|
|
|
|
Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker.");
|
|
|
|
Bstrcpy(ud.ridecule[6], "Damn, you're ugly.");
|
|
|
|
Bstrcpy(ud.ridecule[7], "Ha ha ha...Wasted!");
|
|
|
|
Bstrcpy(ud.ridecule[8], "You suck!");
|
|
|
|
Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!");
|
|
|
|
|
|
|
|
// JBF 20031211
|
2006-04-25 05:01:27 +00:00
|
|
|
|
2012-11-08 22:09:00 +00:00
|
|
|
CONFIG_SetDefaultKeys((const char (*)[MAXGAMEFUNCLEN])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));
|
2006-11-15 01:16:55 +00:00
|
|
|
for (i=0; i<MAXJOYBUTTONS; i++)
|
|
|
|
{
|
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
|
|
|
}
|
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);
|
|
|
|
|
2008-07-04 01:15:32 +00:00
|
|
|
for (k = 0; (unsigned)k < (sizeof(ii) / sizeof(ii[0])); 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
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= CONFIG_SetupMouse
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= CONFIG_SetupJoystick
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXJOYBUTTONS; 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
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXJOYBUTTONS; 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= CONFIG_ReadSetup
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
2009-01-09 09:29:17 +00:00
|
|
|
extern void G_CheckPlayerColor(int32_t *color,int32_t prev_color);
|
2008-11-20 14:06:36 +00:00
|
|
|
extern palette_t CrosshairColors;
|
|
|
|
extern palette_t DefaultCrosshairColors;
|
2010-01-16 23:08:17 +00:00
|
|
|
extern char g_modDir[BMAX_PATH];
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t r_maxfps;
|
|
|
|
extern int32_t g_noSetup;
|
2010-01-24 23:33:17 +00:00
|
|
|
extern int32_t demorec_diffs_cvar, demoplay_diffs;
|
|
|
|
extern int32_t demorec_difftics_cvar, demorec_diffcompress_cvar, demorec_synccompress_cvar;
|
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
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t dummy, i = 0;
|
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;
|
2006-04-25 04:35:39 +00:00
|
|
|
|
2007-01-22 02:49:58 +00:00
|
|
|
pathsearchmode = 1;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0) // JBF 20031211
|
|
|
|
ud.config.scripthandle = SCRIPT_Load(setupfilename);
|
2008-12-10 11:36:53 +00:00
|
|
|
else if (SafeFileExists(SETUPFILENAME) && ud.config.scripthandle < 0)
|
|
|
|
{
|
2010-12-19 22:47:10 +00:00
|
|
|
i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. "
|
|
|
|
"Import configuration data from \"%s\"?",setupfilename,SETUPFILENAME);
|
2008-12-10 11:36:53 +00:00
|
|
|
if (i) ud.config.scripthandle = SCRIPT_Load(SETUPFILENAME);
|
|
|
|
}
|
2008-08-12 12:50:20 +00:00
|
|
|
else if (SafeFileExists("duke3d.cfg") && ud.config.scripthandle < 0)
|
|
|
|
{
|
2010-12-19 22:47:10 +00:00
|
|
|
i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. "
|
|
|
|
"Import configuration data from \"duke3d.cfg\"?",setupfilename);
|
2008-08-12 12:50:20 +00:00
|
|
|
if (i) ud.config.scripthandle = SCRIPT_Load("duke3d.cfg");
|
|
|
|
}
|
2007-01-22 02:49:58 +00:00
|
|
|
pathsearchmode = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.scripthandle < 0) return -1;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.scripthandle >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-10-14 08:40:59 +00:00
|
|
|
char dummybuf[64];
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (dummy = 0; dummy < 10; dummy++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
commmacro[13] = dummy+'0';
|
2007-08-27 00:20:15 +00:00
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-06-19 18:30:32 +00:00
|
|
|
Bmemset(tempbuf, 0, sizeof(tempbuf));
|
|
|
|
// Bmemset(dummybuf, 0, sizeof(dummybuf));
|
2007-08-27 00:20:15 +00:00
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","PlayerName",&tempbuf[0]);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
while (Bstrlen(OSD_StripColors(dummybuf,tempbuf)) > 10)
|
2006-05-10 21:00:56 +00:00
|
|
|
tempbuf[Bstrlen(tempbuf)-1] = '\0';
|
|
|
|
|
2012-03-28 19:43:21 +00:00
|
|
|
Bstrncpyz(szPlayerName, tempbuf, sizeof(szPlayerName));
|
2006-05-01 22:49:09 +00:00
|
|
|
|
2012-03-05 07:24:34 +00:00
|
|
|
if (g_rtsNamePtr == NULL)
|
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Setup","ConfigVersion",&ud.configversion);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Setup","ForceSetup",&ud.config.ForceSetup);
|
2009-04-14 22:55:32 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Setup","NoAutoLoad",&ud.config.NoAutoLoad);
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2009-05-28 02:55:46 +00:00
|
|
|
// #ifdef _WIN32
|
2010-01-16 23:08:17 +00:00
|
|
|
if (g_noSetup == 0 && g_modDir[0] == '/')
|
2008-12-17 01:59:36 +00:00
|
|
|
{
|
2012-11-15 14:27:57 +00:00
|
|
|
struct Bstat st;
|
2010-01-16 23:08:17 +00:00
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]);
|
2008-12-17 01:59:36 +00:00
|
|
|
|
2010-05-25 10:56:00 +00:00
|
|
|
if (Bstat(g_modDir, &st))
|
2008-12-17 01:59:36 +00:00
|
|
|
{
|
|
|
|
if ((st.st_mode & S_IFDIR) != S_IFDIR)
|
|
|
|
{
|
|
|
|
initprintf("Invalid mod dir in cfg!\n");
|
2010-01-16 23:08:17 +00:00
|
|
|
Bsprintf(g_modDir,"/");
|
2008-12-17 01:59:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-05-28 02:55:46 +00:00
|
|
|
// #endif
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2012-06-03 16:09:33 +00:00
|
|
|
if (g_grpNamePtr != NULL && !Bstrcmp(g_grpNamePtr,defaultgamegrp[0]))
|
2012-01-27 15:03:55 +00:00
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr[0]);
|
2006-12-01 04:22:16 +00:00
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (!NAM)
|
|
|
|
{
|
2007-08-27 00:20:15 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out",&ud.lockout);
|
2008-11-20 14:06:36 +00:00
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Screen Setup","Password",&ud.pwlockout[0]);
|
2006-07-22 23:02:08 +00:00
|
|
|
}
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",&ud.config.ScreenHeight);
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",&ud.config.ScreenMode);
|
2008-11-20 14:06:36 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",&ud.config.ScreenWidth);
|
2008-10-01 04:38:14 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
#ifdef RENDERTYPEWIN
|
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32_t *)&windowpos);
|
2008-11-20 14:06:36 +00:00
|
|
|
windowx = -1;
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32_t *)&windowx);
|
2008-11-20 14:06:36 +00:00
|
|
|
windowy = -1;
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32_t *)&windowy);
|
2008-11-20 14:06:36 +00:00
|
|
|
}
|
2006-06-09 01:28:39 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-09 22:12:29 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP);
|
|
|
|
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
|
2009-04-14 22:55:32 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Polymer", &dummy);
|
2010-05-09 22:12:29 +00:00
|
|
|
if (dummy > 0 && ud.config.ScreenBPP >= 16) glrendmode = 4;
|
2009-04-14 22:55:32 +00:00
|
|
|
else glrendmode = 3;
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2006-08-07 19:57:53 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Color",&ud.color);
|
|
|
|
G_CheckPlayerColor((int32_t *)&ud.color,-1);
|
|
|
|
g_player[0].ps->palookup = g_player[0].pcolor = ud.color;
|
|
|
|
tempbuf[0] = 0;
|
|
|
|
*/
|
2008-08-08 01:54:43 +00:00
|
|
|
|
2012-02-20 21:18:57 +00:00
|
|
|
SCRIPT_GetString(ud.config.scripthandle, "Misc", "CrosshairColor",&tempbuf[0]);
|
|
|
|
if (tempbuf[0])
|
|
|
|
{
|
|
|
|
char *ptr = strtok(tempbuf,",");
|
|
|
|
palette_t temppal;
|
|
|
|
char *palptr = (char *)&temppal;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (ptr != NULL && i < 3)
|
|
|
|
{
|
|
|
|
palptr[i++] = Batoi(ptr);
|
|
|
|
ptr = strtok(NULL,",");
|
|
|
|
}
|
|
|
|
if (i == 3)
|
|
|
|
{
|
|
|
|
Bmemcpy(&CrosshairColors,&temppal,sizeof(palette_t));
|
|
|
|
DefaultCrosshairColors.f = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions);
|
2010-01-24 23:33:17 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
// weapon choices are defaulted in G_CheckCommandLine, which may override them
|
2010-01-16 23:08:17 +00:00
|
|
|
if (!g_forceWeaponChoice)
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<10; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buf,"WeaponChoice%d",i);
|
2006-04-25 05:01:27 +00:00
|
|
|
dummy = -1;
|
2007-08-27 00:20:15 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "Misc", buf, &dummy);
|
2011-05-22 21:52:22 +00:00
|
|
|
if (dummy >= 0 && dummy<10) g_player[0].wchoice[i] = dummy;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-12-18 08:37:12 +00:00
|
|
|
#ifdef _WIN32
|
2007-08-27 00:20:15 +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
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
//CONFIG_SetupMouse(ud.config.scripthandle);
|
|
|
|
//CONFIG_SetupJoystick(ud.config.scripthandle);
|
|
|
|
ud.config.setupread = 1;
|
2006-07-01 01:40:18 +00:00
|
|
|
return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
=
|
|
|
|
= CONFIG_WriteSetup
|
|
|
|
=
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
void CONFIG_WriteBinds(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;
|
2008-08-12 12:50:20 +00:00
|
|
|
char *ptr = Bstrdup(setupfilename);
|
2008-08-25 10:27:18 +00:00
|
|
|
char tempbuf[128];
|
2008-08-12 12:50:20 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
if (!Bstrcmp(setupfilename, SETUPFILENAME))
|
|
|
|
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)
|
|
|
|
{
|
2008-06-30 00:18:59 +00:00
|
|
|
symbol_t *symb;
|
2009-04-30 21:09:44 +00:00
|
|
|
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfprintf(fp,"// this file automatically generated by EDuke32\n");
|
|
|
|
Bfprintf(fp,"// these settings take precedence over your main cfg file\n");
|
|
|
|
Bfprintf(fp,"// do not modify if you lack common sense\n");
|
2009-04-30 21:09:44 +00:00
|
|
|
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfprintf(fp,"unbindall\n");
|
2010-05-07 20:45:40 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXBOUNDKEYS; 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
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXMOUSEBUTTONS; i++)
|
2012-11-18 15:44:18 +00:00
|
|
|
if (CONTROL_MouseIsBound(i))
|
2012-11-17 16:47:58 +00:00
|
|
|
Bfprintf(fp,"bind \"%s\"%s \"%s\"\n",CONTROL_MouseBinds[i].key,
|
|
|
|
CONTROL_MouseBinds[i].repeat?"":" norepeat",CONTROL_MouseBinds[i].cmdstr);
|
2008-06-30 19:06:05 +00:00
|
|
|
|
2008-06-30 00:18:59 +00:00
|
|
|
for (symb=symbols; symb!=NULL; symb=symb->next)
|
|
|
|
if (symb->func == (void *)OSD_ALIAS)
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfprintf(fp,"alias \"%s\" \"%s\"\n", symb->name, symb->help);
|
2008-06-30 00:18:59 +00:00
|
|
|
|
2008-07-01 11:14:18 +00:00
|
|
|
/* for (i = 0; i < sizeof(cvar)/sizeof(cvarmappings); i++)
|
|
|
|
if (!(cvar[i].type&CVAR_NOSAVE))
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfprintf(fp,"%s \"%d\"\n",cvar[i].name,*(int32_t*)cvar[i].var);
|
2008-07-01 11:14:18 +00:00
|
|
|
*/
|
2009-04-30 21:09:44 +00:00
|
|
|
OSD_WriteCvars(fp);
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfclose(fp);
|
2010-05-02 23:27:30 +00:00
|
|
|
if (!Bstrcmp(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
|
|
|
|
|
|
|
if (!Bstrcmp(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;
|
2008-08-25 10:27:18 +00:00
|
|
|
char tempbuf[1024];
|
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)
|
|
|
|
ud.config.scripthandle = SCRIPT_Init(setupfilename);
|
|
|
|
|
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
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Setup","ConfigVersion",BYTEVERSION_JF,FALSE,FALSE);
|
|
|
|
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
|
2010-05-09 22:12:29 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Polymer",glrendmode == 4 && bpp > 8,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
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
|
2012-11-15 14:27:57 +00:00
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Setup","SelectedGRP",g_grpNamePtr);
|
2011-03-04 08:50:58 +00:00
|
|
|
|
2012-08-24 18:55:06 +00:00
|
|
|
// XXX: should be "if compiled without startup GUI"
|
|
|
|
#if !defined __linux || defined HAVE_GTK2
|
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)
|
|
|
|
{
|
|
|
|
SCRIPT_Save(ud.config.scripthandle, setupfilename);
|
|
|
|
SCRIPT_Free(ud.config.scripthandle);
|
|
|
|
OSD_Printf("Updated %s\n",setupfilename);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
#ifdef RENDERTYPEWIN
|
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);
|
2008-11-20 14:06:36 +00:00
|
|
|
#endif
|
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
for (dummy=0; dummy<10; dummy++)
|
|
|
|
{
|
|
|
|
Bsprintf(buf,"WeaponChoice%d",dummy);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Misc",buf,g_player[myconnectindex].wchoice[dummy],FALSE,FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!NAM)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (dummy=0; dummy<MAXMOUSEBUTTONS; dummy++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2010-05-02 23:27:30 +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
|
|
|
|
|
|
|
if (dummy >= (MAXMOUSEBUTTONS-2)) continue;
|
|
|
|
|
2010-05-02 23:27:30 +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]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2008-02-02 16:38:30 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (dummy=0; dummy<MAXMOUSEAXES; dummy++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2010-05-02 23:27:30 +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
|
|
|
|
2010-05-02 23:27:30 +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
|
|
|
|
2010-05-02 23:27:30 +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
|
|
|
|
2012-06-03 16:11:22 +00:00
|
|
|
if (ud.config.MouseAnalogueScale[dummy] != DEFAULTMOUSEANALOGUESCALE)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
|
|
|
Bsprintf(buf,"MouseAnalogScale%d",dummy);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.MouseAnalogueScale[dummy], FALSE, FALSE);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2009-04-29 19:43:51 +00:00
|
|
|
|
|
|
|
Bsprintf(tempbuf,"%.2f",CONTROL_MouseSensitivity);
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Controls","Mouse_Sensitivity",tempbuf);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (dummy=0; dummy<MAXJOYBUTTONS; dummy++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2010-05-02 23:27:30 +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
|
|
|
|
2010-05-02 23:27:30 +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]));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
for (dummy=0; dummy<MAXJOYAXES; dummy++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2010-05-02 23:27:30 +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
|
|
|
|
2010-05-02 23:27:30 +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
|
|
|
|
2010-05-02 23:27:30 +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
|
|
|
|
2012-06-03 16:11:22 +00:00
|
|
|
if (ud.config.JoystickAnalogueScale[dummy] != DEFAULTJOYSTICKANALOGUESCALE)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2012-06-03 16:11:22 +00:00
|
|
|
if (ud.config.JoystickAnalogueDead[dummy] != DEFAULTJOYSTICKANALOGUEDEAD)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2012-06-03 16:11:22 +00:00
|
|
|
if (ud.config.JoystickAnalogueSaturate[dummy] != DEFAULTJOYSTICKANALOGUESATURATE)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
|
|
|
Bsprintf(buf,"JoystickAnalogSaturate%d",dummy);
|
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.JoystickAnalogueSaturate[dummy], FALSE, FALSE);
|
|
|
|
}
|
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]);
|
2012-03-05 07:24:34 +00:00
|
|
|
if (g_rtsNamePtr == NULL)
|
|
|
|
SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]);
|
2007-02-13 09:50:58 +00:00
|
|
|
|
2006-04-22 06:10:28 +00:00
|
|
|
{
|
|
|
|
char commmacro[] = "CommbatMacro# ";
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (dummy = 0; dummy < 10; dummy++)
|
2006-04-22 06:10:28 +00:00
|
|
|
{
|
|
|
|
commmacro[13] = dummy+'0';
|
2007-08-27 00:20:15 +00:00
|
|
|
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
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
SCRIPT_Save(ud.config.scripthandle, setupfilename);
|
|
|
|
SCRIPT_Free(ud.config.scripthandle);
|
2008-07-08 04:52:39 +00:00
|
|
|
OSD_Printf("Wrote %s\n",setupfilename);
|
|
|
|
CONFIG_WriteBinds();
|
2012-06-03 16:08:27 +00:00
|
|
|
Bfflush(NULL);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t CONFIG_GetMapBestTime(char *mapname)
|
2006-10-23 21:47:28 +00:00
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t t = -1;
|
2006-10-23 21:47:28 +00:00
|
|
|
char m[BMAX_PATH], *p;
|
|
|
|
|
|
|
|
strcpy(m, mapname);
|
|
|
|
p = strrchr(m, '/');
|
|
|
|
if (!p) p = strrchr(m, '\\');
|
2010-06-07 09:03:16 +00:00
|
|
|
if (p) Bmemmove(m, p, Bstrlen(p)+1);//strcpy(m, p);
|
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++;
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (!ud.config.setupread) return -1;
|
|
|
|
if (ud.config.scripthandle < 0) return -1;
|
2006-10-23 21:47:28 +00:00
|
|
|
|
2008-09-26 04:20:08 +00:00
|
|
|
SCRIPT_GetNumber(ud.config.scripthandle, "MapTimes", p, &t);
|
2006-10-23 21:47:28 +00:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t CONFIG_SetMapBestTime(char *mapname, int32_t tm)
|
2006-10-23 21:47:28 +00:00
|
|
|
{
|
|
|
|
char m[BMAX_PATH], *p;
|
|
|
|
|
|
|
|
strcpy(m, mapname);
|
|
|
|
p = strrchr(m, '/');
|
|
|
|
if (!p) p = strrchr(m, '\\');
|
|
|
|
if (p) strcpy(m, p);
|
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++;
|
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.scripthandle < 0) ud.config.scripthandle = SCRIPT_Init(setupfilename);
|
|
|
|
if (ud.config.scripthandle < 0) return -1;
|
2006-10-23 21:47:28 +00:00
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
SCRIPT_PutNumber(ud.config.scripthandle, "MapTimes", p, tm, FALSE, FALSE);
|
2006-10-23 21:47:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
/*
|
|
|
|
* vim:ts=4:sw=4:
|
|
|
|
*/
|
|
|
|
|