-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
memoryCard: options window, ability to remove card from slot
- Loading branch information
1 parent
1a4bc86
commit 4a423d4
Showing
7 changed files
with
109 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/platform/windows/gui/options/memory_card/memory_card.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
17 changes: 17 additions & 0 deletions
17
src/platform/windows/gui/options/memory_card/memory_card.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters