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

Correctly index quick keys in inventory dialogs

git-svn-id: http://svn.net-core.org/repos/t-engine4@1426 51575b47-30f0-44d4-a5cc-537603b46e54
parent be0d9757
No related branches found
No related tags found
No related merge requests found
......@@ -150,7 +150,7 @@ function _M:generateList()
self.equip_list = {}
local list = self.equip_list
local chars = {}
local i = 0
local i = 1
self.max_h = 0
for inven_id = 1, #self.actor.inven_def do
if self.actor.inven[inven_id] and self.actor.inven_def[inven_id].is_worn then
......@@ -160,7 +160,7 @@ function _M:generateList()
for item, o in ipairs(self.actor.inven[inven_id]) do
if not self.filter or self.filter(o) then
local char = string.char(string.byte('a') + i)
local char = self:makeKeyChar(i)
local zone = Textzone.new{width=self.iw, height=self.ih, text=o:getDesc()}
list[#list+1] = { zone=zone, id=#list+1, char=char, name=o:getName{do_color=true}, object=o, inven=inven_id, item=item, cat=o.subtype, encumberance=o.encumber }
self.max_h = math.max(self.max_h, #o:getDesc():splitLines(self.iw - 10, self.font))
......@@ -177,10 +177,10 @@ function _M:generateList()
self.inven_list = {}
local list = self.inven_list
local chars = {}
local i = 0
local i = 1
for item, o in ipairs(self.actor:getInven("INVEN")) do
if not self.filter or self.filter(o) then
local char = string.char(string.byte('a') + i)
local char = self:makeKeyChar(i)
local zone = Textzone.new{width=self.iw, height=self.ih, text=o:getDesc()}
list[#list+1] = { zone=zone, id=#list+1, char=char, name=o:getName{do_color=true}, object=o, inven=self.actor.INVEN_INVEN, item=item, cat=o.subtype, encumberance=o.encumber }
self.max_h = math.max(self.max_h, #o:getDesc():splitLines(self.iw - 10, self.font))
......
......@@ -82,7 +82,7 @@ function _M:generateList()
local list = {}
local chars = {}
list.chars = chars
local i = 0
local i = 1
for inven_id = 1, #self.actor.inven_def do
if self.actor.inven[inven_id] and self.actor.inven_def[inven_id].is_worn then
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=self.actor.inven_def[inven_id].description}
......@@ -90,7 +90,7 @@ function _M:generateList()
for item, o in ipairs(self.actor.inven[inven_id]) do
if not self.filter or self.filter(o) then
local char = string.char(string.byte('a') + i)
local char = self:makeKeyChar(i)
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=o:getDesc()}
list[#list+1] = { zone=zone, id=#list+1, char=char, name=o:getName{do_color=true}, object=o, inven=inven_id, item=item, cat=o.subtype, encumberance=o.encumber }
chars[char] = #list
......
......@@ -79,11 +79,10 @@ function _M:generateList()
-- Makes up the list
local list = {}
list.chars = {}
local i = 0
for item, o in ipairs(self.inven) do
if not self.filter or self.filter(o) then
local char = string.char(string.byte('a') + i)
list.chars[char] = i
local char = self:makeKeyChar(item)
list.chars[char] = item
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=o:getDesc()}
list[#list+1] = { char=char, zone=zone, name=o:getDisplayString()..o:getName(), color=o:getDisplayColor(), object=o, item=item, cat=o.subtype, encumberance=o.encumber }
i = i + 1
......
......@@ -107,7 +107,7 @@ function _M:generateList()
local o = game.level.map:getObject(self.x, self.y, idx)
if not o then break end
if not self.filter or self.filter(o) then
local char = string.char(string.byte('a') + i)
local char = self:makeKeyChar(i)
list.chars[char] = i
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=o:getDesc()}
list[#list+1] = { char=char, zone=zone, name=o:getDisplayString()..o:getName(), color=o:getDisplayColor(), object=o, item=i, cat=o.subtype, encumberance=o.encumber }
......
......@@ -104,11 +104,11 @@ function _M:generateList()
-- Makes up the list
local list = {}
list.chars = {}
local i = 0
local i = 1
self.max_h = 0
for item, o in ipairs(self.store_inven) do
if not self.store_filter or self.store_filter(o) then
local char = string.char(string.byte('a') + i)
local char = self:makeKeyChar(i)
local zone = Textzone.new{width=self.iw, height=self.ih, text=o:getDesc()}
list[#list+1] = { zone=zone, id=#list+1, char=char, name=o:getDisplayString()..o:getName(), color=o:getDisplayColor(), object=o, item=item, cat=o.subtype, cost=o.cost }
self.max_h = math.max(self.max_h, #o:getDesc():splitLines(self.iw - 10, self.font))
......@@ -121,10 +121,10 @@ function _M:generateList()
-- Makes up the list
local list = {}
list.chars = {}
local i = 0
local i = 1
for item, o in ipairs(self.actor_inven) do
if not self.actor_filter or self.actor_filter(o) then
local char = string.char(string.byte('a') + i)
local char = self:makeKeyChar(i)
local zone = Textzone.new{width=self.iw, height=self.ih, text=o:getDesc()}
list[#list+1] = { zone=zone, id=#list+1, char=char, name=o:getDisplayString()..o:getName(), color=o:getDisplayColor(), object=o, item=item, cat=o.subtype, cost=o.cost }
self.max_h = math.max(self.max_h, #o:getDesc():splitLines(self.iw - 10, self.font))
......
......@@ -298,6 +298,20 @@ function _M:display() end
function _M:unload()
end
function _M:makeKeyChar(i)
i = i - 1
if i <= 26 then
return string.char(string.byte('a') + i)
elseif i <= 52 then
return string.char(string.byte('A') + i)
elseif i <= 62 then
return string.char(string.byte('0') + i)
else
-- Invalid
return " "
end
end
function _M:toScreen(x, y)
-- Draw with only the texture
if self.__showup 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