1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-12-24 11:06:51 -05:00

Revert "d2ui/sprite: Refactor Render() to RenderNoError()"

This reverts commit 77cd538c2f.

Since we removed the return of errors from the Render() method, we no
longer require the RenderNoError() method.
This commit is contained in:
juander 2020-11-11 15:05:04 +01:00
parent 606fc028ac
commit 976431c8e5
12 changed files with 27 additions and 35 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -240,7 +240,7 @@ func (s *SkillPanel) createSkillListImage(skillsListRow *SkillListRow) (d2interf
}
surface.PushTranslation(idx*skillIconWidth, 50)
skillSprite.RenderNoError(surface)
skillSprite.Render(surface)
surface.Pop()
}

View File

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