diff --git a/code/lighting/lighting_profiles.cpp b/code/lighting/lighting_profiles.cpp index 6c0c6ab1ef8..4da21173dc1 100644 --- a/code/lighting/lighting_profiles.cpp +++ b/code/lighting/lighting_profiles.cpp @@ -25,12 +25,18 @@ typedef int profile_index; profile _current; SCP_unordered_map 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; @@ -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 @@ -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 @@ -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); diff --git a/code/lighting/lighting_profiles.h b/code/lighting/lighting_profiles.h index 9ad7a224302..12b5fdf8397 100644 --- a/code/lighting/lighting_profiles.h +++ b/code/lighting/lighting_profiles.h @@ -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); @@ -103,4 +104,23 @@ float lab_get_emissive(); void lab_set_emissive(float in); SCP_vector 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 \ No newline at end of file diff --git a/code/menuui/techmenu.cpp b/code/menuui/techmenu.cpp index b3d81b4ecfa..bfd140745c2 100644 --- a/code/menuui/techmenu.cpp +++ b/code/menuui/techmenu.cpp @@ -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" @@ -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(); diff --git a/code/missionui/missionbrief.cpp b/code/missionui/missionbrief.cpp index da08601d249..8bc97cb8576 100644 --- a/code/missionui/missionbrief.cpp +++ b/code/missionui/missionbrief.cpp @@ -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" @@ -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; diff --git a/code/missionui/missionscreencommon.cpp b/code/missionui/missionscreencommon.cpp index e8212e5964f..61f15d4d3b7 100644 --- a/code/missionui/missionscreencommon.cpp +++ b/code/missionui/missionscreencommon.cpp @@ -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" @@ -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; @@ -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; diff --git a/code/missionui/missionweaponchoice.cpp b/code/missionui/missionweaponchoice.cpp index eb3d450e117..44aab33306f 100644 --- a/code/missionui/missionweaponchoice.cpp +++ b/code/missionui/missionweaponchoice.cpp @@ -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" @@ -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) { diff --git a/code/model/modelrender.cpp b/code/model/modelrender.cpp index fbed56763cc..bfad90a4d1f 100644 --- a/code/model/modelrender.cpp +++ b/code/model/modelrender.cpp @@ -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" @@ -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;