aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2018-12-15 13:40:25 +1200
committerDevine Lu Linvega <[email protected]>2018-12-15 13:40:25 +1200
commite3012761ee05d911992aa5f6f40d78596450f30a (patch)
treeceebc19dbe7f3326085d39398f1e05a6409f03a3
parent5277bb4757421df8be4c37c25dd643dd9c8e218f (diff)
downloadOrca-Mansion.tar.gz
Orca-Mansion.zip
Fixed issue with historyMansion
-rw-r--r--desktop/sources/scripts/history.js19
-rw-r--r--desktop/sources/scripts/terminal.js1
-rw-r--r--examples/_keys.orca13
3 files changed, 15 insertions, 18 deletions
diff --git a/desktop/sources/scripts/history.js b/desktop/sources/scripts/history.js
index 9d3912b..0c16a8a 100644
--- a/desktop/sources/scripts/history.js
+++ b/desktop/sources/scripts/history.js
@@ -14,15 +14,24 @@ function History (terminal, orca = terminal.room) {
}
this.undo = function () {
+ if (terminal.room.id !== 'lobby') { console.warn('History', 'Outside Lobby'); return }
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.lobby.f)
+ this.apply(this.frames[this.index])
}
this.redo = function () {
+ if (terminal.room.id !== 'lobby') { console.warn('History', 'Outside Lobby'); return }
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.lobby.f)
+ this.apply(this.frames[this.index])
+ }
+
+ this.apply = function (f) {
+ if (!f || f.length !== terminal.room.s.length) { return }
+ terminal.room.s = this.frames[this.index]
}
this.reset = function () {
@@ -31,12 +40,12 @@ function History (terminal, orca = terminal.room) {
}
this.append = function () {
- // this.frames.push(`${orca}`)
+ this.frames.push(terminal.room.s)
}
this.fork = function () {
- // this.frames = this.frames.slice(0, this.index + 1)
- // this.frames.push(`${orca}`)
+ this.frames = this.frames.slice(0, this.index + 1)
+ this.frames.push(terminal.room.s)
}
function clamp (v, min, max) { return v < min ? min : v > max ? max : v }
diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js
index c6814b2..68f813f 100644
--- a/desktop/sources/scripts/terminal.js
+++ b/desktop/sources/scripts/terminal.js
@@ -61,6 +61,7 @@ function Terminal (tile = { w: 20, h: 30 }) {
}
this.load = function (rooms, frame = 0) {
+ this.history.reset()
this.rooms = rooms
this.enter()
}
diff --git a/examples/_keys.orca b/examples/_keys.orca
deleted file mode 100644
index f184b23..0000000
--- a/examples/_keys.orca
+++ /dev/null
@@ -1,13 +0,0 @@
-.........................................
-.#.KEYS.#................................
-.........................................
-.#.TOGGLE.KEYS.MODE.WITH.SLASH.#.........
-.#.PRESS.a.b.OR.c.#......................
-.........................................
-.........................................
-........!a......!b......!c...............
-.........................................
-.........................................
-.........................................
-.........................................
-......................................... \ No newline at end of file