UI for rom info
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "RomInfo.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
RomInfo::RomInfo(
|
||||
@@ -10,11 +12,33 @@ RomInfo::RomInfo(
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user