Merge pull request #7753 from thoys/planky-settings-fix

Fix for Planky Settings window
This commit is contained in:
Brad Hefta-Gaub 2016-04-26 09:51:21 -07:00
commit 03321e1fca
2 changed files with 31 additions and 14 deletions

View file

@ -10,9 +10,9 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
HIFI_PUBLIC_BUCKET = 'http://s3.amazonaws.com/hifi-public/';
Script.include("../../libraries/toolBars.js");
Script.include('../../libraries/toolBars.js');
const DEFAULT_NUM_LAYERS = 16;
const DEFAULT_BASE_DIMENSION = { x: 7, y: 2, z: 7 };
@ -30,6 +30,8 @@ const DEFAULT_RESTITUTION = 0.0;
const DEFAULT_SPAWN_DISTANCE = 3;
const DEFAULT_BLOCK_YAW_OFFSET = 45;
const PLANKY_LIFETIME = 3600; // 1 hour (3600 seconds)
var editMode = false;
const BUTTON_DIMENSIONS = {width: 49, height: 49};
@ -51,13 +53,17 @@ SettingsWindow = function() {
this.plankyStack = null;
this.webWindow = null;
this.init = function(plankyStack) {
_this.webWindow = new OverlayWebWindow('Planky', Script.resolvePath('../../html/plankySettings.html'), 255, 500, true);
_this.webWindow = new OverlayWebWindow({
title: 'Planky',
source: Script.resolvePath('../../html/plankySettings.html'),
toolWindow: true
});
_this.webWindow.setVisible(false);
_this.webWindow.eventBridge.webEventReceived.connect(_this.onWebEventReceived);
_this.webWindow.webEventReceived.connect(_this.onWebEventReceived);
_this.plankyStack = plankyStack;
};
this.sendData = function(data) {
_this.webWindow.eventBridge.emitScriptEvent(JSON.stringify(data));
_this.webWindow.emitScriptEvent(JSON.stringify(data));
};
this.onWebEventReceived = function(data) {
data = JSON.parse(data);
@ -188,7 +194,8 @@ PlankyStack = function() {
dimensions: _this.options.baseDimension,
position: Vec3.sum(_this.basePosition, {y: -(_this.options.baseDimension.y / 2)}),
rotation: _this.baseRotation,
shapeType: 'box'
shapeType: 'box',
lifetime: PLANKY_LIFETIME
});
return;
}
@ -254,7 +261,8 @@ PlankyStack = function() {
density: _this.options.density,
velocity: {x: 0, y: 0, z: 0},
angularVelocity: Quat.fromPitchYawRollDegrees(0, 0, 0),
collisionless: true
collisionless: true,
lifetime: PLANKY_LIFETIME
};
_this.planks.forEach(function(plank, index, object) {
if (plank.layer === layer && plank.row === row) {
@ -304,6 +312,7 @@ var settingsWindow = new SettingsWindow();
var plankyStack = new PlankyStack();
settingsWindow.init(plankyStack);
// This function is used to get the ideal y-location for a floor
function grabLowestJointY() {
var jointNames = MyAvatar.getJointNames();
var floorY = MyAvatar.position.y;

View file

@ -3,11 +3,15 @@
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript" src="eventBridgeLoader.js"></script>
<script type="text/javascript">
var properties = [];
function sendWebEvent(data) {
EventBridge.emitWebEvent(JSON.stringify(data));
var sendWebEvent = function(data) {
console.log('sendWebEvent not initialized.');
}
PropertyInput = function(key, label, value, attributes) {
this.key = key;
this.label = label;
@ -93,7 +97,7 @@ function addHeader(label) {
$('#properties-list').append($('<div>').addClass('section-header').append($('<label>').text(label)));
}
$(function() {
$(function() {
addHeader('Stack Settings');
properties['numLayers'] = new NumberInput('numLayers', 'Layers', 17, {'min': 0, 'max': 300, 'step': 1});
properties['blocksPerLayer'] = new NumberInput('blocksPerLayer', 'Blocks per layer', 4, {'min': 1, 'max': 100, 'step': 1});
@ -120,7 +124,8 @@ $(function() {
.append($('<input>').val('factory reset').attr('type', 'button').on('click', function() { sendWebEvent({action: 'factory-reset'}); }))
.append($('<input>').val('save as default').attr('type', 'button').on('click', function() { sendWebEvent({action: 'save-default'}); }))
.append($('<input>').val('cleanup planky').attr('type', 'button').on('click', function() { sendWebEvent({action: 'cleanup'}); }));
if (window.EventBridge !== undefined) {
openEventBridge(function() {
EventBridge.scriptEventReceived.connect(function(data) {
data = JSON.parse(data);
if (data.action == 'load') {
@ -129,12 +134,15 @@ $(function() {
});
}
});
}
sendWebEvent({action: 'loaded'});
sendWebEvent = function(data) {
EventBridge.emitWebEvent(JSON.stringify(data));
};
sendWebEvent({action: 'loaded'});
});
});
</script>
</head>
<body class="properties">
<div id="properties-list"></div>
</body>
</html>
</html>