gui

package
v0.0.0-...-54c8723 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContinueCaretPng pixel.Picture
	CursorPng        pixel.Picture
	BasicAtlas12     *text.Atlas
	BasicAtlasAscii  *text.Atlas
)
e.g.

tBox := TextboxCreateFixed(

	"A nation can survive its fools, and even the ambitious. But it cannot survive treason from within. An enemy at the gates is less formidable, for he is known and carries his banner openly. But the traitor moves amongst those within the gate freely, his sly whispers rustling through all the alleys, heard in the very halls of government itself. For the traitor appears not a traitor; he speaks in accents familiar to his victims, and he wears their face and their arguments, he appeals to the baseness that lies deep in the hearts of all men. He rots the soul of a nation, he works secretly and unknown in the night to undermine the pillars of the city, he infects the body politic so that it can no longer resist. A murderer is less to fear. Jai Hind I Love India <3 ",
	pixel.V(-150, 200), 300, 100,
	"Ajinkya",
	avatarPng,
)

Functions

This section is empty.

Types

type CaptionScreen

type CaptionScreen struct {
	Position pixel.Vec
	// contains filtered or unexported fields
}

func CaptionScreenCreate

func CaptionScreenCreate(txt string, position pixel.Vec, scale float64) CaptionScreen

func (CaptionScreen) Enter

func (s CaptionScreen) Enter()

StackInterface implemented below

func (CaptionScreen) Exit

func (s CaptionScreen) Exit()

func (CaptionScreen) HandleInput

func (s CaptionScreen) HandleInput(win *pixelgl.Window)

func (CaptionScreen) Render

func (s CaptionScreen) Render(win *pixelgl.Window)

func (CaptionScreen) Update

func (s CaptionScreen) Update(dt float64) bool

type CaptionStyle

type CaptionStyle struct {
	Text  string
	Scale float64
}

type Layout

type Layout struct {
	Panels map[string]PanelDef
	// contains filtered or unexported fields
}

func LayoutCreate

func LayoutCreate(x, y float64, win *pixelgl.Window) Layout

centerPos would Player TileX, TileY

func (Layout) Bottom

func (l Layout) Bottom(name string) float64

func (Layout) Contract

func (l Layout) Contract(name string, horz, vert float64)

Contract will reduce the Panel dimension with give value e.g. Contract('screen', 118, 40)

func (Layout) CreatePanel

func (l Layout) CreatePanel(name string) Panel

func (Layout) DebugRender

func (l Layout) DebugRender(win *pixelgl.Window)

DebugRender just for debug

func (Layout) Left

func (l Layout) Left(name string) float64

func (Layout) MidX

func (l Layout) MidX(name string) float64

func (Layout) MidY

func (l Layout) MidY(name string) float64

func (Layout) Right

func (l Layout) Right(name string) float64

func (*Layout) SplitHorz

func (l *Layout) SplitHorz(name, topName, bottomName string, x, margin float64)

e.g. SplitHorz('screen', "top", "bottom", 0.12, 2) // X = from 0 to 1 X represents top height percent

func (*Layout) SplitVert

func (l *Layout) SplitVert(name, leftName, rightName string, y, margin float64)

e.g. SplitVert('bottom', "left", "party", 0.726, 2) // Y = from 0 to 1 Y represents rightName width percent

func (Layout) Top

func (l Layout) Top(name string) float64

since Panel renders from Center of X, Y

type Panel

type Panel struct {
	BGColor color.RGBA //hex
	// contains filtered or unexported fields
}

func PanelCreate

func PanelCreate(pos pixel.Vec, width, height float64) Panel

PanelCreate

func (*Panel) Draw

func (p *Panel) Draw(renderer pixel.Target)

func (Panel) GetCorners

func (p Panel) GetCorners() (topLeft pixel.Vec, topRight pixel.Vec, bottomLeft pixel.Vec, bottomRight pixel.Vec)

type PanelDef

type PanelDef struct {
	Pos           pixel.Vec
	Width, Height float64
}

func (PanelDef) GetSize

func (p PanelDef) GetSize() (width, height float64)

