#include "RomInfo.h" #include #include "imgui.h" RomInfo::RomInfo( std::shared_ptr graphics, std::shared_ptr machine_state, std::shared_ptr callback_manager ) : graphics{std::move(graphics)}, machine_state{std::move(machine_state)}, callback_manager{std::move(callback_manager)} { this->callback_manager->rom_load_callback.push_back(std::bind( &RomInfo::on_rom_load, this, std::placeholders::_1 )); } void RomInfo::render() { if (ImGui::Begin("Chip-8 - ROM Info")) { if (!this->rom_path.empty()) { ImGui::Text("ROM: %s", this->rom_path.c_str()); } else { ImGui::Text("ROM: None"); } } ImGui::End(); } void RomInfo::on_rom_load(const std::string& rom_path) { std::filesystem::path home = SDL_GetUserFolder(SDL_FOLDER_HOME); std::filesystem::path path = rom_path; this->rom_path = "~/" + std::filesystem::relative(path, home).string(); }