gui

package
v0.0.0-...-126e10b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 17 Imported by: 0

README

GUI Manager

The purpose of this Service Mesh service is to provide a GUI which integrates with the raylib renderer and exposes itself as a renderable layer.

The GUI manager maintains a "node tree", where each node can (optionally) do the following: (1) have a function that yields an image.Image, and (2) have an update function.

The GUI manager has a configurable refresh rate. There is a root node that all nodes are attached to by default. The root node will update all its children. When the renderer picks up the GUI manager, the resulting image is a composite of the root node and all of its child images.

Dependencies

This service has dependencies on all other Diablo2 file-loader services:

Integration with other services

This service integrates with the following services:

The raylib renderer integration is mandatory considering that the renderer init is part of the dependency resoltuion loop.


This service exports an integration interface ManagesGui with an alias Dependencncy which are intended to be used by other services for dependency resolution (see servicemesh.HasDependencies), and expose just the methods which other services should use.

type Dependency = ManagesGui

type ManagesGui interface {
    NewNode() node
    Nodes() []node
    Update()
}

Other services can use this GUI manager as a dependency for creating UI nodes. The actual implementation of the update function and the function that yields the image.Image for the node are not a concern of this service. Other services or modules would use this abstraction to build actual UI stuff, this service is just managing the node tree and compositing the root node into an image for the renderer.

The GUI node is an exported interface:

type inputHandler interface {
    InputVector() InputState
    SetInputVector(InputState)
    ClearInputVectors()
    
    Handler() func()
    SetHandler(func())
}

type element interface {
    inputHandler
    
    UUID() uuid.UUID
    
    Enable()
    Disable()
    IsEnabled() bool
    
    Position() (point image.Point)
    SetPosition(point image.Point)
}

type node interface {
    element
    
    Parent() node
    SetParent(node)
    
    Children() []node
    AddChild(child node)
    RemoveChild(child node)
    
    LayerIndexOf(child node) int
    SetLayerIndexOf(child node, index int)
    
    BringToTop(child node)
    BringToBottom(child node)
    Raise(child node)
    Lower(child node)
    
    HandleInput(InputState) (terminate bool)
    
    Image() image.Image
    ImageFunc() func() image.Image
    SetImageFunc(func() image.Image)
    
    Update()
    UpdateFunc() func()
    SetUpdateFunc(func())
    
    GetRelativePosition(target node) (relativePosition image.Point, found bool)
}

Lua service integration

Nothing is implemented for the lua integration, yet.

Documentation

Index

Constants

View Source
const (
	Stopped transportMode = iota
	Playing
	Paused
)
View Source
const LoopForever = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type AnimationDC6

type AnimationDC6 struct {
	DC6 *dc6.DC6

	PlayMode
	// contains filtered or unexported fields
}

func (*AnimationDC6) Advance

func (a *AnimationDC6) Advance(elapsed time.Duration)

func (*AnimationDC6) BoundingBoxOfAllFrames

func (a *AnimationDC6) BoundingBoxOfAllFrames() image.Rectangle

BoundingBoxOfAllFrames returns the bounding box that encompasses all frames in the animation.

func (*AnimationDC6) BoundingBoxOfAllLayers

func (a *AnimationDC6) BoundingBoxOfAllLayers() (r image.Rectangle)

BoundingBoxOfAllLayers returns the bounding box that encompasses all frames in all layers (directions).

func (*AnimationDC6) BoundingBoxOfCurrentFrame

func (a *AnimationDC6) BoundingBoxOfCurrentFrame() image.Rectangle

BoundingBoxOfCurrentFrame returns the bounding box of the current frame.

func (*AnimationDC6) BoundingBoxOfCurrentLayer

func (a *AnimationDC6) BoundingBoxOfCurrentLayer() image.Rectangle

BoundingBoxOfCurrentLayer returns the bounding box that encompasses all frames in the current layer (direction).

func (*AnimationDC6) CurrentFrameIndex

func (a *AnimationDC6) CurrentFrameIndex() int

func (*AnimationDC6) CurrentLayerIndex

func (a *AnimationDC6) CurrentLayerIndex() int

func (*AnimationDC6) Destroy

func (a *AnimationDC6) Destroy()

func (*AnimationDC6) Direction

func (a *AnimationDC6) Direction() int

func (*AnimationDC6) Duration

func (a *AnimationDC6) Duration() time.Duration

func (*AnimationDC6) FramesPerSecond

func (a *AnimationDC6) FramesPerSecond() float32

func (*AnimationDC6) LoopCount

func (a *AnimationDC6) LoopCount() int

func (*AnimationDC6) LoopingMode

func (a *AnimationDC6) LoopingMode() LoopingMode

func (*AnimationDC6) NumDirections

func (a *AnimationDC6) NumDirections() int

func (*AnimationDC6) NumFrames

func (a *AnimationDC6) NumFrames() int

func (*AnimationDC6) NumLayers

func (a *AnimationDC6) NumLayers() int

func (*AnimationDC6) NumTimesLooped

func (a *AnimationDC6) NumTimesLooped() int

func (*AnimationDC6) Pause

func (a *AnimationDC6) Pause()

func (*AnimationDC6) Play

func (a *AnimationDC6) Play()

func (*AnimationDC6) Renderable

func (a *AnimationDC6) Renderable() raylibRenderer.Renderable

func (*AnimationDC6) SetCurrentFrameIndex

func (a *AnimationDC6) SetCurrentFrameIndex(i int)

func (*AnimationDC6) SetCurrentLayerIndex

func (a *AnimationDC6) SetCurrentLayerIndex(i int)

func (*AnimationDC6) SetDirection

func (a *AnimationDC6) SetDirection(i int)

func (*AnimationDC6) SetDuration

func (a *AnimationDC6) SetDuration(duration time.Duration)

func (*AnimationDC6) SetFramesPerSecond

func (a *AnimationDC6) SetFramesPerSecond(f float32)

func (*AnimationDC6) SetLoopCount

func (a *AnimationDC6) SetLoopCount(i int)

func (*AnimationDC6) SetLoopingMode

func (a *AnimationDC6) SetLoopingMode(m LoopingMode)

func (*AnimationDC6) SetPlayMode

func (a *AnimationDC6) SetPlayMode(mode PlayMode)

func (*AnimationDC6) SetSubLoopFrames

func (a *AnimationDC6) SetSubLoopFrames(indices []int)

func (*AnimationDC6) SetSubLoopRange

func (a *AnimationDC6) SetSubLoopRange(firstFrame, lastFrame int)

func (*AnimationDC6) Start

func (a *AnimationDC6) Start()

func (*AnimationDC6) Stop

func (a *AnimationDC6) Stop()

func (*AnimationDC6) SubLoopFrames

func (a *AnimationDC6) SubLoopFrames() []int

func (*AnimationDC6) SubLoopRange

func (a *AnimationDC6) SubLoopRange() (firstFrame, lastFrame int)

type Dependency

type Dependency = ManagesGui

type InputState

type InputState struct {
	Keys         []Key
	ModifierKeys []ModifierKey
	MouseButtons []MouseButton
	MouseCursor  image.Point
}

type Key

type Key int

type LoopingMode

type LoopingMode int
const (
	NotLooping LoopingMode = iota
	Looping
	LoopingSpecificFrames
)

type ManagesGui

type ManagesGui interface {
	servicemesh.Service
	// contains filtered or unexported methods
}

type ModifierKey

type ModifierKey int

type MouseButton

type MouseButton int

type PlayMode

type PlayMode int
const (
	PlayForward PlayMode = iota
	PlayBackward
	PlayYoYo
)

type Service

type Service struct {
	// contains filtered or unexported fields
}

func (*Service) ConfigFileName

func (s *Service) ConfigFileName() string

func (*Service) DefaultConfig

func (s *Service) DefaultConfig() (cfg configFile.Config)

func (*Service) DependenciesResolved

func (s *Service) DependenciesResolved() bool

func (*Service) ExportToLua

func (s *Service) ExportToLua(state *lua.LState)

func (*Service) Init

func (s *Service) Init(mesh servicemesh.Mesh)

func (*Service) LoadConfig

func (s *Service) LoadConfig(config *configFile.Config)

func (*Service) Logger

func (s *Service) Logger() *slog.Logger

func (*Service) Name

func (s *Service) Name() string

func (*Service) NewAnimationDC6

func (s *Service) NewAnimationDC6(dc6Path, pl2Path string) (*AnimationDC6, error)

func (*Service) NewTileSprite

func (s *Service) NewTileSprite(dc6Path, pl2Path string, gridWidth, gridHeight int) (ts *TileSprite, err error)

func (*Service) Ready

func (s *Service) Ready() bool

func (*Service) ResolveDependencies

func (s *Service) ResolveDependencies(services []servicemesh.Service)

func (*Service) SetLogger

func (s *Service) SetLogger(logger *slog.Logger)

func (*Service) UnexportFromLua

func (s *Service) UnexportFromLua(state *lua.LState)

type TileSprite

type TileSprite struct {
	DC6 *dc6.DC6
	// contains filtered or unexported fields
}

func (*TileSprite) Renderable

func (ts *TileSprite) Renderable() raylibRenderer.Renderable

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL