photo-mode: move to libtrx

Resolves #2277.
This commit is contained in:
Marcin Kurczewski 2025-01-10 23:29:09 +01:00
parent 0ec2b4a586
commit 190fef0a37
49 changed files with 313 additions and 130 deletions

View file

@ -666,6 +666,7 @@
"KEYMAP_CAMERA_DOWN": "Camera Down",
"KEYMAP_CAMERA_FORWARD": "Camera Forward",
"KEYMAP_CAMERA_LEFT": "Camera Left",
"KEYMAP_CAMERA_RESET": "Camera Reset",
"KEYMAP_CAMERA_RIGHT": "Camera Right",
"KEYMAP_CAMERA_UP": "Camera Up",
"KEYMAP_CHANGE_TARGET": "Change Target",

View file

@ -154,6 +154,7 @@
"KEYMAP_CAMERA_DOWN": "Camera Down",
"KEYMAP_CAMERA_FORWARD": "Camera Forward",
"KEYMAP_CAMERA_LEFT": "Camera Left",
"KEYMAP_CAMERA_RESET": "Camera Reset",
"KEYMAP_CAMERA_RIGHT": "Camera Right",
"KEYMAP_CAMERA_UP": "Camera Up",
"KEYMAP_CHANGE_TARGET": "Change Target",

View file

@ -233,6 +233,7 @@
"KEYMAP_CAMERA_DOWN": "Camera Down",
"KEYMAP_CAMERA_FORWARD": "Camera Forward",
"KEYMAP_CAMERA_LEFT": "Camera Left",
"KEYMAP_CAMERA_RESET": "Camera Reset",
"KEYMAP_CAMERA_RIGHT": "Camera Right",
"KEYMAP_CAMERA_UP": "Camera Up",
"KEYMAP_CHANGE_TARGET": "Change Target",

View file

@ -420,6 +420,13 @@
"HEADING_OPTION": "OPTION",
"KEYMAP_ACTION": "Action",
"KEYMAP_BACK": "Back",
"KEYMAP_CAMERA_BACK": "Camera Back",
"KEYMAP_CAMERA_DOWN": "Camera Down",
"KEYMAP_CAMERA_FORWARD": "Camera Forward",
"KEYMAP_CAMERA_LEFT": "Camera Left",
"KEYMAP_CAMERA_RESET": "Camera Reset",
"KEYMAP_CAMERA_RIGHT": "Camera Right",
"KEYMAP_CAMERA_UP": "Camera Up",
"KEYMAP_DRAW_WEAPON": "Draw Weapon",
"KEYMAP_ENTER_CONSOLE": "Dev Console",
"KEYMAP_FLY_CHEAT": "Fly Cheat",
@ -435,11 +442,15 @@
"KEYMAP_RUN": "Run",
"KEYMAP_STEP_LEFT": "Step Left",
"KEYMAP_STEP_RIGHT": "Step Right",
"KEYMAP_TOGGLE_PHOTO_MODE": "Toggle Photo Mode",
"KEYMAP_TOGGLE_UI": "Toggle UI",
"KEYMAP_TURBO_CHEAT": "Turbo Speed",
"KEYMAP_USE_FLARE": "Flare",
"KEYMAP_WALK": "Walk",
"MISC_EXIT": "Exit",
"MISC_OFF": "Off",
"MISC_ON": "On",
"MISC_TOGGLE_HELP": "Toggle help",
"OSD_AMBIGUOUS_INPUT_2": "Ambiguous input: %s and %s",
"OSD_AMBIGUOUS_INPUT_3": "Ambiguous input: %s, %s, ...",
"OSD_COMMAND_BAD_INVOCATION": "Invalid invocation: %s",
@ -480,6 +491,7 @@
"OSD_LOAD_GAME_FAIL_INVALID_SLOT": "Invalid save slot %d",
"OSD_LOAD_GAME_FAIL_UNAVAILABLE_SLOT": "Save slot %d is not available",
"OSD_OBJECT_NOT_FOUND": "Object not found",
"OSD_PHOTO_MODE_LAUNCHED": "Entering photo mode, press %s for help",
"OSD_PLAY_LEVEL": "Loading %s",
"OSD_POS_GET": "Level: %d (%s) Room: %d\nPosition: %.3f, %.3f, %.3f\nRotation: %.3f,%.3f,%.3f",
"OSD_POS_SET_ITEM": "Teleported to object: %s",
@ -505,5 +517,15 @@
"PAUSE_PAUSED": "Paused",
"PAUSE_QUIT": "Quit",
"PAUSE_YES": "Yes",
"PHOTO_MODE_FOV_PROMPT": "Adjust FOV",
"PHOTO_MODE_FOV_ROLE": "Draw <+Walk>",
"PHOTO_MODE_MOVE_PROMPT": "Move camera",
"PHOTO_MODE_RESET_PROMPT": "Reset camera",
"PHOTO_MODE_ROLL_PROMPT": "Roll camera",
"PHOTO_MODE_ROLL_ROLE": "Sidestep L/R",
"PHOTO_MODE_ROTATE90_PROMPT": "Rotate 90 degrees",
"PHOTO_MODE_ROTATE_PROMPT": "Rotate camera",
"PHOTO_MODE_SNAP_PROMPT": "Take picture",
"PHOTO_MODE_TITLE": "Photo Mode",
},
}

View file

