Skip to content
Snippets Groups Projects
Commit 113d8137 authored by DarkGod's avatar DarkGod
Browse files

better way to change the current UI setting

parent 4d8919b8
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,8 @@ local skip_key = {init=true, _NAME=true, _M=true, _PACKAGE=true, new=true, _BASE
-- @return function(c)
function inherit(...)
local bases = {...}
local basenames = {}
for _, b in ipairs(bases) do if b._NAME then basenames[b._NAME] = true end end
return function(c)
c._BASES = bases
-- Recursive inheritance caching
......@@ -172,13 +174,25 @@ function _M:importInterface(base)
end
function _M:getClassName()
return self.__CLASSNAME
return self.__CLASSNAME or self._NAME
end
function _M:getClass()
return getmetatable(self).__index
end
function _M:isClassName(name)
if self.__CLASSNAME == name then return true end
if self._NAME == name then return true end
if self._BASES then
for _, b in ipairs(self._BASES) do
if b._NAME == name then return true end
if b:isClassName(name) then return true end
end
end
return false
end
function _M:runInherited()
for _, f in ipairs(run_inherited) do
f()
......
......@@ -60,6 +60,16 @@ function _M:uiExists(ui)
return self.ui_conf[ui]
end
function _M:changeDefault(ui)
if not self:uiExists(ui) then return end
self.ui = ui
for name, c in pairs(package.loaded) do
if type(c) == "table" and c.isClassName and c:isClassName(self._NAME) then
c.ui = ui
end
end
end
function _M:inherited(base)
if base._NAME == "engine.ui.Base" then
self.font = base.font
......
......@@ -45,9 +45,6 @@ UIBase.font_mono_h = UIBase.font_mono:lineSkip()+2
local n = core.noise.new(2)
_2DNoise = n:makeTexture2D(64, 64)
if config.settings.tome and config.settings.tome.ui_theme3 and UIBase:uiExists(config.settings.tome.ui_theme3) then
UIBase.ui = config.settings.tome.ui_theme3
end
UIBase:setTextShadow(0.6)
-- Usefull keybinds
......@@ -81,5 +78,8 @@ Birther:loadDefinition("/data/birth/descriptors.lua")
core.game.setRealtime(8)
class:triggerHook{"Boot:load"}
if config.settings.tome and config.settings.tome.ui_theme3 then
UIBase:changeDefault(config.settings.tome.ui_theme3)
end
return {require "mod.class.Game" }
......@@ -44,7 +44,7 @@ Map.faction_danger_check = function(self, e, max) return (not max and e.rank > 3
Level.remove_old_entity_on_duplicate = true
-- Dialog UI
UIBase.ui = config.settings.tome.ui_theme3
UIBase:changeDefault(config.settings.tome.ui_theme3)
UIBase:setTextShadow(0.6)
-- Dialogs fonts
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment