Documentation
¶
Index ¶
- Constants
- Variables
- func AnimateSlideIn(image []string)
- func BeforeShutdown()
- func Box(topLeftX, topLeftY, bottomRightX, bottomRightY int, title string)
- func CharacterSay(in string, yOffset, xOffset int) (clearFunc func())
- func CollectInputAtPosition(reader io.Reader, posX, posY int, clearAfter bool, limit int) (string, error)
- func FindTopLeftCoord(character []string, longestStringLen int) (int, int)
- func MakeClearFunction(character []string, printedXPos, printedYPos int) func()
- func PrintLine(fixedPos int, char rune, isVertical bool)
- func PrintString(in string, posX, posY int)
- func PrintTransparentMultiRuneSlice(in [][]rune, posX, posY int)
- func PrintTransparentMultiString(in []string, posX, posY int)
- func Scaffold()
- func SelectOption(opts []string) (int, string, error)
- func ShowCharacterInCenter(character []string)
- func ShowOptions(opts []string)
- func StartStatLoop(pt *pet.Pet)
- func UpdateStats(petInfo *pet.Pet)
Constants ¶
const BottomLineHeight = 4
Variables ¶
var ( Screen tcell.Screen StatusLineNumber int InputLineNumber int OptionsLineNumber int )
var ( // The following four global variables are updated by the ShowCharacterInCenter function CharacterXPos int CharacterYPos int LongestCharacterSection int ClearCurrentCharacter func() )
var ErrorInputTerminated = errors.New("input interrupted")
ErrorInputTerminated is the error returned when a user presses CTRL+C during a text input
Functions ¶
func AnimateSlideIn ¶
func AnimateSlideIn(image []string)
AnimateSlideIn shows an animation of the specified image scrolling in from the left hand side of the screen and vanishing as is passes the center point of the display on the X axis.
func BeforeShutdown ¶
func BeforeShutdown()
BeforeShutdown is called before the program exits. It clears the console and terminates the tcell.Screen instance, which means that any error messages or stacktraces that may have arisen can be printed normally and automatically by Go without being messed up.
func Box ¶
Box prints a box between a specified top left position and bottom right position, as well as an optional title
func CharacterSay ¶
CharacterSay prints the specified string prefixed by "> " at the specified offset from the top right hand corner of the currently displayed character. If the string has newlines in it, it is split and each line is printed underneath the previous, with a prefix of " ". A function that can be used to clear the text printed by this function is returned.
func CollectInputAtPosition ¶
func CollectInputAtPosition(reader io.Reader, posX, posY int, clearAfter bool, limit int) (string, error)
CollectInputAtPosition collects input from the provided io.Reader from the specified position on the screen. If clearAfter is true, the input echoed to the display is cleared after a newline is entered. limit specifies the maximum number of bytes that will be accepted as input.
func FindTopLeftCoord ¶
FindTopLeftCoord is used to find the top left coordinate of an image based on its length and the length of its longest part if that image is to be placed in the center of the console
func MakeClearFunction ¶
MakeClearFunction returns a function the clear any images that are printed to the console based on the image itself and position it was printed in.
func PrintLine ¶
PrintLine prints a line of the specified rune along a certain point on the X or Y axis. If isVertical is true, then the line is printed along x = fixedPos. Else, if isVertical is false, the line is printed along y = fixedPos
func PrintString ¶
PrintString prints a string in a specified position. This function acquires and releases the display lock before it does anything and after is has updated the display accordingly.
func PrintTransparentMultiRuneSlice ¶
PrintTransparentMultiString prints a slice of slices of runes beneath each other while not printing spaces (" "), with the top left hand corner of the printed set being at the provided coordinate.
func PrintTransparentMultiString ¶
PrintTransparentMultiString prints a slice of strings beneath each other while not printing spaces (" "), with the top left hand corner of the printed set being at the provided coordinate.
func Scaffold ¶
func Scaffold()
Scaffold draws the inital screen layout, with the Tux character, the info box, a line across the bottom of the screen for the status bar and the ">" symbol where text is inputted from.
func SelectOption ¶
SelectOption wraps ShowOptions, but also adds a prompt for the user to input one of the options. The selected option index and value are returned, and the printed text is cleared afterwards
func ShowCharacterInCenter ¶
func ShowCharacterInCenter(character []string)
ShowCharacterInCenter prints the current character in the center of the console and updates the following global variables: * ClearCurrentCharacter * LongestCharacterSection * CharacterXPos * CharacterYPos
func ShowOptions ¶
func ShowOptions(opts []string)
ShowOptions shows a set of options with a corresponding letter based off the position in the slice in the options line of the bottom bar of the display.
func StartStatLoop ¶
StartStatLoop starts a background worker that updates that statistics in the UI whenever they are modified in the worker. Further explanation about how this function works can be found in the README.md file for this project.
func UpdateStats ¶
UpdateStats takes a reference to a pet and shows its statistics in the info box in the console
Types ¶
This section is empty.