- console code matching with GZDoom

Refactored the buttons to be definable locally per game for easier handling of differing input.
This commit is contained in:
Christoph Oelckers 2020-04-12 00:10:39 +02:00
parent 14cdfa3f3c
commit 57cb22f135
21 changed files with 715 additions and 316 deletions

64
.gitignore vendored
View file

@ -1,67 +1,5 @@
obj/
eduke32
apps/
*.exe
/*.dll
*.dylib
*.so
*.elf
*.dol
*.x86
*.x64
*.ppc
*.app
/movie
/blud*.png
/game*.sav
*.log
*.cache
*.cfg
texturecache
*.index
*.manifest
/*.map
/*.mhk
/platform/Windows/*.map
*.pdb
.vs/
*.VC.db
*.VC.opendb
*.sym
/*.grp
/*.rts
/*.art
/*.ar_
/*.con
/*.SMK
/*.WAV
/platform/Windows/*.con
*.memmap
*.sdf
*.suo
*.opensdf
*.vcxproj.user
*.psess
*.vsp
perl.exe.stackdump
xcuserdata/
project.xcworkspace/
*.dSYM/
.DS_Store
._*
/autoload
/movie
/blud*.png
/*.DEM
/game*.sav
build-vs2019/
build-vs2019-32/
/source/gitinfo.h
/build2
/build

View file

@ -708,9 +708,9 @@ void LocalKeys(void)
bool alt = inputState.AltPressed();
bool ctrl = inputState.CtrlPressed();
bool shift = inputState.ShiftPressed();
if (buttonMap.ButtonDown(gamefunc_See_Chase_View) && !alt && !shift)
if (buttonMap.ButtonDown(gamefunc_Third_Person_View) && !alt && !shift)
{
buttonMap.ClearButton(gamefunc_See_Chase_View);
buttonMap.ClearButton(gamefunc_Third_Person_View);
if (gViewPos > VIEWPOS_0)
gViewPos = VIEWPOS_0;
else
@ -755,7 +755,7 @@ void LocalKeys(void)
gPlayerMsg.Set(*CombatMacros[fk]);
gPlayerMsg.Send();
}
buttonMap.ClearButton(gamefunc_See_Chase_View);
buttonMap.ClearButton(gamefunc_Third_Person_View);
return;
}
#if 0
@ -1035,8 +1035,68 @@ void ClockStrobe()
void ReadAllRFS();
static const char* actions[] = {
"Move_Forward",
"Move_Backward",
"Turn_Left",
"Turn_Right",
"Strafe",
"Fire",
"Open",
"Run",
"Alt_Fire", // Duke3D", Blood
"Jump",
"Crouch",
"Look_Up",
"Look_Down",
"Look_Left",
"Look_Right",
"Strafe_Left",
"Strafe_Right",
"Aim_Up",
"Aim_Down",
"Weapon_1",
"Weapon_2",
"Weapon_3",
"Weapon_4",
"Weapon_5",
"Weapon_6",
"Weapon_7",
"Weapon_8",
"Weapon_9",
"Weapon_10",
"Inventory",
"Inventory_Left",
"Inventory_Right",
"Nightvision",
"MedKit",
"TurnAround",
"SendMessage",
"Map",
"Shrink_Screen",
"Enlarge_Screen",
"Center_View",
"Holster_Weapon",
"Show_Opponents_Weapon",
"Map_Follow_Mode",
"See_Coop_View",
"Mouse_Aiming",
"Toggle_Crosshair",
"Next_Weapon",
"Previous_Weapon",
"Dpad_Select",
"Dpad_Aiming",
"Third_Person_View",
"Toggle_Crouch",
"CrystalBall",
"ProximityBombs",
"RemoteBombs",
"Jetpack"
};
int GameInterface::app_main()
{
buttonMap.SetButtons(actions, NUM_ACTIONS);
memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
gGameOptions.nMonsterSettings = !userConfig.nomonsters;
bQuickStart = userConfig.nologo;

View file

@ -28,6 +28,68 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
enum GameFunction_t
{
gamefunc_Move_Forward,
gamefunc_Move_Backward,
gamefunc_Turn_Left,
gamefunc_Turn_Right,
gamefunc_Strafe,
gamefunc_Fire,
gamefunc_Open,
gamefunc_Run,
gamefunc_Alt_Fire, // Duke3D, Blood
gamefunc_Jump,
gamefunc_Crouch,
gamefunc_Look_Up,
gamefunc_Look_Down,
gamefunc_Look_Left,
gamefunc_Look_Right,
gamefunc_Strafe_Left,
gamefunc_Strafe_Right,
gamefunc_Aim_Up,
gamefunc_Aim_Down,
gamefunc_Weapon_1,
gamefunc_Weapon_2,
gamefunc_Weapon_3,
gamefunc_Weapon_4,
gamefunc_Weapon_5,
gamefunc_Weapon_6,
gamefunc_Weapon_7,
gamefunc_Weapon_8,
gamefunc_Weapon_9,
gamefunc_Weapon_10,
gamefunc_Inventory,
gamefunc_Inventory_Left,
gamefunc_Inventory_Right,
gamefunc_BeastVision, //Nightvision
gamefunc_MedKit,
gamefunc_TurnAround,
gamefunc_SendMessage,
gamefunc_Map,
gamefunc_Shrink_Screen,
gamefunc_Enlarge_Screen,
gamefunc_Center_View,
gamefunc_Holster_Weapon,
gamefunc_Show_Opponents_Weapon,
gamefunc_Map_Follow_Mode,
gamefunc_See_Coop_View,
gamefunc_Mouse_Aiming,
gamefunc_Toggle_Crosshair,
gamefunc_Next_Weapon,
gamefunc_Previous_Weapon,
gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming,
gamefunc_Third_Person_View,
gamefunc_Toggle_Crouch,
gamefunc_CrystalBall,
gamefunc_ProximityBombs,
gamefunc_RemoteBombs,
gamefunc_JumpBoots,
NUM_ACTIONS
};
struct INIDESCRIPTION {
const char *pzName;
const char *pzFilename;

View file

@ -112,9 +112,9 @@ void ctrlGetInput(void)
if (gQuitRequest)
gInput.keyFlags.quit = 1;
if (buttonMap.ButtonDown(gamefunc_Map_Toggle))
if (buttonMap.ButtonDown(gamefunc_Map))
{
buttonMap.ClearButton(gamefunc_Map_Toggle);
buttonMap.ClearButton(gamefunc_Map);
viewToggle(gViewMode);
}
@ -226,9 +226,9 @@ void ctrlGetInput(void)
gInput.keyFlags.nextItem = 1;
}
if (buttonMap.ButtonDown(gamefunc_Inventory_Use))
if (buttonMap.ButtonDown(gamefunc_Inventory))
{
buttonMap.ClearButton(gamefunc_Inventory_Use);
buttonMap.ClearButton(gamefunc_Inventory);
gInput.keyFlags.useItem = 1;
}

View file

@ -48,7 +48,7 @@ CCheatMgr gCheatMgr;
void sub_5A928(void)
{
for (int i = 0; i < NUMGAMEFUNCTIONS-1; i++)
for (int i = 0; i < buttonMap.NumButtons(); i++)
buttonMap.ClearButton(i);
}

View file

@ -49,7 +49,7 @@
#include "d_event.h"
extern int chatmodeon;
const char *KeyNames[NUM_KEYS] =
{
@ -823,7 +823,7 @@ bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds)
return false;
}
if (!binding.IsEmpty())// && (chatmodeon == 0 || ev->data1 < 256))
if (!binding.IsEmpty() && (chatmodeon == 0 || ev->data1 < 256))
{
char *copy = binding.LockBuffer();

View file

@ -34,98 +34,14 @@
*/
#include "c_buttons.h"
#include "templates.h"
#include "c_dispatch.h"
#include "printf.h"
#include "cmdlib.h"
#include "c_dispatch.h"
#include "gamecontrol.h"
#include "c_console.h"
ButtonMap buttonMap;
struct ButtonDesc
{
int index;
const char *name;
};
static const ButtonDesc gamefuncs[] = {
{ gamefunc_Move_Forward, "Move_Forward"},
{ gamefunc_Move_Backward, "Move_Backward"},
{ gamefunc_Turn_Left, "Turn_Left"},
{ gamefunc_Turn_Right, "Turn_Right"},
{ gamefunc_Strafe, "Strafe"},
{ gamefunc_Fire, "Fire"},
{ gamefunc_Open, "Open"},
{ gamefunc_Run, "Run"},
{ gamefunc_Alt_Fire, "Alt_Fire"},
{ gamefunc_Jump, "Jump"},
{ gamefunc_Crouch, "Crouch"},
{ gamefunc_Look_Up, "Look_Up"},
{ gamefunc_Look_Down, "Look_Down"},
{ gamefunc_Look_Left, "Look_Left"},
{ gamefunc_Look_Right, "Look_Right"},
{ gamefunc_Strafe_Left, "Strafe_Left"},
{ gamefunc_Strafe_Right, "Strafe_Right"},
{ gamefunc_Aim_Up, "Aim_Up"},
{ gamefunc_Aim_Down, "Aim_Down"},
{ gamefunc_Weapon_1, "Weapon_1"},
{ gamefunc_Weapon_2, "Weapon_2"},
{ gamefunc_Weapon_3, "Weapon_3"},
{ gamefunc_Weapon_4, "Weapon_4"},
{ gamefunc_Weapon_5, "Weapon_5"},
{ gamefunc_Weapon_6, "Weapon_6"},
{ gamefunc_Weapon_7, "Weapon_7"},
{ gamefunc_Weapon_8, "Weapon_8"},
{ gamefunc_Weapon_9, "Weapon_9"},
{ gamefunc_Weapon_10, "Weapon_10"},
{ gamefunc_Inventory, "Inventory"},
{ gamefunc_Inventory_Left, "Inventory_Left"},
{ gamefunc_Inventory_Right, "Inventory_Right"},
{ gamefunc_Holo_Duke, "Holo_Duke"},
{ gamefunc_Jetpack, "Jetpack"},
{ gamefunc_NightVision, "NightVision"},
{ gamefunc_MedKit, "MedKit"},
{ gamefunc_TurnAround, "Turn_Around"},
{ gamefunc_SendMessage, "Send_Message"},
{ gamefunc_Map, "Map"},
{ gamefunc_Shrink_Screen, "Shrink_Screen"},
{ gamefunc_Enlarge_Screen, "Enlarge_Screen"},
{ gamefunc_Center_View, "Center_View"},
{ gamefunc_Holster_Weapon, "Holster_Weapon"},
{ gamefunc_Show_Opponents_Weapon, "Show_Opponents_Weapon"},
{ gamefunc_Map_Follow_Mode, "Map_Follow_Mode"},
{ gamefunc_See_Coop_View, "See_Coop_View"},
{ gamefunc_Mouse_Aiming, "Mouse_Aiming"},
{ gamefunc_Toggle_Crosshair, "Toggle_Crosshair"},
{ gamefunc_Steroids, "Steroids"},
{ gamefunc_Quick_Kick, "Quick_Kick"},
{ gamefunc_Next_Weapon, "Next_Weapon"},
{ gamefunc_Previous_Weapon, "Previous_Weapon"},
{ gamefunc_Show_DukeMatch_Scores, "Show_DukeMatch_Scores"},
{ gamefunc_Dpad_Select, "Dpad_Select"},
{ gamefunc_Dpad_Aiming, "Dpad_Aiming"},
{ gamefunc_Last_Weapon, "Last_Used_Weapon"},
{ gamefunc_Alt_Weapon, "Alt_Weapon"},
{ gamefunc_Third_Person_View, "Third_Person_View"},
{ gamefunc_Toggle_Crouch, "Toggle_Crouch"},
{ gamefunc_CrystalBall, "CrystalBall"}, // the following were added by Blood
{ gamefunc_ProximityBombs, "ProximityBombs"},
{ gamefunc_RemoteBombs, "RemoteBombs"},
{ gamefunc_Smoke_Bomb, "Smoke_Bomb" },
{ gamefunc_Gas_Bomb, "Gas_Bomb" },
{ gamefunc_Flash_Bomb, "Flash_Bomb" },
{ gamefunc_Caltrops, "Caltrops" },
};
// This is for use by the tab command builder which can run before the optimized tables are initialized.
const char* StaticGetButtonName(int32_t func)
{
for (auto& entry : gamefuncs)
if (entry.index == func) return entry.name;
return "";
}
//=============================================================================
//
@ -133,12 +49,16 @@ const char* StaticGetButtonName(int32_t func)
//
//=============================================================================
ButtonMap::ButtonMap()
void ButtonMap::SetButtons(const char** names, int count)
{
for(auto &gf : gamefuncs)
Buttons.Resize(count);
NumToName.Resize(count);
NameToNum.Clear();
for(int i = 0; i < count; i++)
{
NameToNum.Insert(gf.name, gf.index);
NumToName[gf.index] = gf.name;
Buttons[i] = {};
NameToNum.Insert(names[i], i);
NumToName[i] = names[i];
}
}
@ -153,18 +73,18 @@ int ButtonMap::ListActionCommands (const char *pattern)
char matcher[32];
int count = 0;
for (int i = 0; i < NumButtons(); i++)
for (auto& btn : NumToName)
{
if (pattern == NULL || CheckWildcards (pattern,
(snprintf (matcher, countof(matcher), "+%s", NumToName[i].GetChars()), matcher)))
(mysnprintf (matcher, countof(matcher), "+%s", btn.GetChars()), matcher)))
{
Printf ("+%s\n", NumToName[i].GetChars());
Printf ("+%s\n", btn.GetChars());
count++;
}
if (pattern == NULL || CheckWildcards (pattern,
(snprintf (matcher, countof(matcher), "-%s", NumToName[i].GetChars()), matcher)))
(mysnprintf (matcher, countof(matcher), "-%s", btn.GetChars()), matcher)))
{
Printf ("-%s\n", NumToName[i].GetChars());
Printf ("-%s\n", btn.GetChars());
count++;
}
}
@ -178,11 +98,11 @@ int ButtonMap::ListActionCommands (const char *pattern)
//
//=============================================================================
int ButtonMap::FindButtonIndex (const char *key) const
int ButtonMap::FindButtonIndex (const char *key, int funclen) const
{
if (!key) return -1;
FName name(key, true);
FName name = funclen == -1? FName(key, true) : FName(key, funclen, true);
if (name == NAME_None) return -1;
auto res = NameToNum.CheckKey(name);
@ -214,10 +134,13 @@ void ButtonMap::ResetButtonTriggers ()
void ButtonMap::ResetButtonStates ()
{
for (auto &button : Buttons)
for (auto &btn : Buttons)
{
button.ReleaseKey (0);
button.ResetTriggers ();
if (!btn.bReleaseLock)
{
btn.ReleaseKey (0);
}
btn.ResetTriggers ();
}
}
@ -316,3 +239,23 @@ bool FButtonStatus::ReleaseKey (int keynum)
// Returns true if releasing this key caused the button to go up.
return wasdown && !bDown;
}
//=============================================================================
//
//
//
//=============================================================================
void ButtonMap::AddButtonTabCommands()
{
// Add all the action commands for tab completion
for (auto& btn : NumToName)
{
char tname[16];
strcpy (&tname[1], btn.GetChars());
tname[0] = '+';
C_AddTabCommand (tname);
tname[0] = '-';
C_AddTabCommand (tname);
}
}

