diff --git a/mods/randomizer/CMakeLists.txt b/mods/randomizer/CMakeLists.txt index c85aca27a5..93d7b9531d 100644 --- a/mods/randomizer/CMakeLists.txt +++ b/mods/randomizer/CMakeLists.txt @@ -126,6 +126,7 @@ target_link_libraries(randomizer PRIVATE yaml-cpp::yaml-cpp base64pp randomizer_ string(LENGTH "${CMAKE_CURRENT_SOURCE_DIR}/" RANDOMIZER_SOURCE_PATH_SIZE) target_compile_definitions(randomizer PRIVATE + RANDOMIZER_VERSION="1.0.0" RANDO_DATA_PATH="generator/data/" SOURCE_PATH_SIZE=${RANDOMIZER_SOURCE_PATH_SIZE} ) @@ -134,6 +135,7 @@ target_compile_definitions(randomizer PRIVATE add_executable(randomizer_generator ${CMAKE_CURRENT_SOURCE_DIR}/generator/generator_only.cpp ${RANDOMIZER_GENERATOR_SOURCES}) target_link_libraries(randomizer_generator PRIVATE yaml-cpp::yaml-cpp base64pp fmt::fmt randomizer_embeds) target_compile_definitions(randomizer_generator PRIVATE + RANDOMIZER_VERSION="1.0.0" RANDO_DATA_PATH="generator/data/" SOURCE_PATH_SIZE=${RANDOMIZER_SOURCE_PATH_SIZE} RANDO_SAVE_PATH="${CMAKE_BINARY_DIR}/randomizer/" @@ -143,6 +145,7 @@ target_compile_definitions(randomizer_generator PRIVATE add_executable(randomizer_generator_tests ${CMAKE_CURRENT_SOURCE_DIR}/generator/test/test.cpp ${RANDOMIZER_GENERATOR_SOURCES}) target_link_libraries(randomizer_generator_tests PRIVATE yaml-cpp::yaml-cpp base64pp fmt::fmt randomizer_embeds) target_compile_definitions(randomizer_generator_tests PRIVATE + RANDOMIZER_VERSION="1.0.0" RANDO_DATA_PATH="generator/data/" SOURCE_PATH_SIZE=${RANDOMIZER_SOURCE_PATH_SIZE} RANDO_SAVE_PATH="${CMAKE_BINARY_DIR}/randomizer/" diff --git a/mods/randomizer/generator/seedgen/config.cpp b/mods/randomizer/generator/seedgen/config.cpp index dc01960972..efd3200fd1 100644 --- a/mods/randomizer/generator/seedgen/config.cpp +++ b/mods/randomizer/generator/seedgen/config.cpp @@ -13,6 +13,8 @@ #include #include +#include "mods/svc/log.hpp" + // Fields which aren't part of settings_list.yaml constexpr std::string_view SEED = "Seed"; constexpr std::string_view PLANDOMIZER = "Plandomizer"; @@ -374,9 +376,8 @@ namespace randomizer::seedgen::config std::string permalink{}; - // TODO: print mod version instead of dusklight version? - /*permalink += DUSK_WC_DESCRIBE; - permalink += '\0';*/ + permalink += RANDOMIZER_VERSION; + permalink += '\0'; permalink += std::to_string(settings::GetSettingInfoHash()); permalink += '\0'; permalink += this->_seed; @@ -480,9 +481,8 @@ namespace randomizer::seedgen::config const auto& permaPackedSettings = permaParts[3]; if (permaSettingsInfoHash != std::to_string(settings::GetSettingInfoHash())) { - // TODO: print mod version instead of dusklight version? - return fmt::format("Pasted permalink was generated with an incompatible Dusklight version.\n" - "Your version: {}\nPermalink version: {}", /*DUSK_WC_DESCRIBE*/ 0, permaVersion); + return fmt::format("Pasted permalink was generated with an incompatible Randomizer version.\n" + "Your version: {}\nPermalink version: {}", RANDOMIZER_VERSION, permaVersion); } const std::vector bytes(permaPackedSettings.begin(), permaPackedSettings.end()); diff --git a/mods/randomizer/res/ui.rcss b/mods/randomizer/res/ui.rcss index e5aad78e64..67944fd183 100644 --- a/mods/randomizer/res/ui.rcss +++ b/mods/randomizer/res/ui.rcss @@ -1,5 +1,4 @@ .excluded-locations-pane-right { - overflow: hidden; padding: 0dp; gap: 0dp; } @@ -60,10 +59,12 @@ border-top: 1dp #92875B; } -.excluded-locations-pane-right { - padding-left: 5dp; +.excluded-locations-inner-pane-right { gap: 8dp; - overflow-y: hidden; font-size: 20dp; border-top: 1dp #92875B; +} + +.excluded-locations-inner-pane-right > span { + padding-left: 10dp; } \ No newline at end of file diff --git a/mods/randomizer/src/ui/rando_config.cpp b/mods/randomizer/src/ui/rando_config.cpp index f6c490ee65..ca8e61f403 100644 --- a/mods/randomizer/src/ui/rando_config.cpp +++ b/mods/randomizer/src/ui/rando_config.cpp @@ -1,6 +1,7 @@ #include "rando_config.hpp" #include +#include #include "../session.hpp" #include "../tools.h" @@ -324,7 +325,6 @@ ModResult buildSeedManagementTab(ModContext* ctx, UiWindowHandle, UiElementHandl } add_section(leftPane, "Permalink"); - { std::string help_rml = "Copy your current settings permalink to share with others.
"; help_rml += fmt::format( @@ -334,15 +334,38 @@ ModResult buildSeedManagementTab(ModContext* ctx, UiWindowHandle, UiElementHandl "Copy Permalink", help_rml.c_str(), [](ModContext*, void*) { - // TODO: need SDL clipboard access + mods::ui::set_clipboard_text(GetRandomizerConfig().GetPermalink().data()); + + UiToastDesc desc = UI_TOAST_DESC_INIT; + desc.title_rml = "Randomizer"; + desc.body_rml = "Permalink Copied"; + desc.duration_ms = 3000; + session::svc_mng.ui->push_toast(session::svc_mng.mod_ctx, &desc); }); } - add_button(leftPane, "Paste Permalink", "Paste in a permalink from your clipboard. This will overwrite your current settings.", [](ModContext*, void*) { - // TODO: need SDL clipboard access + std::string text; + ModResult rt = mods::ui::get_clipboard_text(text); + if (rt != MOD_OK) { + return; + } + + auto result = GetRandomizerConfig().LoadFromPermalink(text); + if (result.has_value()) { + mods::log::error("Failed to load permalink: {}", result.value()); + return; + } + + SaveRandomizerConfig(); + + UiToastDesc desc = UI_TOAST_DESC_INIT; + desc.title_rml = "Randomizer"; + desc.body_rml = "Applied Permalink"; + desc.duration_ms = 3000; + session::svc_mng.ui->push_toast(session::svc_mng.mod_ctx, &desc); }); add_section(leftPane, "Presets"); @@ -821,7 +844,7 @@ ModResult buildExcludedLocationsTab(ModContext* ctx, UiWindowHandle, UiElementHa svc_mng.ui->elem_set_class(mod_ctx, exlocSubHeaderElem, "excluded-locations-subheader", true); svc_mng.ui->pane_add_rml(mod_ctx, rightPane, "", &exlocRightPaneElem); - svc_mng.ui->elem_set_class(mod_ctx, exlocRightPaneElem, "excluded-locations-pane-right", true); + svc_mng.ui->elem_set_class(mod_ctx, exlocRightPaneElem, "excluded-locations-inner-pane-right", true); return MOD_OK; } @@ -830,7 +853,7 @@ ModResult updateExcludedLocationsTab(ModContext* ctx, void*, ModError*) { std::string rml = ""; for (const auto& location : GetRandomizerConfig().GetSettings().GetExcludedLocations()) { - rml += fmt::format("• {}
", location); + rml += fmt::format("• {}
", location); } svc_mng.ui->elem_set_rml(svc_mng.mod_ctx, exlocRightPaneElem, rml.c_str());