gamewindow

package
v0.0.0-...-667dda6 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CharacterCreatorState

type CharacterCreatorState int

type GameMenuType

type GameMenuType int
const (
	MenuType_Default GameMenuType = iota
	MenuType_Inventory
	MenuType_Build
	MenuType_Dig
)

A list of menu types

type GameWindow

type GameWindow struct {
	window.Window

	FrameCounter       int
	FrameCounterMutext sync.Mutex

	StatusBarMessage string
	StatusBarMutex   sync.Mutex

	Menus      []MenuBoxType
	MenusMutex sync.Mutex
	CloseMenus bool

	Inventory []edentypes.Item
	Hotkeys   map[string]edentypes.Item

	InventoryMutex              sync.Mutex
	PendingInventoryMutex       sync.Mutex
	PendingInventory            bool
	InventoryDisplayType        edentypes.ItemType
	MenuCallback                interface{}
	InventoryCallbackPrompt     string
	DisplayInventoryPostReceive bool
	// contains filtered or unexported fields
}

GameWindow is a window for users to login as a character, create a new one, manage their settings or log out.

func NewGameWindow

func NewGameWindow(x, y, width, height, consoleWidth, consoleHeight int, input, output chan messages.WindowMessage,
	log logging.LoggerType, term terminals.TerminalType) *GameWindow

NewGameWindow creates a new login window

func (*GameWindow) AddMenuBox

func (gw *GameWindow) AddMenuBox(mb MenuBoxType)

func (*GameWindow) BuildHotKeys

func (gw *GameWindow) BuildHotKeys()

func (*GameWindow) BuildMenu

func (gw *GameWindow) BuildMenu()

func (*GameWindow) BuildWall

func (gw *GameWindow) BuildWall(box *MenuBox)

func (*GameWindow) BuildWallConfirmDirection

func (gw *GameWindow) BuildWallConfirmDirection(box *MenuBox, input string)

func (*GameWindow) BuildWallSend

func (gw *GameWindow) BuildWallSend(box *MenuBox, input string)

func (*GameWindow) ClearStatusBar

func (gw *GameWindow) ClearStatusBar()

func (*GameWindow) CloseInventory

func (gw *GameWindow) CloseInventory()

func (*GameWindow) CreateMenu

func (gw *GameWindow) CreateMenu(menuType GameMenuType)

func (*GameWindow) DigConfirmDirection

func (gw *GameWindow) DigConfirmDirection(box *MenuBox, input string)

func (*GameWindow) DigMenu

func (gw *GameWindow) DigMenu()

func (*GameWindow) DisplayInventory

func (gw *GameWindow) DisplayInventory()

func (*GameWindow) DisplayInventoryAfterReceive

func (gw *GameWindow) DisplayInventoryAfterReceive(toggle bool)

func (*GameWindow) DrawBorder

func (w *GameWindow) DrawBorder(winX int, winY int)

DrawBorder returns the border of a window using code page 437 characters as a string

func (*GameWindow) DrawMap

func (gw *GameWindow) DrawMap()

func (*GameWindow) DrawMenus

func (gw *GameWindow) DrawMenus()

func (*GameWindow) DrawStatusBar

func (gw *GameWindow) DrawStatusBar()

func (*GameWindow) DrawToVisibleMap

func (gw *GameWindow) DrawToVisibleMap(x int, y int, character string, escapeCode string)

func (*GameWindow) HandleCommand

func (gw *GameWindow) HandleCommand(inputType types.InputType, input string)

func (*GameWindow) HandleDig

func (gw *GameWindow) HandleDig(box *MenuBox, input string)

func (*GameWindow) HandleInput

func (gw *GameWindow) HandleInput(input types.Input)

HandleInput handles input for the login window

func (*GameWindow) IsInventoryOpen

func (gw *GameWindow) IsInventoryOpen() bool

func (*GameWindow) ItemForHotkey

func (gw *GameWindow) ItemForHotkey(hotkey string) *edentypes.Item

func (*GameWindow) Listen

func (gw *GameWindow) Listen()

Listen listens for any messages on cw.ReceiveMessages Chan and handles them

func (*GameWindow) LockPendingInventory

func (gw *GameWindow) LockPendingInventory()

func (*GameWindow) MovePlayer

func (gw *GameWindow) MovePlayer(deltax, deltay int)

func (*GameWindow) PostUpdateParams

func (gw *GameWindow) PostUpdateParams()

UpdateParams is used when handling resize events to update the various window parameters in a safe state

func (*GameWindow) PrintStringToMap

func (gw *GameWindow) PrintStringToMap(x int, y int, input string, escapeCode string)

func (*GameWindow) PrintStringToStatusBar

func (gw *GameWindow) PrintStringToStatusBar(x, y int, input string, escapeCode string)

func (*GameWindow) RemoveMenuBox

func (gw *GameWindow) RemoveMenuBox(mb MenuBoxType)

not sure if this actually works or not

