mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-24 19:18:12 -05:00
help overlay text
This commit is contained in:
parent
469e4fa735
commit
8186ecd55a
@ -108,6 +108,11 @@ func (v *Label) SetText(newText string) {
|
||||
v.text = v.processColorTokens(newText)
|
||||
}
|
||||
|
||||
// GetText returns label text
|
||||
func (v *Label) GetText() string {
|
||||
return v.text
|
||||
}
|
||||
|
||||
// SetBackgroundColor sets the background highlight color
|
||||
func (v *Label) SetBackgroundColor(c color.Color) {
|
||||
v.backgroundColor = c
|
||||
|
@ -659,6 +659,7 @@ func (g *GameControls) onCloseQuestLog() {
|
||||
|
||||
func (g *GameControls) toggleHelpOverlay() {
|
||||
if !g.inventory.IsOpen() && !g.skilltree.IsOpen() && !g.heroStatsPanel.IsOpen() && !g.questLog.IsOpen() {
|
||||
g.HelpOverlay.updateKeyMap(g.keyMap)
|
||||
g.hud.miniPanel.openDisabled()
|
||||
g.HelpOverlay.Toggle()
|
||||
g.updateLayout()
|
||||
|
@ -155,6 +155,8 @@ const (
|
||||
beltDotY = 568
|
||||
)
|
||||
|
||||
const bullets = 8
|
||||
|
||||
// NewHelpOverlay creates a new HelpOverlay instance
|
||||
func NewHelpOverlay(
|
||||
asset *d2asset.AssetManager,
|
||||
@ -182,6 +184,7 @@ type HelpOverlay struct {
|
||||
frames []*d2ui.Sprite
|
||||
text []*d2ui.Label
|
||||
lines []line
|
||||
bullets [bullets]*d2ui.Label
|
||||
uiManager *d2ui.UIManager
|
||||
closeButton *d2ui.Button
|
||||
keyMap *KeyMap
|
||||
@ -332,7 +335,7 @@ func (h *HelpOverlay) setupTitleAndButton() {
|
||||
h.text = append(h.text, newLabel)
|
||||
}
|
||||
|
||||
func (h *HelpOverlay) setupBulletedList() {
|
||||
func (h *HelpOverlay) updateBulletText() {
|
||||
// Bullets
|
||||
// the hotkeys displayed here should be pulled from a mapping of input events to game events
|
||||
// https://github.com/OpenDiablo2/OpenDiablo2/issues/793
|
||||
@ -378,17 +381,35 @@ func (h *HelpOverlay) setupBulletedList() {
|
||||
)},
|
||||
}
|
||||
|
||||
for idx := range callouts {
|
||||
for i := 0; i < bullets; i++ {
|
||||
h.bullets[i].SetText(callouts[i].text)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *HelpOverlay) setupBulletedList() {
|
||||
for idx := 0; idx < bullets; idx++ {
|
||||
listItemOffsetY := idx * listItemVerticalOffset
|
||||
|
||||
h.createBullet(callout{
|
||||
LabelText: callouts[idx].text,
|
||||
LabelX: listRootX,
|
||||
LabelY: listRootY + listItemOffsetY,
|
||||
DotX: listBulletX,
|
||||
DotY: listBulletRootY + listItemOffsetY,
|
||||
})
|
||||
label := h.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteSky)
|
||||
label.SetPosition(listRootX, listRootY+listItemOffsetY)
|
||||
h.bullets[idx] = label
|
||||
h.panelGroup.AddWidget(h.bullets[idx])
|
||||
|
||||
newDot, err := h.uiManager.NewSprite(d2resource.HelpYellowBullet, d2resource.PaletteSky)
|
||||
if err != nil {
|
||||
h.Error(err.Error())
|
||||
}
|
||||
|
||||
err = newDot.SetCurrentFrame(0)
|
||||
if err != nil {
|
||||
h.Error(err.Error())
|
||||
}
|
||||
|
||||
newDot.SetPosition(listBulletX, listBulletRootY+listItemOffsetY+bulletOffsetY)
|
||||
|
||||
h.frames = append(h.frames, newDot)
|
||||
}
|
||||
h.updateBulletText()
|
||||
}
|
||||
|
||||
// nolint:funlen // can't reduce
|
||||
@ -553,26 +574,6 @@ type callout struct {
|
||||
DotY int
|
||||
}
|
||||
|
||||
func (h *HelpOverlay) createBullet(c callout) {
|
||||
newLabel := h.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteSky)
|
||||
newLabel.SetText(c.LabelText)
|
||||
newLabel.SetPosition(c.LabelX, c.LabelY)
|
||||
h.text = append(h.text, newLabel)
|
||||
|
||||
newDot, err := h.uiManager.NewSprite(d2resource.HelpYellowBullet, d2resource.PaletteSky)
|
||||
if err != nil {
|
||||
h.Error(err.Error())
|
||||
}
|
||||
|
||||
err = newDot.SetCurrentFrame(0)
|
||||
if err != nil {
|
||||
h.Error(err.Error())
|
||||
}
|
||||
|
||||
newDot.SetPosition(c.DotX, c.DotY+bulletOffsetY)
|
||||
h.frames = append(h.frames, newDot)
|
||||
}
|
||||
|
||||
func (h *HelpOverlay) createLabel(c callout) {
|
||||
newLabel := h.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteSky)
|
||||
newLabel.SetText(c.LabelText)
|
||||
@ -631,3 +632,8 @@ func (h *HelpOverlay) Render(target d2interface.Surface) {
|
||||
target.Pop()
|
||||
}
|
||||
}
|
||||
|
||||
func (h *HelpOverlay) updateKeyMap(km *KeyMap) {
|
||||
h.keyMap = km
|
||||
h.updateBulletText()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user