Getting closer

This commit is contained in:
izzy2lost
2025-07-28 03:38:25 -04:00
committed by GitHub
parent 28b639a9a7
commit f862b8d8ee
+36 -29
View File
@@ -62,6 +62,7 @@ void AudioThread_CreateNextAudioBuffer(int16_t* samples, uint32_t num_samples);
std::vector<uint8_t*> MemoryPool;
GameEngine* GameEngine::Instance;
GameEngine::GameEngine() {
GameEngine::GameEngine() {
#ifdef __SWITCH__
Ship::Switch::Init(Ship::PreInitPhase);
@@ -69,37 +70,42 @@ GameEngine::GameEngine() {
#endif
std::vector<std::string> archiveFiles;
const std::string main_path = "/storage/emulated/0/Starship/sf64.o2r";
#ifdef __linux__
const std::string assets_path = "/storage/emulated/0/Starship/starship.o2r";
#else
const std::string assets_path = "/storage/emulated/0/Starship/starship.o2r";
#endif
const std::string baseDir = "/storage/emulated/0/Starship/";
const std::string main_path = baseDir + "sf64.o2r";
const std::string assets_path = baseDir + "starship.o2r";
const std::string modDir = baseDir + "mods";
#ifdef _WIN32
AllocConsole();
#endif
const std::string modDir = "/storage/emulated/0/Starship/mods";
// Ensure mod directory exists
if (!fs::exists(modDir)) {
fs::create_directories(modDir);
}
// Set external storage as app/user directory path for Ship::Context
Ship::Context::AppDirectoryPath = baseDir;
Ship::Context::UserDirectoryPath = baseDir;
// Add sf64.o2r if it exists, otherwise prompt for extraction
if (std::filesystem::exists(main_path)) {
archiveFiles.push_back(main_path);
} else {
if (ShowYesNoBox("Starship - Asset Extraction", "Please provide a Starfox 64 ROM.\n\nSupported Versions:\nUS 1.0\nUS 1.1\n\nAssets will be extracted into an O2R file.") == IDYES) {
if(!GenAssetFile()){
ShowMessage("Error", "An error occured, no O2R file was generated.\n\nExiting...");
if (ShowYesNoBox("Starship - Asset Extraction",
"Please provide a Starfox 64 ROM.\n\nSupported Versions:\nUS 1.0\nUS 1.1\n\nAssets will be extracted into an O2R file.") == IDYES) {
if (!GenAssetFile()) {
ShowMessage("Error", "An error occurred, no O2R file was generated.\n\nExiting...");
exit(1);
} else {
archiveFiles.push_back(main_path);
}
if (ShowYesNoBox("Extraction Complete", "ROM Extracted. Extract another?\n\n Starship supports JP and EU ROMs for voice replacement.\n Voice replacement ROM assets can also be installed in:\n Settings->Language->Install JP/EU Audio") == IDYES) {
if(!GenAssetFile()){
ShowMessage("Error", "An error occured, no O2R file was generated.");
if (ShowYesNoBox("Extraction Complete",
"ROM Extracted. Extract another?\n\nStarship supports JP and EU ROMs for voice replacement.\nVoice replacement ROM assets can also be installed in:\nSettings -> Language -> Install JP/EU Audio") == IDYES) {
if (!GenAssetFile()) {
ShowMessage("Error", "An error occurred, no O2R file was generated.");
}
}
} else {
@@ -107,33 +113,34 @@ GameEngine::GameEngine() {
}
}
// Add starship.o2r if it exists
if (std::filesystem::exists(assets_path)) {
archiveFiles.push_back(assets_path);
}
if (const std::string patches_path = Ship::Context::GetPathRelativeToAppDirectory("mods");
!patches_path.empty() && std::filesystem::exists(patches_path)) {
if (std::filesystem::is_directory(patches_path)) {
for (const auto& p : std::filesystem::recursive_directory_iterator(patches_path)) {
const auto ext = p.path().extension().string();
if (StringHelper::IEquals(ext, ".otr") || StringHelper::IEquals(ext, ".o2r")) {
archiveFiles.push_back(p.path().generic_string());
}
// Add any mods from external modDir
if (std::filesystem::exists(modDir) && std::filesystem::is_directory(modDir)) {
for (const auto& p : std::filesystem::recursive_directory_iterator(modDir)) {
const auto ext = p.path().extension().string();
if (StringHelper::IEquals(ext, ".otr") || StringHelper::IEquals(ext, ".o2r")) {
archiveFiles.push_back(p.path().generic_string());
}
if (StringHelper::IEquals(ext, ".zip")) {
SPDLOG_WARN("Zip files should be only used for development purposes, not for distribution");
archiveFiles.push_back(p.path().generic_string());
}
if (StringHelper::IEquals(ext, ".zip")) {
SPDLOG_WARN("Zip files should be only used for development purposes, not for distribution");
archiveFiles.push_back(p.path().generic_string());
}
}
}
// Create the context using the overridden external storage paths
this->context = Ship::Context::CreateUninitializedInstance("Starship", "ship", "starship.cfg.json");
this->context->InitConfiguration(); // without this line InitConsoleVariables fails at Config::Reload()
this->context->InitConsoleVariables(); // without this line the controldeck constructor failes in
// ShipDeviceIndexMappingManager::UpdateControllerNamesFromConfig()
// Initialize configuration and console variables
this->context->InitConfiguration();
this->context->InitConsoleVariables();
}
auto defaultMappings = std::make_shared<Ship::ControllerDefaultMappings>(
// KeyboardKeyToButtonMappings - use built-in LUS defaults
std::unordered_map<CONTROLLERBUTTONS_T, std::unordered_set<Ship::KbScancode>>(),