From fa326dadb67595b4e7e842316e057b47fc24a4bf Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 14 Oct 2020 11:36:33 +0200 Subject: [PATCH] Bye Splash Screen --- Animation.js | 2 +- Canvas.js | 8 -- DesignSpace/Workspace/Workspace.js | 2 +- FloatingSpace/UiObjectConstructor.js | 2 +- Globals.js | 2 +- Project.njsproj | 1 - Spaces/ChartingSpace.js | 2 +- Spaces/ChatSpace.js | 2 +- Spaces/CockpitSpace.js | 2 +- Spaces/DesignSpace.js | 2 +- Spaces/DocSpace.js | 2 +- Spaces/FloatingSpace.js | 2 +- Spaces/PanelsSpace.js | 2 +- Spaces/SideSpace.js | 2 +- Spaces/TopSpace.js | 2 +- SplashScreen.js | 160 --------------------------- Utilities/Branches.js | 8 +- Utilities/Hiriarchy.js | 2 +- Utilities/Meshes.js | 2 +- Utilities/NodeChildren.js | 8 +- 20 files changed, 23 insertions(+), 192 deletions(-) delete mode 100644 SplashScreen.js diff --git a/Animation.js b/Animation.js index c3ee45714..2e0e8941f 100644 --- a/Animation.js +++ b/Animation.js @@ -167,7 +167,7 @@ function newAnimation() { } function clearBrowserCanvas() { - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' browserCanvasContext.clearRect(0, 0, browserCanvas.width, browserCanvas.height) } diff --git a/Canvas.js b/Canvas.js index d93cdc846..93d131afe 100644 --- a/Canvas.js +++ b/Canvas.js @@ -1,9 +1,6 @@ let browserCanvasContext // The context of the canvas object. -let stepsInitializationCounter = 0 // This counter the initialization steps required to be able to turn off the splash screen. -let marketInitializationCounter = 0 // This counter the initialization of markets required to be able to turn off the splash screen. - function newCanvas() { const MODULE_NAME = 'Canvas' const ERROR_LOG = true @@ -39,7 +36,6 @@ function newCanvas() { panelsSpace: undefined, cockpitSpace: undefined, designSpace: undefined, - splashScreen: undefined, animation: undefined, mouse: undefined, shorcutNumbers: new Map(), @@ -92,7 +88,6 @@ function newCanvas() { browserCanvas.detachEvent('onmousewheel', onMouseWheel) // IE 6/7/8 } - thisObject.splashScreen = undefined lastContainerMouseOver = undefined thisObject.mouse = undefined @@ -138,8 +133,6 @@ function newCanvas() { thisObject.tutorialSpace = newTutorialSpace() thisObject.tutorialSpace.initialize() - thisObject.splashScreen = newSplashScreen() - let animation = newAnimation() animation.initialize() @@ -167,7 +160,6 @@ function newCanvas() { animation.addCallBackFunction('Doc Space Draw', thisObject.docSpace.draw) //animation.addCallBackFunction('Chat Space Draw', thisObject.chatSpace.draw) animation.addCallBackFunction('Tutorial Space Draw', thisObject.tutorialSpace.draw) - animation.addCallBackFunction('Splash Screen Draw', thisObject.splashScreen.draw) animation.start() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 977905cc1..abc1f88c8 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -126,7 +126,7 @@ function newWorkspace() { runTasksAndSessions() thisObject.enabled = true canvas.cockpitSpace.initializePosition() - canvas.splashScreen.initialize() + CAN_SPACES_DRAW = true savingWorkspaceIntervalId = setInterval(saveWorkspace, 60000) isInitialized = true } diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index b42cfe186..e611c0b3d 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -174,7 +174,7 @@ function newUiObjectConstructor() { uiObject.isVisibleFunction = canvas.floatingSpace.isThisPointVisible let menuItemsInitialValues = getMenuItemsInitialValues(uiObject, floatingObject, payload) - let schemaNode = APP_SCHEMA_MAP.get(payload.node.type) + let schemaNode = getNodeDefinition(payload.node) if (schemaNode === undefined) { console.log(payload.node.type + ' node found at App Schema. This node will not be created. ') return diff --git a/Globals.js b/Globals.js index c4f43fa7b..d6f95a94d 100644 --- a/Globals.js +++ b/Globals.js @@ -231,7 +231,7 @@ let ARE_WE_RECORDING_A_MARKET_PANORAMA = false let PANORAMA_WAS_PANNED = false let CURRENT_PANORAMA_POSITION = 0 -let canWeDraw = false // This global variable regulates when spaces can or can not draw their contents. +let CAN_SPACES_DRAW = false // This global variable regulates when spaces can or can not draw their contents. function toRadians(angle) { return angle * (Math.PI / 180); diff --git a/Project.njsproj b/Project.njsproj index 886b43884..299f685a9 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -159,7 +159,6 @@ - Code diff --git a/Spaces/ChartingSpace.js b/Spaces/ChartingSpace.js index 647ea5a24..68f5d017b 100644 --- a/Spaces/ChartingSpace.js +++ b/Spaces/ChartingSpace.js @@ -414,7 +414,7 @@ function newChartingSpace() { } function draw() { - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } if (thisObject.visible === false) { return } drawBackground() diff --git a/Spaces/ChatSpace.js b/Spaces/ChatSpace.js index f429006f8..e6f0d271d 100644 --- a/Spaces/ChatSpace.js +++ b/Spaces/ChatSpace.js @@ -118,7 +118,7 @@ function newChatSpace() { } function draw() { - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } if (isInitialized === false) { return } borders() thisObject.sidePanelTab.draw() diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 3c0fdcb60..fe16fc4b9 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -203,7 +203,7 @@ function newCockpitSpace() { } function draw() { - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } thisObject.container.frame.draw(false, false) drawBackground() diff --git a/Spaces/DesignSpace.js b/Spaces/DesignSpace.js index d9dce27cd..928bf4caf 100644 --- a/Spaces/DesignSpace.js +++ b/Spaces/DesignSpace.js @@ -109,7 +109,7 @@ function newDesignSpace() { function draw() { if (thisObject.workspace === undefined) { return } - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } thisObject.workspace.draw() } } diff --git a/Spaces/DocSpace.js b/Spaces/DocSpace.js index 41d7c3af6..06a77c401 100644 --- a/Spaces/DocSpace.js +++ b/Spaces/DocSpace.js @@ -116,7 +116,7 @@ function newDocSpace() { } function draw() { - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } if (isInitialized === false) { return } borders() thisObject.sidePanelTab.draw() diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index 19ce0a609..a10c3b510 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -554,7 +554,7 @@ function newFloatingSpace() { } function draw() { - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } if (visible === false) { return } drawBackground() thisObject.floatingLayer.draw() diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index ecfcfdfa6..be5b6e6ad 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -336,7 +336,7 @@ function newPanelsSpace() { } function draw() { - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } if (thisObject.visible !== true) { return } thisObject.container.frame.draw(false, false) diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index b44409b0a..b2ebe1f87 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -91,7 +91,7 @@ function newSideSpace() { } function draw() { - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } if (isInitialized === false) { return } borders() thisObject.sidePanelTab.draw() diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index 169b9c498..339eabdb8 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -54,7 +54,7 @@ function newTopSpace() { } function draw() { - if (canWeDraw === false) { return } + if (CAN_SPACES_DRAW === false) { return } thisObject.container.frame.draw(false, false) drawBackground() diff --git a/SplashScreen.js b/SplashScreen.js deleted file mode 100644 index 688318ed0..000000000 --- a/SplashScreen.js +++ /dev/null @@ -1,160 +0,0 @@ -/* - -The Splash Screen is to show some 'loading...' controls while the app is being loaded on the background. After the loading is complete the Splash Screens dissapears for good. - -*/ - -function newSplashScreen() { - let thisObject = { - container: undefined, - draw: draw, - timeMachines: [], - getContainer: getContainer, // returns the inner most container that holds the point received by parameter. - initialize: initialize - } - - let container = newContainer() - container.initialize() - thisObject.container = container - - resize() - - container.frame.containerName = 'Splash Screen' - - container.frame.position.x = 0 - container.frame.position.y = 0 - - container.isDraggeable = false - - let fadeOutCounter = 0 - let opacity = 1 - - let logo - let canDrawLogo = false - let isInitialized = false - let splashScreenNeeded = true - - return thisObject - - function initialize() { - logo = new Image() - logo.onload = onImageLoad - - function onImageLoad() { - canDrawLogo = true - } - logo.src = 'Images/superalgos-logo.png' - canvas.eventHandler.listenToEvent('Browser Resized', resize) - - isInitialized = true - } - - function resize() { - thisObject.container.frame.width = browserCanvas.width - thisObject.container.frame.height = browserCanvas.height - } - - function draw() { - if (isInitialized === false) { return } - if (splashScreenNeeded === false) { - stepsInitializationCounter = 100 - canDrawLogo = false - - fadeOutCounter++ - - if (fadeOutCounter > 2) { - return - } - opacity = opacity - 1 - } - - thisObject.container.frame.draw(false, false) - - /* Set the background. */ - - browserCanvasContext.beginPath() - browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height) - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ')' - browserCanvasContext.closePath() - browserCanvasContext.fill() - - if (canDrawLogo === false) { return } - - /* First the AA Logo. */ - - let imageHeight = 192 / 2 - let imageWidth = 720 / 2 - let yDisplacement = -60 - let xDisplacement = -60 - - let imagePoint = { - x: thisObject.container.frame.width * 1 / 2 - imageWidth / 2 + xDisplacement, - y: thisObject.container.frame.height * 1 / 2 - imageHeight / 2 + yDisplacement - } - - imagePoint = thisObject.container.frame.frameThisPoint(imagePoint) - - browserCanvasContext.drawImage(logo, imagePoint.x, imagePoint.y, imageWidth, imageHeight) - - /* Second the % of Advance. */ - - let label = '' + Math.trunc(stepsInitializationCounter) + ' %' - stepsInitializationCounter = stepsInitializationCounter + 5.0 - - if (stepsInitializationCounter > 99) { - splashScreenNeeded = false - canWeDraw = true - stepsInitializationCounter = 99 - } - - let fontSize = 15 - - let labelPoint = { - x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO - 22, - y: thisObject.container.frame.height / 2 + fontSize / 2 + fontSize * 0.1 + 90 + yDisplacement - } - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(0, 0, 0, ' + opacity + ')' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - - let title - let titlePoint - - /* Algo Bots Competitions Sub Title */ - - fontSize = 35 - - title = 'Beta 6' - - titlePoint = { - x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20, - y: thisObject.container.frame.height / 2 + 70 + yDisplacement - } - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.font = 'Saira Condensed' - browserCanvasContext.fillStyle = 'rgba(0, 0, 0, ' + opacity + ')' - browserCanvasContext.fillText(title, titlePoint.x, titlePoint.y) - } - - function getContainer(point) { - var container - - /* First we check if this point is inside this space. */ - - if (thisObject.container.frame.isThisPointHere(point) === true) { - /* Now we see which is the inner most container that has it */ - - // add validation of inner most containers here. - - /* The point does not belong to any inner container, so we return the current container. */ - - return thisObject.container - } else { - /* This point does not belong to this space. */ - - return undefined - } - } -} diff --git a/Utilities/Branches.js b/Utilities/Branches.js index 7609b6ec3..8aa46d4db 100644 --- a/Utilities/Branches.js +++ b/Utilities/Branches.js @@ -10,9 +10,9 @@ function nodeBranchToArray(node, nodeType) { return resultArray function scanNodeBranch(startingNode) { - if (startingNode === undefined) {return} - - let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) + if (startingNode === undefined) { return } + + let nodeDefinition = getNodeDefinition(startingNode) if (nodeDefinition === undefined) { return } if (startingNode.type === nodeType) { @@ -24,7 +24,7 @@ function nodeBranchToArray(node, nodeType) { let lastNodePropertyName for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] - if (lastNodePropertyName === property.name) {continue} // Some nodes have a single property por multiple child node types. We need to check repeated properties only once so as no to duplicate results. + if (lastNodePropertyName === property.name) { continue } // Some nodes have a single property por multiple child node types. We need to check repeated properties only once so as no to duplicate results. switch (property.type) { case 'node': { scanNodeBranch(startingNode[property.name]) diff --git a/Utilities/Hiriarchy.js b/Utilities/Hiriarchy.js index e37b075fb..f1c0e965c 100644 --- a/Utilities/Hiriarchy.js +++ b/Utilities/Hiriarchy.js @@ -14,7 +14,7 @@ function getHiriarchyMap(rootNode) { hiriatchyMap.set(node.id, node) /* Now we go down through all this node children */ - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition === undefined) { return } if (nodeDefinition.properties !== undefined) { diff --git a/Utilities/Meshes.js b/Utilities/Meshes.js index 834cb48e1..fbc659f17 100644 --- a/Utilities/Meshes.js +++ b/Utilities/Meshes.js @@ -17,7 +17,7 @@ function findNodeInNodeMesh(node, nodeType, nodeName, connectedViaPayload, findI if (nodeFound !== undefined) { return } if (depth >= MAX_DEPTH) {return} - let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) + let nodeDefinition = getNodeDefinition(startingNode) if (nodeDefinition === undefined) { return } if (nodeType !== undefined) { diff --git a/Utilities/NodeChildren.js b/Utilities/NodeChildren.js index f841180f1..7f89e13c9 100644 --- a/Utilities/NodeChildren.js +++ b/Utilities/NodeChildren.js @@ -6,7 +6,7 @@ function isMissingChildren(startingNode, checkNode, checkReferenceParent) { if (startingNode === undefined) { return } if (checkNode === undefined) { return } - let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) + let nodeDefinition = getNodeDefinition(startingNode) if (nodeDefinition === undefined) { return } /* We scan through this node children */ @@ -69,7 +69,7 @@ function findChildReferencingThisNode(startingNode, checkNode) { if (startingNode === undefined) { return } if (checkNode === undefined) { return } - let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) + let nodeDefinition = getNodeDefinition(startingNode) if (nodeDefinition === undefined) { return } /* We scan through this node children */ @@ -156,7 +156,7 @@ function findChildIndexAtParentNode(startingNode) { let parentNode = startingNode.payload.parentNode - let nodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) + let nodeDefinition = getNodeDefinition(parentNode) if (nodeDefinition === undefined) { return } /* We scan through this parent node children */ @@ -194,7 +194,7 @@ function isMissingChildrenByName(startingNode, nodeName) { */ if (startingNode === undefined) { return } - let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) + let nodeDefinition = getNodeDefinition(startingNode) if (nodeDefinition === undefined) { return } /* We scan through this node children */