Skip to content
Snippets Groups Projects
Commit d93b7120 authored by DarkGod's avatar DarkGod
Browse files

stores & inven rememebr scroll position

parent aa942dde
No related branches found
No related tags found
No related merge requests found
......@@ -168,7 +168,7 @@ function _M:display(x, y, nb_keyframes)
end
if self.focused then
self:drawFrame(self.frame_sel, x + self.title_w, y)
self.texcursor.t:toScreenFull(x + self.text_x + (self.cursor-self.scroll) * self.font_mono_w, y + self.cursor_y, self.texcursor.w, self.texcursor.h, self.texcursor.tw, self.texcursor.th)
self.texcursor.t:toScreenFull(x + self.text_x + (self.cursor-self.scroll) * self.font_mono_w - (self.texcursor.w / 2), y + self.cursor_y, self.texcursor.w, self.texcursor.h, self.texcursor.tw, self.texcursor.th)
else
self:drawFrame(self.frame, x + self.title_w, y)
if self.focus_decay then
......
......@@ -183,7 +183,7 @@ function _M:display(x, y, nb_keyframes)
end
if self.focused then
self:drawFrame(self.frame_sel, x + self.title_w, y)
self.texcursor.t:toScreenFull(x + self.text_x + (self.cursor-self.scroll) * self.font_mono_w, y + self.cursor_y, self.texcursor.w, self.texcursor.h, self.texcursor.tw, self.texcursor.th)
self.texcursor.t:toScreenFull(x + self.text_x + (self.cursor-self.scroll) * self.font_mono_w - (self.texcursor.w / 2), y + self.cursor_y, self.texcursor.w, self.texcursor.h, self.texcursor.tw, self.texcursor.th)
else
self:drawFrame(self.frame, x + self.title_w, y)
if self.focus_decay then
......
......@@ -326,6 +326,9 @@ function _M:drawDialog(kind, actor_to_compare)
if player:attr("forbid_arcane") then
s:drawColorStringBlended(self.font, "#ORCHID#Zigur follower", w, h, 255, 255, 255, true) h = h + self.font_h
end
if player:attr("blood_life") then
s:drawColorStringBlended(self.font, "#DARK_RED#Blood of Life", w, h, 255, 255, 255, true) h = h + self.font_h
end
h = h + self.font_h
self:mouseTooltip(self.TOOLTIP_LEVEL, s:drawColorStringBlended(self.font, "Level: #00ff00#"..player.level, w, h, 255, 255, 255, true)) h = h + self.font_h
......@@ -520,10 +523,10 @@ function _M:drawDialog(kind, actor_to_compare)
print_stat(self.actor.STAT_STR, ("%-12s"):format(Stats.stats_def[self.actor.STAT_STR].name:capitalize()), self.TOOLTIP_STR)
print_stat(self.actor.STAT_DEX, ("%-12s"):format(Stats.stats_def[self.actor.STAT_DEX].name:capitalize()), self.TOOLTIP_DEX)
print_stat(self.actor.STAT_CON, ("%-12s"):format(Stats.stats_def[self.actor.STAT_CON].name:capitalize()), self.TOOLTIP_CON)
print_stat(self.actor.STAT_MAG, ("%-12s"):format(Stats.stats_def[self.actor.STAT_MAG].name:capitalize()), self.TOOLTIP_MAG)
print_stat(self.actor.STAT_WIL, ("%-12s"):format(Stats.stats_def[self.actor.STAT_WIL].name:capitalize()), self.TOOLTIP_WIL)
print_stat(self.actor.STAT_CUN, ("%-12s"):format(Stats.stats_def[self.actor.STAT_CUN].name:capitalize()), self.TOOLTIP_CUN)
print_stat(self.actor.STAT_CON, ("%-12s"):format(Stats.stats_def[self.actor.STAT_CON].name:capitalize()), self.TOOLTIP_CON)
h = h + self.font_h
local nb_inscriptions = 0
......
......@@ -153,12 +153,22 @@ function _M:init(title, equip_actor, filter, action, on_select, inven_actor)
}
self.key:addBinds{
ACCEPT = function() if self.focus_ui and self.focus_ui.ui == self.c_inven then self:use(self.c_inven.c_inven.list[self.c_inven.c_inven.sel]) end end,
EXIT = function() game.tooltip.locked = false game:unregisterDialog(self) end,
EXIT = function()
if self.c_inven.c_inven.scrollbar then
self.equip_actor.inv_scroll = self.c_inven.c_inven.scrollbar.pos or 0
end
game.tooltip.locked = false
game:unregisterDialog(self)
end,
MOVE_UP = function() game.log("up") if game.tooltip.locked then game.tooltip.container.scroll_inertia = math.min(game.tooltip.container.scroll_inertia, 0) - 5 end end,
MOVE_DOWN = function() if game.tooltip.locked then game.tooltip.container.scroll_inertia = math.max(game.tooltip.container.scroll_inertia, 0) + 5 end end,
LOCK_TOOLTIP = lock_tooltip,
LOCK_TOOLTIP_COMPARE = lock_tooltip,
SCREENSHOT = function() if type(game) == "table" and game.key then game.key:triggerVirtual("SCREENSHOT") end end,
}
if self.equip_actor.inv_scroll and self.c_inven.c_inven.scrollbar then
self.c_inven.c_inven.scrollbar.pos = util.bound(self.equip_actor.inv_scroll, 0, self.c_inven.c_inven.scrollbar.max)
end
end
function _M:switchSets(which)
......@@ -203,6 +213,9 @@ function _M:select(item, force)
end
function _M:use(item, button, event)
if self.c_inven.c_inven.scrollbar then
self.equip_actor.inv_scroll = self.c_inven.c_inven.scrollbar.pos or 0
end
if item then
if self.action(item.object, item.inven, item.item, button, event) then
game:unregisterDialog(self)
......@@ -228,6 +241,9 @@ function _M:updateTitle(title)
g = util.lerp(green.g, red.g, v),
b = util.lerp(green.b, red.b, v),
}
if self.equip_actor.inv_scroll and self.c_inven.c_inven.scrollbar then
self.c_inven.c_inven.scrollbar.pos = util.bound(self.equip_actor.inv_scroll, 0, self.c_inven.c_inven.scrollbar.max)
end
end
function _M:onDrag(item)
......
......@@ -119,7 +119,15 @@ function _M:init(title, store_inven, actor_inven, store_filter, actor_filter, ac
[{"_TAB","shift"}] = function() self:moveFocus(1) end,
}
self.key:addBinds{
EXIT = function() game:unregisterDialog(self) end,
EXIT = function()
if self.c_inven.c_inven.scrollbar then
self.actor_actor.inv_scroll = self.c_inven.c_inven.scrollbar.pos or 0
end
if self.c_store.c_inven.scrollbar then
self.actor_actor.store_scroll = self.c_store.c_inven.scrollbar.pos or 0
end
game:unregisterDialog(self)
end,
}
-- Add tooltips
......@@ -147,6 +155,12 @@ function _M:init(title, store_inven, actor_inven, store_filter, actor_filter, ac
self.prev_ctrl = ctrl
end
end
if self.actor_actor.inv_scroll and self.c_inven.c_inven.scrollbar then
self.c_inven.c_inven.scrollbar.pos = util.bound(self.actor_actor.inv_scroll, 0, self.c_inven.c_inven.scrollbar.max or 0)
end
if self.actor_actor.store_scroll and self.c_store.c_inven.scrollbar then
self.c_store.c_inven.scrollbar.pos = util.bound(self.actor_actor.store_scroll, 0, self.c_store.c_inven.scrollbar.max or 0)
end
end
function _M:on_register()
......@@ -160,6 +174,12 @@ end
function _M:updateStore()
self:generateList()
self:updateTitle(self:getStoreTitle())
if self.actor_actor.inv_scroll and self.c_inven.c_inven.scrollbar then
self.c_inven.c_inven.scrollbar.pos = util.bound(self.actor_actor.inv_scroll, 0, self.c_inven.c_inven.scrollbar.max or 0)
end
if self.actor_actor.store_scroll and self.c_store.c_inven.scrollbar then
self.c_store.c_inven.scrollbar.pos = util.bound(self.actor_actor.store_scroll, 0, self.c_store.c_inven.scrollbar.max or 0)
end
end
function _M:select(item, force)
......@@ -169,6 +189,8 @@ function _M:select(item, force)
end
function _M:use(item, force)
self.actor_actor.inv_scroll = self.c_inven.c_inven.scrollbar and self.c_inven.c_inven.scrollbar.pos or 0
self.actor_actor.store_scroll = self.c_store.c_inven.scrollbar and self.c_store.c_inven.scrollbar.pos or 0
if item and item.object then
if self.focus_ui and self.focus_ui.ui == self.c_store then
if util.getval(self.allow_buy, item.object, item.item) 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