mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-29 22:56:07 -04:00
Renamed EquippedSlot enum (#563)
This commit is contained in:
parent
1ad3c72211
commit
a10a53be26
18
d2common/d2enum/equipped_slot.go
Normal file
18
d2common/d2enum/equipped_slot.go
Normal file
@ -0,0 +1,18 @@
|
||||
package d2enum
|
||||
|
||||
// EquippedSlot represents the type of equipment slot
|
||||
type EquippedSlot int
|
||||
|
||||
// Equipped slot ID's
|
||||
const (
|
||||
EquippedSlotHead EquippedSlot = iota + 1
|
||||
EquippedSlotTorso
|
||||
EquippedSlotLegs
|
||||
EquippedSlotRightArm
|
||||
EquippedSlotLeftArm
|
||||
EquippedSlotLeftHand
|
||||
EquippedSlotRightHand
|
||||
EquippedSlotNeck
|
||||
EquippedSlotBelt
|
||||
EquippedSlotGloves
|
||||
)
|
@ -1,17 +0,0 @@
|
||||
package d2enum
|
||||
|
||||
// EquippedTypeSlot represents the type of equipment slot
|
||||
type EquippedSlotType int
|
||||
|
||||
const (
|
||||
Head EquippedSlotType = iota + 1
|
||||
Torso EquippedSlotType = 2
|
||||
Legs EquippedSlotType = 3
|
||||
RightArm EquippedSlotType = 4
|
||||
LeftArm EquippedSlotType = 5
|
||||
LeftHand EquippedSlotType = 6
|
||||
RightHand EquippedSlotType = 7
|
||||
Neck EquippedSlotType = 8
|
||||
Belt EquippedSlotType = 9
|
||||
Gloves EquippedSlotType = 10
|
||||
)
|
@ -12,72 +12,72 @@ type EquipmentSlot struct {
|
||||
}
|
||||
|
||||
//nolint:gomnd Magic numbers are necessary for this file
|
||||
func genEquipmentSlotsMap() map[d2enum.EquippedSlotType]EquipmentSlot {
|
||||
return map[d2enum.EquippedSlotType]EquipmentSlot{
|
||||
d2enum.LeftArm: {
|
||||
func genEquipmentSlotsMap() map[d2enum.EquippedSlot]EquipmentSlot {
|
||||
return map[d2enum.EquippedSlot]EquipmentSlot{
|
||||
d2enum.EquippedSlotLeftArm: {
|
||||
item: nil,
|
||||
x: 418,
|
||||
y: 224,
|
||||
width: 61,
|
||||
height: 116,
|
||||
},
|
||||
d2enum.RightArm: {
|
||||
d2enum.EquippedSlotRightArm: {
|
||||
item: nil,
|
||||
x: 648,
|
||||
y: 224,
|
||||
width: 61,
|
||||
height: 116,
|
||||
},
|
||||
d2enum.Head: {
|
||||
d2enum.EquippedSlotHead: {
|
||||
item: nil,
|
||||
x: 532,
|
||||
y: 125,
|
||||
width: 62,
|
||||
height: 62,
|
||||
},
|
||||
d2enum.Neck: {
|
||||
d2enum.EquippedSlotNeck: {
|
||||
item: nil,
|
||||
x: 604,
|
||||
y: 125,
|
||||
width: 32,
|
||||
height: 32,
|
||||
},
|
||||
d2enum.Torso: {
|
||||
d2enum.EquippedSlotTorso: {
|
||||
item: nil,
|
||||
x: 532,
|
||||
y: 224,
|
||||
width: 62,
|
||||
height: 90,
|
||||
},
|
||||
d2enum.Belt: {
|
||||
d2enum.EquippedSlotBelt: {
|
||||
item: nil,
|
||||
x: 533,
|
||||
y: 269,
|
||||
width: 62,
|
||||
height: 32,
|
||||
},
|
||||
d2enum.LeftHand: {
|
||||
d2enum.EquippedSlotLeftHand: {
|
||||
item: nil,
|
||||
x: 491,
|
||||
y: 270,
|
||||
width: 32,
|
||||
height: 32,
|
||||
},
|
||||
d2enum.RightHand: {
|
||||
d2enum.EquippedSlotRightHand: {
|
||||
item: nil,
|
||||
x: 606,
|
||||
y: 270,
|
||||
width: 32,
|
||||
height: 32,
|
||||
},
|
||||
d2enum.Gloves: {
|
||||
d2enum.EquippedSlotGloves: {
|
||||
item: nil,
|
||||
x: 417,
|
||||
y: 299,
|
||||
width: 62,
|
||||
height: 62,
|
||||
},
|
||||
d2enum.Legs: {
|
||||
d2enum.EquippedSlotLegs: {
|
||||
item: nil,
|
||||
x: 648,
|
||||
y: 299,
|
||||
|
@ -58,16 +58,16 @@ func (g *Inventory) Load() {
|
||||
d2inventory.GetWeaponItemByCode("clb"),
|
||||
// TODO: Load the player's actual items
|
||||
}
|
||||
g.grid.ChangeEquippedSlot(d2enum.LeftArm, d2inventory.GetWeaponItemByCode("wnd"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.RightArm, d2inventory.GetArmorItemByCode("buc"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.Head, d2inventory.GetArmorItemByCode("crn"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.Torso, d2inventory.GetArmorItemByCode("plt"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.Legs, d2inventory.GetArmorItemByCode("vbt"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.Belt, d2inventory.GetArmorItemByCode("vbl"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.Gloves, d2inventory.GetArmorItemByCode("lgl"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.LeftHand, d2inventory.GetMiscItemByCode("rin"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.RightHand, d2inventory.GetMiscItemByCode("rin"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.Neck, d2inventory.GetMiscItemByCode("amu"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotLeftArm, d2inventory.GetWeaponItemByCode("wnd"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotRightArm, d2inventory.GetArmorItemByCode("buc"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotHead, d2inventory.GetArmorItemByCode("crn"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotTorso, d2inventory.GetArmorItemByCode("plt"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotLegs, d2inventory.GetArmorItemByCode("vbt"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotBelt, d2inventory.GetArmorItemByCode("vbl"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotGloves, d2inventory.GetArmorItemByCode("lgl"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotLeftHand, d2inventory.GetMiscItemByCode("rin"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotRightHand, d2inventory.GetMiscItemByCode("rin"))
|
||||
g.grid.ChangeEquippedSlot(d2enum.EquippedSlotNeck, d2inventory.GetMiscItemByCode("amu"))
|
||||
// TODO: Load the player's actual items
|
||||
g.grid.Add(items...)
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ var ErrorInventoryFull = errors.New("inventory full")
|
||||
// Handles layout and rendering item icons based on code.
|
||||
type ItemGrid struct {
|
||||
items []InventoryItem
|
||||
equipmentSlots map[d2enum.EquippedSlotType]EquipmentSlot
|
||||
equipmentSlots map[d2enum.EquippedSlot]EquipmentSlot
|
||||
width int
|
||||
height int
|
||||
originX int
|
||||
@ -73,7 +73,7 @@ func (g *ItemGrid) GetSlot(x int, y int) InventoryItem {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *ItemGrid) ChangeEquippedSlot(slot d2enum.EquippedSlotType, item InventoryItem) {
|
||||
func (g *ItemGrid) ChangeEquippedSlot(slot d2enum.EquippedSlot, item InventoryItem) {
|
||||
var curItem = g.equipmentSlots[slot]
|
||||
curItem.item = item
|
||||
g.equipmentSlots[slot] = curItem
|
||||
|
Loading…
Reference in New Issue
Block a user