diff --git a/src/components/CodePane.vue b/src/components/CodePane.vue index 7caee2d..61f9842 100644 --- a/src/components/CodePane.vue +++ b/src/components/CodePane.vue @@ -85,18 +85,14 @@ export default { } } }, - mounted() { - if (eventBus.api) - this.load(); - else - this.$watch(function() { return eventBus.api }, api => { - console.log('api', api); - if (eventBus.api) - setTimeout( () => this.load(), 1000); - }) - }, computed: { code() { + if (eventBus.api && eventBus.api.modules && this.moduleNames.length === 0) { + this.modules = eventBus.api.modules; + } + if (this.moduleNames.length === 0) { + return '// The code is not loaded. Click "Load all" button.'; + } return this.modules[this.module] || ''; }, moduleNames() { @@ -111,9 +107,10 @@ export default { this.modules = modules; else this.modules = {}; + eventBus.api.modules = this.modules; if (!this.modules[this.module]) { let files = Object.keys(this.modules); - this.module = files[0]; + this.module = files.length ? files[0] : ''; } }, add() { @@ -132,6 +129,7 @@ export default { return; } this.modules[name] = ''; + this.module = name; this.isAddVisible = false; }, remove() { diff --git a/src/components/Console.vue b/src/components/Console.vue index 4529c23..5a1c143 100644 --- a/src/components/Console.vue +++ b/src/components/Console.vue @@ -5,13 +5,15 @@
@@ -137,4 +139,8 @@ export default { margin: 0; } +.console form { + width: 100%; +} + diff --git a/src/components/RoomMap.vue b/src/components/RoomMap.vue index f03cc2f..c1bfda2 100644 --- a/src/components/RoomMap.vue +++ b/src/components/RoomMap.vue @@ -60,15 +60,18 @@ export default { if (!this.api) return ""; const {host, port, secure} = this.api.opts; + const roomName = this.api.shard + ? this.api.shard + '/' + this.roomName + : this.roomName; if (host === "screeps.com") { // official server uses a CDN - if (this.roomName.indexOf('/') > -1) - return `https://d3os7yery2usni.cloudfront.net/map/${this.roomName}.png`; - return `https://d3os7yery2usni.cloudfront.net/map3/${this.roomName}.png`; + if (roomName.indexOf('/') > -1) + return `https://d3os7yery2usni.cloudfront.net/map/${roomName}.png`; + return `https://d3os7yery2usni.cloudfront.net/map3/${roomName}.png`; } const proto = (secure? 'https' : 'http') - let bg = `${proto}://${host}:${port}/assets/map/${this.roomName}.png`; + let bg = `${proto}://${host}:${port}/assets/map/${roomName}.png`; // console.log('bg ', bg); return bg; },