Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
514 changes: 514 additions & 0 deletions code/camera/photomode.cpp

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions code/camera/photomode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

void photo_mode_set_active(bool active);
void photo_mode_do_frame(float frame_time);
void photo_mode_maybe_render_hud();
void photo_mode_clear_screenshot_queued_flag();
void photo_mode_set_screenshot_queued_flag();

// mission-level permission to allow/disallow Photo Mode
void game_toggle_photo_mode();
void game_set_photo_mode_allowed(bool allowed);
bool game_get_photo_mode_allowed();
bool game_is_photo_mode_active();
void game_cycle_photo_mode_filter(int direction);
void game_reset_photo_mode_filters();
void game_adjust_photo_mode_filter_parameter(int delta);
void game_toggle_photo_mode_grid();
8 changes: 8 additions & 0 deletions code/controlconfig/controlsconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ enum IoActionId : int {

CYCLE_PRIMARY_WEAPON_PATTERN,

TOGGLE_PHOTO_MODE,
PHOTO_MODE_FILTER_PREV,
PHOTO_MODE_FILTER_NEXT,
PHOTO_MODE_FILTER_RESET,
PHOTO_MODE_PARAM_DECREASE,
PHOTO_MODE_PARAM_INCREASE,
PHOTO_MODE_TOGGLE_GRID,

/*!
* This must always be below the last defined item
*/
Expand Down
21 changes: 21 additions & 0 deletions code/controlconfig/controlsconfigcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ void control_config_common_init_bindings() {
(TOGGLE_HUD_CONTRAST, KEY_L, -1, COMPUTER_TAB, 1, "Toggle High HUD Contrast", CC_TYPE_TRIGGER)
(TOGGLE_HUD_SHADOWS, KEY_ALTED | KEY_L, -1, COMPUTER_TAB, 1781, "Toggle HUD Drop Shadows", CC_TYPE_TRIGGER)
(HUD_TARGETBOX_TOGGLE_WIREFRAME, KEY_ALTED | KEY_SHIFTED | KEY_Q, -1, COMPUTER_TAB, 1, "Toggle HUD Wireframe Target View", CC_TYPE_TRIGGER)
(TOGGLE_PHOTO_MODE, KEY_ALTED | KEY_1, -1, COMPUTER_TAB, 1910, "Toggle Photo Mode", CC_TYPE_TRIGGER)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know mods can disable controls if they want, but would be interesting to hear if anyone wants to decrease or increase the number of controls for photo mode suggested here. @z64555 would be particularly interested if you could comment, too? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you decrease the number of controls? You need a toggle and a way to change the filters.

(PHOTO_MODE_FILTER_PREV, KEY_ALTED | KEY_2, -1, COMPUTER_TAB, 1911, "Photo Mode Previous Parameter", CC_TYPE_TRIGGER)
(PHOTO_MODE_FILTER_NEXT, KEY_ALTED | KEY_3, -1, COMPUTER_TAB, 1912, "Photo Mode Next Parameter", CC_TYPE_TRIGGER)
(PHOTO_MODE_FILTER_RESET, KEY_ALTED | KEY_4, -1, COMPUTER_TAB, 1913, "Photo Mode Reset Parameters", CC_TYPE_TRIGGER)
(PHOTO_MODE_PARAM_DECREASE, KEY_ALTED | KEY_SHIFTED | KEY_MINUS, -1, COMPUTER_TAB, 1914, "Photo Mode Decrease Selected Parameter", CC_TYPE_TRIGGER)
(PHOTO_MODE_PARAM_INCREASE, KEY_ALTED | KEY_SHIFTED | KEY_EQUAL, -1, COMPUTER_TAB, 1915, "Photo Mode Increase Selected Parameter", CC_TYPE_TRIGGER)
(PHOTO_MODE_TOGGLE_GRID, KEY_ALTED | KEY_5, -1, COMPUTER_TAB, 1916, "Photo Mode Toggle Grid", CC_TYPE_TRIGGER)

// Custom Controls
(CUSTOM_CONTROL_1, KEY_ALTED | KEY_SHIFTED | KEY_1, -1, COMPUTER_TAB, 1784, "Custom Control 1", CC_TYPE_TRIGGER, true)
Expand Down Expand Up @@ -432,6 +439,13 @@ SCP_unordered_map<SCP_string, IoActionId> old_text = {
{"Up Thrust", UP_SLIDE_THRUST},
{"Down Thrust", DOWN_SLIDE_THRUST},
{"Toggle HUD Wireframe Target View", HUD_TARGETBOX_TOGGLE_WIREFRAME},
{"Toggle Photo Mode", TOGGLE_PHOTO_MODE},
{"Photo Mode Previous Parameter", PHOTO_MODE_FILTER_PREV},
{"Photo Mode Next Parameter", PHOTO_MODE_FILTER_NEXT},
{"Photo Mode Reset Parameters", PHOTO_MODE_FILTER_RESET},
{"Photo Mode Decrease Selected Parameter", PHOTO_MODE_PARAM_DECREASE},
{"Photo Mode Increase Selected Parameter", PHOTO_MODE_PARAM_INCREASE},
{"Photo Mode Toggle Grid", PHOTO_MODE_TOGGLE_GRID},
{"Top-Down View", VIEW_TOPDOWN},
{"Target Padlock View", VIEW_TRACK_TARGET},

Expand Down Expand Up @@ -1151,6 +1165,13 @@ void LoadEnumsIntoActionMap() {
ADD_ENUM_TO_ACTION_MAP(UP_SLIDE_THRUST)
ADD_ENUM_TO_ACTION_MAP(DOWN_SLIDE_THRUST)
ADD_ENUM_TO_ACTION_MAP(HUD_TARGETBOX_TOGGLE_WIREFRAME)
ADD_ENUM_TO_ACTION_MAP(TOGGLE_PHOTO_MODE)
ADD_ENUM_TO_ACTION_MAP(PHOTO_MODE_FILTER_PREV)
ADD_ENUM_TO_ACTION_MAP(PHOTO_MODE_FILTER_NEXT)
ADD_ENUM_TO_ACTION_MAP(PHOTO_MODE_FILTER_RESET)
ADD_ENUM_TO_ACTION_MAP(PHOTO_MODE_PARAM_DECREASE)
ADD_ENUM_TO_ACTION_MAP(PHOTO_MODE_PARAM_INCREASE)
ADD_ENUM_TO_ACTION_MAP(PHOTO_MODE_TOGGLE_GRID)
ADD_ENUM_TO_ACTION_MAP(VIEW_TOPDOWN)
ADD_ENUM_TO_ACTION_MAP(VIEW_TRACK_TARGET)

Expand Down
5 changes: 5 additions & 0 deletions code/graphics/2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2963,6 +2963,11 @@ void gr_request_screenshot(const char* filename)
}
}

bool gr_is_screenshot_requested()
{
return !Pending_screenshot_filename.empty();
}

void gr_print_timestamp(int x, int y, fix timestamp, int resize_mode)
{
int seconds = f2i(timestamp);
Expand Down
1 change: 1 addition & 0 deletions code/graphics/2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ extern void gr_activate(int active);
#define gr_dump_envmap GR_CALL(gr_screen.gf_dump_envmap)

void gr_request_screenshot(const char* filename);
bool gr_is_screenshot_requested();

//#define gr_flip GR_CALL(gr_screen.gf_flip)
void gr_flip(bool execute_scripting = true);
Expand Down
59 changes: 54 additions & 5 deletions code/io/keycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "globalincs/pstypes.h"
#include "globalincs/globals.h"
#include "globalincs/linklist.h"
#include "camera/photomode.h"
#include "io/key.h"
#include "io/joy.h"
#include "io/timer.h"
Expand Down Expand Up @@ -328,6 +329,13 @@ int Normal_key_set[] = {
MULTI_SELF_DESTRUCT,

TOGGLE_HUD,
TOGGLE_PHOTO_MODE,
PHOTO_MODE_FILTER_PREV,
PHOTO_MODE_FILTER_NEXT,
PHOTO_MODE_FILTER_RESET,
PHOTO_MODE_PARAM_DECREASE,
PHOTO_MODE_PARAM_INCREASE,
PHOTO_MODE_TOGGLE_GRID,

HUD_TARGETBOX_TOGGLE_WIREFRAME,
AUTO_PILOT_TOGGLE,
Expand Down Expand Up @@ -475,6 +483,13 @@ int Non_critical_key_set[] = {
MULTI_SELF_DESTRUCT,

TOGGLE_HUD,
TOGGLE_PHOTO_MODE,
PHOTO_MODE_FILTER_PREV,
PHOTO_MODE_FILTER_NEXT,
PHOTO_MODE_FILTER_RESET,
PHOTO_MODE_PARAM_DECREASE,
PHOTO_MODE_PARAM_INCREASE,
PHOTO_MODE_TOGGLE_GRID,

HUD_TARGETBOX_TOGGLE_WIREFRAME,
AUTO_PILOT_TOGGLE,
Expand Down Expand Up @@ -1536,9 +1551,13 @@ void game_do_end_mission_popup()
if (Game_subspace_effect) {
game_start_subspace_ambient_sound();
}
audiostream_unpause_all();

if (!game_is_photo_mode_active()) {
audiostream_unpause_all();
message_resume_all();
}

weapon_unpause_sounds();
message_resume_all();
break;
}

Expand Down Expand Up @@ -2230,10 +2249,12 @@ int button_function_demo_valid(int n)

case TIME_SLOW_DOWN:
ret = 1;
if ( Game_mode & GM_NORMAL && !Time_compression_locked ) {
if (Game_mode & GM_NORMAL && (!Time_compression_locked || game_is_photo_mode_active())) {
const auto min_compression = game_is_photo_mode_active() ? fl2f(0.01f) : (F1_0 / (Cmdline_retail_time_compression_range ? MAX_TIME_DIVIDER_RETAIL : MAX_TIME_DIVIDER));

// Goober5000 - time dilation only available in cheat mode (see above);
// now you can do it with or without pressing the tilde, per Kazan's request
if ((Game_time_compression > F1_0) || (Cheats_enabled && (Game_time_compression > (F1_0 / (Cmdline_retail_time_compression_range ? MAX_TIME_DIVIDER_RETAIL : MAX_TIME_DIVIDER))))) {
if ((Game_time_compression > F1_0) || (Game_time_compression > min_compression && (Cheats_enabled || game_is_photo_mode_active()))) {
change_time_compression(0.5f);
break;
}
Expand All @@ -2243,7 +2264,7 @@ int button_function_demo_valid(int n)

case TIME_SPEED_UP:
ret = 1;
if ( Game_mode & GM_NORMAL && !Time_compression_locked ) {
if (Game_mode & GM_NORMAL && (!Time_compression_locked || game_is_photo_mode_active())) {
if (Game_time_compression < (F1_0 * (Cmdline_retail_time_compression_range ? MAX_TIME_MULTIPLIER_RETAIL : MAX_TIME_MULTIPLIER))) {
change_time_compression(2.0f);
break;
Expand Down Expand Up @@ -2582,6 +2603,34 @@ int button_function(int n)
hud_toggle_draw();
break;

case TOGGLE_PHOTO_MODE:
game_toggle_photo_mode();
break;

case PHOTO_MODE_FILTER_PREV:
game_cycle_photo_mode_filter(-1);
break;

case PHOTO_MODE_FILTER_NEXT:
game_cycle_photo_mode_filter(1);
break;

case PHOTO_MODE_FILTER_RESET:
game_reset_photo_mode_filters();
break;

case PHOTO_MODE_PARAM_DECREASE:
game_adjust_photo_mode_filter_parameter(-1);
break;

case PHOTO_MODE_PARAM_INCREASE:
game_adjust_photo_mode_filter_parameter(1);
break;

case PHOTO_MODE_TOGGLE_GRID:
game_toggle_photo_mode_grid();
break;

case HUD_TARGETBOX_TOGGLE_WIREFRAME:
if (!Lock_targetbox_mode) {
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
Expand Down
2 changes: 1 addition & 1 deletion code/localization/localize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool *Lcl_unexpected_tstring_check = nullptr;
// NOTE: with map storage of XSTR strings, the indexes no longer need to be contiguous,
// but internal strings should still increment XSTR_SIZE to avoid collisions.
// retail XSTR_SIZE = 1570
// #define XSTR_SIZE 1892 // This is the next available ID
// #define XSTR_SIZE 1917 // This is the next available ID

// struct to allow for strings.tbl-determined x offset
// offset is 0 for english, by default
Expand Down
13 changes: 9 additions & 4 deletions code/missionui/missionpause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "controlconfig/controlsconfig.h"
#include "freespace.h"
#include "camera/photomode.h"
#include "gamesequence/gamesequence.h"
#include "globalincs/alphacolors.h"
#include "graphics/font.h"
Expand Down Expand Up @@ -254,8 +255,10 @@ void pause_close()
// unpause all weapon sounds
weapon_unpause_sounds();

// unpause voices
message_resume_all();
// unpause voices unless Photo Mode is keeping playback paused
if (!game_is_photo_mode_active()) {
message_resume_all();
}

// deinit stuff
if(Pause_saved_screen != -1) {
Expand All @@ -273,8 +276,10 @@ void pause_close()

io::mouse::CursorManager::get()->popStatus();

// unpause all the music
audiostream_unpause_all();
// unpause all the music unless Photo Mode is keeping playback paused
if (!game_is_photo_mode_active()) {
audiostream_unpause_all();
}

Paused = false;
}
Expand Down
33 changes: 31 additions & 2 deletions code/parse/sexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "asteroid/asteroid.h"
#include "autopilot/autopilot.h"
#include "camera/camera.h"
#include "camera/photomode.h"
#include "cmdline/cmdline.h"
#include "debris/debris.h"
#include "debugconsole/console.h"
Expand Down Expand Up @@ -747,6 +748,7 @@ SCP_vector<sexp_oper> Operators = {
{ "show-subtitle-image", OP_CUTSCENES_SHOW_SUBTITLE_IMAGE, 8, 11, SEXP_ACTION_OPERATOR, },
{ "clear-subtitles", OP_CLEAR_SUBTITLES, 0, 0, SEXP_ACTION_OPERATOR, },
{ "lock-perspective", OP_CUTSCENES_FORCE_PERSPECTIVE, 1, 3, SEXP_ACTION_OPERATOR, },
{ "allow-photo-mode", OP_ALLOW_PHOTO_MODE, 1, 1, SEXP_ACTION_OPERATOR, },
{ "set-camera-shudder", OP_SET_CAMERA_SHUDDER, 2, 4, SEXP_ACTION_OPERATOR, },
{ "supernova-start", OP_SUPERNOVA_START, 1, 1, SEXP_ACTION_OPERATOR, },
{ "supernova-stop", OP_SUPERNOVA_STOP, 0, 0, SEXP_ACTION_OPERATOR, }, //CommanderDJ
Expand Down Expand Up @@ -25700,6 +25702,8 @@ camera* sexp_get_set_camera(bool reset = false)

void sexp_set_camera(int node)
{
game_set_photo_mode_allowed(false);

if (node < 0)
{
sexp_get_set_camera(true);
Expand Down Expand Up @@ -26191,6 +26195,8 @@ void multi_sexp_reset_fov()

void sexp_reset_camera(int node)
{
game_set_photo_mode_allowed(true);

bool cam_reset = false;
camera *cam = cam_get_current().getCamera();
if (cam != nullptr)
Expand All @@ -26209,6 +26215,8 @@ void sexp_reset_camera(int node)

void multi_sexp_reset_camera()
{
game_set_photo_mode_allowed(true);

camera *cam = cam_get_current().getCamera();
bool cam_reset = false;

Expand Down Expand Up @@ -26787,6 +26795,11 @@ void sexp_force_perspective(int n)
}
}

void sexp_allow_photo_mode(int n)
{
game_set_photo_mode_allowed(is_sexp_true(n));
}

void sexp_set_camera_shudder(int n)
{
int time;
Expand Down Expand Up @@ -30378,6 +30391,10 @@ int eval_sexp(int cur_node, int referenced_node)
sexp_val = SEXP_TRUE;
sexp_force_perspective(node);
break;
case OP_ALLOW_PHOTO_MODE:
sexp_val = SEXP_TRUE;
sexp_allow_photo_mode(node);
break;

case OP_SET_CAMERA_SHUDDER:
sexp_val = SEXP_TRUE;
Expand Down Expand Up @@ -31778,6 +31795,7 @@ int query_operator_return_type(int op)
case OP_CUTSCENES_SET_TIME_COMPRESSION:
case OP_CUTSCENES_RESET_TIME_COMPRESSION:
case OP_CUTSCENES_FORCE_PERSPECTIVE:
case OP_ALLOW_PHOTO_MODE:
case OP_SET_CAMERA_SHUDDER:
case OP_JUMP_NODE_SET_JUMPNODE_NAME:
case OP_JUMP_NODE_SET_JUMPNODE_DISPLAY_NAME:
Expand Down Expand Up @@ -34426,6 +34444,9 @@ int query_operator_argument_type(int op, int argnum)
else
return OPF_BOOL;

case OP_ALLOW_PHOTO_MODE:
return OPF_BOOL;

case OP_SET_CAMERA_SHUDDER:
if (argnum == 0 || argnum == 1)
return OPF_POSITIVE;
Expand Down Expand Up @@ -36871,6 +36892,7 @@ int get_category(int op_id)
case OP_CUTSCENES_SET_TIME_COMPRESSION:
case OP_CUTSCENES_RESET_TIME_COMPRESSION:
case OP_CUTSCENES_FORCE_PERSPECTIVE:
case OP_ALLOW_PHOTO_MODE:
case OP_JUMP_NODE_SET_JUMPNODE_NAME:
case OP_JUMP_NODE_SET_JUMPNODE_DISPLAY_NAME:
case OP_JUMP_NODE_SET_JUMPNODE_COLOR:
Expand Down Expand Up @@ -37519,6 +37541,7 @@ int get_subcategory(int op_id)
case OP_CUTSCENES_SHOW_SUBTITLE_IMAGE:
case OP_CLEAR_SUBTITLES:
case OP_CUTSCENES_FORCE_PERSPECTIVE:
case OP_ALLOW_PHOTO_MODE:
case OP_SET_CAMERA_SHUDDER:
case OP_SUPERNOVA_START:
case OP_SUPERNOVA_STOP:
Expand Down Expand Up @@ -41997,7 +42020,7 @@ SCP_vector<sexp_help_struct> Sexp_help = {
},

{ OP_CUTSCENES_SET_CAMERA, "set-camera\r\n"
"\tSets SEXP camera, or another specified cutscene camera. "
"\tSets SEXP camera, or another specified cutscene camera. Automatically disables photo mode while cutscene camera control is active."
"Takes 0 to 1 arguments...\r\n"
"\t(optional)\r\n"
"\t1:\tCamera name (created if nonexistent)\r\n"
Expand Down Expand Up @@ -42095,7 +42118,7 @@ SCP_vector<sexp_help_struct> Sexp_help = {
},

{ OP_CUTSCENES_RESET_CAMERA, "reset-camera\r\n"
"\tReleases cutscene camera control. "
"\tReleases cutscene camera control. Automatically re-enables photo mode."
"Takes 1 optional argument...\r\n"
"\t(optional)\r\n"
"\t1:\tReset camera data (Position, facing, FOV...) (default: false)"
Expand Down Expand Up @@ -42182,6 +42205,12 @@ SCP_vector<sexp_help_struct> Sexp_help = {
"\t3:\tIf in first-person, true to lock the hat/slew/free-look/target-track mode, false to unlock it (optional)\r\n"
},

{ OP_ALLOW_PHOTO_MODE, "allow-photo-mode\r\n"
"\tAllows or disallows Photo Mode for this mission. "
"Takes 1 argument...\r\n"
"\t1:\tTrue to allow Photo Mode, false to disallow it\r\n"
},

{ OP_SET_CAMERA_SHUDDER, "set-camera-shudder\r\n"
"\tCauses the camera to shudder. Normally this will only work if the camera is showing the player's viewpoint (i.e. the HUD), unless the Everywhere flag is set.\r\n\r\n"
"Takes 2 to 4 arguments...\r\n"
Expand Down
1 change: 1 addition & 0 deletions code/parse/sexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ enum : int {
OP_CUTSCENES_SET_TIME_COMPRESSION, // WMC
OP_CUTSCENES_RESET_TIME_COMPRESSION, // WMC
OP_CUTSCENES_FORCE_PERSPECTIVE, // WMC
OP_ALLOW_PHOTO_MODE,
OP_JUMP_NODE_SET_JUMPNODE_NAME, // CommanderDJ
OP_JUMP_NODE_SET_JUMPNODE_DISPLAY_NAME,
OP_JUMP_NODE_SET_JUMPNODE_COLOR, // WMC
Expand Down
Loading
Loading