mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-24 11:06:51 -05:00
add-buttons actions
This commit is contained in:
parent
7e346bd039
commit
3220cc93f4
@ -750,6 +750,7 @@ func getButtonLayouts() map[ButtonType]ButtonLayout {
|
||||
ButtonTypeAddSkill: {
|
||||
XSegments: 1,
|
||||
YSegments: 1,
|
||||
DisabledFrame: 2,
|
||||
DisabledColor: whiteAlpha100,
|
||||
ResourceName: d2resource.AddSkillButton,
|
||||
PaletteName: d2resource.PaletteSky,
|
||||
|
@ -224,13 +224,9 @@ func NewGameControls(
|
||||
}
|
||||
|
||||
helpOverlay := NewHelpOverlay(asset, ui, l, keyMap)
|
||||
hud := NewHUD(asset, ui, hero, miniPanel, actionableRegions, mapEngine, hero.Stats, l, mapRenderer)
|
||||
|
||||
const blackAlpha50percent = 0x0000007f
|
||||
|
||||
hoverLabel := hud.nameLabel
|
||||
hoverLabel.SetBackgroundColor(d2util.Color(blackAlpha50percent))
|
||||
|
||||
gc := &GameControls{
|
||||
asset: asset,
|
||||
ui: ui,
|
||||
@ -246,7 +242,6 @@ func NewGameControls(
|
||||
questLog: questLog,
|
||||
HelpOverlay: helpOverlay,
|
||||
keyMap: keyMap,
|
||||
hud: hud,
|
||||
bottomMenuRect: &d2geom.Rectangle{
|
||||
Left: menuBottomRectX,
|
||||
Top: menuBottomRectY,
|
||||
@ -271,6 +266,12 @@ func NewGameControls(
|
||||
isSinglePlayer: isSinglePlayer,
|
||||
}
|
||||
|
||||
hud := NewHUD(asset, ui, hero, miniPanel, actionableRegions, mapEngine, l, gc, mapRenderer)
|
||||
gc.hud = hud
|
||||
|
||||
hoverLabel := hud.nameLabel
|
||||
hoverLabel.SetBackgroundColor(d2util.Color(blackAlpha50percent))
|
||||
|
||||
gc.heroStatsPanel.SetOnCloseCb(gc.onCloseHeroStatsPanel)
|
||||
gc.questLog.SetOnCloseCb(gc.onCloseQuestLog)
|
||||
gc.inventory.SetOnCloseCb(gc.onCloseInventory)
|
||||
@ -713,6 +714,9 @@ func (g *GameControls) Load() {
|
||||
g.questLog.Load()
|
||||
g.HelpOverlay.Load()
|
||||
|
||||
g.loadAddButtons()
|
||||
g.SetAddButtons()
|
||||
|
||||
miniPanelActions := &miniPanelActions{
|
||||
characterToggle: g.toggleHeroStatsPanel,
|
||||
inventoryToggle: g.toggleInventoryPanel,
|
||||
@ -1099,3 +1103,13 @@ func (g *GameControls) bindTerminalCommands(term d2interface.Terminal) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GameControls) SetAddButtons() {
|
||||
g.hud.addStatsButton.SetEnabled(g.hero.Stats.StatsPoints > 0)
|
||||
g.hud.addSkillButton.SetEnabled(g.hero.Stats.SkillPoints > 0)
|
||||
}
|
||||
|
||||
func (g *GameControls) loadAddButtons() {
|
||||
g.hud.addStatsButton.OnActivated(func() { g.toggleHeroStatsPanel() })
|
||||
g.hud.addSkillButton.OnActivated(func() { g.toggleSkilltreePanel() })
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2hero"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2map/d2mapengine"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2map/d2mapentity"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2map/d2maprenderer"
|
||||
@ -83,7 +82,6 @@ type HUD struct {
|
||||
uiManager *d2ui.UIManager
|
||||
mapEngine *d2mapengine.MapEngine
|
||||
mapRenderer *d2maprenderer.MapRenderer
|
||||
heroStats *d2hero.HeroStatsState
|
||||
lastMouseX int
|
||||
lastMouseY int
|
||||
hero *d2mapentity.Player
|
||||
@ -113,6 +111,8 @@ type HUD struct {
|
||||
addStatsButton *d2ui.Button
|
||||
addSkillButton *d2ui.Button
|
||||
panelGroup *d2ui.WidgetGroup
|
||||
gameControls *GameControls
|
||||
|
||||
*d2util.Logger
|
||||
}
|
||||
|
||||
@ -124,8 +124,8 @@ func NewHUD(
|
||||
miniPanel *miniPanel,
|
||||
actionableRegions []actionableRegion,
|
||||
mapEngine *d2mapengine.MapEngine,
|
||||
heroStats *d2hero.HeroStatsState,
|
||||
l d2util.LogLevel,
|
||||
gameControls *GameControls,
|
||||
mapRenderer *d2maprenderer.MapRenderer,
|
||||
) *HUD {
|
||||
nameLabel := ui.NewLabel(d2resource.Font16, d2resource.PaletteStatic)
|
||||
@ -159,7 +159,7 @@ func NewHUD(
|
||||
zoneChangeText: zoneLabel,
|
||||
healthGlobe: healthGlobe,
|
||||
manaGlobe: manaGlobe,
|
||||
heroStats: heroStats,
|
||||
gameControls: gameControls,
|
||||
}
|
||||
|
||||
hud.Logger = d2util.NewLogger()
|
||||
@ -199,12 +199,6 @@ func (h *HUD) Load() {
|
||||
h.panelGroup.AddWidget(h.addSkillButton)
|
||||
|
||||
h.panelGroup.SetVisible(true)
|
||||
h.setAddButtonsVisible()
|
||||
}
|
||||
|
||||
func (h *HUD) setAddButtonsVisible() {
|
||||
h.addStatsButton.SetVisible(h.heroStats.StatsPoints > 0)
|
||||
h.addSkillButton.SetVisible(h.heroStats.SkillPoints > 0)
|
||||
}
|
||||
|
||||
func (h *HUD) loadCustomWidgets() {
|
||||
|
Loading…
Reference in New Issue
Block a user