fix: Texture loading from romfs
This commit is contained in:
parent
32e05cc62f
commit
550392c8d6
@ -2,8 +2,10 @@
|
||||
|
||||
#include <hex.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <span>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
|
@ -113,10 +113,8 @@ namespace hex::init {
|
||||
|
||||
bool WindowSplash::loop() {
|
||||
// Load splash screen image from romfs
|
||||
auto splashBackground = romfs::get("splash_background.png");
|
||||
auto splashText = romfs::get("splash_text.png");
|
||||
ImGui::Texture splashBackgroundTexture = ImGui::Texture(reinterpret_cast<const ImU8 *>(splashBackground.data()), splashBackground.size());
|
||||
ImGui::Texture splashTextTexture = ImGui::Texture(reinterpret_cast<const ImU8 *>(splashText.data()), splashText.size());
|
||||
ImGui::Texture splashBackgroundTexture = ImGui::Texture(romfs::get("splash_background.png").span());
|
||||
ImGui::Texture splashTextTexture = ImGui::Texture(romfs::get("splash_text.png").span());
|
||||
|
||||
// If the image couldn't be loaded correctly, something went wrong during the build process
|
||||
// Close the application since this would lead to errors later on anyway.
|
||||
|
@ -85,8 +85,7 @@ namespace hex {
|
||||
this->setupNativeWindow();
|
||||
this->registerEventHandlers();
|
||||
|
||||
auto logoData = romfs::get("logo.png");
|
||||
this->m_logoTexture = ImGui::Texture(reinterpret_cast<const ImU8 *>(logoData.data()), logoData.size());
|
||||
this->m_logoTexture = ImGui::Texture(romfs::get("logo.png").span());
|
||||
|
||||
ContentRegistry::Settings::impl::store();
|
||||
EventManager::post<EventSettingsChanged>();
|
||||
|
@ -527,10 +527,7 @@ namespace hex::plugin::builtin {
|
||||
static std::mutex addressMutex;
|
||||
static TaskHolder addressTask;
|
||||
|
||||
static auto mapTexture = [] {
|
||||
auto image = romfs::get("assets/common/map.jpg");
|
||||
return ImGui::Texture(reinterpret_cast<const ImU8 *>(image.data()), image.size());
|
||||
}();
|
||||
static auto mapTexture = ImGui::Texture(romfs::get("assets/common/map.jpg").span());
|
||||
static ImVec2 mapSize = scaled(ImVec2(500, 500 / mapTexture.getAspectRatio()));
|
||||
|
||||
if (shouldReset) {
|
||||
|
@ -33,8 +33,6 @@ namespace hex::plugin::builtin {
|
||||
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.menu.help.ask_for_help" }, 4000, CTRLCMD + SHIFT + Keys::D, [] {
|
||||
PopupDocsQuestion::open();
|
||||
});
|
||||
|
||||
this->m_logoTexture = ImGui::Texture(romfs::get("assets/common/logo.png").span());
|
||||
}
|
||||
|
||||
static void link(const std::string &name, const std::string &author, const std::string &url) {
|
||||
@ -63,6 +61,9 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
// Draw the ImHex icon
|
||||
if (!this->m_logoTexture.isValid())
|
||||
this->m_logoTexture = ImGui::Texture(romfs::get("assets/common/logo.png").span());
|
||||
|
||||
ImGui::Image(this->m_logoTexture, scaled({ 64, 64 }));
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
|
@ -422,9 +422,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
(void)EventManager::subscribe<RequestChangeTheme>([](const std::string &theme) {
|
||||
auto changeTexture = [&](const std::string &path) {
|
||||
auto textureData = romfs::get(path);
|
||||
|
||||
return ImGui::Texture(reinterpret_cast<const ImU8*>(textureData.data()), textureData.size());
|
||||
return ImGui::Texture(romfs::get(path).span());
|
||||
};
|
||||
|
||||
ThemeManager::changeTheme(theme);
|
||||
|
Loading…
x
Reference in New Issue
Block a user