@ -1,6 +1,7 @@
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-0.8...develop) - ××××-××-××
- added Linux builds and toolchain (#1598)
- added pause dialog (#1638)
- added a photo mode feature (#2277)
- fixed showing inventory ring up/down arrows when uncalled for (#2225)
- fixed Lara never stepping backwards off a step using her right foot (#1602)
- fixed blood spawning on Lara from gunshots using incorrect positioning data (#2253)

View file

@ -30,6 +30,7 @@ game with new enhancements and features.
- free flare from underwater pickup
- drifting into walls during underwater pickups
- added a pause screen
- added a photo mode feature
- changed inventory to pause the music rather than muting it
- fixed killing the T-Rex with a grenade launcher crashing the game
- fixed secret rewards not displaying shotgun ammo

View file

@ -20,6 +20,7 @@ CFG_INT32(g_Config, visuals.fov, 80)
CFG_BOOL(g_Config, visuals.use_pcx_fov, true)
CFG_DOUBLE(g_Config, ui.text_scale, 1.0)
CFG_DOUBLE(g_Config, ui.bar_scale, 1.0)
CFG_BOOL(g_Config, ui.enable_photo_mode_ui, true)
CFG_ENUM(g_Config, rendering.screenshot_format, SCREENSHOT_FORMAT_JPEG, SCREENSHOT_FORMAT)
CFG_ENUM(g_Config, rendering.render_mode, RM_HARDWARE, RENDER_MODE)
CFG_ENUM(g_Config, rendering.aspect_mode, AM_ANY, ASPECT_MODE)

View file

@ -1,20 +1,25 @@
#include "game/camera/photo_mode.h"
#include "game/camera/common.h"
#include "game/camera/const.h"
#include "game/camera/enum.h"
#include "game/camera/vars.h"
#include "game/input.h"
#include "game/math.h"
#include "game/output.h"
#include "game/room.h"
#include "game/rooms.h"
#include "game/viewport.h"
#include "utils.h"
#include <libtrx/game/camera/common.h>
#include <libtrx/game/camera/vars.h>
#include <libtrx/game/math.h>
#include <libtrx/utils.h>
#if TR_VERSION == 1
// TODO: remove this call when consolidating the viewport API
extern void Output_ApplyFOV(void);
#endif
#define MIN_PHOTO_FOV 10
#define MAX_PHOTO_FOV 150
#define PHOTO_ROT_SHIFT (PHD_DEGREE * 4)
#define PHOTO_MAX_PITCH_ROLL (PHD_90 - PHD_DEGREE)
#define PHOTO_ROT_SHIFT (DEG_1 * 4)
#define PHOTO_MAX_PITCH_ROLL (DEG_90 - DEG_1)
#define PHOTO_MAX_SPEED 100
#define SHIFT_X(distance, elevation, angle) \
@ -55,8 +60,12 @@ static void M_UpdatePhotoMode(void);
static void M_ResetCamera(void)
{
g_Camera = m_OldCamera;
#if TR_VERSION == 1
Viewport_SetFOV(m_OldFOV);
m_CurrentFOV = m_OldFOV / PHD_DEGREE;
#elif TR_VERSION == 2
Viewport_AlterFOV(m_OldFOV);
#endif
m_CurrentFOV = m_OldFOV / DEG_1;
}
static int32_t M_GetShiftSpeed(const int32_t val)
@ -66,7 +75,7 @@ static int32_t M_GetShiftSpeed(const int32_t val)
static int32_t M_GetRotSpeed(void)
{
return MAX(PHD_DEGREE, M_GetShiftSpeed(PHOTO_ROT_SHIFT));
return MAX(DEG_1, M_GetShiftSpeed(PHOTO_ROT_SHIFT));
}
static void M_ShiftCamera(
@ -102,7 +111,7 @@ static void M_RotateCamera(const int16_t angle, int16_t elevation)
static void M_RotateTarget(const int16_t angle)
{
const PHD_ANGLE elevation = g_Camera.target_elevation;
const int16_t elevation = g_Camera.target_elevation;
const int32_t distance = g_Camera.target_distance;
const XYZ_32 shift = {
.x = SHIFT_X(distance, elevation, angle),
@ -154,10 +163,10 @@ static bool M_HandleShiftInputs(void)
bool result = false;
if (g_Input.camera_left) {
M_ShiftCamera(g_Camera.target_angle - PHD_90, 0, 0);
M_ShiftCamera(g_Camera.target_angle - DEG_90, 0, 0);
result = true;
} else if (g_Input.camera_right) {
M_ShiftCamera(g_Camera.target_angle + PHD_90, 0, 0);
M_ShiftCamera(g_Camera.target_angle + DEG_90, 0, 0);
result = true;
}
@ -166,17 +175,17 @@ static bool M_HandleShiftInputs(void)
result = true;
} else if (g_Input.camera_back) {
M_ShiftCamera(
g_Camera.target_angle + PHD_180, g_Camera.target_elevation, 1);
g_Camera.target_angle + DEG_180, g_Camera.target_elevation, 1);
result = true;
}
if (g_Input.camera_up) {
M_ShiftCamera(
g_Camera.target_angle, g_Camera.target_elevation + PHD_90, -1);
g_Camera.target_angle, g_Camera.target_elevation + DEG_90, -1);
result = true;
} else if (g_Input.camera_down) {
M_ShiftCamera(
g_Camera.target_angle, g_Camera.target_elevation - PHD_90, -1);
g_Camera.target_angle, g_Camera.target_elevation - DEG_90, -1);
result = true;
}
@ -224,7 +233,7 @@ static bool M_HandleTargetRotationInputs(void)
{
bool result = false;
if (g_InputDB.roll) {
M_RotateTarget(g_Camera.target_angle - PHD_90);
M_RotateTarget(g_Camera.target_angle - DEG_90);
result = true;
}
return result;
@ -242,15 +251,23 @@ static bool M_HandleFOVInputs(void)
m_CurrentFOV++;
}
CLAMP(m_CurrentFOV, MIN_PHOTO_FOV, MAX_PHOTO_FOV);
Viewport_SetFOV(m_CurrentFOV * PHD_DEGREE);
#if TR_VERSION == 1
Viewport_SetFOV(m_CurrentFOV * DEG_1);
Output_ApplyFOV();
#elif TR_VERSION == 2
Viewport_AlterFOV(m_CurrentFOV * DEG_1);
#endif
return true;
}
void Camera_EnterPhotoMode(void)
{
#if TR_VERSION == 1
m_OldFOV = Viewport_GetFOV();
m_CurrentFOV = m_OldFOV / PHD_DEGREE;
#elif TR_VERSION == 2
m_OldFOV = Viewport_GetFOV(true);
#endif
m_CurrentFOV = m_OldFOV / DEG_1;
m_OldCamera = g_Camera;
g_Camera.type = CAM_PHOTO_MODE;
m_WorldBounds = Room_GetWorldBounds();
@ -259,7 +276,11 @@ void Camera_EnterPhotoMode(void)
void Camera_ExitPhotoMode(void)
{
#if TR_VERSION == 1
Viewport_SetFOV(m_OldFOV);
#elif TR_VERSION == 2
Viewport_AlterFOV(m_OldFOV);
#endif
M_ResetCamera();
}
@ -273,7 +294,7 @@ void Camera_UpdatePhotoMode(void)
const bool rot_target_input = g_InputDB.roll;
const bool roll_input = g_Input.step_left || g_Input.step_right;
PHD_ANGLE angles[2];
int16_t angles[2];
Math_GetVectorAngles(
g_Camera.target.x - g_Camera.pos.x, g_Camera.target.y - g_Camera.pos.y,
g_Camera.target.z - g_Camera.pos.z, angles);

View file

@ -1,7 +1,11 @@
#include "game/phase/phase_photo_mode.h"
#include "config.h"
#include "game/camera.h"
#include "game/console/common.h"
#include "game/fader.h"
#include "game/game.h"
#include "game/game_string.h"
#include "game/input.h"
#include "game/interpolation.h"
#include "game/music.h"
@ -9,25 +13,24 @@
#include "game/overlay.h"
#include "game/shell.h"
#include "game/sound.h"
#include "game/text.h"
#include "game/ui/common.h"
#include "game/ui/widgets/photo_mode.h"
#include <libtrx/config.h>
#include <libtrx/game/console/common.h>
#include <libtrx/game/game_string.h>
#include <libtrx/game/ui/common.h>
#include <libtrx/memory.h>
#include "memory.h"
#include <stdio.h>
typedef enum {
PS_NONE,
PS_ACTIVE,
PS_COOLDOWN,
} PHOTO_STATUS;
STATE_NAVIGATE,
STATE_FADE_OUT,
STATE_FINISH,
} STATE;
typedef struct {
PHOTO_STATUS status;
STATE state;
UI_WIDGET *ui;
FADER top_fader;
bool taking_screenshot;
bool show_fps_counter;
} M_PRIV;
@ -39,9 +42,11 @@ static void M_Draw(PHASE *phase);
static PHASE_CONTROL M_Start(PHASE *const phase)
{
M_PRIV *const p = phase->priv;
p->status = PS_NONE;
p->state = STATE_NAVIGATE;
#if TR_VERSION == 1
p->show_fps_counter = g_Config.rendering.enable_fps_counter;
g_Config.rendering.enable_fps_counter = false;
#endif
g_OldInputDB = g_Input;
Camera_EnterPhotoMode();
@ -68,7 +73,9 @@ static void M_End(PHASE *const phase)
p->ui->free(p->ui);
p->ui = NULL;
#if TR_VERSION == 1
g_Config.rendering.enable_fps_counter = p->show_fps_counter;
#endif
g_Input = g_OldInputDB;
Music_Unpause();
Sound_UnpauseAll();
@ -77,31 +84,49 @@ static void M_End(PHASE *const phase)
static PHASE_CONTROL M_Control(PHASE *const phase, int32_t num_frames)
{
M_PRIV *const p = phase->priv;
if (p->status == PS_ACTIVE) {
Screenshot_Make(g_Config.rendering.screenshot_format);
Sound_Effect(SFX_MENU_CHOOSE, NULL, SPM_ALWAYS);
p->status = PS_COOLDOWN;
} else if (p->status == PS_COOLDOWN) {
p->status = PS_NONE;
}
switch (p->state) {
case STATE_NAVIGATE:
Input_Update();
Shell_ProcessInput();
Input_Update();
Shell_ProcessInput();
if (g_InputDB.toggle_ui) {
UI_ToggleState(&g_Config.ui.enable_photo_mode_ui);
}
if (g_InputDB.toggle_ui) {
UI_ToggleState(&g_Config.ui.enable_photo_mode_ui);
}
if (g_InputDB.toggle_photo_mode || g_InputDB.menu_back) {
p->state = STATE_FINISH;
return (PHASE_CONTROL) { .action = PHASE_ACTION_NO_WAIT };
} else if (Game_IsExiting()) {
Fader_Init(&p->top_fader, FADER_TRANSPARENT, FADER_BLACK, 0.5);
p->state = STATE_FADE_OUT;
return (PHASE_CONTROL) { .action = PHASE_ACTION_NO_WAIT };
} else if (g_InputDB.action) {
Output_BeginScene();
p->taking_screenshot = true;
M_Draw(phase);
p->taking_screenshot = false;
Screenshot_Make(g_Config.rendering.screenshot_format);
Output_EndScene();
Sound_Effect(SFX_MENU_LARA_HOME, NULL, SPM_ALWAYS);
} else {
p->ui->control(p->ui);
Camera_Update();
}
break;
if (g_InputDB.toggle_photo_mode || g_InputDB.option) {
case STATE_FADE_OUT:
if (g_InputDB.menu_confirm || g_InputDB.menu_back
|| !Fader_IsActive(&p->top_fader)) {
p->state = STATE_FINISH;
return (PHASE_CONTROL) { .action = PHASE_ACTION_NO_WAIT };
}
break;
case STATE_FINISH:
return (PHASE_CONTROL) {
.action = PHASE_ACTION_END,
.gf_cmd = { .action = GF_NOOP },
.gf_cmd = { .action = Game_IsExiting() ? GF_EXIT_GAME : GF_NOOP },
};
} else if (g_InputDB.action) {
p->status = PS_ACTIVE;
} else {
p->ui->control(p->ui);
Camera_Update();
}
return (PHASE_CONTROL) { .action = PHASE_ACTION_CONTINUE };
@ -109,15 +134,19 @@ static PHASE_CONTROL M_Control(PHASE *const phase, int32_t num_frames)
static void M_Draw(PHASE *const phase)
{
const M_PRIV *const p = phase->priv;
M_PRIV *const p = phase->priv;
Interpolation_Disable();
Game_Draw(false);
Interpolation_Enable();
Output_DrawPolyList();
if (p->status == PS_NONE) {
if (!p->taking_screenshot) {
p->ui->draw(p->ui);
}
Fader_Draw(&p->top_fader);
Console_Draw();
Text_Draw();
Output_DrawPolyList();
}

View file

@ -1,16 +1,15 @@
#include "game/ui/widgets/photo_mode.h"
#include "config.h"
#include "game/game_string.h"
#include "game/input.h"
#include "game/text.h"
#include <libtrx/config.h>
#include <libtrx/game/game_string.h>
#include <libtrx/game/ui/common.h>
#include <libtrx/game/ui/widgets/label.h>
#include <libtrx/game/ui/widgets/spacer.h>
#include <libtrx/game/ui/widgets/stack.h>
#include <libtrx/game/ui/widgets/window.h>
#include <libtrx/memory.h>
#include "game/ui/common.h"
#include "game/ui/widgets/label.h"
#include "game/ui/widgets/spacer.h"
#include "game/ui/widgets/stack.h"
#include "game/ui/widgets/window.h"
#include "memory.h"
#include <stdio.h>

View file

@ -51,6 +51,7 @@ typedef struct {
} visuals;
struct {
bool enable_photo_mode_ui;
double text_scale;
double bar_scale;
} ui;

View file

@ -1,6 +1,8 @@
#pragma once
#include "./camera/common.h"
#include "./camera/const.h"
#include "./camera/enum.h"
#include "./camera/photo_mode.h"
#include "./camera/types.h"
#include "./camera/vars.h"

View file

@ -0,0 +1,5 @@
#pragma once
#include "../const.h"
#define CAMERA_DEFAULT_DISTANCE (WALL_L * 3 / 2)

View file

@ -7,7 +7,5 @@ typedef enum {
CAM_COMBAT = 3,
CAM_CINEMATIC = 4,
CAM_HEAVY = 5,
#if TR_VERSION == 1
CAM_PHOTO_MODE = 6,
#endif
} CAMERA_TYPE;

View file

@ -2,5 +2,4 @@
void Camera_EnterPhotoMode(void);
void Camera_ExitPhotoMode(void);
void Camera_UpdatePhotoMode(void);

View file

@ -78,6 +78,15 @@ GS_DEFINE(KEYMAP_LEVEL_SKIP_CHEAT, "Level Skip")
GS_DEFINE(KEYMAP_ENTER_CONSOLE, "Dev Console")
GS_DEFINE(KEYMAP_TURBO_CHEAT, "Turbo Speed")
GS_DEFINE(KEYMAP_PAUSE, "Pause")
GS_DEFINE(KEYMAP_TOGGLE_UI, "Toggle UI")
GS_DEFINE(KEYMAP_TOGGLE_PHOTO_MODE, "Toggle Photo Mode")
GS_DEFINE(KEYMAP_CAMERA_RESET, "Camera Reset")
GS_DEFINE(KEYMAP_CAMERA_FORWARD, "Camera Forward")
GS_DEFINE(KEYMAP_CAMERA_BACK, "Camera Back")
GS_DEFINE(KEYMAP_CAMERA_LEFT, "Camera Left")
GS_DEFINE(KEYMAP_CAMERA_RIGHT, "Camera Right")
GS_DEFINE(KEYMAP_CAMERA_UP, "Camera Up")
GS_DEFINE(KEYMAP_CAMERA_DOWN, "Camera Down")
GS_DEFINE(PAUSE_PAUSED, "Paused")
GS_DEFINE(PAUSE_EXIT_TO_TITLE, "Exit to title?")
GS_DEFINE(PAUSE_CONTINUE, "Continue")
@ -85,3 +94,16 @@ GS_DEFINE(PAUSE_QUIT, "Quit")
GS_DEFINE(PAUSE_ARE_YOU_SURE, "Are you sure?")
GS_DEFINE(PAUSE_YES, "Yes")
GS_DEFINE(PAUSE_NO, "No")
GS_DEFINE(PHOTO_MODE_TITLE, "Photo Mode")
GS_DEFINE(PHOTO_MODE_MOVE_PROMPT, "Move camera")
GS_DEFINE(PHOTO_MODE_ROTATE_PROMPT, "Rotate camera")
GS_DEFINE(PHOTO_MODE_ROLL_PROMPT, "Roll camera")
GS_DEFINE(PHOTO_MODE_ROTATE90_PROMPT, "Rotate 90 degrees")
GS_DEFINE(PHOTO_MODE_FOV_PROMPT, "Adjust FOV")
GS_DEFINE(PHOTO_MODE_RESET_PROMPT, "Reset camera")
GS_DEFINE(PHOTO_MODE_SNAP_PROMPT, "Take picture")
GS_DEFINE(PHOTO_MODE_ROLL_ROLE, "Sidestep L/R")
GS_DEFINE(PHOTO_MODE_FOV_ROLE, "Draw <+Walk>")
GS_DEFINE(OSD_PHOTO_MODE_LAUNCHED, "Entering photo mode, press %s for help")
GS_DEFINE(MISC_TOGGLE_HELP, "Toggle help")
GS_DEFINE(MISC_EXIT, "Exit")

View file

@ -12,11 +12,11 @@ INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_LOOK, SDL_CONTROLLER_BUTTON_
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_ROLL, SDL_CONTROLLER_BUTTON_B)
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_OPTION, SDL_CONTROLLER_BUTTON_BACK)
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_PAUSE, SDL_CONTROLLER_BUTTON_START)
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_CHANGE_TARGET, SDL_CONTROLLER_BUTTON_LEFTSTICK)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_FORWARD, SDL_CONTROLLER_AXIS_RIGHTY, -1)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_BACK, SDL_CONTROLLER_AXIS_RIGHTY, 1)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_LEFT, SDL_CONTROLLER_AXIS_RIGHTX, -1)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_RIGHT, SDL_CONTROLLER_AXIS_RIGHTX, 1)
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_CHANGE_TARGET, SDL_CONTROLLER_BUTTON_LEFTSTICK)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_UP, SDL_CONTROLLER_AXIS_LEFTY, -1)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_DOWN, SDL_CONTROLLER_AXIS_LEFTY, 1)
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_MENU_UP, SDL_CONTROLLER_BUTTON_DPAD_UP)

