Zoom menu windows to the screen and add a text size audit to the UI script driver
A menu window is shown as large as the screen allows instead of at the scale of the whole 3840 x 2160 stage (about 15 % larger on a 16:10 laptop). The script command text-audit lists every visible text with its drawn size and whether its box is too narrow. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
1de09ba8a6
commit
2f71bd70f1
3 files changed
+41
No files matched your search
@@ -48,6 +48,7 @@
|
||||
#include "modern/ui/view.hpp"
|
||||
#include "version.hpp"
|
||||
#include <RmlUi/Core.h>
|
||||
#include <RmlUi/Core/ElementText.h>
|
||||
#include <cstring>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
@@ -375,6 +376,9 @@ class App final : public Rml::EventListener {
|
||||
bool initialized_ = false, closed_ = false, dirty_ = true,
|
||||
needs_render_ = true;
|
||||
double scale_ = 1, canvas_left_ = 0, canvas_top_ = 0;
|
||||
// A menu window (2720 x 2040 at the middle of the stage) is shown as large as the screen
|
||||
// allows; the desk behind it is cropped. Without a window the whole stage is fitted.
|
||||
bool window_zoom_ = false;
|
||||
std::string scene_ = "main", menu_, theme_ = "midnight", active_mod_,
|
||||
selected_mod_, notice_, country_ = "nation:de", league_,
|
||||
selected_club_;
|
||||
@@ -874,6 +878,13 @@ class App final : public Rml::EventListener {
|
||||
"shadow(" + offset + "px " + offset + "px #386824)");
|
||||
}
|
||||
}
|
||||
// Called after the stage was rebuilt: zoom in when it now shows a menu window.
|
||||
void sync_window_zoom() {
|
||||
const bool wanted = doc_->QuerySelector(".window") != nullptr;
|
||||
if (wanted == window_zoom_) return;
|
||||
window_zoom_ = wanted;
|
||||
resize();
|
||||
}
|
||||
void resize() {
|
||||
int w, h, pw, ph;
|
||||
SDL_GetWindowSize(video_.window, &w, &h);
|
||||
@@ -881,6 +892,7 @@ class App final : public Rml::EventListener {
|
||||
if (w <= 0 || h <= 0 || pw <= 0 || ph <= 0)
|
||||
return;
|
||||
scale_ = std::min(double(pw) / 3840, double(ph) / 2160);
|
||||
if (window_zoom_) scale_ = std::max(scale_, std::min(double(pw) / 2760, double(ph) / 2080));
|
||||
canvas_left_ = (pw - 3840 * scale_) / 2;
|
||||
canvas_top_ = (ph - 2160 * scale_) / 2;
|
||||
device_ratio_ = float(pw) / w;
|
||||
@@ -994,6 +1006,7 @@ class App final : public Rml::EventListener {
|
||||
setting_menu_markup_ = true;
|
||||
element("canvas")->SetInnerRML(markup);
|
||||
++document_generation_;
|
||||
sync_window_zoom();
|
||||
live_detail_pending_ = live_ticker_pending_ = false;
|
||||
element("canvas")->SetProperty("overflow", statistics_trophy_.contains("asset") ? "visible" : "hidden");
|
||||
setting_menu_markup_ = false;
|
||||
|
||||
Reference in new issue
Block a user