summaryrefslogtreecommitdiff
path: root/src/port/Engine.cpp
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2025-01-15 19:29:43 -0600
committerKiritoDv <kiritodev01@gmail.com>2025-01-15 19:29:43 -0600
commit4a9a76f945f872eef65f8cfaf51b23cf25f44e03 (patch)
tree4ba48c97d6371677a9845cdc0e9ea4b7f2acc3e3 /src/port/Engine.cpp
parenta0a591a965c8d3299c95ac2d69b0eb52038f3087 (diff)
Added messages on extraction
Diffstat (limited to 'src/port/Engine.cpp')
-rw-r--r--src/port/Engine.cpp56
1 files changed, 45 insertions, 11 deletions
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp
index 65ba8570..c088e0e5 100644
--- a/src/port/Engine.cpp
+++ b/src/port/Engine.cpp
@@ -69,8 +69,16 @@ GameEngine::GameEngine() {
if (std::filesystem::exists(main_path)) {
archiveFiles.push_back(main_path);
} else {
- GenAssetFile();
- archiveFiles.push_back(main_path);
+ if (ShowYesNoBox("No O2R Files", "No O2R files found. Generate one now?") == IDYES) {
+ if(!GenAssetFile()){
+ ShowMessage("Error", "An error occured, no O2R file was generated.\n\nExiting...");
+ exit(1);
+ } else {
+ archiveFiles.push_back(main_path);
+ }
+ } else {
+ exit(1);
+ }
}
if (std::filesystem::exists(assets_path)) {
@@ -197,21 +205,23 @@ GameEngine::GameEngine() {
context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets);
}
-void GameEngine::GenAssetFile() {
+bool GameEngine::GenAssetFile() {
auto extractor = new GameExtractor();
if (!extractor->SelectGameFromUI()) {
- ShowMessage("Extractor", "No game selected.");
- return;
- }
- if (!extractor->ValidateChecksum()) {
- ShowMessage("Extractor", "Invalid checksum.");
- return;
+ ShowMessage("Error", "No ROM selected.\n\nExiting...");
+ exit(1);
}
- if (!extractor->GenerateOTR()) {
- ShowMessage("Extractor", "Failed to generate OTR.");
+ auto game = extractor->ValidateChecksum();
+ if (!game.has_value()) {
+ ShowMessage("Unsupported ROM", "The provided ROM is not supported.\n\nCheck the readme for a list of supported versions.");
+ exit(1);
}
+
+ ShowMessage(("Found " + game.value()).c_str(), "The extraction process will now begin.\n\nThis may take a few minutes.");
+
+ return extractor->GenerateOTR();
}
void GameEngine::Create() {
@@ -457,6 +467,30 @@ void GameEngine::ShowMessage(const char* title, const char* message) {
#endif
}
+int GameEngine::ShowYesNoBox(const char* title, const char* box) {
+ int ret;
+#ifdef _WIN32
+ ret = MessageBoxA(nullptr, box, title, MB_YESNO | MB_ICONQUESTION);
+#else
+ SDL_MessageBoxData boxData = { 0 };
+ SDL_MessageBoxButtonData buttons[2] = { { 0 } };
+
+ buttons[0].buttonid = IDYES;
+ buttons[0].text = "Yes";
+ buttons[0].flags = SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
+ buttons[1].buttonid = IDNO;
+ buttons[1].text = "No";
+ buttons[1].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
+ boxData.numbuttons = 2;
+ boxData.flags = SDL_MESSAGEBOX_INFORMATION;
+ boxData.message = box;
+ boxData.title = title;
+ boxData.buttons = buttons;
+ SDL_ShowMessageBox(&boxData, &ret);
+#endif
+ return ret;
+}
+
extern "C" uint32_t GameEngine_GetSampleRate() {
auto player = Ship::Context::GetInstance()->GetAudio()->GetAudioPlayer();
if (player == nullptr) {