Skip to content

Commit

Permalink
Add steam input debug view, refactor iga (#17)
Browse files Browse the repository at this point in the history
* Fixes

* Add IGAView

* Do not use pointers to Q_GADGETs

* Fixes

* Add basic repl console

* Add console to debug overlay

* Improve console visuals

* Extract components from console

* Refactor ReplEdit

* Cleanup

* Improve IGAView

* show only iga on igaview
  • Loading branch information
zhulik authored Jun 26, 2023
1 parent bad9d55 commit 187167d
Show file tree
Hide file tree
Showing 31 changed files with 528 additions and 226 deletions.
2 changes: 1 addition & 1 deletion resources/qml/ActionLabel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RowLayout {
Layout.fillHeight: parent
verticalAlignment: Text.AlignVCenter

font.pointSize: 18
font.pointSize: root.height - 4

name: root.name
}
Expand Down
62 changes: 52 additions & 10 deletions resources/qml/DebugOverlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ import QtQuick.Layouts 1.15

import "QSteamworks" as Steamworks

import "debug" as Debug

Item {
id: root
visible: false

signal closed()

property var deckfmSettings: ({
showCloseButton: false,
showFooter: false
})

function toggle() {
root.visible = !root.visible
Expand All @@ -26,20 +34,54 @@ Item {
}

ColumnLayout {

anchors.fill: parent

Label {
text: `Action set: ${input.actionSet}`
}
TabBar {
id: bar
Layout.fillWidth: parent

Label {
text: `Current layer: ${JSON.stringify(input.actionSetLayer)} (available: ${JSON.stringify(steam_input.currentActionSet.layers)})`
currentIndex: 2

TabButton {
text: "Controller state"
}

TabButton {
text: "Console"
}

TabButton {
text: "IGA"
}
}

Label {
Layout.fillHeight: parent
id: lastEventLabel
StackLayout {
Layout.fillWidth: parent

currentIndex: bar.currentIndex

ColumnLayout {

Label {
text: `Action set: ${input.actionSet}`
}

Label {
text: `Current layer: ${JSON.stringify(input.actionSetLayer)}`
}

Label {
id: lastEventLabel
}
}

Debug.Console{

}

Debug.IGAView {

}
}
}
}
6 changes: 5 additions & 1 deletion resources/qml/DirectoryView/DirectoryView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Item {
}

analogHandlers: {
"scroll": e => view.flick(e.analogX * 50, e.analogY * 50)
"scroll": e => view.flick(e.analogX, e.analogY)
}
}

Expand Down Expand Up @@ -204,6 +204,10 @@ Item {
const y = fileHighlight.belowView ? view.contentY + view.cellHeight : view.contentY + view.height - view.cellHeight
view.currentIndex = view.indexAt(fileHighlight.x, y)
}

if (!view.moving) {
steam_input.stopAnalogActionMomentum("scroll")
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion resources/qml/Footer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import QtQuick.Layouts 1.15
import "QSteamworks" as Steamworks

ToolBar {
id: root

property alias hintActions: repeater.model

height: 60
height: 20

Rectangle {
anchors.fill: parent
Expand All @@ -29,6 +30,7 @@ ToolBar {
id: repeater

ActionLabel {
height: root.height
name: modelData
}
}
Expand Down
4 changes: 0 additions & 4 deletions resources/qml/Header.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ ToolBar {
onClicked: root.menuClicked()
}

BusyIndicator {
running: true
}

MDI.Button {
text: "DECKFM"
font.pointSize: 24
Expand Down
1 change: 1 addition & 0 deletions resources/qml/MainWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ ApplicationWindow {

DebugOverlay {
id: debugOverlay
visible: true

x: 0
y: 0
Expand Down
34 changes: 34 additions & 0 deletions resources/qml/debug/ActionList.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.12

import "../../../resources/qml/models" as Models

ListView {
id: root
clip: true

property var actions: []

model: Models.JSONListModel {
data: root.actions
}

delegate: ItemDelegate {
width: root.width
height: 50

RowLayout {
anchors.fill: parent

Label {
Layout.fillWidth: parent
height: parent.height
font.pointSize: 20

text: name
verticalAlignment: Qt.AlignVCenter
}
}
}
}
55 changes: 55 additions & 0 deletions resources/qml/debug/Console.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

import "./ConsoleComponents"

Item {
id: root

ColumnLayout {
anchors.fill: parent

ListView {
id: replView

Layout.fillHeight: parent
Layout.fillWidth: parent

verticalLayoutDirection: ListView.BottomToTop

clip: true

model: ListModel {
id: logsModel

ListElement {
replType: "info"
replLine: ">>>"
}

function addLine(type, line) {
insert(0, {replLine: line, replType: type})
}
}

delegate: LineDelegate {
width: parent.width
}
}

ReplEdit {
id: replEdit
Layout.fillWidth: parent

onEvalRequested: {
logsModel.addLine("command", line)
try {
logsModel.addLine("result", `${eval(line)}`)
} catch (e) {
logsModel.addLine("error", `${e}`)
}
}
}
}
}
37 changes: 37 additions & 0 deletions resources/qml/debug/ConsoleComponents/LineDelegate.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

import "../../MDI" as MDI

ItemDelegate {
height: lineLabel.height

property var typeIcons:({
"command": "arrowLeft",
"result": "arrowRight",
"error": "bug",
"info": "information"
})

RowLayout {
anchors.fill: parent

MDI.Icon {
Layout.preferredWidth: 30

name: typeIcons[replType]
color: "gray"
}

Label {
id: lineLabel

Layout.fillWidth: parent

font.pointSize: 16

text: replLine
}
}
}
45 changes: 45 additions & 0 deletions resources/qml/debug/ConsoleComponents/ReplEdit.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

TextArea {
id: root

property var history: []
property int historyPosition: 0

signal evalRequested(string line)

onHistoryPositionChanged: {
text = historyPosition === history.length ? "" : history[historyPosition]
}

Keys.onPressed: (event)=> {
switch(event.key) {
case Qt.Key_Return:
if (event.modifiers === 0) {
event.accepted = true
root.evalRequested(root.text)
history.push(root.text)
historyPosition = history.length
}
break

case Qt.Key_Up:
if (historyPosition > 0) {
event.accepted = true
historyPosition -= 1
root.cursorPosition = root.text.length
}
break

case Qt.Key_Down:
if (historyPosition < history.length) {
event.accepted = true
historyPosition += 1
root.cursorPosition = root.text.length
}
break
}
}
}
Loading

0 comments on commit 187167d

Please sign in to comment.