Fix white crest contrast on Silver surfaces (by Codex)
This commit is contained in:
1 parent
d615f03e15
commit
4b6c18f654
7 files changed
+176
-2
No files matched your search
@@ -3,6 +3,37 @@
|
|||||||
Stand: 23. Oktober 2026. Festlegung für die native Modern UI, noch keine
|
Stand: 23. Oktober 2026. Festlegung für die native Modern UI, noch keine
|
||||||
Implementierung eines neuen Ressourcenladers oder einer Paketmigration.
|
Implementierung eines neuen Ressourcenladers oder einer Paketmigration.
|
||||||
|
|
||||||
|
## Wappenkontrast im Silver-Theme · 28. Oktober 2026
|
||||||
|
|
||||||
|
Ausgangsstand: `0.3` / `d615f03`.
|
||||||
|
|
||||||
|
Der gemeinsame native Wappenpfad erzeugt für transparente, überwiegend weiße,
|
||||||
|
einfarbige Wappen eine dunkle Anzeigevariante im Silver-Theme. Dies behebt unter
|
||||||
|
anderem das kaum sichtbare weiße Deutschland-Wappen in Statusleiste und
|
||||||
|
National-Spielplanung (#17). Der Farbton entspricht dem Silver-Text
|
||||||
|
`#233443`; vorhandene Grauschattierungen, Pixelabmessungen und Alpha-Kontur
|
||||||
|
bleiben erhalten. Farbige Details, dunkle oder schwarz-weiße Vereinswappen
|
||||||
|
und deckende Bildflächen verwenden die Originaltextur.
|
||||||
|
|
||||||
|
Die Prüfung läuft einmal pro geladenem Wappen. Die Texturverwaltung speichert
|
||||||
|
sowohl die Anzeigevariante als auch die Entscheidung für die Originaltextur.
|
||||||
|
Midnight und Matchday verwenden die ursprüngliche Grafik. Ein Weltwechsel
|
||||||
|
verwirft den gesamten zugehörigen Texturcache. Die eigentliche Bildausgabe
|
||||||
|
nutzt weiterhin den gemeinsamen SDL-/RmlUI-Renderer einschließlich der
|
||||||
|
bestehenden Alpha-Behandlung.
|
||||||
|
|
||||||
|
Die Aufbereitung ist eine reine Anzeigeoperation in
|
||||||
|
[crest_contrast.cpp](../../src/modern/ui/crest_contrast.cpp). OBW-Assets und
|
||||||
|
Spielstände werden dadurch nicht geändert. Fotos, Trophäen und feste
|
||||||
|
GUI-Bildmotive durchlaufen diese Wappenaufbereitung nicht.
|
||||||
|
|
||||||
|
Synthetische Prüfungen decken Lesbarkeit, Alpha-/Schattierungserhalt und
|
||||||
|
unveränderte farbige beziehungsweise schwarz-weiße Wappen ab. Die private
|
||||||
|
Vorher-/Nachher-QA mit dem National-Schreibtisch, tatsächlicher OBS und
|
||||||
|
unveränderten Geometrien liegt in
|
||||||
|
`bmh_4k_ui/docs/qa/crest-contrast-2026-10-28/`. Native Windows-/macOS-
|
||||||
|
Ausführung ist in diesem Linux-Durchlauf nicht geprüft.
|
||||||
|
|
||||||
## Zuständigkeit
|
## Zuständigkeit
|
||||||
|
|
||||||
Die festen Bildmotive des HTML-Mockups gehören zur GUI. Sie werden zusammen mit
|
Die festen Bildmotive des HTML-Mockups gehören zur GUI. Sie werden zusammen mit
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ Nationalkontext diese eigene Darstellung. Die vorhandenen Vereinsansichten
|
|||||||
bleiben erhalten. Die Entscheidung erfolgt über die bestätigte Karriere-Rolle
|
bleiben erhalten. Die Entscheidung erfolgt über die bestätigte Karriere-Rolle
|
||||||
und die aktiv ausgewählte Manageridentität, nicht über Person 0.
|
und die aktiv ausgewählte Manageridentität, nicht über Person 0.
|
||||||
|
|
||||||
|
## Wappen in hellen Themes · 28. Oktober 2026
|
||||||
|
|
||||||
|
Das weiße Deutschland-Wappen erhält im Silver-Theme dieselbe dunkle
|
||||||
|
Anzeigevariante wie andere geeignete einfarbige Wappen. Dies betrifft die
|
||||||
|
Statusleiste und die Paarungsköpfe. Farbige Gegnerwappen bleiben unverändert.
|
||||||
|
Die gemeinsame [Wappenaufbereitung](../../assets.md) erhält Grafikgröße und
|
||||||
|
Alpha-Kontur; sie verändert keine Welt- oder Engine-Daten.
|
||||||
|
|
||||||
## Echter Engineanschluss · 28. Oktober 2026
|
## Echter Engineanschluss · 28. Oktober 2026
|
||||||
|
|
||||||
Die Freundschaftsplanung ist jetzt zusätzlich im echten National-Schreibtisch
|
Die Freundschaftsplanung ist jetzt zusätzlich im echten National-Schreibtisch
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-only
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
add_library(bmh_modern_ui_core STATIC catalog.cpp engine_dto.cpp model.cpp demo_career.cpp demo_national_ui.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_live.cpp demo_post_match.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp news_catalog.cpp news_journal.cpp demo_settings.cpp ui_preferences.cpp demo_widgets.cpp demo_files.cpp demo_opening.cpp)
|
add_library(bmh_modern_ui_core STATIC catalog.cpp crest_contrast.cpp engine_dto.cpp model.cpp demo_career.cpp demo_national_ui.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_live.cpp demo_post_match.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp news_catalog.cpp news_journal.cpp demo_settings.cpp ui_preferences.cpp demo_widgets.cpp demo_files.cpp demo_opening.cpp)
|
||||||
target_include_directories(bmh_modern_ui_core PUBLIC ../..)
|
target_include_directories(bmh_modern_ui_core PUBLIC ../..)
|
||||||
target_link_libraries(bmh_modern_ui_core PUBLIC bmh_asset_io)
|
target_link_libraries(bmh_modern_ui_core PUBLIC bmh_asset_io)
|
||||||
add_library(bmh_modern_ui_mods STATIC mod_library.cpp)
|
add_library(bmh_modern_ui_mods STATIC mod_library.cpp)
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "modern/ui/crest_contrast.hpp"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
namespace bmh::modern_ui {
|
||||||
|
std::optional<editor::images::Raster>
|
||||||
|
crest_for_light_surface(const editor::images::Raster &source) {
|
||||||
|
if (source.width <= 0 || source.height <= 0 || source.pixels.size() % 4 != 0)
|
||||||
|
return std::nullopt;
|
||||||
|
const auto count = uint64_t(source.width) * uint64_t(source.height);
|
||||||
|
if (count != source.pixels.size() / 4)
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
uint64_t transparent = 0, coverage = 0, brightness = 0, dark = 0;
|
||||||
|
for (size_t i = 0; i < source.pixels.size(); i += 4) {
|
||||||
|
const int r = source.pixels[i], g = source.pixels[i + 1],
|
||||||
|
b = source.pixels[i + 2], a = source.pixels[i + 3];
|
||||||
|
if (a == 0) ++transparent;
|
||||||
|
if (a >= 16 && std::max({r, g, b}) - std::min({r, g, b}) > 12)
|
||||||
|
return std::nullopt; // Retain even small coloured details and brand colours.
|
||||||
|
const int luma = (54 * r + 183 * g + 19 * b + 128) / 256;
|
||||||
|
if (a >= 64 && luma < 64)
|
||||||
|
return std::nullopt; // Preserve even a small visible black logo detail.
|
||||||
|
coverage += a;
|
||||||
|
brightness += uint64_t(luma) * a;
|
||||||
|
if (luma < 64) dark += a;
|
||||||
|
}
|
||||||
|
// Alpha-weighting excludes invisible RGB and tolerates antialiasing and
|
||||||
|
// embossed grey shadows. Black/white logos and white rectangular backdrops
|
||||||
|
// do not qualify. This is only called for crests, never for photos or GUI art.
|
||||||
|
if (!coverage || transparent * 20 < count || brightness < coverage * 224 ||
|
||||||
|
dark * 100 > coverage)
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
auto result = source;
|
||||||
|
constexpr std::array<unsigned, 3> ink{0x23, 0x34, 0x43}; // Silver --text.
|
||||||
|
for (size_t i = 0; i < result.pixels.size(); i += 4)
|
||||||
|
if (result.pixels[i + 3])
|
||||||
|
for (size_t c = 0; c < ink.size(); ++c)
|
||||||
|
result.pixels[i + c] = uint8_t((unsigned(result.pixels[i + c]) * ink[c] + 127) / 255);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} // namespace bmh::modern_ui
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "editor/images.hpp"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
namespace bmh::modern_ui {
|
||||||
|
// A display-only variant for transparent, predominantly white monochrome crests.
|
||||||
|
// Coloured, dark, opaque and empty images keep their original appearance.
|
||||||
|
// The source, dimensions, shading and alpha coverage are preserved.
|
||||||
|
std::optional<editor::images::Raster>
|
||||||
|
crest_for_light_surface(const editor::images::Raster &source);
|
||||||
|
} // namespace bmh::modern_ui
|
||||||
+21
-1
@@ -5,6 +5,7 @@
|
|||||||
#include "launch/rml_path.hpp"
|
#include "launch/rml_path.hpp"
|
||||||
#include "launch/rml_video.hpp"
|
#include "launch/rml_video.hpp"
|
||||||
#include "modern/ui/controls.hpp"
|
#include "modern/ui/controls.hpp"
|
||||||
|
#include "modern/ui/crest_contrast.hpp"
|
||||||
#include "modern/ui/engine_bridge.hpp"
|
#include "modern/ui/engine_bridge.hpp"
|
||||||
#include "modern/ui/live_match_info.hpp"
|
#include "modern/ui/live_match_info.hpp"
|
||||||
#include "modern/ui/script_locator.hpp"
|
#include "modern/ui/script_locator.hpp"
|
||||||
@@ -301,6 +302,25 @@ public:
|
|||||||
const auto &r = entries_.at(found->second).raster;
|
const auto &r = entries_.at(found->second).raster;
|
||||||
return {found->second, r.width, r.height};
|
return {found->second, r.width, r.height};
|
||||||
}
|
}
|
||||||
|
Picture crest(const std::string &key, bool light_surface) {
|
||||||
|
const auto source = image(key, true);
|
||||||
|
if (!light_surface || source.token.empty()) return source;
|
||||||
|
const auto identity = "light-crest:" + source.token;
|
||||||
|
auto found = keys_.find(identity);
|
||||||
|
if (found == keys_.end()) {
|
||||||
|
auto variant = crest_for_light_surface(entries_.at(source.token).raster);
|
||||||
|
auto token = source.token;
|
||||||
|
if (variant) {
|
||||||
|
token = "modern-image-" + std::to_string(serial_++) + ".png";
|
||||||
|
entries_[token] = {key, true, 512, std::move(*variant)};
|
||||||
|
}
|
||||||
|
// Also cache the decision to keep a coloured/original texture. Theme
|
||||||
|
// changes reuse both variants; world() invalidates them together.
|
||||||
|
found = keys_.emplace(identity, token).first;
|
||||||
|
}
|
||||||
|
const auto &raster = entries_.at(found->second).raster;
|
||||||
|
return {found->second, raster.width, raster.height};
|
||||||
|
}
|
||||||
Rml::TextureHandle LoadTexture(Rml::Vector2i &dimensions,
|
Rml::TextureHandle LoadTexture(Rml::Vector2i &dimensions,
|
||||||
const Rml::String &source) override {
|
const Rml::String &source) override {
|
||||||
const auto token = editor::utf8(editor::path(source).filename());
|
const auto token = editor::utf8(editor::path(source).filename());
|
||||||
@@ -528,7 +548,7 @@ class App final : public Rml::EventListener {
|
|||||||
"dp;\"/></div>";
|
"dp;\"/></div>";
|
||||||
}
|
}
|
||||||
std::string crest(const Json *c, double size) {
|
std::string crest(const Json *c, double size) {
|
||||||
return c ? img(c->value("crest", ""), size, size, true) : "";
|
return c ? picture(renderer_.crest(c->value("crest", ""), theme_ == "silver"), size, size) : "";
|
||||||
}
|
}
|
||||||
std::string glyph(const std::string &name, double size) {
|
std::string glyph(const std::string &name, double size) {
|
||||||
return img("icon." + name + (theme_ == "silver" ? "-ink" : ""), size, size,
|
return img("icon." + name + (theme_ == "silver" ? "-ink" : ""), size, size,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "modern/ui/desktop.hpp"
|
#include "modern/ui/desktop.hpp"
|
||||||
#include "modern/ui/gui_assets.hpp"
|
#include "modern/ui/gui_assets.hpp"
|
||||||
#include "modern/ui/model.hpp"
|
#include "modern/ui/model.hpp"
|
||||||
|
#include "modern/ui/crest_contrast.hpp"
|
||||||
#include "modern/ui/demo_environment.hpp"
|
#include "modern/ui/demo_environment.hpp"
|
||||||
#include "modern/ui/demo_advertising.hpp"
|
#include "modern/ui/demo_advertising.hpp"
|
||||||
#include "modern/ui/demo_toto.hpp"
|
#include "modern/ui/demo_toto.hpp"
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
#include "modern/ui/demo_transfer.hpp"
|
#include "modern/ui/demo_transfer.hpp"
|
||||||
#include "modern/ui/demo_stadium.hpp"
|
#include "modern/ui/demo_stadium.hpp"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cmath>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -23,6 +25,61 @@ void require(bool value, const char *message) {
|
|||||||
if (!value)
|
if (!value)
|
||||||
throw std::runtime_error(message);
|
throw std::runtime_error(message);
|
||||||
}
|
}
|
||||||
|
void check_crest_contrast() {
|
||||||
|
using bmh::editor::images::Raster;
|
||||||
|
Raster source{16, 16, std::vector<uint8_t>(16 * 16 * 4)};
|
||||||
|
const auto pixel = [](Raster &r, int x, int y, std::array<uint8_t,4> rgba) {
|
||||||
|
std::copy(rgba.begin(), rgba.end(), r.pixels.begin() + (y * r.width + x) * 4);
|
||||||
|
};
|
||||||
|
for (int y = 3; y < 13; ++y)
|
||||||
|
for (int x = 4; x < 12; ++x) pixel(source,x,y,{255,255,255,255});
|
||||||
|
pixel(source,4,3,{224,224,224,96}); // antialiased edge
|
||||||
|
pixel(source,5,3,{100,100,100,64}); // embossed shadow
|
||||||
|
pixel(source,0,0,{213,29,91,0}); // invisible RGB is irrelevant
|
||||||
|
const auto original = source;
|
||||||
|
const auto variant = crest_for_light_surface(source);
|
||||||
|
require(variant && variant->width == source.width && variant->height == source.height,
|
||||||
|
"Light crest variant changed bounds or lost a shaded white crest");
|
||||||
|
require(source.pixels == original.pixels, "Crest display variant mutated source bytes");
|
||||||
|
for (size_t i = 0; i < source.pixels.size(); i += 4) {
|
||||||
|
require(variant->pixels[i+3] == source.pixels[i+3], "Crest variant changed alpha coverage");
|
||||||
|
if (!source.pixels[i+3])
|
||||||
|
for (int c = 0; c < 3; ++c)
|
||||||
|
require(variant->pixels[i+c] == source.pixels[i+c], "Invisible source RGB changed");
|
||||||
|
}
|
||||||
|
const auto luma = [](const Raster &r, size_t i) {
|
||||||
|
double out = 0; const std::array<double,3> weights{.2126,.7152,.0722};
|
||||||
|
for (size_t c = 0; c < 3; ++c) { const double v = r.pixels[i+c]/255.; out += weights[c]*(v<=.04045?v/12.92:std::pow((v+.055)/1.055,2.4)); }
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
const size_t center = (8*16+8)*4;
|
||||||
|
require((.8+.05)/(luma(*variant,center)+.05) > 7,
|
||||||
|
"White crest is still illegible on a light menu surface");
|
||||||
|
require(luma(*variant,(3*16+5)*4) < luma(*variant,center), "Crest shading was flattened");
|
||||||
|
|
||||||
|
auto coloured=source;pixel(coloured,8,8,{255,30,20,255});
|
||||||
|
require(!crest_for_light_surface(coloured), "Coloured crest details were recoloured");
|
||||||
|
auto black_white=source;
|
||||||
|
for (int x=4;x<12;++x) pixel(black_white,x,8,{0,0,0,255});
|
||||||
|
require(!crest_for_light_surface(black_white), "Black/white club crest was recoloured");
|
||||||
|
Raster tiny_black_detail{32,32,std::vector<uint8_t>(32*32*4)};
|
||||||
|
for(int y=4;y<28;++y)for(int x=4;x<28;++x)pixel(tiny_black_detail,x,y,{255,255,255,255});
|
||||||
|
pixel(tiny_black_detail,16,16,{0,0,0,255});
|
||||||
|
require(!crest_for_light_surface(tiny_black_detail), "Small black brand detail was recoloured");
|
||||||
|
auto blue=source;
|
||||||
|
for(size_t i=0;i<blue.pixels.size();i+=4)if(blue.pixels[i+3]) {blue.pixels[i]=220;blue.pixels[i+1]=240;blue.pixels[i+2]=255;}
|
||||||
|
require(!crest_for_light_surface(blue), "Pale coloured crest was recoloured");
|
||||||
|
Raster opaque{16,16,std::vector<uint8_t>(16*16*4,255)};
|
||||||
|
require(!crest_for_light_surface(opaque), "White rectangular artwork was recoloured");
|
||||||
|
pixel(opaque,0,0,{0,0,0,0});
|
||||||
|
require(!crest_for_light_surface(opaque), "Tiny transparent corner made a white backdrop qualify");
|
||||||
|
Raster empty{16,16,std::vector<uint8_t>(16*16*4,0)};
|
||||||
|
require(!crest_for_light_surface(empty) && !crest_for_light_surface(*variant),
|
||||||
|
"Empty/dark crest was recoloured");
|
||||||
|
require(!crest_for_light_surface(Raster{0,16,{}}) &&
|
||||||
|
!crest_for_light_surface(Raster{16,16,{255,255,255,255}}),
|
||||||
|
"Malformed raster bounds were accepted");
|
||||||
|
}
|
||||||
void write(const fs::path &root, const std::string &file, const Json &value) {
|
void write(const fs::path &root, const std::string &file, const Json &value) {
|
||||||
fs::create_directories((root / file).parent_path());
|
fs::create_directories((root / file).parent_path());
|
||||||
bmh::editor::write_atomic(root / file, value.dump());
|
bmh::editor::write_atomic(root / file, value.dump());
|
||||||
@@ -327,6 +384,7 @@ void check_finance_source(const fs::path &root,
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
int main(int argc, char **argv) try {
|
int main(int argc, char **argv) try {
|
||||||
|
check_crest_contrast();
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
auto catalog = Catalog::open(bmh::editor::path(argv[1]));
|
auto catalog = Catalog::open(bmh::editor::path(argv[1]));
|
||||||
const auto before = catalog->summary();
|
const auto before = catalog->summary();
|
||||||
|
|||||||
Reference in new issue
Block a user