- migrated the last 3 remaining UI controls to CCMDs.

This commit is contained in:
Christoph Oelckers 2020-08-29 17:49:15 +02:00
parent eb34b41716
commit 56d0647412
27 changed files with 195 additions and 208 deletions

View file

@ -63,7 +63,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
void LocalKeys(void);
void InitCheats();
bool bNoDemo = false;
@ -893,7 +892,6 @@ void GameInterface::RunGameFrame()
case GS_LEVEL:
gameTicker();
LocalKeys();
break;
case GS_FINALE:

View file

@ -64,44 +64,6 @@ float gViewAngleAdjust;
float gViewLookAdjust;
int gViewLookRecenter;
void LocalKeys(void)
{
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
{
buttonMap.ClearButton(gamefunc_Third_Person_View);
if (gViewPos > VIEWPOS_0)
gViewPos = VIEWPOS_0;
else
gViewPos = VIEWPOS_1;
}
if (buttonMap.ButtonDown(gamefunc_See_Coop_View))
{
buttonMap.ClearButton(gamefunc_See_Coop_View);
if (gGameOptions.nGameType == 1)
{
gViewIndex = connectpoint2[gViewIndex];
if (gViewIndex == -1)
gViewIndex = connecthead;
gView = &gPlayer[gViewIndex];
}
else if (gGameOptions.nGameType == 3)
{
int oldViewIndex = gViewIndex;
do
{
gViewIndex = connectpoint2[gViewIndex];
if (gViewIndex == -1)
gViewIndex = connecthead;
if (oldViewIndex == gViewIndex || gMe->teamId == gPlayer[gViewIndex].teamId)
break;
} while (oldViewIndex != gViewIndex);
gView = &gPlayer[gViewIndex];
}
}
}
void ctrlGetInput(void)
{
int prevPauseState = paused;
@ -162,12 +124,6 @@ void ctrlGetInput(void)
{
}
if (buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon))
{
buttonMap.ClearButton(gamefunc_Show_Opponents_Weapon);
cl_showweapon = (cl_showweapon + 1) & 3;
}
if (gInput.actions & (SB_LOOK_UP|SB_LOOK_DOWN))
gInput.actions |= SB_CENTERVIEW;

View file

@ -204,17 +204,62 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
return CCMD_OK;
}
static int osdcmd_third_person_view(CCmdFuncPtr parm)
{
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
if (gViewPos > VIEWPOS_0)
gViewPos = VIEWPOS_0;
else
gViewPos = VIEWPOS_1;
return CCMD_OK;
}
static int osdcmd_coop_view(CCmdFuncPtr parm)
{
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
if (gGameOptions.nGameType == 1)
{
gViewIndex = connectpoint2[gViewIndex];
if (gViewIndex == -1)
gViewIndex = connecthead;
gView = &gPlayer[gViewIndex];
}
else if (gGameOptions.nGameType == 3)
{
int oldViewIndex = gViewIndex;
do
{
gViewIndex = connectpoint2[gViewIndex];
if (gViewIndex == -1)
gViewIndex = connecthead;
if (oldViewIndex == gViewIndex || gMe->teamId == gPlayer[gViewIndex].teamId)
break;
} while (oldViewIndex != gViewIndex);
gView = &gPlayer[gViewIndex];
}
return CCMD_OK;
}
static int osdcmd_show_weapon(CCmdFuncPtr parm)
{
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
cl_showweapon = (cl_showweapon + 1) & 3;
return CCMD_OK;
}
int32_t registerosdcommands(void)
{
C_RegisterFunction("map","map <mapname>: loads the given map", osdcmd_map);
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
C_RegisterFunction("god","god: toggles god mode", osdcmd_god);
C_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
C_RegisterFunction("levelwarp","levelwarp <e> <m>: warp to episode 'e' and map 'm'", osdcmd_levelwarp);
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_coop_view);
C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_show_weapon);
return 0;
}

View file

@ -235,12 +235,9 @@ void SetupGameButtons()
"Aim_Down",
"Shrink_Screen",
"Enlarge_Screen",
"Show_Opponents_Weapon",
"See_Coop_View",
"Mouse_Aiming",
"Dpad_Select",
"Dpad_Aiming",
"Third_Person_View",
"Toggle_Crouch",
"Quick_Kick",
};

View file

