Hud config upgrades (#6581)

* base working version

* localization and minor tweaks

* add retail UI controls

* Add way to hide gauges from Config view

* convert hud config from index matching to id matching

* clang
This commit is contained in:
Mike Nelson authored and GitHub committed 2025-03-22 22:47:38 -04:00
1 parent 9f38451fd4
commit 60777154be
27 files changed
+1507 -1207

No files matched your search

+166 -49
View File
@@ -198,6 +198,49 @@ void hud_maybe_display_subspace_notify();
int hud_maybe_render_emp_icon();
void hud_init_emp_icon();
static bool hud_config_use_iff_color(int gauge_index)
{
switch (gauge_index) {
case HUD_LEAD_INDICATOR:
case HUD_ORIENTATION_TEE:
case HUD_HOSTILE_TRIANGLE:
case HUD_TARGET_TRIANGLE:
case HUD_OFFSCREEN_INDICATOR:
case HUD_MISSILE_WARNING_ARROW:
return true;
default:
return false;
}
}
static bool hud_config_can_popup(int gauge_index)
{
switch (gauge_index) {
case HUD_ETS_GAUGE:
case HUD_AUTO_TARGET:
case HUD_AUTO_SPEED:
case HUD_WEAPONS_GAUGE:
case HUD_ESCORT_VIEW:
case HUD_TARGET_MINI_ICON:
case HUD_DAMAGE_GAUGE:
case HUD_CMEASURE_GAUGE:
case HUD_KILLS_GAUGE:
return true;
default:
return false;
}
}
static bool hud_config_use_tag_color(int gauge_index)
{
switch (gauge_index) {
case HUD_MISSILE_WARNING_ARROW:
return true;
default:
return false;
}
}
// Saturate a value in minv..maxv.
void saturate(int *i, int minv, int maxv)
{
@@ -247,7 +290,7 @@ static int Damage_flash_bright;
static int Damage_flash_timer;
HudGauge::HudGauge():
base_w(0), base_h(0), gauge_config(-1), font_num(font::FONT1), lock_color(false), sexp_lock_color(false), reticle_follow(false),
base_w(0), base_h(0), gauge_type(-1), font_num(font::FONT1), lock_color(false), sexp_lock_color(false), reticle_follow(false),
active(false), off_by_default(false), sexp_override(false), pop_up(false), disabled_views(0), only_render_in_chase_view(false), render_for_cockpit_toggle(0), custom_gauge(false),
texture_target(-1), canvas_w(-1), canvas_h(-1), target_w(-1), target_h(-1)
{
@@ -259,6 +302,13 @@ texture_target(-1), canvas_w(-1), canvas_h(-1), target_w(-1), target_h(-1)
flash_next = timestamp(1);
flash_status = false;
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
gauge_config_id = ""; //gauge_map.get_string_id_from_numeric_id(_gauge_config);
can_popup = hud_config_can_popup(gauge_map.get_numeric_id_from_string_id(gauge_config_id));
use_iff_color = hud_config_use_iff_color(gauge_map.get_numeric_id_from_string_id(gauge_config_id));
use_tag_color = hud_config_use_tag_color(gauge_map.get_numeric_id_from_string_id(gauge_config_id));
popup_timer = timestamp(1);
texture_target_fname[0] = '\0';
@@ -271,12 +321,12 @@ texture_target(-1), canvas_w(-1), canvas_h(-1), target_w(-1), target_h(-1)
}
HudGauge::HudGauge(int _gauge_object, int _gauge_config, bool _slew, bool _message, int _disabled_views, int r, int g, int b):
base_w(0), base_h(0), gauge_config(_gauge_config), gauge_object(_gauge_object), font_num(font::FONT1), lock_color(false), sexp_lock_color(false),
base_w(0), base_h(0), gauge_type(_gauge_config), gauge_object(_gauge_object), font_num(font::FONT1), lock_color(false), sexp_lock_color(false),
reticle_follow(_slew), active(false), off_by_default(false), sexp_override(false), pop_up(false), message_gauge(_message),
disabled_views(_disabled_views), only_render_in_chase_view(false), render_for_cockpit_toggle(0), custom_gauge(false), textoffset_x(0), textoffset_y(0), texture_target(-1),
canvas_w(-1), canvas_h(-1), target_w(-1), target_h(-1)
{
Assert(gauge_config <= NUM_HUD_GAUGES && gauge_config >= 0);
Assertion(_gauge_config <= NUM_HUD_GAUGES && _gauge_config >= 0, "Gauge has an invalid config ID!");
position[0] = 0;
position[1] = 0;
@@ -297,6 +347,14 @@ canvas_w(-1), canvas_h(-1), target_w(-1), target_h(-1)
texture_target_fname[0] = '\0';
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
gauge_config_id = gauge_map.get_string_id_from_numeric_id(_gauge_config);
config_name = gauge_map.get_hcf_name_from_string_id(gauge_config_id);
can_popup = hud_config_can_popup(gauge_map.get_numeric_id_from_string_id(gauge_config_id));
use_iff_color = hud_config_use_iff_color(gauge_map.get_numeric_id_from_string_id(gauge_config_id));
use_tag_color = hud_config_use_tag_color(gauge_map.get_numeric_id_from_string_id(gauge_config_id));
custom_name[0] = '\0';
custom_text = "";
default_text = "";
@@ -307,10 +365,10 @@ canvas_w(-1), canvas_h(-1), target_w(-1), target_h(-1)
// constructor for custom gauges
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):
base_w(0), base_h(0), gauge_config(_gauge_config), gauge_object(HUD_OBJECT_CUSTOM), font_num(font::FONT1), lock_color(false), sexp_lock_color(false),
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),
reticle_follow(_slew), active(false), off_by_default(false), sexp_override(false), pop_up(false), message_gauge(false),
disabled_views(VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY), only_render_in_chase_view(false), 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)
disabled_views(VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY), can_popup(false), use_iff_color(false), use_tag_color(false), only_render_in_chase_view(false),
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)
{
position[0] = 0;
position[1] = 0;
@@ -325,6 +383,13 @@ textoffset_y(txtoffset_y), texture_target(-1), canvas_w(-1), canvas_h(-1), targe
flash_next = timestamp(1);
flash_status = false;
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
gauge_config_id = ""; // gauge_map.get_string_id_from_numeric_id(_gauge_config);
can_popup = hud_config_can_popup(gauge_map.get_numeric_id_from_string_id(gauge_config_id));
use_iff_color = hud_config_use_iff_color(gauge_map.get_numeric_id_from_string_id(gauge_config_id));
use_tag_color = hud_config_use_tag_color(gauge_map.get_numeric_id_from_string_id(gauge_config_id));
popup_timer = timestamp(1);
texture_target_fname[0] = '\0';
@@ -335,6 +400,8 @@ textoffset_y(txtoffset_y), texture_target(-1), canvas_w(-1), canvas_h(-1), targe
custom_name[0] = '\0';
}
config_name = custom_name;
if(_custom_text) {
custom_text = _custom_text;
default_text = _custom_text;
@@ -390,6 +457,36 @@ void HudGauge::initFont(int input_font_num)
}
}
SCP_string HudGauge::getConfigName() const
{
return config_name;
}
SCP_string HudGauge::getConfigId() const
{
return gauge_config_id;
}
bool HudGauge::getConfigUseIffColor() const
{
return use_iff_color;
}
bool HudGauge::getConfigCanPopup() const
{
return can_popup;
}
bool HudGauge::getConfigUseTagColor() const
{
return use_tag_color;
}
bool HudGauge::getVisibleInConfig() const
{
return visible_in_config;
}
int HudGauge::getFont() const
{
return font_num;
@@ -485,34 +582,43 @@ void HudGauge::setGaugeColor(int bright_index, bool config)
int alpha;
if (config) {
color* use_color;
use_color = &HUD_config.clr[gauge_config];
color use_color;
if (custom_gauge) {
// Custom gauges currently use the color based on their gauge type
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
use_color = HUD_config.get_gauge_color(gauge_map.get_string_id_from_numeric_id(gauge_type));
} else {
use_color = HUD_config.get_gauge_color(gauge_config_id);
}
if (hud_config_show_flag_is_set(gauge_config)) {
// Eventually we should allow custom gauges to use IFF colors maybe? Then we can unhardcode this
// and rely on the gauge data itself. But for now only specific gauges use iff and that's hard coded here
if (HC_gauge_regions[gr_screen.res][gauge_config].use_iff) {
if (!custom_gauge && HUD_config.is_gauge_visible(gauge_config_id)) {
if (use_iff_color) {
// Ditto for target tagging color
if (HC_gauge_regions[gr_screen.res][gauge_config].color == 1) {
use_color = iff_get_color(IFF_COLOR_TAGGED, 0);
if (use_tag_color) {
use_color = *iff_get_color(IFF_COLOR_TAGGED, 0);
} else {
use_color = &Color_bright_red;
use_color = Color_bright_red;
}
}
if ((HC_gauge_selected == gauge_config) || HC_select_all) {
if ((HC_gauge_selected == gauge_config_id) || HC_select_all) {
alpha = 255;
} else if (HC_gauge_hot == gauge_config) {
} else if (HC_gauge_hot == gauge_config_id) {
alpha = 200;
} else {
alpha = 150;
}
gr_init_alphacolor(use_color, use_color->red, use_color->green, use_color->blue, alpha);
gr_set_color_fast(use_color);
gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
gr_set_color_fast(&use_color);
} else if (custom_gauge) {
// Custom gauges currently use the current color but alpha dimmed since they are not selectable
alpha = MAX(use_color.alpha - 50, 25);
gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
gr_set_color_fast(&use_color);
} else {
// if its off, make it dark gray
gr_init_alphacolor(use_color, 127, 127, 127, 64);
gr_set_color_fast(use_color);
gr_init_alphacolor(&use_color, 127, 127, 127, 64);
gr_set_color_fast(&use_color);
}
} else {
// if we're drawing it as bright
@@ -603,7 +709,7 @@ float HudGauge::getAspectQuotient() const
int HudGauge::getConfigType() const
{
return gauge_config;
return gauge_type;
}
int HudGauge::getObjectType() const
@@ -654,6 +760,11 @@ void HudGauge::initCockpit_view_choice(int cockpit_view_choice)
render_for_cockpit_toggle = cockpit_view_choice;
}
void HudGauge::initVisible_in_config(bool visible)
{
visible_in_config = visible;
}
bool HudGauge::isOffbyDefault() const
{
return off_by_default;
@@ -763,7 +874,7 @@ void HudGauge::render(float /*frametime*/, bool config)
// The following code will be used to allow custom coloring of custom HUD gauges. This will be implemented in the future.
/*int bmw, bmh;
bm_get_info(custom_frame.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));*/
hud_config_set_mouse_coords(gauge_config_id, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));*/
}
setGaugeColor(HUD_C_NONE, config);
@@ -1295,7 +1406,7 @@ bool HudGauge::canRender() const
}
}
if (gauge_config == HUD_ETS_GAUGE) {
if (gauge_type == HUD_ETS_GAUGE) {
if (Ships[Player_obj->instance].flags[Ship::Ship_Flags::No_ets]) {
return false;
}
@@ -1893,7 +2004,7 @@ void HudGaugeMissionTime::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(time_gauge.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
setGaugeColor(HUD_C_NONE, config);
@@ -2494,7 +2605,7 @@ void HudGaugeDamage::render(float /*frametime*/, bool config)
int bmw, bmh;
bm_get_info(damage_top.first_frame, &bmw, nullptr);
bm_get_info(damage_bottom.first_frame, nullptr, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, last_by + fl2i((bottom_bg_offset + bmh) * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, last_by + fl2i((bottom_bg_offset + bmh) * scale));
}
}
@@ -2704,7 +2815,7 @@ void HudGaugeTextWarnings::render(float /*frametime*/, bool config)
gr_get_string_size(&w, &h, config ? XSTR("Collision", 1431) : Hud_text_flash, scale);
if (config) {
hud_config_set_mouse_coords(gauge_config, fl2i(i2fl(x) - (i2fl(w) / 2.0f) - 1.0f), x + fl2i(i2fl(w) / 2.0f) + 2, y - 1, y + h + 1);
hud_config_set_mouse_coords(gauge_config_id, fl2i(i2fl(x) - (i2fl(w) / 2.0f) - 1.0f), x + fl2i(i2fl(w) / 2.0f) + 2, y - 1, y + h + 1);
}
// set color
@@ -2767,7 +2878,7 @@ void HudGaugeKills::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Kills_gauge.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
setGaugeColor(HUD_C_NONE, config);
@@ -2855,7 +2966,7 @@ void HudGaugeLag::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Netlag_icon.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
int lag_status = config ? 0 : multi_query_lag_status();
@@ -3170,7 +3281,7 @@ void HudGaugeSupport::render(float /*frametime*/, bool config)
if (config) {
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(w * scale), y, y + fl2i(h * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(w * scale), y, y + fl2i(h * scale));
}
// Set hud color
@@ -3421,7 +3532,9 @@ int hud_gauge_active(int gauge_index)
return 0;
}
return hud_config_show_flag_is_set(gauge_index);
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
return HUD_config.is_gauge_visible(gauge_map.get_string_id_from_numeric_id(gauge_index));
}
/**
@@ -3430,7 +3543,9 @@ int hud_gauge_active(int gauge_index)
int hud_gauge_is_popup(int gauge_index)
{
Assert(gauge_index >=0 && gauge_index < NUM_HUD_GAUGES);
return hud_config_popup_flag_is_set(gauge_index);
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
SCP_string gauge = gauge_map.get_string_id_from_numeric_id(gauge_index);
return HUD_config.is_gauge_popup(gauge);
}
/**
@@ -3498,8 +3613,10 @@ void hud_gauge_start_flash(int gauge_index)
*/
void hud_set_gauge_color(int gauge_index, int bright_index)
{
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
int flash_status = hud_gauge_maybe_flash(gauge_index);
color *use_color = &HUD_config.clr[gauge_index];
color use_color = HUD_config.get_gauge_color(gauge_map.get_string_id_from_numeric_id(gauge_index));
int alpha;
// If we're drawing it as bright
@@ -3507,17 +3624,17 @@ void hud_set_gauge_color(int gauge_index, int bright_index)
switch(bright_index){
case HUD_C_DIM:
alpha = HUD_high_contrast ? HUD_NEW_ALPHA_DIM_HI : HUD_NEW_ALPHA_DIM;
gr_init_alphacolor(use_color, use_color->red, use_color->green, use_color->blue, alpha);
gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
break;
case HUD_C_NORMAL:
alpha = HUD_high_contrast ? HUD_NEW_ALPHA_NORMAL_HI : HUD_NEW_ALPHA_NORMAL;
gr_init_alphacolor(use_color, use_color->red, use_color->green, use_color->blue, alpha);
gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
break;
case HUD_C_BRIGHT:
alpha = HUD_high_contrast ? HUD_NEW_ALPHA_BRIGHT_HI : HUD_NEW_ALPHA_BRIGHT;
gr_init_alphacolor(use_color, use_color->red, use_color->green, use_color->blue, alpha);
gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
break;
// Intensity
@@ -3540,27 +3657,27 @@ void hud_set_gauge_color(int gauge_index, int bright_index)
if(alpha < 0){
alpha = 0;
}
gr_init_alphacolor(use_color, use_color->red, use_color->green, use_color->blue, alpha);
gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
break;
}
} else {
switch(flash_status) {
case 0:
alpha = HUD_high_contrast ? HUD_NEW_ALPHA_DIM_HI : HUD_NEW_ALPHA_DIM;
gr_init_alphacolor(use_color, use_color->red, use_color->green, use_color->blue, alpha);
gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
break;
case 1:
alpha = HUD_high_contrast ? HUD_NEW_ALPHA_BRIGHT_HI : HUD_NEW_ALPHA_BRIGHT;
gr_init_alphacolor(use_color, use_color->red, use_color->green, use_color->blue, alpha);
gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
break;
default:
alpha = HUD_high_contrast ? HUD_NEW_ALPHA_NORMAL_HI : HUD_NEW_ALPHA_NORMAL;
gr_init_alphacolor(use_color, use_color->red, use_color->green, use_color->blue, alpha);
gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
break;
}
}
gr_set_color_fast(use_color);
gr_set_color_fast(&use_color);
}
/**
@@ -3761,7 +3878,7 @@ void HudGaugeObjectiveNotify::renderSubspace(bool config)
/*std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Objective_display_gauge.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));*/
hud_config_set_mouse_coords(gauge_config_id, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));*/
}
bool warp_aborted = false;
@@ -3818,7 +3935,7 @@ void HudGaugeObjectiveNotify::renderRedAlert(bool config)
/*std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Objective_display_gauge.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));*/
hud_config_set_mouse_coords(gauge_config_id, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));*/
}
if (!config && !red_alert_in_progress() ) {
@@ -3870,10 +3987,10 @@ void HudGaugeObjectiveNotify::renderObjective(bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Objective_display_gauge.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
if ( timestamp_elapsed(Objective_display.display_timer) ) {
if (!config && timestamp_elapsed(Objective_display.display_timer) ) {
return;
}
@@ -4264,7 +4381,7 @@ void HudGaugeMultiMsg::render(float /*frametime*/, bool config)
/*strcpy(txt, "This is a multiplayer message");
int w, h;
gr_get_string_size(&w, &h, txt, scale);
hud_config_set_mouse_coords(gauge_config, x, x + w, y, y + h);
hud_config_set_mouse_coords(gauge_config_id, x, x + w, y, y + h);
setGaugeColor(HUD_C_NONE, config);*/
return;
@@ -4292,7 +4409,7 @@ void HudGaugeVoiceStatus::render(float /*frametime*/, bool config)
int w, h;
gr_get_string_size(&w, &h, XSTR("[playing voice]", 245), scale);
hud_config_set_mouse_coords(gauge_config, x, x + w, y, y + h);
hud_config_set_mouse_coords(gauge_config_id, x, x + w, y, y + h);
setGaugeColor(HUD_C_NONE, config);
@@ -4352,7 +4469,7 @@ void HudGaugePing::render(float /*frametime*/, bool config)
int w, h;
gr_get_string_size(&w, &h, XSTR("> 1 sec",628), scale);
hud_config_set_mouse_coords(gauge_config, x, x + w, y, y + h);
hud_config_set_mouse_coords(gauge_config_id, x, x + w, y, y + h);
setGaugeColor(HUD_C_NONE, config);
@@ -4411,7 +4528,7 @@ void HudGaugeSupernova::render(float /*frametime*/, bool config)
int w, h;
gr_get_string_size(&w, &h, txt.c_str(), 245), scale);
hud_config_set_mouse_coords(gauge_config, x, x + w, y, y + h);*/
hud_config_set_mouse_coords(gauge_config_id, x, x + w, y, y + h);*/
}
if (!config && !supernova_active()) {
+18 -1
View File
@@ -217,8 +217,9 @@ protected:
int position[2];
int base_w, base_h;
color gauge_color;
int gauge_config;
int gauge_type; // Used to be the gauge_config numeric ID but now more accurately is used as the type. Will be one of the HUD_ defines from hudgauges.h
int gauge_object;
SCP_string gauge_config_id;
int font_num;
@@ -241,6 +242,13 @@ protected:
bool message_gauge;
int disabled_views;
// Config stuff
SCP_string config_name;
bool can_popup;
bool use_iff_color;
bool use_tag_color;
bool visible_in_config;
int flash_duration;
int flash_next;
bool flash_status;
@@ -295,6 +303,14 @@ public:
bool isOffbyDefault() const;
bool isActive() const;
// Config getters
SCP_string getConfigName() const;
SCP_string getConfigId() const;
bool getConfigUseIffColor() const;
bool getConfigCanPopup() const;
bool getConfigUseTagColor() const;
bool getVisibleInConfig() const;
int getFont() const;
void getOriginAndOffset(float *originX, float *originY, int *offsetX, int *offsetY) const;
void getCoords(bool* use_coords, int* coordsX, int* coordsY) const;
@@ -308,6 +324,7 @@ public:
void updateSexpOverride(bool sexp);
void initChase_view_only(bool chase_view_only);
void initCockpit_view_choice(int cockpit_view_choice);
void initVisible_in_config(bool visible);
// SEXP interfacing functions
// For flashing gauges in training missions
+747 -892
View File
File diff suppressed because it is too large. Load diff
+202 -75
View File
@@ -34,24 +34,13 @@ struct ai_info;
extern float Radar_ranges[RR_MAX_RANGES];
extern const char *Radar_range_text(int range_num);
#define RP_SHOW_DEBRIS (1<<0)
#define RP_SHOW_FRIENDLY_MISSILES (1<<1)
#define RP_SHOW_HOSTILE_MISSILES (1<<2)
#define RP_DEFAULT ( RP_SHOW_DEBRIS | RP_SHOW_FRIENDLY_MISSILES | RP_SHOW_HOSTILE_MISSILES )
/*!
* @brief Vector for storing the filenames of hud preset files
* @note main definition in hudconfig.cpp
*/
extern SCP_vector<SCP_string> HC_preset_filenames;
extern int HUD_observer_default_flags;
extern int HUD_observer_default_flags2;
extern int HUD_default_popup_mask;
extern int HUD_default_popup_mask2;
extern int HUD_config_default_flags;
extern int HUD_config_default_flags2;
extern SCP_vector<SCP_string> observer_visible_gauges;
extern const int HC_gauge_config_coords[GR_NUM_RESOLUTIONS][4];
extern int HC_resize_mode;
@@ -60,39 +49,75 @@ extern int HC_resize_mode;
* @brief Contains core HUD configuration data
* @note Is not default init'd. Assumes new player, PLR, or CSG reads will correctly set data.
*/
typedef struct HUD_CONFIG_TYPE {
int show_flags; //!< bitfield, whether to show gauge (0 ~ 31)
int show_flags2; //!< bitfield, whether to show gauge (32 ~ 63)
int popup_flags; //!< bitfield, whether gauge is popup (0 ~ 31)
int popup_flags2; //!< bitfield, whether gauge is popup (32 ~ 63)
int rp_flags; //!< one of RP_ #defines in hudconfig.h; Chiefly shows/hides non-ship objects
typedef struct HUD_CONFIG_TYPE {
int rp_dist; //!< one of RR_ #defines above; Is the maxium radar view distance setting
int is_observer; //!< 1 or 0, observer mode or not, respectively
int main_color; //!< the default HUD_COLOR selection for all gauges; each gauge may override this with a custom RGB
ubyte num_msg_window_lines; //!< Number of message lines. (Deprecated by HudGaugeMessages::Max_lines)
color clr[NUM_HUD_GAUGES]; //!< colors for all the gauges
// Maps for HUD gauge configuration
std::unordered_map<std::string, color> gauge_colors; //!< Gauge-specific colors
std::unordered_map<std::string, bool> show_flags_map; //!< Show/hide state for gauges
std::unordered_map<std::string, bool> popup_flags_map; //!< Popup state for gauges
static color default_white_color()
{
color white;
gr_init_alphacolor(&white, 255, 255, 255, 255);
return white;
}
// Methods for setting and getting gauge properties where getting will return a default value
void set_gauge_color(const std::string& gauge_id, const color& col)
{
gauge_colors[gauge_id] = col;
}
// Get the gauge color or white if the gauge is not found
color get_gauge_color(const std::string& gauge_id) const
{
auto it = gauge_colors.find(gauge_id);
return (it != gauge_colors.end()) ? it->second : default_white_color();
}
void set_gauge_visibility(const std::string& gauge_id, bool visible)
{
show_flags_map[gauge_id] = visible;
}
// Get the gauge config visibility setting or false (invisible) if not found
bool is_gauge_visible(const std::string& gauge_id) const
{
auto it = show_flags_map.find(gauge_id);
return (it != show_flags_map.end()) ? it->second : false; // Default to invisible
}
void set_gauge_popup(const std::string& gauge_id, bool popup)
{
popup_flags_map[gauge_id] = popup;
}
// Get the gauge config popup setting or false if not found
bool is_gauge_popup(const std::string& gauge_id) const
{
auto it = popup_flags_map.find(gauge_id);
return (it != popup_flags_map.end()) ? it->second : false; // Default to not a popup
}
} HUD_CONFIG_TYPE;
extern HUD_CONFIG_TYPE HUD_config;
/**
* @struct HC_gauge_region
* @struct HC_gauge_setting
* @brief Contains core HUD configuration data
*/
struct HC_gauge_region
struct HC_gauge_setting
{
const char *filename; // filename for the gauge
int x,y; // x, y coords
int hotspot; // ??
int use_iff; // if the gauge uses target IFF color for its color
int can_popup; // if the gauge can use the popup method
int bitmap; // bitmap handle
int nframes; // ??
int color; // If the gauge color respects target tagging?
UI_BUTTON button; // button handle for retail UI hud config
bool use_iff_color; // if the gauge uses target IFF color for its color
bool can_popup; // if the gauge can use the popup method
bool use_tag_color; // If the gauge color respects target tagging?
HC_gauge_region(const char *name, int x1, int y1, int h, int iff, int cp, int b, int nf, int cl) : filename(name), x(x1), y(y1), hotspot(h), use_iff(iff), can_popup(cp), bitmap(b), nframes(nf), color(cl){}
HC_gauge_setting(bool iff, bool cp, bool cl) : use_iff_color(iff), can_popup(cp), use_tag_color(cl){}
};
class BoundingBox {
@@ -105,6 +130,12 @@ class BoundingBox {
// Constructor
constexpr BoundingBox(int nx1, int nx2, int ny1, int ny2) : x1(nx1), x2(nx2), y1(ny1), y2(ny2) {}
// Equality operator
bool operator==(const BoundingBox& other) const
{
return x1 == other.x1 && x2 == other.x2 && y1 == other.y1 && y2 == other.y2;
}
bool isOverlapping(const BoundingBox& other) const
{
return (x2 >= other.x1 && // Not completely to the left
@@ -120,40 +151,139 @@ class BoundingBox {
}
// Static function to check if any bounding box in an array overlaps with a new one
static bool isOverlappingAny(const BoundingBox mouse_coords[NUM_HUD_GAUGES], const BoundingBox& newBox, int self_index)
static bool isOverlappingAny(const SCP_vector<std::pair<SCP_string, BoundingBox>>& mouse_coords, const BoundingBox& newBox, SCP_string self_id)
{
for (int i = 0; i < NUM_HUD_GAUGES; i++) {
if (i == self_index) {
continue;
return std::any_of(mouse_coords.begin(), mouse_coords.end(), [&](const std::pair<SCP_string, BoundingBox>& item) {
const auto& [gauge_id, bbox] = item;
if (gauge_id == self_id) {
return false; // Skip checking against itself
}
if (mouse_coords[i].isValid() && mouse_coords[i].isOverlapping(newBox)) {
return true;
}
}
return false;
return bbox.isValid() && bbox.isOverlapping(newBox);
});
}
};
extern char HC_wingam_gauge_status_names[MAX_SQUADRON_WINGS][32];
/*!
* @brief Array of hud gauges to be displayed in the hud config ui and configured by the player
* @note main definition in hudconfig.cpp
*/
extern struct HC_gauge_region HC_gauge_regions[GR_NUM_RESOLUTIONS][NUM_HUD_GAUGES];
extern int HC_gauge_hot;
extern int HC_gauge_selected;
extern int HC_select_all;
extern float HC_gauge_scale;
extern SCP_vector<std::pair<SCP_string, HudGauge*>> HC_gauge_map;
extern SCP_string HC_gauge_hot;
extern SCP_string HC_gauge_selected;
extern SCP_vector<std::pair<size_t, SCP_string>> HC_available_huds;
extern int HC_chosen_hud;
extern bool HC_select_all;
extern int HC_gauge_coordinates[6]; // x1, x2, y1, y2, w, h for gauge rendering
extern BoundingBox HC_gauge_mouse_coords[NUM_HUD_GAUGES];
const char* HC_gauge_descriptions(int n);
extern SCP_vector<std::pair<SCP_string, BoundingBox>> HC_gauge_mouse_coords;
extern int HC_talking_head_frame;
extern SCP_string HC_head_anim_filename;
extern SCP_string HC_shield_gauge_ship;
extern bool HC_show_default_hud;
extern std::unordered_set<SCP_string> HC_ignored_huds;
class HC_gauge_mappings {
public:
static HC_gauge_mappings& get_instance() {
static HC_gauge_mappings instance;
return instance;
}
// Prevent copying
HC_gauge_mappings(const HC_gauge_mappings&) = delete;
HC_gauge_mappings& operator=(const HC_gauge_mappings&) = delete;
// Numeric ID -> New String ID
SCP_string get_string_id_from_numeric_id(int numeric_id) const {
auto it = gauge_map.find(numeric_id);
return (it != gauge_map.end()) ? it->second.second : "";
}
// HCF String Name -> New String ID
SCP_string get_string_id_from_hcf_id(const SCP_string& hcf_name) const
{
for (const auto& [id, mapping] : gauge_map) {
if (XSTR(mapping.first.first.c_str(), mapping.first.second) == hcf_name) {
return mapping.second;
}
}
return "";
}
// New String ID -> Numeric ID (for saving to player file)
int get_numeric_id_from_string_id(const SCP_string& string_id) const {
for (const auto& [id, mapping] : gauge_map) {
if (mapping.second == string_id) {
return id;
}
}
return -1;
}
// New String ID -> HCF String Name (for saving HCF files)
SCP_string get_hcf_name_from_string_id(const SCP_string& string_id) const
{
for (const auto& [id, mapping] : gauge_map) {
if (mapping.second == string_id) {
return XSTR(mapping.first.first.c_str(), mapping.first.second);
}
}
return "";
}
private:
HC_gauge_mappings() {
// Map the old gauge_config numeric IDs, the HCF file IDs (which, yes, were translated...), and the newer string IDs
// for the retail built-in gauges. Custom gauges will only have a string ID and do not need to be mapped.
gauge_map = {
{0, {{"lead indicator", 249}, "Builtin::LeadIndicator"}},
{1, {{"target orientation", 250}, "Builtin::TargetOrientation"}},
{2, {{"closest attacking hostile", 251}, "Builtin::ClosestAttackingHostile"}},
{3, {{"current target direction", 252}, "Builtin::CurrentTargetDirection"}},
{4, {{"mission time", 253}, "Builtin::MissionTime"}},
{5, {{"reticle", 254}, "Builtin::Reticle"}},
{6, {{"throttle", 255}, "Builtin::Throttle"}},
{7, {{"radar", 256}, "Builtin::Radar"}},
{8, {{"target monitor", 257}, "Builtin::TargetMonitor"}},
{9, {{"center of reticle", 258}, "Builtin::CenterOfReticle"}},
{10, {{"extra target info", 259}, "Builtin::ExtraTargetInfo"}},
{11, {{"target shield", 260}, "Builtin::TargetShield"}},
{12, {{"player shield", 261}, "Builtin::PlayerShield"}},
{13, {{"power management", 262}, "Builtin::PowerManagement"}},
{14, {{"auto-target icon", 263}, "Builtin::AutoTargetIcon"}},
{15, {{"auto-speed-match icon", 264}, "Builtin::AutoSpeedMatchIcon"}},
{16, {{"weapons display", 265}, "Builtin::WeaponsDisplay"}},
{17, {{"monitoring view", 266}, "Builtin::MonitoringView"}},
{18, {{"directives view", 267}, "Builtin::DirectivesView"}},
{19, {{"threat gauge", 268}, "Builtin::ThreatGauge"}},
{20, {{"afterburner energy", 269}, "Builtin::AfterburnerEnergy"}},
{21, {{"weapons energy", 270}, "Builtin::WeaponsEnergy"}},
{22, {{"weapon linking", 271}, "Builtin::WeaponLinking"}},
{23, {{"target hull/shield icon", 272}, "Builtin::TargetHullShieldIcon"}},
{24, {{"offscreen indicator", 273}, "Builtin::OffscreenIndicator"}},
{25, {{"comm video", 274}, "Builtin::CommVideo"}},
{26, {{"damage display", 275}, "Builtin::DamageDisplay"}},
{27, {{"message output", 276}, "Builtin::MessageOutput"}},
{28, {{"locked missile direction", 277}, "Builtin::LockedMissileDirection"}},
{29, {{"countermeasures", 278}, "Builtin::Countermeasures"}},
{30, {{"objective notify", 279}, "Builtin::ObjectiveNotify"}},
{31, {{"wingmen status", 280}, "Builtin::WingmenStatus"}},
{32, {{"offscreen range", 281}, "Builtin::OffscreenRange"}},
{33, {{"kills gauge", 282}, "Builtin::KillsGauge"}},
{34, {{"attacking target count", 283}, "Builtin::AttackingTargetCount"}},
{35, {{"warning flash", 1459}, "Builtin::WarningFlash"}},
{36, {{"comm menu", 1460}, "Builtin::CommMenu"}},
{37, {{"support gauge", 1461}, "Builtin::SupportGauge"}},
{38, {{"lag gauge", 1462}, "Builtin::LagGauge"}}
};
}
SCP_unordered_map<int, std::pair<std::pair<SCP_string, int>, SCP_string>> gauge_map;
};
/*!
* @brief get the gauge pointer for the given gauge index
*/
HudGauge* hud_config_get_gauge_pointer(const SCP_string& gauge_id);
/*!
* @brief init hud config screen, setting up the hud preview display
@@ -162,8 +292,9 @@ extern SCP_string HC_shield_gauge_ship;
* param[in] x the x coord to render the preview display
* param[in] y the y coord to render the preview display
* param[in] w the width to render the preview display
* param[in] h the height to render the preview display
*/
void hud_config_init(bool API_Access = false, int x = 0, int y = 0, int w = -1);
void hud_config_init(bool API_Access = false, int x = 0, int y = 0, int w = -1, int h = -1);
/*!
* @brief do a hud config frame, including rendering the preview display and checking for button presses
@@ -185,10 +316,20 @@ void hud_config_close(bool API_Access = false);
/*!
* @brief toggles selecting of all gauges for color modification
*
* param[in] toggle 1 to toggle on, 0 for off
* param[bool] toggle true to toggle on, false for off
* param[in] API_Access whether or not this method has been called from the lua api
*/
void hud_config_select_all_toggle(int toggle, bool API_Access = false);
void hud_config_select_all_toggle(bool toggle, bool API_Access = false);
/*!
* @brief sets no gauges as selected
*/
void hud_config_select_none();
/*!
* @brief sets no gauges as selected
*/
void hud_config_select_hud(bool next);
/*!
* @brief init the list of preset files found by cfile
@@ -214,7 +355,7 @@ void hud_config_delete_preset(SCP_string filename);
* param[in] on_flag if the gauge is on or off, 1 for on, 0 for off
* param[in] popup_flag if the gauge is set to popup, 1 for popup, 0 otherwise
*/
void hud_config_set_gauge_flags(int gauge_index, int on_flag, int popup_flag);
void hud_config_set_gauge_flags(const SCP_string& gauge, bool on_flag, bool popup_flag);
void hud_config_restore();
void hud_config_backup();
@@ -232,14 +373,6 @@ void hud_config_cancel(bool change_state = true);
*/
void hud_config_commit();
// flag access/manipulation routines
int hud_config_show_flag_is_set(int i);
void hud_config_show_flag_set(int i);
void hud_config_show_flag_clear(int i);
int hud_config_popup_flag_is_set(int i);
void hud_config_popup_flag_set(int i);
void hud_config_popup_flag_clear(int i);
void hud_config_record_color(int color);
void hud_config_set_color(int color);
@@ -251,7 +384,7 @@ void hud_config_color_load(const char *name);
/*!
* @brief save the current hud gauges settings to a preset file
*/
void hud_config_color_save(const char* name);
void hud_config_color_save(const char* name, int version = 2);
/*!
* @brief same as hud_config_covert_coords but only returns the scale and doesn't convert any coords
@@ -283,7 +416,7 @@ std::tuple<float, float, float> hud_config_convert_coord_sys(float x, float y, i
/*!
* @brief save gauge coords during rendering time so hud config can check if the mouse is hovering over the gauge
*/
void hud_config_set_mouse_coords(int gauge_config, int x1, int x2, int y1, int y2);
void hud_config_set_mouse_coords(const SCP_string& gauge_id, int x1, int x2, int y1, int y2);
/*!
* @brief Function to calculate screen coordinates based on angle. Used for radial positioning gauges
@@ -293,13 +426,7 @@ std::pair<float, float> hud_config_calc_coords_from_angle(float angle_degrees, i
/*!
* @brief try to find an angle with no overlapping mouse coordinates for target-related gauges
*/
float hud_config_find_valid_angle(int gauge_index, float initial_angle, int centerX, int centerY, float radius);
/*!
* @brief save gauge coords during rendering time so hud config can check if the mouse is hovering over the gauge
* @brief this one is specific to the ETS gauge's individual rendering method
*/
void hud_config_set_mouse_coords_ets(int gauge_config, int x1, int x2, int y1, int y2);
float hud_config_find_valid_angle(const SCP_string& gauge, float initial_angle, int centerX, int centerY, float radius);
#endif
+1 -1
View File
@@ -286,7 +286,7 @@ void HudGaugeEscort::render(float /*frametime*/, bool config)
if (config) {
int bmw, bmh;
bm_get_info(Escort_gauges[2].first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, lx + fl2i(bmw * scale), y, ly + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, lx + fl2i(bmw * scale), y, ly + fl2i(bmh * scale));
}
}
+5 -5
View File
@@ -1100,9 +1100,9 @@ void HudGaugeEtsRetail::render(float /*frametime*/, bool config)
bm_get_info(Ets_bar.first_frame, &bmw, &bmh);
auto coords1 = hud_config_convert_coords(Gauge_positions[0], position[1], scale);
auto coords2 = hud_config_convert_coords(Gauge_positions[initial_position - 1] + bmw, position[1] + (bmh * 2) + 10, scale);
auto coords2 = hud_config_convert_coords(Gauge_positions[initial_position - 1] + bmw, position[1] + (bmh * 2), scale);
hud_config_set_mouse_coords(gauge_config, coords1.first, coords2.first, coords1.second, coords2.second);
hud_config_set_mouse_coords(gauge_config_id, coords1.first, coords2.first, coords1.second, coords2.second);
}
}
@@ -1193,7 +1193,7 @@ void HudGaugeEtsWeapons::render(float /*frametime*/, bool config)
int bmw, bmh;
bm_get_info(Ets_bar.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords_ets(gauge_config, rx, rx + bmw, ry, ry + (bmh * 2) + 10);
hud_config_set_mouse_coords(gauge_config_id, rx, rx + bmw, ry, ry + (bmh * 2));
}
}
@@ -1263,7 +1263,7 @@ void HudGaugeEtsShields::render(float /*frametime*/, bool config)
int bmw, bmh;
bm_get_info(Ets_bar.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords_ets(gauge_config, rx, rx + bmw, ry, ry + (bmh * 2) + 10);
hud_config_set_mouse_coords(gauge_config_id, rx, rx + bmw, ry, ry + (bmh * 2));
}
}
@@ -1333,6 +1333,6 @@ void HudGaugeEtsEngines::render(float /*frametime*/, bool config)
int bmw, bmh;
bm_get_info(Ets_bar.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords_ets(gauge_config, rx, rx + bmw, ry, ry + (bmh * 2) + 10);
hud_config_set_mouse_coords(gauge_config_id, rx, rx + bmw, ry, ry + (bmh * 2));
}
}
+1 -1
View File
@@ -293,7 +293,7 @@ void HudGaugeLock::render(float frametime, bool config)
int w;
int h;
// Will need actual coords for the below if we activate this gauge in config
hud_config_set_mouse_coords(gauge_config, x, x + w, y, y + h);
hud_config_set_mouse_coords(gauge_config_id, x, x + w, y, y + h);
setGaugeColor(HUD_C_NONE, config);*/
+3 -3
View File
@@ -450,7 +450,7 @@ void HudGaugeMessages::render(float /*frametime*/, bool config)
int bmw, bmh;
SCP_string msg = XSTR("Terran Fighter: HUD Message Display", 1874);
gr_get_string_size(&bmw, &bmh, msg.c_str(), scale);
hud_config_set_mouse_coords(gauge_config, x, x + bmw, y, y + bmh);
hud_config_set_mouse_coords(gauge_config_id, x, x + bmw, y, y + bmh);
setGaugeColor(HUD_C_NONE, config);
renderPrintf(x, y, scale, config, "%s", msg.c_str());
@@ -1206,7 +1206,7 @@ void HudGaugeTalkingHead::render(float frametime, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Head_frame.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
// Talking head is complex enough that we can do all the config rendering right here and exit early
setGaugeColor(HUD_C_NONE, config);
@@ -1398,7 +1398,7 @@ void HudGaugeFixedMessages::render(float /*frametime*/, bool config) {
// That may change in the future, in which case the code below can be restored.
if (config) {
/*std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
hud_config_set_mouse_coords(gauge_config, x - fl2i(w * scale), x + fl2i(w * scale), y, y + fl2i(h * scale));*/
hud_config_set_mouse_coords(gauge_config_id, x - fl2i(w * scale), x + fl2i(w * scale), y, y + fl2i(h * scale));*/
return;
}
+5 -4
View File
@@ -44,11 +44,12 @@ void hud_observer_init(ship *shipp, ai_info *aip)
Hud_obs_ship.weapons = shipp->weapons;
HUD_config.is_observer = 1;
HUD_config.show_flags = HUD_observer_default_flags;
HUD_config.show_flags2 = HUD_observer_default_flags2;
HUD_config.show_flags_map.clear();
HUD_config.popup_flags_map.clear();
HUD_config.popup_flags = 0x0;
HUD_config.popup_flags2 = 0x0;
for (const auto& gauge_id : observer_visible_gauges) {
HUD_config.show_flags_map[gauge_id] = true;
}
// shutdown any playing static animations
hud_init_target_static();
+68 -34
View File
@@ -238,6 +238,9 @@ void parse_hud_gauges_tbl(const char *filename)
reset_parse();
if (optional_string("#HUD Config Settings")) {
if (optional_string("$Show Default HUD:")) {
stuff_boolean(&HC_show_default_hud);
}
if (optional_string("$Head Animation:")) {
stuff_string(HC_head_anim_filename, F_NAME);
}
@@ -459,6 +462,15 @@ void parse_hud_gauges_tbl(const char *filename)
case 2:
stuff_string(name, F_NAME);
if (optional_string("$Show in HUD Config:")) {
bool show = true;
stuff_boolean(&show);
if (!show) {
HC_ignored_huds.insert(name);
}
}
if (optional_string("$Load Retail Configuration:")) {
stuff_boolean(&retail_config);
}
@@ -648,8 +660,6 @@ void hud_positions_init()
// load missing retail gauges for the default and ship-specific HUDs
load_missing_retail_gauges();
Hud_parsed_ships.clear();
}
void load_missing_retail_gauges()
@@ -776,38 +786,44 @@ void init_hud() {
for(i = 0; i < num_gauges; i++) {
config_type = Ship_info[Player_ship->ship_info_index].hud_gauges[i]->getConfigType();
SCP_string config_id = Ship_info[Player_ship->ship_info_index].hud_gauges[i]->getConfigId();
if ( !Ship_info[Player_ship->ship_info_index].hud_gauges[i]->isOffbyDefault() && hud_config_show_flag_is_set(config_type) )
if ( !Ship_info[Player_ship->ship_info_index].hud_gauges[i]->isOffbyDefault() && HUD_config.is_gauge_visible(config_id) )
Ship_info[Player_ship->ship_info_index].hud_gauges[i]->updateActive(true);
else
Ship_info[Player_ship->ship_info_index].hud_gauges[i]->updateActive(false);
Ship_info[Player_ship->ship_info_index].hud_gauges[i]->updatePopUp(hud_config_popup_flag_is_set(config_type) ? true : false);
Ship_info[Player_ship->ship_info_index].hud_gauges[i]->updateColor(
HUD_config.clr[config_type].red,
HUD_config.clr[config_type].green,
HUD_config.clr[config_type].blue,
HUD_config.clr[config_type].alpha
);
Ship_info[Player_ship->ship_info_index].hud_gauges[i]->updatePopUp(HUD_config.is_gauge_popup(config_id));
color clr;
if (config_id.empty()) {
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
clr = HUD_config.gauge_colors[gauge_map.get_string_id_from_numeric_id(config_type)];
} else {
clr = HUD_config.get_gauge_color(config_id);
}
Ship_info[Player_ship->ship_info_index].hud_gauges[i]->updateColor(clr.red, clr.green, clr.blue, clr.alpha);
}
} else {
num_gauges = default_hud_gauges.size();
for(i = 0; i < num_gauges; i++) {
config_type = default_hud_gauges[i]->getConfigType();
SCP_string config_id = default_hud_gauges[i]->getConfigId();
if ( !default_hud_gauges[i]->isOffbyDefault() && hud_config_show_flag_is_set(config_type) )
if ( !default_hud_gauges[i]->isOffbyDefault() && HUD_config.is_gauge_visible(config_id) )
default_hud_gauges[i]->updateActive(true);
else
default_hud_gauges[i]->updateActive(false);
default_hud_gauges[i]->updatePopUp(hud_config_popup_flag_is_set(config_type) ? true : false);
default_hud_gauges[i]->updateColor(
HUD_config.clr[config_type].red,
HUD_config.clr[config_type].green,
HUD_config.clr[config_type].blue,
HUD_config.clr[config_type].alpha
);
default_hud_gauges[i]->updatePopUp(HUD_config.is_gauge_popup(config_id));
color clr;
if (config_id.empty()) {
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
clr = HUD_config.gauge_colors[gauge_map.get_string_id_from_numeric_id(config_type)];
} else {
clr = HUD_config.get_gauge_color(config_id);
}
default_hud_gauges[i]->updateColor(clr.red, clr.green, clr.blue, clr.alpha);
}
}
}
@@ -829,40 +845,46 @@ void set_current_hud()
for(i = 0; i < num_gauges; i++) {
HudGauge* hgp = Ship_info[Player_ship->ship_info_index].hud_gauges[i].get();
config_type = hgp->getConfigType();
SCP_string config_id = hgp->getConfigId();
if ( ( (!hgp->isOffbyDefault() || hgp->isActive()) && hud_config_show_flag_is_set(config_type)) )
if ( ( (!hgp->isOffbyDefault() || hgp->isActive()) && HUD_config.is_gauge_visible(config_id)) )
hgp->updateActive(true);
else
hgp->updateActive(false);
//hgp->updateActive(hud_config_show_flag_is_set(config_type) ? true : false);
hgp->updatePopUp(hud_config_popup_flag_is_set(config_type) ? true : false);
hgp->updateColor(
HUD_config.clr[config_type].red,
HUD_config.clr[config_type].green,
HUD_config.clr[config_type].blue,
HUD_config.clr[config_type].alpha
);
hgp->updatePopUp(HUD_config.is_gauge_popup(config_id));
color clr;
if (config_id.empty()) {
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
clr = HUD_config.gauge_colors[gauge_map.get_string_id_from_numeric_id(config_type)];
} else {
clr = HUD_config.get_gauge_color(config_id);
}
hgp->updateColor(clr.red, clr.green, clr.blue, clr.alpha);
}
} else {
num_gauges = default_hud_gauges.size();
for(i = 0; i < num_gauges; i++) {
config_type = default_hud_gauges[i]->getConfigType();
SCP_string config_id = default_hud_gauges[i]->getConfigId();
if ( ( (!default_hud_gauges[i]->isOffbyDefault() || default_hud_gauges[i]->isActive()) && hud_config_show_flag_is_set(config_type)) )
if ( ( (!default_hud_gauges[i]->isOffbyDefault() || default_hud_gauges[i]->isActive()) &&HUD_config.is_gauge_visible(config_id)) )
default_hud_gauges[i]->updateActive(true);
else
default_hud_gauges[i]->updateActive(false);
//default_hud_gauges[i]->updateActive(hud_config_show_flag_is_set(config_type) ? true : false);
default_hud_gauges[i]->updatePopUp(hud_config_popup_flag_is_set(config_type) ? true : false);
default_hud_gauges[i]->updateColor(
HUD_config.clr[config_type].red,
HUD_config.clr[config_type].green,
HUD_config.clr[config_type].blue,
HUD_config.clr[config_type].alpha
);
default_hud_gauges[i]->updatePopUp(HUD_config.is_gauge_popup(config_id));
color clr;
if (config_id.empty()) {
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
clr = HUD_config.gauge_colors[gauge_map.get_string_id_from_numeric_id(config_type)];
} else {
clr = HUD_config.get_gauge_color(config_id);
}
default_hud_gauges[i]->updateColor(clr.red, clr.green, clr.blue, clr.alpha);
}
}
}
@@ -1304,6 +1326,7 @@ std::unique_ptr<T> gauge_load_common(gauge_settings* settings, T* preAllocated =
int display_size[2] = {0, 0};
int display_offset[2] = {0, 0};
int canvas_size[2] = {0, 0};
bool visible_in_config = true;
if(check_base_res(settings->base_res)) {
if (settings->set_position) {
@@ -1435,6 +1458,10 @@ std::unique_ptr<T> gauge_load_common(gauge_settings* settings, T* preAllocated =
}
}
if (optional_string("Config:")) {
stuff_boolean(&visible_in_config);
}
std::unique_ptr<T> instance(preAllocated);
if (instance == NULL)
@@ -1463,6 +1490,7 @@ std::unique_ptr<T> gauge_load_common(gauge_settings* settings, T* preAllocated =
//In this case, we must always slew every hud gauge, no matter what.
instance->initSlew(true);
}
instance->initVisible_in_config(visible_in_config);
return instance;
}
@@ -1500,6 +1528,7 @@ void load_gauge_custom(gauge_settings* settings)
int display_size[2] = {0, 0};
int display_offset[2] = {0, 0};
int canvas_size[2] = {0, 0};
bool visible_in_config = true;
if(check_base_res(settings->base_res)) {
if(optional_string("Position:")) {
@@ -1626,6 +1655,10 @@ void load_gauge_custom(gauge_settings* settings)
stuff_boolean(&settings->slew);
}
if (optional_string("Config:")) {
stuff_boolean(&visible_in_config);
}
if(optional_string("Active by default:")) {
stuff_boolean(&active_by_default);
}
@@ -1655,6 +1688,7 @@ void load_gauge_custom(gauge_settings* settings)
hud_gauge->initCockpitTarget(display_name, display_offset[0], display_offset[1], display_size[0], display_size[1], canvas_size[0], canvas_size[1]);
hud_gauge->initChase_view_only(settings->chase_view_only);
hud_gauge->initCockpit_view_choice(settings->cockpit_view_choice);
hud_gauge->initVisible_in_config(visible_in_config);
gauge_assign_common(settings, std::move(hud_gauge));
}
+8 -4
View File
@@ -264,7 +264,7 @@ void HudGaugeReticle::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(crosshair.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
ship_info* sip = nullptr;
@@ -687,7 +687,7 @@ void HudGaugeThrottle::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(throttle_frames.first_frame + 1, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
int desired_y_pos = y + fl2i(Bottom_offset_y * scale) - fl2i(std::lround(fl2i(throttle_h * scale) * desired_speed / max_speed)) - 1;
@@ -999,7 +999,11 @@ void HudGaugeThreatIndicator::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(threat_arc.first_frame + 1, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id,
x,
x + static_cast<int>(bmw * scale),
y,
y + static_cast<int>(bmh * scale));
}
setGaugeColor(HUD_C_NONE, config);
@@ -1178,7 +1182,7 @@ void HudGaugeWeaponLinking::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(arc.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
setGaugeColor(HUD_C_NONE, config);
+3 -3
View File
@@ -768,7 +768,7 @@ void HudGaugeShield::showShields(const object *objp, int mode, bool config)
if (config) {
int bmw, bmh;
bm_get_info(sgp->first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
}
@@ -783,7 +783,7 @@ void HudGaugeShield::showShields(const object *objp, int mode, bool config)
// If this comment is here then I have not tested this
if (config) {
hud_config_set_mouse_coords(gauge_config, x, x + BAR_LENGTH, y, y + BAR_HEIGHT);
hud_config_set_mouse_coords(gauge_config_id, x, x + BAR_LENGTH, y, y + BAR_HEIGHT);
}
switch(i)
@@ -1032,7 +1032,7 @@ void HudGaugeShieldMini::showMiniShields(const object *objp, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Shield_mini_gauge.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));
}
setGaugeColor(HUD_C_NONE, config);
+1 -1
View File
@@ -2812,7 +2812,7 @@ void HudGaugeSquadMessage::render(float /*frametime*/, bool config)
if (config) {
int bmw, bmh;
bm_get_info(Mbox_gauge[2].first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, bx + fl2i(bmw * scale), y, by + fl2i((bmh + bottom_bg_offset) * scale));
hud_config_set_mouse_coords(gauge_config_id, x, bx + fl2i(bmw * scale), y, by + fl2i((bmh + bottom_bg_offset) * scale));
}
}
+16 -16
View File
@@ -2776,7 +2776,7 @@ void HudGaugeOrientationTee::renderOrientation(object *from_objp, object *to_obj
// Rotate the angle so that 0 is on top
angle -= 180.0f;
angle = hud_config_find_valid_angle(gauge_config, angle, x + fl2i(HUD_nose_x * scale), y + fl2i(HUD_nose_y * scale), Radius * scale);
angle = hud_config_find_valid_angle(gauge_config_id, angle, x + fl2i(HUD_nose_x * scale), y + fl2i(HUD_nose_y * scale), Radius * scale);
// Convert angle to radians
float angle_radians = angle * static_cast<float>(M_PI) / 180.0f;
@@ -2821,7 +2821,7 @@ void HudGaugeOrientationTee::renderOrientation(object *from_objp, object *to_obj
float y_min = std::min({y1, y2, y3, y4});
float y_max = std::max({y1, y2, y3, y4});
hud_config_set_mouse_coords(gauge_config, fl2i(x_min), fl2i(x_max), fl2i(y_min), fl2i(y_max));
hud_config_set_mouse_coords(gauge_config_id, fl2i(x_min), fl2i(x_max), fl2i(y_min), fl2i(y_max));
}
// HACK! Should be antialiased!
@@ -3025,7 +3025,7 @@ void HudGaugeReticleTriangle::renderTriangleMissileTail(float ang, float xpos, f
float min_y = std::min({ypos, y1, y2, ytail});
float max_y = std::max({ypos, y1, y2, ytail});
hud_config_set_mouse_coords(gauge_config, fl2i(min_x), fl2i(max_x), fl2i(min_y), fl2i(max_y));
hud_config_set_mouse_coords(gauge_config_id, fl2i(min_x), fl2i(max_x), fl2i(min_y), fl2i(max_y));
}
gr_reset_screen_scale();
}
@@ -3175,7 +3175,7 @@ void HudGaugeReticleTriangle::renderTriangle(vec3d *hostile_pos, int aspect_flag
float min_y = std::min({ypos, y1, y2});
float max_y = std::max({ypos, y1, y2});
hud_config_set_mouse_coords(gauge_config, fl2i(min_x), fl2i(max_x), fl2i(min_y), fl2i(max_y));
hud_config_set_mouse_coords(gauge_config_id, fl2i(min_x), fl2i(max_x), fl2i(min_y), fl2i(max_y));
}
}
}
@@ -3255,7 +3255,7 @@ void HudGaugeMissileTriangles::render(float /*frametime*/, bool config)
float scale;
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
angle = hud_config_find_valid_angle(gauge_config, angle, x + fl2i(HUD_nose_x * scale), y + fl2i(HUD_nose_y * scale), Radius * scale);
angle = hud_config_find_valid_angle(gauge_config_id, angle, x + fl2i(HUD_nose_x * scale), y + fl2i(HUD_nose_y * scale), Radius * scale);
auto pair = hud_config_calc_coords_from_angle(angle,
x + fl2i(HUD_nose_x * scale),
@@ -3797,7 +3797,7 @@ void HudGaugeHostileTriangle::render(float /*frametime*/, bool config)
float scale;
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
angle = hud_config_find_valid_angle(gauge_config, angle, x + fl2i(HUD_nose_x * scale), y + fl2i(HUD_nose_y * scale), Radius * scale);
angle = hud_config_find_valid_angle(gauge_config_id, angle, x + fl2i(HUD_nose_x * scale), y + fl2i(HUD_nose_y * scale), Radius * scale);
auto pair = hud_config_calc_coords_from_angle(angle,
x + fl2i(HUD_nose_x * scale),
@@ -4113,7 +4113,7 @@ void HudGaugeLeadIndicator::renderIndicator(int frame_offset, object *targetp, v
int max_attempts = 100; // Limit to avoid infinite loops
int attempts = 0;
while (BoundingBox::isOverlappingAny(HC_gauge_mouse_coords, newBox, gauge_config)) {
while (BoundingBox::isOverlappingAny(HC_gauge_mouse_coords, newBox, gauge_config_id)) {
if (++attempts > max_attempts) {
break; // Safety net
}
@@ -4141,7 +4141,7 @@ void HudGaugeLeadIndicator::renderIndicator(int frame_offset, object *targetp, v
int mx = fl2i(x - i2fl(Lead_indicator_half[0] * scale));
int my = fl2i(y - i2fl(Lead_indicator_half[1] * scale));
hud_config_set_mouse_coords(gauge_config, mx, mx + fl2i(bmw * scale), my, my + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, mx, mx + fl2i(bmw * scale), my, my + fl2i(bmh * scale));
} else {
unsize(&x, &y);
}
@@ -4847,7 +4847,7 @@ void HudGaugeTargetTriangle::render(float /*frametime*/, bool config)
float scale;
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
angle = hud_config_find_valid_angle(gauge_config, angle, x + fl2i(HUD_nose_x * scale), y + fl2i(HUD_nose_y * scale), Radius * scale);
angle = hud_config_find_valid_angle(gauge_config_id, angle, x + fl2i(HUD_nose_x * scale), y + fl2i(HUD_nose_y * scale), Radius * scale);
auto pair = hud_config_calc_coords_from_angle(angle,
x + fl2i(HUD_nose_x * scale),
@@ -5104,7 +5104,7 @@ void HudGaugeAutoTarget::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Toggle_frame.first_frame + frame_offset, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
// draw the box background
@@ -5202,7 +5202,7 @@ void HudGaugeAutoSpeed::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Toggle_frame.first_frame + frame_offset, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
setGaugeColor(HUD_C_NONE, config);
@@ -5818,7 +5818,7 @@ void HudGaugeCmeasures::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Cmeasure_gauge.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
// hud_set_default_color();
@@ -5885,7 +5885,7 @@ void HudGaugeAfterburner::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Energy_bar.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
clip_h = fl2i(std::lround((1.0f - percent_left) * Energy_h));
@@ -6001,7 +6001,7 @@ void HudGaugeWeaponEnergy::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Energy_bar.first_frame+2, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
if(use_new_gauge)
@@ -6750,7 +6750,7 @@ void HudGaugeWeapons::render(float /*frametime*/, bool config)
if (config) {
int bmw, bmh;
bm_get_info(secondary_bottom[ballistic_hud_index].first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i((bmw + frame_offset_x[ballistic_hud_index]) * scale), y, ty + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i((bmw + frame_offset_x[ballistic_hud_index]) * scale), y, ty + fl2i(bmh * scale));
}
}
@@ -7200,7 +7200,7 @@ void HudGaugeOffscreen::renderOffscreenIndicator(vec2d *coords, int dir, float d
}
if (config) {
hud_config_set_mouse_coords(gauge_config, fl2i(xpos - w), fl2i(xpos + w), fl2i(ypos), fl2i(ypos + h * 2.0f));
hud_config_set_mouse_coords(gauge_config_id, fl2i(xpos - w), fl2i(xpos + w), fl2i(ypos), fl2i(ypos + h * 2.0f));
}
gr_reset_screen_scale();
+2 -2
View File
@@ -402,7 +402,7 @@ void HudGaugeTargetBox::render(float frametime, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Monitor_frame.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
setGaugeColor(HUD_C_NONE, config);
@@ -1569,7 +1569,7 @@ void HudGaugeExtraTargetData::render(float /*frametime*/, bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(bracket.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(order_max_w * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(order_max_w * scale), y, y + fl2i(bmh * scale));
}
setGaugeColor(HUD_C_NONE, config);
+1 -1
View File
@@ -413,7 +413,7 @@ void HudGaugeWingmanStatus::renderBackground(int num_wings_to_draw, bool config)
if (config) {
int bmw, bmh;
bm_get_info(Wingman_status_right.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, actual_origin[0], sx + fl2i(bmw * scale), actual_origin[1], sy + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, actual_origin[0], sx + fl2i(bmw * scale), actual_origin[1], sy + fl2i(bmh * scale));
}
}
+1 -1
View File
@@ -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 1876 // This is the next available ID
// #define XSTR_SIZE 1877 // This is the next available ID
// struct to allow for strings.tbl-determined x offset
// offset is 0 for english, by default
+2 -2
View File
@@ -219,7 +219,7 @@ bool HudGaugeDirectives::canRender() const
}
}
if (gauge_config == HUD_ETS_GAUGE) {
if (gauge_type == HUD_ETS_GAUGE) {
if (Ships[Player_obj->instance].flags[Ship::Ship_Flags::No_ets]) {
return false;
}
@@ -397,7 +397,7 @@ void HudGaugeDirectives::render(float /*frametime*/, bool config)
if (config) {
int bmw, bmh;
bm_get_info(directives_bottom.first_frame, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, bx + fl2i(bmw * scale), y, by + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, bx + fl2i(bmw * scale), y, by + fl2i(bmh * scale));
}
}
+2 -1
View File
@@ -13561,7 +13561,8 @@ void sexp_hud_reset_color(int n)
WarningEx(LOCATION, "HUD gauge %s does not have a built-in configured color!", gaugename);
} else {
// use the color as specified in the HUD config
auto& c = HUD_config.clr[std::distance(std::begin(Legacy_HUD_gauges), ii)];
auto id = hg->getConfigId();
auto& c = HUD_config.gauge_colors[id];
hg->sexpLockConfigColor(false);
hg->updateColor(c.red, c.green, c.blue, (HUD_color_alpha + 1) * 16);
+82 -26
View File
@@ -1013,20 +1013,41 @@ void pilotfile::csg_write_redalert()
void pilotfile::csg_read_hud()
{
int idx;
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
int strikes = 0;
// flags
HUD_config.show_flags = cfread_int(cfp);
HUD_config.show_flags2 = cfread_int(cfp);
int show_flags = cfread_int(cfp);
int show_flags2 = cfread_int(cfp);
HUD_config.popup_flags = cfread_int(cfp);
HUD_config.popup_flags2 = cfread_int(cfp);
int popup_flags = cfread_int(cfp);
int popup_flags2 = cfread_int(cfp);
// Convert show_flags (0-31) and show_flags2 (32-63)
for (int i = 0; i < 64; i++) {
bool is_set = (i < 32) ? (show_flags & (1 << i)) : (show_flags2 & (1 << (i - 32)));
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(i);
if (!gauge_id.empty()) {
HUD_config.set_gauge_visibility(gauge_id, is_set);
}
}
// Convert popup_flags (0-31) and popup_flags2 (32-63)
for (int i = 0; i < 64; i++) {
bool is_set = (i < 32) ? (popup_flags & (1 << i)) : (popup_flags2 & (1 << (i - 32)));
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(i);
if (!gauge_id.empty()) {
HUD_config.set_gauge_popup(gauge_id, is_set);
}
}
// settings
HUD_config.num_msg_window_lines = cfread_ubyte(cfp);
SCP_UNUSED(cfread_ubyte(cfp));// Deprecated but still read for file compatibility 3/7/2025
SCP_UNUSED(cfread_int(cfp));// Deprecated but still read for file compatibility 3/7/2025
HUD_config.rp_flags = cfread_int(cfp);
HUD_config.rp_dist = cfread_int(cfp);
if (HUD_config.rp_dist < 0 || HUD_config.rp_dist >= RR_MAX_RANGES) {
ReleaseWarning(LOCATION, "Campaign file has invalid radar range %d, setting to default.\n", HUD_config.rp_dist);
@@ -1058,7 +1079,7 @@ void pilotfile::csg_read_hud()
// gauge-specific colors
int num_gauges = cfread_int(cfp);
for (idx = 0; idx < num_gauges; idx++) {
for (int idx = 0; idx < num_gauges; idx++) {
ubyte red = cfread_ubyte(cfp);
ubyte green = cfread_ubyte(cfp);
ubyte blue = cfread_ubyte(cfp);
@@ -1068,30 +1089,61 @@ void pilotfile::csg_read_hud()
continue;
}
HUD_config.clr[idx].red = red;
HUD_config.clr[idx].green = green;
HUD_config.clr[idx].blue = blue;
HUD_config.clr[idx].alpha = alpha;
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(idx);
if (!gauge_id.empty()) {
color clr;
gr_init_alphacolor(&clr, red, green, blue, alpha);
HUD_config.set_gauge_color(gauge_id, clr);
}
}
}
void pilotfile::csg_write_hud()
{
int idx;
startSection(Section::HUD);
// flags
cfwrite_int(HUD_config.show_flags, cfp);
cfwrite_int(HUD_config.show_flags2, cfp);
// Get gauge mappings instance
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
cfwrite_int(HUD_config.popup_flags, cfp);
cfwrite_int(HUD_config.popup_flags2, cfp);
// Initialize bitfields
int show_flags = 0, show_flags2 = 0;
int popup_flags = 0, popup_flags2 = 0;
// Convert show_flags_map to bitfield
for (int i = 0; i < 64; i++) {
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(i);
if (!gauge_id.empty() && HUD_config.is_gauge_visible(gauge_id)) {
if (i < 32) {
show_flags |= (1 << i);
} else {
show_flags2 |= (1 << (i - 32));
}
}
}
// Convert popup_flags_map to bitfield
for (int i = 0; i < 64; i++) {
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(i);
if (!gauge_id.empty() && HUD_config.is_gauge_popup(gauge_id)) {
if (i < 32) {
popup_flags |= (1 << i);
} else {
popup_flags2 |= (1 << (i - 32));
}
}
}
// flags
cfwrite_int(show_flags, cfp);
cfwrite_int(show_flags2, cfp);
cfwrite_int(popup_flags, cfp);
cfwrite_int(popup_flags2, cfp);
// settings
cfwrite_ubyte(HUD_config.num_msg_window_lines, cfp);
cfwrite_ubyte(0, cfp);// Deprecated but still written for file compatibility 3/7/2025
cfwrite_int(0, cfp);// Deprecated but still written for file compatibility 3/7/2025
cfwrite_int(HUD_config.rp_flags, cfp);
cfwrite_int(HUD_config.rp_dist, cfp);
// basic colors
@@ -1101,11 +1153,15 @@ void pilotfile::csg_write_hud()
// gauge-specific colors
cfwrite_int(NUM_HUD_GAUGES, cfp);
for (idx = 0; idx < NUM_HUD_GAUGES; idx++) {
cfwrite_ubyte(HUD_config.clr[idx].red, cfp);
cfwrite_ubyte(HUD_config.clr[idx].green, cfp);
cfwrite_ubyte(HUD_config.clr[idx].blue, cfp);
cfwrite_ubyte(HUD_config.clr[idx].alpha, cfp);
for (int idx = 0; idx < NUM_HUD_GAUGES; idx++) {
// Get the gauge string ID from numeric ID
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(idx);
color clr = HUD_config.get_gauge_color(gauge_id);
cfwrite_ubyte(clr.red, cfp);
cfwrite_ubyte(clr.green, cfp);
cfwrite_ubyte(clr.blue, cfp);
cfwrite_ubyte(clr.alpha, cfp);
}
endSection();
+82 -25
View File
@@ -182,18 +182,40 @@ void pilotfile::plr_write_info()
void pilotfile::plr_read_hud()
{
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
int strikes = 0;
// flags
HUD_config.show_flags = handler->readInt("show_flags");
HUD_config.show_flags2 = handler->readInt("show_flags2");
int show_flags = handler->readInt("show_flags");
int show_flags2 = handler->readInt("show_flags2");
HUD_config.popup_flags = handler->readInt("popup_flags");
HUD_config.popup_flags2 = handler->readInt("popup_flags2");
int popup_flags = handler->readInt("popup_flags");
int popup_flags2 = handler->readInt("popup_flags2");
// Convert show_flags (0-31) and show_flags2 (32-63)
for (int i = 0; i < 64; i++) {
bool is_set = (i < 32) ? (show_flags & (1 << i)) : (show_flags2 & (1 << (i - 32)));
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(i);
if (!gauge_id.empty()) {
HUD_config.set_gauge_visibility(gauge_id, is_set);
}
}
// Convert popup_flags (0-31) and popup_flags2 (32-63)
for (int i = 0; i < 64; i++) {
bool is_set = (i < 32) ? (popup_flags & (1 << i)) : (popup_flags2 & (1 << (i - 32)));
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(i);
if (!gauge_id.empty()) {
HUD_config.set_gauge_popup(gauge_id, is_set);
}
}
// settings
HUD_config.num_msg_window_lines = handler->readUByte("num_msg_window_lines");
SCP_UNUSED(handler->readUByte("num_msg_window_lines"));// Deprecated but still read for file compatibility 3/7/2025
SCP_UNUSED(handler->readInt("rp_flags"));// Deprecated but still read for file compatibility 3/7/2025
HUD_config.rp_flags = handler->readInt("rp_flags");
HUD_config.rp_dist = handler->readInt("rp_dist");
if (HUD_config.rp_dist < 0 || HUD_config.rp_dist >= RR_MAX_RANGES) {
ReleaseWarning(LOCATION, "Player file has invalid radar range %d, setting to default.\n", HUD_config.rp_dist);
@@ -224,7 +246,7 @@ void pilotfile::plr_read_hud()
// gauge-specific colors
auto num_gauges = handler->startArrayRead("hud_gauges");
for (size_t idx = 0; idx < num_gauges; idx++, handler->nextArraySection()) {
for (int idx = 0; idx < static_cast<int>(num_gauges); idx++, handler->nextArraySection()) {
ubyte red = handler->readUByte("red");
ubyte green = handler->readUByte("green");
ubyte blue = handler->readUByte("blue");
@@ -235,31 +257,62 @@ void pilotfile::plr_read_hud()
continue;
}
HUD_config.clr[idx].red = red;
HUD_config.clr[idx].green = green;
HUD_config.clr[idx].blue = blue;
HUD_config.clr[idx].alpha = alpha;
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(idx);
if (!gauge_id.empty()) {
color clr;
gr_init_alphacolor(&clr, red, green, blue, alpha);
HUD_config.set_gauge_color(gauge_id, clr);
}
}
handler->endArrayRead();
}
void pilotfile::plr_write_hud()
{
int idx;
handler->startSectionWrite(Section::HUD);
// flags
handler->writeInt("show_flags", HUD_config.show_flags);
handler->writeInt("show_flags2", HUD_config.show_flags2);
// Get gauge mappings instance
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
handler->writeInt("popup_flags", HUD_config.popup_flags);
handler->writeInt("popup_flags2", HUD_config.popup_flags2);
// Initialize bitfields
int show_flags = 0, show_flags2 = 0;
int popup_flags = 0, popup_flags2 = 0;
// Convert show_flags_map to bitfield
for (int i = 0; i < 64; i++) {
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(i);
if (!gauge_id.empty() && HUD_config.is_gauge_visible(gauge_id)) {
if (i < 32) {
show_flags |= (1 << i);
} else {
show_flags2 |= (1 << (i - 32));
}
}
}
// Convert popup_flags_map to bitfield
for (int i = 0; i < 64; i++) {
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(i);
if (!gauge_id.empty() && HUD_config.is_gauge_popup(gauge_id)) {
if (i < 32) {
popup_flags |= (1 << i);
} else {
popup_flags2 |= (1 << (i - 32));
}
}
}
// Write converted bitfields
handler->writeInt("show_flags", show_flags);
handler->writeInt("show_flags2", show_flags2);
handler->writeInt("popup_flags", popup_flags);
handler->writeInt("popup_flags2", popup_flags2);
// settings
handler->writeUByte("num_msg_window_lines", HUD_config.num_msg_window_lines);
handler->writeUByte("num_msg_window_lines", 0);// Deprecated but still written for file compatibility 3/7/2025
handler->writeInt("rp_flags", 0);// Deprecated but still written for file compatibility 3/7/2025
handler->writeInt("rp_flags", HUD_config.rp_flags);
handler->writeInt("rp_dist", HUD_config.rp_dist);
// basic colors
@@ -268,13 +321,17 @@ void pilotfile::plr_write_hud()
// gauge-specific colors
handler->startArrayWrite("hud_gauges", NUM_HUD_GAUGES);
for (idx = 0; idx < NUM_HUD_GAUGES; idx++) {
for (int idx = 0; idx < NUM_HUD_GAUGES; idx++) {
handler->startSectionWrite(Section::Unnamed);
handler->writeUByte("red", HUD_config.clr[idx].red);
handler->writeUByte("green", HUD_config.clr[idx].green);
handler->writeUByte("blue", HUD_config.clr[idx].blue);
handler->writeUByte("alpha", HUD_config.clr[idx].alpha);
// Get the gauge string ID from numeric ID
SCP_string gauge_id = gauge_map.get_string_id_from_numeric_id(idx);
color clr = HUD_config.get_gauge_color(gauge_id);
handler->writeUByte("red", clr.red);
handler->writeUByte("green", clr.green);
handler->writeUByte("blue", clr.blue);
handler->writeUByte("alpha", clr.alpha);
handler->endSectionWrite();
}
+1 -1
View File
@@ -106,7 +106,7 @@ void HudGaugeRadarStd::blitGauge(bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Radar_gauge.first_frame + 1, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + fl2i(bmw * scale), y, y + fl2i(bmh * scale));
}
if (Radar_gauge.first_frame + 1 >= 0)
+1 -1
View File
@@ -478,7 +478,7 @@ void HudGaugeRadarOrb::blitGauge(bool config)
std::tie(x, y, scale) = hud_config_convert_coord_sys(position[0], position[1], base_w, base_h);
int bmw, bmh;
bm_get_info(Radar_gauge.first_frame + 1, &bmw, &bmh);
hud_config_set_mouse_coords(gauge_config, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));
hud_config_set_mouse_coords(gauge_config_id, x, x + static_cast<int>(bmw * scale), y, y + static_cast<int>(bmh * scale));
}
if (Radar_gauge.first_frame + 1 >= 0)
+9 -3
View File
@@ -111,7 +111,9 @@ ADE_FUNC(getHUDConfigShowStatus, l_HUD, "number|string gaugeNameOrIndex", "Gets
if ((idx < 0) || (idx >= (int)default_hud_gauges.size()))
return ADE_RETURN_NIL;
if (hud_config_show_flag_is_set(idx))
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
if (HUD_config.is_gauge_visible(gauge_map.get_string_id_from_numeric_id(idx)))
return ADE_RETURN_TRUE;
else
return ADE_RETURN_FALSE;
@@ -149,7 +151,9 @@ ADE_FUNC(setHUDGaugeColor, l_HUD,
if ((idx < 0) || (idx >= NUM_HUD_GAUGES))
return ADE_RETURN_FALSE;
gr_init_alphacolor(&HUD_config.clr[idx], r, g, b, a);
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
gr_init_alphacolor(&HUD_config.gauge_colors[gauge_map.get_string_id_from_numeric_id(idx)], r, g, b, a);
return ADE_RETURN_TRUE;
}
@@ -169,7 +173,9 @@ ADE_FUNC(getHUDGaugeColor,
if ((idx < 0) || (idx >= NUM_HUD_GAUGES))
return ADE_RETURN_NIL;
color cur = HUD_config.clr[idx];
const HC_gauge_mappings& gauge_map = HC_gauge_mappings::get_instance();
color cur = HUD_config.gauge_colors[gauge_map.get_string_id_from_numeric_id(idx)];
if (!rc) {
return ade_set_args(L, "iiii", (int)cur.red, (int)cur.green, (int)cur.blue, (int)cur.alpha);
+52 -8
View File
@@ -2399,19 +2399,20 @@ ADE_LIB_DERIV(l_UserInterface_HUDConfig,
ADE_FUNC(initHudConfig,
l_UserInterface_HUDConfig,
"[number X, number Y, number Width]",
"[number X, number Y, number Width, number height]",
"Initializes the HUD Configuration data. Must be used before HUD Configuration data accessed. "
"X and Y are the coordinates where the HUD preview will be drawn when drawHudConfig is used. "
"Width is the pixel width to draw the gauges preview.",
"Width is the pixel width to draw the gauges preview. Height is the pixel height to draw the gauges preview.",
nullptr,
nullptr)
{
int x = 0;
int y = 0;
int w = 0;
ade_get_args(L, "|iii", &x, &y, &w);
int h = 0;
ade_get_args(L, "|iiii", &x, &y, &w, &h);
hud_config_init(true, x, y, w);
hud_config_init(true, x, y, w, h);
return ADE_RETURN_NIL;
}
@@ -2450,13 +2451,29 @@ ADE_FUNC(drawHudConfig,
hud_config_do_frame(0.0f, true, mx, my);
if (HC_gauge_hot >= 0) {
if (!HC_gauge_hot.empty()) {
return ade_set_args(L, "o", l_Gauge_Config.Set(gauge_config_h(HC_gauge_hot)));
} else {
return ade_set_error(L, "o", l_Gauge_Config.Set(gauge_config_h()));
}
}
ADE_FUNC(getCurrentHudName,
l_UserInterface_HUDConfig,
nullptr,
"Returns the name of the current HUD configuration.",
"string",
"The name of the current HUD configuration.")
{
SCP_UNUSED(L);
if (SCP_vector_inbounds(HC_available_huds, HC_chosen_hud)) {
return ade_set_args(L, "s", HC_available_huds[HC_chosen_hud].second.c_str());
} else {
return ade_set_args(L, "s", "Default Hud");
}
}
ADE_FUNC(selectAllGauges,
l_UserInterface_HUDConfig,
"boolean Toggle",
@@ -2472,6 +2489,33 @@ ADE_FUNC(selectAllGauges,
return ADE_RETURN_NIL;
}
ADE_FUNC(selectNoGauges, l_UserInterface_HUDConfig, nullptr, "Sets no gauges as selected.", nullptr, nullptr)
{
SCP_UNUSED(L);
hud_config_select_none();
return ADE_RETURN_NIL;
}
ADE_FUNC(selectNextHud, l_UserInterface_HUDConfig, nullptr, "Selects the next available HUD", nullptr, nullptr)
{
SCP_UNUSED(L);
hud_config_select_hud(true);
return ADE_RETURN_NIL;
}
ADE_FUNC(selectPrevHud, l_UserInterface_HUDConfig, nullptr, "Selects the previous available HUD", nullptr, nullptr)
{
SCP_UNUSED(L);
hud_config_select_hud(false);
return ADE_RETURN_NIL;
}
ADE_FUNC(setToDefault,
l_UserInterface_HUDConfig,
"string Filename",
@@ -2545,15 +2589,15 @@ ADE_INDEXER(l_HUD_Gauges,
return ade_set_error(L, "o", l_Gauge_Config.Set(gauge_config_h()));
idx--; // Convert from Lua's 1 based index system
if ((idx < 0) || (idx >= NUM_HUD_GAUGES))
if ((idx < 0) || (idx >= static_cast<int>(HC_gauge_map.size())))
return ade_set_error(L, "o", l_Gauge_Config.Set(gauge_config_h()));
return ade_set_args(L, "o", l_Gauge_Config.Set(gauge_config_h(idx)));
return ade_set_args(L, "o", l_Gauge_Config.Set(gauge_config_h(HC_gauge_map[idx].first)));
}
ADE_FUNC(__len, l_HUD_Gauges, nullptr, "The number of gauge configs", "number", "The number of gauge configs.")
{
return ade_set_args(L, "i", NUM_HUD_GAUGES);
return ade_set_args(L, "i", static_cast<int>(HC_gauge_map.size()));
}
ADE_LIB_DERIV(l_HUD_Presets, "GaugePresets", nullptr, nullptr, l_UserInterface_HUDConfig);
+23 -41
View File
@@ -9,35 +9,25 @@
namespace scripting {
namespace api {
gauge_config_h::gauge_config_h() : gauge(-1) {}
gauge_config_h::gauge_config_h(int l_gauge) : gauge(l_gauge) {}
gauge_config_h::gauge_config_h(SCP_string l_gauge) : gauge(std::move(l_gauge)) {}
HC_gauge_region* gauge_config_h::getGauge() const
HudGauge* gauge_config_h::getGauge() const
{
if (!isValid()) {
return nullptr;
}
return &HC_gauge_regions[GR_1024][gauge];
return hud_config_get_gauge_pointer(gauge);
}
int gauge_config_h::getIndex() const
SCP_string gauge_config_h::getId() const
{
return gauge;
}
const char* gauge_config_h::getName() const
{
if (!isValid()) {
return nullptr;
}
return HC_gauge_descriptions(gauge);
}
bool gauge_config_h::isValid() const
{
return gauge >= 0 && gauge < NUM_HUD_GAUGES;
return hud_config_get_gauge_pointer(gauge) != nullptr;
}
hud_preset_h::hud_preset_h() : preset(-1) {}
@@ -126,7 +116,7 @@ ADE_VIRTVAR(Name, l_Gauge_Config, nullptr, "The name of this gauge", "string", "
LuaError(L, "This property is read only.");
}
return ade_set_args(L, "s", current.getName());
return ade_set_args(L, "s", current.getGauge()->getConfigName().c_str());
}
ADE_VIRTVAR(CurrentColor,
@@ -147,24 +137,24 @@ ADE_VIRTVAR(CurrentColor,
}
if (ADE_SETTING_VAR) {
if (!current.getGauge()->use_iff) {
HUD_config.clr[current.getIndex()] = newColor;
if (!current.getGauge()->getConfigUseIffColor()) {
HUD_config.set_gauge_color(current.getId(), newColor);
}
}
const color *thisColor;
color thisColor;
if (!current.getGauge()->use_iff) {
thisColor = &HUD_config.clr[current.getIndex()];
if (!current.getGauge()->getConfigUseIffColor()) {
thisColor = HUD_config.get_gauge_color(current.getId());
} else {
if (current.getGauge()->color == 1) {
thisColor = iff_get_color(IFF_COLOR_TAGGED, 0);
if (current.getGauge()->getConfigUseTagColor()) {
thisColor = *iff_get_color(IFF_COLOR_TAGGED, 0);
} else {
thisColor = &Color_bright_red;
thisColor = Color_bright_red;
}
}
return ade_set_args(L, "o", l_Color.Set(*thisColor));
return ade_set_args(L, "o", l_Color.Set(thisColor));
}
ADE_VIRTVAR(ShowGaugeFlag,
@@ -185,14 +175,10 @@ ADE_VIRTVAR(ShowGaugeFlag,
}
if (ADE_SETTING_VAR) {
if (show) {
hud_config_show_flag_set(current.getIndex());
} else {
hud_config_show_flag_clear(current.getIndex());
}
HUD_config.set_gauge_visibility(current.getId(), show);
}
return ade_set_args(L, "b", (bool)hud_config_show_flag_is_set(current.getIndex()));
return ade_set_args(L, "b", HUD_config.is_gauge_visible(current.getId()));
}
ADE_VIRTVAR(PopupGaugeFlag,
@@ -213,18 +199,14 @@ ADE_VIRTVAR(PopupGaugeFlag,
}
if (ADE_SETTING_VAR) {
if (popup) {
hud_config_popup_flag_set(current.getIndex());
} else {
hud_config_popup_flag_clear(current.getIndex());
}
HUD_config.set_gauge_popup(current.getId(), popup);
}
if (current.getGauge()->can_popup == 0) {
if (!current.getGauge()->getConfigCanPopup()) {
return ADE_RETURN_FALSE;
}
return ade_set_args(L, "b", (bool)hud_config_popup_flag_is_set(current.getIndex()));
return ade_set_args(L, "b", HUD_config.is_gauge_popup(current.getId()));
}
ADE_VIRTVAR(CanPopup,
@@ -247,7 +229,7 @@ ADE_VIRTVAR(CanPopup,
LuaError(L, "This property is read only.");
}
if (current.getGauge()->can_popup == 0) {
if (!current.getGauge()->getConfigCanPopup()) {
return ADE_RETURN_FALSE;
}
@@ -274,7 +256,7 @@ ADE_VIRTVAR(UsesIffForColor,
LuaError(L, "This property is read only.");
}
if (current.getGauge()->use_iff == 0) {
if (!current.getGauge()->getConfigUseIffColor()) {
return ADE_RETURN_FALSE;
}
@@ -294,7 +276,7 @@ ADE_FUNC(setSelected, l_Gauge_Config, "boolean", "Sets if the gauge is the curre
}
if (select) {
HC_gauge_selected = current.getIndex();
HC_gauge_selected = current.getId();
}
return ADE_RETURN_NIL;
+5 -6
View File
@@ -7,12 +7,11 @@ namespace scripting {
namespace api {
struct gauge_config_h {
int gauge;
gauge_config_h();
explicit gauge_config_h(int l_gauge);
HC_gauge_region* getGauge() const;
int getIndex() const;
const char* getName() const;
SCP_string gauge;
gauge_config_h() = default;
explicit gauge_config_h(SCP_string l_gauge);
HudGauge* getGauge() const;
SCP_string getId() const;
bool isValid() const;
};