diff options
author | Devine Lu Linvega <[email protected]> | 2018-12-15 12:15:18 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-12-15 12:15:18 +1200 |
commit | 5277bb4757421df8be4c37c25dd643dd9c8e218f (patch) | |
tree | 1e53f02b6e2b60b010e96a5db8b384ab30c3ae14 | |
parent | 70ac4eec9faf6683aaaf54acc759fc143f2a6cc2 (diff) | |
download | Orca-5277bb4757421df8be4c37c25dd643dd9c8e218f.tar.gz Orca-5277bb4757421df8be4c37c25dd643dd9c8e218f.zip |
Improved lobby
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | desktop/core/library/_door.js | 3 | ||||
-rw-r--r-- | desktop/core/orca.js | 6 | ||||
-rw-r--r-- | desktop/sources/index.html | 1 | ||||
-rw-r--r-- | desktop/sources/scripts/history.js | 4 | ||||
-rw-r--r-- | desktop/sources/scripts/source.js | 14 | ||||
-rw-r--r-- | desktop/sources/scripts/terminal.js | 18 |
7 files changed, 21 insertions, 26 deletions
@@ -72,7 +72,6 @@ You can follow the [guide](GUIDE.md) to get started and play your first sounds. - `ctrl+v` paste selection. - `ctrl+z` undo. - `ctrl+shift+z` redo. -- `ctrl/meta+k` crop. ### Grid Controls diff --git a/desktop/core/library/_door.js b/desktop/core/library/_door.js index 108acc2..da82ecb 100644 --- a/desktop/core/library/_door.js +++ b/desktop/core/library/_door.js @@ -14,10 +14,13 @@ function OperatorDoor (orca, x, y, passive) { this.run = function () { const id = this.listen(this.ports.haste.id) + if (!orca.terminal.rooms[id]) { return } + if (orca.host) { return } // Recursive const val = this.listen(this.ports.input.val) const room = orca.terminal.rooms[id] + room.input(val) room.run() const res = room.output() diff --git a/desktop/core/orca.js b/desktop/core/orca.js index e2076e6..8f801db 100644 --- a/desktop/core/orca.js +++ b/desktop/core/orca.js @@ -2,11 +2,13 @@ const library = require('./library') -function Orca (terminal) { +function Orca (terminal, host = null) { this.w = 65 // Default Width this.h = 25 // Default Height this.s = '' // String - this.f = 0 // Frame + this.f = host ? host.f : 0 // Frame + + this.host = host this.terminal = terminal this.keys = Object.keys(library) diff --git a/desktop/sources/index.html b/desktop/sources/index.html index 6e6f7fa..f2949db 100644 --- a/desktop/sources/index.html +++ b/desktop/sources/index.html @@ -39,7 +39,6 @@ terminal.controller.add("default","Edit","Paste Selection",() => { terminal.cursor.paste(); },"CmdOrCtrl+V") terminal.controller.add("default","Edit","Undo",() => { terminal.history.undo(); },"CmdOrCtrl+Z") terminal.controller.add("default","Edit","Redo",() => { terminal.history.redo(); },"CmdOrCtrl+Shift+Z") - terminal.controller.add("default","Edit","Crop Selection",() => { terminal.crop(); },"CmdOrCtrl+K") terminal.controller.add("default","Program","Play/Pause",() => { terminal.pause(); },"Space") terminal.controller.add("default","Program","Incr. Speed",() => { terminal.modSpeed(1); },">") diff --git a/desktop/sources/scripts/history.js b/desktop/sources/scripts/history.js index f591cf8..9d3912b 100644 --- a/desktop/sources/scripts/history.js +++ b/desktop/sources/scripts/history.js @@ -16,13 +16,13 @@ function History (terminal, orca = terminal.room) { this.undo = function () { if (this.index === 0) { console.warn('History', 'Reached beginning'); return } this.index = clamp(this.index - 1, 0, this.frames.lengt - 1) - terminal.load(this.frames[this.index], terminal.rooms.hall.f) + // terminal.load(this.frames[this.index], terminal.rooms.lobby.f) } this.redo = function () { if (this.index > this.frames.length - 1) { console.warn('History', 'Reached end'); return } this.index = clamp(this.index + 1, 0, this.frames.lengt - 1) - terminal.load(this.frames[this.index], terminal.rooms.hall.f) + // terminal.load(this.frames[this.index], terminal.rooms.lobby.f) } this.reset = function () { diff --git a/desktop/sources/scripts/source.js b/desktop/sources/scripts/source.js index 77a5ab1..a662b0f 100644 --- a/desktop/sources/scripts/source.js +++ b/desktop/sources/scripts/source.js @@ -12,8 +12,8 @@ function Source (terminal) { this.path = null - terminal.rooms = { hall: new Orca(terminal) } - terminal.room = terminal.rooms.hall + terminal.rooms = { lobby: new Orca(terminal) } + terminal.room = terminal.rooms.lobby terminal.enter() terminal.resize() terminal.history.reset() @@ -66,9 +66,9 @@ function Source (terminal) { // Converters this.generate = function (rooms = terminal.rooms) { - let html = `${rooms.hall}\n\n` + let html = `${rooms.lobby}\n\n` for (const id in rooms) { - if (id !== 'hall') { + if (id !== 'lobby') { const room = rooms[id] html += `${id}\n\n${room}\n\n` } @@ -78,10 +78,10 @@ function Source (terminal) { this.parse = function (text) { const lines = text.split('\n') - const blocks = { hall: [] } - const rooms = { hall: [] } + const blocks = { lobby: [] } + const rooms = { lobby: [] } const room = [] - let key = 'hall' + let key = 'lobby' // Blocks for (const id in lines) { const line = lines[id].trim() diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index 1cc219e..c6814b2 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -49,7 +49,7 @@ function Terminal (tile = { w: 20, h: 30 }) { this.run = function () { if (this.isPaused) { return } this.io.clear() - this.rooms.hall.run() + this.rooms.lobby.run() this.io.run() this.update() } @@ -61,18 +61,10 @@ function Terminal (tile = { w: 20, h: 30 }) { } this.load = function (rooms, frame = 0) { - console.log(rooms) this.rooms = rooms this.enter() } - this.crop = function () { - const block = this.cursor.getBlock() - const data = block.reduce((acc, val) => { acc.push(val.join('')); return acc }, []).join('\n') - this.load(data) - this.cursor.selectAll() - } - this.update = function () { this.clear() this.ports = this.findPorts() @@ -86,11 +78,11 @@ function Terminal (tile = { w: 20, h: 30 }) { this.create = function (id) { console.log(`Creating Room:${id}`) - this.rooms[id] = new Orca(this) + this.rooms[id] = new Orca(this, this.rooms.lobby) this.rooms[id].reset(33, 17) } - this.enter = function (id = 'hall') { + this.enter = function (id = 'lobby') { if (!this.rooms[id]) { this.create(id) } @@ -99,7 +91,7 @@ function Terminal (tile = { w: 20, h: 30 }) { this.room = this.rooms[id] this.room.id = id - this.resize(this.room.id === 'hall') + this.resize(this.room.id === 'lobby') this.update() } @@ -225,7 +217,7 @@ function Terminal (tile = { w: 20, h: 30 }) { this.write(`${this.cursor.x},${this.cursor.y}`, col * 0, 1, this.size.grid.w) this.write(`${this.cursor.w}:${this.cursor.h}`, col * 1, 1, this.size.grid.w) this.write(`${this.cursor.inspect()}`, col * 2, 1, this.size.grid.w) - this.write(`${this.source}${this.cursor.mode === 2 ? '^' : this.cursor.mode === 1 ? '+' : ''}${this.room.id && this.room.id !== 'hall' ? '/' + this.room.id : ''}`, col * 3, 1, this.size.grid.w) + this.write(`${this.source}${this.cursor.mode === 2 ? '^' : this.cursor.mode === 1 ? '+' : ''}${this.room.id && this.room.id !== 'lobby' ? '/' + this.room.id : ''}`, col * 3, 1, this.size.grid.w) // Grid this.write(`${this.room.w}x${this.room.h}`, col * 0, 0, this.size.grid.w) this.write(`${this.size.grid.w}/${this.size.grid.h}`, col * 1, 0, this.size.grid.w) |