func (*GameWindow) RequestInventoryUpdate

func (gw *GameWindow) RequestInventoryUpdate(callback interface{}, callbackPrompt string)

func (*GameWindow) SendBuildWallRequest

func (gw *GameWindow) SendBuildWallRequest(item *edentypes.Item, tool *edentypes.Item, dir string)

func (*GameWindow) SendDigRequest

func (gw *GameWindow) SendDigRequest(item *edentypes.Item, dir string)

func (*GameWindow) SetStatusBarMessage

func (gw *GameWindow) SetStatusBarMessage(message string)

func (*GameWindow) SetupVisibleMap

func (gw *GameWindow) SetupVisibleMap()

func (*GameWindow) UnlockPendingInventory

func (gw *GameWindow) UnlockPendingInventory()

func (*GameWindow) UpdateContents

func (gw *GameWindow) UpdateContents()

UpdateContents updates the contents of the login window

func (*GameWindow) UpdateInventory

func (gw *GameWindow) UpdateInventory(inventory []edentypes.Item)

func (*GameWindow) UpdateInventoryDisplayType

func (gw *GameWindow) UpdateInventoryDisplayType(itemType edentypes.ItemType)

func (*GameWindow) UpdateMenuCallback

func (gw *GameWindow) UpdateMenuCallback(callback interface{})

type GameWindowState

type GameWindowState int

GameWindowState is an enum for storing game window state

const (
	GW_NullState GameWindowState = iota
	GW_DefaultView
)

type InventoryDisplay

type InventoryDisplay struct {
	MenuBox
	Inventory   []edentypes.Item
	DisplayType edentypes.ItemType
	Content     []string
	Hotkeys     map[string]edentypes.Item
	GW          *GameWindow
}

func (*InventoryDisplay) Draw

func (inv *InventoryDisplay) Draw(gw *GameWindow)

func (*InventoryDisplay) DrawMenuItems

func (inv *InventoryDisplay) DrawMenuItems(gw *GameWindow)

func (*InventoryDisplay) GetType

func (inv *InventoryDisplay) GetType() MenuType

func (*InventoryDisplay) HandleCharInput

func (inv *InventoryDisplay) HandleCharInput(input string)

func (*InventoryDisplay) HandleInput

func (inv *InventoryDisplay) HandleInput(gw *GameWindow, inputType types.InputType, input string)

func (*InventoryDisplay) PrepareContent

func (inv *InventoryDisplay) PrepareContent()

func (*InventoryDisplay) UpdateCallbackFunction

func (inv *InventoryDisplay) UpdateCallbackFunction()
type MenuBox struct {
	Type MenuType
	// The menu box's position
	X, Y int
	// The menu box's width and height
	Width, Height int
	// The menu box's title
	Title string
	// The menu box's options
	Options                  []MenuBoxOption
	ResponseCallback         interface{}
	PopupMenu                *MenuBox
	CallbackData             interface{} // Arbitrary data we can unpack later
	StatusBarMessageMutex    sync.Mutex
	CallbackStatusBarMessage string
	CheckHotkeys             bool
}
func (mb *MenuBox) Clear(gw *GameWindow)
func (mb *MenuBox) CloseMenus(gw *GameWindow)
func (mb *MenuBox) Draw(gw *GameWindow)
func (mb *MenuBox) DrawBorder(gw *GameWindow)
func (mb *MenuBox) DrawMenuItems(gw *GameWindow)
func (mb *MenuBox) DrawPopupMenu(gw *GameWindow)
func (mb *MenuBox) DrawTitle(gw *GameWindow)
func (mb *MenuBox) GetCallbackDataString() string
func (mb *MenuBox) GetType() MenuType
func (mb *MenuBox) HandleInput(gw *GameWindow, inputType types.InputType, input string)
func (mb *MenuBox) PrintToMenu(gw *GameWindow, x, y int, input string, escapeCode string)
func (mb *MenuBox) SetCallbackStatusBarMessage(input string)
func (mb *MenuBox) ToggleHotkeyCheck(toggle bool)
type MenuBoxOption struct {
	Name       string
	SkipDraw   bool
	Data       interface{}
	Keybind    string
	ControlKey int
	Callback   interface{}
	Order      int
}
type MenuBoxType interface {
	HandleInput(*GameWindow, types.InputType, string)
	Draw(*GameWindow)
	Clear(*GameWindow)
	DrawTitle(*GameWindow)
	DrawBorder(*GameWindow)
	DrawMenuItems(*GameWindow)
	DrawPopupMenu(*GameWindow)
	PrintToMenu(*GameWindow, int, int, string, string)
	CloseMenus(*GameWindow)
	SetCallbackStatusBarMessage(string)
	GetCallbackDataString() string
	GetType() MenuType
	ToggleHotkeyCheck(bool)
}
type MenuType int
const (
	MenuTypeNull MenuType = iota
	MenuTypeInventory
)

Jump to

Keyboard shortcuts

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