73 lines
2.4 KiB
JavaScript
73 lines
2.4 KiB
JavaScript
"use strict";
|
|
|
|
const MenuView = (function(){
|
|
|
|
const MenuView = function(hollow_bond){
|
|
|
|
const self = this;
|
|
let root_element = null;
|
|
|
|
this.destroy = () => {
|
|
if(root_element && root_element.parentNode){
|
|
root_element.remove();
|
|
root_element = null;
|
|
};
|
|
};
|
|
|
|
const on_click_new_game = () => {
|
|
self.destroy();
|
|
hollow_bond.views.new_game.go();
|
|
};
|
|
|
|
const on_click_options = () => {
|
|
self.destroy();
|
|
hollow_bond.views.options && hollow_bond.views.options.go();
|
|
};
|
|
|
|
const on_click_credits = () => {
|
|
self.destroy();
|
|
hollow_bond.views.credits.go();
|
|
};
|
|
|
|
this.go = () => {
|
|
self.destroy();
|
|
|
|
root_element = hollow_bond.html(hollow_bond.item_self, ["div", {
|
|
"class" : hollow_bond.settings.get("menu_view_class_name", null, "menu-view")
|
|
}, [
|
|
["div", {"class" : "menu-header"}, [
|
|
["div", {
|
|
"class" : "menu-title",
|
|
"data-i18n" : "menu_title"
|
|
}, hollow_bond.i18n.get("menu_title", null, "HOLLOWBOND")],
|
|
["div", {
|
|
"class" : "menu-subtitle",
|
|
"data-i18n" : "menu_subtitle"
|
|
}, hollow_bond.i18n.get("menu_subtitle", null, "PROCEDURAL DUNGEON ENGINE")]
|
|
]],
|
|
["div", {"class" : "menu-actions"}, [
|
|
["button", {
|
|
"class" : "menu-button",
|
|
"data-i18n" : "menu_new_game",
|
|
"onclick" : on_click_new_game
|
|
}, hollow_bond.i18n.get("menu_new_game", null, "Nueva Partida")],
|
|
["button", {
|
|
"class" : "menu-button",
|
|
"data-i18n" : "menu_options",
|
|
"onclick" : on_click_options
|
|
}, hollow_bond.i18n.get("menu_options", null, "Opciones")],
|
|
["button", {
|
|
"class" : "menu-button",
|
|
"data-i18n" : "menu_credits",
|
|
"onclick" : on_click_credits
|
|
}, hollow_bond.i18n.get("menu_credits", null, "Créditos")]
|
|
]]
|
|
]])[0];
|
|
|
|
return self;
|
|
};
|
|
|
|
};
|
|
|
|
return MenuView;
|
|
})(); |