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

plop

git-svn-id: http://svn.net-core.org/repos/t-engine4@6206 51575b47-30f0-44d4-a5cc-537603b46e54
parent 763d80b2
No related branches found
No related tags found
No related merge requests found
...@@ -178,6 +178,7 @@ function _M:listSavefiles(moddir_filter) ...@@ -178,6 +178,7 @@ function _M:listSavefiles(moddir_filter)
local mods = self:listModules(nil, moddir_filter) local mods = self:listModules(nil, moddir_filter)
for _, mod in ipairs(mods) do for _, mod in ipairs(mods) do
local lss = {} local lss = {}
print("Listing saves for module", mod.short_name)
for i, short_name in ipairs(fs.list("/tmp/listsaves/"..mod.short_name.."/save/")) do for i, short_name in ipairs(fs.list("/tmp/listsaves/"..mod.short_name.."/save/")) do
local dir = "/tmp/listsaves/"..mod.short_name.."/save/"..short_name local dir = "/tmp/listsaves/"..mod.short_name.."/save/"..short_name
if fs.exists(dir.."/game.teag") then if fs.exists(dir.."/game.teag") then
...@@ -788,6 +789,7 @@ function _M:loadSavefileDescription(dir) ...@@ -788,6 +789,7 @@ function _M:loadSavefileDescription(dir)
if not ls.name or not ls.description then return end if not ls.name or not ls.description then return end
ls.dir = dir ls.dir = dir
print(" * save", ls.dir)
return ls return ls
end end
end end
......
...@@ -24,6 +24,7 @@ local TreeList = require "engine.ui.TreeList" ...@@ -24,6 +24,7 @@ local TreeList = require "engine.ui.TreeList"
local Button = require "engine.ui.Button" local Button = require "engine.ui.Button"
local Textzone = require "engine.ui.Textzone" local Textzone = require "engine.ui.Textzone"
local Separator = require "engine.ui.Separator" local Separator = require "engine.ui.Separator"
local Checkbox = require "engine.ui.Checkbox"
local Savefile = require "engine.Savefile" local Savefile = require "engine.Savefile"
module(..., package.seeall, class.inherit(Dialog)) module(..., package.seeall, class.inherit(Dialog))
...@@ -31,12 +32,47 @@ module(..., package.seeall, class.inherit(Dialog)) ...@@ -31,12 +32,47 @@ module(..., package.seeall, class.inherit(Dialog))
function _M:init() function _M:init()
Dialog.init(self, "Load Game", game.w * 0.8, game.h * 0.8) Dialog.init(self, "Load Game", game.w * 0.8, game.h * 0.8)
local list = Module:listSavefiles() self.c_compat = Checkbox.new{default=false, width=math.floor(self.iw / 3 - 40), title="Show incompatible", on_change=function() self:switch() end}
self.c_play = Button.new{text=" Play! ", fct=function(text) self:playSave() end} self.c_play = Button.new{text=" Play! ", fct=function(text) self:playSave() end}
self.c_delete = Button.new{text="Delete", fct=function(text) self:deleteSave() end} self.c_delete = Button.new{text="Delete", fct=function(text) self:deleteSave() end}
self.c_desc = Textzone.new{width=math.floor(self.iw / 3 * 2 - 10), height=self.ih - self.c_delete.h - 10, text=""} self.c_desc = Textzone.new{width=math.floor(self.iw / 3 * 2 - 10), height=self.ih - self.c_delete.h - 10, text=""}
self:generateList()
self.save_sel = nil
self.c_tree = TreeList.new{width=math.floor(self.iw / 3 - 10), height=self.ih, scrollbar=true, columns={
{width=100, display_prop="name"},
}, tree=self.tree,
fct=function(item)
if self.save_sel == item then self:playSave() end
if self.save_sel then self.save_sel.color = nil self.c_tree:drawItem(self.save_sel) end
item.color = function() return colors.simple(colors.LIGHT_GREEN) end
self.save_sel = item
self.c_tree:drawItem(item)
if item.usable then self:toggleDisplay(self.c_play, true) end
self:toggleDisplay(self.c_delete, true)
end,
select=function(item, sel) self:select(item) end,
}
self:loadUI{
{left=0, top=0, ui=self.c_tree},
{right=0, top=0, ui=self.c_desc},
{right=0, bottom=0, ui=self.c_delete, hidden=true},
{left=0, bottom=0, ui=self.c_play, hidden=true},
{left=self.c_tree.w + 5, top=5, ui=Separator.new{dir="horizontal", size=self.ih - 10}},
{left=0, bottom=0, ui=self.c_compat},
}
self:setFocus(self.c_tree)
self:setupUI(false, true)
self.key:addBinds{
EXIT = function() game:unregisterDialog(self) end,
}
end
function _M:generateList()
local list = Module:listSavefiles()
self.tree = {} self.tree = {}
local found = false local found = false
for i = #list, 1, -1 do for i = #list, 1, -1 do
...@@ -48,7 +84,9 @@ function _M:init() ...@@ -48,7 +84,9 @@ function _M:init()
for j, save in ipairs(m.savefiles) do for j, save in ipairs(m.savefiles) do
local mod_string = ("%s-%d.%d.%d"):format(m.short_name, save.module_version and save.module_version[1] or -1, save.module_version and save.module_version[2] or -1, save.module_version and save.module_version[3] or -1) local mod_string = ("%s-%d.%d.%d"):format(m.short_name, save.module_version and save.module_version[1] or -1, save.module_version and save.module_version[2] or -1, save.module_version and save.module_version[3] or -1)
local mod = list[mod_string] local mod = list[mod_string]
if not mod and self.c_compat.checked then mod = m end
if mod and save.loadable then if mod and save.loadable then
for k,e in pairs(mod) do print("<<<===", k, e) end
local laddons = table.reversekey(Module:listAddons(mod, true), "short_name") local laddons = table.reversekey(Module:listAddons(mod, true), "short_name")
local addons = {} local addons = {}
save.usable = true save.usable = true
...@@ -86,36 +124,12 @@ function _M:init() ...@@ -86,36 +124,12 @@ function _M:init()
}) })
end end
end end
end
self.save_sel = nil function _M:switch()
self.c_tree = TreeList.new{width=math.floor(self.iw / 3 - 10), height=self.ih, scrollbar=true, columns={ self:generateList()
{width=100, display_prop="name"}, self.c_tree.tree = self.tree
}, tree=self.tree, self.c_tree:generate()
fct=function(item)
if self.save_sel == item then self:playSave() end
if self.save_sel then self.save_sel.color = nil self.c_tree:drawItem(self.save_sel) end
item.color = function() return colors.simple(colors.LIGHT_GREEN) end
self.save_sel = item
self.c_tree:drawItem(item)
if item.usable then self:toggleDisplay(self.c_play, true) end
self:toggleDisplay(self.c_delete, true)
end,
select=function(item, sel) self:select(item) end,
}
self:loadUI{
{left=0, top=0, ui=self.c_tree},
{right=0, top=0, ui=self.c_desc},
{right=0, bottom=0, ui=self.c_delete, hidden=true},
{left=0, bottom=0, ui=self.c_play, hidden=true},
{left=self.c_tree.w + 5, top=5, ui=Separator.new{dir="horizontal", size=self.ih - 10}},
}
self:setFocus(self.c_tree)
self:setupUI(false, true)
self.key:addBinds{
EXIT = function() game:unregisterDialog(self) end,
}
end end
function _M:on_focus(id, ui) function _M:on_focus(id, ui)
......
...@@ -393,7 +393,7 @@ end ...@@ -393,7 +393,7 @@ end
function _M:aiCanPass(x, y) function _M:aiCanPass(x, y)
-- If there is a friendly actor, add shove_pressure to it -- If there is a friendly actor, add shove_pressure to it
local target = game.level.map(x, y, engine.Map.ACTOR) local target = game.level.map(x, y, engine.Map.ACTOR)
if target and target ~= game.player and self:reactionToward(target) > 0 and not self:attr("never_move") then if target and target ~= game.player and self:reactionToward(target) > 0 and not target:attr("never_move") then
target.shove_pressure = (target.shove_pressure or 0) + shove_algorithm(self) + (self.shove_pressure or 0) target.shove_pressure = (target.shove_pressure or 0) + shove_algorithm(self) + (self.shove_pressure or 0)
-- Shove the target? -- Shove the target?
if target.shove_pressure > shove_algorithm(target) * 1.7 then if target.shove_pressure > shove_algorithm(target) * 1.7 then
......
...@@ -302,7 +302,7 @@ function _M:getTextualDesc(compare_with) ...@@ -302,7 +302,7 @@ function _M:getTextualDesc(compare_with)
if self.quest then desc:add({"color", "VIOLET"},"[Plot Item]", {"color", "LAST"}, true) end if self.quest then desc:add({"color", "VIOLET"},"[Plot Item]", {"color", "LAST"}, true) end
desc:add(("Type: %s / %s"):format(rawget(self, 'type') or "unknown", rawget(self, 'subtype') or "unknown")) desc:add(("Type: %s / %s"):format(tostring(rawget(self, 'type') or "unknown"), tostring(rawget(self, 'subtype') or "unknown")))
if self.material_level then desc:add(" ; tier ", tostring(self.material_level)) end if self.material_level then desc:add(" ; tier ", tostring(self.material_level)) end
desc:add(true) desc:add(true)
if self.slot_forbid == "OFFHAND" then desc:add("It must be held with both hands.", true) end if self.slot_forbid == "OFFHAND" then desc:add("It must be held with both hands.", true) end
......
...@@ -1242,7 +1242,8 @@ function _M:dump() ...@@ -1242,7 +1242,8 @@ function _M:dump()
nl() nl()
for item, o in ipairs(player:getInven("INVEN")) do for item, o in ipairs(player:getInven("INVEN")) do
if not self.filter or self.filter(o) then if not self.filter or self.filter(o) then
local char = string.char(string.byte('a') + item - 1) local char = " "
if item < 26 then string.char(string.byte('a') + item - 1) end
nl(("%s) %s"):format(char, o:getName{force_id=true})) nl(("%s) %s"):format(char, o:getName{force_id=true}))
nl((" %s"):format(tostring(o:getTextualDesc()))) nl((" %s"):format(tostring(o:getTextualDesc())))
if o.droppedBy then if o.droppedBy then
......
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