mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:12:53 +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 "../../styles-uit"
|
||||||
import "../../controls-uit" as HifiControls
|
import "../../controls-uit" as HifiControls
|
||||||
import "../../windows"
|
import "../../windows"
|
||||||
|
import "../../dialogs"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: inputRecorder
|
id: inputRecorder
|
||||||
|
@ -21,8 +22,10 @@ Rectangle {
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
signal sendToScript(var message);
|
signal sendToScript(var message);
|
||||||
color: hifi.colors.baseGray;
|
color: hifi.colors.baseGray;
|
||||||
|
property string path: ""
|
||||||
|
property var dialog: null;
|
||||||
|
|
||||||
|
Component { id: fileDialog; TabletFileDialog { } }
|
||||||
Row {
|
Row {
|
||||||
id: topButtons
|
id: topButtons
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -39,6 +42,9 @@ Rectangle {
|
||||||
text: "Start"
|
text: "Start"
|
||||||
color: hifi.buttons.blue
|
color: hifi.buttons.blue
|
||||||
enabled: true
|
enabled: true
|
||||||
|
onClicked: {
|
||||||
|
sendToScript({method: "Start"});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
|
@ -46,6 +52,9 @@ Rectangle {
|
||||||
text: "Stop"
|
text: "Stop"
|
||||||
color: hifi.buttons.blue
|
color: hifi.buttons.blue
|
||||||
enabled: true
|
enabled: true
|
||||||
|
onClicked: {
|
||||||
|
sendToScript({method: "Stop"});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
|
@ -53,6 +62,9 @@ Rectangle {
|
||||||
text: "Save"
|
text: "Save"
|
||||||
color: hifi.buttons.blue
|
color: hifi.buttons.blue
|
||||||
enabled: true
|
enabled: true
|
||||||
|
onClicked: {
|
||||||
|
sendToScript({method: "Save"});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,6 +92,7 @@ Rectangle {
|
||||||
text: "Load"
|
text: "Load"
|
||||||
color: hifi.buttons.black
|
color: hifi.buttons.black
|
||||||
enabled: true
|
enabled: true
|
||||||
|
onClicked: sendToScript({method: "Load", params: {file: path }});
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
|
@ -91,13 +104,18 @@ Rectangle {
|
||||||
text: "Browse"
|
text: "Browse"
|
||||||
color: hifi.buttons.black
|
color: hifi.buttons.black
|
||||||
enabled: true
|
enabled: true
|
||||||
|
onClicked: {
|
||||||
|
dialog = fileDialog.createObject(inputRecorder);
|
||||||
|
dialog.selectedFile.connect(getFileSelected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Trigger {
|
|
||||||
id: browseTimer
|
function getFileSelected(file) {
|
||||||
interval: 5
|
console.log("------------> file selected <----------------");
|
||||||
repeat: false
|
//sendToScript({ method: "Load", params: { file: file} });
|
||||||
running: false
|
selectedFile.text = file;
|
||||||
|
inputRecorder.path = file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,18 @@ namespace controller {
|
||||||
QByteArray compressedData = qCompress(saveData.toJson(QJsonDocument::Compact));
|
QByteArray compressedData = qCompress(saveData.toJson(QJsonDocument::Compact));
|
||||||
saveFile.write(compressedData);
|
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() {}
|
InputRecorder::InputRecorder() {}
|
||||||
|
|
||||||
|
@ -119,7 +131,16 @@ namespace controller {
|
||||||
exportToFile(data);
|
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() {
|
void InputRecorder::stopRecording() {
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include "Pose.h"
|
#include "Pose.h"
|
||||||
#include "Actions.h"
|
#include "Actions.h"
|
||||||
|
|
||||||
|
@ -28,7 +30,7 @@ namespace controller {
|
||||||
static InputRecorder* getInstance();
|
static InputRecorder* getInstance();
|
||||||
|
|
||||||
void saveRecording();
|
void saveRecording();
|
||||||
void loadRecording();
|
void loadRecording(const QString& path);
|
||||||
void startRecording();
|
void startRecording();
|
||||||
void startPlayback();
|
void startPlayback();
|
||||||
void stopPlayback();
|
void stopPlayback();
|
||||||
|
|
|
@ -175,6 +175,16 @@ namespace controller {
|
||||||
inputRecorder->stopPlayback();
|
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 {
|
bool ScriptingInterface::triggerHapticPulseOnDevice(unsigned int device, float strength, float duration, controller::Hand hand) const {
|
||||||
return DependencyManager::get<UserInputMapper>()->triggerHapticPulseOnDevice(device, strength, duration, hand);
|
return DependencyManager::get<UserInputMapper>()->triggerHapticPulseOnDevice(device, strength, duration, hand);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,8 @@ namespace controller {
|
||||||
Q_INVOKABLE void stopInputRecording();
|
Q_INVOKABLE void stopInputRecording();
|
||||||
Q_INVOKABLE void startInputPlayback();
|
Q_INVOKABLE void startInputPlayback();
|
||||||
Q_INVOKABLE void stopInputPlayback();
|
Q_INVOKABLE void stopInputPlayback();
|
||||||
|
Q_INVOKABLE void saveInputRecording();
|
||||||
|
Q_INVOKABLE void loadInputRecording(const QString& file);
|
||||||
|
|
||||||
bool isMouseCaptured() const { return _mouseCaptured; }
|
bool isMouseCaptured() const { return _mouseCaptured; }
|
||||||
bool isTouchCaptured() const { return _touchCaptured; }
|
bool isTouchCaptured() const { return _touchCaptured; }
|
||||||
|
|
Loading…
Reference in a new issue