diff --git a/Animation.js b/Animation.js index d27dc114c..01ce1f6f5 100644 --- a/Animation.js +++ b/Animation.js @@ -1,7 +1,6 @@ function newAnimation () { const MODULE_NAME = 'Animation' - const INFO_LOG = false const ERROR_LOG = true const logger = newWebDebugLog() logger.fileName = MODULE_NAME @@ -29,75 +28,31 @@ function newAnimation () { return thisObject function finalize () { - try { - if (INFO_LOG === true) { logger.write('[INFO] finalize -> Entering function.') } - - thisObject.stop() - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack) } - }s + thisObject.stop() } - function initialize (callBackFunction) { - try { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') } + function initialize () { - /* Nothing to do here yet. */ - callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } } - function start (callBackFunction) { - try { - if (INFO_LOG === true) { logger.write('[INFO] start -> Entering function.') } - - animationLoop() // Inside this function the animation process is started, and at the same time it creates a loop. - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] start -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } + function start () { + animationLoop() // Inside this function the animation process is started, and at the same time it creates a loop. } - function stop (callBackFunction) { - try { - if (INFO_LOG === true) { logger.write('[INFO] stop -> Entering function.') } - - window.cancelAnimationFrame(animationLoopHandle) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] stop -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } + function stop () { + window.cancelAnimationFrame(animationLoopHandle) } - function addCallBackFunction (key, callBack, callBackFunction) { - try { - if (INFO_LOG === true) { logger.write('[INFO] addCallBackFunction -> Entering function.') } - - callBackFunctions.set(key, callBack) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] addCallBackFunction -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } + function addCallBackFunction (key, callBack) { + callBackFunctions.set(key, callBack) } - function removeCallBackFunction (key, callBackFunction) { - try { - if (INFO_LOG === true) { logger.write('[INFO] removeCallBackFunction -> Entering function.') } - - callBackFunctions.delete(key) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] removeCallBackFunction -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } + function removeCallBackFunction (key) { + callBackFunctions.delete(key) } function animationLoop () { try { - if (INFO_LOG === true) { logger.write('[INFO] animationLoop -> Entering function.') } - if (window.canvasApp.visible === true) { /* We set the canvas to its normal width and height */ @@ -140,4 +95,3 @@ function newAnimation () { browserCanvasContext.fill() } } - diff --git a/Canvas.js b/Canvas.js index 3bc45b757..e29cecb67 100644 --- a/Canvas.js +++ b/Canvas.js @@ -7,7 +7,6 @@ let splashScreenNeeded = true function newCanvas () { const MODULE_NAME = 'Canvas' - const INFO_LOG = false const ERROR_LOG = true const logger = newWebDebugLog() logger.fileName = MODULE_NAME @@ -52,8 +51,6 @@ function newCanvas () { function finalize () { try { - if (INFO_LOG === true) { logger.write('[INFO] finalize -> Entering function.') } - thisObject.chartSpace.finalize() thisObject.floatingSpace.finalize() @@ -78,10 +75,8 @@ function newCanvas () { } } - async function initialize (callBackFunction) { + async function initialize () { try { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') } - initializeBrowserCanvas() addCanvasEvents() @@ -110,12 +105,9 @@ function newCanvas () { function onCharSpaceInitialized (err) { try { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onCharSpaceInitialized -> Entering function.') } - viewPort.raiseEvents() // These events will impacts on objects just initialized. } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onCharSpaceInitialized -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) } } @@ -125,90 +117,32 @@ function newCanvas () { splashScreen.initialize() let animation = newAnimation() - animation.initialize(onAnimationInitialized) + animation.initialize() - function onAnimationInitialized (err) { - try { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onAnimationInitialized -> Entering function.') } - - thisObject.animation = animation + thisObject.animation = animation /* Here we add all the functions that will be called during the animation cycle. */ - animation.addCallBackFunction('Floating Space Draw', thisObject.floatingSpace.draw, onFunctionAdded) - animation.addCallBackFunction('Floating Space Physics', thisObject.floatingSpace.physics, onFunctionAdded) - animation.addCallBackFunction('Chart Space Background', thisObject.chartSpace.drawBackground, onFunctionAdded) - animation.addCallBackFunction('Chart Space Draw', thisObject.chartSpace.draw, onFunctionAdded) - animation.addCallBackFunction('Chart Space Physics', thisObject.chartSpace.physics, onFunctionAdded) - animation.addCallBackFunction('Panels Space', thisObject.panelsSpace.draw, onFunctionAdded) - animation.addCallBackFunction('ViewPort Animate', viewPort.animate, onFunctionAdded) - animation.addCallBackFunction('CockpitSpace Draw', thisObject.cockpitSpace.draw, onFunctionAdded) - animation.addCallBackFunction('CockpitSpace Physics', thisObject.cockpitSpace.physics, onFunctionAdded) - animation.addCallBackFunction('Top Space Draw', thisObject.topSpace.draw, onFunctionAdded) - animation.addCallBackFunction('Strategy Space Draw', thisObject.strategySpace.draw, onFunctionAdded) - animation.addCallBackFunction('Splash Screen Draw', splashScreen.draw, onFunctionAdded) - animation.start(onStart) - - function onFunctionAdded (err) { - try { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onAnimationInitialized -> onFunctionAdded -> Entering function.') } - - if (err.result === GLOBAL.DEFAULT_FAIL_RESPONSE.result) { - animation.stop() - - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onAnimationInitialized -> onFunctionAdded -> Animation Stopped since a vital funtion could not be added.') } - - /* Display some Error Page here. */ - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onAnimationInitialized -> onFunctionAdded -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } - } - - function onStart (err) { - try { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onAnimationInitialized -> onStart -> Entering function.') } - - switch (err.result) { - case GLOBAL.DEFAULT_OK_RESPONSE.result: { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onAnimationInitialized -> onStart -> Received OK Response.') } - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) - return - } - - case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onAnimationInitialized -> onStart -> Received FAIL Response.') } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } - - default: { - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onAnimationInitialized -> onStart -> Received Unexpected Response.') } - callBackFunction(err) - return - } - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onAnimationInitialized -> onStart -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onAnimationInitialized -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } - } + animation.addCallBackFunction('Floating Space Draw', thisObject.floatingSpace.draw) + animation.addCallBackFunction('Floating Space Physics', thisObject.floatingSpace.physics) + animation.addCallBackFunction('Chart Space Background', thisObject.chartSpace.drawBackground) + animation.addCallBackFunction('Chart Space Draw', thisObject.chartSpace.draw) + animation.addCallBackFunction('Chart Space Physics', thisObject.chartSpace.physics) + animation.addCallBackFunction('Panels Space', thisObject.panelsSpace.draw) + animation.addCallBackFunction('ViewPort Animate', viewPort.animate) + animation.addCallBackFunction('CockpitSpace Draw', thisObject.cockpitSpace.draw) + animation.addCallBackFunction('CockpitSpace Physics', thisObject.cockpitSpace.physics) + animation.addCallBackFunction('Top Space Draw', thisObject.topSpace.draw) + animation.addCallBackFunction('Strategy Space Draw', thisObject.strategySpace.draw) + animation.addCallBackFunction('Splash Screen Draw', splashScreen.draw) + animation.start() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) } } function initializeBrowserCanvas () { try { - if (INFO_LOG === true) { logger.write('[INFO] initializeBrowserCanvas -> Entering function.') } - browserCanvasContext = browserCanvas.getContext('2d') // browserCanvasContext.font = 'italic small-caps bold 12px Saira' browserCanvasContext.font = 'Saira' @@ -221,8 +155,6 @@ function newCanvas () { function addCanvasEvents () { try { - if (INFO_LOG === true) { logger.write('[INFO] addCanvasEvents -> Entering function.') } - /* Mouse down and up events to control the drag of the canvas. */ browserCanvas.addEventListener('mousedown', onMouseDown, false) @@ -253,8 +185,6 @@ function newCanvas () { function onMouseDown (event) { try { - if (INFO_LOG === true) { logger.write('[INFO] onMouseDown -> Entering function.') } - /* There are four types of elements that can be dragged. @@ -362,8 +292,6 @@ function newCanvas () { function onMouseClick (event) { try { - if (INFO_LOG === true) { logger.write('[INFO] onMouseClick -> Entering function.') } - if (ignoreNextClick === true) { ignoreNextClick = false return @@ -611,8 +539,6 @@ function newCanvas () { function onMouseWheel (event) { try { - if (INFO_LOG === true) { logger.write('[INFO] onMouseWheel -> Entering function.') } - // cross-browser wheel delta var event = window.event || event // old IE support let delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail)) diff --git a/CockpitSpace/RestartSimulation.js b/CockpitSpace/RestartSimulation.js index 509748b53..1437955a3 100644 --- a/CockpitSpace/RestartSimulation.js +++ b/CockpitSpace/RestartSimulation.js @@ -69,15 +69,14 @@ function newRestartSimulation () { label = 'RESTART SIMULATION' - xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO - yOffset = -45 - - labelPoint = { - x: 0 - xOffset + (thisObject.paramsArray[1].LEFT_OFFSET - thisObject.paramsArray[0].LEFT_OFFSET) / 2 + thisObject.paramsArray[0].LEFT_OFFSET - 20, - y: COCKPIT_SPACE_POSITION - COCKPIT_SPACE_HEIGHT / 2 - yOffset + let labelPoint = { + x: 0, + y: thisObject.container.frame.height - 9 } + labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + OPACITY + ')' browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) } } + diff --git a/Dashboard.js b/Dashboard.js index cb57b4fe3..63e3176af 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -6,7 +6,6 @@ let viewPort = newViewPort() function newDashboard () { const MODULE_NAME = 'Dashboard' - const INFO_LOG = false const ERROR_LOG = true const INTENSIVE_LOG = false const logger = newWebDebugLog() @@ -25,8 +24,6 @@ function newDashboard () { function start () { try { - if (INFO_LOG === true) { logger.write('[INFO] start -> Entering function.') } - /* If this method is executed for a second time, it should finalize the current execution structure */ if (canvas !== undefined) { canvas.finalize() } @@ -40,8 +37,6 @@ function newDashboard () { loadImages(onImagesLoaded) function onImagesLoaded () { - if (INFO_LOG === true) { logger.write('[INFO] start -> onImagesLoaded -> Entering function.') } - /* Next we start the App */ setTimeout(delayedStart, DEBUG_START_UP_DELAY) @@ -53,8 +48,6 @@ function newDashboard () { function delayedStart () { try { - if (INFO_LOG === true) { logger.write('[INFO] delayedStart -> Entering function.') } - /* For now, we are supporting only one market. */ let market = { @@ -76,8 +69,6 @@ function newDashboard () { function userProfileChanged () { try { - if (INFO_LOG === true) { logger.write('[INFO] userProfileChanged -> Entering function.') } - canvas.topSpace.initialize() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] userProfileChanged -> err = ' + err.stack) } @@ -86,8 +77,6 @@ function newDashboard () { function browserResized () { try { - if (INFO_LOG === true) { logger.write('[INFO] browserResized -> Entering function.') } - browserCanvas = document.getElementById('canvas') browserCanvas.width = window.innerWidth @@ -101,8 +90,6 @@ function newDashboard () { function loadImages (callBack) { try { - if (INFO_LOG === true) { logger.write('[INFO] loadImages -> Entering function.') } - const accessToken = '' /* diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index a47822da3..d0bf1a3e9 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -46,8 +46,8 @@ thisObject.assetBalances.initialize() thisObject.restartSimulation = newRestartSimulation() - thisObject.restartSimulation.initialize() thisObject.restartSimulation.container.connectToParent(thisObject.container) + thisObject.restartSimulation.initialize() } function onMouseClick (event) {