mirror of
https://github.com/lubosz/overte.git
synced 2025-04-15 18:48:32 +02:00
working on loading files
This commit is contained in:
parent
cc34cb96e4
commit
64fcfd33a4
5 changed files with 62 additions and 9 deletions
|
@ -14,6 +14,7 @@ import QtQuick.Dialogs 1.2 as OriginalDialogs
|
|||
import "../../styles-uit"
|
||||
import "../../controls-uit" as HifiControls
|
||||
import "../../windows"
|
||||
import "../../dialogs"
|
||||
|
||||
Rectangle {
|
||||
id: inputRecorder
|
||||
|
@ -21,8 +22,10 @@ Rectangle {
|
|||
HifiConstants { id: hifi }
|
||||
signal sendToScript(var message);
|
||||
color: hifi.colors.baseGray;
|
||||
property string path: ""
|
||||
property var dialog: null;
|
||||
|
||||
|
||||
Component { id: fileDialog; TabletFileDialog { } }
|
||||
Row {
|
||||
id: topButtons
|
||||
width: parent.width
|
||||
|
@ -39,6 +42,9 @@ Rectangle {
|
|||
text: "Start"
|
||||
color: hifi.buttons.blue
|
||||
enabled: true
|
||||
onClicked: {
|
||||
sendToScript({method: "Start"});
|
||||
}
|
||||
}
|
||||
|
||||
HifiControls.Button {
|
||||
|
@ -46,6 +52,9 @@ Rectangle {
|
|||
text: "Stop"
|
||||
color: hifi.buttons.blue
|
||||
enabled: true
|
||||
onClicked: {
|
||||
sendToScript({method: "Stop"});
|
||||
}
|
||||
}
|
||||
|
||||
HifiControls.Button {
|
||||
|
@ -53,6 +62,9 @@ Rectangle {
|
|||
text: "Save"
|
||||
color: hifi.buttons.blue
|
||||
enabled: true
|
||||
onClicked: {
|
||||
sendToScript({method: "Save"});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -80,6 +92,7 @@ Rectangle {
|
|||
text: "Load"
|
||||
color: hifi.buttons.black
|
||||
enabled: true
|
||||
onClicked: sendToScript({method: "Load", params: {file: path }});
|
||||
}
|
||||
|
||||
HifiControls.Button {
|
||||
|
@ -91,13 +104,18 @@ Rectangle {
|
|||
text: "Browse"
|
||||
color: hifi.buttons.black
|
||||
enabled: true
|
||||
onClicked: {
|
||||
dialog = fileDialog.createObject(inputRecorder);
|
||||
dialog.selectedFile.connect(getFileSelected);
|
||||
}
|
||||
}
|
||||
|
||||
Trigger {
|
||||
id: browseTimer
|
||||
interval: 5
|
||||
repeat: false
|
||||
running: false
|
||||
|
||||
|
||||
function getFileSelected(file) {
|
||||
console.log("------------> file selected <----------------");
|
||||
//sendToScript({ method: "Load", params: { file: file} });
|
||||
selectedFile.text = file;
|
||||
inputRecorder.path = file;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,18 @@ namespace controller {
|
|||
QByteArray compressedData = qCompress(saveData.toJson(QJsonDocument::Compact));
|
||||
saveFile.write(compressedData);
|
||||
}
|
||||
|
||||
bool openFile(const QString& file, QJsonObject& object) {
|
||||
QFile openFile(file);
|
||||
if (!openFile.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << "could not open file: " << file;
|
||||
return false;
|
||||
}
|
||||
QByteArray compressedData = qUncompress(openFile.readAll());
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromBinaryData(compressedData);
|
||||
object = jsonDoc.object();
|
||||
return true;
|
||||
}
|
||||
|
||||
InputRecorder::InputRecorder() {}
|
||||
|
||||
|
@ -119,7 +131,16 @@ namespace controller {
|
|||
exportToFile(data);
|
||||
}
|
||||
|
||||
void InputRecorder::loadRecording() {
|
||||
void InputRecorder::loadRecording(const QString& path) {
|
||||
QFileInfo info(path);
|
||||
QString extension = info.suffix();
|
||||
if (extension != "gz") {
|
||||
qWarning() << "Could not open file of that type";
|
||||
return;
|
||||
}
|
||||
QJsonObject data;
|
||||
bool success = openFile(path, data);
|
||||
qDebug() << "-------------------> loading file -------------->";
|
||||
}
|
||||
|
||||
void InputRecorder::stopRecording() {
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <atomic>
|
||||
#include <vector>
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "Pose.h"
|
||||
#include "Actions.h"
|
||||
|
||||
|
@ -28,7 +30,7 @@ namespace controller {
|
|||
static InputRecorder* getInstance();
|
||||
|
||||
void saveRecording();
|
||||
void loadRecording();
|
||||
void loadRecording(const QString& path);
|
||||
void startRecording();
|
||||
void startPlayback();
|
||||
void stopPlayback();
|
||||
|
|
|
@ -175,6 +175,16 @@ namespace controller {
|
|||
inputRecorder->stopPlayback();
|
||||
}
|
||||
|
||||
void ScriptingInterface::saveInputRecording() {
|
||||
InputRecorder* inputRecorder = InputRecorder::getInstance();
|
||||
inputRecorder->saveRecording();
|
||||
}
|
||||
|
||||
void ScriptingInterface::loadInputRecording(const QString& file) {
|
||||
InputRecorder* inputRecorder = InputRecorder::getInstance();
|
||||
inputRecorder->loadRecording(file);
|
||||
}
|
||||
|
||||
bool ScriptingInterface::triggerHapticPulseOnDevice(unsigned int device, float strength, float duration, controller::Hand hand) const {
|
||||
return DependencyManager::get<UserInputMapper>()->triggerHapticPulseOnDevice(device, strength, duration, hand);
|
||||
}
|
||||
|
|
|
@ -103,6 +103,8 @@ namespace controller {
|
|||
Q_INVOKABLE void stopInputRecording();
|
||||
Q_INVOKABLE void startInputPlayback();
|
||||
Q_INVOKABLE void stopInputPlayback();
|
||||
Q_INVOKABLE void saveInputRecording();
|
||||
Q_INVOKABLE void loadInputRecording(const QString& file);
|
||||
|
||||
bool isMouseCaptured() const { return _mouseCaptured; }
|
||||
bool isTouchCaptured() const { return _touchCaptured; }
|
||||
|
|
Loading…
Reference in a new issue