1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-12-24 19:18:12 -05:00

game control: fixed panics on game start, when single player (party panel wasn't created)

This commit is contained in:
M. Sz 2021-01-20 08:48:55 +01:00
parent a126242f9f
commit 67525c8f4d
2 changed files with 30 additions and 6 deletions

View File

@ -280,8 +280,10 @@ func (v *Game) Advance(elapsed float64) error {
v.soundEnv.Advance(elapsed)
if v.gameControls != nil {
if v.gameControls.PartyPanel != nil {
v.gameControls.PartyPanel.UpdatePlayersList(v.gameClient.Players)
}
}
return nil
}

View File

@ -505,7 +505,10 @@ func (g *GameControls) OnMouseMove(event d2interface.MouseMoveEvent) bool {
}
g.hud.OnMouseMove(event)
if g.PartyPanel != nil {
g.PartyPanel.OnMouseMove(event)
}
return false
}
@ -564,7 +567,11 @@ func (g *GameControls) OnMouseButtonDown(event d2interface.MouseEvent) bool {
func (g *GameControls) clearLeftScreenSide() {
g.heroStatsPanel.Close()
if g.PartyPanel != nil {
g.PartyPanel.Close()
}
g.questLog.Close()
g.hud.skillSelectMenu.ClosePanels()
g.hud.miniPanel.SetMovedRight(false)
@ -683,7 +690,11 @@ func (g *GameControls) Load() {
g.inventory.Load()
g.skilltree.load()
g.heroStatsPanel.Load()
if g.PartyPanel != nil {
g.PartyPanel.Load()
}
g.questLog.Load()
g.HelpOverlay.Load()
@ -707,7 +718,10 @@ func (g *GameControls) Advance(elapsed float64) error {
g.hud.Advance(elapsed)
g.inventory.Advance(elapsed)
g.questLog.Advance(elapsed)
if g.PartyPanel != nil {
g.PartyPanel.Advance(elapsed)
}
if err := g.escapeMenu.Advance(elapsed); err != nil {
return err
@ -735,7 +749,15 @@ func (g *GameControls) updateLayout() {
}
func (g *GameControls) isLeftPanelOpen() bool {
return g.heroStatsPanel.IsOpen() || g.PartyPanel.IsOpen() || g.questLog.IsOpen() || g.inventory.moveGoldPanel.IsOpen()
var partyPanel bool
if g.PartyPanel != nil {
partyPanel = g.PartyPanel.IsOpen()
} else {
partyPanel = false
}
return g.heroStatsPanel.IsOpen() || partyPanel || g.questLog.IsOpen() || g.inventory.moveGoldPanel.IsOpen()
}
func (g *GameControls) isRightPanelOpen() bool {