1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-15 16:56:00 -05:00

Merge pull request #966 from gucio321/hotfix

hotfix: helpOverlay hotkeys
This commit is contained in:
Tim Sarbin 2020-12-12 13:31:56 -05:00 committed by GitHub
commit 469e4fa735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 42 deletions

View File

@ -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)
}
}

View File

@ -419,9 +419,17 @@ var testAssetManager *d2asset.AssetManager
var testItemFactory *ItemFactory
func TestSetup(t *testing.T) {
var err error
testAssetManager = &d2asset.AssetManager{}
testAssetManager.Records = &d2records.RecordManager{}
testItemFactory, _ = NewItemFactory(testAssetManager)
testItemFactory, err = NewItemFactory(testAssetManager)
if err != nil {
t.Error(err)
return
}
testAssetManager.Records.Item.Stats = itemStatCosts
testAssetManager.Records.Character.Stats = charStats
testAssetManager.Records.Skill.Details = skillDetails

View File

@ -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
@ -303,7 +304,7 @@ func (v *Game) bindGameControls() error {
var err error
v.gameControls, err = d2player.NewGameControls(v.asset, v.renderer, player, v.gameClient.MapEngine,
v.escapeMenu, v.mapRenderer, v, v.terminal, v.uiManager, v.guiManager, v.keyMap, v.logLevel, v.gameClient.IsSinglePlayer())
v.escapeMenu, v.mapRenderer, v, v.terminal, v.uiManager, v.keyMap, v.logLevel, v.gameClient.IsSinglePlayer())
if err != nil {
return err

View File

@ -10,7 +10,6 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2gui"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2hero"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
@ -124,7 +123,6 @@ func NewGameControls(
inputListener inputCallbackListener,
term d2interface.Terminal,
ui *d2ui.UIManager,
guiManager *d2gui.GuiManager,
keyMap *KeyMap,
l d2util.LogLevel,
isSinglePlayer bool,
@ -210,7 +208,12 @@ func NewGameControls(
heroStatsPanel := NewHeroStatsPanel(asset, ui, hero.Name(), hero.Class, l, hero.Stats)
questLog := NewQuestLog(asset, ui, l, hero.Act)
inventory := NewInventory(asset, ui, l, hero.Gold, inventoryRecord)
inventory, err := NewInventory(asset, ui, l, hero.Gold, inventoryRecord)
if err != nil {
return nil, err
}
skilltree := newSkillTree(hero.Skills, hero.Class, asset, l, ui)
miniPanel := newMiniPanel(asset, ui, l, isSinglePlayer)
@ -405,10 +408,7 @@ func (g *GameControls) OnKeyDown(event d2interface.KeyEvent) bool {
case d2enum.HoldRun:
g.hud.onToggleRunButton(true)
case d2enum.ToggleHelpScreen:
g.hud.miniPanel.openDisabled()
g.HelpOverlay.Toggle()
g.updateLayout()
g.toggleHelpOverlay()
default:
return false
}
@ -474,7 +474,7 @@ func (g *GameControls) onEscKey() {
}
if g.HelpOverlay.IsOpen() {
g.HelpOverlay.Toggle()
g.HelpOverlay.Close()
escHandled = true
}
@ -630,10 +630,12 @@ func (g *GameControls) OnMouseButtonDown(event d2interface.MouseEvent) bool {
}
func (g *GameControls) toggleHeroStatsPanel() {
g.questLog.Close()
g.heroStatsPanel.Toggle()
g.hud.miniPanel.SetMovedRight(g.heroStatsPanel.IsOpen())
g.updateLayout()
if !g.HelpOverlay.IsOpen() {
g.questLog.Close()
g.heroStatsPanel.Toggle()
g.hud.miniPanel.SetMovedRight(g.heroStatsPanel.IsOpen())
g.updateLayout()
}
}
func (g *GameControls) onCloseHeroStatsPanel() {
@ -642,10 +644,12 @@ func (g *GameControls) onCloseHeroStatsPanel() {
}
func (g *GameControls) toggleQuestLog() {
g.heroStatsPanel.Close()
g.questLog.Toggle()
g.hud.miniPanel.SetMovedRight(g.questLog.IsOpen())
g.updateLayout()
if !g.HelpOverlay.IsOpen() {
g.heroStatsPanel.Close()
g.questLog.Toggle()
g.hud.miniPanel.SetMovedRight(g.questLog.IsOpen())
g.updateLayout()
}
}
func (g *GameControls) onCloseQuestLog() {
@ -653,11 +657,21 @@ func (g *GameControls) onCloseQuestLog() {
g.updateLayout()
}
func (g *GameControls) toggleHelpOverlay() {
if !g.inventory.IsOpen() && !g.skilltree.IsOpen() && !g.heroStatsPanel.IsOpen() && !g.questLog.IsOpen() {
g.hud.miniPanel.openDisabled()
g.HelpOverlay.Toggle()
g.updateLayout()
}
}
func (g *GameControls) toggleInventoryPanel() {
g.skilltree.Close()
g.inventory.Toggle()
g.hud.miniPanel.SetMovedLeft(g.inventory.IsOpen())
g.updateLayout()
if !g.HelpOverlay.IsOpen() {
g.skilltree.Close()
g.inventory.Toggle()
g.hud.miniPanel.SetMovedLeft(g.inventory.IsOpen())
g.updateLayout()
}
}
func (g *GameControls) onCloseInventory() {
@ -666,10 +680,12 @@ func (g *GameControls) onCloseInventory() {
}
func (g *GameControls) toggleSkilltreePanel() {
g.inventory.Close()
g.skilltree.Toggle()
g.hud.miniPanel.SetMovedLeft(g.skilltree.IsOpen())
g.updateLayout()
if !g.HelpOverlay.IsOpen() {
g.inventory.Close()
g.skilltree.Toggle()
g.hud.miniPanel.SetMovedLeft(g.skilltree.IsOpen())
g.updateLayout()
}
}
func (g *GameControls) onCloseSkilltree() {

View File

@ -32,13 +32,15 @@ func NewInventory(asset *d2asset.AssetManager,
ui *d2ui.UIManager,
l d2util.LogLevel,
gold int,
record *d2records.InventoryRecord) *Inventory {
record *d2records.InventoryRecord) (*Inventory, error) {
itemTooltip := ui.NewTooltip(d2resource.FontFormal11, d2resource.PaletteStatic, d2ui.TooltipXCenter, d2ui.TooltipYBottom)
mgp := NewMoveGoldPanel(asset, ui, gold, l)
itemFactory, err := diablo2item.NewItemFactory(asset)
if err != nil {
return nil, fmt.Errorf("during creating new item factory: %s", err)
}
// https://github.com/OpenDiablo2/OpenDiablo2/issues/797
itemFactory, _ := diablo2item.NewItemFactory(asset)
mgp := NewMoveGoldPanel(asset, ui, gold, l)
inventory := &Inventory{
asset: asset,
@ -59,7 +61,7 @@ func NewInventory(asset *d2asset.AssetManager,
inventory.Logger.SetLevel(l)
inventory.Logger.SetPrefix(logPrefix)
return inventory
return inventory, nil
}
// Inventory represents the inventory

View File

@ -105,12 +105,6 @@ func NewQuestLog(asset *d2asset.AssetManager,
24: 0,
25: 0,
26: 0,
27: 0,
28: 0,
29: 0,
30: 0,
31: 0,
32: 1,
}
var quests [d2enum.ActsNumber]*d2ui.WidgetGroup