@ -87,12 +87,9 @@ enum GameFunction_t
gamefunc_Aim_Down,
gamefunc_Shrink_Screen, // Automap only
gamefunc_Enlarge_Screen, // Automap only
gamefunc_Show_Opponents_Weapon, // CCMD
gamefunc_See_Coop_View, // CCMD
gamefunc_Mouse_Aiming,
gamefunc_Dpad_Select,
gamefunc_Dpad_Aiming,
gamefunc_Third_Person_View, // CCMD
gamefunc_Toggle_Crouch,
gamefunc_Quick_Kick,
NUM_ACTIONS

View file

@ -85,7 +85,6 @@ void StatusMessage(int messageTime, const char *fmt, ...);
int DoSpiritHead();
void CheckKeys();
void CheckKeys2();
void GameTicker();
void InitLevel(int);

View file

@ -254,7 +254,6 @@ void CheckProgression()
void GameLoop()
{
CheckKeys();
GameTicker();
PlayerInterruptKeys(true);
UpdateSounds();

View file

@ -87,33 +87,6 @@ void SendInput()
}
void CheckKeys()
{
// go to 3rd person view?
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
{
if (!nFreeze)
{
if (bCamera) {
bCamera = false;
}
else {
bCamera = true;
}
if (bCamera)
GrabPalette();
}
buttonMap.ClearButton(gamefunc_Third_Person_View);
return;
}
if (paused)
{
return;
}
}
static int32_t nonsharedtimer;
void CheckKeys2()

View file

@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "aistuff.h"
#include "ps_input.h"
#include "cheathandler.h"
#include "gamestate.h"
BEGIN_PS_NS
@ -196,7 +197,29 @@ static int osdcmd_spawn(CCmdFuncPtr parm)
return CCMD_OK;
}
static int osdcmd_third_person_view(CCmdFuncPtr parm)
{
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
if (!nFreeze)
{
if (bCamera) {
bCamera = false;
}
else {
bCamera = true;
}
if (bCamera)
GrabPalette();
}
return CCMD_OK;
}
static int osdcmd_noop(CCmdFuncPtr parm)
{
// this is for silencing key bindings only.
return CCMD_OK;
}
int32_t registerosdcommands(void)
{
@ -209,6 +232,9 @@ int32_t registerosdcommands(void)
C_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
C_RegisterFunction("spawn","spawn <creaturetype>: spawns a creature",osdcmd_spawn);
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_noop);
C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_noop);
return 0;
}

View file

@ -33,6 +33,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "mapinfo.h"
#include "cheathandler.h"
#include "c_dispatch.h"
#include "gamestate.h"
BEGIN_DUKE_NS
@ -285,22 +286,62 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
return CCMD_OK;
}
static int osdcmd_third_person_view(CCmdFuncPtr parm)
{
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
if (!isRRRA() || (!ps[myconnectindex].OnMotorcycle && !ps[myconnectindex].OnBoat))
{
if (ps[myconnectindex].over_shoulder_on)
ps[myconnectindex].over_shoulder_on = 0;
else
{
ps[myconnectindex].over_shoulder_on = 1;
cameradist = 0;
cameraclock = gameclock;
}
FTA(QUOTE_VIEW_MODE_OFF + ps[myconnectindex].over_shoulder_on, &ps[myconnectindex]);
}
return CCMD_OK;
}
static int osdcmd_coop_view(CCmdFuncPtr parm)
{
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
if (ud.coop || ud.recstat == 2)
{
screenpeek = connectpoint2[screenpeek];
if (screenpeek == -1) screenpeek = 0;
}
return CCMD_OK;
}
static int osdcmd_show_weapon(CCmdFuncPtr parm)
{
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
if (ud.multimode > 1)
{
ud.showweapons = 1 - ud.showweapons;
cl_showweapon = ud.showweapons;
FTA(QUOTE_WEAPON_MODE_OFF - ud.showweapons, &ps[screenpeek]);
}
return CCMD_OK;
}
int registerosdcommands(void)
{
C_RegisterFunction("map","map <mapname>: warp to the given map, identified by its name", ccmd_map);
C_RegisterFunction("levelwarp","levelwarp <e> <m>: warp to episode 'e' and map 'm'", ccmd_levelwarp);
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", ccmd_give);
C_RegisterFunction("god","god: toggles god mode", ccmd_god);
C_RegisterFunction("noclip","noclip: toggles clipping mode", ccmd_noclip);
C_RegisterFunction("restartmap", "restartmap: restarts the current map", ccmd_restartmap);
C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",ccmd_spawn);
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_coop_view);
C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_show_weapon);
return 0;
}

View file

