diff --git a/FloatingSpace/FloatingLayer.js b/FloatingSpace/FloatingLayer.js index 8beef9810..7beca69af 100644 --- a/FloatingSpace/FloatingLayer.js +++ b/FloatingSpace/FloatingLayer.js @@ -203,7 +203,7 @@ function newFloatingLayer () { for (let i = 0; i < invisibleFloatingObjects.length; i++) { let floatingObject = invisibleFloatingObjects[i] - if (floatingObject.isFrozen === false) { + if (floatingObject.isFrozen === false && floatingObject.isTensed === false) { visibleFloatingObjects.push(floatingObject) invisibleFloatingObjects.splice(i, 1) // Delete item from array. return // Only one at the time. @@ -215,7 +215,7 @@ function newFloatingLayer () { for (let i = 0; i < visibleFloatingObjects.length; i++) { let floatingObject = visibleFloatingObjects[i] - if (floatingObject.isFrozen === true) { + if (floatingObject.isFrozen === true || floatingObject.isTensed === true) { invisibleFloatingObjects.push(floatingObject) visibleFloatingObjects.splice(i, 1) // Delete item from array. return // Only one at the time. diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index bc9462f71..3cf5f06e3 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -22,13 +22,16 @@ function newFloatingObject () { targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value. isPinned: false, isFrozen: false, + isTensed: false, frozenManually: false, getPinStatus: getPinStatus, getFreezeStatus: getFreezeStatus, + getTensionStatus: getTensionStatus, nearbyFloatingObjects: [], setPosition: setPosition, pinToggle: pinToggle, freezeToggle: freezeToggle, + tensionToggle: tensionToggle, physics: physics, initializeMass: initializeMass, initializeRadius: initializeRadius, @@ -124,6 +127,10 @@ function newFloatingObject () { return thisObject.isFrozen } + function getTensionStatus () { + return thisObject.isTensed + } + function freezeToggle () { if (thisObject.isFrozen !== true) { thisObject.isFrozen = true @@ -135,10 +142,22 @@ function newFloatingObject () { return thisObject.isFrozen } + function tensionToggle () { + if (thisObject.isTensed !== true) { + thisObject.isTensed = true + thisObject.tensedManually = true + } else { + thisObject.isTensed = false + thisObject.tensedManually = false + } + return thisObject.isTensed + } + function physics () { thisObjectPhysics() thisObject.payload.uiObject.physics() frozenPhysics() + tensionPhysics() } function frozenPhysics () { @@ -150,6 +169,15 @@ function newFloatingObject () { } } + function tensionPhysics () { + if (thisObject.tensedManually === false) { + let parent = thisObject.payload.chainParent + if (parent !== undefined) { + thisObject.isTensed = parent.payload.floatingObject.isTensed + } + } + } + function thisObjectPhysics () { // The radius also have a target. @@ -298,12 +326,21 @@ function newFloatingObject () { } function initializeCurrentPosition (arroundPoint) { - let position + let position = {} if (thisObject.payload.position === undefined) { - position = { - x: Math.floor((Math.random() * (200) - 100)) + arroundPoint.x, - y: Math.floor((Math.random() * (200) - 100)) + arroundPoint.y + if (thisObject.payload.chainParent !== undefined) { + position.x = thisObject.payload.chainParent.payload.position.x + 250 + if (thisObject.payload.node.type === thisObject.payload.chainParent.type) { + position.y = thisObject.payload.chainParent.payload.position.y + } else { + position.y = thisObject.payload.chainParent.payload.position.y + Math.floor((Math.random() * (1000) - 500)) + } + } else { + position = { + x: Math.floor((Math.random() * (200) - 100)) + arroundPoint.x, + y: Math.floor((Math.random() * (200) - 100)) + arroundPoint.y + } } } else { position = { diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 565554632..8391e6e86 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -592,11 +592,12 @@ function newStrategyPart () { if (thisObject.container.frame.radius > 1) { /* Target Line */ - let LINE_STYLE + let LINE_STYLE = UI_COLOR.TITANIUM_YELLOW + if (thisObject.payload.floatingObject.isTensed === true) { + LINE_STYLE = UI_COLOR.GOLDEN_ORANGE + } if (thisObject.payload.floatingObject.isFrozen === true) { LINE_STYLE = UI_COLOR.TURQUOISE - } else { - LINE_STYLE = UI_COLOR.TITANIUM_YELLOW } browserCanvasContext.beginPath() diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index a017961cd..eda67cb67 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -51,6 +51,9 @@ function newStrategyPartConstructor () { if (payload.node.savedPayload.floatingObject.isFrozen === true) { floatingObject.freezeToggle() } + if (payload.node.savedPayload.floatingObject.isTensed === true) { + floatingObject.tensionToggle() + } } let strategyPart = newStrategyPart() @@ -67,10 +70,11 @@ function newStrategyPartConstructor () { canvas.strategySpace.workspace.tradingSystem = payload.node } } - payload.node.savedPayload = undefined setFloatingObjectBasicProperties(floatingObject, payload) + payload.node.savedPayload = undefined + floatingLayer.addFloatingObject(floatingObject) return @@ -97,20 +101,6 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, - { - action: 'Freeze / Unfreeze', - actionFunction: floatingObject.freezeToggle, - actionStatus: floatingObject.getFreezeStatus, - currentStatus: true, - label: undefined, - visible: false, - iconPathOn: 'broken-link', - iconPathOff: 'targeting', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 135 - }, { action: 'Download Workspace', actionFunction: payload.onMenuItemClick, @@ -143,6 +133,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: true, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -254,6 +258,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -324,6 +342,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -395,6 +427,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -465,6 +511,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -548,6 +608,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -618,6 +692,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -688,6 +776,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -746,6 +848,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -817,6 +933,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -888,6 +1018,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -959,6 +1103,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1030,6 +1188,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1100,6 +1272,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1171,6 +1357,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1242,6 +1442,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1331,6 +1545,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1402,6 +1630,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1473,6 +1715,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1544,6 +1800,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1620,6 +1890,20 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, + { + action: 'Tense / Untense', + actionFunction: floatingObject.tensionToggle, + actionStatus: floatingObject.getTensionStatus, + currentStatus: false, + label: undefined, + visible: false, + iconPathOn: 'compass', + iconPathOff: 'headphones', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 180 + }, { action: 'Freeze / Unfreeze', actionFunction: floatingObject.freezeToggle, @@ -1804,6 +2088,10 @@ function newStrategyPartConstructor () { floatingObject.initializeFontSize(10) floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' + + if (payload.node.savedPayload === undefined) { + floatingObject.tensionToggle() + } } function level_2 () { @@ -1816,6 +2104,10 @@ function newStrategyPartConstructor () { floatingObject.initializeFontSize(10) floatingObject.fillStyle = 'rgba(' + UI_COLOR.GREEN + ', 1)' + + if (payload.node.savedPayload === undefined) { + floatingObject.tensionToggle() + } } function level_3 () { @@ -1828,6 +2120,10 @@ function newStrategyPartConstructor () { floatingObject.initializeFontSize(10) floatingObject.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', 1)' + + if (payload.node.savedPayload === undefined) { + floatingObject.tensionToggle() + } } function level_4 () { diff --git a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js index c7691e2bb..16638aedb 100644 --- a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js +++ b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js @@ -310,7 +310,8 @@ function newStringifyNode () { }, floatingObject: { isPinned: node.payload.floatingObject.isPinned, - isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually) + isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), + isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually) }, uiObject: { isRunning: node.payload.uiObject.isRunning