Merge pull request #11652 from cain-kilgore/21508

WL 21508 - Improve upon Skybox Changer (Updated)
This commit is contained in:
Zach Fox 2017-10-23 12:22:21 -07:00 committed by GitHub
commit 03b46c5e62
2 changed files with 17 additions and 88 deletions

View file

@ -12,6 +12,7 @@
import QtQuick 2.5
import "../styles-uit"
import "../controls-uit" as HifiControls
import QtQuick.Controls 2.2
Item {
id: root;
@ -20,7 +21,7 @@ Item {
property var defaultThumbnails: [];
property var defaultFulls: [];
SkyboxSelectionModel {
ListModel {
id: skyboxModel;
}
@ -38,47 +39,22 @@ Item {
function sortSkyboxes(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);
defaultFulls.push(arr[i].full);
skyboxModel.append({});
}
setDefaultSkyboxes();
setSkyboxes();
}
function setDefaultSkyboxes() {
function setSkyboxes() {
for (var i = 0; i < skyboxModel.count; i++) {
skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[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: {
getSkyboxes();
}
@ -116,33 +92,18 @@ Item {
horizontalAlignment: Text.AlignHCenter;
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 {
id: gridView
interactive: false
interactive: true
clip: true
anchors.top: titleBarContainer.bottom
anchors.topMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
width: 400
height: parent.height
anchors.bottom: parent.bottom
currentIndex: -1
cellWidth: 200
cellHeight: 200
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);

View file

@ -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"
}
}