@ -65,48 +65,9 @@ void GameInterface::ResetFollowPos(bool message)
void nonsharedkeys(void)
{
if (ud.recstat == 2)
{
ControlInfo noshareinfo;
CONTROL_GetInput(&noshareinfo);
}
if (System_WantGuiCapture())
return;
if (buttonMap.ButtonDown(gamefunc_See_Coop_View) && (ud.coop || ud.recstat == 2))
{
buttonMap.ClearButton(gamefunc_See_Coop_View);
screenpeek = connectpoint2[screenpeek];
if (screenpeek == -1) screenpeek = 0;
}
if ((ud.multimode > 1) && buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon))
{
buttonMap.ClearButton(gamefunc_Show_Opponents_Weapon);
ud.showweapons = 1 - ud.showweapons;
cl_showweapon = ud.showweapons;
FTA(QUOTE_WEAPON_MODE_OFF - ud.showweapons, &ps[screenpeek]);
}
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
{
buttonMap.ClearButton(gamefunc_Third_Person_View);
if (!isRRRA() || (!ps[myconnectindex].OnMotorcycle && !ps[myconnectindex].OnBoat))
{
if (ps[myconnectindex].over_shoulder_on)
ps[myconnectindex].over_shoulder_on = 0;
else
{
ps[myconnectindex].over_shoulder_on = 1;
cameradist = 0;
cameraclock = gameclock;
}
FTA(QUOTE_VIEW_MODE_OFF + ps[myconnectindex].over_shoulder_on, &ps[myconnectindex]);
}
}
if (automapMode != am_off)
{
int j;

View file

@ -34,36 +34,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS
void
FunctionKeys(PLAYERp pp)
{
// F7 VIEW control
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
{
buttonMap.ClearButton(gamefunc_Third_Person_View);
if (inputState.ShiftPressed())
{
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
pp->view_outside_dang = NORM_ANGLE(pp->view_outside_dang + 256);
}
else
{
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
{
RESET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
}
else
{
SET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
pp->camera_dist = 0;
}
}
}
}
double elapsedInputTicks;
double scaleAdjustmentToInterval(double x) { return x * (120 / synctics) / (1000.0 / elapsedInputTicks); }
@ -388,35 +358,6 @@ getinput(InputPacket *loc, SWBOOL tied)
short const which_weapon = u->WeaponNum + 1;
loc->setNewWeapon(which_weapon);
}
if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE)
{
if (buttonMap.ButtonDown(gamefunc_See_Coop_View))
{
buttonMap.ClearButton(gamefunc_See_Coop_View);
screenpeek = connectpoint2[screenpeek];
if (screenpeek < 0)
screenpeek = connecthead;
if (screenpeek == myconnectindex)
{
// JBF: figure out what's going on here
DoPlayerDivePalette(pp); // Check Dive again
DoPlayerNightVisionPalette(pp); // Check Night Vision again
}
else
{
PLAYERp tp = Player+screenpeek;
DoPlayerDivePalette(tp);
DoPlayerNightVisionPalette(tp);
}
}
}
if (!tied)
FunctionKeys(pp);
}
END_SW_NS

View file

@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "jsector.h"
#include "network.h"
#include "gamestate.h"
#include "player.h"
BEGIN_SW_NS
@ -237,6 +238,62 @@ static int osdcmd_mirror(CCmdFuncPtr parm)
return CCMD_OK;
}
static int osdcmd_third_person_view(CCmdFuncPtr parm)
{
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
auto pp = &Player[myconnectindex];
if (inputState.ShiftPressed())
{
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
pp->view_outside_dang = NORM_ANGLE(pp->view_outside_dang + 256);
}
else
{
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
{
RESET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
}
else
{
SET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
pp->camera_dist = 0;
}
}
return CCMD_OK;
}
static int osdcmd_coop_view(CCmdFuncPtr parm)
{
if (gamestate != GS_LEVEL || System_WantGuiCapture()) return CCMD_OK;
if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE)
{
screenpeek = connectpoint2[screenpeek];
if (screenpeek < 0)
screenpeek = connecthead;
if (screenpeek == myconnectindex)
{
// JBF: figure out what's going on here
auto pp = &Player[myconnectindex];
DoPlayerDivePalette(pp); // Check Dive again
DoPlayerNightVisionPalette(pp); // Check Night Vision again
}
else
{
PLAYERp tp = Player + screenpeek;
DoPlayerDivePalette(tp);
DoPlayerNightVisionPalette(tp);
}
}
return CCMD_OK;
}
static int osdcmd_noop(CCmdFuncPtr parm)
{
// this is for silencing key bindings only.
return CCMD_OK;
}
int32_t registerosdcommands(void)
{
@ -244,17 +301,14 @@ int32_t registerosdcommands(void)
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
C_RegisterFunction("god","god: toggles god mode", osdcmd_god);
C_RegisterFunction("bunny", "bunny: toggles bunny rocket mode", osdcmd_bunny);
C_RegisterFunction("mirror", "mirror [mirrornum]: print mirror debug info", osdcmd_mirror);
C_RegisterFunction("mirror_debug", "mirror [mirrornum]: print mirror debug info", osdcmd_mirror);
C_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
C_RegisterFunction("levelwarp", "levelwarp <num>: warp to level", osdcmd_levelwarp);
C_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap);
// C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);
C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view);
C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_coop_view);
C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_noop);
return 0;
}

View file

@ -6,7 +6,7 @@ F3 "openloadmenu"
F4 "openmenu SoundOptions"
F5 "openmenu OptionsMenu" //this key performs some fuckery with the music in Duke Nukem,so the default here is Blood's.
F6 "quicksave"
F7 "+Third_Person_View"
F7 "third_person_view"
F8 "togglemessages"
F9 "quickload"
F10 "menu_endgame"
@ -41,7 +41,7 @@ mapbind - "+Shrink_Screen"
mapbind = "+Enlarge_Screen"
- "sizedown"
= "sizeup"
K "+See_Coop_View"
K "coop_view"
Mouse1 "+Fire"

View file

@ -16,5 +16,5 @@ mapbind KP- "+Shrink_Screen"
mapbind KP+ "+Enlarge_Screen"
- "sizedown"
+ "sizeup""
Y "+Show_Opponents_Weapon"
Y "show_weapon"
CapsLock "toggle cl_autorun"

View file

@ -685,7 +685,7 @@ OptionMenu "OtherControlsMenu"// protected
MapControl "$MAPCNTRLMNU_ZOOMOUT" , "+shrink_screen"
StaticText ""
Control "$CNTRLMNU_CHASECAM" , "+third_person_view"
Control "$CNTRLMNU_CHASECAM" , "third_person_view"
StaticText ""
Control "$CNTRLMNU_SCREENSHOT" , "screenshot"

View file

@ -1,5 +1,5 @@
//
W "+Show_Opponents_Weapon"
W "show_weapon"
B "useitem 3"
C "useitem 2"
P "slot 11"

View file

@ -1,5 +1,5 @@
//
W "+Show_Opponents_Weapon"
W "show_weapon"
B "useitem 3"
C "useitem 2"
P "slot 11"

View file

@ -4,4 +4,4 @@ Q "+Quick_Kick"
J "useitem 4"
N "useitem 5"
M "useitem 1"
W "+Show_Opponents_Weapon"
W "show_weapon"

View file

@ -1,7 +1,7 @@
//
R "useitem 2"
` "+Quick_Kick"
W "+Show_Opponents_Weapon"
W "show_weapon"
H "Holo_Duke"
J "useitem 4"
N "useitem 5"

View file

@ -4,4 +4,4 @@ Q "+Quick_Kick"
J "useitem 4"
N "useitem 5"
M "useitem 1"
W "+Show_Opponents_Weapon"
W "show_weapon"

View file

@ -1,7 +1,7 @@
//
R "useitem 2"
` "+Quick_Kick"
W "+Show_Opponents_Weapon"
W "show_weapon"
H "useitem 3"
J "useitem 4"
N "useitem 5"

View file

@ -1,5 +1,5 @@
//
V "+Show_Opponents_Weapon"
V "show_weapon"
B "useitem 3"
C "useitem 4"
Y "useitem 5"

View file

@ -1,4 +1,4 @@
E "+Show_Opponents_Weapon"
E "show_weapon"
M "useitem 2"
Q "+Quick_Kick"
B "useitem 3"

View file

@ -1,5 +1,5 @@
V "toggleconsole"
E "+Show_Opponents_Weapon"
E "show_weapon"
M "useitem 2"
` "+Quick_Kick"
B "useitem 3"

View file

@ -4,4 +4,4 @@ Q "+Quick_Kick"
J "useitem 4"
N "useitem 5"
M "useitem 1"
W "+Show_Opponents_Weapon"
W "show_weapon"

View file

@ -1,7 +1,7 @@
//
R "useitem 2"
` "+Quick_Kick"
W "+Show_Opponents_Weapon"
W "show_weapon"
H "useitem 3"
J "useitem 4"
N "useitem 5"