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