mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-18 10:31:42 +00:00
G_CopyControls and G_GetControlScheme adjustment (take input list of gc's to check)
This commit is contained in:
parent
1e00381075
commit
75fc91644b
3 changed files with 35 additions and 20 deletions
|
@ -47,6 +47,14 @@ INT32 gamecontrol[num_gamecontrols][2];
|
||||||
INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player
|
INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player
|
||||||
INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention
|
INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention
|
||||||
|
|
||||||
|
// lists of GC codes for selective operation
|
||||||
|
INT32 gcmovement[num_gcmovement] = {
|
||||||
|
gc_forward, gc_backward, gc_strafeleft, gc_straferight,
|
||||||
|
gc_lookup, gc_lookdown, gc_turnleft, gc_turnright, gc_centerview,
|
||||||
|
gc_jump, gc_use
|
||||||
|
// , gc_fire, gc_firenormal
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UINT8 time;
|
UINT8 time;
|
||||||
|
@ -673,25 +681,21 @@ void G_DefineDefaultControls(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], boolean movementonly)
|
INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen)
|
||||||
{
|
{
|
||||||
INT32 i, j, gc;
|
INT32 i, j, gc;
|
||||||
boolean skipscheme;
|
boolean skipscheme;
|
||||||
|
|
||||||
gamecontrols_e movement[] = {
|
|
||||||
gc_forward, gc_backward, gc_strafeleft, gc_straferight,
|
|
||||||
gc_lookup, gc_lookdown, gc_turnleft, gc_turnright, gc_centerview,
|
|
||||||
gc_jump, gc_use
|
|
||||||
// , gc_fire, gc_firenormal
|
|
||||||
};
|
|
||||||
|
|
||||||
for (i = 1; i < num_gamecontrolschemes; i++) // skip gcs_custom (0)
|
for (i = 1; i < num_gamecontrolschemes; i++) // skip gcs_custom (0)
|
||||||
{
|
{
|
||||||
skipscheme = false;
|
skipscheme = false;
|
||||||
for (j = 0; j < (movementonly ? sizeof(movement) : num_gamecontrols); j++)
|
for (j = 0; j < (gclist && gclen ? gclen : num_gamecontrols); j++)
|
||||||
{
|
{
|
||||||
gc = (movementonly) ? movement[j] : j;
|
gc = (gclist && gclen) ? gclist[j] : j;
|
||||||
if (fromcontrols[gc][0] != gamecontroldefault[i][gc][0] && fromcontrols[gc][1] != gamecontroldefault[i][gc][1])
|
if (((fromcontrols[gc][0] && gamecontroldefault[i][gc][0]) ? fromcontrols[gc][0] != gamecontroldefault[i][gc][0] : true) &&
|
||||||
|
((fromcontrols[gc][0] && gamecontroldefault[i][gc][1]) ? fromcontrols[gc][0] != gamecontroldefault[i][gc][1] : true) &&
|
||||||
|
((fromcontrols[gc][1] && gamecontroldefault[i][gc][0]) ? fromcontrols[gc][1] != gamecontroldefault[i][gc][0] : true) &&
|
||||||
|
((fromcontrols[gc][1] && gamecontroldefault[i][gc][1]) ? fromcontrols[gc][1] != gamecontroldefault[i][gc][1] : true))
|
||||||
{
|
{
|
||||||
skipscheme = true;
|
skipscheme = true;
|
||||||
break;
|
break;
|
||||||
|
@ -704,13 +708,15 @@ INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], boolean movementonly)
|
||||||
return gcs_custom;
|
return gcs_custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2])
|
void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i, gc;
|
||||||
for (i = 0; i < num_gamecontrols; i++)
|
|
||||||
|
for (i = 0; i < (gclist && gclen ? gclen : num_gamecontrols); i++)
|
||||||
{
|
{
|
||||||
setupcontrols[i][0] = fromcontrols[i][0];
|
gc = (gclist && gclen) ? gclist[i] : i;
|
||||||
setupcontrols[i][1] = fromcontrols[i][1];
|
setupcontrols[gc][0] = fromcontrols[gc][0];
|
||||||
|
setupcontrols[gc][1] = fromcontrols[gc][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,9 @@ extern INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; //
|
||||||
#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]])
|
#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]])
|
||||||
#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]])
|
#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]])
|
||||||
|
|
||||||
|
#define num_gcmovement 11 // 13
|
||||||
|
extern INT32 gcmovement[num_gcmovement];
|
||||||
|
|
||||||
// peace to my little coder fingers!
|
// peace to my little coder fingers!
|
||||||
// check a gamecontrol being active or not
|
// check a gamecontrol being active or not
|
||||||
|
|
||||||
|
@ -143,8 +146,8 @@ void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control);
|
||||||
void Command_Setcontrol_f(void);
|
void Command_Setcontrol_f(void);
|
||||||
void Command_Setcontrol2_f(void);
|
void Command_Setcontrol2_f(void);
|
||||||
void G_DefineDefaultControls(void);
|
void G_DefineDefaultControls(void);
|
||||||
INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], boolean movementonly);
|
INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen);
|
||||||
void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2]);
|
void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen);
|
||||||
void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis)[2]);
|
void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis)[2]);
|
||||||
void G_CheckDoubleUsage(INT32 keynum);
|
void G_CheckDoubleUsage(INT32 keynum);
|
||||||
|
|
||||||
|
|
10
src/m_misc.c
10
src/m_misc.c
|
@ -476,7 +476,7 @@ void M_FirstLoadConfig(void)
|
||||||
|
|
||||||
// load default control
|
// load default control
|
||||||
G_DefineDefaultControls();
|
G_DefineDefaultControls();
|
||||||
G_CopyControls(gamecontrol, gamecontroldefault[gcs_fps]);
|
G_CopyControls(gamecontrol, gamecontroldefault[gcs_fps], NULL, 0);
|
||||||
|
|
||||||
// load config, make sure those commands doesnt require the screen...
|
// load config, make sure those commands doesnt require the screen...
|
||||||
COM_BufInsertText(va("exec \"%s\"\n", configfile));
|
COM_BufInsertText(va("exec \"%s\"\n", configfile));
|
||||||
|
@ -540,7 +540,13 @@ void M_SaveConfig(const char *filename)
|
||||||
// FIXME: save key aliases if ever implemented..
|
// FIXME: save key aliases if ever implemented..
|
||||||
|
|
||||||
CV_SaveVariables(f);
|
CV_SaveVariables(f);
|
||||||
if (!dedicated) G_SaveKeySetting(f, gamecontrol, gamecontrolbis);
|
if (!dedicated)
|
||||||
|
{
|
||||||
|
if (tutorialmode)
|
||||||
|
G_SaveKeySetting(f, gamecontroldefault[gcs_custom], gamecontrolbis); // using gcs_custom as temp storage
|
||||||
|
else
|
||||||
|
G_SaveKeySetting(f, gamecontrol, gamecontrolbis);
|
||||||
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue