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
22 changes: 22 additions & 0 deletions code/lighting/lighting_profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ typedef int profile_index;
profile _current;
SCP_unordered_map<SCP_string, profile> Profiles;
SCP_string default_profile_name;
SCP_string non_mission_profile_name;

const SCP_string &default_name()
{
return default_profile_name;
}

const SCP_string& non_mission_name()
{
return non_mission_profile_name;
}

const profile* current()
{
return &_current;
Expand All @@ -54,6 +60,11 @@ void switch_to(const SCP_string& name)
_current = Profiles[name];
}

void switch_to_non_mission()
{
switch_to(non_mission_profile_name);
}

void update_current_profile()
{
// processes any change-overs and transitions
Expand Down Expand Up @@ -250,7 +261,14 @@ void parse_all();
void load_profiles()
{
default_profile_name = "Default Profile";
non_mission_profile_name = default_profile_name;
parse_all();
if (Profiles.find(non_mission_profile_name) == Profiles.end()) {
mprintf(("Unknown non-mission lighting profile '%s'; using '%s' instead.\n",
non_mission_profile_name.c_str(),
default_profile_name.c_str()));
non_mission_profile_name = default_profile_name;
}
switch_to(default_profile_name);
}
// The logic for grabbing all the parseable files
Expand Down Expand Up @@ -341,6 +359,10 @@ void profile::parse(const char* filename, const SCP_string& profile_name, const
tonemapper = tn;
parsed = true;
}
if (optional_string("$Non-mission lighting profile:")) {
stuff_string(non_mission_profile_name, F_NAME);
parsed = true;
}
parsed |= parse_optional_float_into("$PPC Toe Strength:", &ppc_values.toe_strength);
parsed |= parse_optional_float_into("$PPC Toe Length:", &ppc_values.toe_length);
parsed |= parse_optional_float_into("$PPC Shoulder Length:", &ppc_values.shoulder_length);
Expand Down
20 changes: 20 additions & 0 deletions code/lighting/lighting_profiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class profile {
};

const SCP_string &default_name();
const SCP_string& non_mission_name();
const profile* current();
enum TonemapperAlgorithm name_to_tonemapper(SCP_string name);
SCP_string tonemapper_to_name(TonemapperAlgorithm tnm);
Expand All @@ -103,4 +104,23 @@ float lab_get_emissive();
void lab_set_emissive(float in);
SCP_vector<SCP_string> list_profiles();
void switch_to(const SCP_string& name);
void switch_to_non_mission();

// Use the tech room profile profile and then automatically
// remove it on destruction.
class set_non_mission_profile {
public:
set_non_mission_profile() : _old_profile_name(current()->name)
{
switch_to_non_mission();
}

~set_non_mission_profile()
{
switch_to(_old_profile_name);
}

private:
SCP_string _old_profile_name;
};
} // namespace lighting_profiles
3 changes: 3 additions & 0 deletions code/menuui/techmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "io/key.h"
#include "io/mouse.h"
#include "lighting/lighting.h"
#include "lighting/lighting_profiles.h"
#include "localization/localize.h"
#include "menuui/techmenu.h"
#include "missionui/missionscreencommon.h"
Expand Down Expand Up @@ -516,6 +517,8 @@ void tech_common_render()

void techroom_ships_render(float frametime)
{
lighting_profiles::set_non_mission_profile non_mission_lighting_profile;

// render all the common stuff
tech_common_render();

Expand Down
3 changes: 3 additions & 0 deletions code/missionui/missionbrief.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "io/timer.h"
#include "jumpnode/jumpnode.h"
#include "lighting/lighting.h"
#include "lighting/lighting_profiles.h"
#include "menuui/snazzyui.h"
#include "mission/missionbriefcommon.h"
#include "mission/missioncampaign.h"
Expand Down Expand Up @@ -1080,6 +1081,8 @@ void brief_render_closeup_text()
//
void brief_render_closeup(int ship_class, float frametime)
{
lighting_profiles::set_non_mission_profile non_mission_lighting_profile;

matrix view_orient = IDENTITY_MATRIX;
matrix temp_matrix;
float ang;
Expand Down
5 changes: 5 additions & 0 deletions code/missionui/missionscreencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "io/mouse.h"
#include "io/timer.h"
#include "lighting/lighting.h"
#include "lighting/lighting_profiles.h"
#include "missionui/chatbox.h"
#include "missionui/missionbrief.h"
#include "missionui/missionscreencommon.h"
Expand Down Expand Up @@ -1553,6 +1554,8 @@ int restore_wss_data(ubyte *data)

void draw_model_icon(int model_id, uint64_t flags, float closeup_zoom, int x, int y, int w, int h, ship_info *sip, int resize_mode, const vec3d *closeup_pos)
{
lighting_profiles::set_non_mission_profile non_mission_lighting_profile;

matrix object_orient = IDENTITY_MATRIX;
angles rot_angles = vmd_zero_angles;
float zoom = closeup_zoom * 2.5f;
Expand Down Expand Up @@ -1669,6 +1672,8 @@ void draw_model_rotating(model_render_params *render_info, int model_id, int x1,
if (model_id < 0)
return;

lighting_profiles::set_non_mission_profile non_mission_lighting_profile;

float time = (timer_get_milliseconds()-anim_timer_start)/1000.0f;
angles rot_angles, view_angles;
matrix model_orient;
Expand Down
3 changes: 3 additions & 0 deletions code/missionui/missionweaponchoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "io/mouse.h"
#include "io/timer.h"
#include "lighting/lighting.h"
#include "lighting/lighting_profiles.h"
#include "localization/localize.h"
#include "menuui/snazzyui.h"
#include "missionui/chatbox.h"
Expand Down Expand Up @@ -768,6 +769,8 @@ void draw_3d_overhead_view(int model_num,
overhead_style style,
const SCP_string& tcolor)
{
lighting_profiles::set_non_mission_profile non_mission_lighting_profile;

ship_info* sip = &Ship_info[ship_class];

if (model_num < 0) {
Expand Down
3 changes: 3 additions & 0 deletions code/model/modelrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "io/timer.h"
#include "jumpnode/jumpnode.h"
#include "lighting/lighting.h"
#include "lighting/lighting_profiles.h"
#include "math/staticrand.h"
#include "missionui/missionscreencommon.h"
#include "mod_table/mod_table.h"
Expand Down Expand Up @@ -3111,6 +3112,8 @@ void modelinstance_replace_active_texture(polymodel_instance* pmi, const char* o
bool render_tech_model(tech_render_type model_type, int x1, int y1, int x2, int y2, float zoom, bool lighting, int class_idx, const matrix* orient, const SCP_string &pof_filename, float close_zoom, const vec3d *close_pos, const SCP_string& tcolor)
{

lighting_profiles::set_non_mission_profile non_mission_lighting_profile;

model_render_params render_info;
const vec3d *closeup_pos;
float closeup_zoom;
Expand Down