2020-01-31 23:18:11 -05:00
|
|
|
package d2ui
|
|
|
|
|
|
|
|
import (
|
2020-06-28 19:31:10 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
2020-11-21 05:33:22 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
2020-09-12 16:51:30 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
2020-01-31 23:18:11 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// CursorButton represents a mouse button
|
|
|
|
type CursorButton uint8
|
|
|
|
|
2020-11-21 05:33:22 -05:00
|
|
|
const (
|
|
|
|
logPrefix = "UI Manager"
|
|
|
|
)
|
|
|
|
|
2020-01-31 23:18:11 -05:00
|
|
|
const (
|
|
|
|
// CursorButtonLeft represents the left mouse button
|
|
|
|
CursorButtonLeft CursorButton = 1
|
|
|
|
// CursorButtonRight represents the right mouse button
|
|
|
|
CursorButtonRight CursorButton = 2
|
|
|
|
)
|
|
|
|
|
2020-11-13 15:03:30 -05:00
|
|
|
// HorizontalAlign type, determines alignment along x-axis within a layout
|
|
|
|
type HorizontalAlign int
|
|
|
|
|
|
|
|
// Horizontal alignment types
|
|
|
|
const (
|
|
|
|
HorizontalAlignLeft HorizontalAlign = iota
|
|
|
|
HorizontalAlignCenter
|
|
|
|
HorizontalAlignRight
|
|
|
|
)
|
|
|
|
|
2020-08-06 10:30:23 -04:00
|
|
|
// NewUIManager creates a UIManager instance with the given input and audio provider
|
|
|
|
func NewUIManager(
|
2020-09-12 16:51:30 -04:00
|
|
|
asset *d2asset.AssetManager,
|
2020-08-06 10:30:23 -04:00
|
|
|
renderer d2interface.Renderer,
|
|
|
|
input d2interface.InputManager,
|
2020-11-21 05:33:22 -05:00
|
|
|
l d2util.LogLevel,
|
2020-08-06 10:30:23 -04:00
|
|
|
audio d2interface.AudioProvider,
|
|
|
|
) *UIManager {
|
|
|
|
ui := &UIManager{
|
2020-09-12 16:51:30 -04:00
|
|
|
asset: asset,
|
2020-08-06 10:30:23 -04:00
|
|
|
renderer: renderer,
|
|
|
|
inputManager: input,
|
|
|
|
audio: audio,
|
2020-06-23 18:12:08 -04:00
|
|
|
}
|
2020-01-31 23:18:11 -05:00
|
|
|
|
2020-11-21 05:33:22 -05:00
|
|
|
ui.Logger = d2util.NewLogger()
|
|
|
|
ui.Logger.SetPrefix(logPrefix)
|
|
|
|
ui.Logger.SetLevel(l)
|
|
|
|
|
2020-08-06 10:30:23 -04:00
|
|
|
return ui
|
2020-01-31 23:18:11 -05:00
|
|
|
}
|