diff --git a/game/engines/default/engine/Module.lua b/game/engines/default/engine/Module.lua index 00ef183d0897ae5a540a2f0ec69251f4f16aba3f..caceac34bf717c7c36d28c8326b4ae8a58882350 100644 --- a/game/engines/default/engine/Module.lua +++ b/game/engines/default/engine/Module.lua @@ -286,6 +286,73 @@ function _M:listVaultSavesForCurrent() return lss end +--- List all available background alterations +function _M:listBackgrounds(mod) + local defs = {} + local load = function(dir, teaa) + local add_def = loadfile(dir.."/boot-screen/init.lua") + if add_def then + local add = {} + setfenv(add_def, add) + add_def() + table.print(add) + + add.for_modules = table.reverse(add.for_modules) + if add.for_modules[mod.short_name] then + if add.add_backgrounds then + for i, d in ipairs(add.add_backgrounds) do + local nd = {chance=d.chance, name=dir.."/boot-screen/"..d.name} + if d.logo then nd.logo = dir.."/boot-screen/"..d.logo end + if teaa then + nd.mount = function() fs.mount(fs.getRealPath(teaa), "/testload", false) end + nd.umount = function() fs.umount(fs.getRealPath(teaa)) end + end + defs[#defs+1] = nd + end + end + end + end + end + + local parse = function(basedir) + for i, short_name in ipairs(fs.list(basedir)) do if short_name:find("^.+%-.+") or short_name:find(".teaac$") then + local dir = basedir..short_name + -- print("Checking background", short_name, ":: (as dir)", fs.exists(dir.."/init.lua"), ":: (as teaa)", short_name:find(".teaa$"), "") + if fs.exists(dir.."/boot-screen/init.lua") then + load(dir, nil) + elseif short_name:find(".teaa$") or short_name:find(".teaac$") then + fs.mount(fs.getRealPath(dir), "/testload", false) + local mod + if fs.exists("/testload/boot-screen/init.lua") then + load("/testload", dir) + end + fs.umount(fs.getRealPath(dir)) + end + end end + end + parse("/addons/") + parse("/dlcs/") + + -- Add the default one + local backname = util.getval(mod.background_name) or "tome" + defs[#defs+1] = {name="/data/gfx/background/"..backname..".png", logo="/data/gfx/background/"..backname.."-logo.png", chance=100} + + -- os.exit() + + local def = nil + while not def or not rng.percent(def.chance or 100) do + def = rng.table(defs) + end + + if def.mount then def.mount() end + local bkgs = core.display.loadImage(def.name) or core.display.loadImage("/data/gfx/background/tome.png") + local logo = nil + if def.logo then logo = {(core.display.loadImage(def.logo) or core.display.loadImage("/data/gfx/background/tome-logo.png")):glTexture()} end + if def.umount then def.umount() end + + return bkgs, logo +end + --- List all available addons function _M:listAddons(mod, ignore_compat) local adds = {} @@ -553,14 +620,12 @@ function _M:loadScreen(mod) local has_max = mod.loading_wait_ticks if has_max then core.wait.addMaxTicks(has_max) end local i, max, dir = has_max or 20, has_max or 20, -1 - local backname = util.getval(mod.background_name) or "tome" + local bkgs, logo = self:listBackgrounds(mod) - local bkgs = core.display.loadImage("/data/gfx/background/"..backname..".png") or core.display.loadImage("/data/gfx/background/tome.png") local sw, sh = core.display.size() local bw, bh = bkgs:getSize() local bkg = {bkgs:glTexture()} - local logo = {(core.display.loadImage("/data/gfx/background/"..backname.."-logo.png") or core.display.loadImage("/data/gfx/background/tome-logo.png")):glTexture()} local pubimg, publisher = nil, nil if mod.publisher_logo then pubimg, publisher = core.display.loadImage("/data/gfx/background/"..mod.publisher_logo..".png"), nil @@ -662,7 +727,7 @@ function _M:loadScreen(mod) bkg[1]:toScreenFull(x, y, bw, bh, bw * bkg[4], bh * bkg[5]) -- Logo - logo[1]:toScreenFull(0, 0, logo[6], logo[7], logo[2], logo[3]) + if logo then logo[1]:toScreenFull(0, 0, logo[6], logo[7], logo[2], logo[3]) end -- Publisher Logo if publisher then publisher[1]:toScreenFull(sw - publisher[6], 0, publisher[6], publisher[7], publisher[2], publisher[3]) end diff --git a/game/engines/default/engine/version.lua b/game/engines/default/engine/version.lua index e7272a850ca8fcbc8d02355b6fb812dfc7e26a88..9a9fc4a80697aa06c2610a18afa2b75e28469ad1 100644 --- a/game/engines/default/engine/version.lua +++ b/game/engines/default/engine/version.lua @@ -18,7 +18,7 @@ -- darkgod@te4.org -- Engine Version -engine.version = {1,2,3,"te4",17} +engine.version = {1,2,4,"te4",17} engine.require_c_core = engine.version[5] engine.version_id = ("%s-%d_%d.%d.%d"):format(engine.version[4], engine.require_c_core, engine.version[1], engine.version[2], engine.version[3]) diff --git a/game/engines/default/modules/boot/class/Game.lua b/game/engines/default/modules/boot/class/Game.lua index e30648cc8daf9c327c6e1b977685fbde9a01282d..554dd541fef532f5ccecabe6bf1f9b36086ed802 100644 --- a/game/engines/default/modules/boot/class/Game.lua +++ b/game/engines/default/modules/boot/class/Game.lua @@ -57,7 +57,11 @@ function _M:init() if not config.settings.censor_boot then background_name = {"tome","tome2","tome3"} else background_name = {"tome3"} end - + + local value = {name=background_name} + local hd = {"Boot:loadBackground", value=value} + if self:triggerHook(hd) then background_name = hd.value.name end + self.background = core.display.loadImage("/data/gfx/background/"..util.getval(background_name)..".png") if self.background then self.background_w, self.background_h = self.background:getSize() diff --git a/game/modules/tome/init.lua b/game/modules/tome/init.lua index 8da6af5355cb7a11711b8cb06ea297825200fddb..d659a818f695c496e41a0ed0b10734b3ed2c58f7 100644 --- a/game/modules/tome/init.lua +++ b/game/modules/tome/init.lua @@ -22,8 +22,8 @@ long_name = "Tales of Maj'Eyal: Age of Ascendancy" short_name = "tome" author = { "DarkGod", "darkgod@te4.org" } homepage = "http://te4.org/" -version = {1,2,3} -engine = {1,2,3,"te4"} +version = {1,2,4} +engine = {1,2,4,"te4"} description = [[ Welcome to Maj'Eyal.