mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-01-27 11:47:45 -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)
|
fmt.Println(errorMessage)
|
||||||
a.ToMainMenu(errorMessage)
|
a.ToMainMenu(errorMessage)
|
||||||
} else {
|
} 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,
|
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
|
package d2gamescreen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ func CreateGame(
|
|||||||
term d2interface.Terminal,
|
term d2interface.Terminal,
|
||||||
l d2util.LogLevel,
|
l d2util.LogLevel,
|
||||||
guiManager *d2gui.GuiManager,
|
guiManager *d2gui.GuiManager,
|
||||||
) *Game {
|
) (*Game, error) {
|
||||||
// find the local player and its initial location
|
// find the local player and its initial location
|
||||||
var startX, startY float64
|
var startX, startY float64
|
||||||
|
|
||||||
@ -93,10 +94,10 @@ func CreateGame(
|
|||||||
game.escapeMenu.OnLoad()
|
game.escapeMenu.OnLoad()
|
||||||
|
|
||||||
if err := inputManager.BindHandler(game.escapeMenu); err != nil {
|
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
|
// Game represents the Gameplay screen
|
||||||
|
Loading…
Reference in New Issue
Block a user