mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-10 14:26:15 -05:00
Merge pull request #914 from juander-ux/drawable-refactor
d2ui/drawable refactor
This commit is contained in:
commit
2035a62ec6
@ -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()
|
||||
@ -344,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
|
||||
@ -412,13 +408,10 @@ 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)
|
||||
label.Render(*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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
case FrameRight:
|
||||
return u.renderRight(target)
|
||||
if err := u.renderLeft(target); err != nil {
|
||||
log.Printf("Render error %e", err)
|
||||
}
|
||||
case FrameRight:
|
||||
if err := u.renderRight(target); err != nil {
|
||||
log.Printf("Render error %e", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *UIFrame) renderLeft(target d2interface.Surface) error {
|
||||
@ -227,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
|
||||
}
|
||||
|
@ -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,14 +45,8 @@ func (ui *UIManager) NewLabel(fontPath, palettePath string) *Label {
|
||||
return result
|
||||
}
|
||||
|
||||
// Render draws the label on the screen
|
||||
func (v *Label) Render(target d2interface.Surface) error {
|
||||
v.RenderNoError(target)
|
||||
return nil
|
||||
}
|
||||
|
||||
// RenderNoError draws the label on the screen, respliting the lines to allow for other alignments.
|
||||
func (v *Label) RenderNoError(target d2interface.Surface) {
|
||||
// Render draws the label on the screen, respliting the lines to allow for other alignments.
|
||||
func (v *Label) Render(target d2interface.Surface) {
|
||||
target.PushTranslation(v.GetPosition())
|
||||
|
||||
lines := strings.Split(v.text, "\n")
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -41,13 +38,7 @@ 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 {
|
||||
s.RenderNoError(target)
|
||||
return nil
|
||||
}
|
||||
|
||||
// RenderNoError renders the sprite on the given surface
|
||||
func (s *Sprite) RenderNoError(target d2interface.Surface) {
|
||||
func (s *Sprite) Render(target d2interface.Surface) {
|
||||
_, frameHeight := s.animation.GetCurrentFrameSize()
|
||||
|
||||
target.PushTranslation(s.x, s.y-frameHeight)
|
||||
@ -65,7 +56,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 +65,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 +79,6 @@ func (s *Sprite) RenderSegmented(target d2interface.Surface, segmentsX, segments
|
||||
|
||||
currentY += maxFrameHeight
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSize returns the size of the current frame
|
||||
|
@ -56,19 +56,17 @@ 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)
|
||||
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)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnKeyChars handles key character events
|
||||
|
@ -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
|
||||
@ -187,13 +187,11 @@ func (t *Tooltip) Render(target d2interface.Surface) error {
|
||||
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)
|
||||
}
|
||||
|
||||
target.PopN(len(t.lines))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Advance is a no-op
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,19 +71,14 @@ 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
|
||||
func (wg *WidgetGroup) SetVisible(visible bool) {
|
||||
for _, entry := range wg.entries {
|
||||
|
@ -369,17 +369,13 @@ 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.Render(screen)
|
||||
|
||||
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++ {
|
||||
@ -388,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
|
||||
@ -402,12 +398,8 @@ 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.deleteCharConfirmLabel.RenderNoError(screen)
|
||||
v.okCancelBox.RenderSegmented(screen, 2, 1, 0)
|
||||
v.deleteCharConfirmLabel.Render(screen)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -129,17 +129,14 @@ 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 {
|
||||
continue
|
||||
}
|
||||
|
||||
label.Label.RenderNoError(screen)
|
||||
label.Label.Render(screen)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,56 +436,45 @@ 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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,17 +511,14 @@ 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.headingLabel.RenderNoError(screen)
|
||||
v.bgImage.RenderSegmented(screen, 4, 3, 0)
|
||||
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,12 +533,12 @@ func (v *SelectHeroClass) Render(screen d2interface.Surface) {
|
||||
}
|
||||
}
|
||||
|
||||
v.campfire.RenderNoError(screen)
|
||||
v.campfire.Render(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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -620,11 +620,11 @@ func (h *HelpOverlay) Render(target d2interface.Surface) error {
|
||||
}
|
||||
|
||||
for _, f := range h.frames {
|
||||
f.RenderNoError(target)
|
||||
f.Render(target)
|
||||
}
|
||||
|
||||
for _, t := range h.text {
|
||||
t.RenderNoError(target)
|
||||
t.Render(target)
|
||||
}
|
||||
|
||||
for _, l := range h.lines {
|
||||
|
@ -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,
|
||||
@ -242,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
|
||||
@ -295,7 +293,7 @@ func (s *HeroStatsPanel) renderStaticLabels(target d2interface.Surface) {
|
||||
cfg.centerAlign,
|
||||
})
|
||||
|
||||
label.RenderNoError(target)
|
||||
label.Render(target)
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,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 {
|
||||
|
@ -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{
|
||||
@ -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
|
||||
@ -612,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
|
||||
}
|
||||
@ -625,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
|
||||
}
|
||||
@ -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) {
|
||||
@ -772,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
|
||||
@ -794,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)
|
||||
|
@ -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,
|
||||
@ -196,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:
|
||||
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
@ -242,7 +240,7 @@ func (s *SkillPanel) createSkillListImage(skillsListRow *SkillListRow) (d2interf
|
||||
}
|
||||
|
||||
surface.PushTranslation(idx*skillIconWidth, 50)
|
||||
skillSprite.RenderNoError(surface)
|
||||
skillSprite.Render(surface)
|
||||
surface.Pop()
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
si.sprite.Render(target)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -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
|
||||
s.resources.skillPanel.Render(target)
|
||||
}
|
||||
|
||||
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
|
||||
s.availSPLabel.Render(target)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user