mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-24 22:35:53 -04:00
Use full color extensions
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include "string.hpp"
|
||||
#include "yaml.hpp"
|
||||
|
||||
#include <mods/svc/flow.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <ranges>
|
||||
@@ -14,6 +16,20 @@
|
||||
#endif
|
||||
|
||||
namespace randomizer {
|
||||
namespace {
|
||||
|
||||
std::string text_color_code(uint32_t rgba) {
|
||||
const auto message =
|
||||
mods::flow::MessageBuilder{}.text_color(rgba).build(MESSAGE_LANGUAGE_ENGLISH);
|
||||
const auto& bytes = message.text();
|
||||
return {reinterpret_cast<const char*>(bytes.data()), bytes.size() - 1};
|
||||
}
|
||||
|
||||
const auto kDarkGreenMessageCode = text_color_code(0x4BBE4BFF);
|
||||
const auto kBlueMessageCode = text_color_code(0x4B96D7FF);
|
||||
const auto kSilverMessageCode = text_color_code(0xBFBFBFFF);
|
||||
|
||||
} // namespace
|
||||
|
||||
Text::Text(const std::string& str) {
|
||||
for (auto& text : mText) {
|
||||
@@ -435,10 +451,9 @@ namespace randomizer {
|
||||
{"<yellow>", "\x1A\x06\xFF\x00\x00\x04"sv},
|
||||
{"<purple>", "\x1A\x06\xFF\x00\x00\x06"sv},
|
||||
{"<orange>", "\x1A\x06\xFF\x00\x00\x08"sv},
|
||||
// custom colors
|
||||
{"<dark green>", "\x1A\x06\xFF\x00\x00\x09"sv},
|
||||
{"<blue>", "\x1A\x06\xFF\x00\x00\x0A"sv},
|
||||
{"<silver>", "\x1A\x06\xFF\x00\x00\x0B"sv},
|
||||
{"<dark green>", kDarkGreenMessageCode},
|
||||
{"<blue>", kBlueMessageCode},
|
||||
{"<silver>", kSilverMessageCode},
|
||||
};
|
||||
|
||||
void breakLines(std::string& str, float maxStrLength) {
|
||||
|
||||
@@ -202,10 +202,6 @@ DEFINE_HOOK_SYMBOL("dComIfGs_getCollectSmell", u8(), getCollectSmell);
|
||||
|
||||
DEFINE_HOOK(&dEvt_control_c::skipper, dEvt_control_c__skipper);
|
||||
|
||||
DEFINE_HOOK_SYMBOL("getFontCCColorTable", u32(u8, u8), getCCColorTable);
|
||||
DEFINE_HOOK_SYMBOL("getFontGCColorTable", u32(u8, u8), getGCColorTable);
|
||||
|
||||
|
||||
namespace randomizer::ui {
|
||||
dialogSelectModeState g_dialogSelectModeState = SelectReady;
|
||||
}
|
||||
@@ -3081,28 +3077,6 @@ void hookReplaceEvtControlSkipper(ModContext*, void* args, void* retval, void*)
|
||||
*static_cast<bool*>(retval) = doSkip;
|
||||
}
|
||||
|
||||
void hookPostGetColorTable(ModContext*, void* args, void* retval, void* userdata) {
|
||||
auto& returnColor = *static_cast<u32*>(retval);
|
||||
if (returnColor != 0xFFFFFFFF) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto i_color = mods::arg<u8>(args, 0);
|
||||
switch (i_color) {
|
||||
case 9:
|
||||
returnColor = 0x4BBE4BFF; // Dark Green
|
||||
break;
|
||||
case 10:
|
||||
returnColor = 0x4B96D7FF; // Blue
|
||||
break;
|
||||
case 11:
|
||||
returnColor = 0xBFBFBFFF; // Silver
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ModResult initialize() {
|
||||
@@ -3260,9 +3234,6 @@ ModResult initialize() {
|
||||
|
||||
ADD_HOOK_REPLACE(dEvt_control_c__skipper, hookReplaceEvtControlSkipper);
|
||||
|
||||
ADD_HOOK_POST(getCCColorTable, hookPostGetColorTable);
|
||||
ADD_HOOK_POST(getGCColorTable, hookPostGetColorTable);
|
||||
|
||||
return MOD_OK;
|
||||
}
|
||||
|
||||
@@ -3394,9 +3365,6 @@ ModResult uninstall() {
|
||||
|
||||
mods::hook::uninstall<dEvt_control_c__skipper>(svc_hook);
|
||||
|
||||
mods::hook::uninstall<getCCColorTable>(svc_hook);
|
||||
mods::hook::uninstall<getGCColorTable>(svc_hook);
|
||||
|
||||
return MOD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user