HollowBond/Public/ecma/Managers/ThemesManager.ecma.js

54 lines
1.4 KiB
JavaScript

"use strict";
const ThemeManager = (function(){
const ThemeManager = function(hollow_bond){
const self = this;
const themes = {};
// Tema activo por defecto
this.current_theme = "level_0";
const constructor = () => {
// --- Registro del Tema Base: Level 0 (Backrooms Clásico) ---
self.register(Level0Theme.key, Level0Theme);
};
/**
* Registra un nuevo tema gráfico.
* @param {string} key - Identificador único ("level_0", "poolrooms", etc.)
* @param {Object} definition - Colección de shaders por superficie
*/
this.register = (key, definition) => {
themes[key] = definition;
};
/**
* Obtiene la definición completa de un tema o el activo por defecto.
* @param {string} [key=null]
* @returns {Object}
*/
this.get = (key = null) => {
const target_key = key || self.current_theme;
return themes[target_key] || themes[self.current_theme] || null;
};
/**
* Cambia el tema global activo.
* @param {string} key
*/
this.set_theme = key => {
if(themes[key]){
self.current_theme = key;
}
};
constructor();
};
return ThemeManager;
})();