overlays: Unified icon loading logic
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "stdafx.h"
|
||||
#include "overlay_home_icons.h"
|
||||
|
||||
#include "Emu/RSX/Overlays/overlay_controls.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace rsx::overlays::home_menu
|
||||
@@ -44,8 +46,8 @@ namespace rsx::overlays::home_menu
|
||||
|
||||
void load_icon(fa_icon icon)
|
||||
{
|
||||
const std::string image_path = fmt::format("%s/Icons/ui/home/32/%s", fs::get_config_dir(), fa_icon_to_filename(icon));
|
||||
g_icons_cache[icon] = std::make_unique<image_info>(image_path);
|
||||
const std::string image_path = fmt::format("home/32/%s", fa_icon_to_filename(icon));
|
||||
g_icons_cache[icon] = rsx::overlays::resource_config::load_icon(image_path);
|
||||
}
|
||||
|
||||
const image_info* get_icon(fa_icon icon)
|
||||
|
||||
@@ -314,7 +314,6 @@ namespace rsx
|
||||
|
||||
void home_menu_page::set_size(u16 _w, u16 _h)
|
||||
{
|
||||
const auto prev_w = w;
|
||||
list_view::set_size(_w, _h);
|
||||
|
||||
for (auto& entry : m_items)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace rsx
|
||||
m_tabs->set_selected_tab(0);
|
||||
}
|
||||
|
||||
void home_menu_settings::add_page(home_menu::fa_icon icon, std::shared_ptr<home_menu_page> page)
|
||||
void home_menu_settings::add_page(home_menu::fa_icon /*icon*/, std::shared_ptr<home_menu_page> page)
|
||||
{
|
||||
auto panel = std::static_pointer_cast<overlay_element>(page);
|
||||
page->on_deactivate();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "Emu/RSX/Overlays/overlay_controls.h"
|
||||
#include "overlay_animated_icon.h"
|
||||
|
||||
#include "Utilities/File.h"
|
||||
|
||||
#include "Emu/Cell/timers.hpp"
|
||||
|
||||
namespace rsx
|
||||
@@ -11,8 +10,7 @@ namespace rsx
|
||||
{
|
||||
animated_icon::animated_icon(const char* icon_name)
|
||||
{
|
||||
const std::string image_path = fmt::format("%s/Icons/ui/%s", fs::get_config_dir(), icon_name);
|
||||
m_icon = std::make_unique<image_info>(image_path);
|
||||
m_icon = overlays::resource_config::load_icon(icon_name);
|
||||
set_raw_image(m_icon.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -108,28 +108,10 @@ namespace rsx
|
||||
{
|
||||
}
|
||||
|
||||
void resource_config::load_files()
|
||||
{
|
||||
const std::array<std::string, 15> texture_resource_files
|
||||
{
|
||||
"fade_top.png",
|
||||
"fade_bottom.png",
|
||||
"select.png",
|
||||
"start.png",
|
||||
"cross.png",
|
||||
"circle.png",
|
||||
"triangle.png",
|
||||
"square.png",
|
||||
"L1.png",
|
||||
"R1.png",
|
||||
"L2.png",
|
||||
"R2.png",
|
||||
"save.png",
|
||||
"new.png",
|
||||
"spinner-24.png"
|
||||
};
|
||||
for (const std::string& res : texture_resource_files)
|
||||
std::unique_ptr<image_info> resource_config::load_icon(std::string_view relative_path)
|
||||
{
|
||||
const std::string res = relative_path.data();
|
||||
|
||||
// First check the global config dir
|
||||
const std::string image_path = fs::get_config_dir() + "Icons/ui/" + res;
|
||||
auto info = std::make_unique<image_info>(image_path);
|
||||
@@ -206,6 +188,32 @@ namespace rsx
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void resource_config::load_files()
|
||||
{
|
||||
const std::array<std::string, 15> texture_resource_files
|
||||
{
|
||||
"fade_top.png",
|
||||
"fade_bottom.png",
|
||||
"select.png",
|
||||
"start.png",
|
||||
"cross.png",
|
||||
"circle.png",
|
||||
"triangle.png",
|
||||
"square.png",
|
||||
"L1.png",
|
||||
"R1.png",
|
||||
"L2.png",
|
||||
"R2.png",
|
||||
"save.png",
|
||||
"new.png",
|
||||
"spinner-24.png"
|
||||
};
|
||||
for (const std::string& res : texture_resource_files)
|
||||
{
|
||||
auto info = load_icon(res);
|
||||
texture_raw_data.push_back(std::move(info));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,8 @@ namespace rsx
|
||||
|
||||
void load_files();
|
||||
void free_resources();
|
||||
|
||||
static std::unique_ptr<image_info> load_icon(std::string_view relative_path);
|
||||
};
|
||||
|
||||
struct compiled_resource
|
||||
|
||||
Reference in New Issue
Block a user