mistergui

package
v0.0.0-...-c88d184 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BGR8BytesPerPixel int = 3
View Source
var BGR8Model color.Model = color.ModelFunc(bgr8Model)
View Source
var DefaultListRender = func(list *List) {
	items := list.PageItems()
	textStrings := make([]string, 0)
	for _, item := range items {
		line := item.Label()
		if list.IsCurrentItem(item) {
			line = "> " + item.Label()
		}
		textStrings = append(textStrings, line)

	}
	surface := list.guiState.Surface
	surface.Erase(surface.Image.Rect, P0)
	img := DrawText(textStrings, surface.Image.Rect, image.Transparent)
	draw.Draw(surface.Image, surface.Image.Rect, img, P0, draw.Over)

	btnLabel := []string{list.CurrentItem().ButtonsLabel()}
	surfRect := surface.Image.Rect
	labelRect := image.Rect(0, 0, surfRect.Max.X, 30)
	btnLabelImg := DrawText(btnLabel, labelRect, image.Transparent)
	draw.Draw(surface.Image, image.Rect(0, 202, surfRect.Max.X, 232), btnLabelImg, P0, draw.Over)

}
View Source
var ImageNull image.Image = image.NewNRGBA(image.Rect(0, 0, 0, 0))
View Source
var LoadingImage image.Image = image.NewNRGBA(image.Rect(0, 0, 0, 0))
View Source
var P0 image.Point = image.Point{0, 0}
View Source
var PtSansRegular *truetype.Font = parseFont(*Embeds.PtSansRegular)

Functions

func DecodeImageBytes

func DecodeImageBytes(imageBytes *[]byte) (*image.Image, error)

func DecodeImageBytesFit

func DecodeImageBytesFit(imageBytes *[]byte) (*image.Image, error)

func DrawText

func DrawText(text []string, rect image.Rectangle, bg *image.Uniform) *image.NRGBA

func ScanMGDBGames

func ScanMGDBGames(client *mgdb.MGDBClient) (chan string, chan bool)

Utility method for collection scanning

Types

type AsyncCallback

type AsyncCallback func(gui *GUI)

type BGR8

type BGR8 struct {
	// Pix holds the image's pixels, in R, G, B, A order. The pixel at
	// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*4].
	Pix []uint8
	// Stride is the Pix stride (in bytes) between vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

BGR8 is an in-memory image whose At method returns color.BGR8 values.

func NewBGR8

func NewBGR8(r image.Rectangle) *BGR8

NewBGR8 returns a new BGR8 image with the given bounds.

func (*BGR8) At

func (p *BGR8) At(x, y int) color.Color

func (*BGR8) BGR8At

func (p *BGR8) BGR8At(x, y int) ColorBGR8

func (*BGR8) Bounds

func (p *BGR8) Bounds() image.Rectangle

func (*BGR8) ColorModel

func (p *BGR8) ColorModel() color.Model

func (*BGR8) NRGBAAt

func (p *BGR8) NRGBAAt(x, y int) color.NRGBA

func (*BGR8) Opaque

func (p *BGR8) Opaque() bool

Opaque scans the entire image and reports whether it is fully opaque.

func (*BGR8) PixOffset

func (p *BGR8) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*BGR8) RGBA64At

func (p *BGR8) RGBA64At(x, y int) color.RGBA64

func (*BGR8) Set

func (p *BGR8) Set(x, y int, c color.Color)

func (*BGR8) SetNRGBA

func (p *BGR8) SetNRGBA(x, y int, c color.NRGBA)

func (*BGR8) SetRGBA64

func (p *BGR8) SetRGBA64(x, y int, c color.RGBA64)

func (*BGR8) SubImage

func (p *BGR8) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type BasicListItem

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

func (*BasicListItem) ButtonsLabel

func (item *BasicListItem) ButtonsLabel() string

func (*BasicListItem) Label

func (item *BasicListItem) Label() string

func (*BasicListItem) List

func (item *BasicListItem) List() *List

func (*BasicListItem) OnEnter

func (item *BasicListItem) OnEnter()

func (*BasicListItem) OnExit

func (item *BasicListItem) OnExit()

func (*BasicListItem) OnTick

func (item *BasicListItem) OnTick()

type ColorBGR8

type ColorBGR8 struct {
	B, G, R uint8
}

func ColorToBGR8

func ColorToBGR8(c color.Color) ColorBGR8

func (ColorBGR8) RGBA

func (c ColorBGR8) RGBA() (r, g, b, a uint32)

type ConsoleState

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

type EmbededData

type EmbededData struct {
	PtSansRegular *[]byte
	ListingBg     *[]byte
}
var Embeds *EmbededData = &EmbededData{
	PtSansRegular: &ptSansRegular,
	ListingBg:     &listingBg,
}

type GUI

type GUI struct {
	State     *GUIState
	QuitChan  chan bool
	UdpClient *groovymister.UdpClient
}

func (*GUI) OnTick

func (gui *GUI) OnTick(tick TickData)

func (*GUI) Setup

func (gui *GUI) Setup(
	modeline *groovymister.Modeline,
	settings *settings.Settings,
	udpClient *groovymister.UdpClient,
	quitChan chan bool,
)

func (*GUI) TearDown

func (gui *GUI) TearDown()

type GUIState

type GUIState struct {
	Screen    IScreen
	IsChanged bool
	IsLoading bool
	Surface   *Surface
	Input     *groovymister.GroovyInput
	Modeline  *groovymister.Modeline
	QuitChan  chan bool
	Settings  *settings.Settings
}

func (*GUIState) PopScreen

func (state *GUIState) PopScreen()

func (*GUIState) PushScreen

func (state *GUIState) PushScreen(newScreen IScreen)

type GameListItem

type GameListItem struct {
	Game mgdb.Game
	// contains filtered or unexported fields
}

func (*GameListItem) ButtonsLabel

func (item *GameListItem) ButtonsLabel() string

func (*GameListItem) Label

func (item *GameListItem) Label() string

func (*GameListItem) List

func (item *GameListItem) List() *List

func (*GameListItem) OnEnter

func (item *GameListItem) OnEnter()

func (*GameListItem) OnExit

func (item *GameListItem) OnExit()

func (*GameListItem) OnTick

func (item *GameListItem) OnTick()

type IListItem

type IListItem interface {
	List() *List
	Label() string
	OnEnter()
	OnExit()
	//OnCancel()
	//TearDown()
	// Rework this to be OnButton() instead of onSelect
	OnTick()
	ButtonsLabel() string
}

type IScreen

type IScreen interface {
	GUIState() *GUIState
	Name() string
	Parent() IScreen
	Setup()
	OnEnter()
	OnExit()
	OnTick(TickData)
	Render()
	TearDown()
}

type List

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

func NewList

func NewList(screen IScreen, guiState *GUIState, items []IListItem, perPage int) *List

func (*List) CurrentItem

func (list *List) CurrentItem() IListItem

func (*List) CurrentPage

func (list *List) CurrentPage() int

func (*List) IsCurrentItem

func (list *List) IsCurrentItem(item IListItem) bool

func (*List) ItemCount

func (list *List) ItemCount() int

func (*List) NextItem

func (list *List) NextItem()

func (*List) NextPage

func (list *List) NextPage()

func (*List) OnTick

func (list *List) OnTick()

func (*List) PageCount

func (list *List) PageCount() int

func (*List) PageFinalIndex

func (list *List) PageFinalIndex() int

func (*List) PageInitialIndex

func (list *List) PageInitialIndex() int

func (*List) PageItemLocalIndex

func (list *List) PageItemLocalIndex() int

func (*List) PageItems

func (list *List) PageItems() []IListItem

func (*List) PreviousItem

func (list *List) PreviousItem()

func (*List) PreviousPage

func (list *List) PreviousPage()

func (*List) Render

func (list *List) Render()

func (*List) ReplaceItems

func (list *List) ReplaceItems(items []IListItem)

func (*List) Screen

func (list *List) Screen() IScreen

type MetaView

type MetaView int
const (
	ListView MetaView = iota
	ScreenshotView
	TitleScreenView
	InfoView
	DescriptionView
)

type ScreenCollections

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

func (*ScreenCollections) GUIState

func (screen *ScreenCollections) GUIState() *GUIState

func (*ScreenCollections) Name

func (screen *ScreenCollections) Name() string

func (*ScreenCollections) OnEnter

func (screen *ScreenCollections) OnEnter()

func (*ScreenCollections) OnExit

func (screen *ScreenCollections) OnExit()

func (*ScreenCollections) OnTick

func (screen *ScreenCollections) OnTick(tick TickData)

func (*ScreenCollections) Parent

func (screen *ScreenCollections) Parent() IScreen

func (*ScreenCollections) Render

func (screen *ScreenCollections) Render()

func (*ScreenCollections) Setup

func (screen *ScreenCollections) Setup()

func (*ScreenCollections) TearDown

func (screen *ScreenCollections) TearDown()

type ScreenConsole

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

func (*ScreenConsole) GUIState

func (screen *ScreenConsole) GUIState() *GUIState

func (*ScreenConsole) Name

func (screen *ScreenConsole) Name() string

func (*ScreenConsole) OnEnter

func (screen *ScreenConsole) OnEnter()

func (*ScreenConsole) OnExit

func (screen *ScreenConsole) OnExit()

func (*ScreenConsole) OnTick

func (screen *ScreenConsole) OnTick(tick TickData)

func (*ScreenConsole) Parent

func (screen *ScreenConsole) Parent() IScreen

func (*ScreenConsole) PushText

