Skip to content

Commit c05c06d

Browse files
authored
Fix CockpitFOV and CockpitFOVToggle missing in default table (scp-fs2open#7547)
* Update camera.cpp * order cleanup
1 parent b26c8e4 commit c05c06d

1 file changed

Lines changed: 39 additions & 20 deletions

File tree

code/camera/camera.cpp

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ APPLY_TO_FOV_T(-, sub)
5656

5757
// Used to set the default value for in-game options
5858
static float fov_default = DEFAULT_FOV;
59+
static float cockpit_fov_default = DEFAULT_FOV;
60+
static bool cockpit_fov_toggle_default = false;
61+
62+
bool Use_cockpit_fov = false;
5963

6064
static SCP_string fov_display(float val)
6165
{
@@ -73,6 +77,21 @@ static void parse_fov_func()
7377
fov_default = value;
7478
}
7579

80+
static void parse_cockpit_fov_func()
81+
{
82+
float value;
83+
stuff_float(&value);
84+
CLAMP(value, 0.436332f, 1.5708f);
85+
cockpit_fov_default = value;
86+
}
87+
88+
static void parse_cockpit_fov_toggle_func()
89+
{
90+
bool value;
91+
stuff_boolean(&value);
92+
cockpit_fov_toggle_default = value;
93+
}
94+
7695
// coverity[GLOBAL_INIT_ORDER] -- safe; OptionBuilder::finish() uses Meyers singleton
7796
auto FovOption = options::OptionBuilder<float>("Graphics.FOV",
7897
std::pair<const char*, int>{"Field Of View", 1703},
@@ -90,25 +109,6 @@ auto FovOption = options::OptionBuilder<float>("Graphics.FOV",
90109
.parser(parse_fov_func)
91110
.finish();
92111

93-
bool Use_cockpit_fov = false;
94-
95-
// coverity[GLOBAL_INIT_ORDER] -- safe; OptionBuilder::finish() uses Meyers singleton
96-
auto CockpitFOVToggleOption = options::OptionBuilder<bool>("Graphics.CockpitFOVToggle",
97-
std::pair<const char*, int>{"Cockpit FOV Toggle", 1838},
98-
std::pair<const char*, int>{"Whether or not to use a different FOV for cockpit rendering from normal rendering", 1839})
99-
.category(std::make_pair("Graphics", 1825))
100-
.default_val(false)
101-
.change_listener([](bool val, bool) {
102-
if (!val) {
103-
COCKPIT_ZOOM_DEFAULT = VIEWER_ZOOM_DEFAULT;
104-
}
105-
return true; // This option will always persist so we never return false
106-
})
107-
.level(options::ExpertLevel::Advanced)
108-
.bind_to(&Use_cockpit_fov)
109-
.importance(61)
110-
.finish();
111-
112112
// coverity[GLOBAL_INIT_ORDER] -- safe; OptionBuilder::finish() uses Meyers singleton
113113
auto CockpitFovOption = options::OptionBuilder<float>("Graphics.CockpitFOV",
114114
std::pair<const char*, int>{"Cockpit Field Of View", 1840},
@@ -124,9 +124,28 @@ auto CockpitFovOption = options::OptionBuilder<float>("Graphics.CockpitFOV",
124124
return true;
125125
})
126126
.display(fov_display)
127-
.default_val(fov_default)
127+
.default_func([]() { return cockpit_fov_default; })
128128
.level(options::ExpertLevel::Advanced)
129129
.importance(62)
130+
.parser(parse_cockpit_fov_func)
131+
.finish();
132+
133+
// coverity[GLOBAL_INIT_ORDER] -- safe; OptionBuilder::finish() uses Meyers singleton
134+
auto CockpitFOVToggleOption = options::OptionBuilder<bool>("Graphics.CockpitFOVToggle",
135+
std::pair<const char*, int>{"Cockpit FOV Toggle", 1838},
136+
std::pair<const char*, int>{"Whether or not to use a different FOV for cockpit rendering from normal rendering", 1839})
137+
.category(std::make_pair("Graphics", 1825))
138+
.default_func([]() {return cockpit_fov_toggle_default;})
139+
.change_listener([](bool val, bool) {
140+
if (!val) {
141+
COCKPIT_ZOOM_DEFAULT = VIEWER_ZOOM_DEFAULT;
142+
}
143+
return true; // This option will always persist so we never return false
144+
})
145+
.level(options::ExpertLevel::Advanced)
146+
.bind_to(&Use_cockpit_fov)
147+
.importance(61)
148+
.parser(parse_cockpit_fov_toggle_func)
130149
.finish();
131150

132151
//*************************CLASS: camera*************************

0 commit comments

Comments
 (0)