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

Saving will now display a progress bar

git-svn-id: http://svn.net-core.org/repos/t-engine4@1697 51575b47-30f0-44d4-a5cc-537603b46e54
parent aba43c6e
No related branches found
No related tags found
No related merge requests found
......@@ -101,6 +101,7 @@ function _M:saveObject(obj, zip)
local tbl = table.remove(self.process)
self.tables[tbl] = self:getFileName(tbl)
zip:add(self:getFileName(tbl), tbl:save())
savefile_pipe.current_nb = savefile_pipe.current_nb + 1
end
return self.tables[obj]
end
......
......@@ -39,6 +39,8 @@ function _M:init(class, max_before_wait)
self.pipe = {}
self.max_before_wait = max_before_wait or 4
self.co = nil
self.current_nb = 0
self.total_nb = 1
end
--- Push a savefile request
......@@ -53,7 +55,13 @@ function _M:push(savename, type, object, class)
local Savefile = require(class)
local id = Savefile["nameSave"..type:lower():capitalize()](Savefile, object)
self.pipe[#self.pipe+1] = {id=id, savename = savename, type=type, object=object:cloneFull(), baseobject=object, class=class, saveversion=game:saveVersion("new")}
if #self.pipe == 0 then savefile_pipe.current_nb = 0 end
local clone, nb = object:cloneFull()
self.pipe[#self.pipe+1] = {id=id, savename = savename, type=type, object=clone, nb_objects=nb, baseobject=object, class=class, saveversion=game:saveVersion("new")}
local total_nb = 0
for i, p in ipairs(self.pipe) do total_nb = total_nb + p.nb_objects end
self.total_nb = total_nb
if not self.co or coroutine.status(self.co) == "dead" then
self.co = coroutine.create(function() return self:doThread() end)
game:registerCoroutine("savefilepipe", self.co)
......@@ -78,7 +86,7 @@ function _M:doThread()
local Savefile = require(p.class)
local o = p.object
print("[SAVEFILE PIPE] new save running in the pipe:", p.savename, p.type, "::", p.id, "::", p.baseobject, "=>", p.object)
print("[SAVEFILE PIPE] new save running in the pipe:", p.savename, p.type, "::", p.id, "::", p.baseobject, "=>", p.object, "("..p.nb_objects..")")
local save = Savefile.new(p.savename, true)
o.__saved_saveversion = p.saveversion
......@@ -101,7 +109,10 @@ function _M:forceWait()
popup.__showup = nil
core.display.forceRedraw()
local cnt = 0
while coroutine.status(self.co) ~= "dead" do
cnt = cnt + 1
if cnt == 1000 then core.display.forceRedraw() if game:getPlayer() then game:getPlayer().changed = true end cnt = 0 end
coroutine.resume(self.co)
end
......
......@@ -113,31 +113,34 @@ function _M:clone(t)
end
local function clonerecursfull(clonetable, d, allow_cloned)
local function clonerecursfull(clonetable, d)
local nb = 0
local add
local n = {}
clonetable[d] = n
for k, e in pairs(d) do
local nk, ne = k, e
if clonetable[k] then nk = clonetable[k]
elseif type(k) == "table" then nk = clonerecursfull(clonetable, k)
elseif type(k) == "table" then nk, add = clonerecursfull(clonetable, k) nb = nb + add
end
if clonetable[e] then ne = clonetable[e]
elseif type(e) == "table" and (type(k) ~= "string" or k ~= "__threads") then ne = clonerecursfull(clonetable, e)
elseif type(e) == "table" and (type(k) ~= "string" or k ~= "__threads") then ne, add = clonerecursfull(clonetable, e) nb = nb + add
end
n[nk] = ne
end
setmetatable(n, getmetatable(d))
if n.cloned and n.__CLASSNAME then n:cloned(d) end
return n
if n.__CLASSNAME then nb = nb + 1 end
return n, nb
end
--- Clones the object, all subobjects without cloning twice a subobject
function _M:cloneFull(allow_cloned)
-- @return the clone and the number of cloned objects
function _M:cloneFull()
local clonetable = {}
local n = clonerecursfull(clonetable, self, allow_cloned)
return n
return clonerecursfull(clonetable, self)
end
--- Replaces the object with an other, by copying (not deeply)
......
......@@ -462,6 +462,7 @@ function _M:tick()
-- (since display is on a set FPS while tick() ticks as much as possible
-- engine.GameEnergyBased.tick(self)
end
if savefile_pipe.saving then self.player.changed = true end
if self.paused and not savefile_pipe.saving then return true end
end
......
......@@ -152,7 +152,13 @@ function _M:display()
self:mouseTooltip(self.TOOLTIP_HATE, s:drawColorStringBlended(self.font, ("#F53CBE#Hate: #ffffff#%.1f/%d"):format(player:getHate(), 10), x, h, 255, 255, 255)) h = h + self.font_h
end
if savefile_pipe.saving then h = h + self.font_h s:drawColorStringBlended(self.font, "#YELLOW#Saving...", x, h, 255, 255, 255) h = h + self.font_h end
if savefile_pipe.saving then
h = h + self.font_h
s:erase(0x68 / 6, 0x72 / 6, 0x00 / 6, 255, self.bars_x, h, self.bars_w, self.font_h)
s:erase(0x95 / 3, 0xa2 / 3, 0x80 / 3, 255, self.bars_x, h, self.bars_w * savefile_pipe.current_nb / savefile_pipe.total_nb, self.font_h)
s:drawColorStringBlended(self.font, ("#YELLOW#Saving...: %d%%"):format(100 * savefile_pipe.current_nb / savefile_pipe.total_nb), x, h, 255, 255, 255)
h = h + self.font_h
end
h = h + self.font_h
for tid, act in pairs(player.sustain_talents) do
......
......@@ -82,8 +82,6 @@ newTalent{
particle = self:addParticles(Particles.new("stone_skin", 1)),
move = self:addTemporaryValue("never_move", 1),
knock = self:addTemporaryValue("knockback_immune", kb),
detect = self:addTemporaryValue("detect_range", rad),
tremor = self:addTemporaryValue("detect_actor", 1),
cdred = self:addTemporaryValue("talent_cd_reduction", {
[self.T_STALACTITIC_MISSILES] = cdr,
[self.T_STRIKE] = cdr,
......@@ -100,8 +98,6 @@ newTalent{
self:removeParticles(p.particle)
self:removeTemporaryValue("never_move", p.move)
self:removeTemporaryValue("knockback_immune", p.knock)
self:removeTemporaryValue("detect_actor", p.tremor)
self:removeTemporaryValue("detect_range", p.detect)
self:removeTemporaryValue("talent_cd_reduction", p.cdred)
self:removeTemporaryValue("resists", p.res)
return true
......@@ -111,9 +107,8 @@ newTalent{
Your stoned form and your affinity with the earth while the spell is active has the following effects:
* Reduces the cooldown of Stalactitic Missiles, Earthquake, and Strike by %d
* Grants %d%% Fire Resistance, %d%% Lightning Resistance, %d%% Physical Resistance, and %d%% Knockback Resistance
* Sense foes around you in a radius of %d.
Resistances and Sense radius scale with the Magic Stat.]])
:format((self:getTalentLevel(t)/2), self:combatTalentSpellDamage(t, 5, 80), self:combatTalentSpellDamage(t, 5, 50), self:combatTalentSpellDamage(t, 5, 20), (self:getTalentLevel(t)*10), (5 + self:combatSpellpower(0.1) * self:getTalentLevel(t)))
:format((self:getTalentLevel(t)/2), self:combatTalentSpellDamage(t, 5, 80), self:combatTalentSpellDamage(t, 5, 50), self:combatTalentSpellDamage(t, 5, 20), (self:getTalentLevel(t)*10))
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