payload properly shared
This commit is contained in:
1 parent
fdaf322278
commit
7de9979f56
6 files changed
+21
-12
No files matched your search
@@ -22,10 +22,12 @@ function newCircularMenu () {
|
||||
|
||||
let menuItemsInitialValues = []
|
||||
let menuItems = []
|
||||
let payload
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize (menuItemsInitialValues) {
|
||||
function initialize (menuItemsInitialValues, pPayload) {
|
||||
payload = pPayload
|
||||
/* Create the array of Menu Items */
|
||||
|
||||
for (let i = 0; i < menuItemsInitialValues.length; i++) {
|
||||
@@ -41,7 +43,7 @@ function newCircularMenu () {
|
||||
menuItem.currentRadius = menuItemInitialValue.currentRadius
|
||||
menuItem.angle = menuItemInitialValue.angle
|
||||
|
||||
menuItem.initialize()
|
||||
menuItem.initialize(payload)
|
||||
menuItem.container.connectToParent(thisObject.container, false, false, true, true, false, false, true, true)
|
||||
menuItems.push(menuItem)
|
||||
}
|
||||
|
||||
@@ -34,10 +34,12 @@ function newCircularMenuItem () {
|
||||
thisObject.container.frame.height = 30
|
||||
|
||||
let isMouseOver = false
|
||||
let payload
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize () {
|
||||
function initialize (pPayload) {
|
||||
payload = pPayload
|
||||
/* Load Menu Images */
|
||||
|
||||
thisObject.iconOn = new Image()
|
||||
@@ -97,7 +99,7 @@ function newCircularMenuItem () {
|
||||
}
|
||||
|
||||
function onMouseClick (event) {
|
||||
console.log('Menu item clicked')
|
||||
payload.onMenuItemClick(payload)
|
||||
}
|
||||
|
||||
function drawBackground () {
|
||||
|
||||
@@ -89,7 +89,7 @@ function newFloatingObject () {
|
||||
|
||||
case 'Strategy Part': {
|
||||
thisObject.underlayingObject = newStrategyPart()
|
||||
thisObject.underlayingObject.initialize(floatingLayer, pSubType)
|
||||
thisObject.underlayingObject.initialize(floatingLayer, pSubType, thisObject.payload)
|
||||
thisObject.underlayingObject.container.connectToParent(thisObject.container, false, false, true, true, false, false, true, true)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -25,10 +25,12 @@ function newStrategyPart () {
|
||||
let floatingLayer
|
||||
let image
|
||||
let imagePath
|
||||
let payload
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize (pFloatingLayer, pType) {
|
||||
function initialize (pFloatingLayer, pType, pPayload) {
|
||||
payload = pPayload
|
||||
floatingLayer = pFloatingLayer
|
||||
|
||||
let menuItemsInitialValues = []
|
||||
@@ -239,7 +241,7 @@ function newStrategyPart () {
|
||||
}
|
||||
|
||||
thisObject.menu = newCircularMenu()
|
||||
thisObject.menu.initialize(menuItemsInitialValues)
|
||||
thisObject.menu.initialize(menuItemsInitialValues, payload)
|
||||
thisObject.menu.container.connectToParent(thisObject.container, false, false, true, true, false, false, true, true)
|
||||
|
||||
/* Load Part Image */
|
||||
|
||||
@@ -35,12 +35,12 @@ function newStrategyParts () {
|
||||
|
||||
function createNewStrategyPart (type, pPayload, callBackFunction) {
|
||||
let floatingObject = newFloatingObject()
|
||||
floatingObject.payload = pPayload
|
||||
floatingObject.initialize('Strategy Part', type, floatingLayer, onInitialized)
|
||||
floatingObject.underlayingObject.type = type
|
||||
|
||||
function onInitialized (err) {
|
||||
const FRICTION = 0.97
|
||||
floatingObject.payload = pPayload
|
||||
|
||||
switch (type) {
|
||||
case 'Strategy': {
|
||||
|
||||
@@ -50,6 +50,11 @@ function newStrategyCollectionItem () {
|
||||
}
|
||||
}
|
||||
|
||||
function onMenuItemClick (payload) {
|
||||
console.log('onMenuItemClick')
|
||||
payload.profile.upLabel = payload.profile.upLabel + '1'
|
||||
}
|
||||
|
||||
function createPart (partType, name, node, parentNode, title) {
|
||||
let payload = {
|
||||
profile: {
|
||||
@@ -62,8 +67,6 @@ function newStrategyCollectionItem () {
|
||||
notes: []
|
||||
}
|
||||
|
||||
let imageId // 'My Image.png'
|
||||
|
||||
if (title !== undefined) {
|
||||
payload.profile.upLabel = title
|
||||
} else {
|
||||
@@ -71,9 +74,9 @@ function newStrategyCollectionItem () {
|
||||
}
|
||||
|
||||
payload.profile.downLabel = name
|
||||
payload.node = node
|
||||
payload.parentNode = parentNode
|
||||
|
||||
node.payload = payload
|
||||
payload.onMenuItemClick = onMenuItemClick
|
||||
|
||||
canvas.floatingSpace.strategyParts.createNewStrategyPart(partType, payload, onStrategyPartCreated)
|
||||
|
||||
|
||||
Reference in new issue
Block a user