Bind native manager actions and preserve ongoing Modern standings (by Codex)

This commit is contained in:
Codex committed 2026-10-29 21:24:49 +01:00
1 parent f9f950fc7f
commit cf424b6be1
31 files changed
+466 -100

No files matched your search

+3 -50
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/model.hpp"
#include "modern/content/manager_name.hpp"
#include "modern/ui/demo_advertising.hpp"
#include "modern/ui/demo_almanac.hpp"
#include "modern/ui/demo_calendar.hpp"
@@ -25,57 +26,9 @@
namespace bmh::modern_ui {
std::optional<std::string> normalized_manager_name(std::string_view raw) {
const auto whitespace = [](uint32_t c) {
return c == 0x20 || c == 0xa0 || c == 0x1680 ||
(c >= 0x2000 && c <= 0x200a) || c == 0x2028 || c == 0x2029 ||
c == 0x202f || c == 0x205f || c == 0x3000 || c == 0xfeff;
};
size_t first = raw.size(), last = 0, count = 0, pending_spaces = 0;
for (size_t at = 0; at < raw.size();) {
const auto start = at;
const auto byte = uint8_t(raw[at++]);
uint32_t value = byte;
int remaining = 0;
if (byte >= 0xc2 && byte <= 0xdf) {
value &= 31;
remaining = 1;
} else if (byte >= 0xe0 && byte <= 0xef) {
value &= 15;
remaining = 2;
} else if (byte >= 0xf0 && byte <= 0xf4) {
value &= 7;
remaining = 3;
} else if (byte >= 128)
return {};
const auto encoded_length = remaining;
while (remaining--) {
if (at == raw.size() || (uint8_t(raw[at]) & 0xc0) != 0x80)
return {};
value = value * 64 + (uint8_t(raw[at++]) & 63);
}
if ((encoded_length == 1 && value < 0x80) ||
(encoded_length == 2 && value < 0x800) ||
(encoded_length == 3 && value < 0x10000) || value > 0x10ffff ||
(value >= 0xd800 && value <= 0xdfff) || value < 32 ||
(value >= 127 && value <= 159))
return {};
if (whitespace(value)) {
if (count)
pending_spaces = std::min(size_t(25), pending_spaces + 1);
continue;
}
if (!count)
first = start;
count += pending_spaces + 1;
pending_spaces = 0;
if (count > 24)
return {};
last = at;
}
if (!count)
return {};
return std::string(raw.substr(first, last - first));
return modern::normalized_manager_name(raw);
}
namespace {
bool bounded_integer(const Json &value, int low, int high) {
if (!value.is_number_integer())