1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-10 09:50:42 +00:00
This commit is contained in:
Tim Sarbin 2020-06-25 17:28:48 -04:00 committed by GitHub
parent 48a193579f
commit 226181ffcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 13 deletions

View File

@ -138,7 +138,7 @@ func (l *Layout) Clear() {
}
func (l *Layout) render(target d2render.Surface) error {
l.adjustEntryPlacement()
l.AdjustEntryPlacement()
for _, entry := range l.entries {
if !entry.widget.isVisible() {
@ -295,7 +295,7 @@ func (l *Layout) adjustEntryEvent(entry *layoutEntry, eventX, eventY *int) bool
return true
}
func (l *Layout) adjustEntryPlacement() {
func (l *Layout) AdjustEntryPlacement() {
width, height := l.getSize()
var expanderCount int

View File

@ -46,6 +46,9 @@ func createGuiManager() (*manager, error) {
func (m *manager) SetLayout(layout *Layout) {
m.layout = layout
if m.layout != nil {
m.layout.AdjustEntryPlacement()
}
}
func (m *manager) OnMouseButtonDown(event d2input.MouseEvent) bool {

View File

@ -21,7 +21,6 @@ type widget interface {
onMouseButtonClick(event d2input.MouseEvent) bool
getPosition() (int, int)
getOffset() (int, int)
setOffset(x, y int)
getSize() (int, int)
getLayer() int
@ -57,10 +56,6 @@ func (w *widgetBase) GetOffset() (int, int) {
return w.offsetX, w.offsetY
}
func (w *widgetBase) getOffset() (int, int) {
return w.offsetX, w.offsetY
}
func (w *widgetBase) setOffset(x, y int) {
w.offsetX = x
w.offsetY = y

View File

@ -27,7 +27,7 @@ type Label struct {
Height int
Alignment LabelAlignment
font *Font
imageData d2render.Surface
imageData map[string]d2render.Surface
Color color.Color
}
@ -37,7 +37,9 @@ func CreateLabel(fontPath, palettePath string) Label {
Alignment: LabelAlignLeft,
Color: color.White,
font: GetFont(fontPath, palettePath),
imageData: make(map[string]d2render.Surface),
}
return result
}
@ -60,7 +62,7 @@ func (v *Label) Render(target d2render.Surface) {
target.PushTranslation(x, y)
defer target.PopN(3)
target.Render(v.imageData)
target.Render(v.imageData[v.text])
}
// SetPosition moves the label to the specified location
@ -74,14 +76,14 @@ func (v *Label) GetTextMetrics(text string) (width, height int) {
}
func (v *Label) cacheImage() {
if v.imageData != nil {
if v.imageData[v.text] != nil {
return
}
width, height := v.font.GetTextMetrics(v.text)
v.Width = width
v.Height = height
v.imageData, _ = d2render.NewSurface(width, height, d2render.FilterNearest)
surface, _ := d2render.CreateSurface(v.imageData)
v.imageData[v.text], _ = d2render.NewSurface(width, height, d2render.FilterNearest)
surface, _ := d2render.CreateSurface(v.imageData[v.text])
v.font.Render(0, 0, v.text, v.Color, surface)
}
@ -91,7 +93,6 @@ func (v *Label) SetText(newText string) {
return
}
v.text = newText
v.imageData = nil
}
// Size returns the size of the label

View File

@ -364,6 +364,7 @@ func (m *EscapeMenu) setLayout(id layoutID) {
m.currentLayout = id
m.layouts[id].currentEl = 0
d2gui.SetLayout(m.layouts[id].Layout)
m.onHoverElement(0)
}
func (m *EscapeMenu) onUpKey() {