View file

@ -13,3 +13,10 @@ INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_ROLL, SDL_CONTROLLER_BUTTON_B)
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_OPTION, SDL_CONTROLLER_BUTTON_BACK)
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_MENU_CONFIRM, SDL_CONTROLLER_BUTTON_A)
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_MENU_BACK, SDL_CONTROLLER_BUTTON_B)
INPUT_CONTROLLER_ASSIGN_BUTTON(INPUT_ROLE_PAUSE, SDL_CONTROLLER_BUTTON_START)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_FORWARD, SDL_CONTROLLER_AXIS_RIGHTY, -1)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_BACK, SDL_CONTROLLER_AXIS_RIGHTY, 1)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_LEFT, SDL_CONTROLLER_AXIS_RIGHTX, -1)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_RIGHT, SDL_CONTROLLER_AXIS_RIGHTX, 1)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_UP, SDL_CONTROLLER_AXIS_LEFTY, -1)
INPUT_CONTROLLER_ASSIGN_AXIS(INPUT_ROLE_CAMERA_DOWN, SDL_CONTROLLER_AXIS_LEFTY, 1)

View file

@ -20,6 +20,13 @@ INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_ITEM_CHEAT, SDL_SCANCODE_I)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_LEVEL_SKIP_CHEAT, SDL_SCANCODE_L)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_TURBO_CHEAT, SDL_SCANCODE_TAB)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_CAMERA_UP, SDL_SCANCODE_Q)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_CAMERA_DOWN, SDL_SCANCODE_E)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_CAMERA_FORWARD, SDL_SCANCODE_W)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_CAMERA_BACK, SDL_SCANCODE_S)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_CAMERA_LEFT, SDL_SCANCODE_A)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_CAMERA_RIGHT, SDL_SCANCODE_D)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_EQUIP_PISTOLS, SDL_SCANCODE_1)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_EQUIP_SHOTGUN, SDL_SCANCODE_2)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_EQUIP_MAGNUMS, SDL_SCANCODE_3)
@ -40,6 +47,8 @@ INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_TOGGLE_Z_BUFFER, SDL_SCANCODE_F7)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_CYCLE_LIGHTING_CONTRAST, SDL_SCANCODE_F8)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_TOGGLE_FULLSCREEN, SDL_SCANCODE_UNKNOWN)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_TOGGLE_RENDERING_MODE, SDL_SCANCODE_F12)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_TOGGLE_UI, SDL_SCANCODE_H)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_TOGGLE_PHOTO_MODE, SDL_SCANCODE_F11)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_OPTION, SDL_SCANCODE_ESCAPE)
INPUT_KEYBOARD_ASSIGN(INPUT_ROLE_MENU_BACK, SDL_SCANCODE_ESCAPE)

