diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index f3c8c1948..920b4b100 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -124,18 +124,74 @@ function newConditionEditor () { } function initializePickers () { + let properties + let parent + let current + operatorA.dataMinePicker = newPicker() operatorA.dataMinePicker.container.connectToParent(thisObject.container) - operatorA.dataMinePicker.container.frame.position.x = 0 - operatorA.dataMinePicker.container.frame.width / 2 - operatorA.dataMinePicker.container.frame.position.y = 0 - operatorA.dataMinePicker.container.frame.height / 2 - operatorA.dataMinePicker.initialize(Object.keys(operatorA.selector)) + operatorA.dataMinePicker.container.frame.position.x = 0 - operatorA.dataMinePicker.container.frame.width / 2 - operatorA.dataMinePicker.container.frame.width * 1.5 + operatorA.dataMinePicker.container.frame.position.y = 0 - operatorA.dataMinePicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + current = operatorA.selector + properties = Object.keys(current) + operatorA.dataMinePicker.initialize(properties) + parent = current + + operatorA.botPicker = newPicker() + operatorA.botPicker.container.connectToParent(thisObject.container) + operatorA.botPicker.container.frame.position.x = 0 - operatorA.botPicker.container.frame.width / 2 - operatorA.botPicker.container.frame.width * 0.5 + operatorA.botPicker.container.frame.position.y = 0 - operatorA.botPicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + current = parent[properties[0]] + properties = Object.keys(current) + operatorA.botPicker.initialize(properties, parent) + parent = current + + operatorA.productPicker = newPicker() + operatorA.productPicker.container.connectToParent(thisObject.container) + operatorA.productPicker.container.frame.position.x = 0 - operatorA.productPicker.container.frame.width / 2 + operatorA.productPicker.container.frame.width * 0.5 + operatorA.productPicker.container.frame.position.y = 0 - operatorA.productPicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + current = parent[properties[0]] + properties = Object.keys(current) + operatorA.productPicker.initialize(properties, parent) + parent = current + + operatorA.propertyPicker = newPicker() + operatorA.propertyPicker.container.connectToParent(thisObject.container) + operatorA.propertyPicker.container.frame.position.x = 0 - operatorA.propertyPicker.container.frame.width / 2 + operatorA.propertyPicker.container.frame.width * 1.5 + operatorA.propertyPicker.container.frame.position.y = 0 - operatorA.propertyPicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + current = parent[properties[0]] + properties = Object.keys(current) + operatorA.propertyPicker.initialize(properties, parent) + parent = current + + operatorA.dataMinePicker.eventSuscriptionId = operatorA.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', operatorA.botPicker.onParentChanged) + operatorA.botPicker.eventSuscriptionId = operatorA.botPicker.container.eventHandler.listenToEvent('onParentChanged', operatorA.productPicker.onParentChanged) + operatorA.productPicker.eventSuscriptionId = operatorA.productPicker.container.eventHandler.listenToEvent('onParentChanged', operatorA.propertyPicker.onParentChanged) } function finalizePickers () { if (operatorA.dataMinePicker !== undefined) { + operatorA.dataMinePicker.container.eventHandler.stopListening(operatorA.dataMinePicker.eventSuscriptionId) operatorA.dataMinePicker.finalize() operatorA.dataMinePicker = undefined } + + if (operatorA.botPicker !== undefined) { + operatorA.botPicker.container.eventHandler.stopListening(operatorA.botPicker.eventSuscriptionId) + operatorA.botPicker.finalize() + operatorA.botPicker = undefined + } + + if (operatorA.productPicker !== undefined) { + operatorA.productPicker.container.eventHandler.stopListening(operatorA.productPicker.eventSuscriptionId) + operatorA.productPicker.finalize() + operatorA.productPicker = undefined + } + + if (operatorA.propertyPicker !== undefined) { + operatorA.propertyPicker.finalize() + operatorA.propertyPicker = undefined + } } function getContainer (point) { @@ -146,6 +202,21 @@ function newConditionEditor () { if (container !== undefined) { return container } } + if (operatorA.botPicker !== undefined) { + container = operatorA.botPicker.getContainer(point) + if (container !== undefined) { return container } + } + + if (operatorA.productPicker !== undefined) { + container = operatorA.productPicker.getContainer(point) + if (container !== undefined) { return container } + } + + if (operatorA.propertyPicker !== undefined) { + container = operatorA.propertyPicker.getContainer(point) + if (container !== undefined) { return container } + } + if (thisObject.container.frame.isThisPointHere(point, true, false) === true) { return thisObject.container } else { @@ -159,10 +230,26 @@ function newConditionEditor () { operatorsPhysics() } + function selectionPhysics () { + + } + function operatorsPhysics () { if (operatorA.dataMinePicker !== undefined) { operatorA.dataMinePicker.physics() } + + if (operatorA.botPicker !== undefined) { + operatorA.botPicker.physics() + } + + if (operatorA.productPicker !== undefined) { + operatorA.productPicker.physics() + } + + if (operatorA.propertyPicker !== undefined) { + operatorA.propertyPicker.physics() + } } function thisObjectphysics () { @@ -177,8 +264,8 @@ function newConditionEditor () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = thisObject.container.frame.radius * 1 * 2 - thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 + thisObject.container.frame.width = thisObject.container.frame.radius * 1 * 2 * 2 + thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 * 2 } function drawBackground () { @@ -190,6 +277,18 @@ function newConditionEditor () { if (operatorA.dataMinePicker !== undefined) { operatorA.dataMinePicker.drawBackground() } + + if (operatorA.botPicker !== undefined) { + operatorA.botPicker.drawBackground() + } + + if (operatorA.productPicker !== undefined) { + operatorA.productPicker.drawBackground() + } + + if (operatorA.propertyPicker !== undefined) { + operatorA.propertyPicker.drawBackground() + } } function thisObjectDrawBackground () { @@ -201,7 +300,7 @@ function newConditionEditor () { position = thisObject.container.frame.frameThisPoint(position) - let radius = thisObject.container.frame.radius * 1 + let radius = thisObject.container.frame.radius * 2 if (radius > 0.5) { browserCanvasContext.beginPath() @@ -228,6 +327,18 @@ function newConditionEditor () { if (operatorA.dataMinePicker !== undefined) { operatorA.dataMinePicker.drawForeground() } + + if (operatorA.botPicker !== undefined) { + operatorA.botPicker.drawForeground() + } + + if (operatorA.productPicker !== undefined) { + operatorA.productPicker.drawForeground() + } + + if (operatorA.propertyPicker !== undefined) { + operatorA.propertyPicker.drawForeground() + } } function thisObjectDrawForeground () { diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 410b6c968..97beda5a5 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -5,6 +5,8 @@ function newPicker () { let thisObject = { container: undefined, selectedItem: 0, + onParentChanged: onParentChanged, + getSelected: getSelected, physics: physics, drawBackground: drawBackground, drawForeground: drawForeground, @@ -21,11 +23,13 @@ function newPicker () { thisObject.container.frame.radius = 0 thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = 50 + thisObject.container.frame.width = 250 thisObject.container.frame.height = 200 let optionsList + let parent let selected = 0 + let lastSelected = 0 let onMouseWheelEventSubscriptionId return thisObject @@ -35,13 +39,31 @@ function newPicker () { thisObject.container.finalize() thisObject.container = undefined optionsList = undefined + parent = undefined } - function initialize (pOptionsList) { + function initialize (pOptionsList, pParent) { optionsList = pOptionsList + parent = pParent onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) } + function onParentChanged (event) { + if (event.parent !== undefined) { + parent = event.parent + } + + selected = 0 + let parentKeys = Object.keys(parent) + optionsList = Object.keys(parent[parentKeys[event.selected]]) + + event = { + selected: selected, + parent: parent[parentKeys[event.selected]] + } + thisObject.container.eventHandler.raiseEvent('onParentChanged', event) + } + function getContainer (point) { let container @@ -50,6 +72,10 @@ function newPicker () { } } + function getSelected () { + return optionsList[selected] + } + function onMouseWheel () { delta = event.wheelDelta if (delta > 0) { @@ -63,6 +89,14 @@ function newPicker () { if (selected > optionsList.length - 1) { selected = optionsList.length - 1 } + + if (selected !== lastSelected) { + let event = { + selected: selected + } + thisObject.container.eventHandler.raiseEvent('onParentChanged', event) + lastSelected = selected + } } function physics () { @@ -82,7 +116,7 @@ function newPicker () { for (let i = 0; i < VISIBLE_LABELS; i++) { let index = i - 2 + selected let label = '' - if (index >= 0 && index < VISIBLE_LABELS) { + if (index >= 0 && index < optionsList.length) { label = optionsList[index] } fontColor = UI_COLOR.WHITE @@ -103,4 +137,3 @@ function newPicker () { } } } - diff --git a/SplashScreen.js b/SplashScreen.js index 5fe6da376..4370f934b 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -122,7 +122,7 @@ function newSplashScreen () { fontSize = 35 - title = 'Beta' + title = 'Beta 4' titlePoint = { x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20,