1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-18 02:16:23 -05:00

removed unused fields from d2player.GameControl.actionableRegions (#997)

Co-authored-by: M. Sz <mszeptuch@protonmail.com>
Co-authored-by: gravestench <dknuth0101@gmail.com>
This commit is contained in:
gucio321 2021-01-07 06:51:36 +01:00 committed by GitHub
parent 6addf7a243
commit 0e95fd44ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 67 deletions

View File

@ -37,11 +37,8 @@ const mouseBtnActionsThreshold = 0.25
const ( const (
// Since they require special handling, not considering (1) globes, (2) content of the mini panel, (3) belt // Since they require special handling, not considering (1) globes, (2) content of the mini panel, (3) belt
leftSkill actionableType = iota leftSkill actionableType = iota
newStats
xp xp
walkRun
stamina stamina
newSkills
rightSkill rightSkill
hpGlobe hpGlobe
manaGlobe manaGlobe
@ -53,31 +50,16 @@ const (
leftSkillWidth, leftSkillWidth,
leftSkillHeight = 117, 550, 50, 50 leftSkillHeight = 117, 550, 50, 50
newStatsX,
newStatsY,
newStatsWidth,
newStatsHeight = 206, 563, 30, 30
xpX, xpX,
xpY, xpY,
xpWidth, xpWidth,
xpHeight = 253, 560, 125, 5 xpHeight = 253, 560, 125, 5
walkRunX,
walkRunY,
walkRunWidth,
walkRunHeight = 255, 573, 17, 20
staminaX, staminaX,
staminaY, staminaY,
staminaWidth, staminaWidth,
staminaHeight = 273, 573, 105, 20 staminaHeight = 273, 573, 105, 20
newSkillsX,
newSkillsY,
newSkillsWidth,
newSkillsHeight = 562, 563, 30, 30
rightSkillX, rightSkillX,
rightSkillY, rightSkillY,
rightSkillWidth, rightSkillWidth,
@ -156,36 +138,18 @@ func NewGameControls(
Width: leftSkillWidth, Width: leftSkillWidth,
Height: leftSkillHeight, Height: leftSkillHeight,
}}, }},
{newStats, d2geom.Rectangle{
Left: newStatsX,
Top: newStatsY,
Width: newStatsWidth,
Height: newStatsHeight,
}},
{xp, d2geom.Rectangle{ {xp, d2geom.Rectangle{
Left: xpX, Left: xpX,
Top: xpY, Top: xpY,
Width: xpWidth, Width: xpWidth,
Height: xpHeight, Height: xpHeight,
}}, }},
{walkRun, d2geom.Rectangle{
Left: walkRunX,
Top: walkRunY,
Width: walkRunWidth,
Height: walkRunHeight,
}},
{stamina, d2geom.Rectangle{ {stamina, d2geom.Rectangle{
Left: staminaX, Left: staminaX,
Top: staminaY, Top: staminaY,
Width: staminaWidth, Width: staminaWidth,
Height: staminaHeight, Height: staminaHeight,
}}, }},
{newSkills, d2geom.Rectangle{
Left: newSkillsX,
Top: newSkillsY,
Width: newSkillsWidth,
Height: newSkillsHeight,
}},
{rightSkill, d2geom.Rectangle{ {rightSkill, d2geom.Rectangle{
Left: rightSkillX, Left: rightSkillX,
Top: rightSkillY, Top: rightSkillY,
@ -857,11 +821,8 @@ func (g *GameControls) ToggleManaStats() {
func (g *GameControls) onHoverActionable(item actionableType) { func (g *GameControls) onHoverActionable(item actionableType) {
hoverMap := map[actionableType]func(){ hoverMap := map[actionableType]func(){
leftSkill: func() {}, leftSkill: func() {},
newStats: func() {},
xp: func() {}, xp: func() {},
walkRun: func() {},
stamina: func() {}, stamina: func() {},
newSkills: func() {},
rightSkill: func() {}, rightSkill: func() {},
hpGlobe: func() {}, hpGlobe: func() {},
manaGlobe: func() {}, manaGlobe: func() {},
@ -883,26 +844,14 @@ func (g *GameControls) onClickActionable(item actionableType) {
g.toggleLeftSkillPanel() g.toggleLeftSkillPanel()
}, },
newStats: func() {
g.Info("New Stats Selector Action Pressed")
},
xp: func() { xp: func() {
g.Info("XP Action Pressed") g.Info("XP Action Pressed")
}, },
walkRun: func() {
g.Info("Walk/Run Action Pressed")
},
stamina: func() { stamina: func() {
g.Info("Stamina Action Pressed") g.Info("Stamina Action Pressed")
}, },
newSkills: func() {
g.Info("New Skills Selector Action Pressed")
},
rightSkill: func() { rightSkill: func() {
g.toggleRightSkillPanel() g.toggleRightSkillPanel()
}, },

View File

@ -312,21 +312,6 @@ func (h *HUD) loadTooltips() {
labelY := staminaExperienceY - halfLabelHeight labelY := staminaExperienceY - halfLabelHeight
h.staminaTooltip.SetPosition(labelX, labelY) h.staminaTooltip.SetPosition(labelX, labelY)
// runwalk tooltip
h.runWalkTooltip = h.uiManager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, d2ui.TooltipXCenter, d2ui.TooltipYBottom)
rect = &h.actionableRegions[walkRun].rect
halfButtonWidth = rect.Width >> 1
halfButtonHeight := rect.Height >> 1
centerX = rect.Left + halfButtonWidth
centerY := rect.Top + halfButtonHeight
_, labelHeight = h.runWalkTooltip.GetSize()
labelX = centerX
labelY = centerY - halfButtonHeight - labelHeight
h.runWalkTooltip.SetPosition(labelX, labelY)
// experience tooltip // experience tooltip
h.experienceTooltip = h.uiManager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, d2ui.TooltipXCenter, d2ui.TooltipYTop) h.experienceTooltip = h.uiManager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, d2ui.TooltipXCenter, d2ui.TooltipYTop)
rect = &h.actionableRegions[stamina].rect rect = &h.actionableRegions[stamina].rect
@ -347,8 +332,21 @@ func (h *HUD) loadUIButtons() {
h.runButton = h.uiManager.NewButton(d2ui.ButtonTypeRun, "") h.runButton = h.uiManager.NewButton(d2ui.ButtonTypeRun, "")
h.runButton.SetPosition(runButtonX, runButtonY) h.runButton.SetPosition(runButtonX, runButtonY)
h.runButton.OnActivated(func() { h.onToggleRunButton(false) }) h.runButton.OnActivated(func() { h.onToggleRunButton(false) })
h.runButton.SetTooltip(h.runWalkTooltip)
h.runWalkTooltip = h.uiManager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, d2ui.TooltipXCenter, d2ui.TooltipYTop)
// we must set text first, and then we're getting its height
h.updateRunTooltipText() h.updateRunTooltipText()
bw, bh := h.runButton.GetSize()
_, lh := h.runWalkTooltip.GetSize()
// nolint:gomnd // dividing by 2 (const)
labelX := runButtonX + bw/2
// nolint:gomnd // dividing by 2 (const)
labelY := runButtonY - bh/2 - lh/2
h.runWalkTooltip.SetPosition(labelX, labelY)
h.runButton.SetTooltip(h.runWalkTooltip)
h.panelGroup.AddWidget(h.runButton) h.panelGroup.AddWidget(h.runButton)
if h.hero.IsRunToggled() { if h.hero.IsRunToggled() {