type ProgressBar

type ProgressBar struct {
	Background *pixel.Sprite
	Foreground *pixel.Sprite

	Value, Maximum, HalfWidth, Width float64
	// contains filtered or unexported fields
}

func ProgressBarCreate

func ProgressBarCreate(x, y float64, value, max float64, background, foreground string) ProgressBar

func (ProgressBar) Enter

func (pb ProgressBar) Enter()

func (ProgressBar) Exit

func (pb ProgressBar) Exit()

func (ProgressBar) GetPosition

func (pb ProgressBar) GetPosition() (x, y float64)

func (ProgressBar) HandleInput

func (pb ProgressBar) HandleInput(win *pixelgl.Window)

TO MATCH StackInterface below

func (ProgressBar) Render

func (pb ProgressBar) Render(renderer pixel.Target)

func (*ProgressBar) SetMax

func (pb *ProgressBar) SetMax(maxHealth float64)

func (*ProgressBar) SetPosition

func (pb *ProgressBar) SetPosition(x, y float64)

func (*ProgressBar) SetValue

func (pb *ProgressBar) SetValue(health float64)

func (ProgressBar) Update

func (pb ProgressBar) Update(dt float64) bool

type ProgressBarIMD

type ProgressBarIMD struct {
	Background color.RGBA
	Foreground color.RGBA

	Value, Maximum, HalfWidth,
	Height, Width float64
	// contains filtered or unexported fields
}

func ProgressBarIMDCreate

func ProgressBarIMDCreate(x, y float64, value, max float64, background, foreground string, height, width float64, parentImd *imdraw.IMDraw) ProgressBarIMD

func (ProgressBarIMD) Enter

func (pb ProgressBarIMD) Enter()

func (ProgressBarIMD) Exit

func (pb ProgressBarIMD) Exit()

func (ProgressBarIMD) GetPercentWidth

func (pb ProgressBarIMD) GetPercentWidth() float64

func (ProgressBarIMD) GetPosition

func (pb ProgressBarIMD) GetPosition() (x, y float64)

func (ProgressBarIMD) HandleInput

func (pb ProgressBarIMD) HandleInput(win *pixelgl.Window)

TO MATCH StackInterface below

func (ProgressBarIMD) Render

func (pb ProgressBarIMD) Render(renderer pixel.Target)

func (*ProgressBarIMD) SetMax

func (pb *ProgressBarIMD) SetMax(maxHealth float64)

func (*ProgressBarIMD) SetPosition

func (pb *ProgressBarIMD) SetPosition(x, y float64)

func (*ProgressBarIMD) SetValue

func (pb *ProgressBarIMD) SetValue(health float64)

func (ProgressBarIMD) Update

func (pb ProgressBarIMD) Update(dt float64) bool

type SelectionMenu

type SelectionMenu struct {
	X, Y float64

	Columns int //The number of columns the menu has. This defaults to 1

	//focusX tells us which column is selected and focusY which element in that column
	SpacingY, SpacingX float64 //space btw each items
	Scale              float64 //menu Scale in size

	CursorWidth, CursorHeight float64
	IsShowCursor              bool
	MaxRows                   int //rows might be 30 but only 5 maxRows are displayed at once

	OnSelection    func(int, interface{}) //to be called after selection
	DataI          []interface{}
	RenderFunction func(a ...interface{})
	// contains filtered or unexported fields
}

func SelectionMenuCreate

func SelectionMenuCreate(spacingY, spacingX, xWidth float64, data interface{}, showColumns bool, position pixel.Vec, onSelection func(int, interface{}), renderFunc func(a ...interface{})) SelectionMenu

func (SelectionMenu) CanScrollDown

func (m SelectionMenu) CanScrollDown() bool

func (SelectionMenu) CanScrollUp

func (m SelectionMenu) CanScrollUp() bool

func (SelectionMenu) GetHeight

func (m SelectionMenu) GetHeight() float64

func (SelectionMenu) GetIndex

func (m SelectionMenu) GetIndex() int

func (*SelectionMenu) GetWidth

