Skip to content

Commit 405de8d

Browse files
authored
Allow setting custom gauges as message gauges (#7217)
1 parent 512021d commit 405de8d

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

code/hud/hud.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ canvas_w(-1), canvas_h(-1), target_w(-1), target_h(-1)
364364
}
365365

366366
// constructor for custom gauges
367-
HudGauge::HudGauge(int _gauge_config, bool _slew, int r, int g, int b, char* _custom_name, char* _custom_text, char* frame_fname, int txtoffset_x, int txtoffset_y):
367+
HudGauge::HudGauge(int _gauge_config, bool _slew, bool _message, int r, int g, int b, char* _custom_name, char* _custom_text, char* frame_fname, int txtoffset_x, int txtoffset_y):
368368
base_w(0), base_h(0), gauge_type(_gauge_config), gauge_object(HUD_OBJECT_CUSTOM), font_num(font::FONT1), lock_color(false), sexp_lock_color(false),
369-
reticle_follow(_slew), active(false), off_by_default(false), sexp_override(false), pop_up(false), message_gauge(false),
369+
reticle_follow(_slew), active(false), off_by_default(false), sexp_override(false), pop_up(false), message_gauge(_message),
370370
disabled_views(VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY), scripting_render_override(false), can_popup(false), use_iff_color(false), use_tag_color(false), only_render_in_chase_view(false),
371371
render_for_cockpit_toggle(0), custom_gauge(true), textoffset_x(txtoffset_x), textoffset_y(txtoffset_y), texture_target(-1), canvas_w(-1), canvas_h(-1), target_w(-1), target_h(-1)
372372
{

code/hud/hud.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class HudGauge
278278
HudGauge();
279279
HudGauge(int _gauge_object, int _gauge_config, bool _slew, bool _message, int _disabled_views, int r, int g, int b);
280280
// constructor for custom gauges
281-
HudGauge(int _gauge_config, bool _slew, int r, int g, int b, char* _custom_name, char* _custom_text, char* frame_fname, int txtoffset_x, int txtoffset_y);
281+
HudGauge(int _gauge_config, bool _slew, bool _message, int r, int g, int b, char* _custom_name, char* _custom_text, char* frame_fname, int txtoffset_x, int txtoffset_y);
282282
virtual ~HudGauge();
283283

284284
void initPosition(int x, int y);
@@ -393,8 +393,8 @@ class HudGauge3DAnchor : public HudGauge {
393393
HudGauge3DAnchor(int _gauge_object, int _gauge_config, bool /*_slew*/, bool _message, int _disabled_views, int r, int g, int b)
394394
: HudGauge(_gauge_object, _gauge_config, false, _message, _disabled_views, r, g, b) { }
395395
// constructor for custom gauges
396-
HudGauge3DAnchor(int _gauge_config, bool /*_slew*/, int r, int g, int b, char* _custom_name, char* _custom_text, char* frame_fname, int txtoffset_x, int txtoffset_y)
397-
: HudGauge(_gauge_config, false, r, g, b, _custom_name, _custom_text, frame_fname, txtoffset_x, txtoffset_y) { }
396+
HudGauge3DAnchor(int _gauge_config, bool /*_slew*/, bool _message, int r, int g, int b, char* _custom_name, char* _custom_text, char* frame_fname, int txtoffset_x, int txtoffset_y)
397+
: HudGauge(_gauge_config, false, _message, r, g, b, _custom_name, _custom_text, frame_fname, txtoffset_x, txtoffset_y) { }
398398

399399
void initSlew(bool /*slew*/) override {};
400400
};

code/hud/hudparse.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,10 @@ void load_gauge_custom(gauge_settings* settings)
17611761
stuff_boolean(&settings->slew);
17621762
}
17631763

1764+
if (optional_string("Message Gauge:")) {
1765+
stuff_boolean(&settings->message_gauge);
1766+
}
1767+
17641768
if (optional_string("Config:")) {
17651769
stuff_boolean(&visible_in_config);
17661770
}
@@ -1780,7 +1784,7 @@ void load_gauge_custom(gauge_settings* settings)
17801784
}
17811785
}
17821786

1783-
std::unique_ptr<HudGauge> hud_gauge(new HudGauge(gauge_type, settings->slew, r, g, b, name, text, filename, txtoffset_x, txtoffset_y));
1787+
std::unique_ptr<HudGauge> hud_gauge(new HudGauge(gauge_type, settings->slew, settings->message_gauge, r, g, b, name, text, filename, txtoffset_x, txtoffset_y));
17841788

17851789
hud_gauge->initBaseResolution(settings->base_res[0], settings->base_res[1], settings->aspect_quotient);
17861790
hud_gauge->initPosition(settings->coords[0], settings->coords[1]);

code/hud/hudparse.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ typedef struct gauge_settings {
4141
bool set_position;
4242
bool set_colour;
4343
bool slew;
44+
bool message_gauge;
4445
bool chase_view_only;
4546
int cockpit_view_choice;
4647

4748
gauge_settings()
4849
: font_num(Hud_font), scale_gauge(Scale_retail_gauges), ship_idx(nullptr), use_clr(nullptr), use_coords(false),
49-
set_position(true), set_colour(true), slew(false), chase_view_only(Chase_view_only_ex), cockpit_view_choice(0)
50+
set_position(true), set_colour(true), slew(false), message_gauge(false), chase_view_only(Chase_view_only_ex), cockpit_view_choice(0)
5051
{
5152
base_res[0] = -1;
5253
base_res[1] = -1;

0 commit comments

Comments
 (0)