diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index 2c7d464ee..a41066c97 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -31,6 +31,14 @@ function newTopSpace() { function initialize() { + let sharedStatus = { + currentDevTeamIndex: 0, + currentUserBotIndex: 0, + currentProcessIndex: 0, + currentBotType: "", + eventHandler: newEventHandler() + }; + thisObject.companyLogo = newCompanyLogo(); thisObject.companyLogo.initialize(); @@ -38,16 +46,16 @@ function newTopSpace() { thisObject.endUser.initialize(); thisObject.devTeam = newDevTeam(); - thisObject.devTeam.initialize(); + thisObject.devTeam.initialize(sharedStatus); thisObject.currentBot = newCurrentBot(); - thisObject.currentBot.initialize(); + thisObject.currentBot.initialize(sharedStatus); thisObject.currentProcess = newCurrentProcess(); - thisObject.currentProcess.initialize(); + thisObject.currentProcess.initialize(sharedStatus); thisObject.currentStartMode = newCurrentStartMode(); - thisObject.currentStartMode.initialize(); + thisObject.currentStartMode.initialize(sharedStatus); thisObject.playStopButton = newPlayStopButton(); thisObject.playStopButton.initialize(); diff --git a/TopSpace/CurrentBot.js b/TopSpace/CurrentBot.js index f98fcc2f3..584a1e772 100644 --- a/TopSpace/CurrentBot.js +++ b/TopSpace/CurrentBot.js @@ -19,15 +19,59 @@ function newCurrentBot() { container.frame.position.y = 0; container.isDraggeable = false; + container.isClickeable = true; + + let sharedStatus; return thisObject; - function initialize() { + function initialize(pSharedStatus) { - window.CURRENT_BOT = window.localStorage.getItem("currentBot"); + sharedStatus = pSharedStatus; - if (window.CURRENT_BOT === null) { + if (window.USER_PROFILE.devTeams.length === 0) { window.CURRENT_BOT = "You have no Bots"; + } else { + + if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length === 0) { + window.CURRENT_BOT = "You have no Bots"; + } else { + window.CURRENT_BOT = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName; + } + } + + thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick); + sharedStatus.eventHandler.listenToEvent("devTeam Changed", onDevTeamChanged); + } + + function onDevTeamChanged() { + + if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length > 0) { + + sharedStatus.currentUserBotIndex = 0; + window.CURRENT_BOT = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName; + + } else { + + window.CURRENT_BOT = "You have no Bots"; + + } + } + + function onClick() { + + if (sharedStatus.currentUserBotIndex + 1 === window.USER_PROFILE.devTeams.length) { + + sharedStatus.currentUserBotIndex = 0; + window.CURRENT_BOT = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName; + return; + } + + if (sharedStatus.currentUserBotIndex + 1 < window.USER_PROFILE.devTeams.length) { + + sharedStatus.currentUserBotIndex++; + window.CURRENT_BOT = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName; + return; } } diff --git a/TopSpace/DevTeam.js b/TopSpace/DevTeam.js index 89783ab6c..bad342f67 100644 --- a/TopSpace/DevTeam.js +++ b/TopSpace/DevTeam.js @@ -19,17 +19,42 @@ function newDevTeam() { container.frame.position.y = 0; container.isDraggeable = false; + container.isClickeable = true; + + let sharedStatus; return thisObject; - function initialize() { + function initialize(pSharedStatus) { + + sharedStatus = pSharedStatus; if (window.USER_PROFILE.devTeams.length === 0) { window.DEV_TEAM = "Not a devTeam Member"; } else { - window.DEV_TEAM = window.USER_PROFILE.devTeams[0]; + window.DEV_TEAM = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].displayName; } + thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick); + } + + function onClick() { + + if (sharedStatus.currentDevTeamIndex + 1 === window.USER_PROFILE.devTeams.length) { + + sharedStatus.currentDevTeamIndex = 0; + window.DEV_TEAM = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].displayName; + sharedStatus.eventHandler.raiseEvent("devTeam Changed"); + return; + } + + if (sharedStatus.currentDevTeamIndex + 1 < window.USER_PROFILE.devTeams.length) { + + sharedStatus.currentDevTeamIndex++; + window.DEV_TEAM = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].displayName; + sharedStatus.eventHandler.raiseEvent("devTeam Changed"); + return; + } } function getContainer(point) {