func (m *SelectionMenu) GetWidth() float64

func (*SelectionMenu) HandleInput

func (m *SelectionMenu) HandleInput(window *pixelgl.Window)

func (*SelectionMenu) HideCursor

func (m *SelectionMenu) HideCursor()

func (SelectionMenu) IsDataSourceEmpty

func (m SelectionMenu) IsDataSourceEmpty() bool

func (*SelectionMenu) MoveDisplayDown

func (m *SelectionMenu) MoveDisplayDown()

func (*SelectionMenu) MoveDisplayUp

func (m *SelectionMenu) MoveDisplayUp()

func (*SelectionMenu) MoveDown

func (m *SelectionMenu) MoveDown()

func (*SelectionMenu) MoveLeft

func (m *SelectionMenu) MoveLeft()

func (*SelectionMenu) MoveRight

func (m *SelectionMenu) MoveRight()

func (*SelectionMenu) MoveUp

func (m *SelectionMenu) MoveUp()

func (*SelectionMenu) OffsetCursorPosition

func (m *SelectionMenu) OffsetCursorPosition(x, y float64)

func (SelectionMenu) OnClick

func (m SelectionMenu) OnClick()

func (SelectionMenu) Render

func (m SelectionMenu) Render(renderer *pixelgl.Window)

func (SelectionMenu) SelectedItem

func (m SelectionMenu) SelectedItem() interface{}

func (*SelectionMenu) SetColumns

func (m *SelectionMenu) SetColumns(columns, maxRows int)

func (*SelectionMenu) SetPosition

func (m *SelectionMenu) SetPosition(x, y float64)

func (*SelectionMenu) ShowCursor

func (m *SelectionMenu) ShowCursor()

type SimpleCaptionsScreen

type SimpleCaptionsScreen struct {
	Position pixel.Vec
	// contains filtered or unexported fields
}

func SimpleCaptionsScreenCreate

func SimpleCaptionsScreenCreate(captions []CaptionStyle, position pixel.Vec) SimpleCaptionsScreen

func (SimpleCaptionsScreen) Render

func (s SimpleCaptionsScreen) Render(win *pixelgl.Window)

type StackInterface

type StackInterface interface {
	Enter()
	Exit()
	Update(dt float64) bool
	Render(win *pixelgl.Window)
	HandleInput(win *pixelgl.Window)
}

type StateStack

type StateStack struct {
	States    []StackInterface
	Win       *pixelgl.Window
	Globals   map[string]interface{}
	DeltaTime float64
}

A state stack is, simply, a stack of states. Every time you add a new state it goes on top of the stack and is rendered last. aka Last in First out

func StateStackCreate

func StateStackCreate(win *pixelgl.Window) *StateStack

func (*StateStack) Clear

func (ss *StateStack) Clear()

func (StateStack) GetLastIndex

func (ss StateStack) GetLastIndex() int

func (*StateStack) Pop

func (ss *StateStack) Pop() StackInterface

func (*StateStack) Push

func (ss *StateStack) Push(state StackInterface)

func (*StateStack) PushFITMenu

func (ss *StateStack) PushFITMenu(x, y float64, txt string, choices []string, onSelection func(int, interface{}))

PushFITMenu PENDING not getting correct height and width

func (*StateStack) PushFitted

func (ss *StateStack) PushFitted(x, y float64, txt string) *Textbox

func (*StateStack) PushFixed

func (ss *StateStack) PushFixed(x, y, width, height float64, txt, avatarName string, avatarPng pixel.Picture)

func (*StateStack) PushSelectionMenu

func (ss *StateStack) PushSelectionMenu(x, y, width, height float64, txt string, choices []string, onSelection func(int, interface{}), showColumns bool)

func (*StateStack) RemoveStateAtIndex

func (ss *StateStack) RemoveStateAtIndex(i int)

func (StateStack) Render

func (ss StateStack) Render(renderer *pixelgl.Window)

Render only last item in array unless the last item gets Pop() next would show.

func (StateStack) Top

func (ss StateStack) Top() *StackInterface

func (*StateStack) Update

