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
+21
-1
@@ -5,6 +5,7 @@
|
||||
#include "launch/rml_path.hpp"
|
||||
#include "launch/rml_video.hpp"
|
||||
#include "modern/ui/controls.hpp"
|
||||
#include "modern/ui/crest_contrast.hpp"
|
||||
#include "modern/ui/engine_bridge.hpp"
|
||||
#include "modern/ui/live_match_info.hpp"
|
||||
#include "modern/ui/script_locator.hpp"
|
||||
@@ -301,6 +302,25 @@ public:
|
||||
const auto &r = entries_.at(found->second).raster;
|
||||
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,
|
||||
const Rml::String &source) override {
|
||||
const auto token = editor::utf8(editor::path(source).filename());
|
||||
@@ -528,7 +548,7 @@ class App final : public Rml::EventListener {
|
||||
"dp;\"/></div>";
|
||||
}
|
||||
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) {
|
||||
return img("icon." + name + (theme_ == "silver" ? "-ink" : ""), size, size,
|
||||
|
||||
Reference in new issue
Block a user