Revert "skins: SkinManager + hot-swap (F7), classic/nes a data/skins/"
This reverts commit ebfcad6f22.
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
#include "core/input/input.h"
|
||||
#include "core/locale/lang.h"
|
||||
#include "core/rendering/screen.h"
|
||||
#include "core/resources/resource.h"
|
||||
#include "core/resources/skin_manager.hpp"
|
||||
#include "game/options.hpp"
|
||||
#include "utils/utils.h"
|
||||
|
||||
@@ -20,7 +18,6 @@ namespace GlobalInputs {
|
||||
constexpr int LANG_SHADER = 99;
|
||||
constexpr int LANG_PRESET = 100;
|
||||
constexpr int LANG_EXIT_CONFIRM = 101;
|
||||
constexpr int LANG_SKIN = 102;
|
||||
|
||||
constexpr Uint32 NOTIFY_MS = 1500;
|
||||
constexpr Uint32 EXIT_CONFIRM_MS = 2000;
|
||||
@@ -66,11 +63,6 @@ namespace GlobalInputs {
|
||||
Screen::get()->notify(MSG, GREEN, BLACK, NOTIFY_MS);
|
||||
}
|
||||
|
||||
void notifySkin() {
|
||||
const std::string MSG = Lang::get()->getText(LANG_SKIN) + " " + SkinManager::get()->currentDisplayName();
|
||||
Screen::get()->notify(MSG, CYAN, BLACK, NOTIFY_MS);
|
||||
}
|
||||
|
||||
void onExit() {
|
||||
const Uint32 NOW = SDL_GetTicks();
|
||||
if (NOW < exit_window_until_ticks) {
|
||||
@@ -125,14 +117,6 @@ namespace GlobalInputs {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (Input::get()->checkInput(Input::Action::NEXT_SKIN, Input::Repeat::OFF)) {
|
||||
const std::string NEXT_ID = SkinManager::get()->nextSkinId();
|
||||
if (NEXT_ID != SkinManager::get()->current()) {
|
||||
Resource::get()->reloadForSkin(NEXT_ID);
|
||||
}
|
||||
notifySkin();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
namespace GlobalInputs {
|
||||
// Gestiona els atalls globals disponibles en qualsevol escena: zoom de
|
||||
// finestra (F1/F2), fullscreen (F3), toggle shader (F4), tipus de shader
|
||||
// POSTFX↔CRTPI (F5), següent preset (F6), següent skin (F7) i la
|
||||
// confirmació d'eixida amb ESC (Action::EXIT) en dues pulsacions. Cada
|
||||
// hotkey emet una notificació localitzada. Retorna true si ha consumit
|
||||
// alguna tecla (per si la capa cridant vol suprimir-la del processament
|
||||
// específic de l'escena).
|
||||
// POSTFX↔CRTPI (F5), següent preset (F6) i la confirmació d'eixida amb
|
||||
// ESC (Action::EXIT) en dues pulsacions. Cada hotkey emet una
|
||||
// notificació localitzada. Retorna true si ha consumit alguna tecla (per
|
||||
// si la capa cridant vol suprimir-la del processament específic de
|
||||
// l'escena).
|
||||
auto handle() -> bool;
|
||||
|
||||
// True si la doble pulsació d'ESC s'ha confirmat. Director consulta açò
|
||||
|
||||
@@ -50,9 +50,6 @@ class Input {
|
||||
TOGGLE_SHADER,
|
||||
TOGGLE_SHADER_TYPE,
|
||||
|
||||
// Skins
|
||||
NEXT_SKIN,
|
||||
|
||||
// Centinela final (usar para sizing)
|
||||
NUMBER_OF_INPUTS
|
||||
};
|
||||
@@ -64,12 +61,12 @@ class Input {
|
||||
|
||||
~Input(); // Destructor
|
||||
|
||||
void update(); // Actualiza el estado del objeto
|
||||
void update(); // Actualiza el estado del objeto
|
||||
void bindKey(Action input, SDL_Scancode code); // Asigna inputs a teclas
|
||||
void bindGameControllerButton(Action input, SDL_GamepadButton button); // Asigna inputs a botones del mando
|
||||
|
||||
auto checkInput(Action input, Repeat repeat = Repeat::ON, Device device = Device::ANY, int index = 0) -> bool; // Comprueba si un input esta activo
|
||||
auto checkAnyInput(Device device = Device::ANY, int index = 0) -> bool; // Comprueba si hay almenos un input activo
|
||||
auto checkAnyInput(Device device = Device::ANY, int index = 0) -> bool; // Comprueba si hay almenos un input activo
|
||||
|
||||
auto discoverGameController() -> bool; // Busca si hay un mando conectado
|
||||
|
||||
@@ -85,9 +82,9 @@ class Input {
|
||||
[[nodiscard]] auto getNumControllers() const -> int; // Obten el numero de mandos conectados
|
||||
auto getControllerName(int index) -> std::string; // Obten el nombre de un mando de juego
|
||||
|
||||
void setVerbose(bool value); // Establece si ha de mostrar mensajes
|
||||
void disableUntil(Disable value); // Deshabilita las entradas durante un periodo de tiempo
|
||||
void enable(); // Hablita las entradas
|
||||
void setVerbose(bool value); // Establece si ha de mostrar mensajes
|
||||
void disableUntil(Disable value); // Deshabilita las entradas durante un periodo de tiempo
|
||||
void enable(); // Hablita las entradas
|
||||
|
||||
private:
|
||||
struct KeyBindings {
|
||||
|
||||
@@ -30,7 +30,7 @@ class Lang {
|
||||
static auto nextLanguage(Code c) -> Code; // Devuelve el siguiente idioma del ciclo
|
||||
|
||||
private:
|
||||
static constexpr int MAX_TEXT_STRINGS = 111;
|
||||
static constexpr int MAX_TEXT_STRINGS = 110;
|
||||
|
||||
std::string text_strings_[MAX_TEXT_STRINGS]; // Vector con los textos
|
||||
|
||||
|
||||
@@ -212,14 +212,6 @@ auto Texture::reLoad() -> bool {
|
||||
return loadFromFile(path_, renderer_);
|
||||
}
|
||||
|
||||
// Reapunta el path emmagatzemat i recarrega: usat pel SkinManager per a
|
||||
// fer hot-swap d'skin mantenint estable el punter Texture* (els Sprites
|
||||
// continuen apuntant al mateix objecte amb contingut actualitzat).
|
||||
auto Texture::reLoadFromPath(const std::string &new_path) -> bool {
|
||||
path_ = new_path;
|
||||
return loadFromFile(path_, renderer_);
|
||||
}
|
||||
|
||||
// Obtiene la textura
|
||||
auto Texture::getSDLTexture() -> SDL_Texture * {
|
||||
return texture_;
|
||||
|
||||
@@ -26,14 +26,13 @@ class Texture {
|
||||
void setAlpha(Uint8 alpha); // Establece el alpha para la modulación
|
||||
|
||||
void render(SDL_Renderer *renderer, int x, int y, const SDL_Rect *clip = nullptr, float zoom_w = 1, float zoom_h = 1, double angle = 0.0, const SDL_Point *center = nullptr, SDL_FlipMode flip = SDL_FLIP_NONE); // Renderiza la textura en un punto específico
|
||||
void setAsRenderTarget(SDL_Renderer *renderer); // Establece la textura como objetivo de renderizado
|
||||
void setAsRenderTarget(SDL_Renderer *renderer); // Establece la textura como objetivo de renderizado
|
||||
|
||||
[[nodiscard]] auto getWidth() const -> int; // Obtiene el ancho de la imagen
|
||||
[[nodiscard]] auto getHeight() const -> int; // Obtiene el alto de la imagen
|
||||
|
||||
auto reLoad() -> bool; // Recarga la textura
|
||||
auto reLoadFromPath(const std::string &new_path) -> bool; // Reapunta path_ i recarrega (preserva el Texture*)
|
||||
auto getSDLTexture() -> SDL_Texture *; // Obtiene la textura
|
||||
auto reLoad() -> bool; // Recarga la textura
|
||||
auto getSDLTexture() -> SDL_Texture *; // Obtiene la textura
|
||||
|
||||
private:
|
||||
// Objetos y punteros
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, endl
|
||||
|
||||
#include "core/resources/resource_helper.h"
|
||||
#include "core/resources/skin_manager.hpp"
|
||||
|
||||
// Instancia única
|
||||
Asset *Asset::instance = nullptr;
|
||||
@@ -42,30 +41,6 @@ void Asset::add(const std::string &file, Type type, bool required, bool absolute
|
||||
longest_name_ = SDL_max(longest_name_, FILE_NAME.size());
|
||||
}
|
||||
|
||||
// Afegeix un asset gfx skin-aware: el path complet es composa via
|
||||
// SkinManager (que ja inclou el PREFIX de plataforma) i guardem el
|
||||
// basename per a poder-lo recomposar quan canviï la skin activa.
|
||||
void Asset::addSkinAware(const std::string &basename, Type type, bool required) {
|
||||
Item temp;
|
||||
temp.file = executable_path_ + SkinManager::get()->gfxPath(basename);
|
||||
temp.type = type;
|
||||
temp.required = required;
|
||||
temp.skin_basename = basename;
|
||||
file_list_.push_back(temp);
|
||||
|
||||
longest_name_ = SDL_max(longest_name_, basename.size());
|
||||
}
|
||||
|
||||
// Recomposa els paths dels items skin-aware amb l'skin actual del
|
||||
// SkinManager. Cridat per Resource::reloadForSkin després d'un canvi.
|
||||
void Asset::onSkinChanged() {
|
||||
for (auto &it : file_list_) {
|
||||
if (!it.skin_basename.empty()) {
|
||||
it.file = executable_path_ + SkinManager::get()->gfxPath(it.skin_basename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Devuelve el fichero de un elemento de la lista a partir de una cadena
|
||||
auto Asset::get(const std::string &text) -> std::string {
|
||||
for (const auto &f : file_list_) {
|
||||
|
||||
@@ -23,10 +23,9 @@ class Asset {
|
||||
|
||||
// Estructura para definir un item
|
||||
struct Item {
|
||||
std::string file; // Ruta del fichero desde la raiz del directorio
|
||||
Type type; // Indica el tipo de recurso
|
||||
bool required; // Indica si es un fichero que debe de existir
|
||||
std::string skin_basename; // No buit ⇒ item skin-aware (recomposable via SkinManager)
|
||||
std::string file; // Ruta del fichero desde la raiz del directorio
|
||||
Type type; // Indica el tipo de recurso
|
||||
bool required; // Indica si es un fichero que debe de existir
|
||||
};
|
||||
|
||||
// Singleton API
|
||||
@@ -35,8 +34,6 @@ class Asset {
|
||||
static auto get() -> Asset *; // Obtiene el puntero a la instancia
|
||||
|
||||
void add(const std::string &file, Type type, bool required = true, bool absolute = false); // Añade un elemento a la lista
|
||||
void addSkinAware(const std::string &basename, Type type, bool required = true); // Afegeix un asset gfx que viu sota la skin activa (recomposable)
|
||||
void onSkinChanged(); // Recomposa el path dels items skin-aware amb la skin actual
|
||||
auto get(const std::string &text) -> std::string; // Devuelve un elemento de la lista a partir de una cadena
|
||||
[[nodiscard]] auto getAll() const -> const std::vector<Item> & { return file_list_; } // Devuelve toda la lista de items registrados
|
||||
auto check() -> bool; // Comprueba que existen todos los elementos
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "core/rendering/texture.h"
|
||||
#include "core/resources/asset.h"
|
||||
#include "core/resources/resource_helper.h"
|
||||
#include "core/resources/skin_manager.hpp"
|
||||
#include "game/options.hpp"
|
||||
#include "game/ui/menu.h"
|
||||
|
||||
// Nota: Asset::get() e Input::get() se consultan en preloadAll y al construir
|
||||
@@ -265,41 +263,3 @@ auto Resource::getMenu(const std::string &name) -> Menu * {
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void Resource::reloadForSkin(const std::string &skin_id) {
|
||||
if (SkinManager::get() == nullptr || !SkinManager::get()->exists(skin_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkinManager::get()->setCurrent(skin_id);
|
||||
Asset::get()->onSkinChanged();
|
||||
|
||||
// Recarrega cada textura cachejada des del nou path mantenint pointer
|
||||
// identity perquè els Sprites no s'invaliden.
|
||||
for (auto &[bname, tex] : textures_) {
|
||||
const std::string NEW_PATH = Asset::get()->get(bname);
|
||||
if (!NEW_PATH.empty()) {
|
||||
tex->reLoadFromPath(NEW_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
// Re-parseja els fitxers .ani de la nova skin.
|
||||
for (auto &[bname, lines] : animation_lines_) {
|
||||
const std::string NEW_PATH = Asset::get()->get(bname);
|
||||
if (NEW_PATH.empty()) { continue; }
|
||||
auto bytes = ResourceHelper::loadFile(NEW_PATH);
|
||||
if (bytes.empty()) { continue; }
|
||||
std::string content(reinterpret_cast<const char *>(bytes.data()), bytes.size());
|
||||
std::stringstream ss(content);
|
||||
std::vector<std::string> new_lines;
|
||||
std::string line;
|
||||
while (std::getline(ss, line)) {
|
||||
if (!line.empty() && line.back() == '\r') { line.pop_back(); }
|
||||
new_lines.push_back(line);
|
||||
}
|
||||
lines = std::move(new_lines);
|
||||
}
|
||||
|
||||
Options::settings.skin = skin_id;
|
||||
Options::saveToFile();
|
||||
}
|
||||
|
||||
@@ -31,11 +31,6 @@ class Resource {
|
||||
auto getMenu(const std::string &name) -> Menu *; // name sin extensión: "title", "options", ...
|
||||
auto getDemoBytes() const -> const std::vector<uint8_t> & { return demo_bytes_; }
|
||||
|
||||
// Recarrega tots els recursos skin-aware (textures + animacions) per a
|
||||
// l'skin donada. Manté pointer identity dels Texture* perquè els Sprites
|
||||
// existents continuïn vàlids.
|
||||
void reloadForSkin(const std::string &skin_id);
|
||||
|
||||
private:
|
||||
explicit Resource(SDL_Renderer *renderer);
|
||||
~Resource();
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
#include "core/resources/skin_manager.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
#include "core/resources/resource_helper.h"
|
||||
#include "core/resources/resource_loader.h"
|
||||
#include "external/fkyaml_node.hpp"
|
||||
|
||||
SkinManager *SkinManager::instance = nullptr;
|
||||
|
||||
void SkinManager::init(const std::string &executable_path, const std::string &asset_prefix) {
|
||||
if (instance == nullptr) {
|
||||
instance = new SkinManager(executable_path, asset_prefix);
|
||||
instance->scan();
|
||||
}
|
||||
}
|
||||
|
||||
void SkinManager::destroy() {
|
||||
delete instance;
|
||||
instance = nullptr;
|
||||
}
|
||||
|
||||
auto SkinManager::get() -> SkinManager * {
|
||||
return instance;
|
||||
}
|
||||
|
||||
SkinManager::SkinManager(std::string executable_path, std::string asset_prefix)
|
||||
: executable_path_(std::move(executable_path)),
|
||||
asset_prefix_(std::move(asset_prefix)) {
|
||||
}
|
||||
|
||||
void SkinManager::scan() {
|
||||
skins_.clear();
|
||||
|
||||
// ResourceLoader enumera tant entries del pack com fitxers de
|
||||
// `data/` en mode fallback. Les claus retornades són relatives a
|
||||
// `data/` (ex: "skins/classic/skin.yaml"). Buscar manifests
|
||||
// amb aquest patró és més robust que `std::filesystem` perquè
|
||||
// funciona igual a release (pack) que a dev (filesystem).
|
||||
const auto ALL = ResourceLoader::getInstance().getAvailableResources();
|
||||
|
||||
const std::string PREFIX = "skins/";
|
||||
const std::string SUFFIX = "/skin.yaml";
|
||||
|
||||
for (const auto &key : ALL) {
|
||||
if (!key.starts_with(PREFIX) || !key.ends_with(SUFFIX)) { continue; }
|
||||
const std::string ID = key.substr(PREFIX.size(), key.size() - PREFIX.size() - SUFFIX.size());
|
||||
if (ID.find('/') != std::string::npos) { continue; } // només top-level dins skins/
|
||||
|
||||
// ResourceHelper espera un path que contingui "data/" — el construïm
|
||||
// amb la convenció habitual del projecte.
|
||||
const std::string FULL_PATH = executable_path_ + asset_prefix_ + "/data/" + key;
|
||||
auto bytes = ResourceHelper::loadFile(FULL_PATH);
|
||||
if (bytes.empty()) {
|
||||
std::cerr << "SkinManager: cannot read manifest " << FULL_PATH << '\n';
|
||||
continue;
|
||||
}
|
||||
|
||||
SkinInfo info;
|
||||
info.id = ID;
|
||||
info.display_name = ID;
|
||||
info.gfx_dir = "gfx";
|
||||
|
||||
try {
|
||||
const std::string CONTENT(reinterpret_cast<const char *>(bytes.data()), bytes.size());
|
||||
auto yaml = fkyaml::node::deserialize(CONTENT);
|
||||
if (yaml.contains("display_name")) {
|
||||
info.display_name = yaml["display_name"].get_value<std::string>();
|
||||
}
|
||||
if (yaml.contains("gfx_dir")) {
|
||||
info.gfx_dir = yaml["gfx_dir"].get_value<std::string>();
|
||||
}
|
||||
} catch (const fkyaml::exception &e) {
|
||||
std::cerr << "SkinManager: bad manifest " << FULL_PATH << ": " << e.what() << '\n';
|
||||
continue;
|
||||
}
|
||||
|
||||
skins_.push_back(std::move(info));
|
||||
}
|
||||
|
||||
// Ordre alfabètic estable: garanteix que next/prev són deterministes.
|
||||
std::ranges::sort(skins_, [](const SkinInfo &a, const SkinInfo &b) { return a.id < b.id; });
|
||||
}
|
||||
|
||||
auto SkinManager::exists(const std::string &id) const -> bool {
|
||||
return std::ranges::any_of(skins_, [&](const SkinInfo &s) { return s.id == id; });
|
||||
}
|
||||
|
||||
auto SkinManager::currentDisplayName() const -> std::string {
|
||||
return displayNameOf(current_id_);
|
||||
}
|
||||
|
||||
auto SkinManager::displayNameOf(const std::string &id) const -> std::string {
|
||||
const auto IT = std::ranges::find_if(skins_, [&](const SkinInfo &s) { return s.id == id; });
|
||||
return (IT != skins_.end()) ? IT->display_name : id;
|
||||
}
|
||||
|
||||
void SkinManager::setCurrent(const std::string &id) {
|
||||
if (exists(id)) {
|
||||
current_id_ = id;
|
||||
}
|
||||
}
|
||||
|
||||
auto SkinManager::gfxDirOf(const std::string &id) const -> std::string {
|
||||
const auto IT = std::ranges::find_if(skins_, [&](const SkinInfo &s) { return s.id == id; });
|
||||
return (IT != skins_.end()) ? IT->gfx_dir : std::string("gfx");
|
||||
}
|
||||
|
||||
auto SkinManager::gfxPath(const std::string &basename) const -> std::string {
|
||||
return asset_prefix_ + "/data/skins/" + current_id_ + "/" + gfxDirOf(current_id_) + "/" + basename;
|
||||
}
|
||||
|
||||
auto SkinManager::nextSkinId() const -> std::string {
|
||||
if (skins_.empty()) { return current_id_; }
|
||||
for (size_t i = 0; i < skins_.size(); ++i) {
|
||||
if (skins_[i].id == current_id_) {
|
||||
return skins_[(i + 1) % skins_.size()].id;
|
||||
}
|
||||
}
|
||||
return skins_.front().id;
|
||||
}
|
||||
|
||||
auto SkinManager::prevSkinId() const -> std::string {
|
||||
if (skins_.empty()) { return current_id_; }
|
||||
for (size_t i = 0; i < skins_.size(); ++i) {
|
||||
if (skins_[i].id == current_id_) {
|
||||
return skins_[(i + skins_.size() - 1) % skins_.size()].id;
|
||||
}
|
||||
}
|
||||
return skins_.front().id;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Gestor de skins. Una "skin" és un set complet de gràfics (PNGs + .ani)
|
||||
// emmagatzemat sota `data/skins/<id>/gfx/`. El SkinManager:
|
||||
//
|
||||
// * descobreix les skins disponibles escanejant `data/skins/*/skin.yaml`,
|
||||
// * recorda quina skin està activa (`current_id_`),
|
||||
// * composa els paths perquè Asset/Resource sàpiguen on llegir.
|
||||
//
|
||||
// L'arrencada típica és: Director crida `init(executable_path, asset_prefix)`
|
||||
// (escaneja manifests) i acte seguit `setCurrent(Options::settings.skin)`.
|
||||
// Després registra els assets via `Asset::addSkinAware("balloon1.png", ...)`
|
||||
// que utilitza internament `gfxPath()` del SkinManager.
|
||||
//
|
||||
// Per al canvi en calent, Resource crida `setCurrent(new_id)`, després
|
||||
// `Asset::onSkinChanged()` per a actualitzar paths registrats, i recarrega
|
||||
// cada Texture via `reLoadFromPath`.
|
||||
|
||||
class SkinManager {
|
||||
public:
|
||||
struct SkinInfo {
|
||||
std::string id; // Carpeta dins data/skins/ (ex: "classic")
|
||||
std::string display_name; // Etiqueta visible a la UI (ex: "Classic")
|
||||
std::string gfx_dir; // Subcarpeta amb els gfx (default: "gfx")
|
||||
};
|
||||
|
||||
// executable_path: acabat amb '/' (típicament SDL_GetBasePath()).
|
||||
// asset_prefix: prefix relatiu per a paths registrats a Asset
|
||||
// (ex: "" en Linux/Win, "/../Resources" dins el bundle de macOS).
|
||||
static void init(const std::string &executable_path, const std::string &asset_prefix);
|
||||
static void destroy();
|
||||
static auto get() -> SkinManager *;
|
||||
|
||||
void scan();
|
||||
[[nodiscard]] auto available() const -> const std::vector<SkinInfo> & { return skins_; }
|
||||
[[nodiscard]] auto current() const -> const std::string & { return current_id_; }
|
||||
[[nodiscard]] auto currentDisplayName() const -> std::string;
|
||||
[[nodiscard]] auto displayNameOf(const std::string &id) const -> std::string;
|
||||
[[nodiscard]] auto exists(const std::string &id) const -> bool;
|
||||
|
||||
void setCurrent(const std::string &id);
|
||||
|
||||
// Compon el path relatiu d'un gràfic dins la skin activa, amb el format
|
||||
// que Asset::add espera (relatiu amb prefix de plataforma):
|
||||
// "<asset_prefix>/data/skins/<id>/<gfx_dir>/<basename>"
|
||||
[[nodiscard]] auto gfxPath(const std::string &basename) const -> std::string;
|
||||
|
||||
// Cíclic. Si només hi ha una skin, retorna la mateixa.
|
||||
[[nodiscard]] auto nextSkinId() const -> std::string;
|
||||
[[nodiscard]] auto prevSkinId() const -> std::string;
|
||||
|
||||
private:
|
||||
SkinManager(std::string executable_path, std::string asset_prefix);
|
||||
|
||||
[[nodiscard]] auto gfxDirOf(const std::string &id) const -> std::string;
|
||||
|
||||
std::string executable_path_; // Acabat amb '/' (per a scan filesystem)
|
||||
std::string asset_prefix_; // PREFIX per a paths registrats
|
||||
std::vector<SkinInfo> skins_;
|
||||
std::string current_id_{"classic"};
|
||||
|
||||
static SkinManager *instance;
|
||||
};
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "core/resources/asset.h" // for Asset, Asset::Type
|
||||
#include "core/resources/resource.h"
|
||||
#include "core/resources/resource_helper.h"
|
||||
#include "core/resources/skin_manager.hpp"
|
||||
#include "game/defaults.hpp" // for SECTION_PROG_LOGO, GAMECANVAS_H...
|
||||
#include "game/game.h" // for Game
|
||||
#include "game/options.hpp" // for Options::init, loadFromFile...
|
||||
@@ -107,22 +106,6 @@ Director::Director(int argc, const char *argv[]) {
|
||||
Asset::init(executable_path_);
|
||||
Asset::get()->setVerbose(Options::settings.console);
|
||||
|
||||
// Inicialitza el gestor de skins ANTES de registrar assets: setFileList
|
||||
// composa els paths gfx via SkinManager::gfxPath(). Si la skin del config
|
||||
// no existeix, caiem a "classic".
|
||||
#ifdef MACOS_BUNDLE
|
||||
SkinManager::init(executable_path_, "/../Resources");
|
||||
#else
|
||||
SkinManager::init(executable_path_, "");
|
||||
#endif
|
||||
if (!SkinManager::get()->exists(Options::settings.skin)) {
|
||||
if (Options::settings.console) {
|
||||
std::cout << "Skin '" << Options::settings.skin << "' not found, falling back to 'classic'.\n";
|
||||
}
|
||||
Options::settings.skin = "classic";
|
||||
}
|
||||
SkinManager::get()->setCurrent(Options::settings.skin);
|
||||
|
||||
// Si falta algún fichero no inicia el programa
|
||||
if (!setFileList()) {
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -201,7 +184,6 @@ Director::~Director() {
|
||||
Resource::destroy();
|
||||
|
||||
Asset::destroy();
|
||||
SkinManager::destroy();
|
||||
Input::destroy();
|
||||
Lang::destroy();
|
||||
delete section_;
|
||||
@@ -249,7 +231,6 @@ void Director::initInput() {
|
||||
Input::get()->bindKey(Input::Action::TOGGLE_SHADER, SDL_SCANCODE_F4);
|
||||
Input::get()->bindKey(Input::Action::TOGGLE_SHADER_TYPE, SDL_SCANCODE_F5);
|
||||
Input::get()->bindKey(Input::Action::NEXT_SHADER_PRESET, SDL_SCANCODE_F6);
|
||||
Input::get()->bindKey(Input::Action::NEXT_SKIN, SDL_SCANCODE_F7);
|
||||
|
||||
// Mando - Movimiento del jugador
|
||||
Input::get()->bindGameControllerButton(Input::Action::UP, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
||||
@@ -382,66 +363,66 @@ auto Director::setFileList() -> bool {
|
||||
Asset::get()->add(PREFIX + "/data/sound/clock.wav", Asset::Type::SOUND);
|
||||
Asset::get()->add(PREFIX + "/data/sound/powerball.wav", Asset::Type::SOUND);
|
||||
|
||||
// Texturas (skin-aware: viuen sota data/skins/<skin>/gfx/)
|
||||
Asset::get()->addSkinAware("balloon1.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("balloon1.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("balloon2.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("balloon2.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("balloon3.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("balloon3.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("balloon4.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("balloon4.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("bullet.png", Asset::Type::BITMAP);
|
||||
// Texturas
|
||||
Asset::get()->add(PREFIX + "/data/gfx/balloon1.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/balloon1.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/balloon2.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/balloon2.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/balloon3.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/balloon3.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/balloon4.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/balloon4.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/bullet.png", Asset::Type::BITMAP);
|
||||
|
||||
Asset::get()->addSkinAware("game_buildings.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("game_clouds.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("game_grass.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("game_power_meter.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("game_sky_colors.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("game_text.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/game_buildings.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/game_clouds.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/game_grass.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/game_power_meter.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/game_sky_colors.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/game_text.png", Asset::Type::BITMAP);
|
||||
|
||||
Asset::get()->addSkinAware("intro.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("logo.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("menu_game_over.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("menu_game_over_end.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/intro.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/logo.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/menu_game_over.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/menu_game_over_end.png", Asset::Type::BITMAP);
|
||||
|
||||
Asset::get()->addSkinAware("item_points1_disk.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("item_points1_disk.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("item_points2_gavina.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("item_points2_gavina.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("item_points3_pacmar.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("item_points3_pacmar.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("item_clock.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("item_clock.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("item_coffee.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("item_coffee.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("item_coffee_machine.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("item_coffee_machine.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_points1_disk.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_points1_disk.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_points2_gavina.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_points2_gavina.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_points3_pacmar.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_points3_pacmar.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_clock.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_clock.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_coffee.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_coffee.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_coffee_machine.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/item_coffee_machine.ani", Asset::Type::DATA);
|
||||
|
||||
Asset::get()->addSkinAware("title_bg_tile.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("title_coffee.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("title_crisis.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("title_dust.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("title_dust.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("title_gradient.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/title_bg_tile.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/title_coffee.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/title_crisis.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/title_dust.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/title_dust.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/title_gradient.png", Asset::Type::BITMAP);
|
||||
|
||||
Asset::get()->addSkinAware("player_head.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("player_body.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("player_legs.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("player_death.ani", Asset::Type::DATA);
|
||||
Asset::get()->addSkinAware("player_fire.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_head.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_body.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_legs.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_death.ani", Asset::Type::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_fire.ani", Asset::Type::DATA);
|
||||
|
||||
Asset::get()->addSkinAware("player_bal1_head.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("player_bal1_body.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("player_bal1_legs.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("player_bal1_death.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("player_bal1_fire.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_head.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_body.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_legs.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_death.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_bal1_fire.png", Asset::Type::BITMAP);
|
||||
|
||||
Asset::get()->addSkinAware("player_arounder_head.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("player_arounder_body.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("player_arounder_legs.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("player_arounder_death.png", Asset::Type::BITMAP);
|
||||
Asset::get()->addSkinAware("player_arounder_fire.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_head.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_body.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_legs.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_death.png", Asset::Type::BITMAP);
|
||||
Asset::get()->add(PREFIX + "/data/gfx/player_arounder_fire.png", Asset::Type::BITMAP);
|
||||
|
||||
// Fuentes
|
||||
Asset::get()->add(PREFIX + "/data/font/8bithud.png", Asset::Type::FONT);
|
||||
|
||||
Reference in New Issue
Block a user