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

Quick Birth

Water now uses OpenGL shaders


git-svn-id: http://svn.net-core.org/repos/t-engine4@835 51575b47-30f0-44d4-a5cc-537603b46e54
parent 4e963040
No related branches found
No related tags found
No related merge requests found
......@@ -60,10 +60,12 @@ end
--- Instanciates a birther for the given actor
function _M:init(actor, order, at_end)
function _M:init(actor, order, at_end, quickbirth)
self.quickbirth = quickbirth
self.actor = actor
self.order = order
self.at_end = at_end
engine.Dialog.init(self, "Character Creation: "..actor.name, 600, 400)
self.descriptors = {}
......@@ -91,6 +93,34 @@ function _M:init(actor, order, at_end)
}
end
function _M:on_register()
if self.quickbirth then
self:yesnoPopup("Quick Birth", "Do you want to recreate the same character?", function(ret)
self.do_quickbirth = true
self:quickBirth()
end)
end
end
function _M:quickBirth()
if not self.do_quickbirth then return end
-- Aborth quickbirth if stage not found
if not self.quickbirth[self.current_type] then self.do_quickbirth = false end
-- Find the corect descriptor
for i, d in ipairs(self.list) do
if self.quickbirth[self.current_type] == d.name then
print("[QUICK BIRTH] using", d.name, "for", self.current_type)
self.sel = i
self:next()
return true
end
end
-- Abord if not found
self.do_quickbirth = false
end
function _M:selectType(type)
local default = 1
self.list = {}
......@@ -148,6 +178,9 @@ function _M:next()
end
end
self:selectType(self.order[self.cur_order])
if self:quickBirth() then return end
if #self.list == 1 and self.birth_auto[self.current_type] ~= false then
self:next()
end
......
......@@ -131,6 +131,7 @@ function _M:registerDialog(d)
self.dialogs[d] = #self.dialogs
if d.key then d.key:setCurrent() end
if d.mouse then d.mouse:setCurrent() end
if d.on_register then d:on_register() end
end
--- Undisplay a dialog, removing its own keyhandler if needed
......
......@@ -37,6 +37,7 @@ _M.current_save = false
function _M:init(savefile)
self.short_name = savefile:gsub("[^a-zA-Z0-9_-.]", "_")
self.save_dir = "/save/"..self.short_name.."/"
self.quickbirth_file = "/save/"..self.short_name..".quickbirth"
self.load_dir = "/tmp/loadsave/"
self.tables = {}
......@@ -111,6 +112,34 @@ function _M:saveWorld(world)
game:unregisterDialog(popup)
end
--- Save the given birth descriptors, used for quick start
function _M:saveQuickBirth(descriptor)
collectgarbage("collect")
local f = fs.open(self.quickbirth_file, "w")
for k, e in pairs(descriptor) do
f:write(("%s = %q\n"):format(tostring(k), tostring(e)))
end
f:close()
end
--- Load the given birth descriptors, used for quick start
function _M:loadQuickBirth()
collectgarbage("collect")
local f = loadfile(self.quickbirth_file)
print("[QUICK BIRTH]", f)
if f then
-- Call the file body inside its own private environment
local def = {}
setfenv(f, def)
if pcall(f) then
return def
end
end
return nil
end
--- Save the given game
function _M:saveGame(game)
collectgarbage("collect")
......
......@@ -120,7 +120,17 @@ function _M:newGame()
Map:setViewerActor(self.player)
self:setupDisplayMode()
-- Load for quick birth
local save = Savefile.new(self.save_name)
local quickbirth = save:loadQuickBirth()
save:close()
local birth = Birther.new(self.player, {"base", "difficulty", "world", "race", "subrace", "sex", "class", "subclass" }, function()
-- Save for quick birth
local save = Savefile.new(self.save_name)
save:saveQuickBirth(self.player.descriptor)
save:close()
self.player.wild_x, self.player.wild_y = self.player.default_wilderness[1], self.player.default_wilderness[2]
self.player.last_wilderness = self.player.default_wilderness[3] or "wilderness"
self:changeLevel(1, self.player.starting_zone)
......@@ -134,7 +144,7 @@ function _M:newGame()
print("[PLAYER BIRTH] resolved!")
self.player:grantQuest(self.player.starting_quest)
self:registerDialog(require("mod.dialogs.IntroDialog").new(self.player))
end)
end, quickbirth)
self:registerDialog(birth)
end
......
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