Skip to content
Snippets Groups Projects
Commit 4ca5cc0c authored by DarkGod's avatar DarkGod
Browse files

Updated the Arena deth dialog to use the same code as the normal one

parent db49ecd4
No related branches found
No related tags found
No related merge requests found
...@@ -18,38 +18,20 @@ ...@@ -18,38 +18,20 @@
-- darkgod@te4.org -- darkgod@te4.org
require "engine.class" require "engine.class"
local Dialog = require "engine.ui.Dialog" local DeathDialog = require "mod.dialogs.DeathDialog"
local Textzone = require "engine.ui.Textzone" local Textzone = require "engine.ui.Textzone"
local Separator = require "engine.ui.Separator" local Shader = require "engine.Shader"
local List = require "engine.ui.List"
local Savefile = require "engine.Savefile"
local Map = require "engine.Map"
module(..., package.seeall, class.inherit(Dialog)) module(..., package.seeall, class.inherit(DeathDialog))
function _M:init(actor) function _M:init(actor)
self.actor = actor DeathDialog.init(self, actor)
Dialog.init(self, _t"Arena mode", 500, 300)
actor:saveUUID()
self:generateList()
self.c_desc = Textzone.new{width=self.iw, auto_height=true, text=self:printRanking() }
self.c_list = List.new{width=self.iw, nb_items=#self.list, list=self.list, fct=function(item) self:use(item) end}
self:loadUI{
{left=0, top=0, ui=self.c_desc},
{left=5, top=self.c_desc.h, padding_h=10, ui=Separator.new{dir="vertical", size=self.iw - 10}},
{left=0, bottom=0, ui=self.c_list},
}
self:setFocus(self.c_list)
self:setupUI(false, true)
end end
function _M:printRanking() function _M:printRanking()
local scores = world.arena.scores local scores = world.arena.scores
if not scores[1].name then return _t"#LIGHT_GREEN#No high scores. This should not happen." if not scores[1].name then
return _t"#LIGHT_GREEN#No high scores. This should not happen."
else else
local text = "" local text = ""
local tmp = "" local tmp = ""
...@@ -65,102 +47,12 @@ function _M:printRanking() ...@@ -65,102 +47,12 @@ function _M:printRanking()
end end
i = i + 1 i = i + 1
end end
return text return text
end
end
--- Clean the actor from debuffs/buffs
function _M:cleanActor(actor)
local effs = {}
-- Go through all spell effects
for eff_id, p in pairs(actor.tmp) do
local e = actor.tempeffect_def[eff_id]
effs[#effs+1] = {"effect", eff_id}
end
-- Go through all sustained spells
for tid, act in pairs(actor.sustain_talents) do
if act then
effs[#effs+1] = {"talent", tid}
end
end
while #effs > 0 do
local eff = rng.tableRemove(effs)
if eff[1] == "effect" then
actor:removeEffect(eff[2])
else
actor:forceUseTalent(eff[2], {ignore_energy=true})
end
end end
end end
--- Restore resources function _M:setupDescription()
function _M:restoreResources(actor) self.c_desc = Textzone.new{width=self.iw, auto_height=true, text=self:printRanking()}
if actor.resetToFull then self.c_desc:setTextShadow(1)
actor:resetToFull() self.c_desc:setShadowShader(Shader.default.textoutline and Shader.default.textoutline.shad, 1.2)
actor.energy.value = game.energy_to_act
end
end
--- Basic resurrection
function _M:resurrectBasic(actor)
actor.dead = false
actor.died = (actor.died or 0) + 1
local x, y = util.findFreeGrid(actor.x, actor.y, 20, true, {[Map.ACTOR]=true})
if not x then x, y = actor.x, actor.y end
actor.x, actor.y = nil, nil
actor:move(x, y, true)
game.level:addEntity(actor)
game:unregisterDialog(self)
game.level.map:redisplay()
actor.energy.value = game.energy_to_act
actor.changed = true
game.paused = true
end
function _M:use(item)
if not item then return end
local act = item.action
if act == "exit" then
game:getPlayer(true).dead = true
game:saveGame()
world:saveWorld()
if item.subaction == "none" then
util.showMainMenu()
elseif item.subaction == "restart" then
util.showMainMenu(false, engine.version[4], engine.version[1].."."..engine.version[2].."."..engine.version[3], game.__mod_info.short_name, game.save_name, true, ("auto_quickbirth=%q"):format(game:getPlayer(true).name))
elseif item.subaction == "restart-new" then
util.showMainMenu(false, engine.version[4], engine.version[1].."."..engine.version[2].."."..engine.version[3], game.__mod_info.short_name, game.save_name, true)
end
elseif act == "cheat" then
game.logPlayer(self.actor, "#LIGHT_BLUE#You resurrect! CHEATER !")
self:cleanActor(self.actor)
self:restoreResources(self.actor)
self:resurrectBasic(self.actor)
elseif act == "dump" then
game:registerDialog(require("mod.dialogs.CharacterSheet").new(self.actor))
elseif act == "log" then
game:registerDialog(require("mod.dialogs.ShowChatLog").new(_t"Message Log", 0.6, game.uiset.logdisplay, profile.chat))
end
end
function _M:generateList()
local list = {}
if config.settings.cheat then list[#list+1] = {name=_t"Resurrect by cheating", action="cheat"} end
list[#list+1] = {name=(not profile.auth and _t"Message Log" or _t"Message/Chat log (allows to talk)"), action="log"}
list[#list+1] = {name=_t"Character dump", action="dump"}
list[#list+1] = {name=_t"Restart the same character", action="exit", subaction="restart"}
list[#list+1] = {name=_t"Restart with a new character", action="exit", subaction="restart-new"}
list[#list+1] = {name=_t"Exit to main menu", action="exit", subaction="none"}
self.list = list
end end
...@@ -39,18 +39,9 @@ function _M:init(actor) ...@@ -39,18 +39,9 @@ function _M:init(actor)
if self.dont_show then return end if self.dont_show then return end
if not config.settings.cheat then game:onTickEnd(function() game:saveGame() end) end if not config.settings.cheat then game:onTickEnd(function() game:saveGame() end) end
local text = _t[[Death in #{bold}#Tales of Maj'Eyal#{normal}# is usually permanent, but if you have a means of resurrection it will be proposed in the menu below. self:setupDescription()
You can dump your character data to a file to remember her/him forever, or you can exit and try once again to survive in the wilds!
]]
if #game.party.on_death_show_achieved > 0 then
self.c_achv = Textzone.new{width=self.iw, scrollbar=true, height=100, text=("#LIGHT_GREEN#During your game you#WHITE#:\n* %s"):tformat(table.concat(game.party.on_death_show_achieved, "\n* "))}
end
self:setTitleShadowShader(Shader.default.textoutline and Shader.default.textoutline.shad, 1.5) self:setTitleShadowShader(Shader.default.textoutline and Shader.default.textoutline.shad, 1.5)
self.c_desc = Textzone.new{width=self.iw, auto_height=true, text=text}
self.c_desc:setTextShadow(1)
self.c_desc:setShadowShader(Shader.default.textoutline and Shader.default.textoutline.shad, 1.2)
self.c_list = List.new{width=self.iw, nb_items=#self.list, list=self.list, fct=function(item) self:use(item) end, select=function(item) self.cur_item = item end} self.c_list = List.new{width=self.iw, nb_items=#self.list, list=self.list, fct=function(item) self:use(item) end, select=function(item) self.cur_item = item end}
...@@ -88,6 +79,18 @@ You can dump your character data to a file to remember her/him forever, or you c ...@@ -88,6 +79,18 @@ You can dump your character data to a file to remember her/him forever, or you c
self:setupUI(false, true) self:setupUI(false, true)
end end
function _M:setupDescription()
self.c_desc = Textzone.new{width=self.iw, auto_height=true, text=_t[[Death in #{bold}#Tales of Maj'Eyal#{normal}# is usually permanent, but if you have a means of resurrection it will be proposed in the menu below.
You can dump your character data to a file to remember her/him forever, or you can exit and try once again to survive in the wilds!
]]}
self.c_desc:setTextShadow(1)
self.c_desc:setShadowShader(Shader.default.textoutline and Shader.default.textoutline.shad, 1.2)
if #game.party.on_death_show_achieved > 0 then
self.c_achv = Textzone.new{width=self.iw, scrollbar=true, height=100, text=("#LIGHT_GREEN#During your game you#WHITE#:\n* %s"):tformat(table.concat(game.party.on_death_show_achieved, "\n* "))}
end
end
--- Clean the actor from debuffs/buffs --- Clean the actor from debuffs/buffs
function _M:cleanActor(actor) function _M:cleanActor(actor)
local effs = {} local effs = {}
......
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