The surroundings with the project's own pictures, kept in the repository
assets/modern/art holds pictures of the project's own with a catalogue; a key named there is drawn from that folder, whatever a supplied picture pack says about it. The six cards of the surroundings take theirs from it, framed on the faces. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
98fb61dddf
commit
ff9ed94d1b
8 files changed
+101
-14
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 3.7 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
@@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"schema": "openbmh-gui-assets@1",
|
||||||
|
"note": "The project's own pictures. A key named here is drawn from this folder, whatever a supplied picture pack says about it.",
|
||||||
|
"items": {
|
||||||
|
"environment.youth.0": {
|
||||||
|
"file": "environment-people.png",
|
||||||
|
"sha256": "644f491b9a19ac7f6ed1aeffde50b8fb55f4cc38a234b8674d84e8c5e1e4d957",
|
||||||
|
"crop": [
|
||||||
|
0.0055,
|
||||||
|
0.0405,
|
||||||
|
0.3223,
|
||||||
|
0.231
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"environment.youth.1": {
|
||||||
|
"file": "environment-people.png",
|
||||||
|
"sha256": "644f491b9a19ac7f6ed1aeffde50b8fb55f4cc38a234b8674d84e8c5e1e4d957",
|
||||||
|
"crop": [
|
||||||
|
0.3389,
|
||||||
|
0.0147,
|
||||||
|
0.3223,
|
||||||
|
0.231
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"environment.youth.2": {
|
||||||
|
"file": "environment-people.png",
|
||||||
|
"sha256": "644f491b9a19ac7f6ed1aeffde50b8fb55f4cc38a234b8674d84e8c5e1e4d957",
|
||||||
|
"crop": [
|
||||||
|
0.6722,
|
||||||
|
0.0037,
|
||||||
|
0.3223,
|
||||||
|
0.231
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"environment.staff.0": {
|
||||||
|
"file": "environment-people.png",
|
||||||
|
"sha256": "644f491b9a19ac7f6ed1aeffde50b8fb55f4cc38a234b8674d84e8c5e1e4d957",
|
||||||
|
"crop": [
|
||||||
|
0.0055,
|
||||||
|
0.5037,
|
||||||
|
0.3223,
|
||||||
|
0.231
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"environment.staff.1": {
|
||||||
|
"file": "environment-doctor.png",
|
||||||
|
"sha256": "4ac325814508a6dad9115451ce0ce6159372fbb932ef7c08dd5094dc7e555205",
|
||||||
|
"crop": [
|
||||||
|
0,
|
||||||
|
0.0074,
|
||||||
|
1,
|
||||||
|
0.7168
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"environment.staff.2": {
|
||||||
|
"file": "environment-people.png",
|
||||||
|
"sha256": "644f491b9a19ac7f6ed1aeffde50b8fb55f4cc38a234b8674d84e8c5e1e4d957",
|
||||||
|
"crop": [
|
||||||
|
0.6722,
|
||||||
|
0.5037,
|
||||||
|
0.3223,
|
||||||
|
0.231
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,6 +69,13 @@ foreach(icon ${modern_icons})
|
|||||||
get_filename_component(icon_name "${icon}" NAME)
|
get_filename_component(icon_name "${icon}" NAME)
|
||||||
configure_file("${icon}" "${modern_assets}/icons/${icon_name}" COPYONLY)
|
configure_file("${icon}" "${modern_assets}/icons/${icon_name}" COPYONLY)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
# the project's own pictures with their catalogue
|
||||||
|
file(GLOB modern_art CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/assets/modern/art/*")
|
||||||
|
file(MAKE_DIRECTORY "${modern_assets}/art")
|
||||||
|
foreach(art ${modern_art})
|
||||||
|
get_filename_component(art_name "${art}" NAME)
|
||||||
|
configure_file("${art}" "${modern_assets}/art/${art_name}" COPYONLY)
|
||||||
|
endforeach()
|
||||||
# the display serif and the chalk hand (SIL Open Font License, THIRD_PARTY_NOTICES.md)
|
# the display serif and the chalk hand (SIL Open Font License, THIRD_PARTY_NOTICES.md)
|
||||||
file(GLOB modern_fonts CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/assets/modern/fonts/*")
|
file(GLOB modern_fonts CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/assets/modern/fonts/*")
|
||||||
file(MAKE_DIRECTORY "${modern_assets}/fonts")
|
file(MAKE_DIRECTORY "${modern_assets}/fonts")
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ std::string App::render_environment() {
|
|||||||
for (const auto &row : rows) total += row.at("cost").get<int64_t>();
|
for (const auto &row : rows) total += row.at("cost").get<int64_t>();
|
||||||
page_title_ = "Umfeld – " + money(total, currency) + " pro Monat";
|
page_title_ = "Umfeld – " + money(total, currency) + " pro Monat";
|
||||||
// a card is a third of the page wide; its picture takes the height that is left
|
// a card is a third of the page wide; its picture takes the height that is left
|
||||||
const double card_width = (2799 - 2 * 31.5) / 3, picture_width = card_width - 2 * 36 - 4, picture_height = 396;
|
const double card_width = (2799 - 2 * 31.5) / 3, picture_width = card_width - 2 * 36 - 4, picture_height = 500;
|
||||||
std::string out = "<div class=\"pg-page\" id=\"environment-ring\"><div class=\"env-grid\">";
|
std::string out = "<div class=\"pg-page\" id=\"environment-ring\"><div class=\"env-grid\">";
|
||||||
for (size_t i = 0; i < rows.size(); ++i) {
|
for (size_t i = 0; i < rows.size(); ++i) {
|
||||||
const auto &row = rows[i];
|
const auto &row = rows[i];
|
||||||
|
|||||||
@@ -4,22 +4,30 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace bmh::modern_ui {
|
namespace bmh::modern_ui {
|
||||||
GuiAssets::GuiAssets(fs::path root) : root_(std::move(root)) {
|
GuiAssets::GuiAssets(fs::path root, fs::path own) : root_(std::move(root)), own_root_(std::move(own)) {
|
||||||
if (root_.empty() || !fs::exists(root_ / "gui-assets.json"))
|
if (!root_.empty() && fs::exists(root_ / "gui-assets.json")) {
|
||||||
return;
|
|
||||||
root_ = fs::weakly_canonical(root_);
|
root_ = fs::weakly_canonical(root_);
|
||||||
auto document = Json::parse(editor::read_file(root_ / "gui-assets.json"));
|
load(root_, false);
|
||||||
|
}
|
||||||
|
if (!own_root_.empty() && fs::exists(own_root_ / "gui-assets.json")) {
|
||||||
|
own_root_ = fs::weakly_canonical(own_root_);
|
||||||
|
load(own_root_, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void GuiAssets::load(const fs::path &folder, bool own) {
|
||||||
|
auto document = Json::parse(editor::read_file(folder / "gui-assets.json"));
|
||||||
if (document.value("schema", "") != "openbmh-gui-assets@1" ||
|
if (document.value("schema", "") != "openbmh-gui-assets@1" ||
|
||||||
!document.at("items").is_object())
|
!document.at("items").is_object())
|
||||||
throw editor::Error("invalid_gui_catalog");
|
throw editor::Error("invalid_gui_catalog");
|
||||||
items_ = document.at("items");
|
for (const auto &[key, item] : document.at("items").items()) {
|
||||||
for (const auto &[key, item] : items_.items()) {
|
|
||||||
const auto relative = editor::path(item.at("file").get<std::string>());
|
const auto relative = editor::path(item.at("file").get<std::string>());
|
||||||
const auto full = fs::weakly_canonical(root_ / relative);
|
const auto full = fs::weakly_canonical(folder / relative);
|
||||||
const auto inside = full.lexically_relative(root_);
|
const auto inside = full.lexically_relative(folder);
|
||||||
if (relative.is_absolute() || inside.empty() || *inside.begin() == ".." ||
|
if (relative.is_absolute() || inside.empty() || *inside.begin() == ".." ||
|
||||||
!fs::is_regular_file(full))
|
!fs::is_regular_file(full))
|
||||||
throw editor::Error("missing_or_unsafe_gui_asset", {{"key", key}});
|
throw editor::Error("missing_or_unsafe_gui_asset", {{"key", key}});
|
||||||
|
items_[key] = item;
|
||||||
|
if (own) own_.insert(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
editor::images::Raster GuiAssets::decode(const std::string &key,
|
editor::images::Raster GuiAssets::decode(const std::string &key,
|
||||||
@@ -27,7 +35,7 @@ editor::images::Raster GuiAssets::decode(const std::string &key,
|
|||||||
if (!items_.contains(key))
|
if (!items_.contains(key))
|
||||||
throw editor::Error("missing_gui_asset", {{"key", key}});
|
throw editor::Error("missing_gui_asset", {{"key", key}});
|
||||||
const auto item = items_.at(key);
|
const auto item = items_.at(key);
|
||||||
const auto file = root_ / editor::path(item.at("file").get<std::string>());
|
const auto file = (own_.contains(key) ? own_root_ : root_) / editor::path(item.at("file").get<std::string>());
|
||||||
auto image = editor::images::decode(editor::read_file(file),
|
auto image = editor::images::decode(editor::read_file(file),
|
||||||
file.extension().string(), pixels);
|
file.extension().string(), pixels);
|
||||||
if (!item.contains("crop"))
|
if (!item.contains("crop"))
|
||||||
|
|||||||
@@ -2,19 +2,25 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "editor/images.hpp"
|
#include "editor/images.hpp"
|
||||||
#include "modern/ui/catalog.hpp"
|
#include "modern/ui/catalog.hpp"
|
||||||
|
#include <set>
|
||||||
|
|
||||||
namespace bmh::modern_ui {
|
namespace bmh::modern_ui {
|
||||||
class GuiAssets {
|
class GuiAssets {
|
||||||
public:
|
public:
|
||||||
explicit GuiAssets(fs::path root = {});
|
// `own` is the folder of the project's own pictures; what its catalogue names comes from
|
||||||
bool available() const { return !items_.empty(); }
|
// there, whatever the supplied catalogue under `root` says about the same key.
|
||||||
|
explicit GuiAssets(fs::path root = {}, fs::path own = {});
|
||||||
|
// whether a picture pack was supplied; the own pictures alone do not make one
|
||||||
|
bool available() const { return items_.size() > own_.size(); }
|
||||||
editor::images::Raster decode(const std::string &, int pixels = 1024) const;
|
editor::images::Raster decode(const std::string &, int pixels = 1024) const;
|
||||||
bool contains(const std::string &key) const { return items_.contains(key); }
|
bool contains(const std::string &key) const { return items_.contains(key); }
|
||||||
const Json &items() const { return items_; }
|
const Json &items() const { return items_; }
|
||||||
const fs::path &root() const { return root_; }
|
const fs::path &root() const { return root_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fs::path root_;
|
void load(const fs::path &folder, bool own);
|
||||||
|
fs::path root_, own_root_;
|
||||||
Json items_ = Json::object();
|
Json items_ = Json::object();
|
||||||
|
std::set<std::string> own_; // the keys that come from the project's own pictures
|
||||||
};
|
};
|
||||||
} // namespace bmh::modern_ui
|
} // namespace bmh::modern_ui
|
||||||
@@ -1526,7 +1526,7 @@ public:
|
|||||||
gui_root_(config.gui_assets.empty() ? assets_ / "gui"
|
gui_root_(config.gui_assets.empty() ? assets_ / "gui"
|
||||||
: config.gui_assets),
|
: config.gui_assets),
|
||||||
migrate_(std::move(migrate)), config_(std::move(config)),
|
migrate_(std::move(migrate)), config_(std::move(config)),
|
||||||
gui_(gui_root_),
|
gui_(gui_root_, assets_ / "art"),
|
||||||
video_("Dreierpack Manager", config_.width, config_.height, 960, 540),
|
video_("Dreierpack Manager", config_.width, config_.height, 960, 540),
|
||||||
system_(video_.window), renderer_(video_, gui_, assets_) {
|
system_(video_.window), renderer_(video_, gui_, assets_) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in new issue
Block a user