mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 18:24:09 +02:00
Merge pull request #11652 from cain-kilgore/21508
WL 21508 - Improve upon Skybox Changer (Updated)
This commit is contained in:
commit
03b46c5e62
2 changed files with 17 additions and 88 deletions
|
@ -12,6 +12,7 @@
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import "../styles-uit"
|
import "../styles-uit"
|
||||||
import "../controls-uit" as HifiControls
|
import "../controls-uit" as HifiControls
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root;
|
id: root;
|
||||||
|
@ -20,7 +21,7 @@ Item {
|
||||||
property var defaultThumbnails: [];
|
property var defaultThumbnails: [];
|
||||||
property var defaultFulls: [];
|
property var defaultFulls: [];
|
||||||
|
|
||||||
SkyboxSelectionModel {
|
ListModel {
|
||||||
id: skyboxModel;
|
id: skyboxModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,47 +39,22 @@ Item {
|
||||||
|
|
||||||
function sortSkyboxes(response) {
|
function sortSkyboxes(response) {
|
||||||
var arr = JSON.parse(response);
|
var arr = JSON.parse(response);
|
||||||
for (var i = 0; i < arr.length; i++) {
|
var arrLength = arr.length;
|
||||||
|
for (var i = 0; i < arrLength; i++) {
|
||||||
defaultThumbnails.push(arr[i].thumb);
|
defaultThumbnails.push(arr[i].thumb);
|
||||||
defaultFulls.push(arr[i].full);
|
defaultFulls.push(arr[i].full);
|
||||||
|
skyboxModel.append({});
|
||||||
}
|
}
|
||||||
setDefaultSkyboxes();
|
setSkyboxes();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefaultSkyboxes() {
|
function setSkyboxes() {
|
||||||
for (var i = 0; i < skyboxModel.count; i++) {
|
for (var i = 0; i < skyboxModel.count; i++) {
|
||||||
skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[i]);
|
skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[i]);
|
||||||
skyboxModel.setProperty(i, "fullSkyboxPath", defaultFulls[i]);
|
skyboxModel.setProperty(i, "fullSkyboxPath", defaultFulls[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function shuffle(array) {
|
|
||||||
var tmp, current, top = array.length;
|
|
||||||
if (top) {
|
|
||||||
while (--top) {
|
|
||||||
current = Math.floor(Math.random() * (top + 1));
|
|
||||||
tmp = array[current];
|
|
||||||
array[current] = array[top];
|
|
||||||
array[top] = tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
function chooseRandom() {
|
|
||||||
for (var a = [], i=0; i < defaultFulls.length; ++i) {
|
|
||||||
a[i] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
a = shuffle(a);
|
|
||||||
|
|
||||||
for (var i = 0; i < skyboxModel.count; i++) {
|
|
||||||
skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[a[i]]);
|
|
||||||
skyboxModel.setProperty(i, "fullSkyboxPath", defaultFulls[a[i]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
getSkyboxes();
|
getSkyboxes();
|
||||||
}
|
}
|
||||||
|
@ -116,33 +92,18 @@ Item {
|
||||||
horizontalAlignment: Text.AlignHCenter;
|
horizontalAlignment: Text.AlignHCenter;
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
}
|
}
|
||||||
HifiControls.Button {
|
|
||||||
id: randomButton
|
|
||||||
text: "Randomize"
|
|
||||||
color: hifi.buttons.blue
|
|
||||||
colorScheme: root.colorScheme
|
|
||||||
width: 100
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.topMargin: 5
|
|
||||||
anchors.rightMargin: 40
|
|
||||||
onClicked: {
|
|
||||||
chooseRandom()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GridView {
|
GridView {
|
||||||
id: gridView
|
id: gridView
|
||||||
interactive: false
|
interactive: true
|
||||||
clip: true
|
clip: true
|
||||||
anchors.top: titleBarContainer.bottom
|
anchors.top: titleBarContainer.bottom
|
||||||
anchors.topMargin: 20
|
anchors.topMargin: 20
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
width: 400
|
width: 400
|
||||||
height: parent.height
|
anchors.bottom: parent.bottom
|
||||||
currentIndex: -1
|
currentIndex: -1
|
||||||
|
|
||||||
cellWidth: 200
|
cellWidth: 200
|
||||||
cellHeight: 200
|
cellHeight: 200
|
||||||
model: skyboxModel
|
model: skyboxModel
|
||||||
|
@ -168,6 +129,14 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ScrollBar.vertical: ScrollBar {
|
||||||
|
parent: gridView.parent
|
||||||
|
anchors.top: gridView.top
|
||||||
|
anchors.left: gridView.right
|
||||||
|
anchors.bottom: gridView.bottom
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
width: 19
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signal sendToScript(var message);
|
signal sendToScript(var message);
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
//
|
|
||||||
// SkyboxSelectionModel.qml
|
|
||||||
// qml/hifi
|
|
||||||
//
|
|
||||||
// Created by Cain Kilgore on 21st October 2017
|
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// 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.5
|
|
||||||
|
|
||||||
ListModel {
|
|
||||||
id: root;
|
|
||||||
ListElement{
|
|
||||||
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
|
|
||||||
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
|
|
||||||
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
|
|
||||||
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
|
|
||||||
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
|
|
||||||
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
|
|
||||||
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue