diff --git a/game/engines/default/engine/Module.lua b/game/engines/default/engine/Module.lua index f2ea3f35ae5904f9a9d46586062becfa372ec168..587221650ca8cb43efdafef68ead51fe24ec0952 100644 --- a/game/engines/default/engine/Module.lua +++ b/game/engines/default/engine/Module.lua @@ -178,6 +178,7 @@ function _M:listSavefiles(moddir_filter) local mods = self:listModules(nil, moddir_filter) for _, mod in ipairs(mods) do 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 local dir = "/tmp/listsaves/"..mod.short_name.."/save/"..short_name if fs.exists(dir.."/game.teag") then @@ -788,6 +789,7 @@ function _M:loadSavefileDescription(dir) if not ls.name or not ls.description then return end ls.dir = dir + print(" * save", ls.dir) return ls end end diff --git a/game/engines/default/modules/boot/dialogs/LoadGame.lua b/game/engines/default/modules/boot/dialogs/LoadGame.lua index 9a1ea44f9edf03b7d40a826ff00a5d5fbced301d..7fbe1e2b27b7b794a9ccd9eb4f9c9111ce1a9cc7 100644 --- a/game/engines/default/modules/boot/dialogs/LoadGame.lua +++ b/game/engines/default/modules/boot/dialogs/LoadGame.lua @@ -24,6 +24,7 @@ local TreeList = require "engine.ui.TreeList" local Button = require "engine.ui.Button" local Textzone = require "engine.ui.Textzone" local Separator = require "engine.ui.Separator" +local Checkbox = require "engine.ui.Checkbox" local Savefile = require "engine.Savefile" module(..., package.seeall, class.inherit(Dialog)) @@ -31,12 +32,47 @@ module(..., package.seeall, class.inherit(Dialog)) function _M:init() 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_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: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 = {} local found = false for i = #list, 1, -1 do @@ -48,7 +84,9 @@ function _M:init() 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 = list[mod_string] + if not mod and self.c_compat.checked then mod = m end 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 addons = {} save.usable = true @@ -86,36 +124,12 @@ function _M:init() }) end end +end - 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}}, - } - self:setFocus(self.c_tree) - self:setupUI(false, true) - - self.key:addBinds{ - EXIT = function() game:unregisterDialog(self) end, - } +function _M:switch() + self:generateList() + self.c_tree.tree = self.tree + self.c_tree:generate() end function _M:on_focus(id, ui) diff --git a/game/modules/tome/class/NPC.lua b/game/modules/tome/class/NPC.lua index 5beb029e2d29e246c8d3ffac16fc253a0cbe81e3..d1a5f0f69395903b4585ff99070b7c8d60aeb6ed 100644 --- a/game/modules/tome/class/NPC.lua +++ b/game/modules/tome/class/NPC.lua @@ -393,7 +393,7 @@ end function _M:aiCanPass(x, y) -- If there is a friendly actor, add shove_pressure to it 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) -- Shove the target? if target.shove_pressure > shove_algorithm(target) * 1.7 then diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua index b172064aae671e87b8dd91d9686c1b6749dfb51b..ba5b8fda84dc169bcbc2eb1f7ad9d68fa4b19523 100644 --- a/game/modules/tome/class/Object.lua +++ b/game/modules/tome/class/Object.lua @@ -302,7 +302,7 @@ function _M:getTextualDesc(compare_with) 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 desc:add(true) if self.slot_forbid == "OFFHAND" then desc:add("It must be held with both hands.", true) end diff --git a/game/modules/tome/dialogs/CharacterSheet.lua b/game/modules/tome/dialogs/CharacterSheet.lua index c503ffd721ab355e23b68e1a3086973d964fee02..d36edba1851a60955262522b27d1c232fa281a85 100644 --- a/game/modules/tome/dialogs/CharacterSheet.lua +++ b/game/modules/tome/dialogs/CharacterSheet.lua @@ -1242,7 +1242,8 @@ function _M:dump() nl() for item, o in ipairs(player:getInven("INVEN")) do 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"):format(tostring(o:getTextualDesc()))) if o.droppedBy then