2020-10-22 01:12:06 -04:00
|
|
|
// Package help contains the in-game diablo2 help panel
|
2020-09-09 08:21:27 -04:00
|
|
|
package help
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"image/color"
|
2020-09-23 13:30:54 -04:00
|
|
|
"log"
|
2020-09-09 08:21:27 -04:00
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2tbl"
|
2020-09-09 08:21:27 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
|
|
|
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2gui"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
tlCornerFrame = iota
|
|
|
|
lFrame
|
|
|
|
tFrameLHalf
|
|
|
|
tFrameRHalf
|
|
|
|
trCornerFrameTHalf
|
|
|
|
trCornerFrameRHalf
|
|
|
|
rFrame
|
|
|
|
)
|
|
|
|
|
2020-09-18 16:10:52 -04:00
|
|
|
// Overlay represents the in-game overlay that toggles visibility when the h key is pressed
|
2020-09-09 08:21:27 -04:00
|
|
|
type Overlay struct {
|
2020-09-15 23:37:08 -04:00
|
|
|
asset *d2asset.AssetManager
|
|
|
|
isOpen bool
|
|
|
|
renderer d2interface.Renderer
|
|
|
|
frames []*d2ui.Sprite
|
|
|
|
text []*d2ui.Label
|
|
|
|
lines []line
|
|
|
|
uiManager *d2ui.UIManager
|
|
|
|
originX int
|
|
|
|
originY int
|
|
|
|
layout *d2gui.Layout
|
|
|
|
closeButton *d2ui.Button
|
2020-09-18 16:10:52 -04:00
|
|
|
guiManager *d2gui.GuiManager
|
2020-09-09 08:21:27 -04:00
|
|
|
}
|
|
|
|
|
2020-09-18 16:10:52 -04:00
|
|
|
func NewHelpOverlay(
|
|
|
|
asset *d2asset.AssetManager,
|
|
|
|
renderer d2interface.Renderer,
|
|
|
|
ui *d2ui.UIManager,
|
|
|
|
guiManager *d2gui.GuiManager,
|
|
|
|
) *Overlay {
|
2020-09-09 08:21:27 -04:00
|
|
|
h := &Overlay{
|
2020-09-18 16:10:52 -04:00
|
|
|
asset: asset,
|
|
|
|
renderer: renderer,
|
|
|
|
uiManager: ui,
|
|
|
|
guiManager: guiManager,
|
2020-09-09 08:21:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return h
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Overlay) Toggle() {
|
|
|
|
fmt.Print("Help overlay toggled\n")
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
if h.isOpen {
|
|
|
|
h.close()
|
|
|
|
} else {
|
|
|
|
h.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Overlay) close() {
|
|
|
|
h.isOpen = false
|
2020-09-15 23:37:08 -04:00
|
|
|
h.closeButton.SetVisible(false)
|
2020-09-18 16:10:52 -04:00
|
|
|
h.guiManager.SetLayout(nil)
|
2020-09-09 08:21:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Overlay) open() {
|
|
|
|
h.isOpen = true
|
|
|
|
if h.layout == nil {
|
2020-09-18 16:10:52 -04:00
|
|
|
h.layout = d2gui.CreateLayout(h.renderer, d2gui.PositionTypeHorizontal, h.asset)
|
2020-09-15 23:37:08 -04:00
|
|
|
}
|
2020-09-09 08:21:27 -04:00
|
|
|
|
2020-09-15 23:37:08 -04:00
|
|
|
h.closeButton.SetVisible(true)
|
|
|
|
h.closeButton.SetPressed(false)
|
2020-09-09 08:21:27 -04:00
|
|
|
|
2020-09-18 16:10:52 -04:00
|
|
|
h.guiManager.SetLayout(h.layout)
|
2020-09-09 08:21:27 -04:00
|
|
|
}
|
|
|
|
|
2020-09-15 23:37:08 -04:00
|
|
|
func (h *Overlay) IsOpen() bool {
|
|
|
|
return h.isOpen
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Overlay) IsInRect(px, py int) bool {
|
2020-10-07 21:20:05 -04:00
|
|
|
|
|
|
|
ww, hh := h.layout.GetSize()
|
|
|
|
x, y := h.layout.GetPosition()
|
2020-09-15 23:37:08 -04:00
|
|
|
|
|
|
|
if px >= x && px <= x+ww && py >= y && py <= y+hh {
|
|
|
|
return true
|
|
|
|
}
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-15 23:37:08 -04:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
func (h *Overlay) Load() {
|
|
|
|
|
|
|
|
var (
|
|
|
|
x = 0
|
|
|
|
y = 0
|
|
|
|
prevX = 0
|
|
|
|
prevY = 0
|
|
|
|
)
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
for frameIndex := 0; frameIndex < 7; frameIndex++ {
|
2020-09-23 13:30:54 -04:00
|
|
|
f, err := h.uiManager.NewSprite(d2resource.HelpBorder, d2resource.PaletteSky)
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = f.SetCurrentFrame(frameIndex)
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
2020-09-09 08:21:27 -04:00
|
|
|
|
|
|
|
ww, hh := f.GetCurrentFrameSize()
|
|
|
|
//fmt.Printf("Help frame %d size: %d, %d\n", frameIndex, ww, hh)
|
|
|
|
|
|
|
|
switch frameIndex {
|
|
|
|
case tlCornerFrame:
|
|
|
|
y = hh
|
|
|
|
case lFrame:
|
|
|
|
y = hh + prevY
|
|
|
|
case tFrameLHalf:
|
|
|
|
y = hh
|
|
|
|
x = 65
|
|
|
|
case tFrameRHalf:
|
|
|
|
y = hh
|
|
|
|
x = 800 - ww - 245
|
|
|
|
case trCornerFrameTHalf:
|
|
|
|
y = hh
|
|
|
|
x = 800 - ww - 20
|
|
|
|
case trCornerFrameRHalf:
|
|
|
|
y = hh
|
|
|
|
x = 800 - ww
|
|
|
|
case rFrame:
|
|
|
|
y = hh + prevY
|
|
|
|
x = 800 - ww
|
|
|
|
}
|
|
|
|
|
|
|
|
//y += 50
|
|
|
|
|
|
|
|
_ = prevX
|
|
|
|
|
|
|
|
prevX = x
|
|
|
|
prevY = y
|
|
|
|
f.SetPosition(x, y)
|
|
|
|
h.frames = append(h.frames, f)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Title
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
text := d2tbl.TranslateString("Strhelp1") // "Diablo II Help"
|
2020-09-09 08:21:27 -04:00
|
|
|
newLabel := h.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteSky)
|
|
|
|
newLabel.SetText(text)
|
|
|
|
ww, _ := newLabel.GetSize()
|
|
|
|
newLabel.SetPosition((800/2)-(ww/2)-30, 0)
|
|
|
|
h.text = append(h.text, newLabel)
|
|
|
|
|
|
|
|
// Close
|
2020-09-15 23:37:08 -04:00
|
|
|
|
2020-09-20 02:54:24 -04:00
|
|
|
h.closeButton = h.uiManager.NewButton(d2ui.ButtonTypeSquareClose, "")
|
2020-09-15 23:37:08 -04:00
|
|
|
h.closeButton.SetPosition(685, 25)
|
|
|
|
h.closeButton.SetVisible(false)
|
|
|
|
h.closeButton.OnActivated(func() { h.close() })
|
2020-09-09 08:21:27 -04:00
|
|
|
|
|
|
|
newLabel = h.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteSky)
|
2020-09-26 11:14:34 -04:00
|
|
|
newLabel.SetText(d2tbl.TranslateString("strClose")) // "Close"
|
2020-09-09 08:21:27 -04:00
|
|
|
newLabel.SetPosition(680, 60)
|
|
|
|
h.text = append(h.text, newLabel)
|
|
|
|
|
|
|
|
// Bullets
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
yOffset := 59
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
h.createBullet(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: fmt.Sprintf(d2tbl.TranslateString("StrHelp2"), "Ctrl"), // TODO "Ctrl" should be hotkey // "Hold Down <%s> to Run"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 100,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: yOffset - 10,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 100 - 12,
|
|
|
|
DotY: yOffset,
|
|
|
|
})
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
yOffset += 20
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
h.createBullet(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: fmt.Sprintf(d2tbl.TranslateString("StrHelp3"), "Alt"), // TODO "Alt" should be hotkey // "Hold down <%s> to highlight items on the ground"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 100,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: yOffset - 10,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 100 - 12,
|
|
|
|
DotY: yOffset,
|
|
|
|
})
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
yOffset += 20
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
h.createBullet(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: fmt.Sprintf(d2tbl.TranslateString("StrHelp4"), "Shift"), // TODO "Shift" should be hotkey // "Hold down <%s> to attack while standing still"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 100,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: yOffset - 10,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 100 - 12,
|
|
|
|
DotY: yOffset,
|
|
|
|
})
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
yOffset += 20
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
h.createBullet(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: fmt.Sprintf(d2tbl.TranslateString("StrHelp5"), "Tab"), // TODO "Tab" should be hotkey // "Hit <%s> to toggle the automap on and off"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 100,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: yOffset - 10,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 100 - 12,
|
|
|
|
DotY: yOffset,
|
|
|
|
})
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
yOffset += 20
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
h.createBullet(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp6"), // "Hit <Esc> to bring up the Game Menu"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 100,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: yOffset - 10,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 100 - 12,
|
|
|
|
DotY: yOffset,
|
|
|
|
})
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
yOffset += 20
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
h.createBullet(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp7"), // "Hit <Enter> to go into chat mode"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 100,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: yOffset - 10,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 100 - 12,
|
|
|
|
DotY: yOffset,
|
|
|
|
})
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
yOffset += 20
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
h.createBullet(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp8"), // "Hit F1-F8 to set your Left or Right Mouse Buttton Skills."
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 100,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: yOffset - 10,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 100 - 12,
|
|
|
|
DotY: yOffset,
|
|
|
|
})
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
yOffset += 20
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
h.createBullet(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: fmt.Sprintf(d2tbl.TranslateString("StrHelp8a"), "H"), // TODO "H" should be hotkey
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 100,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: yOffset - 10,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 100 - 12,
|
|
|
|
DotY: yOffset,
|
|
|
|
})
|
|
|
|
|
|
|
|
// Callouts
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("strlvlup"), // "New Stats"
|
|
|
|
LabelX: 222,
|
|
|
|
LabelY: 355,
|
|
|
|
DotX: 217,
|
|
|
|
DotY: 574,
|
2020-09-09 08:21:27 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("strnewskl"), // "New Skill"
|
|
|
|
LabelX: 578,
|
|
|
|
LabelY: 355,
|
|
|
|
DotX: 573,
|
|
|
|
DotY: 574,
|
|
|
|
})
|
|
|
|
|
|
|
|
// Some of the help fonts require mulktiple lines.
|
|
|
|
h.createLabel(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp10"), // "Left Mouse-"
|
|
|
|
LabelX: 135,
|
|
|
|
LabelY: 382,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createLabel(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp11"), // "Button Skill"
|
|
|
|
LabelX: 135,
|
|
|
|
LabelY: 397,
|
2020-09-09 08:21:27 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp12"), // "(Click to Change)"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 135,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: 412,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 130,
|
|
|
|
DotY: 565,
|
|
|
|
})
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
h.createLabel(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp13"), // "Right Mouse"
|
|
|
|
LabelX: 675,
|
|
|
|
LabelY: 381,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createLabel(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp11"), // "Button Skill"
|
|
|
|
LabelX: 675,
|
|
|
|
LabelY: 396,
|
2020-09-09 08:21:27 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp12"), // "(Click to Change)"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 675,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: 411,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 670,
|
2020-09-26 11:14:34 -04:00
|
|
|
DotY: 562,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createLabel(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp17"), // "Mini-Panel"
|
|
|
|
LabelX: 450,
|
|
|
|
LabelY: 371,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createLabel(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp18"), // "(Opens Character,"
|
|
|
|
LabelX: 450,
|
|
|
|
LabelY: 386,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createLabel(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp19"), // "inventory, and"
|
|
|
|
LabelX: 450,
|
|
|
|
LabelY: 401,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp20"), // "other screens)"
|
|
|
|
LabelX: 450,
|
|
|
|
LabelY: 417,
|
|
|
|
DotX: 445,
|
|
|
|
DotY: 539,
|
2020-09-09 08:21:27 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp9"), // "Life Orb"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 65,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: 451,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 60,
|
2020-09-26 11:14:34 -04:00
|
|
|
DotY: 538,
|
2020-09-09 08:21:27 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp15"), // "Stamina Bar"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 315,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: 450,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 310,
|
2020-09-26 11:14:34 -04:00
|
|
|
DotY: 583,
|
2020-09-09 08:21:27 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp22"), // "Mana Orb"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 745,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: 451,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 740,
|
2020-09-26 11:14:34 -04:00
|
|
|
DotY: 538,
|
2020-09-09 08:21:27 -04:00
|
|
|
})
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
h.createLabel(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp14"), // "Run/Walk"
|
|
|
|
LabelX: 264,
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelY: 480,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp14a"), // "Toggle"
|
|
|
|
LabelX: 264,
|
|
|
|
LabelY: 495,
|
|
|
|
DotX: 259,
|
|
|
|
DotY: 583,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createLabel(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp16"), // "Experience"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 370,
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelY: 476,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
|
|
|
LabelText: d2tbl.TranslateString("StrHelp16a"), // "Bar"
|
|
|
|
LabelX: 370,
|
|
|
|
LabelY: 493,
|
2020-09-09 08:21:27 -04:00
|
|
|
DotX: 365,
|
|
|
|
DotY: 565,
|
|
|
|
})
|
|
|
|
|
|
|
|
h.createCallout(callout{
|
2020-09-26 11:14:34 -04:00
|
|
|
LabelText: d2tbl.TranslateString("StrHelp21"), // "Belt"
|
2020-09-09 08:21:27 -04:00
|
|
|
LabelX: 535,
|
|
|
|
LabelY: 490,
|
|
|
|
DotX: 530,
|
|
|
|
DotY: 568,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type line struct {
|
|
|
|
StartX int
|
|
|
|
StartY int
|
|
|
|
MoveX int
|
|
|
|
MoveY int
|
|
|
|
Color color.Color
|
|
|
|
}
|
|
|
|
|
|
|
|
type callout struct {
|
|
|
|
LabelText string
|
|
|
|
LabelX int
|
|
|
|
LabelY int
|
|
|
|
DotX int
|
|
|
|
DotY int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Overlay) createBullet(c callout) {
|
2020-09-26 11:14:34 -04:00
|
|
|
newLabel := h.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteSky)
|
2020-09-09 08:21:27 -04:00
|
|
|
newLabel.SetText(c.LabelText)
|
|
|
|
//ww, hh = newLabel.GetSize()
|
|
|
|
newLabel.SetPosition(c.LabelX, c.LabelY)
|
|
|
|
h.text = append(h.text, newLabel)
|
|
|
|
|
2020-09-23 13:30:54 -04:00
|
|
|
newDot, err := h.uiManager.NewSprite(d2resource.HelpYellowBullet, d2resource.PaletteSky)
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = newDot.SetCurrentFrame(0)
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
newDot.SetPosition(c.DotX, c.DotY+14)
|
|
|
|
h.frames = append(h.frames, newDot)
|
|
|
|
}
|
|
|
|
|
2020-09-26 11:14:34 -04:00
|
|
|
func (h *Overlay) createLabel(c callout) {
|
|
|
|
newLabel := h.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteSky)
|
|
|
|
newLabel.SetText(c.LabelText)
|
|
|
|
//ww, hh = newLabel.GetSize()
|
|
|
|
newLabel.SetPosition(c.LabelX, c.LabelY)
|
|
|
|
h.text = append(h.text, newLabel)
|
|
|
|
newLabel.Alignment = d2gui.HorizontalAlignCenter
|
|
|
|
}
|
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
func (h *Overlay) createCallout(c callout) {
|
2020-09-26 11:14:34 -04:00
|
|
|
newLabel := h.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteSky)
|
2020-09-15 23:37:08 -04:00
|
|
|
newLabel.Color[0] = color.White
|
2020-09-09 08:21:27 -04:00
|
|
|
newLabel.SetText(c.LabelText)
|
|
|
|
newLabel.SetPosition(c.LabelX, c.LabelY)
|
|
|
|
newLabel.Alignment = d2gui.HorizontalAlignCenter
|
|
|
|
ww, hh := newLabel.GetTextMetrics(c.LabelText)
|
|
|
|
h.text = append(h.text, newLabel)
|
|
|
|
_ = ww
|
|
|
|
|
|
|
|
l := line{
|
|
|
|
StartX: c.LabelX,
|
|
|
|
StartY: c.LabelY + hh + 5,
|
|
|
|
MoveX: 0,
|
|
|
|
MoveY: c.DotY - c.LabelY - hh - 5,
|
|
|
|
Color: color.White,
|
|
|
|
}
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
h.lines = append(h.lines, l)
|
|
|
|
|
2020-09-23 13:30:54 -04:00
|
|
|
newDot, err := h.uiManager.NewSprite(d2resource.HelpWhiteBullet, d2resource.PaletteSky)
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = newDot.SetCurrentFrame(0)
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
|
|
|
|
2020-09-09 08:21:27 -04:00
|
|
|
newDot.SetPosition(c.DotX, c.DotY)
|
|
|
|
h.frames = append(h.frames, newDot)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Overlay) Render(target d2interface.Surface) error {
|
|
|
|
if !h.isOpen {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, f := range h.frames {
|
2020-09-23 13:30:54 -04:00
|
|
|
err := f.Render(target)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-09 08:21:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, t := range h.text {
|
|
|
|
t.Render(target)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, l := range h.lines {
|
|
|
|
target.PushTranslation(l.StartX, l.StartY)
|
|
|
|
target.DrawLine(l.MoveX, l.MoveY, l.Color)
|
|
|
|
target.Pop()
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|