From f4d78549c585de8e63e61f8e99e94eef79469e8e Mon Sep 17 00:00:00 2001 From: Brendan Porter Date: Sun, 20 Sep 2020 01:54:24 -0500 Subject: [PATCH] Helpv3 (#739) * finishing up help overlay * fixes help overlay close button, adds hack to prevent buysellbtn from rendering all 24 unrelated frames on top of eachother --- d2common/d2resource/resource_paths.go | 2 +- d2core/d2ui/button.go | 35 +++++++++++++++++---------- d2game/d2player/help/help.go | 12 +-------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/d2common/d2resource/resource_paths.go b/d2common/d2resource/resource_paths.go index 3c241a83..baf9f676 100644 --- a/d2common/d2resource/resource_paths.go +++ b/d2common/d2resource/resource_paths.go @@ -168,7 +168,7 @@ const ( RunButton = "/data/global/ui/PANEL/runbutton.dc6" MenuButton = "/data/global/ui/PANEL/menubutton.DC6" GoldCoinButton = "/data/global/ui/panel/goldcoinbtn.dc6" - SquareButton = "/data/global/ui/panel/buysellbtn.dc6" + BuySellButton = "/data/global/ui/panel/buysellbtn.dc6" ArmorPlaceholder = "/data/global/ui/PANEL/inv_armor.DC6" BeltPlaceholder = "/data/global/ui/PANEL/inv_belt.DC6" diff --git a/d2core/d2ui/button.go b/d2core/d2ui/button.go index 6b80f2af..4aeb350e 100644 --- a/d2core/d2ui/button.go +++ b/d2core/d2ui/button.go @@ -39,11 +39,12 @@ const ( ButtonTypeMinipanelMessage ButtonType = 17 ButtonTypeMinipanelQuest ButtonType = 18 ButtonTypeMinipanelMen ButtonType = 19 + ButtonTypeSquareClose ButtonType = 20 ) const ( - greyAlpha100 = 0x646464_ff - lightGreyAlpha75 = 0x808080_c3 + greyAlpha100 = 0x646464ff + lightGreyAlpha75 = 0x808080c3 ) // ButtonLayout defines the type of buttons @@ -83,9 +84,9 @@ const ( buttonOkCancelSegmentsY = 1 buttonOkCancelDisabledFrame = -1 - buttonCloseSegmentsX = 1 - buttonCloseSegmentsY = 1 - buttonCloseDisabledFrame = -1 + buttonBuySellSegmentsX = 1 + buttonBuySellSegmentsY = 1 + buttonBuySellDisabledFrame = 1 buttonRunSegmentsX = 1 buttonRunSegmentsY = 1 @@ -152,15 +153,16 @@ func getButtonLayouts() map[ButtonType]ButtonLayout { FontPath: d2resource.FontRediculous, AllowFrameChange: true, }, - ButtonTypeClose: { - XSegments: buttonCloseSegmentsX, - YSegments: buttonCloseSegmentsY, - DisabledFrame: buttonCloseDisabledFrame, - ResourceName: d2resource.SquareButton, - PaletteName: d2resource.PaletteUnits, - Toggleable: true, - FontPath: d2resource.Font30, + ButtonTypeSquareClose: { + XSegments: buttonBuySellSegmentsX, + YSegments: buttonBuySellSegmentsY, + DisabledFrame: buttonBuySellDisabledFrame, + ResourceName: d2resource.BuySellButton, + PaletteName: d2resource.PaletteUnits, + Toggleable: true, + FontPath: d2resource.Font30, AllowFrameChange: true, + BaseFrame: 10, }, } } @@ -266,6 +268,13 @@ func (v *Button) renderFrames(btnSprite *Sprite, btnLayout *ButtonLayout, label label.Render(v.pressedSurface) } + if btnLayout.ResourceName == d2resource.BuySellButton { + // Without returning early, the button UI gets all subsequent (unrelated) frames stacked on top + // Only 2 frames from this sprite are applicable to the button in question + // The presentation is incorrect without this hack + return + } + totalButtonTypes-- if totalButtonTypes > 0 { // button has more than two types frameOffset++ diff --git a/d2game/d2player/help/help.go b/d2game/d2player/help/help.go index 94f9bdd9..50d3b5f1 100644 --- a/d2game/d2player/help/help.go +++ b/d2game/d2player/help/help.go @@ -158,12 +158,7 @@ func (h *Overlay) Load() { // Close - //close, _ := h.uiManager.NewSprite(d2resource.SquareButton, d2resource.PaletteSky) - //_ = close.SetCurrentFrame(0) - //close.SetPosition(685, 57) - //h.frames = append(h.frames, close) - - h.closeButton = h.uiManager.NewButton(d2ui.ButtonTypeClose, "0") + h.closeButton = h.uiManager.NewButton(d2ui.ButtonTypeSquareClose, "") h.closeButton.SetPosition(685, 25) h.closeButton.SetVisible(false) h.closeButton.OnActivated(func() { h.close() }) @@ -173,11 +168,6 @@ func (h *Overlay) Load() { newLabel.SetPosition(680, 60) h.text = append(h.text, newLabel) - newLabel = h.uiManager.NewLabel(d2resource.Font30, d2resource.PaletteSky) - newLabel.SetText("0") - newLabel.SetPosition(695, 32) - h.text = append(h.text, newLabel) - // Bullets yOffset := 60