Permalink
Please
sign in to comment.
Browse files
memoryCard: options window, ability to remove card from slot
- Loading branch information
Showing
with
109 additions
and 16 deletions.
- +1 β1 src/config.cpp
- +5 β0 src/device/controller/peripherals/memory_card.cpp
- +8 β7 src/device/controller/peripherals/memory_card.h
- +6 β0 src/platform/windows/gui/gui.cpp
- +43 β0 src/platform/windows/gui/options/memory_card/memory_card.cpp
- +17 β0 src/platform/windows/gui/options/memory_card/memory_card.h
- +29 β8 src/platform/windows/main.cpp
@@ -0,0 +1,43 @@ | ||
#include "memory_card.h" | ||
#include <imgui.h> | ||
#include <misc/cpp/imgui_stdlib.h> | ||
#include "config.h" | ||
#include "system.h" | ||
#include "utils/string.h" | ||
|
||
namespace gui::options::memory_card { | ||
void MemoryCard::memoryCardWindow(System* sys) { | ||
if (loadPaths) { | ||
for (size_t i = 0; i < cardPaths.size(); i++) { | ||
cardPaths[i] = config["memoryCard"][std::to_string(i + 1)]; | ||
} | ||
loadPaths = false; | ||
} | ||
ImGui::Begin("MemoryCard", &memoryCardWindowOpen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse); | ||
ImGui::BeginTabBar("##memory_select"); | ||
|
||
for (size_t i = 0; i < sys->controller->card.size(); i++) { | ||
if (ImGui::BeginTabItem(string_format("Slot %d", i + 1).c_str())) { | ||
if (ImGui::InputText("Path", &cardPaths[i])) { | ||
config["memoryCard"][std::to_string(i + 1)] = cardPaths[i]; | ||
} | ||
// TODO: Reload contents on change? | ||
// TODO: Check if card exists, override or reload? | ||
|
||
bool inserted = sys->controller->card[i]->inserted; | ||
if (ImGui::Checkbox("Inserted", &inserted)) { | ||
sys->controller->card[0]->inserted = inserted; | ||
} | ||
|
||
ImGui::EndTabItem(); | ||
} | ||
} | ||
|
||
ImGui::EndTabBar(); | ||
ImGui::End(); | ||
} | ||
|
||
void MemoryCard::displayWindows(System* sys) { | ||
if (memoryCardWindowOpen) memoryCardWindow(sys); | ||
} | ||
} // namespace gui::options::memory_card |
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
#include <array> | ||
#include <string> | ||
|
||
struct System; | ||
|
||
namespace gui::options::memory_card { | ||
class MemoryCard { | ||
bool loadPaths = true; | ||
std::array<std::string, 2> cardPaths; | ||
void memoryCardWindow(System* sys); | ||
|
||
public: | ||
bool memoryCardWindowOpen = false; | ||
void displayWindows(System* sys); | ||
}; | ||
} // namespace gui::options::memory_card |
0 comments on commit
4a423d4