Browse Source

Controller: implement spellcasting

pull/420/head
Gleb Mazovetskiy 6 years ago committed by Anders Jenbo
parent
commit
93203fa445
  1. 8
      SourceX/controls/game_controls.cpp
  2. 1
      SourceX/controls/game_controls.h
  3. 10
      SourceX/miniwin/misc_msg.cpp

8
SourceX/controls/game_controls.cpp

@ -20,8 +20,6 @@ DWORD translate_controller_button_to_key(ControllerButton controller_button)
return questlog ? DVL_VK_SPACE : DVL_VK_ESCAPE;
case ControllerButton::BUTTON_B: // Right button
return sgpCurrentMenu || stextflag || questlog ? DVL_VK_RETURN : DVL_VK_SPACE;
case ControllerButton::BUTTON_X: // Left button
return 'X';
case ControllerButton::BUTTON_Y: // Top button
return DVL_VK_RETURN;
case ControllerButton::BUTTON_LEFTSTICK:
@ -69,6 +67,12 @@ bool GetGameAction(const SDL_Event &event, GameAction *action)
if (!ctrl_event.up)
*action = GameAction(GameActionType::SECONDARY_ACTION);
return true;
case ControllerButton::BUTTON_X: // Left button
if (InGameMenu())
break; // Map to keyboard key
if (!ctrl_event.up)
*action = GameAction(GameActionType::CAST_SPELL);
return true;
case ControllerButton::BUTTON_A: // Bottom button
if (InGameMenu())
break; // Map to keyboard key

1
SourceX/controls/game_controls.h

@ -10,6 +10,7 @@ enum class GameActionType {
USE_MANA_POTION,
PRIMARY_ACTION, // Talk to towners, click on inv items, attack, etc.
SECONDARY_ACTION, // Open chests, doors, pickup items.
CAST_SPELL,
TOGGLE_INVENTORY,
TOGGLE_CHARACTER_INFO,
TOGGLE_QUICK_SPELL_MENU,

10
SourceX/miniwin/misc_msg.cpp

@ -361,6 +361,16 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter
case GameActionType::SECONDARY_ACTION:
performSecondaryAction();
break;
case GameActionType::CAST_SPELL:
if (pcurs >= CURSOR_FIRSTITEM && invflag)
// Drop item so that it does not get destroyed.
DropItemBeforeTrig();
if (!invflag && !talkflag)
// Cast the spell.
RightMouseDown();
// Close active menu if any / stop walking.
PressEscKey();
break;
case GameActionType::TOGGLE_QUICK_SPELL_MENU:
ShowCursor();
lpMsg->message = DVL_WM_KEYDOWN;

Loading…
Cancel
Save