diff --git a/game/modules/tome/dialogs/ShowEquipInven.lua b/game/modules/tome/dialogs/ShowEquipInven.lua index bd4fe7a3596a406321d2e70735251a6d21b5be74..0876c06ee568f44bd0f8b89e27fccdaff7f4f556 100644 --- a/game/modules/tome/dialogs/ShowEquipInven.lua +++ b/game/modules/tome/dialogs/ShowEquipInven.lua @@ -23,6 +23,7 @@ local Dialog = require "engine.ui.Dialog" local Inventory = require "engine.ui.Inventory" local Separator = require "engine.ui.Separator" local EquipDoll = require "engine.ui.EquipDoll" +local Tab = require "engine.ui.Tab" module(..., package.seeall, class.inherit(Dialog)) @@ -34,6 +35,9 @@ function _M:init(title, actor, filter, action, on_select) Dialog.init(self, title or "Inventory", math.max(800, game.w * 0.8), math.max(600, game.h * 0.8)) + self.c_main_set = Tab.new{title="Main Set", default=not actor.off_weapon_slots, fct=function() end, on_change=function(s) if s then self:switchSets("main") end end} + self.c_off_set = Tab.new{title="Off Set", default=actor.off_weapon_slots, fct=function() end, on_change=function(s) if s then self:switchSets("off") end end} + -- Add tooltips self.on_select = function(item) if item.last_display_x and item.object then @@ -66,7 +70,9 @@ function _M:init(title, actor, filter, action, on_select) } local uis = { - {left=0, top=0, ui=self.c_doll}, + {left=0, top=0, ui=self.c_main_set}, + {left=self.c_main_set, top=0, ui=self.c_off_set}, + {left=0, top=self.c_main_set, ui=self.c_doll}, {right=0, top=0, ui=self.c_inven}, {left=self.c_doll.w, top=5, ui=Separator.new{dir="horizontal", size=self.ih - 10}}, } @@ -88,7 +94,16 @@ function _M:init(title, actor, filter, action, on_select) -- Control resets the tooltip if sym == self.key._LCTRL or sym == self.key._RCTRL then local i = self.cur_item self.cur_item = nil self:select(i) end end +end + +function _M:switchSets(which) + if which == "main" and not self.actor.off_weapon_slots then return end + if which == "off" and self.actor.off_weapon_slots then return end + + self.actor:quickSwitchWeapons() + self.c_main_set.selected = not self.actor.off_weapon_slots + self.c_off_set.selected = self.actor.off_weapon_slots end function _M:firstDisplay() diff --git a/game/modules/tome/dialogs/ShowEquipment.lua b/game/modules/tome/dialogs/ShowEquipment.lua index 10862c308074e1dc04deb1d9e04ee17d1f4c934b..af562c4130a4d6105316310f301320f37cb51eb9 100644 --- a/game/modules/tome/dialogs/ShowEquipment.lua +++ b/game/modules/tome/dialogs/ShowEquipment.lua @@ -23,6 +23,7 @@ local EquipDoll = require "engine.ui.EquipDoll" local Textzone = require "engine.ui.Textzone" local TextzoneList = require "engine.ui.TextzoneList" local Separator = require "engine.ui.Separator" +local Tab = require "engine.ui.Tab" module(..., package.seeall, class.inherit(Dialog)) @@ -32,6 +33,9 @@ function _M:init(title, actor, filter, action) self.action = action Dialog.init(self, title or "Equipment", math.max(800, game.w * 0.8), math.max(600, game.h * 0.8)) + self.c_main_set = Tab.new{title="Main Set", default=not actor.off_weapon_slots, fct=function() end, on_change=function(s) if s then self:switchSets("main") end end} + self.c_off_set = Tab.new{title="Off Set", default=actor.off_weapon_slots, fct=function() end, on_change=function(s) if s then self:switchSets("off") end end} + self.c_doll = EquipDoll.new{actor=actor, drag_enable=true, fct=function(item) self:use(item) end, on_select=function(ui, inven, item, o) self:select{item=item, object=o} end @@ -40,7 +44,9 @@ function _M:init(title, actor, filter, action) self.c_desc = TextzoneList.new{width=self.iw - 20 - self.c_doll.w, height=self.ih, no_color_bleed=true} self:loadUI{ - {left=0, top=0, ui=self.c_doll}, + {left=0, top=0, ui=self.c_main_set}, + {left=self.c_main_set, top=0, ui=self.c_off_set}, + {left=0, top=self.c_main_set, ui=self.c_doll}, {right=0, top=0, ui=self.c_desc}, {left=self.c_doll.w, top=5, ui=Separator.new{dir="horizontal", size=self.ih - 10}}, } @@ -62,6 +68,16 @@ function _M:init(title, actor, filter, action) } end +function _M:switchSets(which) + if which == "main" and not self.actor.off_weapon_slots then return end + if which == "off" and self.actor.off_weapon_slots then return end + + self.actor:quickSwitchWeapons() + + self.c_main_set.selected = not self.actor.off_weapon_slots + self.c_off_set.selected = self.actor.off_weapon_slots +end + function _M:on_register() game:onTickEnd(function() self.key:unicodeInput(true) end) end