mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-04 15:46:51 -05:00
removed all 'govet' type lint errors (#834)
This commit is contained in:
parent
a1380bc264
commit
6b5c2a1fc5
@ -311,15 +311,15 @@ func (c *Composite) loadCompositeLayer(layerKey, layerValue, animationMode, weap
|
||||
}
|
||||
|
||||
for _, animationPath := range animationPaths {
|
||||
|
||||
if exists, err := c.FileExists(animationPath); exists && err == nil {
|
||||
animation, err := c.LoadAnimationWithEffect(animationPath, palettePath, drawEffect)
|
||||
if err == nil {
|
||||
return animation, nil
|
||||
}
|
||||
} else {
|
||||
exists, err := c.FileExists(animationPath)
|
||||
if !exists || err != nil {
|
||||
return nil, fmt.Errorf("animation path '%s' not found: %v", animationPath, err)
|
||||
}
|
||||
|
||||
animation, err := c.LoadAnimationWithEffect(animationPath, palettePath, drawEffect)
|
||||
if err == nil {
|
||||
return animation, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("animation not found")
|
||||
|
@ -62,18 +62,18 @@ type ButtonLayout struct {
|
||||
ResourceName string
|
||||
PaletteName string
|
||||
FontPath string
|
||||
ClickableRect *image.Rectangle
|
||||
XSegments int
|
||||
YSegments int
|
||||
BaseFrame int
|
||||
DisabledFrame int
|
||||
ClickableRect *image.Rectangle
|
||||
TextOffset int
|
||||
Toggleable bool
|
||||
AllowFrameChange bool
|
||||
HasImage bool
|
||||
FixedWidth int
|
||||
FixedHeight int
|
||||
LabelColor uint32
|
||||
Toggleable bool
|
||||
AllowFrameChange bool
|
||||
HasImage bool
|
||||
}
|
||||
|
||||
const (
|
||||
@ -276,13 +276,14 @@ func (ui *UIManager) NewButton(buttonType ButtonType, text string) *Button {
|
||||
log.Print(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
if buttonLayout.FixedWidth > 0 {
|
||||
btn.width = buttonLayout.FixedWidth
|
||||
} else {
|
||||
for i := 0; i < buttonLayout.XSegments; i++ {
|
||||
w, _, err := buttonSprite.GetFrameSize(i)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
w, _, frameSizeErr := buttonSprite.GetFrameSize(i)
|
||||
if frameSizeErr != nil {
|
||||
log.Print(frameSizeErr)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -294,9 +295,9 @@ func (ui *UIManager) NewButton(buttonType ButtonType, text string) *Button {
|
||||
btn.height = buttonLayout.FixedHeight
|
||||
} else {
|
||||
for i := 0; i < buttonLayout.YSegments; i++ {
|
||||
_, h, err := buttonSprite.GetFrameSize(i * buttonLayout.YSegments)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
_, h, frameSizeErr := buttonSprite.GetFrameSize(i * buttonLayout.YSegments)
|
||||
if frameSizeErr != nil {
|
||||
log.Print(frameSizeErr)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,10 @@ import (
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2client/d2clientconnectiontype"
|
||||
)
|
||||
|
||||
const (
|
||||
millisecondsPerSecond = 1000.0
|
||||
)
|
||||
|
||||
type heroRenderConfig struct {
|
||||
idleAnimationPath string
|
||||
idleSelectedAnimationPath string
|
||||
@ -486,18 +490,19 @@ func (v *SelectHeroClass) onExitButtonClicked() {
|
||||
}
|
||||
|
||||
func (v *SelectHeroClass) onOkButtonClicked() {
|
||||
|
||||
heroName := v.heroNameTextbox.GetText()
|
||||
defaultStats := v.asset.Records.Character.Stats[v.selectedHero]
|
||||
statsState := v.CreateHeroStatsState(v.selectedHero, defaultStats)
|
||||
|
||||
playerState, err := v.CreateHeroState(heroName, v.selectedHero, statsState)
|
||||
|
||||
if err := v.Save(playerState); err != nil {
|
||||
fmt.Printf("failed to save game state!, err: %v\n", err)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to create hero state!, err: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = v.Save(playerState)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to save game state!, err: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -776,7 +781,7 @@ func (v *SelectHeroClass) loadSprite(animationPath string, position image.Point,
|
||||
}
|
||||
|
||||
if playLength != 0 {
|
||||
sprite.SetPlayLength(float64(playLength) / 1000.0)
|
||||
sprite.SetPlayLength(float64(playLength) / millisecondsPerSecond)
|
||||
}
|
||||
|
||||
sprite.SetPosition(position.X, position.Y)
|
||||
|
Loading…
Reference in New Issue
Block a user