ui

package
v0.0.0-...-d9921b7 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Margin is the space in pixels between screen border and UI text.
	Margin = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func(state uint8)

Action type for user interactions. TODO: see if we can use a single one for gameboy/ui. TODO: see if we can't move that to widgets (see QAction for inspiration)

type UI

type UI struct {
	Emulator *gameboy.GameBoy

	KeyboardControls       map[options.KeyStroke]Action
	GameControllerControls map[sdl.GameControllerButton]Action

	SigINTChan chan os.Signal

	// Send true to this channel to quit the program.
	QuitChan chan bool
	// contains filtered or unexported fields
}

UI structure to manage user commands and overlay. TODO: move Gameboy inside UI, implement UI.Tick(), see if it works.

func New

func New() *UI

Return a UI instance given a renderer to create the overlay texture.

func (*UI) ButtonAction

func (u *UI) ButtonAction(e widgets.Event, gbAction gameboy.Action) Action

ButtonAction returns a control action function that will propagate event keys for button presses to the proper object (emulator if it's running, UI if it's paused).

func (*UI) EmulatorAction

func (u *UI) EmulatorAction(action Action) Action

EmulatorAction returns a control action function that will handle some high-level events but only if the emulator is currently running (so that we don't change palettes or stuff while the emulator is paused).

func (*UI) Hide

func (u *UI) Hide()

func (*UI) Home

func (u *UI) Home(state uint8)

Home hides the UI and resumes emulation.

func (*UI) NextPalette

func (u *UI) NextPalette(state uint8)

NextPalette switches colors to the next defined palette, wrapping around. There should always be at least a default palette defined.

func (*UI) OpenROM

func (u *UI) OpenROM()

Actions available in Paused state.

func (*UI) PreviousPalette

func (u *UI) PreviousPalette(state uint8)

PreviousPalette switches colors to the previous defined palette, wrapping around. There should always be at least a default palette defined.

func (*UI) ProcessEvents

func (u *UI) ProcessEvents()

func (*UI) Quit

func (u *UI) Quit(state uint8)

Quit cleanly quits the program.

func (*UI) Repaint

func (u *UI) Repaint()

func (*UI) Screenshot

func (u *UI) Screenshot(state uint8)

Screenshot saves the current frame to disk as a PNG file. TODO: configurable folder, obviously.

func (*UI) SetControls

func (u *UI) SetControls(keymap options.Keymap, joymap options.Joymap) (err error)

SetControls validates and sets the given control map for the emulator's UI.

func (*UI) Show

func (u *UI) Show()

func (*UI) ShowDialog

func (u *UI) ShowDialog(dialog widgets.DialogWidget, cb widgets.DialogCloser)

TODO: ... another dialogs.go, I guess.

func (*UI) StartStopRecord

func (u *UI) StartStopRecord(state uint8)

StartStopRecord starts recording video output to GIF and closes the file when done. Defined as a single action to toggle between the two and avoid opening several GIFs at once. TODO: move to ui

func (*UI) Tick

func (u *UI) Tick() (res gameboy.TickResult)

TODO: FillAudioBuffer

func (*UI) ToggleVoice1

func (u *UI) ToggleVoice1(state uint8)

ToggleVoice1 mutes or unmutes the first audio generator (Square 1).

func (*UI) ToggleVoice2

func (u *UI) ToggleVoice2(state uint8)

ToggleVoice2 mutes or unmutes the second audio generator (Square 2).

func (*UI) ToggleVoice3

func (u *UI) ToggleVoice3(state uint8)

ToggleVoice3 mutes or unmutes the third audio generator (Wave).

func (*UI) ToggleVoice4

func (u *UI) ToggleVoice4(state uint8)

ToggleVoice4 mutes or unmutes the fourth audio generator (Noise).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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