ajustos de qualitat, canvi de tecles, persistencia de opcions, etc
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource::Cache
|
||||
#include "core/resources/resource_list.hpp" // Para Resource::List
|
||||
#include "core/resources/resource_types.hpp" // Para RoomResource
|
||||
#include "core/system/debug.hpp" // Para Debug (persistencia de render_info)
|
||||
#include "external/fkyaml_node.hpp" // Para fkyaml::node (loadSettings)
|
||||
#include "game/editor/editor_statusbar.hpp" // Para EditorStatusBar
|
||||
#include "game/entities/player.hpp" // Para Player
|
||||
@@ -76,7 +77,6 @@ void MapEditor::loadSettings() {
|
||||
try {
|
||||
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_integer()) {
|
||||
settings_.minimap_bg = static_cast<Uint8>(yaml["minimap_bg"].get_value<int>());
|
||||
@@ -106,19 +106,17 @@ void MapEditor::saveSettings() const {
|
||||
|
||||
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: " << static_cast<int>(settings_.minimap_bg) << "\n";
|
||||
file << "minimap_conn: " << static_cast<int>(settings_.minimap_conn) << "\n";
|
||||
file.close();
|
||||
}
|
||||
|
||||
// Muestra/oculta render info (persistente)
|
||||
// Muestra/oculta render info (persistente en debug.yaml, fuente de verdad global)
|
||||
auto MapEditor::showInfo(bool show) -> std::string {
|
||||
settings_.show_render_info = show;
|
||||
if (RenderInfo::get()->isActive() != show) {
|
||||
RenderInfo::get()->toggle();
|
||||
}
|
||||
saveSettings();
|
||||
if (Debug::get() != nullptr) { Debug::get()->setRenderInfoEnabled(show); }
|
||||
return show ? "Info ON" : "Info OFF";
|
||||
}
|
||||
|
||||
@@ -203,18 +201,12 @@ void MapEditor::enter(std::shared_ptr<Room> room, std::shared_ptr<Player> player
|
||||
if (!reenter_) {
|
||||
// Solo guardar estado previo en el primer enter (no en re-enter tras cambio de room)
|
||||
invincible_before_editor_ = Options::cheats.invincible;
|
||||
render_info_before_editor_ = RenderInfo::get()->isActive();
|
||||
}
|
||||
reenter_ = false;
|
||||
|
||||
// Forzar invencibilidad
|
||||
Options::cheats.invincible = Options::Cheat::State::ENABLED;
|
||||
|
||||
// Aplicar el setting de render_info del editor
|
||||
if (settings_.show_render_info != RenderInfo::get()->isActive()) {
|
||||
RenderInfo::get()->toggle();
|
||||
}
|
||||
|
||||
// Activar scope de la consola para el editor
|
||||
Console::get()->setScope("editor");
|
||||
|
||||
@@ -256,10 +248,6 @@ void MapEditor::exit() {
|
||||
if (!reenter_) {
|
||||
// Solo restaurar en el exit final (no en cambio de room)
|
||||
Options::cheats.invincible = invincible_before_editor_;
|
||||
|
||||
if (RenderInfo::get()->isActive() != render_info_before_editor_) {
|
||||
RenderInfo::get()->toggle();
|
||||
}
|
||||
}
|
||||
|
||||
// Restaurar prompt y scope de la consola
|
||||
@@ -443,8 +431,13 @@ void MapEditor::render() {
|
||||
|
||||
// Maneja eventos del editor
|
||||
void MapEditor::handleEvent(const SDL_Event& event) { // NOLINT(readability-function-cognitive-complexity)
|
||||
// Si el tile picker está abierto, los eventos van a él
|
||||
// Si el tile picker está abierto, los eventos van a él.
|
||||
// Excepción: la T lo cierra como toggle (sin tocar el brush).
|
||||
if (tile_picker_.isOpen()) {
|
||||
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_T && static_cast<int>(event.key.repeat) == 0) {
|
||||
tile_picker_.close();
|
||||
return;
|
||||
}
|
||||
tile_picker_.handleEvent(event);
|
||||
return;
|
||||
}
|
||||
@@ -528,7 +521,7 @@ void MapEditor::handleEvent(const SDL_Event& event) { // NOLINT(readability-fun
|
||||
}
|
||||
}
|
||||
|
||||
// T: abrir TilePicker
|
||||
// T: abrir TilePicker (el cierre con T también se gestiona arriba, antes de delegar al picker)
|
||||
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_T && static_cast<int>(event.key.repeat) == 0) {
|
||||
// Deseleccionar entidades
|
||||
selection_.clear();
|
||||
@@ -1464,7 +1457,8 @@ void MapEditor::updateStatusBarInfo() { // NOLINT(readability-function-cognitiv
|
||||
// Propiedades de la habitación
|
||||
std::string ts_marker = room_data_.tile_set_overridden ? " (ts*)" : "";
|
||||
std::string mu_marker = room_data_.music_overridden ? " (mu*)" : "";
|
||||
line2 = "zone:" + room_data_.zone + ts_marker + mu_marker;
|
||||
std::string bg_marker = room_data_.bg_color_overridden ? "*" : "";
|
||||
line2 = "zone:" + room_data_.zone + ts_marker + mu_marker + " bg:" + std::to_string(room_data_.bg_color) + bg_marker;
|
||||
line3 = "u:" + conn(room_data_.upper_room) + " d:" + conn(room_data_.lower_room) +
|
||||
" l:" + conn(room_data_.left_room) + " r:" + conn(room_data_.right_room);
|
||||
break;
|
||||
@@ -1509,7 +1503,7 @@ auto MapEditor::getSetCompletions() const -> std::vector<std::string> {
|
||||
case EntityType::DOOR:
|
||||
return {"ID", "ANIMATION"};
|
||||
default:
|
||||
return {"ZONE", "TILESET", "MUSIC", "UP", "DOWN", "LEFT", "RIGHT"};
|
||||
return {"ZONE", "TILESET", "MUSIC", "BGCOLOR", "UP", "DOWN", "LEFT", "RIGHT"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1733,6 +1727,10 @@ auto MapEditor::setRoomProperty(const std::string& property, const std::string&
|
||||
if (!room_data_.music_overridden) {
|
||||
room_data_.music = zone->music;
|
||||
}
|
||||
if (!room_data_.bg_color_overridden) {
|
||||
room_data_.bg_color = zone->bg_color;
|
||||
room_->setBgColor(zone->bg_color);
|
||||
}
|
||||
autosave();
|
||||
return "zone: " + val;
|
||||
}
|
||||
@@ -1758,6 +1756,30 @@ auto MapEditor::setRoomProperty(const std::string& property, const std::string&
|
||||
return "tileset: " + tileset;
|
||||
}
|
||||
|
||||
if (property == "BGCOLOR") {
|
||||
// "reset" / "none" limpia el override y vuelve a heredar de la zona
|
||||
if (val == "reset" || val == "none") {
|
||||
room_data_.bg_color_overridden = false;
|
||||
const Zone::Data* zone = ZoneManager::get()->getZone(room_data_.zone);
|
||||
if (zone != nullptr) {
|
||||
room_data_.bg_color = zone->bg_color;
|
||||
room_->setBgColor(zone->bg_color);
|
||||
}
|
||||
autosave();
|
||||
return "bgcolor: (inherit from zone)";
|
||||
}
|
||||
int color = 0;
|
||||
try {
|
||||
color = std::stoi(val);
|
||||
} catch (...) { return "usage: set bgcolor <0-255|reset>"; }
|
||||
if (color < 0 || color > 255) { return "bgcolor must be 0-255"; }
|
||||
room_data_.bg_color = static_cast<Uint8>(color);
|
||||
room_data_.bg_color_overridden = true;
|
||||
room_->setBgColor(static_cast<Uint8>(color));
|
||||
autosave();
|
||||
return "bgcolor: " + std::to_string(color);
|
||||
}
|
||||
|
||||
if (property == "MUSIC") {
|
||||
// "reset" / "none" limpia el override y vuelve a heredar de la zona
|
||||
if (val == "reset" || val == "none") {
|
||||
@@ -1875,7 +1897,7 @@ auto MapEditor::setRoomProperty(const std::string& property, const std::string&
|
||||
return toLower(property) + ": " + connection;
|
||||
}
|
||||
|
||||
return "Unknown property: " + property + " (use: zone, itemcolor1, itemcolor2, conveyor, tileset, music, up, down, left, right)";
|
||||
return "Unknown property: " + property + " (use: zone, itemcolor1, itemcolor2, conveyor, tileset, music, bgcolor, up, down, left, right)";
|
||||
}
|
||||
|
||||
// Crea una nueva habitación
|
||||
|
||||
Reference in New Issue
Block a user