From 91eacb0661f27a2f5523e0b6da3f6296e53da83b Mon Sep 17 00:00:00 2001 From: theTwister <6237734+twist84@users.noreply.github.com> Date: Fri, 10 Jan 2025 02:38:43 +0000 Subject: [PATCH] Updated `debug_menu` --- .../interface/debug_menu/debug_menu.cpp | 90 ++++++------ .../interface/debug_menu/debug_menu.hpp | 12 +- .../interface/debug_menu/debug_menu_item.cpp | 20 +-- .../interface/debug_menu/debug_menu_item.hpp | 7 +- .../debug_menu/debug_menu_item_numbered.cpp | 92 ++++++------- .../debug_menu/debug_menu_item_numbered.hpp | 34 ++--- .../interface/debug_menu/debug_menu_main.cpp | 129 ++++++++++-------- .../interface/debug_menu/debug_menu_main.hpp | 6 +- .../debug_menu/debug_menu_scroll.cpp | 22 +-- .../debug_menu/debug_menu_scroll.hpp | 2 +- 10 files changed, 211 insertions(+), 203 deletions(-) diff --git a/game/source/interface/debug_menu/debug_menu.cpp b/game/source/interface/debug_menu/debug_menu.cpp index df5ef5ecd..ca73245b5 100644 --- a/game/source/interface/debug_menu/debug_menu.cpp +++ b/game/source/interface/debug_menu/debug_menu.cpp @@ -63,10 +63,10 @@ void c_debug_menu::update() } else { - m_up_time = 0; - m_down_time = 0; - m_left_time = 0; - m_right_time = 0; + m_last_up = 0; + m_last_down = 0; + m_last_left = 0; + m_last_right = 0; } } @@ -241,14 +241,14 @@ void c_debug_menu::notify_up() if (!is_active_menu()) return; - if (debug_menu_get_time() - m_up_time < get_menu_rate()) + if (debug_menu_get_time() - m_last_up < get_menu_rate()) return; if (!get_num_items()) return; short selection = get_selection(); - m_up_time = debug_menu_get_time(); + m_last_up = debug_menu_get_time(); c_debug_menu_item* item = NULL; do @@ -270,14 +270,14 @@ void c_debug_menu::notify_down() if (!is_active_menu()) return; - if (debug_menu_get_time() - m_down_time < get_menu_rate()) + if (debug_menu_get_time() - m_last_down < get_menu_rate()) return; if (!get_num_items()) return; short selection = get_selection(); - m_down_time = debug_menu_get_time(); + m_last_down = debug_menu_get_time(); c_debug_menu_item* item = NULL; do @@ -333,31 +333,31 @@ short c_debug_menu::get_max_active_captions() void c_debug_menu::render_background(c_font_cache_base* font_cache, point2d const& point) { - real unused = get_enabled() ? 0.7f : 0.1f; real item_margin = get_value_width() ? debug_menu_get_item_margin() : 0.0f; - short a1 = short((((point.x - debug_menu_get_item_margin()) - get_num_items_to_render()) - item_margin) - 60.0); - short a2 = point.y; - short a3 = short((point.x + debug_menu_get_item_width()) + debug_menu_get_item_margin()); - short a4 = short((point.y + get_title_height()) + (get_num_items_to_render() + get_max_active_captions()) * get_item_height()); + short x0 = short((((point.x - debug_menu_get_item_margin()) - get_num_items_to_render()) - item_margin) - 60.0); + short y0 = point.y; + short x1 = short((point.x + debug_menu_get_item_width()) + debug_menu_get_item_margin()); + short y1 = short((point.y + get_title_height()) + (get_num_items_to_render() + get_max_active_captions()) * get_item_height()); + real alpha = get_enabled() ? 0.7f : 0.1f; - debug_menu_draw_rect(a1, a2, a3, a4, unused, debug_real_argb_tv_blue); + debug_menu_draw_rect(x0, y0, x1, y1, alpha, debug_real_argb_tv_blue); } void c_debug_menu::render_title(c_font_cache_base* font_cache, point2d const& point) { - real unused = get_enabled() ? 0.7f : 0.1f; c_rasterizer_draw_string draw_string{}; rectangle2d bounds{}; interface_get_current_display_settings(NULL, NULL, NULL, &bounds); - short a1 = point.x; - short a2 = short(point.y + debug_menu_get_item_indent_y()); - short a3 = short(point.x + debug_menu_get_item_width()); - short a4 = short((point.y + get_item_height()) - (2.0f * debug_menu_get_item_indent_y())); + short x0 = point.x; + short y0 = short(point.y + debug_menu_get_item_indent_y()); + short x1 = short(point.x + debug_menu_get_item_width()); + short y1 = short((point.y + get_item_height()) - (2.0f * debug_menu_get_item_indent_y())); + real alpha = get_enabled() ? 0.7f : 0.1f; - debug_menu_draw_rect(a1, a2, a3, a4, unused, debug_real_argb_grey); + debug_menu_draw_rect(x0, y0, x1, y1, alpha, debug_real_argb_grey); set_rectangle2d(&bounds, point.x, point.y, short(point.x + debug_menu_get_item_width()), bounds.y1); draw_string.set_bounds(&bounds); @@ -373,14 +373,13 @@ void c_debug_menu::render_caption(c_font_cache_base* font_cache, point2d const& interface_get_current_display_settings(NULL, NULL, NULL, &bounds); if (*get_caption()) { - real unused = get_enabled() ? 0.7f : 0.1f; + short x0 = point.x; + short y0 = short(point.y + debug_menu_get_item_indent_y()); + short x1 = short(point.x + debug_menu_get_item_width()); + short y1 = short(((point.y + get_title_height()) + get_num_items_to_render() * get_item_height()) - (2.0f * debug_menu_get_item_indent_y())); + real alpha = get_enabled() ? 0.7f : 0.1f; - short a1 = point.x; - short a2 = short(point.y + debug_menu_get_item_indent_y()); - short a3 = short(point.x + debug_menu_get_item_width()); - short a4 = short(((point.y + get_title_height()) + get_num_items_to_render() * get_item_height()) - (2.0f * debug_menu_get_item_indent_y())); - - debug_menu_draw_rect(a1, a2, a3, a4, unused, debug_real_argb_grey); + debug_menu_draw_rect(x0, y0, x1, y1, alpha, debug_real_argb_grey); } set_rectangle2d(&bounds, point.x, short((point.y + get_title_height()) + get_num_items_to_render() * get_item_height()), short(point.x + debug_menu_get_item_width()), bounds.y1); @@ -401,14 +400,13 @@ void c_debug_menu::render_global_caption(c_font_cache_base* font_cache, point2d { if (*debug_menu_get_caption(caption_index)) { - real unused = get_enabled() ? 0.7f : 0.1f; - - short a1 = point.x; - short a2 = short(((point.y + get_title_height()) + ((caption_index + 1) + get_num_items_to_render()) * get_item_height()) + debug_menu_get_item_indent_y()); - short a3 = short(point.x + debug_menu_get_item_width()); - short a4 = short(((point.y + get_title_height()) + ((caption_index + 2) + get_num_items_to_render()) * get_item_height()) - (2.0f * debug_menu_get_item_indent_y())); + short x0 = point.x; + short y0 = short(((point.y + get_title_height()) + ((caption_index + 1) + get_num_items_to_render()) * get_item_height()) + debug_menu_get_item_indent_y()); + short x1 = short(point.x + debug_menu_get_item_width()); + short y1 = short(((point.y + get_title_height()) + ((caption_index + 2) + get_num_items_to_render()) * get_item_height()) - (2.0f * debug_menu_get_item_indent_y())); + real alpha = get_enabled() ? 0.7f : 0.1f; - debug_menu_draw_rect(a1, a2, a3, a4, unused, debug_real_argb_grey); + debug_menu_draw_rect(x0, y0, x1, y1, alpha, debug_real_argb_grey); } if (bounds.x1 - bounds.x0 > 0 && bounds.y1 - bounds.y0 > 0) @@ -432,13 +430,13 @@ void c_debug_menu::render_items(c_font_cache_base* font_cache, point2d const& po c_debug_menu_item* item = get_item(item_index); if (item->get_active()) { - real unused = get_enabled() ? 0.7f : 0.1f; + short x0 = point.x; + short y0 = short(((point.y + get_title_height()) + (item_index - start_index) * get_item_height()) + debug_menu_get_item_indent_y()); + short x1 = short(point.x + debug_menu_get_item_width()); + short y1 = short((((point.y + get_title_height()) + (item_index - start_index + 1) * get_item_height())) - (2.0f * debug_menu_get_item_indent_y())); + real alpha = get_enabled() ? 0.7f : 0.1f; - short a1 = point.x; - short a2 = short(((point.y + get_title_height()) + (item_index - start_index) * get_item_height()) + debug_menu_get_item_indent_y()); - short a3 = short(point.x + debug_menu_get_item_width()); - short a4 = short((((point.y + get_title_height()) + (item_index - start_index + 1) * get_item_height())) - (2.0f * debug_menu_get_item_indent_y())); - debug_menu_draw_rect(a1, a2, a3, a4, unused, item->get_background_color()); + debug_menu_draw_rect(x0, y0, x1, y1, alpha, item->get_background_color()); } point2d item_point{}; @@ -451,13 +449,13 @@ void c_debug_menu::try_left() { ASSERT(get_selection() >= 0); - if (debug_menu_get_time() - m_left_time < get_menu_rate()) + if (debug_menu_get_time() - m_last_left < get_menu_rate()) return; if (!get_num_items()) return; - m_left_time = debug_menu_get_time(); + m_last_left = debug_menu_get_time(); notify_left(); if (get_selection() >= get_num_items()) @@ -470,13 +468,13 @@ void c_debug_menu::try_right() { ASSERT(get_selection() >= 0); - if (debug_menu_get_time() - m_right_time < get_menu_rate()) + if (debug_menu_get_time() - m_last_right < get_menu_rate()) return; if (!get_num_items()) return; - m_right_time = debug_menu_get_time(); + m_last_right = debug_menu_get_time(); notify_right(); if (get_selection() >= get_num_items()) @@ -488,7 +486,7 @@ void c_debug_menu::try_right() c_debug_menu::c_debug_menu(c_debug_menu* parent, char const* name) : m_name(NULL), m_caption(NULL), - m_parent(parent) + m_parent_ref(parent) { set_name(name ? name : "Menu???"); set_num_items(0); @@ -578,7 +576,7 @@ void c_debug_menu::set_caption(char const* caption) c_debug_menu* c_debug_menu::get_parent() { - return m_parent; + return m_parent_ref; } bool c_debug_menu::get_enabled() diff --git a/game/source/interface/debug_menu/debug_menu.hpp b/game/source/interface/debug_menu/debug_menu.hpp index 773996ff4..076ea4b37 100644 --- a/game/source/interface/debug_menu/debug_menu.hpp +++ b/game/source/interface/debug_menu/debug_menu.hpp @@ -82,14 +82,14 @@ class c_debug_menu protected: short m_num_items; short m_selection; - long m_up_time; - long m_down_time; - long m_left_time; - long m_right_time; - c_debug_menu_item* m_items[64]; + long m_last_up; + long m_last_down; + long m_last_left; + long m_last_right; + c_debug_menu_item* m_items[k_max_items]; char* m_name; char* m_caption; - c_debug_menu* m_parent; + c_debug_menu* m_parent_ref; bool m_enabled; }; diff --git a/game/source/interface/debug_menu/debug_menu_item.cpp b/game/source/interface/debug_menu/debug_menu_item.cpp index 3adc528f3..0de7dee36 100644 --- a/game/source/interface/debug_menu/debug_menu_item.cpp +++ b/game/source/interface/debug_menu/debug_menu_item.cpp @@ -10,16 +10,16 @@ c_debug_menu_item::~c_debug_menu_item() { - if (m_child) - m_child->~c_debug_menu(); - m_child = NULL; + if (m_child_ref) + m_child_ref->~c_debug_menu(); + m_child_ref = NULL; } void c_debug_menu_item::update() { } -void c_debug_menu_item::render(c_font_cache_base* font_cache, point2d const& point) +void c_debug_menu_item::render(c_font_cache_base* font_cache, point2d const& position) { real_argb_color const* color = global_real_argb_black; if (get_active() && get_menu()->get_enabled()) @@ -28,8 +28,8 @@ void c_debug_menu_item::render(c_font_cache_base* font_cache, point2d const& poi c_rasterizer_draw_string draw_string{}; rectangle2d bounds{}; - interface_get_current_display_settings(nullptr, nullptr, nullptr, &bounds); - set_rectangle2d(&bounds, point.x, point.y, bounds.x1, bounds.y1); + interface_get_current_display_settings(NULL, NULL, NULL, &bounds); + set_rectangle2d(&bounds, position.x, position.y, bounds.x1, bounds.y1); draw_string.set_bounds(&bounds); draw_string.set_color(color); @@ -86,8 +86,8 @@ real_argb_color const* c_debug_menu_item::get_background_color() c_debug_menu_item::c_debug_menu_item(c_debug_menu* menu, char const* name, c_debug_menu* child, bool active) : m_name(), - m_menu(menu), - m_child(child) + m_menu_ref(menu), + m_child_ref(child) { set_name(name ? name : "Item???"); set_active(active); @@ -110,12 +110,12 @@ void c_debug_menu_item::set_name(char const* name) c_debug_menu* c_debug_menu_item::get_menu() { - return m_menu; + return m_menu_ref; } c_debug_menu* c_debug_menu_item::get_child() { - return m_child; + return m_child_ref; } bool c_debug_menu_item::get_active() diff --git a/game/source/interface/debug_menu/debug_menu_item.hpp b/game/source/interface/debug_menu/debug_menu_item.hpp index 2358ea230..cbd8a638b 100644 --- a/game/source/interface/debug_menu/debug_menu_item.hpp +++ b/game/source/interface/debug_menu/debug_menu_item.hpp @@ -10,7 +10,7 @@ class c_debug_menu_item public: virtual ~c_debug_menu_item(); virtual void update(); - virtual void render(c_font_cache_base* font_cache, point2d const& point); + virtual void render(c_font_cache_base* font_cache, point2d const& position); virtual void notify_selected(); virtual void open(); virtual void notify_left(); @@ -39,9 +39,10 @@ class c_debug_menu_item protected: char* m_name; - c_debug_menu* m_menu; - c_debug_menu* m_child; + c_debug_menu* m_menu_ref; + c_debug_menu* m_child_ref; bool m_active; + //bool m_numbered; long m_data; }; diff --git a/game/source/interface/debug_menu/debug_menu_item_numbered.cpp b/game/source/interface/debug_menu/debug_menu_item_numbered.cpp index 3716b1fd9..f601977cf 100644 --- a/game/source/interface/debug_menu/debug_menu_item_numbered.cpp +++ b/game/source/interface/debug_menu/debug_menu_item_numbered.cpp @@ -9,13 +9,13 @@ c_debug_menu_item_numbered::~c_debug_menu_item_numbered() { } -void c_debug_menu_item_numbered::render(c_font_cache_base* font_cache, point2d const& point) +void c_debug_menu_item_numbered::render(c_font_cache_base* font_cache, point2d const& position) { - render_number(font_cache, point); + render_number(font_cache, position); - point2d next_point{}; - set_point2d(&next_point, point.x + get_indent(), point.y); - c_debug_menu_item::render(font_cache, next_point); + point2d super_class_render_position{}; + set_point2d(&super_class_render_position, position.x + get_indent(), position.y); + c_debug_menu_item::render(font_cache, super_class_render_position); } c_debug_menu_item_numbered::c_debug_menu_item_numbered(c_debug_menu* menu, char const* name, struct c_debug_menu* child) : @@ -23,9 +23,9 @@ c_debug_menu_item_numbered::c_debug_menu_item_numbered(c_debug_menu* menu, char { } -void c_debug_menu_item_numbered::render_number(c_font_cache_base* font_cache, point2d const& point) +void c_debug_menu_item_numbered::render_number(c_font_cache_base* font_cache, point2d const& position) { - char string[64]{}; + char buffer[64]{}; short index = get_index(); bool is_number = index < 10; @@ -34,24 +34,24 @@ void c_debug_menu_item_numbered::render_number(c_font_cache_base* font_cache, po c_rasterizer_draw_string draw_string{}; rectangle2d bounds{}; - interface_get_current_display_settings(nullptr, nullptr, nullptr, &bounds); + interface_get_current_display_settings(NULL, NULL, NULL, &bounds); ASSERT(!(is_number && is_letter)); if (is_number) { - csnzprintf(string, sizeof(string), " %s%d", index < 9 ? " " : "", get_index() + 1); + csnzprintf(buffer, sizeof(buffer), " %s%d", index < 9 ? " " : "", get_index() + 1); } else if (is_letter) { - csnzprintf(string, sizeof(string), "(%c)%d", index + 87, get_index() + 1); + csnzprintf(buffer, sizeof(buffer), "(%c)%d", index + 87, get_index() + 1); } else { - csnzprintf(string, sizeof(string), " %d", index + 1); + csnzprintf(buffer, sizeof(buffer), " %d", index + 1); } - set_rectangle2d(&bounds, point.x - 3, point.y, bounds.x1, bounds.y1); + set_rectangle2d(&bounds, position.x - 3, position.y, bounds.x1, bounds.y1); real_argb_color const* color = global_real_argb_black; if (get_active()) @@ -59,7 +59,7 @@ void c_debug_menu_item_numbered::render_number(c_font_cache_base* font_cache, po draw_string.set_color(color); draw_string.set_bounds(&bounds); - draw_string.draw(font_cache, string); + draw_string.draw(font_cache, buffer); } short c_debug_menu_item_numbered::get_indent() @@ -71,15 +71,15 @@ c_debug_menu_item_type::~c_debug_menu_item_type() { } -void c_debug_menu_item_type::render(c_font_cache_base* font_cache, point2d const& point) +void c_debug_menu_item_type::render(c_font_cache_base* font_cache, point2d const& position) { point2d value_point{}; point2d number_point{}; point2d next_point{}; - set_point2d(&value_point, point.x - 66, point.y); - set_point2d(&number_point, point.x, point.y); - set_point2d(&next_point, point.x + get_indent(), point.y); + set_point2d(&value_point, position.x - 66, position.y); + set_point2d(&number_point, position.x, position.y); + set_point2d(&next_point, position.x + get_indent(), position.y); render_value(font_cache, value_point); render_number(font_cache, number_point); @@ -91,7 +91,7 @@ void c_debug_menu_item_type::to_string(char* buffer, long buffer_size) csstrnzcpy(buffer, "overload toString", buffer_size); } -void c_debug_menu_item_type::render_value(c_font_cache_base* font_cache, point2d const& point) +void c_debug_menu_item_type::render_value(c_font_cache_base* font_cache, point2d const& position) { c_rasterizer_draw_string draw_string{}; @@ -99,18 +99,18 @@ void c_debug_menu_item_type::render_value(c_font_cache_base* font_cache, point2d to_string(buffer, sizeof(buffer)); rectangle2d bounds{}; - set_rectangle2d(&bounds, point.x + 2, point.y, point.x + 60, point.y + get_menu()->get_item_height()); + set_rectangle2d(&bounds, position.x + 2, position.y, position.x + 60, position.y + get_menu()->get_item_height()); if (get_active()) { - real unused = get_menu()->get_enabled() ? 0.7f : 0.1f; + real alpha = get_menu()->get_enabled() ? 0.7f : 0.1f; - short a1 = point.x; - short a2 = short(point.y + debug_menu_get_item_indent_y()); - short a3 = short(point.x + 60); - short a4 = short((point.y + get_menu()->get_item_height()) - (2.0f * debug_menu_get_item_indent_y())); + short x0 = position.x; + short y0 = short(position.y + debug_menu_get_item_indent_y()); + short x1 = short(position.x + 60); + short y1 = short((position.y + get_menu()->get_item_height()) - (2.0f * debug_menu_get_item_indent_y())); - debug_menu_draw_rect(a1, a2, a3, a4, unused, get_background_color()); + debug_menu_draw_rect(x0, y0, x1, y1, alpha, get_background_color()); } real_argb_color const* color = debug_real_argb_grey; @@ -173,7 +173,7 @@ void c_debug_menu_item_type_real::notify_left() c_debug_menu_item::notify_left(); if (!get_readonly()) - m_value.set(MIN(m_max_value, MAX(m_min_value, m_value.get() - m_inc_value))); + m_value.set(MIN(m_max, MAX(m_min, m_value.get() - m_inc))); } void c_debug_menu_item_type_real::notify_right() @@ -181,7 +181,7 @@ void c_debug_menu_item_type_real::notify_right() c_debug_menu_item::notify_right(); if (!get_readonly()) - m_value.set(MIN(m_max_value, MAX(m_min_value, m_value.get() + m_inc_value))); + m_value.set(MIN(m_max, MAX(m_min, m_value.get() + m_inc))); } void c_debug_menu_item_type_real::to_string(char* buffer, long buffer_size) @@ -189,12 +189,12 @@ void c_debug_menu_item_type_real::to_string(char* buffer, long buffer_size) csnzprintf(buffer, buffer_size, "%f", m_value.get()); } -c_debug_menu_item_type_real::c_debug_menu_item_type_real(c_debug_menu* menu, char const* name, bool readonly, char const* hs_global_name, real min_value, real max_value, real inc_value) : +c_debug_menu_item_type_real::c_debug_menu_item_type_real(c_debug_menu* menu, char const* name, bool readonly, char const* variable, real min, real max, real inc) : c_debug_menu_item_type(menu, name, readonly), - m_value(hs_global_name), - m_min_value(min_value), - m_max_value(max_value), - m_inc_value(inc_value) + m_value(variable), + m_min(min), + m_max(max), + m_inc(inc) { } @@ -207,7 +207,7 @@ void c_debug_menu_item_type_short::notify_left() c_debug_menu_item::notify_left(); if (!get_readonly()) - m_value.set(MIN(m_max_value, MAX(m_min_value, m_value.get() - m_inc_value))); + m_value.set(MIN(m_max, MAX(m_min, m_value.get() - m_inc))); } void c_debug_menu_item_type_short::notify_right() @@ -215,7 +215,7 @@ void c_debug_menu_item_type_short::notify_right() c_debug_menu_item::notify_right(); if (!get_readonly()) - m_value.set(MIN(m_max_value, MAX(m_min_value, m_value.get() + m_inc_value))); + m_value.set(MIN(m_max, MAX(m_min, m_value.get() + m_inc))); } void c_debug_menu_item_type_short::to_string(char* buffer, long buffer_size) @@ -223,12 +223,12 @@ void c_debug_menu_item_type_short::to_string(char* buffer, long buffer_size) csnzprintf(buffer, buffer_size, "%d", m_value.get()); } -c_debug_menu_item_type_short::c_debug_menu_item_type_short(c_debug_menu* menu, char const* name, bool readonly, char const* hs_global_name, short min_value, short max_value, short inc_value) : +c_debug_menu_item_type_short::c_debug_menu_item_type_short(c_debug_menu* menu, char const* name, bool readonly, char const* variable, short min, short max, short inc) : c_debug_menu_item_type(menu, name, readonly), - m_value(hs_global_name), - m_min_value(min_value), - m_max_value(max_value), - m_inc_value(inc_value) + m_value(variable), + m_min(min), + m_max(min), + m_inc(inc) { } @@ -241,7 +241,7 @@ void c_debug_menu_item_type_long::notify_left() c_debug_menu_item::notify_left(); if (!get_readonly()) - m_value.set(MIN(m_max_value, MAX(m_min_value, m_value.get() - m_inc_value))); + m_value.set(MIN(m_max, MAX(m_min, m_value.get() - m_inc))); } void c_debug_menu_item_type_long::notify_right() @@ -249,7 +249,7 @@ void c_debug_menu_item_type_long::notify_right() c_debug_menu_item::notify_right(); if (!get_readonly()) - m_value.set(MIN(m_max_value, MAX(m_min_value, m_value.get() + m_inc_value))); + m_value.set(MIN(m_max, MAX(m_min, m_value.get() + m_inc))); } void c_debug_menu_item_type_long::to_string(char* buffer, long buffer_size) @@ -257,11 +257,11 @@ void c_debug_menu_item_type_long::to_string(char* buffer, long buffer_size) csnzprintf(buffer, buffer_size, "%d", m_value.get()); } -c_debug_menu_item_type_long::c_debug_menu_item_type_long(c_debug_menu* menu, char const* name, bool readonly, char const* hs_global_name, long min_value, long max_value, long inc_value) : +c_debug_menu_item_type_long::c_debug_menu_item_type_long(c_debug_menu* menu, char const* name, bool readonly, char const* variable, long min, long max, long inc) : c_debug_menu_item_type(menu, name, readonly), - m_value(hs_global_name), - m_min_value(min_value), - m_max_value(max_value), - m_inc_value(inc_value) + m_value(variable), + m_min(min), + m_max(max), + m_inc(inc) { } diff --git a/game/source/interface/debug_menu/debug_menu_item_numbered.hpp b/game/source/interface/debug_menu/debug_menu_item_numbered.hpp index e27d9c265..212ec528a 100644 --- a/game/source/interface/debug_menu/debug_menu_item_numbered.hpp +++ b/game/source/interface/debug_menu/debug_menu_item_numbered.hpp @@ -10,12 +10,12 @@ class c_debug_menu_item_numbered : { public: virtual ~c_debug_menu_item_numbered(); - virtual void render(c_font_cache_base* font_cache, point2d const& point) override; + virtual void render(c_font_cache_base* font_cache, point2d const& position) override; c_debug_menu_item_numbered(c_debug_menu* menu, char const* name, c_debug_menu* child); protected: - void render_number(c_font_cache_base* font_cache, point2d const& point); + void render_number(c_font_cache_base* font_cache, point2d const& position); short get_indent(); }; @@ -25,9 +25,9 @@ struct c_debug_menu_item_type : { public: virtual ~c_debug_menu_item_type(); - virtual void render(c_font_cache_base* font_cache, point2d const& point) override; + virtual void render(c_font_cache_base* font_cache, point2d const& position) override; virtual void to_string(char* buffer, long buffer_size); - virtual void render_value(c_font_cache_base* font_cache, point2d const& point); + virtual void render_value(c_font_cache_base* font_cache, point2d const& position); c_debug_menu_item_type(c_debug_menu* menu, char const* name, bool readonly); @@ -49,7 +49,7 @@ class c_debug_menu_item_type_bool : virtual void to_string(char* buffer, long buffer_size) override; public: - c_debug_menu_item_type_bool(c_debug_menu* menu, char const* name, bool readonly, char const* hs_global_name); + c_debug_menu_item_type_bool(c_debug_menu* menu, char const* name, bool readonly, char const* variable); protected: c_debug_menu_value_hs_global_external m_value; @@ -67,13 +67,13 @@ class c_debug_menu_item_type_real : virtual void to_string(char* buffer, long buffer_size) override; public: - c_debug_menu_item_type_real(c_debug_menu* menu, char const* name, bool readonly, char const* hs_global_name, real min_value, real max_value, real inc_value); + c_debug_menu_item_type_real(c_debug_menu* menu, char const* name, bool readonly, char const* variable, real min, real max, real inc); protected: c_debug_menu_value_hs_global_external m_value; - real m_min_value; - real m_max_value; - real m_inc_value; + real m_min; + real m_max; + real m_inc; }; class c_debug_menu_item_type_short : @@ -88,13 +88,13 @@ class c_debug_menu_item_type_short : virtual void to_string(char* buffer, long buffer_size) override; public: - c_debug_menu_item_type_short(c_debug_menu* menu, char const* name, bool readonly, char const* hs_global_name, short min_value, short max_value, short inc_value); + c_debug_menu_item_type_short(c_debug_menu* menu, char const* name, bool readonly, char const* variable, short min, short max, short inc); protected: c_debug_menu_value_hs_global_external m_value; - short m_min_value; - short m_max_value; - short m_inc_value; + short m_min; + short m_max; + short m_inc; }; class c_debug_menu_item_type_long : @@ -109,12 +109,12 @@ class c_debug_menu_item_type_long : virtual void to_string(char* buffer, long buffer_size) override; public: - c_debug_menu_item_type_long(c_debug_menu* menu, char const* name, bool readonly, char const* hs_global_name, long min_value, long max_value, long inc_value); + c_debug_menu_item_type_long(c_debug_menu* menu, char const* name, bool readonly, char const* variable, long min, long max, long inc); protected: c_debug_menu_value_hs_global_external m_value; - long m_min_value; - long m_max_value; - long m_inc_value; + long m_min; + long m_max; + long m_inc; }; diff --git a/game/source/interface/debug_menu/debug_menu_main.cpp b/game/source/interface/debug_menu/debug_menu_main.cpp index 95d987daa..74de5c28c 100644 --- a/game/source/interface/debug_menu/debug_menu_main.cpp +++ b/game/source/interface/debug_menu/debug_menu_main.cpp @@ -41,13 +41,18 @@ class c_main_menu : struct s_debug_menu_globals { - c_debug_menu* root_menu; - c_debug_menu* active_menu; - char captions[DEBUG_MENU_NUM_GLOBAL_CAPTIONS][128]; - bool render; - gamepad_state current_gamepad_state; - gamepad_state last_gamepad_state; - dword open_time; + enum + { + k_str_length = 127 + }; + + c_debug_menu* m_main_menu; + c_debug_menu* m_active_menu; + char m_caption[DEBUG_MENU_NUM_GLOBAL_CAPTIONS][k_str_length + 1]; + bool m_do_render; + gamepad_state m_current_gamepad; + gamepad_state m_last_gamepad; + long open_menu_time; }; static_assert(sizeof(s_debug_menu_globals) == 0x488); @@ -74,26 +79,26 @@ bool g_debug_menu_rebuild_request = false; c_static_stack g_debug_menu_stack; -void debug_menu_draw_rect(short a1, short a2, short a3, short a4, real a5, real_argb_color const* color) +void debug_menu_draw_rect(short x0, short y0, short x1, short y1, real alpha, real_argb_color const* color) { point2d points[4]{}; - set_point2d(&points[0], a1, a4); - set_point2d(&points[1], a3, a4); - set_point2d(&points[2], a3, a2); - set_point2d(&points[3], a1, a2); + set_point2d(&points[0], x0, y1); + set_point2d(&points[1], x1, y1); + set_point2d(&points[2], x1, y0); + set_point2d(&points[3], x0, y0); rasterizer_quad_screenspace(points, real_argb_color_to_pixel32(color), nullptr, 0, false); } bool debug_menu_get_active() { - return g_debug_menu_globals.active_menu != NULL; + return g_debug_menu_globals.m_active_menu != NULL; } c_debug_menu* debug_menu_get_root() { - return g_debug_menu_globals.root_menu; + return g_debug_menu_globals.m_main_menu; } void debug_menu_initialize() @@ -106,14 +111,14 @@ void debug_menu_dispose() void debug_menu_initialize_for_new_map() { - g_debug_menu_globals.render = false; - g_debug_menu_globals.root_menu = NULL; - g_debug_menu_globals.active_menu = NULL; + g_debug_menu_globals.m_do_render = false; + g_debug_menu_globals.m_main_menu = NULL; + g_debug_menu_globals.m_active_menu = NULL; - g_debug_menu_globals.root_menu = new c_main_menu(); + g_debug_menu_globals.m_main_menu = new c_main_menu(); - csmemset(&g_debug_menu_globals.last_gamepad_state, 0, sizeof(g_debug_menu_globals.last_gamepad_state)); - csmemset(&g_debug_menu_globals.current_gamepad_state, 0, sizeof(g_debug_menu_globals.current_gamepad_state)); + csmemset(&g_debug_menu_globals.m_last_gamepad, 0, sizeof(g_debug_menu_globals.m_last_gamepad)); + csmemset(&g_debug_menu_globals.m_current_gamepad, 0, sizeof(g_debug_menu_globals.m_current_gamepad)); debug_menu_parse(debug_menu_get_root(), "debug_menu_init.txt"); debug_menu_parse(debug_menu_get_root(), "debug_menu_user_init.txt"); @@ -121,12 +126,12 @@ void debug_menu_initialize_for_new_map() void debug_menu_dispose_from_old_map() { - if (g_debug_menu_globals.root_menu) + if (g_debug_menu_globals.m_main_menu) { g_debug_menu_stack.resize(0); - g_debug_menu_globals.root_menu = NULL; + g_debug_menu_globals.m_main_menu = NULL; } - g_debug_menu_globals.active_menu = NULL; + g_debug_menu_globals.m_active_menu = NULL; if (g_user_interface_controller_globals.event_manager_suppress) g_user_interface_controller_globals.event_manager_suppress = false; @@ -134,19 +139,19 @@ void debug_menu_dispose_from_old_map() void debug_menu_update_current_gamepad_state() { - csmemset(&g_debug_menu_globals.current_gamepad_state, 0, sizeof(g_debug_menu_globals.current_gamepad_state)); + csmemset(&g_debug_menu_globals.m_current_gamepad, 0, sizeof(g_debug_menu_globals.m_current_gamepad)); for (long controller_index = first_controller(); controller_index != k_no_controller; controller_index = next_controller(controller_index)) { if (controller_index != k_no_controller) { if (gamepad_state const* state = input_get_gamepad_state(static_cast(controller_index))) - xor_buffers(&g_debug_menu_globals.current_gamepad_state, state, sizeof(gamepad_state)); + xor_buffers(&g_debug_menu_globals.m_current_gamepad, state, sizeof(gamepad_state)); } } - csmemset(&g_debug_menu_globals.current_gamepad_state.thumb_left, 0, 8); - csmemset(&g_debug_menu_globals.current_gamepad_state.trigger_msec_down, 0, 2); - csmemset(&g_debug_menu_globals.current_gamepad_state.max_trigger_msec_down, 0, 2); + csmemset(&g_debug_menu_globals.m_current_gamepad.thumb_left, 0, 8); + csmemset(&g_debug_menu_globals.m_current_gamepad.trigger_msec_down, 0, 2); + csmemset(&g_debug_menu_globals.m_current_gamepad.max_trigger_msec_down, 0, 2); } void debug_menu_update() @@ -156,7 +161,7 @@ void debug_menu_update() gamepad_state const& state = debug_menu_get_gamepad_state(); if (state.button_frames_down[_controller_button_left_stick]) { - g_debug_menu_globals.render = false; + g_debug_menu_globals.m_do_render = false; } else { @@ -201,10 +206,10 @@ void debug_menu_update() debug_menu_get_active_menu()->update(); } - g_debug_menu_globals.render = true; + g_debug_menu_globals.m_do_render = true; } - g_debug_menu_globals.last_gamepad_state = g_debug_menu_globals.current_gamepad_state; + g_debug_menu_globals.m_last_gamepad = g_debug_menu_globals.m_current_gamepad; } void debug_menu_open() @@ -212,14 +217,14 @@ void debug_menu_open() if (debug_menu_get_root() && !debug_menu_get_active()) { debug_menu_set_active_menu(debug_menu_get_root(), false); - g_debug_menu_globals.open_time = system_milliseconds(); + g_debug_menu_globals.open_menu_time = system_milliseconds(); } } void debug_menu_close() { if (debug_menu_get_root() && debug_menu_get_active() && - system_milliseconds() - g_debug_menu_globals.open_time > 100) + system_milliseconds() - g_debug_menu_globals.open_menu_time > 100) { debug_menu_set_active_menu(NULL, false); } @@ -237,24 +242,24 @@ void render_debug_debug_menu() if (restricted_region_locked_for_current_thread(1) && debug_menu_get_active() - && g_debug_menu_globals.render) + && g_debug_menu_globals.m_do_render) { c_font_cache_mt_safe font_cache{}; - point2d point{}; - set_point2d(&point, 180, 60); - debug_menu_get_active_menu()->render(&font_cache, point); + point2d position{}; + set_point2d(&position, 180, 60); + debug_menu_get_active_menu()->render(&font_cache, position); } } gamepad_state const& debug_menu_get_gamepad_state() { - return g_debug_menu_globals.current_gamepad_state; + return g_debug_menu_globals.m_current_gamepad; } gamepad_state const& debug_menu_get_last_gamepad_state() { - return g_debug_menu_globals.last_gamepad_state; + return g_debug_menu_globals.m_last_gamepad; } real debug_menu_get_item_margin() @@ -289,33 +294,37 @@ real debug_menu_get_item_indent_y() c_debug_menu* debug_menu_get_active_menu() { - return g_debug_menu_globals.active_menu; + return g_debug_menu_globals.m_active_menu; } -void debug_menu_set_active_menu(c_debug_menu* menu, bool active) +void debug_menu_set_active_menu(c_debug_menu* active_menu, bool dont_open) { - c_debug_menu* active_menu = g_debug_menu_globals.active_menu; - - bool v4 = g_debug_menu_globals.active_menu - && menu - && g_debug_menu_globals.active_menu->get_parent() - && g_debug_menu_globals.active_menu->get_parent() == menu; + c_debug_menu* current_active_menu = g_debug_menu_globals.m_active_menu; - g_debug_menu_globals.active_menu = menu; + bool menu_is_parent = 0; + if (g_debug_menu_globals.m_active_menu && active_menu) + { + if (c_debug_menu* parent = g_debug_menu_globals.m_active_menu->get_parent()) + { + if (parent == active_menu) + menu_is_parent = true; + } + } + g_debug_menu_globals.m_active_menu = active_menu; - if (menu) + if (active_menu) { - if (!v4 && !active) + if (!menu_is_parent && !dont_open) { - menu->open(); - menu = g_debug_menu_globals.active_menu; + active_menu->open(); + active_menu = g_debug_menu_globals.m_active_menu; g_user_interface_controller_globals.event_manager_suppress = true; } - menu->notify_activated(); + active_menu->notify_activated(); } - else if (active_menu) + else if (current_active_menu) { - active_menu->notify_closed(); + current_active_menu->notify_closed(); g_user_interface_controller_globals.event_manager_suppress = false; } @@ -327,14 +336,14 @@ void debug_menu_set_caption(short caption_index, char const* caption) { ASSERT(caption_index >= 0 && caption_index < DEBUG_MENU_NUM_GLOBAL_CAPTIONS); - csstrnzcpy(g_debug_menu_globals.captions[caption_index], caption, sizeof(*g_debug_menu_globals.captions)); + csstrnzcpy(g_debug_menu_globals.m_caption[caption_index], caption, sizeof(*g_debug_menu_globals.m_caption)); } char const* debug_menu_get_caption(short caption_index) { ASSERT(caption_index >= 0 && caption_index < DEBUG_MENU_NUM_GLOBAL_CAPTIONS); - return g_debug_menu_globals.captions[caption_index]; + return g_debug_menu_globals.m_caption[caption_index]; } long debug_menu_get_time() @@ -351,9 +360,9 @@ void* debug_menu_malloc(long size) return result; } -void xor_buffers(void* destination, void const* source, long buffer_size) +void xor_buffers(void* dest, void const* source, long count) { - for (long i = 0; i < buffer_size; i++) - ((byte*)destination)[i] ^= ((byte const*)source)[i]; + for (long i = 0; i < count; i++) + ((byte*)dest)[i] ^= ((byte const*)source)[i]; } diff --git a/game/source/interface/debug_menu/debug_menu_main.hpp b/game/source/interface/debug_menu/debug_menu_main.hpp index 3626d15d5..799b2534d 100644 --- a/game/source/interface/debug_menu/debug_menu_main.hpp +++ b/game/source/interface/debug_menu/debug_menu_main.hpp @@ -20,7 +20,7 @@ extern bool debug_menu_enabled; extern bool g_debug_menu_rebuild_request; extern c_static_stack g_debug_menu_stack; -extern void debug_menu_draw_rect(short a1, short a2, short a3, short a4, real a5, real_argb_color const* color); +extern void debug_menu_draw_rect(short x0, short y0, short x1, short y1, real alpha, real_argb_color const* color); extern bool debug_menu_get_active(); extern void debug_menu_initialize(); extern void debug_menu_dispose(); @@ -34,7 +34,7 @@ extern void render_debug_debug_menu(); extern gamepad_state const& debug_menu_get_gamepad_state(); extern gamepad_state const& debug_menu_get_last_gamepad_state(); extern c_debug_menu* debug_menu_get_active_menu(); -extern void debug_menu_set_active_menu(c_debug_menu* menu, bool active); +extern void debug_menu_set_active_menu(c_debug_menu* active_menu, bool dont_open); extern void debug_menu_set_caption(short caption_index, char const* caption); extern char const* debug_menu_get_caption(short caption_index); extern long debug_menu_get_time(); @@ -45,5 +45,5 @@ extern real debug_menu_get_title_height(); extern real debug_menu_get_item_indent_x(); extern real debug_menu_get_item_indent_y(); extern void* debug_menu_malloc(long size); -extern void xor_buffers(void* destination, void const* source, long buffer_size); +extern void xor_buffers(void* dest, void const* source, long count); diff --git a/game/source/interface/debug_menu/debug_menu_scroll.cpp b/game/source/interface/debug_menu/debug_menu_scroll.cpp index 9860bd4d0..ab4e5d259 100644 --- a/game/source/interface/debug_menu/debug_menu_scroll.cpp +++ b/game/source/interface/debug_menu/debug_menu_scroll.cpp @@ -45,14 +45,14 @@ void c_debug_menu_scroll::update() } } -void c_debug_menu_scroll::render(c_font_cache_base* font_cache, point2d const& point) +void c_debug_menu_scroll::render(c_font_cache_base* font_cache, point2d const& position) { - render_background(font_cache, point); - render_title(font_cache, point); - render_caption(font_cache, point); - render_global_caption(font_cache, point); + render_background(font_cache, position); + render_title(font_cache, position); + render_caption(font_cache, position); + render_global_caption(font_cache, position); if (get_num_visible() > 0) - render_items(font_cache, point, get_first(), get_first() + get_num_visible() - 1); + render_items(font_cache, position, get_first(), get_first() + get_num_visible() - 1); c_rasterizer_draw_string draw_string{}; @@ -62,7 +62,7 @@ void c_debug_menu_scroll::render(c_font_cache_base* font_cache, point2d const& p draw_string.set_color(debug_real_argb_tv_magenta); if (get_first() > 0) { - set_rectangle2d(&bounds, point.x, point.y + get_title_height(), bounds.x1, bounds.y1); + set_rectangle2d(&bounds, position.x, position.y + get_title_height(), bounds.x1, bounds.y1); draw_string.set_bounds(&bounds); draw_string.draw(font_cache, "^"); @@ -74,7 +74,7 @@ void c_debug_menu_scroll::render(c_font_cache_base* font_cache, point2d const& p if (get_num_items() - get_first() > get_num_visible()) { - set_rectangle2d(&bounds, point.x, (point.y + get_title_height()) + (get_num_visible() - 2) * get_item_height(), bounds.x1, bounds.y1); + set_rectangle2d(&bounds, position.x, (position.y + get_title_height()) + (get_num_visible() - 2) * get_item_height(), bounds.x1, bounds.y1); draw_string.set_bounds(&bounds); draw_string.draw(font_cache, "|"); @@ -163,10 +163,10 @@ void c_debug_menu_zone_sets::notify_down() update_caption(); } -c_debug_menu_zone_sets::c_debug_menu_zone_sets(c_debug_menu* parent, short num_visible, char const* name) : - c_debug_menu_scroll(parent, num_visible, name) +c_debug_menu_zone_sets::c_debug_menu_zone_sets(c_debug_menu* parent, short num_visible, char const* name_ptr) : + c_debug_menu_scroll(parent, num_visible, name_ptr) { - csstrnzcpy(m_some_string, "", sizeof(m_some_string)); + csstrnzcpy(m_caption, "", sizeof(m_caption)); for (s_scenario_zone_set& zone_set : global_scenario_get()->zone_sets) add_item(new c_debug_menu_item_numbered(this, zone_set.name.get_string(), NULL)); diff --git a/game/source/interface/debug_menu/debug_menu_scroll.hpp b/game/source/interface/debug_menu/debug_menu_scroll.hpp index 0543b0a41..ddafddb53 100644 --- a/game/source/interface/debug_menu/debug_menu_scroll.hpp +++ b/game/source/interface/debug_menu/debug_menu_scroll.hpp @@ -49,6 +49,6 @@ class c_debug_menu_zone_sets : void update_caption(); protected: - char m_some_string[128]; + char m_caption[128]; };