View file

@ -43,10 +43,19 @@ INPUT_ROLE_DEFINE(USE_SMALL_MEDI, use_small_medi)
INPUT_ROLE_DEFINE(USE_BIG_MEDI, use_big_medi)
INPUT_ROLE_DEFINE(PAUSE, pause)
INPUT_ROLE_DEFINE(CAMERA_FORWARD, camera_forward)
INPUT_ROLE_DEFINE(CAMERA_BACK, camera_back)
INPUT_ROLE_DEFINE(CAMERA_LEFT, camera_left)
INPUT_ROLE_DEFINE(CAMERA_RIGHT, camera_right)
INPUT_ROLE_DEFINE(CAMERA_UP, camera_up)
INPUT_ROLE_DEFINE(CAMERA_DOWN, camera_down)
INPUT_ROLE_DEFINE(CAMERA_RESET, camera_reset)
INPUT_ROLE_DEFINE(SWITCH_RESOLUTION, switch_resolution)
INPUT_ROLE_DEFINE(SWITCH_INTERNAL_SCREEN_SIZE, switch_internal_screen_size)
INPUT_ROLE_DEFINE(TOGGLE_BILINEAR_FILTER, toggle_bilinear_filter)
INPUT_ROLE_DEFINE(TOGGLE_PERSPECTIVE_FILTER, toggle_perspective_filter)
INPUT_ROLE_DEFINE(TOGGLE_PHOTO_MODE, toggle_photo_mode)
INPUT_ROLE_DEFINE(TOGGLE_UI, toggle_ui)
INPUT_ROLE_DEFINE(TOGGLE_Z_BUFFER, toggle_z_buffer)
INPUT_ROLE_DEFINE(CYCLE_LIGHTING_CONTRAST, cycle_lighting_contrast)
INPUT_ROLE_DEFINE(TOGGLE_RENDERING_MODE, toggle_rendering_mode)

