first
Some checks failed
Linux / Build Linux (push) Has been cancelled
Linux / Build Linux-1 (push) Has been cancelled
macOS / Build macOS (push) Has been cancelled
macOS / Build macOS-1 (push) Has been cancelled
Windows (MinGW) / Build MinGW (push) Has been cancelled
Windows (MinGW) / Build MinGW-1 (push) Has been cancelled
Windows (MSVC) / Build Windows (push) Has been cancelled
Windows (MSVC) / Build Windows-1 (push) Has been cancelled

This commit is contained in:
saarsena@gmail.com 2026-03-24 10:46:22 -04:00
commit 8269b17aa7
652 changed files with 273930 additions and 0 deletions

152
Quake/sh_input.c Normal file
View file

@ -0,0 +1,152 @@
/*
* sh_input.c -- Turn-based input handling for Space Hulk
*
* Copyright (C) 2026 fish fvch studios
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "quakedef.h"
#include "sh_game.h"
/* ============================================================
* CONSOLE COMMAND WRAPPERS
* ============================================================ */
static void SH_Cmd_Move (void)
{
if (SH_Active() && sh_game.phase == SH_PHASE_PLAYER)
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_MOVE_FORWARD);
}
static void SH_Cmd_TurnLeft (void)
{
if (SH_Active() && sh_game.phase == SH_PHASE_PLAYER)
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_TURN_LEFT);
}
static void SH_Cmd_TurnRight (void)
{
if (SH_Active() && sh_game.phase == SH_PHASE_PLAYER)
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_TURN_RIGHT);
}
static void SH_Cmd_Turn180 (void)
{
if (SH_Active() && sh_game.phase == SH_PHASE_PLAYER)
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_TURN_180);
}
static void SH_Cmd_Shoot (void)
{
if (SH_Active() && sh_game.phase == SH_PHASE_PLAYER)
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_SHOOT);
}
static void SH_Cmd_Overwatch (void)
{
if (SH_Active() && sh_game.phase == SH_PHASE_PLAYER)
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_OVERWATCH);
}
static void SH_Cmd_EndTurn (void)
{
if (SH_Active() && sh_game.phase == SH_PHASE_PLAYER)
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_END_TURN);
}
static void SH_Cmd_NextMarine (void)
{
if (SH_Active() && sh_game.phase == SH_PHASE_PLAYER)
SH_Marine_SelectNext();
}
static void SH_Cmd_PrevMarine (void)
{
if (SH_Active() && sh_game.phase == SH_PHASE_PLAYER)
SH_Marine_SelectPrev();
}
/* ============================================================
* INIT -- register console commands
* ============================================================ */
void SH_Input_Init (void)
{
Cmd_AddCommand("sh_move", SH_Cmd_Move);
Cmd_AddCommand("sh_turn_left", SH_Cmd_TurnLeft);
Cmd_AddCommand("sh_turn_right", SH_Cmd_TurnRight);
Cmd_AddCommand("sh_turn_180", SH_Cmd_Turn180);
Cmd_AddCommand("sh_shoot", SH_Cmd_Shoot);
Cmd_AddCommand("sh_overwatch", SH_Cmd_Overwatch);
Cmd_AddCommand("sh_end_turn", SH_Cmd_EndTurn);
Cmd_AddCommand("sh_next_marine", SH_Cmd_NextMarine);
Cmd_AddCommand("sh_prev_marine", SH_Cmd_PrevMarine);
}
/* ============================================================
* KEY EVENT -- intercept keys during game
*
* Called from Key_EventWithKeycode() before normal key handling.
* Returns true if we consumed the key.
* ============================================================ */
qboolean SH_Input_KeyEvent (int key, qboolean down)
{
if (!down)
return false; /* only handle key-down */
if (sh_game.phase != SH_PHASE_PLAYER)
return false; /* only intercept during player phase */
/* swallow input while animations play */
if (SH_AnimBusy())
return true;
switch (key) {
case 'w':
case K_UPARROW:
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_MOVE_FORWARD);
return true;
case 'a':
case K_LEFTARROW:
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_TURN_LEFT);
return true;
case 'd':
case K_RIGHTARROW:
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_TURN_RIGHT);
return true;
case 's':
case K_DOWNARROW:
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_TURN_180);
return true;
case 'f':
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_SHOOT);
return true;
case 'o':
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_OVERWATCH);
return true;
case 'e':
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_DOOR);
return true;
case K_TAB:
SH_Marine_SelectNext();
return true;
case K_SPACE:
SH_Marine_TryAction(sh_game.selected_marine, SH_ACTION_END_TURN);
return true;
}
return false;
}