retocs sucosets al minimap
This commit is contained in:
@@ -64,6 +64,14 @@ void MapEditor::loadSettings() {
|
||||
auto yaml = fkyaml::node::deserialize(content);
|
||||
if (yaml.contains("grid")) { settings_.grid = yaml["grid"].get_value<bool>(); }
|
||||
if (yaml.contains("show_render_info")) { settings_.show_render_info = yaml["show_render_info"].get_value<bool>(); }
|
||||
if (yaml.contains("minimap_bg")) {
|
||||
if (yaml["minimap_bg"].is_string()) { settings_.minimap_bg = yaml["minimap_bg"].get_value<std::string>(); }
|
||||
else if (yaml["minimap_bg"].is_integer()) { settings_.minimap_bg = std::to_string(yaml["minimap_bg"].get_value<int>()); }
|
||||
}
|
||||
if (yaml.contains("minimap_conn")) {
|
||||
if (yaml["minimap_conn"].is_string()) { settings_.minimap_conn = yaml["minimap_conn"].get_value<std::string>(); }
|
||||
else if (yaml["minimap_conn"].is_integer()) { settings_.minimap_conn = std::to_string(yaml["minimap_conn"].get_value<int>()); }
|
||||
}
|
||||
} catch (...) {
|
||||
// Fichero corrupto o vacío, usar defaults
|
||||
}
|
||||
@@ -80,6 +88,8 @@ void MapEditor::saveSettings() {
|
||||
file << "# Map Editor Settings\n";
|
||||
file << "grid: " << (settings_.grid ? "true" : "false") << "\n";
|
||||
file << "show_render_info: " << (settings_.show_render_info ? "true" : "false") << "\n";
|
||||
file << "minimap_bg: " << settings_.minimap_bg << "\n";
|
||||
file << "minimap_conn: " << settings_.minimap_conn << "\n";
|
||||
file.close();
|
||||
}
|
||||
|
||||
@@ -100,13 +110,37 @@ auto MapEditor::showGrid(bool show) -> std::string {
|
||||
return show ? "Grid ON" : "Grid OFF";
|
||||
}
|
||||
|
||||
// Parsea un color por nombre o índice numérico
|
||||
static auto parseColor(const std::string& value) -> Uint8 {
|
||||
try { return static_cast<Uint8>(std::stoi(value)); }
|
||||
catch (...) { return stringToColor(value); }
|
||||
}
|
||||
|
||||
void MapEditor::toggleMiniMap() {
|
||||
if (!mini_map_) {
|
||||
mini_map_ = std::make_unique<MiniMap>();
|
||||
mini_map_ = std::make_unique<MiniMap>(parseColor(settings_.minimap_bg), parseColor(settings_.minimap_conn));
|
||||
}
|
||||
mini_map_visible_ = !mini_map_visible_;
|
||||
}
|
||||
|
||||
auto MapEditor::setMiniMapBg(const std::string& color) -> std::string {
|
||||
settings_.minimap_bg = toLower(color);
|
||||
saveSettings();
|
||||
if (mini_map_) {
|
||||
mini_map_->rebuild(parseColor(settings_.minimap_bg), parseColor(settings_.minimap_conn));
|
||||
}
|
||||
return "minimap bg: " + settings_.minimap_bg;
|
||||
}
|
||||
|
||||
auto MapEditor::setMiniMapConn(const std::string& color) -> std::string {
|
||||
settings_.minimap_conn = toLower(color);
|
||||
saveSettings();
|
||||
if (mini_map_) {
|
||||
mini_map_->rebuild(parseColor(settings_.minimap_bg), parseColor(settings_.minimap_conn));
|
||||
}
|
||||
return "minimap conn: " + settings_.minimap_conn;
|
||||
}
|
||||
|
||||
// Entra en modo editor
|
||||
void MapEditor::enter(std::shared_ptr<Room> room, std::shared_ptr<Player> player, const std::string& room_path, std::shared_ptr<Scoreboard::Data> scoreboard_data) {
|
||||
if (active_) { return; }
|
||||
|
||||
Reference in New Issue
Block a user