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

New death option: restart a new character

bump to b29


git-svn-id: http://svn.net-core.org/repos/t-engine4@3600 51575b47-30f0-44d4-a5cc-537603b46e54
parent e31da538
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
-- darkgod@te4.org -- darkgod@te4.org
-- Engine Version -- Engine Version
engine.version = {0,9,28,"te4",14} engine.version = {0,9,29,"te4",14}
engine.require_c_core = engine.version[5] 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]) 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])
......
...@@ -23,7 +23,7 @@ short_name = "example" ...@@ -23,7 +23,7 @@ short_name = "example"
author = { "DarkGod", "darkgod@te4.org" } author = { "DarkGod", "darkgod@te4.org" }
homepage = "http://te4.org/modules:example" homepage = "http://te4.org/modules:example"
version = {1,0,0} version = {1,0,0}
engine = {0,9,28,"te4"} engine = {0,9,29,"te4"}
description = [[ description = [[
This is *NOT* a game, just an example/template to make your own using the T-Engine4. This is *NOT* a game, just an example/template to make your own using the T-Engine4.
]] ]]
......
...@@ -23,7 +23,7 @@ short_name = "example_realtime" ...@@ -23,7 +23,7 @@ short_name = "example_realtime"
author = { "DarkGod", "darkgod@te4.org" } author = { "DarkGod", "darkgod@te4.org" }
homepage = "http://te4.org/modules:example" homepage = "http://te4.org/modules:example"
version = {1,0,0} version = {1,0,0}
engine = {0,9,28,"te4"} engine = {0,9,29,"te4"}
description = [[ description = [[
This is *NOT* a game, just an example/template to make your own using the T-Engine4. This is *NOT* a game, just an example/template to make your own using the T-Engine4.
]] ]]
......
...@@ -137,7 +137,9 @@ function _M:use(item) ...@@ -137,7 +137,9 @@ function _M:use(item)
if item.subaction == "none" then if item.subaction == "none" then
util.showMainMenu() util.showMainMenu()
elseif item.subaction == "restart" then 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=true") 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 end
elseif act == "cheat" then elseif act == "cheat" then
game.logPlayer(self.actor, "#LIGHT_BLUE#You resurrect! CHEATER !") game.logPlayer(self.actor, "#LIGHT_BLUE#You resurrect! CHEATER !")
...@@ -156,6 +158,7 @@ function _M:generateList() ...@@ -156,6 +158,7 @@ function _M:generateList()
if config.settings.cheat then list[#list+1] = {name="Resurrect by cheating", action="cheat"} end if config.settings.cheat then list[#list+1] = {name="Resurrect by cheating", action="cheat"} end
list[#list+1] = {name="Character dump", action="dump"} list[#list+1] = {name="Character dump", action="dump"}
list[#list+1] = {name="Restart the same character", action="exit", subaction="restart"} list[#list+1] = {name="Restart the same character", action="exit", subaction="restart"}
list[#list+1] = {name="Restart with a new character", action="exit", subaction="restart-new"}
list[#list+1] = {name="Exit to main menu", action="exit", subaction="none"} list[#list+1] = {name="Exit to main menu", action="exit", subaction="none"}
self.list = list self.list = list
......
...@@ -31,6 +31,7 @@ local TextzoneList = require "engine.ui.TextzoneList" ...@@ -31,6 +31,7 @@ local TextzoneList = require "engine.ui.TextzoneList"
local Separator = require "engine.ui.Separator" local Separator = require "engine.ui.Separator"
local NameGenerator = require "engine.NameGenerator" local NameGenerator = require "engine.NameGenerator"
local Module = require "engine.Module" local Module = require "engine.Module"
local CharacterVaultSave = require "engine.CharacterVaultSave"
module(..., package.seeall, class.inherit(Birther)) module(..., package.seeall, class.inherit(Birther))
...@@ -46,7 +47,7 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h) ...@@ -46,7 +47,7 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h)
self.descriptors = {} self.descriptors = {}
self.descriptors_by_type = {} self.descriptors_by_type = {}
self.c_ok = Button.new{text=" Play! ", fct=function() self:atEnd("created") end} self.c_ok = Button.new{text=" Play! ", fct=function() self:atEnd("created") end}
self.c_random = Button.new{text="Random!", fct=function() self:randomBirth() end} self.c_random = Button.new{text="Random!", fct=function() self:randomBirth() end}
self.c_premade = Button.new{text="Load premade", fct=function() self:loadPremadeUI() end} self.c_premade = Button.new{text="Load premade", fct=function() self:loadPremadeUI() end}
self.c_cancel = Button.new{text="Cancel", fct=function() self:atEnd("quit") end} self.c_cancel = Button.new{text="Cancel", fct=function() self:atEnd("quit") end}
...@@ -137,16 +138,32 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h) ...@@ -137,16 +138,32 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h)
self:setFocus(self.c_name) self:setFocus(self.c_name)
end end
function _M:checkNew(fct)
local savename = self.c_name.text:gsub("[^a-zA-Z0-9_-.]", "_")
if fs.exists(("/save/%s/game.teag"):format(savename)) then
Dialog:yesnoPopup("Overwrite character?", "There is already a character with this name, do you want to overwrite it?", function(ret)
if not ret then fct() end
end, "No", "Yes")
else
fct()
end
end
function _M:atEnd(v) function _M:atEnd(v)
if v == "created" then if v == "created" and not self.ui_by_ui[self.c_ok].hidden then
game:unregisterDialog(self) self:checkNew(function()
self:apply() game:unregisterDialog(self)
game:setPlayerName(self.c_name.text) self:apply()
self.at_end(false) game:setPlayerName(self.c_name.text)
self.at_end(false)
end)
elseif v == "loaded" then elseif v == "loaded" then
game:unregisterDialog(self) self:checkNew(function()
self.at_end(true) game:unregisterDialog(self)
else game:setPlayerName(self.c_name.text)
self.at_end(true)
end)
elseif v == "quit" then
util.showMainMenu() util.showMainMenu()
end end
end end
...@@ -525,10 +542,10 @@ function _M:generateClasses() ...@@ -525,10 +542,10 @@ function _M:generateClasses()
end end
function _M:loadPremade(pm) function _M:loadPremade(pm)
local fallback = false local fallback = pm.force_fallback
-- Load the entities directly -- Load the entities directly
if pm.module_version and pm.module_version[1] == game.__mod_info.version[1] and pm.module_version[2] == game.__mod_info.version[2] and pm.module_version[3] == game.__mod_info.version[3] then if not fallback and pm.module_version and pm.module_version[1] == game.__mod_info.version[1] and pm.module_version[2] == game.__mod_info.version[2] and pm.module_version[3] == game.__mod_info.version[3] then
savefile_pipe:ignoreSaveToken(true) savefile_pipe:ignoreSaveToken(true)
local qb = savefile_pipe:doLoad(pm.short_name, "entity", "engine.CharacterVaultSave", "character") local qb = savefile_pipe:doLoad(pm.short_name, "entity", "engine.CharacterVaultSave", "character")
savefile_pipe:ignoreSaveToken(false) savefile_pipe:ignoreSaveToken(false)
...@@ -538,6 +555,7 @@ function _M:loadPremade(pm) ...@@ -538,6 +555,7 @@ function _M:loadPremade(pm)
game.party = qb game.party = qb
game.player = nil game.player = nil
game.party:setPlayer(1, true) game.party:setPlayer(1, true)
self.c_name:setText(game.player.name)
self:atEnd("loaded") self:atEnd("loaded")
else else
fallback = true fallback = true
...@@ -548,8 +566,57 @@ function _M:loadPremade(pm) ...@@ -548,8 +566,57 @@ function _M:loadPremade(pm)
-- Fill in the descriptors and validate -- Fill in the descriptors and validate
if fallback then if fallback then
local ok = 0
-- Name
self.c_name:setText(pm.short_name) self.c_name:setText(pm.short_name)
-- self.
-- Sex
self.c_male.checked = pm.descriptors.sex == "Male"
self.c_female.checked = pm.descriptors.sex == "Female"
self:setDescriptor("sex", pm.descriptors.sex and "Male" or "Female")
-- Campaign
for i, item in ipairs(self.all_campaigns) do if not item.locked and item.id == pm.descriptors.world then
self:campaignUse(item)
self.c_campaign.c_list.sel = i
ok = ok + 1
break
end end
-- Difficulty
for i, item in ipairs(self.all_difficulties) do if not item.locked and item.id == pm.descriptors.difficulty then
self:difficultyUse(item)
self.c_difficulty.c_list.sel = i
ok = ok + 1
break
end end
-- Race
for i, pitem in ipairs(self.all_races) do
for j, item in ipairs(pitem.nodes) do
if not item.locked and item.id == pm.descriptors.subrace and pitem.id == pm.descriptors.race then
self:raceUse(pitem)
self:raceUse(item)
ok = ok + 1
break
end
end
end
-- Class
for i, pitem in ipairs(self.all_classes) do
for j, item in ipairs(pitem.nodes) do
if not item.locked and item.id == pm.descriptors.subclass and pitem.id == pm.descriptors.class then
self:classUse(pitem)
self:classUse(item)
ok = ok + 1
break
end
end
end
if ok == 4 then self:atEnd("created") end
end end
end end
...@@ -558,8 +625,6 @@ function _M:loadPremadeUI() ...@@ -558,8 +625,6 @@ function _M:loadPremadeUI()
local d = Dialog.new("Characters Vault", 600, 550) local d = Dialog.new("Characters Vault", 600, 550)
local sel = nil local sel = nil
local load = Button.new{text=" Load ", fct=function() if sel then self:loadPremade(sel) game:unregisterDialog(d) end end}
local del = Button.new{text="Delete", fct=function() end}
local desc = TextzoneList.new{width=220, height=400} local desc = TextzoneList.new{width=220, height=400}
local list list = List.new{width=350, list=lss, height=400, local list list = List.new{width=350, list=lss, height=400,
fct=function(item) fct=function(item)
...@@ -575,6 +640,17 @@ function _M:loadPremadeUI() ...@@ -575,6 +640,17 @@ function _M:loadPremadeUI()
} }
local sep = Separator.new{dir="horizontal", size=400} local sep = Separator.new{dir="horizontal", size=400}
local load = Button.new{text=" Load ", fct=function() if sel then self:loadPremade(sel) game:unregisterDialog(d) end end}
local del = Button.new{text="Delete", fct=function() if sel then
local vault = CharacterVaultSave.new(sel.short_name)
vault:delete()
vault:close()
lss = Module:listVaultSavesForCurrent()
list.list = lss
list:generate()
sel = nil
end end}
d:loadUI{ d:loadUI{
{left=0, top=0, ui=list}, {left=0, top=0, ui=list},
{left=list.w, top=0, ui=sep}, {left=list.w, top=0, ui=sep},
...@@ -591,4 +667,15 @@ end ...@@ -591,4 +667,15 @@ end
-- Disable stuff from the base Birther -- Disable stuff from the base Birther
function _M:updateList() end function _M:updateList() end
function _M:selectType(type) end function _M:selectType(type) end
function _M:on_register() end
function _M:on_register()
if __module_extra_info.auto_quickbirth then
local lss = Module:listVaultSavesForCurrent()
for i, pm in ipairs(lss) do
if pm.short_name == __module_extra_info.auto_quickbirth then
self:loadPremade(pm)
break
end
end
end
end
...@@ -54,10 +54,10 @@ end ...@@ -54,10 +54,10 @@ 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 = {}
-- Remove chronoworlds -- Remove chronoworlds
if game._chronoworlds then game._chronoworlds = nil end if game._chronoworlds then game._chronoworlds = nil end
-- Go through all spell effects -- Go through all spell effects
for eff_id, p in pairs(actor.tmp) do for eff_id, p in pairs(actor.tmp) do
local e = actor.tempeffect_def[eff_id] local e = actor.tempeffect_def[eff_id]
...@@ -174,7 +174,9 @@ function _M:use(item) ...@@ -174,7 +174,9 @@ function _M:use(item)
if item.subaction == "none" then if item.subaction == "none" then
util.showMainMenu() util.showMainMenu()
elseif item.subaction == "restart" then 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=true") 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 end
elseif act == "dump" then elseif act == "dump" then
game:registerDialog(require("mod.dialogs.CharacterSheet").new(self.actor)) game:registerDialog(require("mod.dialogs.CharacterSheet").new(self.actor))
...@@ -251,6 +253,7 @@ function _M:generateList() ...@@ -251,6 +253,7 @@ function _M:generateList()
list[#list+1] = {name="Character dump", action="dump"} list[#list+1] = {name="Character dump", action="dump"}
list[#list+1] = {name="Restart the same character", action="exit", subaction="restart"} list[#list+1] = {name="Restart the same character", action="exit", subaction="restart"}
list[#list+1] = {name="Restart with a new character", action="exit", subaction="restart-new"}
list[#list+1] = {name="Exit to main menu", action="exit", subaction="none"} list[#list+1] = {name="Exit to main menu", action="exit", subaction="none"}
self.list = list self.list = list
......
...@@ -22,8 +22,8 @@ long_name = "Tales of Maj'Eyal: Age of Ascendancy" ...@@ -22,8 +22,8 @@ long_name = "Tales of Maj'Eyal: Age of Ascendancy"
short_name = "tome" short_name = "tome"
author = { "DarkGod", "darkgod@te4.org" } author = { "DarkGod", "darkgod@te4.org" }
homepage = "http://tome.te4.org/" homepage = "http://tome.te4.org/"
version = {3,9,28} version = {3,9,29}
engine = {0,9,28,"te4"} engine = {0,9,29,"te4"}
description = [[ description = [[
Welcome to Maj'Eyal. Welcome to Maj'Eyal.
......
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