mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-11 02:58:10 -05:00
Linter error fixes
Fixed inventory display bugs - Tooltip doesn't hide when was visible and inventory window was closed using keyboard
This commit is contained in:
parent
ac572e3bf5
commit
220f0febaa
@ -207,6 +207,7 @@ func (g *Inventory) Close() {
|
|||||||
g.isOpen = false
|
g.isOpen = false
|
||||||
g.moveGoldPanel.Close()
|
g.moveGoldPanel.Close()
|
||||||
g.panelGroup.SetVisible(false)
|
g.panelGroup.SetVisible(false)
|
||||||
|
g.itemTooltip.SetVisible(false)
|
||||||
g.onCloseCb()
|
g.onCloseCb()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,26 +289,25 @@ func (g *Inventory) renderFrame(target d2interface.Surface) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Inventory) showItemDescriptionTooltip() {
|
func (g *Inventory) showItemDescriptionTooltip() {
|
||||||
hovering := false
|
hoveringNow := g.checkEquippedSlotsHover()
|
||||||
|
|
||||||
for _, slot := range g.grid.equipmentSlots {
|
if hoveringNow {
|
||||||
mx, my := g.lastMouseX, g.lastMouseY
|
g.hovering = true
|
||||||
hovering = hovering || ((mx > slot.x) && (mx < slot.x+slot.width) && (my < slot.y) && (my > slot.y-slot.height))
|
|
||||||
if hovering {
|
|
||||||
if !g.hovering {
|
|
||||||
g.hoverX, g.hoverY = mx, my
|
|
||||||
}
|
|
||||||
g.showEquippedItemDescriptionTooltip(&slot)
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g.hovering = hovering
|
|
||||||
if hovering {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hoveringNow = g.checkGridSlotsHover()
|
||||||
|
|
||||||
|
if !hoveringNow {
|
||||||
|
g.itemTooltip.SetVisible(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
g.hovering = hoveringNow
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Inventory) checkGridSlotsHover() bool {
|
||||||
|
hovering := false
|
||||||
|
|
||||||
for idx := range g.grid.items {
|
for idx := range g.grid.items {
|
||||||
item := g.grid.items[idx]
|
item := g.grid.items[idx]
|
||||||
ix, iy := g.grid.SlotToScreen(item.InventoryGridSlot())
|
ix, iy := g.grid.SlotToScreen(item.InventoryGridSlot())
|
||||||
@ -328,10 +328,28 @@ func (g *Inventory) showItemDescriptionTooltip() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g.hovering = hovering
|
return hovering
|
||||||
if !g.hovering {
|
}
|
||||||
g.itemTooltip.SetVisible(false)
|
|
||||||
|
func (g *Inventory) checkEquippedSlotsHover() bool {
|
||||||
|
hovering := false
|
||||||
|
|
||||||
|
for _, slot := range g.grid.equipmentSlots {
|
||||||
|
mx, my := g.lastMouseX, g.lastMouseY
|
||||||
|
|
||||||
|
hovering = hovering || ((mx > slot.x) && (mx < slot.x+slot.width) && (my < slot.y) && (my > slot.y-slot.height))
|
||||||
|
if hovering {
|
||||||
|
if !g.hovering {
|
||||||
|
g.hoverX, g.hoverY = mx, my
|
||||||
|
}
|
||||||
|
|
||||||
|
g.showEquippedItemDescriptionTooltip(slot)
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return hovering
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Inventory) showGridItemDescriptionTooltip(i InventoryItem) {
|
func (g *Inventory) showGridItemDescriptionTooltip(i InventoryItem) {
|
||||||
@ -345,7 +363,7 @@ func (g *Inventory) showGridItemDescriptionTooltip(i InventoryItem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Inventory) showEquippedItemDescriptionTooltip(slot *EquipmentSlot) {
|
func (g *Inventory) showEquippedItemDescriptionTooltip(slot EquipmentSlot) {
|
||||||
if !g.moveGoldPanel.IsOpen() {
|
if !g.moveGoldPanel.IsOpen() {
|
||||||
lines := slot.item.GetItemDescription()
|
lines := slot.item.GetItemDescription()
|
||||||
g.itemTooltip.SetTextLines(lines)
|
g.itemTooltip.SetTextLines(lines)
|
||||||
|
Loading…
Reference in New Issue
Block a user