View file

@ -1,3 +1,4 @@
#pragma once
extern void Overlay_MakeAmmoString(char *string);
extern void Overlay_HideGameInfo(void);

View file

@ -3,6 +3,7 @@
#include "./phase/control.h"
#include "./phase/executor.h"
#include "./phase/phase_pause.h"
#include "./phase/phase_photo_mode.h"
#include "./phase/phase_picture.h"
#include "./phase/phase_stats.h"
#include "./phase/types.h"

View file

@ -1,6 +1,6 @@
#pragma once
#include <libtrx/game/phase/types.h>
#include "./types.h"
PHASE *Phase_PhotoMode_Create(void);
void Phase_PhotoMode_Destroy(PHASE *phase);

View file

@ -106,7 +106,7 @@ typedef enum {
SFX_DAMOCLES_SWORD = 103,
SFX_ATLANTEAN_EXPLODE = 104,
SFX_MENU_ROTATE = 108,
SFX_MENU_CHOOSE = 109,
SFX_MENU_LARA_HOME = 109,
SFX_MENU_GAMEBOY = 110,
SFX_MENU_SPININ = 111,
SFX_MENU_SPINOUT = 112,
@ -287,7 +287,7 @@ typedef enum {
SFX_ENEMY_CLIMBUP = 75,
SFX_ENEMY_CLIMBDOWN = 76,
SFX_WEAPON_CLATTER = 77,
SFX_M16_FIRE = 78,
SFX_M16_FIRE = 78,
SFX_WATERFALL_LOOP = 79,
SFX_SWORD_STATUE_DROP = 80,
SFX_SWORD_STATUE_LIFT = 81,
@ -313,7 +313,7 @@ typedef enum {
SFX_TIGER_STRIKE = 101,
SFX_TIGER_DEATH = 102,
SFX_TIGER_GROWL = 103,
SFX_M16_STOP = 104,
SFX_M16_STOP = 104,
SFX_EXPLOSION_1 = 105,
SFX_GROWL = 106,
SFX_SPIDER_JUMP = 107,

View file

@ -1,5 +1,5 @@
#pragma once
#include <libtrx/game/ui/widgets/base.h>
#include "./base.h"
UI_WIDGET *UI_PhotoMode_Create(void);

View file

@ -0,0 +1,12 @@
#pragma once
#include <stdint.h>
// TODO: consolidate this API
#if TR_VERSION == 1
extern int16_t Viewport_GetFOV(void);
extern void Viewport_SetFOV(int16_t view_angle);
#elif TR_VERSION == 2
extern int16_t Viewport_GetFOV(bool resolve_user_fov);
extern void Viewport_AlterFOV(int16_t view_angle);
#endif

View file

@ -80,6 +80,7 @@ sources = [
'filesystem.c',
'game/anims/common.c',
'game/anims/frames.c',
'game/camera/photo_mode.c',
'game/camera/vars.c',
'game/clock/common.c',
'game/clock/timer.c',
@ -126,6 +127,7 @@ sources = [
'game/objects/vars.c',
'game/phase/executor.c',
'game/phase/phase_pause.c',
'game/phase/phase_photo_mode.c',
'game/phase/phase_picture.c',
'game/phase/phase_stats.c',
'game/random.c',
@ -138,6 +140,7 @@ sources = [
'game/ui/widgets/console.c',
'game/ui/widgets/frame.c',
'game/ui/widgets/label.c',
'game/ui/widgets/photo_mode.c',
'game/ui/widgets/prompt.c',
'game/ui/widgets/requester.c',
'game/ui/widgets/spacer.c',

View file

@ -1,6 +1,5 @@
#pragma once
#include "game/camera/common.h"
#include "game/camera/photo_mode.h"
#include <libtrx/game/camera.h>

View file

@ -1,6 +1,5 @@
#include "game/camera/common.h"
#include "game/camera/photo_mode.h"
#include "game/input.h"
#include "game/items.h"
#include "game/los.h"
@ -14,6 +13,8 @@
#include <libtrx/config.h>
#include <libtrx/debug.h>
#include <libtrx/game/camera/common.h>
#include <libtrx/game/camera/const.h>
#include <libtrx/game/camera/photo_mode.h>
#include <libtrx/game/camera/vars.h>
#include <libtrx/game/math.h>
#include <libtrx/game/matrix.h>

View file

@ -4,8 +4,6 @@
#include <stdint.h>
#define CAMERA_DEFAULT_DISTANCE (WALL_L * 3 / 2)
void Camera_Initialise(void);
void Camera_Reset(void);
void Camera_ResetPosition(void);

View file

@ -40,14 +40,6 @@ GS_DEFINE(SOUND_SET_VOLUMES, "Set Volumes")
GS_DEFINE(CONTROL_RESET_DEFAULTS, "Reset All: Hold %s")
GS_DEFINE(CONTROL_UNBIND, "Unbind: Hold %s")
GS_DEFINE(KEYMAP_CHANGE_TARGET, "Change Target")
GS_DEFINE(KEYMAP_TOGGLE_UI, "Toggle UI")
GS_DEFINE(KEYMAP_TOGGLE_PHOTO_MODE, "Toggle Photo Mode")
GS_DEFINE(KEYMAP_CAMERA_FORWARD, "Camera Forward")
GS_DEFINE(KEYMAP_CAMERA_BACK, "Camera Back")
GS_DEFINE(KEYMAP_CAMERA_LEFT, "Camera Left")
GS_DEFINE(KEYMAP_CAMERA_RIGHT, "Camera Right")
GS_DEFINE(KEYMAP_CAMERA_UP, "Camera Up")
GS_DEFINE(KEYMAP_CAMERA_DOWN, "Camera Down")
GS_DEFINE(KEYMAP_EQUIP_PISTOLS, "Equip Pistols")
GS_DEFINE(KEYMAP_EQUIP_SHOTGUN, "Equip Shotgun")
GS_DEFINE(KEYMAP_EQUIP_MAGNUMS, "Equip Magnums")
@ -111,24 +103,11 @@ GS_DEFINE(OSD_TEXTURE_FILTER_NN, "nearest-neighbor")
GS_DEFINE(OSD_TEXTURE_FILTER_BILINEAR, "bilinear")
GS_DEFINE(OSD_PERSPECTIVE_FILTER_ON, "Perspective filter enabled")
GS_DEFINE(OSD_PERSPECTIVE_FILTER_OFF, "Perspective filter disabled")
GS_DEFINE(OSD_PHOTO_MODE_LAUNCHED, "Entering photo mode, press %s for help")
GS_DEFINE(OSD_FPS_COUNTER_ON, "FPS counter enabled")
GS_DEFINE(OSD_FPS_COUNTER_OFF, "FPS counter disabled")
GS_DEFINE(OSD_DOOR_OPEN, "Open Sesame!")
GS_DEFINE(OSD_DOOR_CLOSE, "Close Sesame!")
GS_DEFINE(OSD_DOOR_OPEN_FAIL, "No doors in Lara's proximity")
GS_DEFINE(MISC_TOGGLE_HELP, "Toggle help")
GS_DEFINE(MISC_EXIT, "Exit")
GS_DEFINE(PHOTO_MODE_TITLE, "Photo Mode")
GS_DEFINE(PHOTO_MODE_MOVE_PROMPT, "Move camera")
GS_DEFINE(PHOTO_MODE_ROTATE_PROMPT, "Rotate camera")
GS_DEFINE(PHOTO_MODE_ROLL_PROMPT, "Roll camera")
GS_DEFINE(PHOTO_MODE_ROTATE90_PROMPT, "Rotate 90 degrees")
GS_DEFINE(PHOTO_MODE_FOV_PROMPT, "Adjust FOV")
GS_DEFINE(PHOTO_MODE_RESET_PROMPT, "Reset camera")
GS_DEFINE(PHOTO_MODE_SNAP_PROMPT, "Take picture")
GS_DEFINE(PHOTO_MODE_ROLL_ROLE, "Sidestep L/R")
GS_DEFINE(PHOTO_MODE_FOV_ROLE, "Draw <+Walk>")
GS_DEFINE(ITEM_EXAMINE_ROLE, "\\{button empty} %s: Examine")
GS_DEFINE(ITEM_USE_ROLE, "\\{button empty} %s: Use")
GS_DEFINE(PAGINATION_NAV, "%d / %d")

View file

@ -80,6 +80,7 @@ static void M_UpdateFromBackend(
s->load |= backend->is_pressed(layout, INPUT_ROLE_LOAD);
s->pause |= backend->is_pressed(layout, INPUT_ROLE_PAUSE);
s->toggle_ui |= backend->is_pressed(layout, INPUT_ROLE_TOGGLE_UI);
s->toggle_photo_mode |= backend->is_pressed(layout, INPUT_ROLE_TOGGLE_PHOTO_MODE);
s->camera_up |= backend->is_pressed(layout, INPUT_ROLE_CAMERA_UP);
@ -114,7 +115,6 @@ static void M_UpdateFromBackend(
s->toggle_fps_counter |= backend->is_pressed(layout, INPUT_ROLE_FPS);
s->toggle_bilinear_filter |= backend->is_pressed(layout, INPUT_ROLE_BILINEAR);
s->toggle_perspective_filter |= backend->is_pressed(layout, INPUT_ROLE_PERSPECTIVE);
s->toggle_ui |= backend->is_pressed(layout, INPUT_ROLE_TOGGLE_UI);
// clang-format on
backend->custom_update(s, layout);

View file

@ -505,7 +505,7 @@ static GAME_FLOW_COMMAND M_Control(INV_RING *const ring)
break;
case O_PHOTO_OPTION:
Sound_Effect(SFX_MENU_CHOOSE, NULL, SPM_ALWAYS);
Sound_Effect(SFX_MENU_LARA_HOME, NULL, SPM_ALWAYS);
break;
case O_CONTROL_OPTION:

View file

@ -1,5 +1,3 @@
#pragma once
#include "game/phase/phase_photo_mode.h"
#include <libtrx/game/phase.h>

View file

@ -3,6 +3,7 @@
#include "global/const.h"
#include "global/types.h"
#include <libtrx/game/camera/vars.h>
#include <libtrx/game/inventory_ring/enum.h>
#include <stdbool.h>

View file

@ -99,7 +99,6 @@ sources = [
init,
'game/box.c',
'game/camera/common.c',
'game/camera/photo_mode.c',
'game/carrier.c',
'game/clock.c',
'game/collide.c',
@ -252,7 +251,6 @@ sources = [
'game/phase/phase_demo.c',
'game/phase/phase_game.c',
'game/phase/phase_inventory.c',
'game/phase/phase_photo_mode.c',
'game/requester.c',
'game/room.c',
'game/room_draw.c',
@ -268,7 +266,6 @@ sources = [
'game/ui/common.c',
'game/ui/widgets/stats_dialog.c',
'game/ui/widgets/paginator.c',
'game/ui/widgets/photo_mode.c',
'game/viewport.c',
'global/enum_map.c',
'global/vars.c',

View file

@ -13,6 +13,8 @@
#include <libtrx/config.h>
#include <libtrx/debug.h>
#include <libtrx/game/camera/const.h>
#include <libtrx/game/camera/photo_mode.h>
#include <libtrx/game/math.h>
#include <libtrx/game/matrix.h>
#include <libtrx/utils.h>
@ -708,6 +710,11 @@ void Camera_Fixed(void)
void Camera_Update(void)
{
if (g_Camera.type == CAM_PHOTO_MODE) {
Camera_UpdatePhotoMode();
return;
}
if (g_Camera.type == CAM_CINEMATIC) {
Camera_LoadCutsceneFrame();
return;

View file

@ -50,6 +50,9 @@ static GAME_FLOW_COMMAND M_Control(const bool demo_mode)
Shell_ProcessInput();
Game_ProcessInput();
if (g_InputDB.toggle_photo_mode) {
return GF_EnterPhotoMode();
}
if (g_InputDB.pause) {
return GF_PauseGame();
}

View file

@ -668,6 +668,14 @@ GAME_FLOW_COMMAND GF_StartGame(
return gf_cmd;
}
GAME_FLOW_COMMAND GF_EnterPhotoMode(void)
{
PHASE *const subphase = Phase_PhotoMode_Create();
const GAME_FLOW_COMMAND gf_cmd = PhaseExecutor_Run(subphase);
Phase_PhotoMode_Destroy(subphase);
return gf_cmd;
}
GAME_FLOW_COMMAND GF_PauseGame(void)
{
PHASE *const subphase = Phase_Pause_Create();

View file

@ -17,6 +17,7 @@ void GF_ModifyInventory(int32_t level, int32_t type);
GAME_FLOW_COMMAND GF_StartDemo(int32_t level_num);
GAME_FLOW_COMMAND GF_StartGame(
int32_t level_num, GAME_FLOW_LEVEL_TYPE level_type);
GAME_FLOW_COMMAND GF_EnterPhotoMode(void);
GAME_FLOW_COMMAND GF_PauseGame(void);
GAME_FLOW_COMMAND GF_ShowInventory(INVENTORY_MODE mode);
GAME_FLOW_COMMAND GF_ShowInventoryKeys(GAME_OBJECT_ID receptacle_type_id);

View file

@ -83,6 +83,15 @@ static void M_UpdateFromBackend(
s->load |= backend->is_pressed(layout, INPUT_ROLE_LOAD);
s->pause |= backend->is_pressed(layout, INPUT_ROLE_PAUSE);
s->toggle_ui |= backend->is_pressed(layout, INPUT_ROLE_TOGGLE_UI);
s->toggle_photo_mode |= backend->is_pressed(layout, INPUT_ROLE_TOGGLE_PHOTO_MODE);
s->camera_up |= backend->is_pressed(layout, INPUT_ROLE_CAMERA_UP);
s->camera_down |= backend->is_pressed(layout, INPUT_ROLE_CAMERA_DOWN);
s->camera_forward |= backend->is_pressed(layout, INPUT_ROLE_CAMERA_FORWARD);
s->camera_back |= backend->is_pressed(layout, INPUT_ROLE_CAMERA_BACK);
s->camera_left |= backend->is_pressed(layout, INPUT_ROLE_CAMERA_LEFT);
s->camera_right |= backend->is_pressed(layout, INPUT_ROLE_CAMERA_RIGHT);
s->item_cheat |= backend->is_pressed(layout, INPUT_ROLE_ITEM_CHEAT);
s->fly_cheat |= backend->is_pressed(layout, INPUT_ROLE_FLY_CHEAT);
@ -131,6 +140,7 @@ void Input_Update(void)
M_UpdateFromBackend(
&g_Input, &g_Input_Controller, g_Config.input.controller_layout);
g_Input.camera_reset |= g_Input.look;
g_Input.menu_up |= g_Input.forward;
g_Input.menu_down |= g_Input.back;
g_Input.menu_left |= g_Input.left;
@ -175,27 +185,36 @@ const char *Input_GetRoleName(const INPUT_ROLE role)
{
// clang-format off
switch (role) {
case INPUT_ROLE_UP: return GS(KEYMAP_RUN);
case INPUT_ROLE_DOWN: return GS(KEYMAP_BACK);
case INPUT_ROLE_LEFT: return GS(KEYMAP_LEFT);
case INPUT_ROLE_RIGHT: return GS(KEYMAP_RIGHT);
case INPUT_ROLE_STEP_L: return GS(KEYMAP_STEP_LEFT);
case INPUT_ROLE_STEP_R: return GS(KEYMAP_STEP_RIGHT);
case INPUT_ROLE_SLOW: return GS(KEYMAP_WALK);
case INPUT_ROLE_JUMP: return GS(KEYMAP_JUMP);
case INPUT_ROLE_ACTION: return GS(KEYMAP_ACTION);
case INPUT_ROLE_DRAW: return GS(KEYMAP_DRAW_WEAPON);
case INPUT_ROLE_USE_FLARE: return GS(KEYMAP_USE_FLARE);
case INPUT_ROLE_LOOK: return GS(KEYMAP_LOOK);
case INPUT_ROLE_ROLL: return GS(KEYMAP_ROLL);
case INPUT_ROLE_OPTION: return GS(KEYMAP_INVENTORY);
case INPUT_ROLE_FLY_CHEAT: return GS(KEYMAP_FLY_CHEAT);
case INPUT_ROLE_ITEM_CHEAT: return GS(KEYMAP_ITEM_CHEAT);
case INPUT_ROLE_LEVEL_SKIP_CHEAT: return GS(KEYMAP_LEVEL_SKIP_CHEAT);
case INPUT_ROLE_TURBO_CHEAT: return GS(KEYMAP_TURBO_CHEAT);
case INPUT_ROLE_ENTER_CONSOLE: return GS(KEYMAP_ENTER_CONSOLE);
case INPUT_ROLE_PAUSE: return GS(KEYMAP_PAUSE);
default: return "";
case INPUT_ROLE_UP: return GS(KEYMAP_RUN);
case INPUT_ROLE_DOWN: return GS(KEYMAP_BACK);
case INPUT_ROLE_LEFT: return GS(KEYMAP_LEFT);
case INPUT_ROLE_RIGHT: return GS(KEYMAP_RIGHT);
case INPUT_ROLE_STEP_L: return GS(KEYMAP_STEP_LEFT);
case INPUT_ROLE_STEP_R: return GS(KEYMAP_STEP_RIGHT);
case INPUT_ROLE_SLOW: return GS(KEYMAP_WALK);
case INPUT_ROLE_JUMP: return GS(KEYMAP_JUMP);
case INPUT_ROLE_ACTION: return GS(KEYMAP_ACTION);
case INPUT_ROLE_DRAW: return GS(KEYMAP_DRAW_WEAPON);
case INPUT_ROLE_USE_FLARE: return GS(KEYMAP_USE_FLARE);
case INPUT_ROLE_LOOK: return GS(KEYMAP_LOOK);
case INPUT_ROLE_ROLL: return GS(KEYMAP_ROLL);
case INPUT_ROLE_OPTION: return GS(KEYMAP_INVENTORY);
case INPUT_ROLE_FLY_CHEAT: return GS(KEYMAP_FLY_CHEAT);
case INPUT_ROLE_ITEM_CHEAT: return GS(KEYMAP_ITEM_CHEAT);
case INPUT_ROLE_LEVEL_SKIP_CHEAT: return GS(KEYMAP_LEVEL_SKIP_CHEAT);
case INPUT_ROLE_TURBO_CHEAT: return GS(KEYMAP_TURBO_CHEAT);
case INPUT_ROLE_ENTER_CONSOLE: return GS(KEYMAP_ENTER_CONSOLE);
case INPUT_ROLE_PAUSE: return GS(KEYMAP_PAUSE);
case INPUT_ROLE_TOGGLE_UI: return GS(KEYMAP_TOGGLE_UI);
case INPUT_ROLE_TOGGLE_PHOTO_MODE: return GS(KEYMAP_TOGGLE_PHOTO_MODE);
case INPUT_ROLE_CAMERA_RESET: return GS(KEYMAP_CAMERA_RESET);
case INPUT_ROLE_CAMERA_UP: return GS(KEYMAP_CAMERA_UP);
case INPUT_ROLE_CAMERA_DOWN: return GS(KEYMAP_CAMERA_DOWN);
case INPUT_ROLE_CAMERA_FORWARD: return GS(KEYMAP_CAMERA_FORWARD);
case INPUT_ROLE_CAMERA_BACK: return GS(KEYMAP_CAMERA_BACK);
case INPUT_ROLE_CAMERA_LEFT: return GS(KEYMAP_CAMERA_LEFT);
case INPUT_ROLE_CAMERA_RIGHT: return GS(KEYMAP_CAMERA_RIGHT);
default: return "";
}
// clang-format on
}

View file

@ -645,7 +645,7 @@ INV_RING *InvRing_Open(const INVENTORY_MODE mode)
INV_RING *const ring = Memory_Alloc(sizeof(INV_RING));
ring->mode = mode;
ring->old_fov = Viewport_GetFOV();
ring->old_fov = Viewport_GetFOV(false);
m_NoInputCounter = 0;
switch (mode) {

View file

@ -135,6 +135,14 @@ static PHASE_CONTROL M_Control(PHASE *const phase, const int32_t num_frames)
.gf_cmd = { .action = GF_NOOP },
};
}
} else if (g_InputDB.toggle_photo_mode) {
const GAME_FLOW_COMMAND gf_cmd = GF_EnterPhotoMode();
if (gf_cmd.action != GF_NOOP) {
return (PHASE_CONTROL) {
.action = PHASE_ACTION_END,
.gf_cmd = { .action = GF_NOOP },
};
}
}
g_DynamicLightCount = 0;

View file

@ -312,7 +312,7 @@ static void M_HandleConfigChange(const EVENT *const event, void *const data)
}
if (CHANGED(visuals.fov) || CHANGED(visuals.use_pcx_fov)) {
if (Viewport_GetFOV() == -1) {
if (Viewport_GetFOV(false) == -1) {
Viewport_AlterFOV(-1);
}
}

View file

@ -20,6 +20,15 @@ static const INPUT_ROLE m_LeftRoles[] = {
INPUT_ROLE_SLOW,
INPUT_ROLE_ENTER_CONSOLE,
INPUT_ROLE_PAUSE,
INPUT_ROLE_TOGGLE_PHOTO_MODE,
INPUT_ROLE_TOGGLE_UI,
// INPUT_ROLE_CAMERA_RESET, // same as look, no need to configure
INPUT_ROLE_CAMERA_UP,
INPUT_ROLE_CAMERA_DOWN,
INPUT_ROLE_CAMERA_LEFT,
INPUT_ROLE_CAMERA_RIGHT,
INPUT_ROLE_CAMERA_FORWARD,
INPUT_ROLE_CAMERA_BACK,
(INPUT_ROLE)-1,
// clang-format on
};

View file

@ -4,6 +4,9 @@
#include <libtrx/game/ui/widgets/stack.h>
#include <libtrx/memory.h>
#include <stdio.h>
#include <string.h>
typedef struct {
UI_WIDGET_VTABLE vtable;
INPUT_ROLE input_role;
@ -32,7 +35,10 @@ static void M_UpdateText(UI_CONTROLS_INPUT_SELECTOR *const self)
} else {
UI_Label_ChangeText(self->choice, key_name);
}
UI_Label_ChangeText(self->label, Input_GetRoleName(self->input_role));
const char *const role_name = Input_GetRoleName(self->input_role);
char role_name_padded[strlen(role_name) + 2];
sprintf(role_name_padded, "%s ", role_name);
UI_Label_ChangeText(self->label, role_name_padded);
}
static int32_t M_GetWidth(const UI_CONTROLS_INPUT_SELECTOR *const self)
@ -119,7 +125,7 @@ UI_WIDGET *UI_ControlsInputSelector_Create(
self->controller = controller;
self->input_role = input_role;
self->label = UI_Label_Create("", 140, 15);
self->label = UI_Label_Create("", UI_LABEL_AUTO_SIZE, 15);
self->choice = UI_Label_Create("", 70, 15);
self->container = UI_Stack_Create(
UI_STACK_LAYOUT_HORIZONTAL, UI_STACK_AUTO_SIZE, UI_STACK_AUTO_SIZE);

View file

@ -189,9 +189,11 @@ void Viewport_Restore(const VIEWPORT *ref_vp)
M_ApplyGameVars(&m_Viewport);
}
int16_t Viewport_GetFOV(void)
int16_t Viewport_GetFOV(bool resolve_user_fov)
{
return m_Viewport.view_angle;
return resolve_user_fov && m_Viewport.view_angle < 0
? g_Config.visuals.fov * DEG_1
: m_Viewport.view_angle;
}
void Viewport_AlterFOV(const int16_t view_angle)

View file

@ -51,7 +51,7 @@ void Viewport_Reset(void);
void Viewport_Restore(const VIEWPORT *ref_vp);
int16_t Viewport_GetFOV(void);
int16_t Viewport_GetFOV(bool resolve_user_fov);
void Viewport_AlterFOV(int16_t view_angle);
const VIEWPORT *Viewport_Get(void);

View file

@ -2,6 +2,7 @@
#include "global/types.h"
#include <libtrx/game/camera/vars.h>
#include <libtrx/gfx/context.h>
#include <SDL2/SDL.h>