path cleanup

This commit is contained in:
gymnast86
2026-05-23 09:10:58 -07:00
parent 484c5e8bf3
commit deb213d07a
7 changed files with 37 additions and 37 deletions
+7 -10
View File
@@ -5,6 +5,8 @@
#include "dusk/logging.h"
#include "dusk/data.hpp"
#include "dusk/map_loader_definitions.h"
#include "dusk/ui/rando_config.hpp"
#include "dusk/randomizer/generator/logic/search.hpp"
#include "dusk/randomizer/generator/utility/string.hpp"
#include "dusk/randomizer/game/randomizer_context.hpp"
@@ -16,8 +18,6 @@
#include <numeric>
#include <ranges>
#include "dusk/map_loader_definitions.h"
#include "dusk/randomizer/generator/utility/string.hpp"
namespace dusk {
@@ -78,8 +78,7 @@ namespace dusk {
}
if (ImGui::BeginMenu(loadSeedText.c_str(), playerIsOnTitleScreen())) {
std::filesystem::path seedDirectory =
dusk::data::configured_data_path() / "randomizer" / "seeds";
std::filesystem::path seedDirectory = ui::GetRandomizerSeedsPath();
std::list<std::string> hashes{};
@@ -115,9 +114,7 @@ namespace dusk {
if (ImGui::BeginMenu("Delete Seed")) {
std::filesystem::path seedDirectory =
dusk::data::configured_data_path() / "randomizer" / "seeds";
std::filesystem::path seedDirectory = ui::GetRandomizerSeedsPath();
std::list<std::string> hashes{};
for (const auto& entry : std::filesystem::directory_iterator(seedDirectory)) {
@@ -251,7 +248,7 @@ namespace dusk {
auto trackerHash = trackerRando->GetConfig().GetHash(false);
// If no hash, or seeds switched, try to create tracker world from currently active seed
if (trackerHash.empty() || (trackerHash != contextHash && !contextHash.empty())) {
*trackerRando = randomizer::Randomizer(data::configured_data_path());
*trackerRando = randomizer::Randomizer(ui::GetRandomizerPath());
trackerRando->GenerateTrackerWorld();
}
@@ -347,7 +344,7 @@ namespace dusk {
}
randomizer::Randomizer* ImGuiMenuRandomizer::getTrackerRando() {
static randomizer::Randomizer trackerRando{data::configured_data_path()};
static randomizer::Randomizer trackerRando{ui::GetRandomizerPath()};
return &trackerRando;
}
@@ -403,7 +400,7 @@ namespace dusk {
}
}
auto counts = m_LocationInfo | std::views::transform([](const std::pair<std::string, TrackerAreaGroup>& location) { return location.second.accessibleCount; });
auto counts = m_LocationInfo | std::views::transform([](const std::pair<std::string, TrackerAreaGroup>& location) { return location.second.collectedCount; });
m_numCollectedLocations = std::accumulate(counts.begin(), counts.end(), 0);
}
} // namespace dusk
@@ -1,9 +1,10 @@
#include "randomizer_context.hpp"
#include "dusk/app_info.hpp"
#include "dusk/logging.h"
#include "dusk/main.h"
#include "dusk/data.hpp"
#include "dusk/ui/rando_config.hpp"
#include "dusk/randomizer/game/flags.h"
#include "dusk/randomizer/game/tools.h"
#include "dusk/randomizer/game/stages.h"
#include "dusk/randomizer/game/verify_item_functions.h"
@@ -12,7 +13,6 @@
#include "dusk/randomizer/generator/randomizer.hpp"
#include "dusk/randomizer/generator/utility/text.hpp"
#include "SDL3/SDL_filesystem.h"
#include <zlib.h>
#include <fstream>
@@ -23,7 +23,6 @@
#include "d/d_meter2_draw.h"
#include "d/d_meter2_info.h"
#include "d/d_msg_flow.h"
#include "flags.h"
std::optional<std::string> RandomizerContext::WriteToFile() {
@@ -268,7 +267,7 @@ std::optional<std::string> RandomizerContext::LoadFromHash(const std::string& ha
}
std::filesystem::path RandomizerContext::GetSeedDataPath() const {
return dusk::data::configured_data_path() / "randomizer" / "seeds" / this->mHash / "seed.dat";
return dusk::ui::GetRandomizerSeedsPath() / this->mHash / "seed.dat";
}
int RandomizerContext::SettingToEnum(const std::string& settingName) {
@@ -1283,7 +1282,7 @@ static void DeleteFailedGenerationFiles(randomizer::Randomizer& rando) {
* Generates a seed and writes the necessary seed files to the players seed directory
*/
void GenerateAndWriteSeed(std::string& generationStatusMsg) {
auto r = randomizer::Randomizer{dusk::data::configured_data_path()};
auto r = randomizer::Randomizer{dusk::ui::GetRandomizerPath()};
auto generationResult = r.Generate();
if (generationResult.has_value()) {
+2 -2
View File
@@ -13,8 +13,8 @@
#include <iostream>
#include "dusk/data.hpp"
#include "dusk/logging.h"
#include "dusk/ui/rando_config.hpp"
#include "dusk/randomizer/game/randomizer_context.hpp"
namespace randomizer
@@ -51,7 +51,7 @@ namespace randomizer
return;
}
std::filesystem::path seedSettings = dusk::data::configured_data_path() / "randomizer" / "seeds" /
std::filesystem::path seedSettings = dusk::ui::GetRandomizerSeedsPath() /
contextHash / (contextHash + " Anti-Spoiler Log.txt");
this->_config.LoadFromFile(seedSettings, GetPrefPath());
+2 -2
View File
@@ -10,7 +10,7 @@ namespace randomizer
{
public:
Randomizer() = delete;
Randomizer(const std::filesystem::path& baseOutputPath) : _baseOutputPath(baseOutputPath / "randomizer") {}
Randomizer(const std::filesystem::path& baseOutputPath) : _baseOutputPath(baseOutputPath) {}
/**
* @brief Generates a complete randomizer seed
@@ -39,7 +39,7 @@ namespace randomizer
std::filesystem::path GetSeedOutputPath();
std::filesystem::path GetBaseOutputPath() const { return this->_baseOutputPath; };
void SetBaseOutputPath(const std::filesystem::path& path) { this->_baseOutputPath = path / "randomizer"; };
void SetBaseOutputPath(const std::filesystem::path& path) { this->_baseOutputPath = path; };
std::filesystem::path GetConfigPath() const { return this->GetBaseOutputPath() / "settings.yaml"; }
std::filesystem::path GetPrefPath() const { return this->GetBaseOutputPath() / "preferences.yaml"; }
+18 -17
View File
@@ -3,11 +3,8 @@
#include <mutex>
#include <thread>
#include "SDL3/SDL_filesystem.h"
#include "bool_button.hpp"
#include "modal.hpp"
#include "dusk/app_info.hpp"
#include "dusk/config.hpp"
#include "dusk/data.hpp"
#include "dusk/logging.h"
@@ -222,6 +219,12 @@ Document* show_seed_gen_modal(std::string_view message) {
}
RandomizerWindow::RandomizerWindow() {
// Create rando directories if they don't exist
if (!std::filesystem::exists(GetRandomizerSeedsPath())) {
std::filesystem::create_directories(GetRandomizerSeedsPath());
}
add_tab("Seed Management", [this](Rml::Element* content) {
auto& leftPane = add_child<Pane>(content, Pane::Type::Controlled);
auto& rightPane = add_child<Pane>(content, Pane::Type::Controlled);
@@ -237,12 +240,7 @@ RandomizerWindow::RandomizerWindow() {
},
}),
rightPane, [](Pane& pane) {
std::filesystem::path seedDirectory =
dusk::data::configured_data_path() / "randomizer" / "seeds";
if (!std::filesystem::exists(seedDirectory)) {
std::filesystem::create_directories(seedDirectory);
}
std::filesystem::path seedDirectory = GetRandomizerSeedsPath();
if (std::filesystem::is_empty(seedDirectory)) {
pane.add_rml(
@@ -275,12 +273,7 @@ RandomizerWindow::RandomizerWindow() {
leftPane.register_control(
leftPane.add_button("Delete Seeds"),
rightPane, [](Pane& pane) {
std::filesystem::path seedDirectory =
dusk::data::configured_data_path() / "randomizer" / "seeds";
if (!std::filesystem::exists(seedDirectory)) {
std::filesystem::create_directories(seedDirectory);
}
std::filesystem::path seedDirectory = GetRandomizerSeedsPath();
if (std::filesystem::is_empty(seedDirectory)) {
pane.add_rml(
@@ -493,12 +486,20 @@ void RandomizerWindow::update() {
}
}
std::filesystem::path GetRandomizerPath() {
return data::configured_data_path() / "randomizer";
}
std::filesystem::path GetRandomizerSettingsPath() {
return data::configured_data_path() / "randomizer" / "settings.yaml";
return GetRandomizerPath() / "settings.yaml";
}
std::filesystem::path GetRandomizerPreferencesPath() {
return data::configured_data_path() / "randomizer" / "preferences.yaml";
return GetRandomizerPath() / "preferences.yaml";
}
std::filesystem::path GetRandomizerSeedsPath() {
return GetRandomizerPath() / "seeds";
}
randomizer::seedgen::config::Config& GetRandomizerConfig() {
+2
View File
@@ -8,8 +8,10 @@ namespace randomizer::seedgen::config {
namespace dusk::ui {
std::filesystem::path GetRandomizerPath();
std::filesystem::path GetRandomizerSettingsPath();
std::filesystem::path GetRandomizerPreferencesPath();
std::filesystem::path GetRandomizerSeedsPath();
randomizer::seedgen::config::Config& GetRandomizerConfig();
class RandomizerWindow : public Window {
+2 -1
View File
@@ -64,6 +64,7 @@
#include "dusk/ui/prelaunch.hpp"
#include "dusk/ui/preset.hpp"
#include "dusk/ui/ui.hpp"
#include "dusk/ui/rando_config.hpp"
#include "version.h"
#include <aurora/aurora.h>
@@ -503,7 +504,7 @@ int game_main(int argc, char* argv[]) {
#ifdef LOGIC_TESTS
randomizer::test::test::RunTests();
#else
randomizer::Randomizer rando{dusk::data::configured_data_path()};
randomizer::Randomizer rando{dusk::ui::GetRandomizerPath()};
rando.Generate();
#endif
exit(0);