tetraterm

package module
v0.0.0-...-85cb2c2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 16 Imported by: 0

README

TetraTerm 🖥️

TetraTermImg

Devlog Video Talking About It

TetraTerm is a terminal-based debugging app for Tetra3D games and applications. It features a node graph, easy visualization of node properties, and means to create, modify, and delete nodes with minimal modifications to your game. It works by hooking into your game using localhost networking; this means your game can crash or be interrupted and you can debug as you would normally, while TetraTerm continues without issue and will re-connect when possible.

How to install

The general approach to install TetraTerm easily would be:

  1. Run go get github.com/solarlune/tetraterm from your game project directory. This downloads tetraterm so you can create a server for your game. The server runs in your game and connects to the terminal end of TetraTerm.

  2. Create a Server instance in your game and call Server.Update() and Server.Draw() every tick from your Game.Update() function.

  3. Run go install github.com/solarlune/tetraterm/terminal to install the tetraterm terminal display application to your Go bin directory. If that Go bin directory (which defaults to ~/go on Linux) is in your terminal path, then you will now be able to run tetraterm from anywhere by just typing that command. You can also just checkout the TetraTerm repo and run or build the terminal application from the terminal directory for the same result.

  4. Now just run your game as you normally do, and run tetraterm from a terminal. They should automatically connect to each other via port 7979 (the port number used is customizeable by passing a port flag to tetraterm).

See the example for more information.

Basic usage

TetraTerm has a few options - you have the node graph at the left and the game and node properties on the right. You can use the keyboard or mouse to focus on UI elements, and collapse or expand the node tree using space or enter. Ctrl+H lists general help and key information.

To-do

  • Get it to work!
  • Connection / Re-connection if server crashes
    • Connection indicator
    • Not freezing the terminal until a connection is established when one is abruptly stopped
  • Quit button (modal?)
  • When changing scenes, try to select a node with the same name in the new scene (i.e. if the Player is selected in Scene A and you go to Scene B, try to select the Player again)
  • Node graph
    • Hide or gray out nodes in the tree that aren't selected?
  • Properties panel.
    • Output position, scale, rotation, ID
    • Tag display for properties
    • Keys to scale
    • Keys to rotate (this was working previously, I think it would be better to have a mode switch between moving, scaling, and rotation, though).
    • Mode switch for local vs world movement?
    • Allow modification / setting these properties numerically
  • Game properties panel.
    • FPS, TPS, frame-time, render count
  • Cloning Nodes should parent them to the currently highlighted Node
  • Vertical progress bar / draggable for visualizing or even scrolling through the node tree?
    • Display scroll percentage? (not sure if I want this anymore)
  • Scrolling through the node tree with mouse wheel doesn't work? (This has been determined to be an issue with tview, not TetraTerm.)
  • Follow Nodes
    • Built-in free-look camera to not modify the hierarchy when following a node?
    • Following Nodes should look at the target constantly, regardless of camera movement (?)
  • Keybindings
    • Expand / Collapse All
    • Expand / Collapse All Up to Current Node
    • Customizeable keybindings?
  • Search pane (Shift+F)
    • Search by tag, node type
    • Shift+F while a node name is entered to cycle through Nodes with those names
  • Clone pane (Shift+C)
    • Cloning objects from other scenes in the library
  • Option to toggle debug drawing from terminal (1 key, by default)
  • Ability to create a blank node for hierarchy-altering purposes
  • Ability to track a node to always display its properties in another pane (underneath the existing Node Properties pane?)
  • Flags
    • Flag to change port
    • Flag to change host
  • EOFs when terminal expects a message can cause terminal drawing distortions; the terminal needs to be cleared when this happens
  • Options menu
    • Auto-hide, collapse, or darken treeview elements that are not selected?
    • Ini file for settings storage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionSettings

type ConnectionSettings struct {
	Host string // What host name to use for connecting from the client to the server
	Port string // What port to use for the connection
	// Whether logging should be silent (default) or not; if not silent, the terminal client will spam messages
	// indicating the messages received from the server, and vice-versa
	SilentLogging bool
}

ConnectionSettings represents the set of options to use for both the terminal display client as well as your server in your game. The host and port settings should match for the connection to take.

func NewDefaultConnectionSettings

func NewDefaultConnectionSettings() *ConnectionSettings

NewDefaultConnectionSettings returns a new ConnectionSettings object filled out with the default connection setting values.

type Display

type Display struct {
	Client         *p2p.Client
	ClientSettings *ConnectionSettings

	App *tview.Application

	Root *tview.Pages

	TreeNodeRoot   *tview.TreeNode
	TreeView       *tview.TreeView
	TreeViewScroll *Scrollbar

	NodePropertyArea *tview.TextArea
	GamePropertyArea *tview.TextArea

	SearchBar                           *tview.InputField
	SearchBarCloneMode                  bool
	SearchBarCloneModeAutocompleteNames []string

	SelectNextNode      bool
	SelectNextNodeIndex uint64

	SceneNodesToTreeNodes map[uint64]*tview.TreeNode
	// contains filtered or unexported fields
}

Display represents the terminal interface that hooks into your game through a TCP connection. By manipulating the Display in your terminal, you can view and modify your connected game scene while it's running. It will also automatically reconnect if the connection is lots.

func NewDisplay

func NewDisplay(settings *ConnectionSettings) *Display

NewDisplay returns a new Display object with the ConnectionSettings provided. If nil is passed, the default connection settings set is used.

func (*Display) Start

func (td *Display) Start() error

Start starts the terminal display app.

func (*Display) Stop

func (td *Display) Stop()

Stop stops the terminal display app.

type Scrollbar

type Scrollbar struct {
	*tview.TextArea
	// contains filtered or unexported fields
}

func NewScrollbar

func NewScrollbar(treeview *tview.TreeView) *Scrollbar

func (*Scrollbar) ChildIndexInTree

func (sb *Scrollbar) ChildIndexInTree(treeNode *tview.TreeNode) int

func (*Scrollbar) ChildWithIndexInTree

func (sb *Scrollbar) ChildWithIndexInTree(targetIndex int) *tview.TreeNode

func (*Scrollbar) HandleMouseInput

func (sb *Scrollbar) HandleMouseInput(action tview.MouseAction, event *tcell.EventMouse) (tview.MouseAction, *tcell.EventMouse)

func (*Scrollbar) ScrollTo

func (sb *Scrollbar) ScrollTo(index int)

type Server

type Server struct {
	P2PServer *p2p.Server

	DebugDrawHierarchy bool
	DebugDrawWireframe bool
	DebugDrawBounds    bool
	// contains filtered or unexported fields
}

Server represents the endpoint of your game that the debugging Terminal hooks into. Note that this handles and records various settings to enable debugging simply and easily, so it's best to not instantiate a Server when shipping a release version of your game.

func NewServer

func NewServer(settings *ConnectionSettings) *Server

NewServer returns a new server, using the connection settings provided. If you pass nil, that is valid for a default set of connection settings.

func (*Server) Draw

func (server *Server) Draw(screen *ebiten.Image, camera *tetra3d.Camera)

Draw handles any additional drawing from the terminal, drawing to the screen using the Tetra3D camera provided.

func (*Server) Update

func (server *Server) Update(scene *tetra3d.Scene)

Update updates the server as necessary. The scene should be the current game scene that you wish to send and visualize in the terminal client. This should be called every tick.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