permalink copy/paste working

This commit is contained in:
TakaRikka
2026-08-19 19:49:26 -07:00
parent 88c6e28179
commit 6f840b050e
4 changed files with 43 additions and 16 deletions
+3
View File
@@ -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/"
+6 -6
View File
@@ -13,6 +13,8 @@
#include <fmt/format.h>
#include <iostream>
#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<char> bytes(permaPackedSettings.begin(), permaPackedSettings.end());
+5 -4
View File
@@ -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;
}
+29 -6
View File
@@ -1,6 +1,7 @@
#include "rando_config.hpp"
#include <mods/svc/log.hpp>
#include <mods/svc/ui.hpp>
#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.<br/>";
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("• {}<br/>", location);
rml += fmt::format("<span>• {}</span><br/>", location);
}
svc_mng.ui->elem_set_rml(svc_mng.mod_ctx, exlocRightPaneElem, rml.c_str());