mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-02-02 16:23:57 +03:00
Added messages on extraction
This commit is contained in:
parent
a0a591a965
commit
4a9a76f945
@ -69,8 +69,16 @@ GameEngine::GameEngine() {
|
|||||||
if (std::filesystem::exists(main_path)) {
|
if (std::filesystem::exists(main_path)) {
|
||||||
archiveFiles.push_back(main_path);
|
archiveFiles.push_back(main_path);
|
||||||
} else {
|
} else {
|
||||||
GenAssetFile();
|
if (ShowYesNoBox("No O2R Files", "No O2R files found. Generate one now?") == IDYES) {
|
||||||
archiveFiles.push_back(main_path);
|
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)) {
|
if (std::filesystem::exists(assets_path)) {
|
||||||
@ -197,21 +205,23 @@ GameEngine::GameEngine() {
|
|||||||
context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets);
|
context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameEngine::GenAssetFile() {
|
bool GameEngine::GenAssetFile() {
|
||||||
auto extractor = new GameExtractor();
|
auto extractor = new GameExtractor();
|
||||||
|
|
||||||
if (!extractor->SelectGameFromUI()) {
|
if (!extractor->SelectGameFromUI()) {
|
||||||
ShowMessage("Extractor", "No game selected.");
|
ShowMessage("Error", "No ROM selected.\n\nExiting...");
|
||||||
return;
|
exit(1);
|
||||||
}
|
|
||||||
if (!extractor->ValidateChecksum()) {
|
|
||||||
ShowMessage("Extractor", "Invalid checksum.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extractor->GenerateOTR()) {
|
auto game = extractor->ValidateChecksum();
|
||||||
ShowMessage("Extractor", "Failed to generate OTR.");
|
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() {
|
void GameEngine::Create() {
|
||||||
@ -457,6 +467,30 @@ void GameEngine::ShowMessage(const char* title, const char* message) {
|
|||||||
#endif
|
#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() {
|
extern "C" uint32_t GameEngine_GetSampleRate() {
|
||||||
auto player = Ship::Context::GetInstance()->GetAudio()->GetAudioPlayer();
|
auto player = Ship::Context::GetInstance()->GetAudio()->GetAudioPlayer();
|
||||||
if (player == nullptr) {
|
if (player == nullptr) {
|
||||||
|
@ -15,7 +15,12 @@ struct GamePool {
|
|||||||
#include <Fast3D/gfx_pc.h>
|
#include <Fast3D/gfx_pc.h>
|
||||||
#include "libultraship/src/Context.h"
|
#include "libultraship/src/Context.h"
|
||||||
|
|
||||||
|
#ifndef IDYES
|
||||||
|
#define IDYES 6
|
||||||
|
#endif
|
||||||
|
#ifndef IDNO
|
||||||
|
#define IDNO 7
|
||||||
|
#endif
|
||||||
|
|
||||||
class GameEngine {
|
class GameEngine {
|
||||||
public:
|
public:
|
||||||
@ -24,7 +29,7 @@ class GameEngine {
|
|||||||
std::shared_ptr<Ship::Context> context;
|
std::shared_ptr<Ship::Context> context;
|
||||||
|
|
||||||
GameEngine();
|
GameEngine();
|
||||||
static void GenAssetFile();
|
static bool GenAssetFile();
|
||||||
static void Create();
|
static void Create();
|
||||||
void StartFrame() const;
|
void StartFrame() const;
|
||||||
static void HandleAudioThread();
|
static void HandleAudioThread();
|
||||||
@ -38,6 +43,8 @@ class GameEngine {
|
|||||||
static void Destroy();
|
static void Destroy();
|
||||||
static void ProcessGfxCommands(Gfx* commands);
|
static void ProcessGfxCommands(Gfx* commands);
|
||||||
static uint32_t GetInterpolationFPS();
|
static uint32_t GetInterpolationFPS();
|
||||||
|
|
||||||
|
static int ShowYesNoBox(const char* title, const char* box);
|
||||||
static void ShowMessage(const char* title, const char* message);
|
static void ShowMessage(const char* title, const char* message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,8 +8,10 @@
|
|||||||
#include <port/Engine.h>
|
#include <port/Engine.h>
|
||||||
|
|
||||||
std::unordered_map<std::string, std::string> mGameList = {
|
std::unordered_map<std::string, std::string> mGameList = {
|
||||||
{ "f7475fb11e7e6830f82883412638e8390791ab87", "Star Fox 64 (U) (V1.1) (Uncompressed)" },
|
{ "d8b1088520f7c5f81433292a9258c1184afa1457", "Star Fox 64 (U) (V1.1)" },
|
||||||
{ "09f0d105f476b00efa5303a3ebc42e60a7753b7a", "Star Fox 64 (U) (V1.1)" }
|
{ "63b69f0ef36306257481afc250f9bc304c7162b2", "Star Fox 64 (U) (V1.0) (Uncompressed)" },
|
||||||
|
{ "09f0d105f476b00efa5303a3ebc42e60a7753b7a", "Star Fox 64 (U) (V1.1)" },
|
||||||
|
{ "f7475fb11e7e6830f82883412638e8390791ab87", "Star Fox 64 (U) (V1.0) (Uncompressed)" },
|
||||||
};
|
};
|
||||||
|
|
||||||
bool GameExtractor::SelectGameFromUI() {
|
bool GameExtractor::SelectGameFromUI() {
|
||||||
@ -34,7 +36,13 @@ bool GameExtractor::SelectGameFromUI() {
|
|||||||
std::optional<std::string> GameExtractor::ValidateChecksum() const {
|
std::optional<std::string> GameExtractor::ValidateChecksum() const {
|
||||||
const auto rom = new N64::Cartridge(this->mGameData);
|
const auto rom = new N64::Cartridge(this->mGameData);
|
||||||
rom->Initialize();
|
rom->Initialize();
|
||||||
return mGameList[rom->GetHash()];
|
auto hash = rom->GetHash();
|
||||||
|
|
||||||
|
if (mGameList.find(hash) == mGameList.end()) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mGameList[hash];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameExtractor::GenerateOTR() const {
|
bool GameExtractor::GenerateOTR() const {
|
||||||
@ -43,8 +51,7 @@ bool GameExtractor::GenerateOTR() const {
|
|||||||
try {
|
try {
|
||||||
Companion::Instance->Init(ExportType::Binary);
|
Companion::Instance->Init(ExportType::Binary);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
GameEngine::ShowMessage("Failed to generate OTR", e.what());
|
return false;
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
class GameExtractor {
|
class GameExtractor {
|
||||||
public:
|
public:
|
||||||
static void GenAssetFile();
|
static bool GenAssetFile();
|
||||||
std::optional<std::string> ValidateChecksum() const;
|
std::optional<std::string> ValidateChecksum() const;
|
||||||
bool SelectGameFromUI();
|
bool SelectGameFromUI();
|
||||||
bool GenerateOTR() const;
|
bool GenerateOTR() const;
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit c6b1cdfa850597165bba15b36447ab2d91e4abff
|
Subproject commit 7da8ae8e25d6c1267792941bf9ac56c1acc384ae
|
Loading…
Reference in New Issue
Block a user