mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-24 19:18:12 -05:00
error handling in d2gamescreen.CreateNewGame
This commit is contained in:
parent
509dfda5e5
commit
8f1aadc223
@ -943,9 +943,14 @@ func (a *App) ToCreateGame(filePath string, connType d2clientconnectiontype.Clie
|
||||
fmt.Println(errorMessage)
|
||||
a.ToMainMenu(errorMessage)
|
||||
} else {
|
||||
a.screen.SetNextScreen(d2gamescreen.CreateGame(
|
||||
game, err := d2gamescreen.CreateGame(
|
||||
a, a.asset, a.ui, a.renderer, a.inputManager, a.audio, gameClient, a.terminal, a.config.LogLevel, a.guiManager,
|
||||
))
|
||||
)
|
||||
if err != nil {
|
||||
a.Error(err.Error())
|
||||
}
|
||||
|
||||
a.screen.SetNextScreen(game)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package d2gamescreen
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image/color"
|
||||
|
||||
@ -47,7 +48,7 @@ func CreateGame(
|
||||
term d2interface.Terminal,
|
||||
l d2util.LogLevel,
|
||||
guiManager *d2gui.GuiManager,
|
||||
) *Game {
|
||||
) (*Game, error) {
|
||||
// find the local player and its initial location
|
||||
var startX, startY float64
|
||||
|
||||
@ -93,10 +94,10 @@ func CreateGame(
|
||||
game.escapeMenu.OnLoad()
|
||||
|
||||
if err := inputManager.BindHandler(game.escapeMenu); err != nil {
|
||||
game.Error("failed to add gameplay screen as event handler")
|
||||
return nil, errors.New("failed to add gameplay screen as event handler")
|
||||
}
|
||||
|
||||
return game
|
||||
return game, nil
|
||||
}
|
||||
|
||||
// Game represents the Gameplay screen
|
||||
|
Loading…
Reference in New Issue
Block a user