diff --git a/interface/resources/qml/hifi/tablet/InputRecorder.qml b/interface/resources/qml/hifi/tablet/InputRecorder.qml index e4c3526839..b9b5406a72 100644 --- a/interface/resources/qml/hifi/tablet/InputRecorder.qml +++ b/interface/resources/qml/hifi/tablet/InputRecorder.qml @@ -24,6 +24,7 @@ Rectangle { color: hifi.colors.baseGray; property string path: "" property var dialog: null; + property bool recording: false; Component { id: fileDialog; TabletFileDialog { } } Row { @@ -37,36 +38,50 @@ Rectangle { top: parent.top topMargin: 10 } + HifiControls.Button { id: start - text: "Start" - color: hifi.buttons.blue + text: "Start Recoring" + color: hifi.buttons.black enabled: true onClicked: { - sendToScript({method: "Start"}); - } - } - - HifiControls.Button { - id: stop - text: "Stop" - color: hifi.buttons.blue - enabled: true - onClicked: { - sendToScript({method: "Stop"}); + if (inputRecorder.recording) { + sendToScript({method: "Stop"}); + inputRecorder.recording = false; + start.text = "Start Recording"; + } else { + sendToScript({method: "Start"}); + inputRecorder.recording = true; + start.text = "Stop Recording"; + } } } HifiControls.Button { id: save - text: "Save" - color: hifi.buttons.blue + text: "Save Recording" + color: hifi.buttons.black enabled: true onClicked: { sendToScript({method: "Save"}); } } + + HifiControls.Button { + id: playBack + anchors.right: browse.left + anchors.top: selectedFile.bottom + anchors.topMargin: 10 + text: "Play Recording" + color: hifi.buttons.black + enabled: true + onClicked: { + sendToScript({method: "playback"}); + HMD.closeTablet(); + } + } + } HifiControls.VerticalSpacer {} @@ -110,24 +125,25 @@ Rectangle { } } - HifiControls.Button { - id: playBack - anchors.right: browse.left - anchors.top: selectedFile.bottom - anchors.topMargin: 10 - - text: "Playback" - color: hifi.buttons.black - enabled: true - onClicked: { - sendToScript({method: "playback"}); + Column { + id: notes + anchors.centerIn: parent; + spacing: 20 + + Text { + text: "All files are saved under the folder 'hifi-input-recording' in your home directory"; + color: "white" + font.pointSize: 10 + } + + Text { + text: "To cancel a recording playback press Alt-B" + color: "white" + font.pointSize: 10 } } - - + function getFileSelected(file) { - console.log("------------> file selected <----------------"); - //sendToScript({ method: "Load", params: { file: file} }); selectedFile.text = file; inputRecorder.path = file; } diff --git a/libraries/controllers/src/controllers/InputRecorder.cpp b/libraries/controllers/src/controllers/InputRecorder.cpp index 486405767b..8deb89e062 100644 --- a/libraries/controllers/src/controllers/InputRecorder.cpp +++ b/libraries/controllers/src/controllers/InputRecorder.cpp @@ -166,6 +166,10 @@ namespace controller { } void InputRecorder::loadRecording(const QString& path) { + _recording = false; + _playback = false; + _loading = true; + _playCount = 0; resetFrame(); _poseStateList.clear(); _actionStateList.clear(); @@ -174,16 +178,16 @@ namespace controller { QFileInfo info(filePath); QString extension = info.suffix(); if (extension != "gz") { - qWarning() << "Could not open file of type " << extension; + qWarning() << "can not load file with exentsion of " << extension; return; } bool success = false; QJsonObject data = openFile(info.absoluteFilePath(), success); - int count = 0; if (success) { _framesRecorded = data["frameCount"].toInt(); QJsonArray actionArrayList = data["actionList"].toArray(); QJsonArray poseArrayList = data["poseList"].toArray(); + for (int actionIndex = 0; actionIndex < actionArrayList.size(); actionIndex++) { QJsonArray actionState = actionArrayList[actionIndex].toArray(); for (int index = 0; index < actionState.size(); index++) { @@ -202,6 +206,8 @@ namespace controller { _currentFramePoses = PoseStates(toInt(Action::NUM_ACTIONS)); } } + + _loading = false; } void InputRecorder::stopRecording() { @@ -211,10 +217,12 @@ namespace controller { void InputRecorder::startPlayback() { _playback = true; _recording = false; + _playCount = 0; } void InputRecorder::stopPlayback() { _playback = false; + _playCount = 0; } void InputRecorder::setActionState(controller::Action action, float value) { diff --git a/libraries/controllers/src/controllers/InputRecorder.h b/libraries/controllers/src/controllers/InputRecorder.h index 8656966962..20b30f4b6e 100644 --- a/libraries/controllers/src/controllers/InputRecorder.h +++ b/libraries/controllers/src/controllers/InputRecorder.h @@ -39,7 +39,7 @@ namespace controller { void togglePlayback() { _playback = !_playback; } void resetFrame(); bool isRecording() { return _recording; } - bool isPlayingback() { return _playback; } + bool isPlayingback() { return (_playback && !_loading); } void setActionState(controller::Action action, float value); void setActionState(controller::Action action, const controller::Pose pose); float getActionState(controller::Action action); @@ -48,6 +48,7 @@ namespace controller { private: bool _recording { false }; bool _playback { false }; + bool _loading { false }; std::vector _poseStateList = std::vector(); std::vector _actionStateList = std::vector(); PoseStates _currentFramePoses = PoseStates(toInt(Action::NUM_ACTIONS));