adding the options form for the stream view
This commit is contained in:
@@ -87,6 +87,7 @@ func NewCreateWindowFormView() *CreateWindowFormView {
|
||||
Form: NewCDashDisplayWindowFormView(),
|
||||
}
|
||||
|
||||
// NOTE: is this variable actually used anywhere
|
||||
view.CreateBtn = tview.NewButton("Create")
|
||||
// Need to inject the button functionality later
|
||||
|
||||
|
||||
@@ -51,9 +51,6 @@ type DeviceAPIListView struct {
|
||||
|
||||
func NewDeviceAPIListView() *DeviceAPIListView {
|
||||
deviceAPIList := tview.NewList()
|
||||
// AddItem("layout", "build a layout for CDashDisplay", 0, func() {
|
||||
// layoutToolUIOnSelect(bus, doc)
|
||||
// })
|
||||
deviceAPIList.SetBorder(true).SetTitle("list")
|
||||
|
||||
return &DeviceAPIListView{
|
||||
@@ -75,40 +72,18 @@ func (dl *DeviceAPIListView) AddItem(name, description string, onSelect func())
|
||||
}
|
||||
|
||||
func NewDeviceAPIView() (*DeviceAPIView, error) {
|
||||
// To build the main view we must set the DOM root
|
||||
mainFlex := tview.NewFlex().SetDirection(tview.FlexColumn)
|
||||
// mainFlexUINode, err := doc.NewUINode(MainFlexID, nil, mainFlex)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// doc.SetRoot(mainFlexUINode)
|
||||
|
||||
deviceAPIList := NewDeviceAPIListView()
|
||||
// apiListWindowUINode, err := doc.NewUINode(DeviceAPIListID, doc.GetRootElem(),
|
||||
// deviceAPIList.List)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
apiToolPages := NewDeviceAPIToolView()
|
||||
// apiToolPagesNode, err := doc.NewUINode(APIToolPagesID, doc.GetElemByID(RightFlexID),
|
||||
// apiToolPages.Pages)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
mainFlex.
|
||||
AddItem(deviceAPIList.List, 0, 1, false).
|
||||
AddItem(apiToolPages.Pages, 0, 4, false)
|
||||
|
||||
// Output window
|
||||
|
||||
outputWin := NewOutputWinView()
|
||||
// _, err = doc.NewUINode("output-window", nil, outputWin.TextArea)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// Flex with debug window
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package views
|
||||
|
||||
import (
|
||||
telem "esdi/telemetry"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"esdi/providers"
|
||||
telem "esdi/telemetry"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
@@ -17,20 +19,51 @@ const (
|
||||
BrakeBiasLen = 6
|
||||
)
|
||||
|
||||
type StreamView struct {
|
||||
// Form to select the game and whatnot ↓↓↓↓
|
||||
|
||||
// StreamOptionsView will be our view element to show the stream data
|
||||
type StreamOptionsView struct {
|
||||
Form *tview.Form
|
||||
SimDropdown *tview.DropDown
|
||||
UpdateBtn *tview.Button
|
||||
}
|
||||
|
||||
func NewStreamOptionsView() *StreamOptionsView {
|
||||
sov := &StreamOptionsView{}
|
||||
|
||||
sov.Form = tview.NewForm()
|
||||
sov.Form.SetTitle("Stream Options").SetBorder(true)
|
||||
|
||||
sov.SimDropdown = tview.NewDropDown().SetLabel("SIM").SetCurrentOption(0)
|
||||
for _, prov := range providers.Providers {
|
||||
sov.SimDropdown.AddOption(prov.Name, func() {})
|
||||
}
|
||||
sov.Form.AddFormItem(sov.SimDropdown)
|
||||
|
||||
// Inject callback on the controller
|
||||
sov.Form.AddButton("Update", func() {})
|
||||
|
||||
return sov
|
||||
}
|
||||
|
||||
// Form to select the game and whatnot ↑↑↑↑
|
||||
|
||||
// Area to visualize what data is being passed to the game and whatnot ↓↓↓↓
|
||||
|
||||
type StreamVisualizerView struct {
|
||||
TextView *tview.TextView
|
||||
}
|
||||
|
||||
func NewStreamView() *StreamView {
|
||||
func NewStreamVisualizerView() *StreamVisualizerView {
|
||||
tv := tview.NewTextView()
|
||||
tv.SetTitle("Streaming Tool").SetBorder(true)
|
||||
tv.SetTitle("Streaming Visualizer").SetBorder(true)
|
||||
|
||||
return &StreamView{
|
||||
return &StreamVisualizerView{
|
||||
TextView: tv,
|
||||
}
|
||||
}
|
||||
|
||||
func (sv *StreamView) Update(data *telem.TelemetryData) {
|
||||
func (sv *StreamVisualizerView) Update(data *telem.TelemetryData) {
|
||||
sv.TextView.SetText(stringify(data))
|
||||
}
|
||||
|
||||
@@ -49,3 +82,32 @@ func stringify(data *telem.TelemetryData) string {
|
||||
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
// Area to visualize what data is being passed to the game and whatnot ↑↑↑↑
|
||||
|
||||
// Stream Tool ↓↓↓↓
|
||||
|
||||
type StreamToolView struct {
|
||||
Flex *tview.Flex
|
||||
Options *StreamOptionsView
|
||||
Visualizer *StreamVisualizerView
|
||||
}
|
||||
|
||||
func NewStreamToolView() *StreamToolView {
|
||||
optionsView := NewStreamOptionsView()
|
||||
visualizerView := NewStreamVisualizerView()
|
||||
flex := tview.NewFlex().SetDirection(tview.FlexColumn)
|
||||
flex.SetTitle("Streaming Tool")
|
||||
|
||||
flex.
|
||||
AddItem(optionsView.Form, 0, 2, true).
|
||||
AddItem(visualizerView.TextView, 0, 5, true)
|
||||
|
||||
return &StreamToolView{
|
||||
Flex: flex,
|
||||
Options: optionsView,
|
||||
Visualizer: visualizerView,
|
||||
}
|
||||
}
|
||||
|
||||
// Stream Tool ↑↑↑↑
|
||||
|
||||
Reference in New Issue
Block a user