Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlays: use signed short for position to allow negative positions #15204

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/Modules/cellGem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ static bool check_gem_num(const u32 gem_num)

static inline void draw_overlay_cursor(u32 gem_num, const gem_config::gem_controller&, s32 x_pos, s32 y_pos, s32 x_max, s32 y_max)
{
const u16 x = static_cast<u16>(x_pos / (x_max / static_cast<f32>(rsx::overlays::overlay::virtual_width)));
const u16 y = static_cast<u16>(y_pos / (y_max / static_cast<f32>(rsx::overlays::overlay::virtual_height)));
const s16 x = static_cast<s16>(x_pos / (x_max / static_cast<f32>(rsx::overlays::overlay::virtual_width)));
const s16 y = static_cast<s16>(y_pos / (y_max / static_cast<f32>(rsx::overlays::overlay::virtual_height)));

// Note: We shouldn't use sphere_rgb here. The game will set it to black in many cases.
const gem_config_data::gem_color& rgb = gem_config_data::gem_color::get_default_color(gem_num);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace rsx
{
const f64 percentage = std::clamp((this->m_last_value - static_cast<T>(m_minimum)) / std::fabs(m_maximum - m_minimum), 0.0, 1.0);
m_slider.set_pos(m_slider.x, this->y + (this->h - m_slider.h) / 2);
m_handle.set_pos(m_slider.x + static_cast<u16>(percentage * (m_slider.w - m_handle.w)), this->y + (this->h - m_handle.h) / 2);
m_handle.set_pos(m_slider.x + static_cast<s16>(percentage * (m_slider.w - m_handle.w)), this->y + (this->h - m_handle.h) / 2);

const auto set_label_text = [this]() -> void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace rsx
{
namespace overlays
{
home_menu_main_menu::home_menu_main_menu(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
home_menu_main_menu::home_menu_main_menu(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
: home_menu_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_TITLE))
{
is_current_page = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace rsx
{
struct home_menu_main_menu : public home_menu_page
{
home_menu_main_menu(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
home_menu_main_menu(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace rsx
{
namespace overlays
{
home_menu_message_box::home_menu_message_box(u16 x, u16 y, u16 width, u16 height)
home_menu_message_box::home_menu_message_box(s16 x, s16 y, u16 width, u16 height)
: overlay_element()
, m_accept_btn(120, 30)
, m_cancel_btn(120, 30)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace rsx
struct home_menu_message_box : public overlay_element
{
public:
home_menu_message_box(u16 x, u16 y, u16 width, u16 height);
home_menu_message_box(s16 x, s16 y, u16 width, u16 height);
compiled_resource& get_compiled() override;
void show(const std::string& text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
void hide();
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace rsx
{
namespace overlays
{
home_menu_page::home_menu_page(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent, const std::string& title)
home_menu_page::home_menu_page(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent, const std::string& title)
: list_view(width, height, use_separators)
, parent(parent)
, title(title)
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace rsx
struct home_menu_page : public list_view
{
public:
home_menu_page(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent, const std::string& text);
home_menu_page(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent, const std::string& text);

void set_current_page(home_menu_page* page);
home_menu_page* get_current_page(bool include_this);
Expand Down
16 changes: 8 additions & 8 deletions rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace rsx
{
namespace overlays
{
home_menu_settings::home_menu_settings(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
home_menu_settings::home_menu_settings(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
: home_menu_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_SETTINGS))
{
add_page(std::make_shared<home_menu_settings_audio>(x, y, width, height, use_separators, this));
Expand All @@ -24,7 +24,7 @@ namespace rsx
apply_layout();
}

home_menu_settings_audio::home_menu_settings_audio(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
home_menu_settings_audio::home_menu_settings_audio(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
: home_menu_settings_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_SETTINGS_AUDIO))
{
add_signed_slider(&g_cfg.audio.volume, "Master Volume", " %", 1);
Expand All @@ -39,7 +39,7 @@ namespace rsx
apply_layout();
}

home_menu_settings_video::home_menu_settings_video(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
home_menu_settings_video::home_menu_settings_video(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
: home_menu_settings_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_SETTINGS_VIDEO))
{
add_dropdown(&g_cfg.video.frame_limit, "Frame Limit");
Expand All @@ -56,7 +56,7 @@ namespace rsx
apply_layout();
}

home_menu_settings_advanced::home_menu_settings_advanced(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
home_menu_settings_advanced::home_menu_settings_advanced(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
: home_menu_settings_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_SETTINGS_ADVANCED))
{
add_signed_slider(&g_cfg.core.preferred_spu_threads, "Preferred SPU Threads", "", 1);
Expand All @@ -71,7 +71,7 @@ namespace rsx
apply_layout();
}

home_menu_settings_input::home_menu_settings_input(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
home_menu_settings_input::home_menu_settings_input(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
: home_menu_settings_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_SETTINGS_INPUT))
{
add_checkbox(&g_cfg.io.background_input_enabled, "Background Input Enabled");
Expand All @@ -89,7 +89,7 @@ namespace rsx
apply_layout();
}

home_menu_settings_overlays::home_menu_settings_overlays(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
home_menu_settings_overlays::home_menu_settings_overlays(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
: home_menu_settings_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_SETTINGS_OVERLAYS))
{
add_checkbox(&g_cfg.misc.show_trophy_popups, "Show Trophy Popups");
Expand All @@ -99,7 +99,7 @@ namespace rsx
apply_layout();
}

home_menu_settings_performance_overlay::home_menu_settings_performance_overlay(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
home_menu_settings_performance_overlay::home_menu_settings_performance_overlay(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
: home_menu_settings_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY))
{
add_checkbox(&g_cfg.video.perf_overlay.perf_overlay_enabled, "Enable Performance Overlay");
Expand All @@ -125,7 +125,7 @@ namespace rsx
apply_layout();
}

home_menu_settings_debug::home_menu_settings_debug(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
home_menu_settings_debug::home_menu_settings_debug(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
: home_menu_settings_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_SETTINGS_DEBUG))
{
add_checkbox(&g_cfg.video.overlay, "Debug Overlay");
Expand Down
16 changes: 8 additions & 8 deletions rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace rsx
struct home_menu_settings : public home_menu_page
{
public:
home_menu_settings(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
home_menu_settings(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);

private:
std::vector<std::shared_ptr<home_menu_page>> m_settings_pages;
Expand Down Expand Up @@ -207,37 +207,37 @@ namespace rsx

struct home_menu_settings_audio : public home_menu_settings_page
{
home_menu_settings_audio(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
home_menu_settings_audio(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
};

struct home_menu_settings_video : public home_menu_settings_page
{
home_menu_settings_video(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
home_menu_settings_video(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
};

struct home_menu_settings_advanced : public home_menu_settings_page
{
home_menu_settings_advanced(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
home_menu_settings_advanced(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
};

struct home_menu_settings_input : public home_menu_settings_page
{
home_menu_settings_input(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
home_menu_settings_input(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
};

struct home_menu_settings_overlays : public home_menu_settings_page
{
home_menu_settings_overlays(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
home_menu_settings_overlays(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
};

struct home_menu_settings_performance_overlay : public home_menu_settings_page
{
home_menu_settings_performance_overlay(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
home_menu_settings_performance_overlay(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
};

struct home_menu_settings_debug : public home_menu_settings_page
{
home_menu_settings_debug(u16 x, u16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
home_menu_settings_debug(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
};
}
}
16 changes: 8 additions & 8 deletions rpcs3/Emu/RSX/Overlays/overlay_controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ namespace rsx

void overlay_element::translate(s16 _x, s16 _y)
{
x = static_cast<u16>(x + _x);
y = static_cast<u16>(y + _y);
x += _x;
y += _y;

is_compiled = false;
}
Expand All @@ -295,8 +295,8 @@ namespace rsx
{
if (origin_scaling)
{
x = static_cast<u16>(_x * x);
y = static_cast<u16>(_y * y);
x = static_cast<s16>(_x * x);
y = static_cast<s16>(_y * y);
}

w = static_cast<u16>(_x * w);
Expand All @@ -305,7 +305,7 @@ namespace rsx
is_compiled = false;
}

void overlay_element::set_pos(u16 _x, u16 _y)
void overlay_element::set_pos(s16 _x, s16 _y)
{
x = _x;
y = _y;
Expand Down Expand Up @@ -646,10 +646,10 @@ namespace rsx
itm->translate(_x, _y);
}

void layout_container::set_pos(u16 _x, u16 _y)
void layout_container::set_pos(s16 _x, s16 _y)
{
s16 dx = static_cast<s16>(_x - x);
s16 dy = static_cast<s16>(_y - y);
s16 dx = _x - x;
s16 dy = _y - y;
translate(dx, dy);
}

Expand Down
10 changes: 5 additions & 5 deletions rpcs3/Emu/RSX/Overlays/overlay_controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ namespace rsx
right
};

u16 x = 0;
u16 y = 0;
s16 x = 0;
s16 y = 0;
u16 w = 0;
u16 h = 0;

Expand Down Expand Up @@ -178,7 +178,7 @@ namespace rsx
virtual void refresh();
virtual void translate(s16 _x, s16 _y);
virtual void scale(f32 _x, f32 _y, bool origin_scaling);
virtual void set_pos(u16 _x, u16 _y);
virtual void set_pos(s16 _x, s16 _y);
virtual void set_size(u16 _w, u16 _h);
virtual void set_padding(u16 left, u16 right, u16 top, u16 bottom);
virtual void set_padding(u16 padding);
Expand Down Expand Up @@ -210,7 +210,7 @@ namespace rsx
layout_container();

void translate(s16 _x, s16 _y) override;
void set_pos(u16 _x, u16 _y) override;
void set_pos(s16 _x, s16 _y) override;

compiled_resource& get_compiled() override;

Expand Down Expand Up @@ -315,7 +315,7 @@ namespace rsx

public:
graph();
void set_pos(u16 _x, u16 _y) override;
void set_pos(s16 _x, s16 _y) override;
void set_size(u16 _w, u16 _h) override;
void set_title(const char* title);
void set_font(const char* font_name, u16 font_size) override;
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/RSX/Overlays/overlay_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace rsx
m_cross_v.set_size(1, 15);
}

bool cursor_item::set_position(u16 x, u16 y)
bool cursor_item::set_position(s16 x, s16 y)
{
if (m_x == x && m_y == y)
{
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace rsx
return cr;
}

void cursor_manager::update_cursor(u32 id, u16 x, u16 y, const color4f& color, u64 duration_us, bool force_update)
void cursor_manager::update_cursor(u32 id, s16 x, s16 y, const color4f& color, u64 duration_us, bool force_update)
{
std::lock_guard lock(m_mutex);

Expand All @@ -136,7 +136,7 @@ namespace rsx
}
}

void set_cursor(u32 id, u16 x, u16 y, const color4f& color, u64 duration_us, bool force_update)
void set_cursor(u32 id, s16 x, s16 y, const color4f& color, u64 duration_us, bool force_update)
{
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
{
Expand Down
10 changes: 5 additions & 5 deletions rpcs3/Emu/RSX/Overlays/overlay_cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace rsx
cursor_item();

void set_expiration(u64 expiration_time);
bool set_position(u16 x, u16 y);
bool set_position(s16 x, s16 y);
bool set_color(color4f color);

bool update_visibility(u64 time);
Expand All @@ -32,8 +32,8 @@ namespace rsx
overlay_element m_cross_h{};
overlay_element m_cross_v{};
u64 m_expiration_time = 0;
u16 m_x = 0;
u16 m_y = 0;
s16 m_x = 0;
s16 m_y = 0;
};

class cursor_manager final : public overlay
Expand All @@ -42,14 +42,14 @@ namespace rsx
void update(u64 timestamp_us) override;
compiled_resource get_compiled() override;

void update_cursor(u32 id, u16 x, u16 y, const color4f& color, u64 duration_us, bool force_update);
void update_cursor(u32 id, s16 x, s16 y, const color4f& color, u64 duration_us, bool force_update);

private:
shared_mutex m_mutex;
std::map<u32, cursor_item> m_cursors;
};

void set_cursor(u32 id, u16 x, u16 y, const color4f& color, u64 duration_us, bool force_update);
void set_cursor(u32 id, s16 x, s16 y, const color4f& color, u64 duration_us, bool force_update);

} // namespace overlays
} // namespace rsx
7 changes: 4 additions & 3 deletions rpcs3/Emu/RSX/Overlays/overlay_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace rsx
return m_text.text == text;
}

void message_item::set_pos(u16 _x, u16 _y)
void message_item::set_pos(s16 _x, s16 _y)
{
rounded_rect::set_pos(_x, _y);
m_text.set_pos(_x + m_margin, y + m_margin);
Expand Down Expand Up @@ -108,7 +108,7 @@ namespace rsx
return compiled_resources;
}

void message_item::update(usz index, u64 timestamp_us, u16 y_offset)
void message_item::update(usz index, u64 timestamp_us, s16 y_offset)
{
if (m_cur_pos != index)
{
Expand Down Expand Up @@ -186,7 +186,8 @@ namespace rsx

// Render reversed list. Oldest entries are furthest from the border
constexpr u16 spacing = 4;
u16 y_offset = 8, index = 0;
s16 y_offset = 8;
usz index = 0;
for (auto it = vis_set.rbegin(); it != vis_set.rend(); ++it, ++index)
{
if (origin == message_pin_location::top) [[ likely ]]
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/RSX/Overlays/overlay_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace rsx
public:
template <typename T>
message_item(T msg_id, u64 expiration, std::shared_ptr<atomic_t<u32>> refs, std::shared_ptr<overlay_element> icon = {});
void update(usz index, u64 timestamp_us, u16 y_offset);
void set_pos(u16 _x, u16 _y) override;
void update(usz index, u64 timestamp_us, s16 y_offset);
void set_pos(s16 _x, s16 _y) override;

void reset_expiration();
u64 get_expiration() const;
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ namespace rsx
num_progress_bars = type.progress_bar_count;
if (num_progress_bars)
{
u16 offset = 58;
s16 offset = 58;
::at32(progress_bars, 0).set_pos(240, 412);

if (num_progress_bars > 1)
Expand Down