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

Equipment window now has a switch to select main/off weapons set

git-svn-id: http://svn.net-core.org/repos/t-engine4@4853 51575b47-30f0-44d4-a5cc-537603b46e54
parent c127cee3
No related branches found
No related tags found
No related merge requests found
......@@ -972,6 +972,7 @@ function _M:quickSwitchWeapons()
local mh1, mh2 = self.inven[self.INVEN_MAINHAND], self.inven[self.INVEN_QS_MAINHAND]
local oh1, oh2 = self.inven[self.INVEN_OFFHAND], self.inven[self.INVEN_QS_OFFHAND]
local pf1, pf2 = self.inven[self.INVEN_PSIONIC_FOCUS], self.inven[self.INVEN_QS_PSIONIC_FOCUS]
local qv1, qv2 = self.inven[self.INVEN_QUIVER], self.inven[self.INVEN_QS_QUIVER]
if not mh1 or not mh2 or not oh1 or not oh2 then return end
......@@ -981,6 +982,7 @@ function _M:quickSwitchWeapons()
local mhset1, mhset2 = {}, {}
local ohset1, ohset2 = {}, {}
local pfset1, pfset2 = {}, {}
local qvset1, qvset2 = {}, {}
-- Remove them all
for i = #mh1, 1, -1 do mhset1[#mhset1+1] = self:removeObject(mh1, i, true) end
for i = #mh2, 1, -1 do mhset2[#mhset2+1] = self:removeObject(mh2, i, true) end
......@@ -990,6 +992,10 @@ function _M:quickSwitchWeapons()
for i = #pf1, 1, -1 do pfset1[#pfset1+1] = self:removeObject(pf1, i, true) end
for i = #pf2, 1, -1 do pfset2[#pfset2+1] = self:removeObject(pf2, i, true) end
end
if qv1 and qv2 then
for i = #qv1, 1, -1 do qvset1[#qvset1+1] = self:removeObject(qv1, i, true) end
for i = #qv2, 1, -1 do qvset2[#qvset2+1] = self:removeObject(qv2, i, true) end
end
-- Put them all back
for i = 1, #mhset1 do self:addObject(mh2, mhset1[i]) end
for i = 1, #mhset2 do self:addObject(mh1, mhset2[i]) end
......@@ -999,6 +1005,10 @@ function _M:quickSwitchWeapons()
for i = 1, #pfset1 do self:addObject(pf2, pfset1[i]) end
for i = 1, #pfset2 do self:addObject(pf1, pfset2[i]) end
end
if qv1 and qv2 then
for i = 1, #qvset1 do self:addObject(qv2, qvset1[i]) end
for i = 1, #qvset2 do self:addObject(qv1, qvset2[i]) end
end
if not self:knowTalent(self.T_CELERITY) then self:useEnergy() end
local names = ""
if pf1 and pf2 then
......@@ -1025,6 +1035,7 @@ function _M:quickSwitchWeapons()
self:playerCheckSustains()
game.logPlayer(self, "You switch your weapons to: %s.", names)
self.off_weapon_slots = not self.off_weapon_slots
self.changed = true
end
......
......@@ -173,7 +173,7 @@ newBirthDescriptor{
resolvers.inventory{ id=true, inven="QS_MAINHAND",
{type="weapon", subtype="sling", name="rough leather sling", autoreq=true, ego_chance=-1000},
},
resolvers.inventory{ id=true,
resolvers.inventory{ id=true, inven="QS_QUIVER",
{type="ammo", subtype="shot", name="pouch of iron shot", autoreq=true, ego_chance=-1000},
},
resolvers.generic(function(e)
......
......@@ -60,7 +60,7 @@ newBirthDescriptor{
},
talents = {},
experience = 1.0,
body = { INVEN = 1000, QS_MAINHAND = 1, QS_OFFHAND = 1, MAINHAND = 1, OFFHAND = 1, FINGER = 2, NECK = 1, LITE = 1, BODY = 1, HEAD = 1, CLOAK = 1, HANDS = 1, BELT = 1, FEET = 1, TOOL = 1, QUIVER = 1 },
body = { INVEN = 1000, QS_MAINHAND = 1, QS_OFFHAND = 1, MAINHAND = 1, OFFHAND = 1, FINGER = 2, NECK = 1, LITE = 1, BODY = 1, HEAD = 1, CLOAK = 1, HANDS = 1, BELT = 1, FEET = 1, TOOL = 1, QUIVER = 1, QS_QUIVER = 1 },
copy = {
-- Some basic stuff
......
......@@ -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
......@@ -62,7 +66,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}},
}
......@@ -84,7 +90,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()
......
......@@ -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
......
......@@ -158,6 +158,7 @@ ActorInventory:defineInventory("GEM", "Socketed Gems", true, "Socketed gems.", n
ActorInventory:defineInventory("QS_MAINHAND", "Second weapon set: In main hand", false, "Weapon Set 2: Most weapons are wielded in the main hand. Press 'x' to switch weapon sets.", true)
ActorInventory:defineInventory("QS_OFFHAND", "Second weapon set: In off hand", false, "Weapon Set 2: You can use shields or a second weapon in your off-hand, if you have the talents for it. Press 'x' to switch weapon sets.", true)
ActorInventory:defineInventory("QS_PSIONIC_FOCUS", "Second weapon set: psionic focus", false, "Weapon Set 2: Object held in your telekinetic grasp. It can be a weapon or some other item to provide a benefit to your psionic powers. Press 'x' to switch weapon sets.", true)
ActorInventory:defineInventory("QS_QUIVER", "Second weapon set: Quiver", true, "Weapon Set 2: Your readied ammo.", true)
ActorInventory.equipdolls = {
default = { w=48, h=48, itemframe="ui/equipdoll/itemframe48.png", itemframe_sel="ui/equipdoll/itemframe-sel48.png", ix=3, iy=3, iw=42, ih=42, doll_x=116, doll_y=168+64, list={
PSIONIC_FOCUS = {{weight=1, x=48, y=48}},
......
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