func (ss *StateStack) Update(dt float64)

type Textbox

type Textbox struct {
	Stack *StateStack

	Position pixel.Vec

	Panel Panel

	Width, Height float64

	AppearTween animation.Tween
	// contains filtered or unexported fields
}

func TextboxCreateFitted

func TextboxCreateFitted(stack *StateStack, txt string, panelPos pixel.Vec, hasMenu bool) Textbox

TextboxCreateFitted are good for small chats height and width gets set automatically

func TextboxCreateFixed

func TextboxCreateFixed(stack *StateStack, txt string, panelPos pixel.Vec, panelWidth, panelHeight float64, avatarName string, avatarImg pixel.Picture, hasMenu bool) Textbox

func TextboxFITMenuCreate

func TextboxFITMenuCreate(stack *StateStack, x, y float64, textBoxText string, choices []string, onSelection func(int, interface{})) *Textbox

func TextboxFITPassedMenuCreate

func TextboxFITPassedMenuCreate(stack *StateStack, x, y float64, textBoxText string, menu *SelectionMenu) *Textbox

func TextboxNew

func TextboxNew(stack *StateStack, txt string, size float64, atlas *text.Atlas, avatarName string, avatarImg pixel.Picture) Textbox

func TextboxWithMenuCreate

func TextboxWithMenuCreate(stack *StateStack, textBoxText string, panelPos pixel.Vec, panelWidth, panelHeight float64,
	choices []string, onSelection func(int, interface{}), showColumns bool) *Textbox

func (*Textbox) Enter

func (t *Textbox) Enter()

func (*Textbox) Exit

func (t *Textbox) Exit()

func (*Textbox) HandleInput

func (t *Textbox) HandleInput(window *pixelgl.Window)

HandleInput takes care of 3 types of textbox's 1 textbox with menu 2 Fixed then we let the blocks render 3 Fitted users marks as read and goes to next text popup

func (Textbox) HasReachedLimit

func (t Textbox) HasReachedLimit() bool

func (*Textbox) IsDead

func (t *Textbox) IsDead() bool

func (*Textbox) Next

func (t *Textbox) Next()

func (*Textbox) OnClick

func (t *Textbox) OnClick()

func (*Textbox) Render

func (t *Textbox) Render(renderer *pixelgl.Window)

func (*Textbox) Update

func (t *Textbox) Update(dt float64) bool

type TitleScreen

type TitleScreen struct {
	Stack *StateStack
	// contains filtered or unexported fields
}

func TitleScreenCreate

func TitleScreenCreate(stack *StateStack, win *pixelgl.Window) *TitleScreen

func (TitleScreen) Enter

func (s TitleScreen) Enter()

StackInterface implemented below

func (TitleScreen) Exit

func (s TitleScreen) Exit()

func (TitleScreen) HandleInput

func (s TitleScreen) HandleInput(win *pixelgl.Window)

func (TitleScreen) Render

func (s TitleScreen) Render(win *pixelgl.Window)

func (TitleScreen) Update

func (s TitleScreen) Update(dt float64) bool

type XPPopUp

type XPPopUp struct {
	X, Y      float64
	Text      string
	TextColor color.RGBA
	Tween     animation.Tween
	FadeTime,
	DisplayTime float64
	Pane Panel
	// contains filtered or unexported fields
}

func XPPopUpCreate

func XPPopUpCreate(x, y float64, txt, color string) *XPPopUp

func (XPPopUp) IsFinished

func (p XPPopUp) IsFinished() bool

func (XPPopUp) IsTurningOff

func (p XPPopUp) IsTurningOff() bool

func (*XPPopUp) Render

func (p *XPPopUp) Render(renderer pixel.Target)

func (*XPPopUp) SetPosition

func (p *XPPopUp) SetPosition(x, y float64)

func (*XPPopUp) TurnOff

func (p *XPPopUp) TurnOff()

func (*XPPopUp) TurnOn

func (p *XPPopUp) TurnOn()

func (*XPPopUp) Update

func (p *XPPopUp) Update(dt float64)

Jump to

Keyboard shortcuts

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