mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 10:34:33 +02:00
add sound url prompt
This commit is contained in:
parent
b7a3fb1072
commit
eb7d97064f
3 changed files with 215 additions and 7 deletions
|
@ -51,7 +51,6 @@
|
|||
|
||||
var DEFAULT_IMAGE = Script.getExternalPath(Script.ExternalPaths.Assets, "Bazaar/Assets/Textures/Defaults/Interface/default_image.jpg");
|
||||
var DEFAULT_PARTICLE = Script.getExternalPath(Script.ExternalPaths.Assets, "Bazaar/Assets/Textures/Defaults/Interface/default_particle.png");
|
||||
var DEFAULT_SOUND = "TODO";
|
||||
|
||||
var createToolsWindow = new CreateWindow(
|
||||
Script.resolvePath("qml/EditTools.qml"),
|
||||
|
@ -497,7 +496,11 @@
|
|||
cutoff: 75.0,
|
||||
},
|
||||
Sound: {
|
||||
soundURL: DEFAULT_SOUND
|
||||
volume: 1.0,
|
||||
playing: true,
|
||||
loop: true,
|
||||
positional: true,
|
||||
localOnly: false
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -866,6 +869,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
function handleNewSoundDialogResult(result) {
|
||||
if (result) {
|
||||
var soundURL = result.textInput;
|
||||
if (soundURL) {
|
||||
createNewEntity({
|
||||
type: "Sound",
|
||||
soundURL: soundURL
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fromQml(message) { // messages are {method, params}, like json-rpc. See also sendToQml.
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
tablet.popFromStack();
|
||||
|
@ -894,6 +909,13 @@
|
|||
case "newPolyVoxDialogCancel":
|
||||
closeExistingDialogWindow();
|
||||
break;
|
||||
case "newSoundDialogAdd":
|
||||
handleNewSoundDialogResult(message.params);
|
||||
closeExistingDialogWindow();
|
||||
break;
|
||||
case "newSoundDialogCancel":
|
||||
closeExistingDialogWindow();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1063,11 +1085,7 @@
|
|||
|
||||
addButton("newPolyVoxButton", createNewEntityDialogButtonCallback("PolyVox"));
|
||||
|
||||
addButton("newSoundButton", function () {
|
||||
createNewEntity({
|
||||
type: "Sound",
|
||||
});
|
||||
});
|
||||
addButton("newSoundButton", createNewEntityDialogButtonCallback("Sound"));
|
||||
|
||||
var deactivateCreateIfDesktopWindowsHidden = function() {
|
||||
if (!shouldUseEditTabletApp() && !entityListTool.isVisible() && !createToolsWindow.isVisible()) {
|
||||
|
|
159
scripts/system/create/qml/NewSoundDialog.qml
Normal file
159
scripts/system/create/qml/NewSoundDialog.qml
Normal file
|
@ -0,0 +1,159 @@
|
|||
//
|
||||
// NewSoundDialog.qml
|
||||
// qml/hifi
|
||||
//
|
||||
// Created by HifiExperiments on 4/7/24
|
||||
// Copyright 2024 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2 as OriginalDialogs
|
||||
|
||||
import stylesUit 1.0
|
||||
import controlsUit 1.0
|
||||
import hifi.dialogs 1.0
|
||||
|
||||
Rectangle {
|
||||
id: newSoundDialog
|
||||
// width: parent.width
|
||||
// height: parent.height
|
||||
HifiConstants { id: hifi }
|
||||
color: hifi.colors.baseGray;
|
||||
signal sendToScript(var message);
|
||||
property bool keyboardEnabled: false
|
||||
property bool punctuationMode: false
|
||||
property bool keyboardRasied: false
|
||||
|
||||
function errorMessageBox(message) {
|
||||
try {
|
||||
return desktop.messageBox({
|
||||
icon: hifi.icons.warning,
|
||||
defaultButton: OriginalDialogs.StandardButton.Ok,
|
||||
title: "Error",
|
||||
text: message
|
||||
});
|
||||
} catch(e) {
|
||||
Window.alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: column1
|
||||
anchors.rightMargin: 10
|
||||
anchors.leftMargin: 10
|
||||
anchors.bottomMargin: 10
|
||||
anchors.topMargin: 10
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: keyboard.top
|
||||
|
||||
Text {
|
||||
id: text1
|
||||
text: qsTr("Sound URL")
|
||||
color: "#ffffff"
|
||||
font.pixelSize: 12
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: soundURL
|
||||
height: 20
|
||||
text: qsTr("")
|
||||
color: "white"
|
||||
anchors.top: text1.bottom
|
||||
anchors.topMargin: 5
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 0
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
font.pixelSize: 12
|
||||
|
||||
onAccepted: {
|
||||
newSoundDialog.keyboardEnabled = false;
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
newSoundDialog.keyboardEnabled = HMD.active
|
||||
parent.focus = true;
|
||||
parent.forceActiveFocus();
|
||||
soundURL.cursorPosition = soundURL.positionAt(mouseX, mouseY, TextInput.CursorBetweenCharaters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: textInputBox
|
||||
color: "white"
|
||||
anchors.fill: soundURL
|
||||
opacity: 0.1
|
||||
}
|
||||
|
||||
Row {
|
||||
id: row1
|
||||
height: 400
|
||||
spacing: 30
|
||||
anchors.top: soundURL.bottom
|
||||
anchors.topMargin: 5
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 0
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
|
||||
Column {
|
||||
id: column3
|
||||
height: 400
|
||||
spacing: 10
|
||||
|
||||
Row {
|
||||
id: row3
|
||||
width: 200
|
||||
height: 400
|
||||
spacing: 5
|
||||
|
||||
anchors.horizontalCenter: column3.horizontalCenter
|
||||
anchors.horizontalCenterOffset: 0
|
||||
|
||||
Button {
|
||||
id: button1
|
||||
text: qsTr("Create")
|
||||
z: -1
|
||||
onClicked: {
|
||||
newSoundDialog.sendToScript({
|
||||
method: "newSoundDialogAdd",
|
||||
params: {
|
||||
textInput: soundURL.text
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: button2
|
||||
z: -1
|
||||
text: qsTr("Cancel")
|
||||
onClicked: {
|
||||
newSoundDialog.sendToScript({method: "newSoundDialogCancel"})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Keyboard {
|
||||
id: keyboard
|
||||
raised: parent.keyboardEnabled
|
||||
numeric: parent.punctuationMode
|
||||
anchors {
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
}
|
||||
}
|
31
scripts/system/create/qml/NewSoundWindow.qml
Normal file
31
scripts/system/create/qml/NewSoundWindow.qml
Normal file
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// NewSoundWindow.qml
|
||||
// qml/hifi
|
||||
//
|
||||
// Created by HifiExperiments on 4/7/24
|
||||
// Copyright 2024 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
StackView {
|
||||
id: stackView
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 10
|
||||
anchors.rightMargin: 10
|
||||
anchors.topMargin: 40
|
||||
|
||||
signal sendToScript(var message);
|
||||
|
||||
NewSoundDialog {
|
||||
id: dialog
|
||||
anchors.fill: parent
|
||||
Component.onCompleted:{
|
||||
dialog.sendToScript.connect(stackView.sendToScript);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue