From c148941194820c128eb7c3af1c49e71f8f16a03d Mon Sep 17 00:00:00 2001 From: juander Date: Wed, 11 Nov 2020 14:55:59 +0100 Subject: [PATCH 1/3] d2ui/drawable: Refactor render() method to not return error this simplifies error handling statements all over the ui code. Before we had to write: if err := foo.Render(target); err != nil { return err } which simplifies now to foo.Render(target) --- d2core/d2ui/button.go | 15 +--- d2core/d2ui/checkbox.go | 16 +--- d2core/d2ui/custom_widget.go | 8 +- d2core/d2ui/drawable.go | 2 +- d2core/d2ui/frame.go | 12 +-- d2core/d2ui/label.go | 3 +- d2core/d2ui/scrollbar.go | 20 ++--- d2core/d2ui/sprite.go | 9 +-- d2core/d2ui/textbox.go | 6 +- d2core/d2ui/tooltip.go | 4 +- d2core/d2ui/ui_manager.go | 10 +-- d2core/d2ui/widget_group.go | 9 +-- d2game/d2gamescreen/character_select.go | 15 +--- d2game/d2gamescreen/cinematics.go | 20 +---- d2game/d2gamescreen/credits.go | 5 +- d2game/d2gamescreen/main_menu.go | 21 ++---- d2game/d2gamescreen/select_hero_class.go | 5 +- d2game/d2player/hero_stats_panel.go | 4 +- d2game/d2player/hud.go | 30 ++------ d2game/d2player/inventory.go | 10 +-- d2game/d2player/skill_select_panel.go | 4 +- d2game/d2player/skillicon.go | 29 +++----- d2game/d2player/skilltree.go | 94 +++++++----------------- 23 files changed, 96 insertions(+), 255 deletions(-) diff --git a/d2core/d2ui/button.go b/d2core/d2ui/button.go index 3cd8c371..e7d98fe7 100644 --- a/d2core/d2ui/button.go +++ b/d2core/d2ui/button.go @@ -1,7 +1,6 @@ package d2ui import ( - "fmt" "image" "log" @@ -332,11 +331,8 @@ func (v *Button) prerenderStates(btnSprite *Sprite, btnLayout *ButtonLayout, lab // buttons always have a base image if v.buttonLayout.HasImage { - err := btnSprite.RenderSegmented(v.normalSurface, btnLayout.XSegments, + btnSprite.RenderSegmented(v.normalSurface, btnLayout.XSegments, btnLayout.YSegments, btnLayout.BaseFrame) - if err != nil { - fmt.Printf("failed to render button normalSurface, err: %v\n", err) - } } _, labelHeight := label.GetSize() @@ -412,10 +408,7 @@ func (v *Button) prerenderStates(btnSprite *Sprite, btnLayout *ButtonLayout, lab *state.prerenderdestination = surface - err := btnSprite.RenderSegmented(*state.prerenderdestination, xSeg, ySeg, state.baseFrame) - if err != nil { - fmt.Printf(state.fmtErr, err) - } + btnSprite.RenderSegmented(*state.prerenderdestination, xSeg, ySeg, state.baseFrame) label.SetPosition(state.offsetX, state.offsetY) label.RenderNoError(*state.prerenderdestination) @@ -437,7 +430,7 @@ func (v *Button) Activate() { } // Render renders the button -func (v *Button) Render(target d2interface.Surface) error { +func (v *Button) Render(target d2interface.Surface) { target.PushFilter(d2enum.FilterNearest) defer target.Pop() @@ -462,8 +455,6 @@ func (v *Button) Render(target d2interface.Surface) error { default: target.Render(v.normalSurface) } - - return nil } // Toggle negates the toggled state of the button diff --git a/d2core/d2ui/checkbox.go b/d2core/d2ui/checkbox.go index fb7fd6e7..3a5d326a 100644 --- a/d2core/d2ui/checkbox.go +++ b/d2core/d2ui/checkbox.go @@ -49,19 +49,11 @@ func (ui *UIManager) NewCheckbox(checkState bool) *Checkbox { result.Image = ui.renderer.NewSurface(result.width, result.height) - err = checkboxSprite.RenderSegmented(result.Image, 1, 1, 0) - if err != nil { - log.Print(err) - return nil - } + checkboxSprite.RenderSegmented(result.Image, 1, 1, 0) result.checkedImage = ui.renderer.NewSurface(result.width, result.height) - err = checkboxSprite.RenderSegmented(result.checkedImage, 1, 1, 1) - if err != nil { - log.Print(err) - return nil - } + checkboxSprite.RenderSegmented(result.checkedImage, 1, 1, 1) ui.addWidget(result) @@ -69,7 +61,7 @@ func (ui *UIManager) NewCheckbox(checkState bool) *Checkbox { } // Render renders the checkbox -func (v *Checkbox) Render(target d2interface.Surface) error { +func (v *Checkbox) Render(target d2interface.Surface) { target.PushTranslation(v.x, v.y) defer target.Pop() @@ -81,8 +73,6 @@ func (v *Checkbox) Render(target d2interface.Surface) error { } else { target.Render(v.Image) } - - return nil } // Advance does nothing for checkboxes diff --git a/d2core/d2ui/custom_widget.go b/d2core/d2ui/custom_widget.go index 0b3899bb..c5b9fa70 100644 --- a/d2core/d2ui/custom_widget.go +++ b/d2core/d2ui/custom_widget.go @@ -8,11 +8,11 @@ var _ Widget = &CustomWidget{} // CustomWidget is a widget with a fully custom render function type CustomWidget struct { *BaseWidget - renderFunc func(target d2interface.Surface) error + renderFunc func(target d2interface.Surface) } // NewCustomWidget creates a new widget with custom render function -func (ui *UIManager) NewCustomWidget(renderFunc func(target d2interface.Surface) error) *CustomWidget { +func (ui *UIManager) NewCustomWidget(renderFunc func(target d2interface.Surface)) *CustomWidget { base := NewBaseWidget(ui) return &CustomWidget{ @@ -22,8 +22,8 @@ func (ui *UIManager) NewCustomWidget(renderFunc func(target d2interface.Surface) } // Render draws the custom widget -func (c *CustomWidget) Render(target d2interface.Surface) error { - return c.renderFunc(target) +func (c *CustomWidget) Render(target d2interface.Surface) { + c.renderFunc(target) } // Advance is a no-op diff --git a/d2core/d2ui/drawable.go b/d2core/d2ui/drawable.go index dc623ff9..fc267f3a 100644 --- a/d2core/d2ui/drawable.go +++ b/d2core/d2ui/drawable.go @@ -6,7 +6,7 @@ import ( // Drawable represents an instance that can be drawn type Drawable interface { - Render(target d2interface.Surface) error + Render(target d2interface.Surface) Advance(elapsed float64) error GetSize() (width, height int) SetPosition(x, y int) diff --git a/d2core/d2ui/frame.go b/d2core/d2ui/frame.go index 095d9acd..158a6d7e 100644 --- a/d2core/d2ui/frame.go +++ b/d2core/d2ui/frame.go @@ -83,15 +83,17 @@ func (u *UIFrame) Load() { } // Render the frame to the target surface -func (u *UIFrame) Render(target d2interface.Surface) error { +func (u *UIFrame) Render(target d2interface.Surface) { switch u.frameOrientation { case FrameLeft: - return u.renderLeft(target) + if err := u.renderLeft(target); err != nil { + log.Printf("Render error %e", err) + } case FrameRight: - return u.renderRight(target) + if err := u.renderRight(target); err != nil { + log.Printf("Render error %e", err) + } } - - return nil } func (u *UIFrame) renderLeft(target d2interface.Surface) error { diff --git a/d2core/d2ui/label.go b/d2core/d2ui/label.go index 32bd3409..8f51e9b5 100644 --- a/d2core/d2ui/label.go +++ b/d2core/d2ui/label.go @@ -49,9 +49,8 @@ func (ui *UIManager) NewLabel(fontPath, palettePath string) *Label { } // Render draws the label on the screen -func (v *Label) Render(target d2interface.Surface) error { +func (v *Label) Render(target d2interface.Surface) { v.RenderNoError(target) - return nil } // RenderNoError draws the label on the screen, respliting the lines to allow for other alignments. diff --git a/d2core/d2ui/scrollbar.go b/d2core/d2ui/scrollbar.go index 18268663..73181fc6 100644 --- a/d2core/d2ui/scrollbar.go +++ b/d2core/d2ui/scrollbar.go @@ -106,9 +106,9 @@ func (v *Scrollbar) GetLastDirChange() int { } // Render renders the scrollbar to the given surface -func (v *Scrollbar) Render(target d2interface.Surface) error { +func (v *Scrollbar) Render(target d2interface.Surface) { if !v.visible || v.maxOffset == 0 { - return nil + return } offset := 0 @@ -119,18 +119,14 @@ func (v *Scrollbar) Render(target d2interface.Surface) error { v.scrollbarSprite.SetPosition(v.x, v.y) - if err := v.scrollbarSprite.RenderSegmented(target, 1, 1, 0+offset); err != nil { - return err - } + v.scrollbarSprite.RenderSegmented(target, 1, 1, 0+offset) v.scrollbarSprite.SetPosition(v.x, v.y+v.height-scrollbarSpriteOffsetY) // what is the magic? - if err := v.scrollbarSprite.RenderSegmented(target, 1, 1, 1+offset); err != nil { - return err - } + v.scrollbarSprite.RenderSegmented(target, 1, 1, 1+offset) if v.maxOffset == 0 || v.currentOffset < 0 || v.currentOffset > v.maxOffset { - return nil + return } v.scrollbarSprite.SetPosition(v.x, v.y+10+v.getBarPosition()) @@ -141,11 +137,7 @@ func (v *Scrollbar) Render(target d2interface.Surface) error { offset++ } - if err := v.scrollbarSprite.RenderSegmented(target, 1, 1, offset); err != nil { - return err - } - - return nil + v.scrollbarSprite.RenderSegmented(target, 1, 1, offset) } // Advance advances the scrollbar sprite diff --git a/d2core/d2ui/sprite.go b/d2core/d2ui/sprite.go index e9c3cdf6..09181254 100644 --- a/d2core/d2ui/sprite.go +++ b/d2core/d2ui/sprite.go @@ -41,9 +41,8 @@ func (ui *UIManager) NewSprite(animationPath, palettePath string) (*Sprite, erro } // Render renders the sprite on the given surface -func (s *Sprite) Render(target d2interface.Surface) error { +func (s *Sprite) Render(target d2interface.Surface) { s.RenderNoError(target) - return nil } // RenderNoError renders the sprite on the given surface @@ -65,7 +64,7 @@ func (s *Sprite) RenderSection(sfc d2interface.Surface, bound image.Rectangle) { } // RenderSegmented renders a sprite that is internally segmented as frames -func (s *Sprite) RenderSegmented(target d2interface.Surface, segmentsX, segmentsY, frameOffset int) error { +func (s *Sprite) RenderSegmented(target d2interface.Surface, segmentsX, segmentsY, frameOffset int) { var currentY int for y := 0; y < segmentsY; y++ { @@ -74,7 +73,7 @@ func (s *Sprite) RenderSegmented(target d2interface.Surface, segmentsX, segments for x := 0; x < segmentsX; x++ { idx := x + y*segmentsX + frameOffset*segmentsX*segmentsY if err := s.animation.SetCurrentFrame(idx); err != nil { - return err + log.Printf("SetCurrentFrame error %e", err) } target.PushTranslation(s.x+currentX, s.y+currentY) @@ -88,8 +87,6 @@ func (s *Sprite) RenderSegmented(target d2interface.Surface, segmentsX, segments currentY += maxFrameHeight } - - return nil } // GetSize returns the size of the current frame diff --git a/d2core/d2ui/textbox.go b/d2core/d2ui/textbox.go index de914f6c..e5b503a9 100644 --- a/d2core/d2ui/textbox.go +++ b/d2core/d2ui/textbox.go @@ -56,9 +56,9 @@ func (v *TextBox) SetFilter(filter string) { } // Render renders the text box -func (v *TextBox) Render(target d2interface.Surface) error { +func (v *TextBox) Render(target d2interface.Surface) { if !v.visible { - return nil + return } v.bgSprite.RenderNoError(target) @@ -67,8 +67,6 @@ func (v *TextBox) Render(target d2interface.Surface) error { if (time.Now().UnixNano()/1e6)&(1<<8) > 0 { v.lineBar.RenderNoError(target) } - - return nil } // OnKeyChars handles key character events diff --git a/d2core/d2ui/tooltip.go b/d2core/d2ui/tooltip.go index fc27818a..a69e9ebc 100644 --- a/d2core/d2ui/tooltip.go +++ b/d2core/d2ui/tooltip.go @@ -140,7 +140,7 @@ func (t *Tooltip) GetSize() (sx, sy int) { } // Render draws the tooltip -func (t *Tooltip) Render(target d2interface.Surface) error { +func (t *Tooltip) Render(target d2interface.Surface) { maxW, maxH := t.GetSize() // nolint:gomnd // no magic numbers, their meaning is obvious @@ -192,8 +192,6 @@ func (t *Tooltip) Render(target d2interface.Surface) error { } target.PopN(len(t.lines)) - - return nil } // Advance is a no-op diff --git a/d2core/d2ui/ui_manager.go b/d2core/d2ui/ui_manager.go index 708cb02b..f6f95edb 100644 --- a/d2core/d2ui/ui_manager.go +++ b/d2core/d2ui/ui_manager.go @@ -124,19 +124,13 @@ func (ui *UIManager) OnMouseButtonDown(event d2interface.MouseEvent) bool { func (ui *UIManager) Render(target d2interface.Surface) { for _, widget := range ui.widgets { if widget.GetVisible() { - err := widget.Render(target) - if err != nil { - log.Print(err) - } + widget.Render(target) } } for _, widgetGroup := range ui.widgetsGroups { if widgetGroup.GetVisible() { - err := widgetGroup.Render(target) - if err != nil { - log.Print(err) - } + widgetGroup.Render(target) } } } diff --git a/d2core/d2ui/widget_group.go b/d2core/d2ui/widget_group.go index da55cd63..88deb8a7 100644 --- a/d2core/d2ui/widget_group.go +++ b/d2core/d2ui/widget_group.go @@ -71,17 +71,12 @@ func (wg *WidgetGroup) Advance(elapsed float64) error { } // Render draw the widgets to the screen -func (wg *WidgetGroup) Render(target d2interface.Surface) error { +func (wg *WidgetGroup) Render(target d2interface.Surface) { for _, entry := range wg.entries { if entry.GetVisible() { - err := entry.Render(target) - if err != nil { - return err - } + entry.Render(target) } } - - return nil } // SetVisible sets the visibility of all widgets in the group diff --git a/d2game/d2gamescreen/character_select.go b/d2game/d2gamescreen/character_select.go index 76832383..45c6e1fa 100644 --- a/d2game/d2gamescreen/character_select.go +++ b/d2game/d2gamescreen/character_select.go @@ -369,17 +369,12 @@ func (v *CharacterSelect) onExitButtonClicked() { // Render renders the Character Select screen func (v *CharacterSelect) Render(screen d2interface.Surface) { - if err := v.background.RenderSegmented(screen, 4, 3, 0); err != nil { - return - } - + v.background.RenderSegmented(screen, 4, 3, 0) v.d2HeroTitle.RenderNoError(screen) actualSelectionIndex := v.selectedCharacter - (v.charScrollbar.GetCurrentOffset() * 2) if v.selectedCharacter > -1 && actualSelectionIndex >= 0 && actualSelectionIndex < 8 { - if err := v.selectionBox.RenderSegmented(screen, 2, 1, 0); err != nil { - return - } + v.selectionBox.RenderSegmented(screen, 2, 1, 0) } for i := 0; i < 8; i++ { @@ -402,11 +397,7 @@ func (v *CharacterSelect) Render(screen d2interface.Surface) { if v.showDeleteConfirmation { screen.DrawRect(screenWidth, screenHeight, rgbaColor(blackHalfOpacity)) - - if err := v.okCancelBox.RenderSegmented(screen, 2, 1, 0); err != nil { - return - } - + v.okCancelBox.RenderSegmented(screen, 2, 1, 0) v.deleteCharConfirmLabel.RenderNoError(screen) } } diff --git a/d2game/d2gamescreen/cinematics.go b/d2game/d2gamescreen/cinematics.go index 3159dafd..39192f89 100644 --- a/d2game/d2gamescreen/cinematics.go +++ b/d2game/d2gamescreen/cinematics.go @@ -183,21 +183,7 @@ func (v *Cinematics) playVideo(path string) { // Render renders the credits screen func (v *Cinematics) Render(screen d2interface.Surface) { - err := v.background.RenderSegmented(screen, 4, 3, 0) - - if err != nil { - return - } - - err = v.cinematicsBackground.RenderSegmented(screen, 2, 2, 0) - - if err != nil { - return - } - - err = v.cinematicsLabel.Render(screen) - - if err != nil { - return - } + v.background.RenderSegmented(screen, 4, 3, 0) + v.cinematicsBackground.RenderSegmented(screen, 2, 2, 0) + v.cinematicsLabel.Render(screen) } diff --git a/d2game/d2gamescreen/credits.go b/d2game/d2gamescreen/credits.go index eb850fcc..f66f5484 100644 --- a/d2game/d2gamescreen/credits.go +++ b/d2game/d2gamescreen/credits.go @@ -129,10 +129,7 @@ func (v *Credits) OnLoad(loading d2screen.LoadingState) { // Render renders the credits screen func (v *Credits) Render(screen d2interface.Surface) { - err := v.creditsBackground.RenderSegmented(screen, 4, 3, 0) - if err != nil { - return - } + v.creditsBackground.RenderSegmented(screen, 4, 3, 0) for _, label := range v.labels { if label.Available { diff --git a/d2game/d2gamescreen/main_menu.go b/d2game/d2gamescreen/main_menu.go index 43466698..2e30f07f 100644 --- a/d2game/d2gamescreen/main_menu.go +++ b/d2game/d2gamescreen/main_menu.go @@ -436,25 +436,14 @@ func (v *MainMenu) Render(screen d2interface.Surface) { func (v *MainMenu) renderBackgrounds(screen d2interface.Surface) { switch v.screenMode { case ScreenModeTrademark: - if err := v.trademarkBackground.RenderSegmented(screen, 4, 3, 0); err != nil { - return - } + v.trademarkBackground.RenderSegmented(screen, 4, 3, 0) case ScreenModeServerIP: - if err := v.tcpIPBackground.RenderSegmented(screen, 4, 3, 0); err != nil { - return - } - - if err := v.serverIPBackground.RenderSegmented(screen, 2, 1, 0); err != nil { - return - } + v.tcpIPBackground.RenderSegmented(screen, 4, 3, 0) + v.serverIPBackground.RenderSegmented(screen, 2, 1, 0) case ScreenModeTCPIP: - if err := v.tcpIPBackground.RenderSegmented(screen, 4, 3, 0); err != nil { - return - } + v.tcpIPBackground.RenderSegmented(screen, 4, 3, 0) default: - if err := v.background.RenderSegmented(screen, 4, 3, 0); err != nil { - return - } + v.background.RenderSegmented(screen, 4, 3, 0) } } diff --git a/d2game/d2gamescreen/select_hero_class.go b/d2game/d2gamescreen/select_hero_class.go index 56ee9fb3..aee4e7d9 100644 --- a/d2game/d2gamescreen/select_hero_class.go +++ b/d2game/d2gamescreen/select_hero_class.go @@ -511,10 +511,7 @@ func (v *SelectHeroClass) onOkButtonClicked() { // Render renders the Select Hero Class screen func (v *SelectHeroClass) Render(screen d2interface.Surface) { - if err := v.bgImage.RenderSegmented(screen, 4, 3, 0); err != nil { - return - } - + v.bgImage.RenderSegmented(screen, 4, 3, 0) v.headingLabel.RenderNoError(screen) if v.selectedHero != d2enum.HeroNone { diff --git a/d2game/d2player/hero_stats_panel.go b/d2game/d2player/hero_stats_panel.go index 4c0ddf0c..f054156a 100644 --- a/d2game/d2player/hero_stats_panel.go +++ b/d2game/d2player/hero_stats_panel.go @@ -208,9 +208,7 @@ func (s *HeroStatsPanel) renderStaticMenu(target d2interface.Surface) error { } func (s *HeroStatsPanel) renderStaticPanelFrames(target d2interface.Surface) error { - if err := s.frame.Render(target); err != nil { - return err - } + s.frame.Render(target) frames := []int{ statsPanelTopLeft, diff --git a/d2game/d2player/hud.go b/d2game/d2player/hud.go index a8f3b1d2..2f7486d4 100644 --- a/d2game/d2player/hud.go +++ b/d2game/d2player/hud.go @@ -595,10 +595,7 @@ func (h *HUD) renderMiniPanel(target d2interface.Surface) error { labelY := centerY - halfButtonHeight - labelHeight h.miniPanelTooltip.SetPosition(labelX, labelY) - - if err := h.miniPanelTooltip.Render(target); err != nil { - return err - } + h.miniPanelTooltip.Render(target) } return nil @@ -645,10 +642,7 @@ func (h *HUD) renderHealthTooltip(target d2interface.Surface) { } h.healthTooltip.SetText(strPanelHealth) - - if err := h.healthTooltip.Render(target); err != nil { - log.Printf("Cannot render tooltip, %e", err) - } + h.healthTooltip.Render(target) } //nolint:golint,dupl // we clean this up later @@ -665,10 +659,7 @@ func (h *HUD) renderManaTooltip(target d2interface.Surface) { } h.manaTooltip.SetText(strPanelMana) - - if err := h.manaTooltip.Render(target); err != nil { - log.Printf("Cannot render tooltip, %e", err) - } + h.manaTooltip.Render(target) } func (h *HUD) renderRunWalkTooltip(target d2interface.Surface) { @@ -689,10 +680,7 @@ func (h *HUD) renderRunWalkTooltip(target d2interface.Surface) { } h.runWalkTooltip.SetText(h.asset.TranslateString(stringTableKey)) - - if err := h.runWalkTooltip.Render(target); err != nil { - log.Printf("Cannot render tooltip, %e", err) - } + h.runWalkTooltip.Render(target) } func (h *HUD) renderStaminaTooltip(target d2interface.Surface) { @@ -709,10 +697,7 @@ func (h *HUD) renderStaminaTooltip(target d2interface.Surface) { strPanelStamina := fmt.Sprintf(fmtStamina, staminaCurr, staminaMax) h.staminaTooltip.SetText(strPanelStamina) - - if err := h.staminaTooltip.Render(target); err != nil { - log.Printf("Cannot render tooltip, %e", err) - } + h.staminaTooltip.Render(target) } func (h *HUD) renderExperienceTooltip(target d2interface.Surface) { @@ -736,10 +721,7 @@ func (h *HUD) renderExperienceTooltip(target d2interface.Surface) { strPanelExp := fmt.Sprintf(fmtExp, expCurr, expMax) h.experienceTooltip.SetText(strPanelExp) - - if err := h.experienceTooltip.Render(target); err != nil { - log.Printf("Cannot render tooltip, %e", err) - } + h.experienceTooltip.Render(target) } func (h *HUD) renderForSelectableEntitiesHovered(target d2interface.Surface) { diff --git a/d2game/d2player/inventory.go b/d2game/d2player/inventory.go index 4b970b8a..45bc544e 100644 --- a/d2game/d2player/inventory.go +++ b/d2game/d2player/inventory.go @@ -174,9 +174,7 @@ func (g *Inventory) Render(target d2interface.Surface) { } func (g *Inventory) renderFrame(target d2interface.Surface) error { - if err := g.frame.Render(target); err != nil { - return err - } + g.frame.Render(target) frames := []int{ frameInventoryTopLeft, @@ -241,9 +239,7 @@ func (g *Inventory) renderItemDescription(target d2interface.Surface, i Inventor lines := i.GetItemDescription() g.itemTooltip.SetTextLines(lines) _, y := g.grid.SlotToScreen(i.InventoryGridSlot()) - g.itemTooltip.SetPosition(g.hoverX, y) - if err := g.itemTooltip.Render(target); err != nil { - log.Printf("Cannot render tooltip, %e", err) - } + g.itemTooltip.SetPosition(g.hoverX, y) + g.itemTooltip.Render(target) } diff --git a/d2game/d2player/skill_select_panel.go b/d2game/d2player/skill_select_panel.go index cb7507fa..e5e2a49e 100644 --- a/d2game/d2player/skill_select_panel.go +++ b/d2game/d2player/skill_select_panel.go @@ -129,9 +129,7 @@ func (s *SkillPanel) Render(target d2interface.Surface) error { } if s.hoveredSkill != nil { - if err := s.hoverTooltip.Render(target); err != nil { - log.Printf("Cannot render tooltip, %e", err) - } + s.hoverTooltip.Render(target) } return nil diff --git a/d2game/d2player/skillicon.go b/d2game/d2player/skillicon.go index c8bb0551..feb7a4c0 100644 --- a/d2game/d2player/skillicon.go +++ b/d2game/d2player/skillicon.go @@ -1,6 +1,7 @@ package d2player import ( + "log" "strconv" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" @@ -50,11 +51,12 @@ func (si *skillIcon) SetVisible(visible bool) { si.lvlLabel.SetVisible(visible) } -func (si *skillIcon) renderSprite(target d2interface.Surface) error { +func (si *skillIcon) renderSprite(target d2interface.Surface) { x, y := si.GetPosition() if err := si.sprite.SetCurrentFrame(si.skill.IconCel); err != nil { - return err + log.Printf("Cannot set Frame %e", err) + return } if si.skill.SkillPoints == 0 { @@ -66,32 +68,23 @@ func (si *skillIcon) renderSprite(target d2interface.Surface) error { } si.sprite.SetPosition(x, y) - - if err := si.sprite.Render(target); err != nil { - return err - } - - return nil + si.sprite.Render(target) } -func (si *skillIcon) renderSpriteLabel(target d2interface.Surface) error { +func (si *skillIcon) renderSpriteLabel(target d2interface.Surface) { if si.skill.SkillPoints == 0 { - return nil + return } x, y := si.GetPosition() si.lvlLabel.SetText(strconv.Itoa(si.skill.SkillPoints)) si.lvlLabel.SetPosition(x+skillLabelXOffset, y+skillLabelYOffset) - - return si.lvlLabel.Render(target) + si.lvlLabel.Render(target) } -func (si *skillIcon) Render(target d2interface.Surface) error { - if err := si.renderSprite(target); err != nil { - return err - } - - return si.renderSpriteLabel(target) +func (si *skillIcon) Render(target d2interface.Surface) { + si.renderSprite(target) + si.renderSpriteLabel(target) } func (si *skillIcon) Advance(elapsed float64) error { diff --git a/d2game/d2player/skilltree.go b/d2game/d2player/skilltree.go index b44e7303..bc7a73ea 100644 --- a/d2game/d2player/skilltree.go +++ b/d2game/d2player/skilltree.go @@ -383,71 +383,54 @@ func (s *skillTree) setTab(tab int) { func (s *skillTree) renderPanelSegment( target d2interface.Surface, - frame int) error { + frame int) { if err := s.resources.skillPanel.SetCurrentFrame(frame); err != nil { - return err + log.Printf("%e", err) + return } s.resources.skillPanel.RenderNoError(target) - - return nil } -func (s *skillTree) renderTabCommon(target d2interface.Surface) error { +func (s *skillTree) renderTabCommon(target d2interface.Surface) { skillPanel := s.resources.skillPanel x, y := s.originX, s.originY // top w, h, err := skillPanel.GetFrameSize(frameCommonTabTopLeft) if err != nil { - return err + log.Printf("%e", err) + return } y += h skillPanel.SetPosition(x, y) - - err = s.renderPanelSegment(target, frameCommonTabTopLeft) - if err != nil { - return err - } + s.renderPanelSegment(target, frameCommonTabTopLeft) skillPanel.SetPosition(x+w, y) - - err = s.renderPanelSegment(target, frameCommonTabTopRight) - if err != nil { - return err - } + s.renderPanelSegment(target, frameCommonTabTopRight) // bottom _, h, err = skillPanel.GetFrameSize(frameCommonTabBottomLeft) if err != nil { - return err + log.Printf("%e", err) + return } y += h skillPanel.SetPosition(x, y) - - err = s.renderPanelSegment(target, frameCommonTabBottomLeft) - if err != nil { - return err - } + s.renderPanelSegment(target, frameCommonTabBottomLeft) skillPanel.SetPosition(x+w, y) - - err = s.renderPanelSegment(target, frameCommonTabBottomRight) - if err != nil { - return err - } + s.renderPanelSegment(target, frameCommonTabBottomRight) // available skill points label s.availSPLabel.RenderNoError(target) - - return nil } -func (s *skillTree) renderTab(target d2interface.Surface, tab int) error { +func (s *skillTree) renderTab(target d2interface.Surface, tab int) { topFrame := frameOffsetTop + (tabIndexOffset * tab) bottomFrame := frameOffsetBottom + (tabIndexOffset * tab) @@ -457,71 +440,46 @@ func (s *skillTree) renderTab(target d2interface.Surface, tab int) error { // top _, h0, err := skillPanel.GetFrameSize(topFrame) if err != nil { - return err + log.Printf("%e", err) + return } y += h0 skillPanel.SetPosition(x, y) - - err = s.renderPanelSegment(target, topFrame) - if err != nil { - return err - } + s.renderPanelSegment(target, topFrame) // bottom w, h1, err := skillPanel.GetFrameSize(bottomFrame) if err != nil { - return err + log.Printf("%e", err) + return } skillPanel.SetPosition(x, y+h1) - if err := s.renderPanelSegment(target, bottomFrame); err != nil { - return err - } + s.renderPanelSegment(target, bottomFrame) // tab button highlighted switch tab { case firstTab: skillPanel.SetPosition(x+w, y+h1) - - if err := s.renderPanelSegment(target, frameSelectedTab1Full); err != nil { - return err - } + s.renderPanelSegment(target, frameSelectedTab1Full) case secondTab: x += w skillPanel.SetPosition(x, s.originY+h0) - - if err := s.renderPanelSegment(target, frameSelectedTab2Top); err != nil { - return err - } + s.renderPanelSegment(target, frameSelectedTab2Top) skillPanel.SetPosition(x, y+h1) - - if err := s.renderPanelSegment(target, frameSelectedTab2Bottom); err != nil { - return err - } + s.renderPanelSegment(target, frameSelectedTab2Bottom) case thirdTab: skillPanel.SetPosition(x+w, y) - - if err := s.renderPanelSegment(target, frameSelectedTab3Full); err != nil { - return err - } + s.renderPanelSegment(target, frameSelectedTab3Full) } - - return nil } // Render the skill tree panel -func (s *skillTree) Render(target d2interface.Surface) error { - if err := s.renderTabCommon(target); err != nil { - return err - } - - if err := s.renderTab(target, s.selectedTab); err != nil { - return err - } - - return nil +func (s *skillTree) Render(target d2interface.Surface) { + s.renderTabCommon(target) + s.renderTab(target, s.selectedTab) } From 606fc028acdfb1456a531d31f19cfdd168565a07 Mon Sep 17 00:00:00 2001 From: juander Date: Wed, 11 Nov 2020 15:01:36 +0100 Subject: [PATCH 2/3] Revert "d2ui/label: Refactor Render() to RenderNoError()" This reverts commit f2a55312e41a774e2d2bcb6e070547c888021b3f. Since we removed the return of errors from the Render() method, we no longer require the RenderNoError() method. --- d2core/d2ui/button.go | 4 ++-- d2core/d2ui/label.go | 10 +--------- d2core/d2ui/textbox.go | 6 +++--- d2core/d2ui/tooltip.go | 2 +- d2game/d2gamescreen/character_select.go | 11 ++++++----- d2game/d2gamescreen/credits.go | 2 +- d2game/d2gamescreen/main_menu.go | 18 +++++++++--------- d2game/d2gamescreen/select_hero_class.go | 16 ++++++++-------- d2game/d2player/help_overlay.go | 2 +- d2game/d2player/hero_stats_panel.go | 4 ++-- d2game/d2player/hud.go | 4 ++-- d2game/d2player/skilltree.go | 2 +- 12 files changed, 37 insertions(+), 44 deletions(-) diff --git a/d2core/d2ui/button.go b/d2core/d2ui/button.go index e7d98fe7..01cacd65 100644 --- a/d2core/d2ui/button.go +++ b/d2core/d2ui/button.go @@ -340,7 +340,7 @@ func (v *Button) prerenderStates(btnSprite *Sprite, btnLayout *ButtonLayout, lab xOffset := half(v.width) label.SetPosition(xOffset, textY) - label.RenderNoError(v.normalSurface) + label.Render(v.normalSurface) if !btnLayout.HasImage || !btnLayout.AllowFrameChange { return @@ -411,7 +411,7 @@ func (v *Button) prerenderStates(btnSprite *Sprite, btnLayout *ButtonLayout, lab btnSprite.RenderSegmented(*state.prerenderdestination, xSeg, ySeg, state.baseFrame) label.SetPosition(state.offsetX, state.offsetY) - label.RenderNoError(*state.prerenderdestination) + label.Render(*state.prerenderdestination) } } diff --git a/d2core/d2ui/label.go b/d2core/d2ui/label.go index 8f51e9b5..aa768ee1 100644 --- a/d2core/d2ui/label.go +++ b/d2core/d2ui/label.go @@ -13,9 +13,6 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2core/d2gui" ) -// static check that UIFrame implements Widget -var _ Widget = &Label{} - // Label represents a user interface label type Label struct { *BaseWidget @@ -48,13 +45,8 @@ func (ui *UIManager) NewLabel(fontPath, palettePath string) *Label { return result } -// Render draws the label on the screen +// Render draws the label on the screen, respliting the lines to allow for other alignments. func (v *Label) Render(target d2interface.Surface) { - v.RenderNoError(target) -} - -// RenderNoError draws the label on the screen, respliting the lines to allow for other alignments. -func (v *Label) RenderNoError(target d2interface.Surface) { target.PushTranslation(v.GetPosition()) lines := strings.Split(v.text, "\n") diff --git a/d2core/d2ui/textbox.go b/d2core/d2ui/textbox.go index e5b503a9..17edfe80 100644 --- a/d2core/d2ui/textbox.go +++ b/d2core/d2ui/textbox.go @@ -61,11 +61,11 @@ func (v *TextBox) Render(target d2interface.Surface) { return } - v.bgSprite.RenderNoError(target) - v.textLabel.RenderNoError(target) + v.bgSprite.Render(target) + v.textLabel.Render(target) if (time.Now().UnixNano()/1e6)&(1<<8) > 0 { - v.lineBar.RenderNoError(target) + v.lineBar.Render(target) } } diff --git a/d2core/d2ui/tooltip.go b/d2core/d2ui/tooltip.go index a69e9ebc..1f1e1216 100644 --- a/d2core/d2ui/tooltip.go +++ b/d2core/d2ui/tooltip.go @@ -187,7 +187,7 @@ func (t *Tooltip) Render(target d2interface.Surface) { for i := range t.lines { t.label.SetText(t.lines[i]) _, h := t.label.GetTextMetrics(t.lines[i]) - t.label.RenderNoError(target) + t.label.Render(target) target.PushTranslation(0, h) } diff --git a/d2game/d2gamescreen/character_select.go b/d2game/d2gamescreen/character_select.go index 45c6e1fa..3c951568 100644 --- a/d2game/d2gamescreen/character_select.go +++ b/d2game/d2gamescreen/character_select.go @@ -370,7 +370,8 @@ func (v *CharacterSelect) onExitButtonClicked() { // Render renders the Character Select screen func (v *CharacterSelect) Render(screen d2interface.Surface) { v.background.RenderSegmented(screen, 4, 3, 0) - v.d2HeroTitle.RenderNoError(screen) + v.d2HeroTitle.Render(screen) + actualSelectionIndex := v.selectedCharacter - (v.charScrollbar.GetCurrentOffset() * 2) if v.selectedCharacter > -1 && actualSelectionIndex >= 0 && actualSelectionIndex < 8 { @@ -383,9 +384,9 @@ func (v *CharacterSelect) Render(screen d2interface.Surface) { continue } - v.characterNameLabel[i].RenderNoError(screen) - v.characterStatsLabel[i].RenderNoError(screen) - v.characterExpLabel[i].RenderNoError(screen) + v.characterNameLabel[i].Render(screen) + v.characterStatsLabel[i].Render(screen) + v.characterExpLabel[i].Render(screen) x, y := v.characterNameLabel[i].GetPosition() charImgX := x - selectionBoxImageOffsetX @@ -398,7 +399,7 @@ func (v *CharacterSelect) Render(screen d2interface.Surface) { if v.showDeleteConfirmation { screen.DrawRect(screenWidth, screenHeight, rgbaColor(blackHalfOpacity)) v.okCancelBox.RenderSegmented(screen, 2, 1, 0) - v.deleteCharConfirmLabel.RenderNoError(screen) + v.deleteCharConfirmLabel.Render(screen) } } diff --git a/d2game/d2gamescreen/credits.go b/d2game/d2gamescreen/credits.go index f66f5484..a71b4e8b 100644 --- a/d2game/d2gamescreen/credits.go +++ b/d2game/d2gamescreen/credits.go @@ -136,7 +136,7 @@ func (v *Credits) Render(screen d2interface.Surface) { continue } - label.Label.RenderNoError(screen) + label.Label.Render(screen) } } diff --git a/d2game/d2gamescreen/main_menu.go b/d2game/d2gamescreen/main_menu.go index 2e30f07f..7acfc652 100644 --- a/d2game/d2gamescreen/main_menu.go +++ b/d2game/d2gamescreen/main_menu.go @@ -460,21 +460,21 @@ func (v *MainMenu) renderLogos(screen d2interface.Surface) { func (v *MainMenu) renderLabels(screen d2interface.Surface) { switch v.screenMode { case ScreenModeServerIP: - v.tcpIPOptionsLabel.RenderNoError(screen) - v.tcpJoinGameLabel.RenderNoError(screen) + v.tcpIPOptionsLabel.Render(screen) + v.tcpJoinGameLabel.Render(screen) case ScreenModeTCPIP: - v.tcpIPOptionsLabel.RenderNoError(screen) + v.tcpIPOptionsLabel.Render(screen) case ScreenModeTrademark: - v.copyrightLabel.RenderNoError(screen) - v.copyrightLabel2.RenderNoError(screen) + v.copyrightLabel.Render(screen) + v.copyrightLabel2.Render(screen) if v.errorLabel != nil { - v.errorLabel.RenderNoError(screen) + v.errorLabel.Render(screen) } case ScreenModeMainMenu: - v.openDiabloLabel.RenderNoError(screen) - v.versionLabel.RenderNoError(screen) - v.commitLabel.RenderNoError(screen) + v.openDiabloLabel.Render(screen) + v.versionLabel.Render(screen) + v.commitLabel.Render(screen) } } diff --git a/d2game/d2gamescreen/select_hero_class.go b/d2game/d2gamescreen/select_hero_class.go index aee4e7d9..d224086d 100644 --- a/d2game/d2gamescreen/select_hero_class.go +++ b/d2game/d2gamescreen/select_hero_class.go @@ -512,13 +512,13 @@ func (v *SelectHeroClass) onOkButtonClicked() { // Render renders the Select Hero Class screen func (v *SelectHeroClass) Render(screen d2interface.Surface) { v.bgImage.RenderSegmented(screen, 4, 3, 0) - v.headingLabel.RenderNoError(screen) + v.headingLabel.Render(screen) if v.selectedHero != d2enum.HeroNone { - v.heroClassLabel.RenderNoError(screen) - v.heroDesc1Label.RenderNoError(screen) - v.heroDesc2Label.RenderNoError(screen) - v.heroDesc3Label.RenderNoError(screen) + v.heroClassLabel.Render(screen) + v.heroDesc1Label.Render(screen) + v.heroDesc2Label.Render(screen) + v.heroDesc3Label.Render(screen) } for heroClass, heroInfo := range v.heroRenderInfo { @@ -536,9 +536,9 @@ func (v *SelectHeroClass) Render(screen d2interface.Surface) { v.campfire.RenderNoError(screen) if v.heroNameTextbox.GetVisible() { - v.heroNameLabel.RenderNoError(screen) - v.expansionCharLabel.RenderNoError(screen) - v.hardcoreCharLabel.RenderNoError(screen) + v.heroNameLabel.Render(screen) + v.expansionCharLabel.Render(screen) + v.hardcoreCharLabel.Render(screen) } } diff --git a/d2game/d2player/help_overlay.go b/d2game/d2player/help_overlay.go index 2608e266..e54b12f6 100644 --- a/d2game/d2player/help_overlay.go +++ b/d2game/d2player/help_overlay.go @@ -624,7 +624,7 @@ func (h *HelpOverlay) Render(target d2interface.Surface) error { } for _, t := range h.text { - t.RenderNoError(target) + t.Render(target) } for _, l := range h.lines { diff --git a/d2game/d2player/hero_stats_panel.go b/d2game/d2player/hero_stats_panel.go index f054156a..8428a6d6 100644 --- a/d2game/d2player/hero_stats_panel.go +++ b/d2game/d2player/hero_stats_panel.go @@ -293,7 +293,7 @@ func (s *HeroStatsPanel) renderStaticLabels(target d2interface.Surface) { cfg.centerAlign, }) - label.RenderNoError(target) + label.Render(target) } } @@ -346,7 +346,7 @@ func (s *HeroStatsPanel) renderStatValues(target d2interface.Surface) { func (s *HeroStatsPanel) renderStatValueNum(label *d2ui.Label, value int, target d2interface.Surface) { label.SetText(strconv.Itoa(value)) - label.RenderNoError(target) + label.Render(target) } func (s *HeroStatsPanel) createStatValueLabel(stat, x, y int) *d2ui.Label { diff --git a/d2game/d2player/hud.go b/d2game/d2player/hud.go index 2f7486d4..d3d04063 100644 --- a/d2game/d2player/hud.go +++ b/d2game/d2player/hud.go @@ -754,7 +754,7 @@ func (h *HUD) renderForSelectableEntitiesHovered(target d2interface.Surface) { xLabel, yLabel := entScreenX-xOff, entScreenY-yOff-entityHeight-hoverLabelOuterPad h.nameLabel.SetPosition(xLabel, yLabel) - h.nameLabel.RenderNoError(target) + h.nameLabel.Render(target) entity.Highlight() break @@ -776,7 +776,7 @@ func (h *HUD) Render(target d2interface.Surface) error { if h.isZoneTextShown { h.zoneChangeText.SetPosition(zoneChangeTextX, zoneChangeTextY) - h.zoneChangeText.RenderNoError(target) + h.zoneChangeText.Render(target) } h.renderHealthTooltip(target) diff --git a/d2game/d2player/skilltree.go b/d2game/d2player/skilltree.go index bc7a73ea..cbed3818 100644 --- a/d2game/d2player/skilltree.go +++ b/d2game/d2player/skilltree.go @@ -427,7 +427,7 @@ func (s *skillTree) renderTabCommon(target d2interface.Surface) { s.renderPanelSegment(target, frameCommonTabBottomRight) // available skill points label - s.availSPLabel.RenderNoError(target) + s.availSPLabel.Render(target) } func (s *skillTree) renderTab(target d2interface.Surface, tab int) { From 976431c8e5b640846102f155b722eb8507e48eda Mon Sep 17 00:00:00 2001 From: juander Date: Wed, 11 Nov 2020 15:05:04 +0100 Subject: [PATCH 3/3] Revert "d2ui/sprite: Refactor Render() to RenderNoError()" This reverts commit 77cd538c2f8995845280fcbcc606624eeff74dbc. Since we removed the return of errors from the Render() method, we no longer require the RenderNoError() method. --- d2core/d2ui/frame.go | 2 +- d2core/d2ui/sprite.go | 8 -------- d2game/d2gamescreen/main_menu.go | 8 ++++---- d2game/d2gamescreen/select_hero_class.go | 4 ++-- d2game/d2player/help_overlay.go | 2 +- d2game/d2player/hero_stats_panel.go | 2 +- d2game/d2player/hud.go | 24 ++++++++++++------------ d2game/d2player/inventory.go | 2 +- d2game/d2player/inventory_grid.go | 2 +- d2game/d2player/mini_panel.go | 4 ++-- d2game/d2player/skill_select_panel.go | 2 +- d2game/d2player/skilltree.go | 2 +- 12 files changed, 27 insertions(+), 35 deletions(-) diff --git a/d2core/d2ui/frame.go b/d2core/d2ui/frame.go index 158a6d7e..99b5b56c 100644 --- a/d2core/d2ui/frame.go +++ b/d2core/d2ui/frame.go @@ -229,7 +229,7 @@ func (u *UIFrame) renderFramePiece(sfc d2interface.Surface, x, y, idx int) error u.frame.SetPosition(x, y) - u.frame.RenderNoError(sfc) + u.frame.Render(sfc) return nil } diff --git a/d2core/d2ui/sprite.go b/d2core/d2ui/sprite.go index 09181254..dc956e3d 100644 --- a/d2core/d2ui/sprite.go +++ b/d2core/d2ui/sprite.go @@ -11,9 +11,6 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" ) -// static check that Sprite implements Widget -var _ Widget = &Sprite{} - // Sprite is a positioned visual object. type Sprite struct { *BaseWidget @@ -42,11 +39,6 @@ func (ui *UIManager) NewSprite(animationPath, palettePath string) (*Sprite, erro // Render renders the sprite on the given surface func (s *Sprite) Render(target d2interface.Surface) { - s.RenderNoError(target) -} - -// RenderNoError renders the sprite on the given surface -func (s *Sprite) RenderNoError(target d2interface.Surface) { _, frameHeight := s.animation.GetCurrentFrameSize() target.PushTranslation(s.x, s.y-frameHeight) diff --git a/d2game/d2gamescreen/main_menu.go b/d2game/d2gamescreen/main_menu.go index 7acfc652..2a484f83 100644 --- a/d2game/d2gamescreen/main_menu.go +++ b/d2game/d2gamescreen/main_menu.go @@ -450,10 +450,10 @@ func (v *MainMenu) renderBackgrounds(screen d2interface.Surface) { func (v *MainMenu) renderLogos(screen d2interface.Surface) { switch v.screenMode { case ScreenModeTrademark, ScreenModeMainMenu, ScreenModeMultiplayer: - v.diabloLogoLeftBack.RenderNoError(screen) - v.diabloLogoRightBack.RenderNoError(screen) - v.diabloLogoLeft.RenderNoError(screen) - v.diabloLogoRight.RenderNoError(screen) + v.diabloLogoLeftBack.Render(screen) + v.diabloLogoRightBack.Render(screen) + v.diabloLogoLeft.Render(screen) + v.diabloLogoRight.Render(screen) } } diff --git a/d2game/d2gamescreen/select_hero_class.go b/d2game/d2gamescreen/select_hero_class.go index d224086d..571e3000 100644 --- a/d2game/d2gamescreen/select_hero_class.go +++ b/d2game/d2gamescreen/select_hero_class.go @@ -533,7 +533,7 @@ func (v *SelectHeroClass) Render(screen d2interface.Surface) { } } - v.campfire.RenderNoError(screen) + v.campfire.Render(screen) if v.heroNameTextbox.GetVisible() { v.heroNameLabel.Render(screen) @@ -736,7 +736,7 @@ func setSpriteToFirstFrame(sprite *d2ui.Sprite) { func drawSprite(sprite *d2ui.Sprite, target d2interface.Surface) { if sprite != nil { - sprite.RenderNoError(target) + sprite.Render(target) } } diff --git a/d2game/d2player/help_overlay.go b/d2game/d2player/help_overlay.go index e54b12f6..8414d3c8 100644 --- a/d2game/d2player/help_overlay.go +++ b/d2game/d2player/help_overlay.go @@ -620,7 +620,7 @@ func (h *HelpOverlay) Render(target d2interface.Surface) error { } for _, f := range h.frames { - f.RenderNoError(target) + f.Render(target) } for _, t := range h.text { diff --git a/d2game/d2player/hero_stats_panel.go b/d2game/d2player/hero_stats_panel.go index 8428a6d6..8d3355fd 100644 --- a/d2game/d2player/hero_stats_panel.go +++ b/d2game/d2player/hero_stats_panel.go @@ -240,7 +240,7 @@ func (s *HeroStatsPanel) renderStaticPanelFrames(target d2interface.Surface) err s.panel.SetPosition(currentX-w, currentY+h) } - s.panel.RenderNoError(target) + s.panel.Render(target) } return nil diff --git a/d2game/d2player/hud.go b/d2game/d2player/hud.go index d3d04063..bbeff94d 100644 --- a/d2game/d2player/hud.go +++ b/d2game/d2player/hud.go @@ -391,7 +391,7 @@ func (h *HUD) renderManaGlobe(x, _ int, target d2interface.Surface) error { h.mainPanel.SetPosition(x, height) - h.mainPanel.RenderNoError(target) + h.mainPanel.Render(target) // Mana status bar manaPercent := float64(h.hero.Stats.Mana) / float64(h.hero.Stats.MaxMana) @@ -413,8 +413,8 @@ func (h *HUD) renderManaGlobe(x, _ int, target d2interface.Surface) error { h.globeSprite.SetPosition(x+rightGlobeOffsetX, height+rightGlobeOffsetY) - h.globeSprite.RenderNoError(target) - h.globeSprite.RenderNoError(target) + h.globeSprite.Render(target) + h.globeSprite.Render(target) return nil } @@ -438,7 +438,7 @@ func (h *HUD) renderHealthGlobe(x, y int, target d2interface.Surface) error { } h.globeSprite.SetPosition(x+globeSpriteOffsetX, y+globeSpriteOffsetY) - h.globeSprite.RenderNoError(target) + h.globeSprite.Render(target) return nil } @@ -449,7 +449,7 @@ func (h *HUD) renderPanel(x, y int, target d2interface.Surface) error { } h.mainPanel.SetPosition(x, y) - h.mainPanel.RenderNoError(target) + h.mainPanel.Render(target) return nil } @@ -466,7 +466,7 @@ func (h *HUD) renderLeftSkill(x, y int, target d2interface.Surface) error { } h.leftSkillResource.SkillIcon.SetPosition(x, y) - h.leftSkillResource.SkillIcon.RenderNoError(target) + h.leftSkillResource.SkillIcon.Render(target) return nil } @@ -485,7 +485,7 @@ func (h *HUD) renderRightSkill(x, _ int, target d2interface.Surface) error { } h.rightSkillResource.SkillIcon.SetPosition(x, height) - h.rightSkillResource.SkillIcon.RenderNoError(target) + h.rightSkillResource.SkillIcon.Render(target) return nil } @@ -496,7 +496,7 @@ func (h *HUD) renderNewStatsButton(x, y int, target d2interface.Surface) error { } h.mainPanel.SetPosition(x, y) - h.mainPanel.RenderNoError(target) + h.mainPanel.Render(target) return nil } @@ -507,7 +507,7 @@ func (h *HUD) renderStamina(x, y int, target d2interface.Surface) error { } h.mainPanel.SetPosition(x, y) - h.mainPanel.RenderNoError(target) + h.mainPanel.Render(target) return nil } @@ -558,7 +558,7 @@ func (h *HUD) renderMiniPanel(target d2interface.Surface) error { buttonX, buttonY := (width>>1)+miniPanelButtonOffsetX, height+miniPanelButtonOffsetY h.menuButton.SetPosition(buttonX, buttonY) - h.menuButton.RenderNoError(target) + h.menuButton.Render(target) h.miniPanel.Render(target) miniPanelButtons := map[actionableType]string{ @@ -609,7 +609,7 @@ func (h *HUD) renderPotions(x, _ int, target d2interface.Surface) error { } h.mainPanel.SetPosition(x, height) - h.mainPanel.RenderNoError(target) + h.mainPanel.Render(target) return nil } @@ -622,7 +622,7 @@ func (h *HUD) renderNewSkillsButton(x, _ int, target d2interface.Surface) error } h.mainPanel.SetPosition(x, height) - h.mainPanel.RenderNoError(target) + h.mainPanel.Render(target) return nil } diff --git a/d2game/d2player/inventory.go b/d2game/d2player/inventory.go index 45bc544e..3d8bc062 100644 --- a/d2game/d2player/inventory.go +++ b/d2game/d2player/inventory.go @@ -194,7 +194,7 @@ func (g *Inventory) renderFrame(target d2interface.Surface) error { w, h := g.panel.GetCurrentFrameSize() g.panel.SetPosition(x, y+h) - g.panel.RenderNoError(target) + g.panel.Render(target) switch frame { case frameInventoryTopLeft: diff --git a/d2game/d2player/inventory_grid.go b/d2game/d2player/inventory_grid.go index 771c49b2..2c30a648 100644 --- a/d2game/d2player/inventory_grid.go +++ b/d2game/d2player/inventory_grid.go @@ -234,7 +234,7 @@ func (g *ItemGrid) renderItem(item InventoryItem, target d2interface.Surface, x, if itemSprite != nil { itemSprite.SetPosition(x, y) itemSprite.GetCurrentFrameSize() - itemSprite.RenderNoError(target) + itemSprite.Render(target) } } diff --git a/d2game/d2player/mini_panel.go b/d2game/d2player/mini_panel.go index f69dd07a..b2be6eb9 100644 --- a/d2game/d2player/mini_panel.go +++ b/d2game/d2player/mini_panel.go @@ -104,7 +104,7 @@ func (m *miniPanel) Render(target d2interface.Surface) { m.container.SetPosition(x, y) - m.container.RenderNoError(target) + m.container.Render(target) buttonWidth, _ := m.button.GetCurrentFrameSize() buttonWidth++ @@ -122,7 +122,7 @@ func (m *miniPanel) Render(target d2interface.Surface) { x, y := halfW+offsetX, height+buttonOffsetY m.button.SetPosition(x, y) - m.button.RenderNoError(target) + m.button.Render(target) j += 2 } diff --git a/d2game/d2player/skill_select_panel.go b/d2game/d2player/skill_select_panel.go index e5e2a49e..d5785c1e 100644 --- a/d2game/d2player/skill_select_panel.go +++ b/d2game/d2player/skill_select_panel.go @@ -240,7 +240,7 @@ func (s *SkillPanel) createSkillListImage(skillsListRow *SkillListRow) (d2interf } surface.PushTranslation(idx*skillIconWidth, 50) - skillSprite.RenderNoError(surface) + skillSprite.Render(surface) surface.Pop() } diff --git a/d2game/d2player/skilltree.go b/d2game/d2player/skilltree.go index cbed3818..73d01fdb 100644 --- a/d2game/d2player/skilltree.go +++ b/d2game/d2player/skilltree.go @@ -389,7 +389,7 @@ func (s *skillTree) renderPanelSegment( return } - s.resources.skillPanel.RenderNoError(target) + s.resources.skillPanel.Render(target) } func (s *skillTree) renderTabCommon(target d2interface.Surface) {