1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-15 20:15:24 +00:00

Renamed EquippedSlot enum (#563)

This commit is contained in:
Intyre 2020-07-09 01:08:07 +02:00 committed by GitHub
parent 1ad3c72211
commit a10a53be26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 41 deletions

View 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
)

View File

@ -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
)

View File

@ -12,72 +12,72 @@ type EquipmentSlot struct {
} }
//nolint:gomnd Magic numbers are necessary for this file //nolint:gomnd Magic numbers are necessary for this file
func genEquipmentSlotsMap() map[d2enum.EquippedSlotType]EquipmentSlot { func genEquipmentSlotsMap() map[d2enum.EquippedSlot]EquipmentSlot {
return map[d2enum.EquippedSlotType]EquipmentSlot{ return map[d2enum.EquippedSlot]EquipmentSlot{
d2enum.LeftArm: { d2enum.EquippedSlotLeftArm: {
item: nil, item: nil,
x: 418, x: 418,
y: 224, y: 224,
width: 61, width: 61,
height: 116, height: 116,
}, },
d2enum.RightArm: { d2enum.EquippedSlotRightArm: {
item: nil, item: nil,
x: 648, x: 648,
y: 224, y: 224,
width: 61, width: 61,
height: 116, height: 116,
}, },
d2enum.Head: { d2enum.EquippedSlotHead: {
item: nil, item: nil,
x: 532, x: 532,
y: 125, y: 125,
width: 62, width: 62,
height: 62, height: 62,
}, },
d2enum.Neck: { d2enum.EquippedSlotNeck: {
item: nil, item: nil,
x: 604, x: 604,
y: 125, y: 125,
width: 32, width: 32,
height: 32, height: 32,
}, },
d2enum.Torso: { d2enum.EquippedSlotTorso: {
item: nil, item: nil,
x: 532, x: 532,
y: 224, y: 224,
width: 62, width: 62,
height: 90, height: 90,
}, },
d2enum.Belt: { d2enum.EquippedSlotBelt: {
item: nil, item: nil,
x: 533, x: 533,
y: 269, y: 269,
width: 62, width: 62,
height: 32, height: 32,
}, },
d2enum.LeftHand: { d2enum.EquippedSlotLeftHand: {
item: nil, item: nil,
x: 491, x: 491,
y: 270, y: 270,
width: 32, width: 32,
height: 32, height: 32,
}, },
d2enum.RightHand: { d2enum.EquippedSlotRightHand: {
item: nil, item: nil,
x: 606, x: 606,
y: 270, y: 270,
width: 32, width: 32,
height: 32, height: 32,
}, },
d2enum.Gloves: { d2enum.EquippedSlotGloves: {
item: nil, item: nil,
x: 417, x: 417,
y: 299, y: 299,
width: 62, width: 62,
height: 62, height: 62,
}, },
d2enum.Legs: { d2enum.EquippedSlotLegs: {
item: nil, item: nil,
x: 648, x: 648,
y: 299, y: 299,

View File

@ -58,16 +58,16 @@ func (g *Inventory) Load() {
d2inventory.GetWeaponItemByCode("clb"), d2inventory.GetWeaponItemByCode("clb"),
// TODO: Load the player's actual items // TODO: Load the player's actual items
} }
g.grid.ChangeEquippedSlot(d2enum.LeftArm, d2inventory.GetWeaponItemByCode("wnd")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotLeftArm, d2inventory.GetWeaponItemByCode("wnd"))
g.grid.ChangeEquippedSlot(d2enum.RightArm, d2inventory.GetArmorItemByCode("buc")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotRightArm, d2inventory.GetArmorItemByCode("buc"))
g.grid.ChangeEquippedSlot(d2enum.Head, d2inventory.GetArmorItemByCode("crn")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotHead, d2inventory.GetArmorItemByCode("crn"))
g.grid.ChangeEquippedSlot(d2enum.Torso, d2inventory.GetArmorItemByCode("plt")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotTorso, d2inventory.GetArmorItemByCode("plt"))
g.grid.ChangeEquippedSlot(d2enum.Legs, d2inventory.GetArmorItemByCode("vbt")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotLegs, d2inventory.GetArmorItemByCode("vbt"))
g.grid.ChangeEquippedSlot(d2enum.Belt, d2inventory.GetArmorItemByCode("vbl")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotBelt, d2inventory.GetArmorItemByCode("vbl"))
g.grid.ChangeEquippedSlot(d2enum.Gloves, d2inventory.GetArmorItemByCode("lgl")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotGloves, d2inventory.GetArmorItemByCode("lgl"))
g.grid.ChangeEquippedSlot(d2enum.LeftHand, d2inventory.GetMiscItemByCode("rin")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotLeftHand, d2inventory.GetMiscItemByCode("rin"))
g.grid.ChangeEquippedSlot(d2enum.RightHand, d2inventory.GetMiscItemByCode("rin")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotRightHand, d2inventory.GetMiscItemByCode("rin"))
g.grid.ChangeEquippedSlot(d2enum.Neck, d2inventory.GetMiscItemByCode("amu")) g.grid.ChangeEquippedSlot(d2enum.EquippedSlotNeck, d2inventory.GetMiscItemByCode("amu"))
// TODO: Load the player's actual items // TODO: Load the player's actual items
g.grid.Add(items...) g.grid.Add(items...)
} }

View File

@ -27,7 +27,7 @@ var ErrorInventoryFull = errors.New("inventory full")
// Handles layout and rendering item icons based on code. // Handles layout and rendering item icons based on code.
type ItemGrid struct { type ItemGrid struct {
items []InventoryItem items []InventoryItem
equipmentSlots map[d2enum.EquippedSlotType]EquipmentSlot equipmentSlots map[d2enum.EquippedSlot]EquipmentSlot
width int width int
height int height int
originX int originX int
@ -73,7 +73,7 @@ func (g *ItemGrid) GetSlot(x int, y int) InventoryItem {
return nil 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] var curItem = g.equipmentSlots[slot]
curItem.item = item curItem.item = item
g.equipmentSlots[slot] = curItem g.equipmentSlots[slot] = curItem