Colors are now being loaded from assets/palette.json

This commit is contained in:
Zed A. Shaw 2025-07-17 10:50:09 -04:00
parent 48a7f72411
commit f4fa50a413
13 changed files with 113 additions and 52 deletions

View file

@ -9,6 +9,7 @@
#include <functional>
#include <iostream>
#include "textures.hpp"
#include "palette.hpp"
namespace fs = std::filesystem;
constexpr const int TILE_COUNT=10;
@ -217,16 +218,14 @@ void load_config(MapConfig& config, bool is_centered, std::string path, std::fun
(int)display, (std::string)key));
if(data.contains("foreground")) {
auto fg_color = data["foreground"];
sf::Color fg{fg_color[0], fg_color[1], fg_color[2]};
auto fg = palette::get(data["foreground"]);
config.colors.insert_or_assign(display, fg);
} else {
config.colors.insert_or_assign(display, DEFAULT_COLOR);
}
if(data.contains("background")) {
auto bg_color = data["background"];
sf::Color bg{bg_color[0], bg_color[1], bg_color[2]};
auto bg = palette::get(data["background"]);
config.backgrounds.insert_or_assign(display, bg);
} else {
sf::Color bg{0, 0, 0, 0};
@ -249,6 +248,7 @@ json& component_display(json& val) {
}
int main() {
palette::init();
MapConfig config;
load_config(config, false, "./assets/tiles.json", [](json& val) -> json& {