mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:47:41 +02:00
planky:
- removed workaround for delayed overlay loading - make buttons functional (reset, cleanup, save-default) - only show live changes for the visual planky properties: blocksize , numLayers etc. (no physical properties)
This commit is contained in:
parent
8ed9eb0633
commit
b711022796
1 changed files with 44 additions and 30 deletions
|
@ -68,14 +68,28 @@ SettingsWindow = function() {
|
||||||
case 'value_change':
|
case 'value_change':
|
||||||
_this.plankyStack.onValueChanged(data.option, data.value);
|
_this.plankyStack.onValueChanged(data.option, data.value);
|
||||||
break;
|
break;
|
||||||
|
case 'factory-reset':
|
||||||
|
_this.plankyStack.options.factoryReset();
|
||||||
|
_this.sendData({action: 'load', options: _this.plankyStack.options.getJSON()})
|
||||||
|
break;
|
||||||
|
case 'save-default':
|
||||||
|
_this.plankyStack.options.save();
|
||||||
|
break;
|
||||||
|
case 'cleanup':
|
||||||
|
_this.plankyStack.deRez();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Window.alert('unknown action ' + data.action);
|
Window.alert('[planky] unknown action ' + data.action);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
PlankyOptions = function() {
|
PlankyOptions = function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
this.factoryReset = function() {
|
||||||
|
_this.setDefaults();
|
||||||
|
Settings.setValue('plankyOptions', '');
|
||||||
|
};
|
||||||
this.save = function() {
|
this.save = function() {
|
||||||
Settings.setValue('plankyOptions', JSON.stringify(_this.getJSON()));
|
Settings.setValue('plankyOptions', JSON.stringify(_this.getJSON()));
|
||||||
};
|
};
|
||||||
|
@ -86,9 +100,9 @@ PlankyOptions = function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var options = JSON.parse(plankyOptions);
|
var options = JSON.parse(plankyOptions);
|
||||||
options.forEach(function(value, option, object) {
|
for (option in options) {
|
||||||
_this[option] = value;
|
_this[option] = options[option];
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
this.getJSON = function() {
|
this.getJSON = function() {
|
||||||
return {
|
return {
|
||||||
|
@ -147,9 +161,10 @@ PlankyStack = function() {
|
||||||
})
|
})
|
||||||
if (_this.centerLine) {
|
if (_this.centerLine) {
|
||||||
Entities.deleteEntity(_this.centerLine);
|
Entities.deleteEntity(_this.centerLine);
|
||||||
}
|
}
|
||||||
_this.ground = false;
|
_this.ground = false;
|
||||||
_this.centerLine = false;
|
_this.centerLine = false;
|
||||||
|
_this.editLines = [];
|
||||||
};
|
};
|
||||||
this.rez = function() {
|
this.rez = function() {
|
||||||
if (_this.planks.length > 0) {
|
if (_this.planks.length > 0) {
|
||||||
|
@ -243,7 +258,9 @@ PlankyStack = function() {
|
||||||
};
|
};
|
||||||
this.onValueChanged = function(option, value) {
|
this.onValueChanged = function(option, value) {
|
||||||
_this.options[option] = value;
|
_this.options[option] = value;
|
||||||
_this.refresh();
|
if (['numLayers', 'blocksPerLayer', 'blockSize', 'blockSpacing', 'blockHeightVariation'].indexOf(option) !== -1) {
|
||||||
|
_this.refresh();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this.refresh = function() {
|
this.refresh = function() {
|
||||||
refreshGround();
|
refreshGround();
|
||||||
|
@ -284,31 +301,28 @@ function grabLowestJointY() {
|
||||||
return floorY;
|
return floorY;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createButtons() {
|
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.games.planky", function (windowDimensions, toolbar) {
|
||||||
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.games.planky", function (windowDimensions, toolbar) {
|
return {
|
||||||
return {
|
x: windowDimensions.x - (toolbar.width * 1.1),
|
||||||
x: windowDimensions.x - (toolbar.width * 1.1),
|
y: toolbar.height / 2
|
||||||
y: toolbar.height / 2
|
};
|
||||||
};
|
});
|
||||||
});
|
|
||||||
button = toolBar.addTool({
|
|
||||||
width: BUTTON_DIMENSIONS.width,
|
|
||||||
height: BUTTON_DIMENSIONS.height,
|
|
||||||
imageURL: HIFI_PUBLIC_BUCKET + 'marketplace/hificontent/Games/blocks/planky_button.svg',
|
|
||||||
alpha: 0.8,
|
|
||||||
visible: true
|
|
||||||
});
|
|
||||||
|
|
||||||
cogButton = toolBar.addTool({
|
button = toolBar.addTool({
|
||||||
width: BUTTON_DIMENSIONS.width,
|
width: BUTTON_DIMENSIONS.width,
|
||||||
height: BUTTON_DIMENSIONS.height,
|
height: BUTTON_DIMENSIONS.height,
|
||||||
imageURL: HIFI_PUBLIC_BUCKET + 'marketplace/hificontent/Games/blocks/cog.svg',
|
imageURL: HIFI_PUBLIC_BUCKET + 'marketplace/hificontent/Games/blocks/planky_button.svg',
|
||||||
alpha: 0.8,
|
alpha: 0.8,
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
}
|
|
||||||
// Fixes bug of not showing buttons on startup
|
cogButton = toolBar.addTool({
|
||||||
Script.setTimeout(createButtons, 2000);
|
width: BUTTON_DIMENSIONS.width,
|
||||||
|
height: BUTTON_DIMENSIONS.height,
|
||||||
|
imageURL: HIFI_PUBLIC_BUCKET + 'marketplace/hificontent/Games/blocks/cog.svg',
|
||||||
|
alpha: 0.8,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(function(event) {
|
Controller.mousePressEvent.connect(function(event) {
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||||
|
|
Loading…
Reference in a new issue