func (screen *ScreenConsole) PushText(newLine string)

func (*ScreenConsole) Render

func (screen *ScreenConsole) Render()

func (*ScreenConsole) Setup

func (screen *ScreenConsole) Setup()

func (*ScreenConsole) TearDown

func (screen *ScreenConsole) TearDown()

type ScreenDev

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

func (*ScreenDev) GUIState

func (screen *ScreenDev) GUIState() *GUIState

func (*ScreenDev) Name

func (screen *ScreenDev) Name() string

func (*ScreenDev) OnEnter

func (screen *ScreenDev) OnEnter()

func (*ScreenDev) OnExit

func (screen *ScreenDev) OnExit()

func (*ScreenDev) OnTick

func (screen *ScreenDev) OnTick(tick TickData)

func (*ScreenDev) Parent

func (screen *ScreenDev) Parent() IScreen

func (*ScreenDev) Render

func (screen *ScreenDev) Render()

func (*ScreenDev) Setup

func (screen *ScreenDev) Setup()

func (*ScreenDev) TearDown

func (screen *ScreenDev) TearDown()

type ScreenGames

type ScreenGames struct {
	CurrentGame mgdb.Game
	// contains filtered or unexported fields
}

func (*ScreenGames) CycleMediaView

func (screen *ScreenGames) CycleMediaView()

func (*ScreenGames) GUIState

func (screen *ScreenGames) GUIState() *GUIState

func (*ScreenGames) Name

func (screen *ScreenGames) Name() string

func (*ScreenGames) OnEnter

func (screen *ScreenGames) OnEnter()

func (*ScreenGames) OnExit

func (screen *ScreenGames) OnExit()

func (*ScreenGames) OnTick

func (screen *ScreenGames) OnTick(tick TickData)

func (*ScreenGames) Parent

func (screen *ScreenGames) Parent() IScreen

func (*ScreenGames) Render

func (screen *ScreenGames) Render()

func (*ScreenGames) ResetGameAssets

func (screen *ScreenGames) ResetGameAssets()

func (*ScreenGames) Setup

func (screen *ScreenGames) Setup()

func (*ScreenGames) TearDown

func (screen *ScreenGames) TearDown()

type ScreenRomSystems

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

func (*ScreenRomSystems) GUIState

func (screen *ScreenRomSystems) GUIState() *GUIState

func (*ScreenRomSystems) Name

func (screen *ScreenRomSystems) Name() string

func (*ScreenRomSystems) OnEnter

func (screen *ScreenRomSystems) OnEnter()

func (*ScreenRomSystems) OnExit

func (screen *ScreenRomSystems) OnExit()

func (*ScreenRomSystems) OnTick

func (screen *ScreenRomSystems) OnTick(tick TickData)

func (*ScreenRomSystems) Parent

func (screen *ScreenRomSystems) Parent() IScreen

func (*ScreenRomSystems) Render

func (screen *ScreenRomSystems) Render()

func (*ScreenRomSystems) Setup

func (screen *ScreenRomSystems) Setup()

func (*ScreenRomSystems) TearDown

func (screen *ScreenRomSystems) TearDown()

type ScreenRoms

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

func (*ScreenRoms) GUIState

func (screen *ScreenRoms) GUIState() *GUIState

func (*ScreenRoms) Name

func (screen *ScreenRoms) Name() string

func (*ScreenRoms) OnEnter

func (screen *ScreenRoms) OnEnter()

func (*ScreenRoms) OnExit

func (screen *ScreenRoms) OnExit()

func (*ScreenRoms) OnTick

func (screen *ScreenRoms) OnTick(tick TickData)

func (*ScreenRoms) Parent

func (screen *ScreenRoms) Parent() IScreen

func (*ScreenRoms) Render

func (screen *ScreenRoms) Render()

func (*ScreenRoms) Setup

func (screen *ScreenRoms) Setup()

func (*ScreenRoms) TearDown

func (screen *ScreenRoms) TearDown()

type Screens

type Screens struct {
	Cores *ScreenCollections
	Games *ScreenGames
	Roms  *ScreenRoms
}

type Surface

type Surface struct {
	Width     uint16
	Height    uint16
	Interlace bool
	Image     *BGR8
	BgImage   *BGR8
}

func NewSurface

func NewSurface(width, height uint16, interlace bool) *Surface

func (*Surface) BGRbytes

func (surface *Surface) BGRbytes(_ bool) []byte

func (*Surface) Erase

func (surface *Surface) Erase(rect image.Rectangle, sp image.Point)

func (*Surface) Fill

func (surface *Surface) Fill(c color.Color)

func (*Surface) FillBg

func (surface *Surface) FillBg(c color.Color)

type TickData

type TickData struct {
	FrameCount  uint32
	InputPacket groovymister.GroovyInputPacket
}

Jump to

Keyboard shortcuts

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