Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes macOS randomizer functionality with App Directory #761

Merged
merged 5 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions soh/soh.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@
<ClCompile Include="src\overlays\misc\ovl_kaleido_scope\z_lmap_mark.c" />
<ClCompile Include="src\overlays\misc\ovl_kaleido_scope\z_lmap_mark_data.c" />
<ClCompile Include="src\overlays\misc\ovl_map_mark_data\z_map_mark_data.c" />

</ItemGroup>
<ItemGroup>
<ClInclude Include="soh\Enhancements\cosmetics\CosmeticsEditor.h" />
Expand Down
5 changes: 4 additions & 1 deletion soh/soh/Enhancements/randomizer/3drando/rando_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
// #include <soh/Enhancements/randomizer.h>
#include <Cvar.h>
#include <GameSettings.h>
#define NOGDI
#define WIN32_LEAN_AND_MEAN
#include <GlobalCtx2.h>
Kenix3 marked this conversation as resolved.
Show resolved Hide resolved

#define TICKS_PER_SEC 268123480.0

Expand All @@ -18,7 +21,7 @@ void RandoMain::GenerateRando(std::unordered_map<RandomizerSettingKey, u8> cvarS
// std::string settingsFileName = "./randomizer/latest_settings.json";
// CVar_SetString("gLoadedPreset", settingsFileName.c_str());

std::string fileName = GenerateRandomizer(cvarSettings);
std::string fileName = Ship::GlobalCtx2::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings).c_str());
CVar_SetString("gSpoilerLog", fileName.c_str());

Game::SaveSettings();
Expand Down
11 changes: 8 additions & 3 deletions soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <filesystem>
#include <variables.h>

#define NOGDI
#define WIN32_LEAN_AND_MEAN
#include "GlobalCtx2.h"

using json = nlohmann::json;

json jsonData;
Expand Down Expand Up @@ -721,12 +725,13 @@ const char* SpoilerLog_Write(int language) {
//WriteShuffledEntrances(spoilerLog);
WriteAllLocations(language);

if (!std::filesystem::exists("./Randomizer")) {
std::filesystem::create_directory("./Randomizer");
if (!std::filesystem::exists(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer"))) {
std::filesystem::create_directory(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer"));
}

std::string jsonString = jsonData.dump(4);
std::ofstream jsonFile("./Randomizer/" + Settings::seed + ".json");
std::ofstream jsonFile(Ship::GlobalCtx2::GetPathRelativeToAppDirectory(
(std::string("Randomizer/") + std::string(Settings::seed) + std::string(".json")).c_str()));
jsonFile << std::setw(4) << jsonString << std::endl;
jsonFile.close();

Expand Down