1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-01-12 20:36:25 -05:00

skill tre - remaining points label

This commit is contained in:
M. Sz 2020-12-15 20:03:24 +01:00
parent be8b3e3157
commit cf439ede2f
2 changed files with 34 additions and 19 deletions

View File

@ -214,7 +214,7 @@ func NewGameControls(
return nil, err return nil, err
} }
skilltree := newSkillTree(hero.Skills, hero.Class, asset, l, ui) skilltree := newSkillTree(hero.Skills, hero.Class, hero.Stats, asset, l, ui)
miniPanel := newMiniPanel(asset, ui, l, isSinglePlayer) miniPanel := newMiniPanel(asset, ui, l, isSinglePlayer)

View File

@ -3,6 +3,7 @@ package d2player
import ( import (
"errors" "errors"
"fmt" "fmt"
"strconv"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
@ -56,6 +57,10 @@ const (
frameSelectedTab3Full = 13 frameSelectedTab3Full = 13
) )
const (
remainingPointsLabelX, remainingPointsLabelY = 677, 128
)
const ( const (
skillTreePanelX = 401 skillTreePanelX = 401
skillTreePanelY = 64 skillTreePanelY = 64
@ -87,6 +92,7 @@ type skillTreeHeroTypeResources struct {
func newSkillTree( func newSkillTree(
skills map[int]*d2hero.HeroSkill, skills map[int]*d2hero.HeroSkill,
heroClass d2enum.Hero, heroClass d2enum.Hero,
hero *d2hero.HeroStatsState,
asset *d2asset.AssetManager, asset *d2asset.AssetManager,
l d2util.LogLevel, l d2util.LogLevel,
ui *d2ui.UIManager, ui *d2ui.UIManager,
@ -98,6 +104,7 @@ func newSkillTree(
uiManager: ui, uiManager: ui,
originX: skillTreePanelX, originX: skillTreePanelX,
originY: skillTreePanelY, originY: skillTreePanelY,
stats: hero,
tab: [numTabs]*skillTreeTab{ tab: [numTabs]*skillTreeTab{
{}, {},
{}, {},
@ -114,24 +121,26 @@ func newSkillTree(
} }
type skillTree struct { type skillTree struct {
resources *skillTreeHeroTypeResources resources *skillTreeHeroTypeResources
asset *d2asset.AssetManager asset *d2asset.AssetManager
uiManager *d2ui.UIManager uiManager *d2ui.UIManager
skills map[int]*d2hero.HeroSkill skills map[int]*d2hero.HeroSkill
skillIcons []*skillIcon skillIcons []*skillIcon
heroClass d2enum.Hero heroClass d2enum.Hero
frame *d2ui.UIFrame frame *d2ui.UIFrame
availSPLabel *d2ui.Label availSPLabel *d2ui.Label
closeButton *d2ui.Button closeButton *d2ui.Button
tab [numTabs]*skillTreeTab tab [numTabs]*skillTreeTab
isOpen bool remainingPoints *d2ui.Label
originX int isOpen bool
originY int originX int
selectedTab int originY int
onCloseCb func() selectedTab int
panelGroup *d2ui.WidgetGroup onCloseCb func()
iconGroup *d2ui.WidgetGroup panelGroup *d2ui.WidgetGroup
panel *d2ui.CustomWidget iconGroup *d2ui.WidgetGroup
panel *d2ui.CustomWidget
stats *d2hero.HeroStatsState
*d2util.Logger *d2util.Logger
l d2util.LogLevel l d2util.LogLevel
@ -152,6 +161,12 @@ func (s *skillTree) load() {
s.closeButton.OnActivated(func() { s.Close() }) s.closeButton.OnActivated(func() { s.Close() })
s.panelGroup.AddWidget(s.closeButton) s.panelGroup.AddWidget(s.closeButton)
s.remainingPoints = s.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteSky)
s.remainingPoints.SetPosition(remainingPointsLabelX, remainingPointsLabelY)
s.remainingPoints.Alignment = d2ui.HorizontalAlignCenter
s.remainingPoints.SetText(strconv.Itoa(s.stats.SkillPoints))
s.panelGroup.AddWidget(s.remainingPoints)
if err := s.setHeroTypeResourcePath(); err != nil { if err := s.setHeroTypeResourcePath(); err != nil {
s.Error(err.Error()) s.Error(err.Error())
} }