View file

@ -2,95 +2,8 @@
#include <stdint.h>
#include "tarray.h"
#include "zstring.h"
#include "name.h"
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
enum GameFunction_t
{
gamefunc_Move_Forward,
gamefunc_Move_Backward,
gamefunc_Turn_Left,
gamefunc_Turn_Right,
gamefunc_Strafe,
gamefunc_Fire,
gamefunc_Open,
gamefunc_Run,
gamefunc_Alt_Fire, // Duke3D, Blood
gamefunc_Jump,
gamefunc_Crouch,
gamefunc_Look_Up,
gamefunc_Look_Down,
gamefunc_Look_Left,
gamefunc_Look_Right,
gamefunc_Strafe_Left,
gamefunc_Strafe_Right,
gamefunc_Aim_Up,
gamefunc_Aim_Down,
gamefunc_Weapon_1,
gamefunc_Weapon_2,
gamefunc_Weapon_3,
gamefunc_Weapon_4,
gamefunc_Weapon_5,
gamefunc_Weapon_6,
gamefunc_Weapon_7,
gamefunc_Weapon_8,
gamefunc_Weapon_9,
gamefunc_Weapon_10,
gamefunc_Inventory,
gamefunc_Inventory_Use = gamefunc_Inventory,
gamefunc_Inventory_Left,
gamefunc_Inventory_Right,
gamefunc_Holo_Duke, // Duke3D, RR
gamefunc_Jetpack,
gamefunc_JumpBoots = gamefunc_Jetpack,
gamefunc_NightVision,
gamefunc_Night_Vision = gamefunc_NightVision,
gamefunc_BeastVision = gamefunc_NightVision,
gamefunc_MedKit,
gamefunc_Med_Kit = gamefunc_MedKit,
gamefunc_TurnAround,
gamefunc_SendMessage,
gamefunc_Map,
gamefunc_Map_Toggle = gamefunc_Map,
gamefunc_Shrink_Screen,
gamefunc_Enlarge_Screen,
gamefunc_Center_View,
gamefunc_Look_Straight = gamefunc_Center_View,
gamefunc_Holster_Weapon,
gamefunc_Show_Opponents_Weapon,
gamefunc_Map_Follow_Mode,
gamefunc_See_Coop_View,
gamefunc_See_Co_Op_View = gamefunc_See_Coop_View,
gamefunc_Mouse_Aiming,
gamefunc_Mouseview = gamefunc_Mouse_Aiming,
gamefunc_Toggle_Crosshair,
gamefunc_Steroids,
gamefunc_Quick_Kick,
gamefunc_Next_Weapon,
gamefunc_Previous_Weapon,
gamefunc_Show_DukeMatch_Scores,
gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming,
gamefunc_Last_Weapon,
gamefunc_Alt_Weapon,
gamefunc_Third_Person_View,
gamefunc_See_Chase_View = gamefunc_Third_Person_View,
gamefunc_Toggle_Crouch, // This is the last one used by EDuke32.
gamefunc_CrystalBall,
gamefunc_ProximityBombs,
gamefunc_RemoteBombs,
gamefunc_Smoke_Bomb, // and these by ShadowWarrior (todo: There's quite a bit of potential for consolidation here - is it worth it?)
gamefunc_Gas_Bomb,
gamefunc_Flash_Bomb,
gamefunc_Caltrops,
gamefunc_Zoom_In, // Map controls should not pollute the global button namespace.
gamefunc_Zoom_Out,
};
// Actions
struct FButtonStatus
{
@ -100,6 +13,9 @@ struct FButtonStatus
bool bDown; // Button is down right now
bool bWentDown; // Button went down this tic
bool bWentUp; // Button went up this tic
bool bReleaseLock; // Lock ReleaseKey call in ResetButtonStates
void (*PressHandler)(); // for optional game-side customization
void (*ReleaseHandler)();
bool PressKey (int keynum); // Returns true if this key caused the button to be pressed.
bool ReleaseKey (int keynum); // Returns true if this key is no longer pressed.
@ -107,34 +23,38 @@ struct FButtonStatus
void Reset () { bDown = bWentDown = bWentUp = false; }
};
class ButtonMap
{
TArray<FButtonStatus> Buttons;
TArray<FString> NumToName; // The internal name of the button
TMap<FName, int> NameToNum;
public:
ButtonMap();
void SetButtons(const char** names, int count);
constexpr int NumButtons() const
int NumButtons() const
{
return Buttons.Size();
}
int FindButtonIndex(const char* func) const;
FButtonStatus *FindButton(const char *func)
int FindButtonIndex(const char* func, int funclen = -1) const;
FButtonStatus* FindButton(const char* func, int funclen = -1)
{
int index = FindButtonIndex(func);
return index > -1? &Buttons[index] : nullptr;
int index = FindButtonIndex(func, funclen);
return index > -1 ? &Buttons[index] : nullptr;
}
void ResetButtonTriggers (); // Call ResetTriggers for all buttons
void ResetButtonStates (); // Same as above, but also clear bDown
FButtonStatus* GetButton(int index)
{
return &Buttons[index];
}
void ResetButtonTriggers(); // Call ResetTriggers for all buttons
void ResetButtonStates(); // Same as above, but also clear bDown
int ListActionCommands(const char* pattern);
void AddButtonTabCommands();
bool ButtonDown(int x) const

View file

@ -50,8 +50,6 @@
#include "c_cvars.h"
#include "c_buttons.h"
#include "findfile.h"
// Todo: Get rid of
#include "inputstate.h"
// MACROS ------------------------------------------------------------------
@ -173,7 +171,6 @@ FString StoredWarp;
FConsoleCommand* Commands[FConsoleCommand::HASH_SIZE];
CVAR (Bool, lookspring, true, CVAR_ARCHIVE); // Generate centerview when -mlook encountered?
// PRIVATE DATA DEFINITIONS ------------------------------------------------
@ -239,22 +236,18 @@ void C_DoCommand (const char *cmd, int keynum)
// Check if this is an action
if (*beg == '+' || *beg == '-')
{
auto button = buttonMap.FindButton(beg + 1);
if (button)
auto button = buttonMap.FindButton(beg + 1, int(end - beg - 1));
if (button != nullptr)
{
if (*beg == '+')
{
button->PressKey (keynum);
if (button->PressHandler) button->PressHandler();
}
else
{
button->ReleaseKey (keynum);
/*
if (button == &Button_Mlook && lookspring)
{
Net_WriteByte (DEM_CENTERVIEW);
}
*/
if (button->ReleaseHandler) button->ReleaseHandler();
}
return;
}
@ -462,29 +455,9 @@ FConsoleCommand* FConsoleCommand::FindByName (const char* name)
return FindNameInHashTable (Commands, name, strlen (name));
}
const char* StaticGetButtonName(int32_t func);
FConsoleCommand::FConsoleCommand (const char *name, CCmdRun runFunc)
: m_RunFunc (runFunc)
{
static bool firstTime = true;
if (firstTime)
{
unsigned int i;
firstTime = false;
// Add all the action commands for tab completion
for (i = 0; i < buttonMap.NumButtons(); i++)
{
FString tname = "+"; tname << StaticGetButtonName(i);
C_AddTabCommand (tname);
tname.Substitute('+', '-');
C_AddTabCommand (tname);
}
}
int ag = strcmp (name, "kill");
if (ag == 0)
ag=0;

View file

@ -91,6 +91,7 @@ void I_SetWindowTitle(const char* caption);
void InitENet();
void ShutdownENet();
bool AppActive;
int chatmodeon; // needed by the common console code.
FString currentGame;
FString LumpFilter;

View file

@ -35,6 +35,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "menu/menu.h"
#include "memarena.h"
#ifdef EDUKE32_STANDALONE
#define VOLUMEALL (1)
#define PLUTOPAK (1)
@ -132,8 +134,72 @@ EDUKE32_STATIC_ASSERT(7 <= MAXTILES-MAXUSERTILES);
BEGIN_DUKE_NS
static inline int32_t G_TileHasActor(int const tileNum)
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
enum GameFunction_t
{
gamefunc_Move_Forward,
gamefunc_Move_Backward,
gamefunc_Turn_Left,
gamefunc_Turn_Right,
gamefunc_Strafe,
gamefunc_Fire,
gamefunc_Open,
gamefunc_Run,
gamefunc_Alt_Fire, // Duke3D, Blood
gamefunc_Jump,
gamefunc_Crouch,
gamefunc_Look_Up,
gamefunc_Look_Down,
gamefunc_Look_Left,
gamefunc_Look_Right,
gamefunc_Strafe_Left,
gamefunc_Strafe_Right,
gamefunc_Aim_Up,
gamefunc_Aim_Down,
gamefunc_Weapon_1,
gamefunc_Weapon_2,
gamefunc_Weapon_3,
gamefunc_Weapon_4,
gamefunc_Weapon_5,
gamefunc_Weapon_6,
gamefunc_Weapon_7,
gamefunc_Weapon_8,
gamefunc_Weapon_9,
gamefunc_Weapon_10,
gamefunc_Inventory,
gamefunc_Inventory_Left,
gamefunc_Inventory_Right,
gamefunc_Holo_Duke, // Duke3D, RR
gamefunc_Jetpack,
gamefunc_NightVision,
gamefunc_MedKit,
gamefunc_TurnAround,
gamefunc_SendMessage,
gamefunc_Map,
gamefunc_Shrink_Screen,
gamefunc_Enlarge_Screen,
gamefunc_Center_View,
gamefunc_Holster_Weapon,
gamefunc_Show_Opponents_Weapon,
gamefunc_Map_Follow_Mode,
gamefunc_See_Coop_View,
gamefunc_Mouse_Aiming,
gamefunc_Toggle_Crosshair,
gamefunc_Steroids,
gamefunc_Quick_Kick,
gamefunc_Next_Weapon,
gamefunc_Previous_Weapon,
gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming,
gamefunc_Last_Weapon,
gamefunc_Alt_Weapon,
gamefunc_Third_Person_View,
gamefunc_Show_DukeMatch_Scores,
gamefunc_Toggle_Crouch, // This is the last one used by EDuke32.
NUM_ACTIONS
};
static inline int32_t G_TileHasActor(int const tileNum){
return g_tile[tileNum].execPtr!=NULL;
}

View file

@ -5573,8 +5573,70 @@ EDUKE32_STATIC_ASSERT(sizeof(DukePlayer_t)%4 == 0);
void app_loop();
static const char* actions[] = {
"Move_Forward",
"Move_Backward",
"Turn_Left",
"Turn_Right",
"Strafe",
"Fire",
"Open",
"Run",
"Alt_Fire", // Duke3D", Blood
"Jump",
"Crouch",
"Look_Up",
"Look_Down",
"Look_Left",
"Look_Right",
"Strafe_Left",
"Strafe_Right",
"Aim_Up",
"Aim_Down",
"Weapon_1",
"Weapon_2",
"Weapon_3",
"Weapon_4",
"Weapon_5",
"Weapon_6",
"Weapon_7",
"Weapon_8",
"Weapon_9",
"Weapon_10",
"Inventory",
"Inventory_Left",
"Inventory_Right",
"Holo_Duke", // Duke3D", RR
"Jetpack",
"NightVision",
"MedKit",
"TurnAround",
"SendMessage",
"Map",
"Shrink_Screen",
"Enlarge_Screen",
"Center_View",
"Holster_Weapon",
"Show_Opponents_Weapon",
"Map_Follow_Mode",
"See_Coop_View",
"Mouse_Aiming",
"Toggle_Crosshair",
"Steroids",
"Quick_Kick",
"Next_Weapon",
"Previous_Weapon",
"Dpad_Select",
"Dpad_Aiming",
"Last_Weapon",
"Alt_Weapon",
"Third_Person_View",
"Show_DukeMatch_Scores",
"Toggle_Crouch", // This is the last one used by EDuke32.
};
int GameInterface::app_main()
{
buttonMap.SetButtons(actions, NUM_ACTIONS);
g_skillCnt = 4;
ud.multimode = 1;
ud.m_monsters_off = userConfig.nomonsters;

View file

@ -4993,7 +4993,7 @@ repeatcase:
scriptSkipSpaces();
if (EDUKE32_PREDICT_FALSE((unsigned)j > NUMGAMEFUNCTIONS-1))
if (EDUKE32_PREDICT_FALSE((unsigned)j > NUM_ACTIONS-1))
{
Printf("%s:%d: error: function number exceeds number of game functions.\n",
g_scriptFileName,g_lineNumber);
@ -5029,7 +5029,7 @@ repeatcase:
g_scriptPtr--;
j = *g_scriptPtr;
if (EDUKE32_PREDICT_FALSE((unsigned)j > NUMGAMEFUNCTIONS-1))
if (EDUKE32_PREDICT_FALSE((unsigned)j > NUM_ACTIONS -1))
{
Printf("%s:%d: error: function number exceeds number of game functions.\n",
g_scriptFileName,g_lineNumber);

View file

@ -3722,7 +3722,7 @@ badindex:
int const gameFunc = Gv_GetVar(*insptr++);
int funcPos = Gv_GetVar(*insptr++);
VM_ASSERT((unsigned)quoteIndex < MAXQUOTES, "invalid quote %d\n", quoteIndex);
VM_ASSERT((unsigned)gameFunc < NUMGAMEFUNCTIONS, "invalid function %d\n", gameFunc);
VM_ASSERT((unsigned)gameFunc < NUM_ACTIONS, "invalid function %d\n", gameFunc);
auto bindings = Bindings.GetKeysForCommand(C_CON_GetButtonFunc(gameFunc));
if ((unsigned)funcPos >= bindings.Size()) funcPos = 0;
@ -3737,7 +3737,7 @@ badindex:
int const gameFunc = Gv_GetVar(*insptr++);
VM_ASSERT((unsigned)quoteIndex < MAXQUOTES, "invalid quote %d\n", quoteIndex);
VM_ASSERT((unsigned)gameFunc < NUMGAMEFUNCTIONS, "invalid function %d\n", gameFunc);
VM_ASSERT((unsigned)gameFunc < NUM_ACTIONS, "invalid function %d\n", gameFunc);
auto binding = C_CON_GetBoundKeyForLastInput(gameFunc);
if (binding.Len()) quoteMgr.FormatQuote(quoteIndex, "(%s)", binding.GetChars());

View file

@ -1796,6 +1796,63 @@ void CheckCommandLine(int argc, char const* const* argv, int &doTitle)
}
}
static const char* actions[] =
{
"Move_Forward",
"Move_Backward",
"Turn_Left",
"Turn_Right",
"Strafe",
"Fire",
"Open",
"Run",
"Alt_Fire", // Duke3D", Blood
"Jump",
"Crouch",
"Look_Up",
"Look_Down",
"Look_Left",
"Look_Right",
"Strafe_Left",
"Strafe_Right",
"Aim_Up",
"Aim_Down",
"Weapon_1",
"Weapon_2",
"Weapon_3",
"Weapon_4",
"Weapon_5",
"Weapon_6",
"Weapon_7",
"Weapon_8",
"Weapon_9",
"Weapon_10",
"Inventory",
"Inventory_Left",
"Inventory_Right",
"TurnAround",
"SendMessage",
"Map",
"Shrink_Screen",
"Enlarge_Screen",
"Center_View",
"Holster_Weapon",
"Show_Opponents_Weapon",
"Map_Follow_Mode",
"See_Coop_View",
"Mouse_Aiming",
"Toggle_Crosshair",
"Next_Weapon",
"Previous_Weapon",
"Dpad_Select",
"Dpad_Aiming",
"Last_Weapon",
"Alt_Weapon",
"Third_Person_View",
"Toggle_Crouch", // This is the last one used by EDuke32.
"Zoom_In", // Map controls should not pollute the global button namespace.
"Zoom_Out",
};
int GameInterface::app_main()
{
@ -1806,6 +1863,8 @@ int GameInterface::app_main()
int stopTitle = kFalse;
levelnew = 1;
buttonMap.SetButtons(actions, NUM_ACTIONS);
help_disabled = true;
// Create the global level table. Parts of the engine need it, even though the game itself does not.
for (int i = 0; i <= 32; i++)

View file

@ -35,6 +35,67 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
enum GameFunction_t
{
gamefunc_Move_Forward,
gamefunc_Move_Backward,
gamefunc_Turn_Left,
gamefunc_Turn_Right,
gamefunc_Strafe,
gamefunc_Fire,
gamefunc_Open,
gamefunc_Run,
gamefunc_Alt_Fire, // Duke3D, Blood
gamefunc_Jump,
gamefunc_Crouch,
gamefunc_Look_Up,
gamefunc_Look_Down,
gamefunc_Look_Left,
gamefunc_Look_Right,
gamefunc_Strafe_Left,
gamefunc_Strafe_Right,
gamefunc_Aim_Up,
gamefunc_Aim_Down,
gamefunc_Weapon_1,
gamefunc_Weapon_2,
gamefunc_Weapon_3,
gamefunc_Weapon_4,
gamefunc_Weapon_5,
gamefunc_Weapon_6,
gamefunc_Weapon_7,
gamefunc_Weapon_8,
gamefunc_Weapon_9,
gamefunc_Weapon_10,
gamefunc_Inventory,
gamefunc_Inventory_Left,
gamefunc_Inventory_Right,
gamefunc_TurnAround,
gamefunc_SendMessage,
gamefunc_Map,
gamefunc_Shrink_Screen,
gamefunc_Enlarge_Screen,
gamefunc_Center_View,
gamefunc_Holster_Weapon,
gamefunc_Show_Opponents_Weapon,
gamefunc_Map_Follow_Mode,
gamefunc_See_Coop_View,
gamefunc_Mouse_Aiming,
gamefunc_Toggle_Crosshair,
gamefunc_Next_Weapon,
gamefunc_Previous_Weapon,
gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming,
gamefunc_Last_Weapon,
gamefunc_Alt_Weapon,
gamefunc_Third_Person_View,
gamefunc_Toggle_Crouch, // This is the last one used by EDuke32.
gamefunc_Zoom_In, // Map controls should not pollute the global button namespace.
gamefunc_Zoom_Out,
NUM_ACTIONS,
};
#define kTimerTicks 120
#ifdef __WATCOMC__

View file

@ -132,6 +132,71 @@ END_RR_NS
BEGIN_RR_NS
// Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name.
enum GameFunction_t
{
gamefunc_Move_Forward,
gamefunc_Move_Backward,
gamefunc_Turn_Left,
gamefunc_Turn_Right,
gamefunc_Strafe,
gamefunc_Fire,
gamefunc_Open,
gamefunc_Run,
gamefunc_Alt_Fire, // Duke3D, Blood
gamefunc_Jump,
gamefunc_Crouch,
gamefunc_Look_Up,
gamefunc_Look_Down,
gamefunc_Look_Left,
gamefunc_Look_Right,
gamefunc_Strafe_Left,
gamefunc_Strafe_Right,
gamefunc_Aim_Up,
gamefunc_Aim_Down,
gamefunc_Weapon_1,
gamefunc_Weapon_2,
gamefunc_Weapon_3,
gamefunc_Weapon_4,
gamefunc_Weapon_5,
gamefunc_Weapon_6,
gamefunc_Weapon_7,
gamefunc_Weapon_8,
gamefunc_Weapon_9,
gamefunc_Weapon_10,
gamefunc_Inventory,
gamefunc_Inventory_Left,
gamefunc_Inventory_Right,
gamefunc_Holo_Duke, // Duke3D, RR
gamefunc_Jetpack,
gamefunc_NightVision,
gamefunc_MedKit,
gamefunc_TurnAround,
gamefunc_SendMessage,
gamefunc_Map,
gamefunc_Shrink_Screen,
gamefunc_Enlarge_Screen,
gamefunc_Center_View,
gamefunc_Holster_Weapon,
gamefunc_Show_Opponents_Weapon,
gamefunc_Map_Follow_Mode,
gamefunc_See_Coop_View,
gamefunc_Mouse_Aiming,
gamefunc_Toggle_Crosshair,
gamefunc_Steroids,
gamefunc_Quick_Kick,
gamefunc_Next_Weapon,
gamefunc_Previous_Weapon,
gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming,
gamefunc_Last_Weapon,
gamefunc_Alt_Weapon,
gamefunc_Third_Person_View,
gamefunc_Show_DukeMatch_Scores,
gamefunc_Toggle_Crouch, // This is the last one used by EDuke32.
NUM_ACTIONS
};
static inline int32_t G_HaveActor(int spriteNum)
{
return g_tile[spriteNum].execPtr!=NULL;

View file

@ -6957,9 +6957,72 @@ void app_loop();
EDUKE32_STATIC_ASSERT(sizeof(actor_t)%4 == 0);
EDUKE32_STATIC_ASSERT(sizeof(DukePlayer_t)%4 == 0);
static const char* actions[] = {
"Move_Forward",
"Move_Backward",
"Turn_Left",
"Turn_Right",
"Strafe",
"Fire",
"Open",
"Run",
"Alt_Fire", // Duke3D", Blood
"Jump",
"Crouch",
"Look_Up",
"Look_Down",
"Look_Left",
"Look_Right",
"Strafe_Left",
"Strafe_Right",
"Aim_Up",
"Aim_Down",
"Weapon_1",
"Weapon_2",
"Weapon_3",
"Weapon_4",
"Weapon_5",
"Weapon_6",
"Weapon_7",
"Weapon_8",
"Weapon_9",
"Weapon_10",
"Inventory",
"Inventory_Left",
"Inventory_Right",
"Holo_Duke", // Duke3D", RR
"Jetpack",
"NightVision",
"MedKit",
"TurnAround",
"SendMessage",
"Map",
"Shrink_Screen",
"Enlarge_Screen",
"Center_View",
"Holster_Weapon",
"Show_Opponents_Weapon",
"Map_Follow_Mode",
"See_Coop_View",
"Mouse_Aiming",
"Toggle_Crosshair",
"Steroids",
"Quick_Kick",
"Next_Weapon",
"Previous_Weapon",
"Dpad_Select",
"Dpad_Aiming",
"Last_Weapon",
"Alt_Weapon",
"Third_Person_View",
"Show_DukeMatch_Scores",
"Toggle_Crouch", // This is the last one used by EDuke32.
};
int GameInterface::app_main()
{
playing_rr = 1;
buttonMap.SetButtons(actions, NUM_ACTIONS);
playing_rr = 1;
g_skillCnt = 4;
ud.multimode = 1;
ud.m_monsters_off = userConfig.nomonsters;

View file

@ -502,7 +502,7 @@ DemoPlayBack(void)
}
}
if (buttonMap.ButtonDown(gamefunc_See_Co_Op_View))
if (buttonMap.ButtonDown(gamefunc_See_Coop_View))
{
screenpeek += 1;
if (screenpeek > numplayers-1)

View file

@ -2672,6 +2672,68 @@ void CommandLineHelp(char const * const * argv)
{
}
static const char* actions[] = {
"Move_Forward",
"Move_Backward",
"Turn_Left",
"Turn_Right",
"Strafe",
"Fire",
"Open",
"Run",
"Alt_Fire", // Duke3D", Blood
"Jump",
"Crouch",
"Look_Up",
"Look_Down",
"Look_Left",
"Look_Right",
"Strafe_Left",
"Strafe_Right",
"Aim_Up",
"Aim_Down",
"Weapon_1",
"Weapon_2",
"Weapon_3",
"Weapon_4",
"Weapon_5",
"Weapon_6",
"Weapon_7",
"Weapon_8",
"Weapon_9",
"Weapon_10",
"Inventory",
"Inventory_Left",
"Inventory_Right",
"NightVision",
"MedKit",
"TurnAround",
"SendMessage",
"Map",
"Shrink_Screen",
"Enlarge_Screen",
"Center_View",
"Holster_Weapon",
"Show_Opponents_Weapon",
"Map_Follow_Mode",
"See_Coop_View",
"Mouse_Aiming",
"Toggle_Crosshair",
"Next_Weapon",
"Previous_Weapon",
"Dpad_Select",
"Dpad_Aiming",
"Last_Weapon",
"Alt_Weapon",
"Third_Person_View",
"Toggle_Crouch", // This is the last one used by EDuke32"",
"Smoke_Bomb",
"Gas_Bomb",
"Flash_Bomb",
"Caltrops",
};
int32_t GameInterface::app_main()
{
int i;
@ -2680,6 +2742,7 @@ int32_t GameInterface::app_main()
void gameinput(void);
int cnt = 0;
buttonMap.SetButtons(actions, NUM_ACTIONS);
automapping = 1;
BorderAdjust = true;
SW_ExtInit();
@ -3584,11 +3647,11 @@ void getinput(int const playerNum)
inv_hotkey = 0;
if (buttonMap.ButtonDown(gamefunc_Med_Kit))
if (buttonMap.ButtonDown(gamefunc_MedKit))
inv_hotkey = INVENTORY_MEDKIT+1;
if (buttonMap.ButtonDown(gamefunc_Smoke_Bomb))
inv_hotkey = INVENTORY_CLOAK+1;
if (buttonMap.ButtonDown(gamefunc_Night_Vision))
if (buttonMap.ButtonDown(gamefunc_NightVision))
inv_hotkey = INVENTORY_NIGHT_VISION+1;
if (buttonMap.ButtonDown(gamefunc_Gas_Bomb))
inv_hotkey = INVENTORY_CHEMBOMB+1;
@ -3617,9 +3680,9 @@ void getinput(int const playerNum)
if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE)
{
if (buttonMap.ButtonDown(gamefunc_See_Co_Op_View))
if (buttonMap.ButtonDown(gamefunc_See_Coop_View))
{
buttonMap.ClearButton(gamefunc_See_Co_Op_View);
buttonMap.ClearButton(gamefunc_See_Coop_View);
screenpeek = connectpoint2[screenpeek];

View file

@ -49,6 +49,69 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS
enum GameFunction_t
{
gamefunc_Move_Forward,
gamefunc_Move_Backward,
gamefunc_Turn_Left,
gamefunc_Turn_Right,
gamefunc_Strafe,
gamefunc_Fire,
gamefunc_Open,
gamefunc_Run,
gamefunc_Alt_Fire, // Duke3D, Blood
gamefunc_Jump,
gamefunc_Crouch,
gamefunc_Look_Up,
gamefunc_Look_Down,
gamefunc_Look_Left,
gamefunc_Look_Right,
gamefunc_Strafe_Left,
gamefunc_Strafe_Right,
gamefunc_Aim_Up,
gamefunc_Aim_Down,
gamefunc_Weapon_1,
gamefunc_Weapon_2,
gamefunc_Weapon_3,
gamefunc_Weapon_4,
gamefunc_Weapon_5,
gamefunc_Weapon_6,
gamefunc_Weapon_7,
gamefunc_Weapon_8,
gamefunc_Weapon_9,
gamefunc_Weapon_10,
gamefunc_Inventory,
gamefunc_Inventory_Left,
gamefunc_Inventory_Right,
gamefunc_NightVision,
gamefunc_MedKit,
gamefunc_TurnAround,
gamefunc_SendMessage,
gamefunc_Map,
gamefunc_Shrink_Screen,
gamefunc_Enlarge_Screen,
gamefunc_Center_View,
gamefunc_Holster_Weapon,
gamefunc_Show_Opponents_Weapon,
gamefunc_Map_Follow_Mode,
gamefunc_See_Coop_View,
gamefunc_Mouse_Aiming,
gamefunc_Toggle_Crosshair,
gamefunc_Next_Weapon,
gamefunc_Previous_Weapon,
gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming,
gamefunc_Last_Weapon,
gamefunc_Alt_Weapon,
gamefunc_Third_Person_View,
gamefunc_Toggle_Crouch, // This is the last one used by EDuke32.
gamefunc_Smoke_Bomb, // and these by ShadowWarrior (todo: There's quite a bit of potential for consolidation here - is it worth it?)
gamefunc_Gas_Bomb,
gamefunc_Flash_Bomb,
gamefunc_Caltrops,
NUM_ACTIONS
};
//#define SW_SHAREWARE 1 // This determines whether game is shareware compile or not!
extern char isShareware;
#define SW_SHAREWARE (isShareware)