Skip to content
Snippets Groups Projects
Commit fdd1c9f6 authored by dg's avatar dg
Browse files

Classes may have an inherited method that gets called after module init

git-svn-id: http://svn.net-core.org/repos/t-engine4@4896 51575b47-30f0-44d4-a5cc-537603b46e54
parent f8f973d7
No related branches found
No related tags found
No related merge requests found
......@@ -540,6 +540,7 @@ function _M:instanciate(mod, name, new_game, no_reboot)
-- Init the module code
local M, W = mod.load("init")
class:runInherited()
_G.game = M.new()
_G.game:setPlayerName(name)
......
......@@ -20,6 +20,7 @@
module("class", package.seeall)
local base = _G
local run_inherited = {}
local function search(k, plist)
for i=1, #plist do
......@@ -100,6 +101,15 @@ function inherit(...)
o.__CLASSNAME = c._NAME
setmetatable(o, {__index=c})
end
if c.inherited then
run_inherited[#run_inherited+1] = function()
local i = 1
while i <= #bases do
c:inherited(bases[i], i)
i = i + 1
end
end
end
return c
end
end
......@@ -112,6 +122,12 @@ function _M:getClass()
return getmetatable(self).__index
end
function _M:runInherited()
for _, f in ipairs(run_inherited) do
f()
end
end
local function clonerecurs(d)
local n = {}
for k, e in pairs(d) do
......
......@@ -87,6 +87,18 @@ _M.ui_conf = {
},
}
function _M:inherited(base)
if base._NAME == "engine.ui.Base" then
self.font = base.font
self.font_h = base.font_h
self.font_mono = base.font_mono
self.font_mono_w = base.font_mono_w
self.font_mono_h = base.font_mono_h
self.font_bold = base.font_bold
self.font_bold_h = base.font_bold_h
end
end
function _M:init(t, no_gen)
self.mouse = Mouse.new()
self.key = KeyBind.new()
......
......@@ -33,7 +33,7 @@ function _M:init(l, w, force_height)
self.ui = l.special_ui or "parchment"
Dialog.init(self, "Lore found: #0080FF#"..l.name, 1, 1)
--FX FUCKING FONT SIZE!
local text = util.getval(l.lore).."\n"
local list = text:splitLines(w - 10, self.font)
......
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