summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9bd99e6)
raw | patch | inline | side by side (parent: 9bd99e6)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 5 Jun 2017 15:51:06 +0000 (18:51 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 5 Jun 2017 15:57:48 +0000 (18:57 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_language.pas | patch | blob | history | |
src/game/g_menu.pas | patch | blob | history | |
src/game/g_options.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index baf0f630cdbe3414543ba7107537817dbd33e31c..110111e6ca492084d47e8488d0a32138a9c66359 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
gEvents: Array of TGameEvent;
gDelayedEvents: Array of TDelayedEvent;
+ // move button values:
+ // bits 0-1: l/r state:
+ // 0: neither left, nor right pressed
+ // 1: left pressed
+ // 2: right pressed
+ // bits 4-5: l/r state when strafe was pressed
P1MoveButton: Byte = 0;
P2MoveButton: Byte = 0;
procedure processPlayerControls (plr: TPlayer; var ctrl: TPlayerControl; var MoveButton: Byte; p2hack: Boolean=false);
var
time: Word;
+ strafeDir: Byte;
begin
if (plr = nil) then exit;
if (p2hack) then time := 1000 else time := 1;
+ strafeDir := MoveButton shr 4;
+ MoveButton := MoveButton and $0F;
with ctrl do
begin
if isKeyPressed(KeyLeft, KeyLeft2) and (not isKeyPressed(KeyRight, KeyRight2)) then MoveButton := 1 // Íàæàòà òîëüêî "Âëåâî"
if MoveButton = 1 then plr.PressKey(KEY_LEFT, time)
else if MoveButton = 2 then plr.PressKey(KEY_RIGHT, time);
- // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
- if (MoveButton = 2) and isKeyPressed(KeyLeft, KeyLeft2) then plr.SetDirection(D_LEFT)
- // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
- else if (MoveButton = 1) and isKeyPressed(KeyRight, KeyRight2) then plr.SetDirection(D_RIGHT)
- // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
- else if MoveButton <> 0 then plr.SetDirection(TDirection(MoveButton-1));
+ // if we have "strafe" key, turn off old strafe mechanics
+ if isKeyPressed(KeyStrafe, KeyStrafe2) then
+ begin
+ // new strafe mechanics
+ if (strafeDir = 0) then strafeDir := MoveButton; // start strafing
+ // now set direction according to strafe
+ if (strafeDir = 1) then plr.SetDirection(D_LEFT)
+ else if (strafeDir = 2) then plr.SetDirection(D_RIGHT)
+ else plr.SetDirection(TDirection(MoveButton-1));
+ end
+ else
+ begin
+ strafeDir := 0; // not strafing anymore
+ // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
+ if (MoveButton = 2) and isKeyPressed(KeyLeft, KeyLeft2) then plr.SetDirection(D_LEFT)
+ // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
+ else if (MoveButton = 1) and isKeyPressed(KeyRight, KeyRight2) then plr.SetDirection(D_RIGHT)
+ // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
+ else if MoveButton <> 0 then plr.SetDirection(TDirection(MoveButton-1));
+ end;
+
+ // fix movebutton state
+ MoveButton := MoveButton or (strafeDir shl 4);
// Îñòàëüíûå êëàâèøè:
if isKeyPressed(KeyJump, KeyJump2) then plr.PressKey(KEY_JUMP, time);
index 1d90b6902b56e7404295c14864e4c7bf4bab8c97..d340408dccfb1ef8d46c8714fcb9c90333cbcfe2 100644 (file)
--- a/src/game/g_language.pas
+++ b/src/game/g_language.pas
I_MENU_CONTROL_USE,
I_MENU_CONTROL_NEXT_WEAPON,
I_MENU_CONTROL_PREV_WEAPON,
+ I_MENU_CONTROL_STRAFE,
I_MENU_COUNT_NONE,
I_MENU_COUNT_SMALL,
'Îñòàëîñü %d ñåêóíä äî ñëåäóþùåãî ðàóíäà'),
('MENU LOADING', 'Loading...',
'Çàãðóçêà...'),
- ('MENU PLAYER 1', 'Player 1',
- 'Ïåðâûé èãðîê'),
- ('MENU PLAYER 2', 'Player 2',
- 'Âòîðîé èãðîê'),
- ('MENU PLAYER 1 ALT', 'Player 1 ALT',
- 'Ïåðâûé èãðîê ALT'),
- ('MENU PLAYER 2 ALT', 'Player 2 ALT',
- 'Âòîðîé èãðîê ALT'),
+ ('MENU PLAYER 1', 'Player 1 KEYBOARD',
+ 'Ïåðâûé èãðîê, êëàâèàòóðà'),
+ ('MENU PLAYER 2', 'Player 2 KEYBOARD',
+ 'Âòîðîé èãðîê, êëàâèàòóðà'),
+ ('MENU PLAYER 1 ALT', 'Player 1 GAMEPAD',
+ 'Ïåðâûé èãðîê GAMEPAD'),
+ ('MENU PLAYER 2 ALT', 'Player 2 GAMEPAD',
+ 'Âòîðîé èãðîê GAMEPAD'),
('MENU CONTROL JOYSTICKS', 'Joystick Settings',
'Íàñòðîéêè äæîéñòèêîâ'),
'Ñëåä. îðóæèå:'),
('MENU CONTROL PREV WEAPON', 'Prev weapon:',
'Ïðåä. îðóæèå:'),
+ ('MENU CONTROL STRAFE', 'Strafe:',
+ 'Ñòðýéô:'),
('MENU COUNT NONE', 'None',
'Íåò'),
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index bdf925b1ea2d897d51f141164006f9b91a16a950..5cd389bf42ff5b970267fe35e77ca35e9cb9cac5 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
KeyNextWeapon2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key;
KeyPrevWeapon2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key;
KeyOpen2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key;
+ KeyStrafe2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key;
end;
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
KeyNextWeapon2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key;
KeyPrevWeapon2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key;
KeyOpen2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key;
+ KeyStrafe2 := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key;
end;
if e_JoysticksAvailable > 0 then
TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key := KeyNextWeapon2;
TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key := KeyPrevWeapon2;
TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key := KeyOpen2;
+ TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key := KeyStrafe2;
end;
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key := KeyNextWeapon2;
TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key := KeyPrevWeapon2;
TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_USE])).Key := KeyOpen2;
+ TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key := KeyStrafe2;
end;
if e_JoysticksAvailable > 0 then
AddKeyRead(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
AddKeyRead(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
AddKeyRead(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
+ AddKeyRead(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
end;
Menu.DefControl := 'mOptionsControlsP1MenuAlt';
g_GUI_AddWindow(Menu);
AddKeyRead(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
AddKeyRead(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
AddKeyRead(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
+ AddKeyRead(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
end;
Menu.DefControl := 'mOptionsControlsP2MenuAlt';
g_GUI_AddWindow(Menu);
diff --git a/src/game/g_options.pas b/src/game/g_options.pas
index 65e6f21188d331d1e0566db37a32c5eb90c2720e..2ad3e6e497fd99f58d1b45c16d61a0b93dd83c9f 100644 (file)
--- a/src/game/g_options.pas
+++ b/src/game/g_options.pas
KeyNextWeapon: Word;
KeyPrevWeapon: Word;
KeyOpen: Word;
+ KeyStrafe: Word;
KeyRight2: Word;
KeyLeft2: Word;
KeyNextWeapon2: Word;
KeyPrevWeapon2: Word;
KeyOpen2: Word;
+ KeyStrafe2: Word;
end;
TGameControls = record
KeyNextWeapon := 73;
KeyPrevWeapon := 71;
KeyOpen := 54;
+ KeyStrafe := 0;
KeyRight2 := 0;
KeyLeft2 := 0;
KeyNextWeapon2 := 0;
KeyPrevWeapon2 := 0;
KeyOpen2 := 0;
+ KeyStrafe2 := 0;
end;
with gGameControls.P2Control do
KeyNextWeapon := 19;
KeyPrevWeapon := 17;
KeyOpen := 58;
+ KeyStrafe := 0;
KeyRight2 := 0;
KeyLeft2 := 0;
KeyNextWeapon2 := 0;
KeyPrevWeapon2 := 0;
KeyOpen2 := 0;
+ KeyStrafe2 := 0;
end;
with gPlayer1Settings do
KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
+ KeyStrafe := ReadInt('Player1', 'KeyStrafe', 0);
KeyRight2 := ReadInt('Player1', 'KeyRight2', 0);
KeyLeft2 := ReadInt('Player1', 'KeyLeft2', 0);
KeyNextWeapon2 := ReadInt('Player1', 'KeyNextWeapon2', 0);
KeyPrevWeapon2 := ReadInt('Player1', 'KeyPrevWeapon2', 0);
KeyOpen2 := ReadInt('Player1', 'KeyOpen2', 0);
+ KeyStrafe2 := ReadInt('Player1', 'KeyStrafe2', 0);
end;
with gPlayer1Settings, config do
KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
+ KeyStrafe := ReadInt('Player2', 'KeyStrafe', 0);
KeyRight2 := ReadInt('Player2', 'KeyRight2', 0);
KeyLeft2 := ReadInt('Player2', 'KeyLeft2', 0);
KeyNextWeapon2 := ReadInt('Player2', 'KeyNextWeapon2', 0);
KeyPrevWeapon2 := ReadInt('Player2', 'KeyPrevWeapon2', 0);
KeyOpen2 := ReadInt('Player2', 'KeyOpen2', 0);
+ KeyStrafe2 := ReadInt('Player2', 'KeyStrafe2', 0);
end;
with gPlayer2Settings, config do
WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
WriteInt('Player1', 'KeyOpen', KeyOpen);
+ WriteInt('Player1', 'KeyStrafe', KeyStrafe);
WriteInt('Player1', 'KeyRight2', KeyRight2);
WriteInt('Player1', 'KeyLeft2', KeyLeft2);
WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2);
WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
WriteInt('Player1', 'KeyOpen2', KeyOpen2);
+ WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
WriteStr('Player1', 'Name', Name);
WriteStr('Player1', 'model', Model);
WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
WriteInt('Player2', 'KeyOpen', KeyOpen);
+ WriteInt('Player2', 'KeyStrafe', KeyStrafe);
WriteInt('Player2', 'KeyRight2', KeyRight2);
WriteInt('Player2', 'KeyLeft2', KeyLeft2);
WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2);
WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
WriteInt('Player2', 'KeyOpen2', KeyOpen2);
+ WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
WriteStr('Player2', 'Name', Name);
WriteStr('Player2', 'model', Model);