From df8d94d3d57a3ddbfbb6bdfd1f15010c1bc7d18c Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 19 Dec 2016 14:25:30 -0700 Subject: [PATCH] Progress on source files. --- scripts/core/commander.js | 77 +++++++++++++++++++++----------------- scripts/core/init.js | 5 ++- scripts/core/keyboard.js | 18 +-------- scripts/core/ronin.js | 2 +- scripts/modules/history.js | 2 +- 5 files changed, 50 insertions(+), 54 deletions(-) diff --git a/scripts/core/commander.js b/scripts/core/commander.js index d9f4e71..80ac04e 100644 --- a/scripts/core/commander.js +++ b/scripts/core/commander.js @@ -2,11 +2,52 @@ function Commander(element,element_input) { this.element = element; this.element_input = element_input; - this.cmd = null; this.storage = []; this.storage_index = 0; this.always_show = false; + this.query = function(input_str) + { + if(input_str.indexOf(";") > 0){ + var multi = input_str.split(";"); + for (i = 0; i < multi.length; i++) { + this.query(multi[i]); + } + } + else{ + this.active(input_str); + } + } + + this.active = function(content) + { + var key = content[0]; + var cmd = new Command(content.substring(1).split(" ")); + + if(ronin.modules[key]){ + ronin.modules[key].active(cmd); + } + + this.hide(); + + ronin.history.add(content); + } + + this.passive = function(content) + { + var key = content[0]; + var cmd = new Command(content.substring(1).split(" ")); + + ronin.module = null; + + if(ronin.modules[key]){ + ronin.modules[key].passive(cmd); + ronin.module = ronin.modules[key]; + } + } + + // + this.show = function() { this.element.setAttribute('class','visible'); @@ -42,39 +83,5 @@ function Commander(element,element_input) this.element_input.value = this.storage[this.storage_index]; } - this.active = function(content) - { - this.storage.push(content.join(" ")); - this.storage_index = this.storage.length; - - var key = content[0][0]; - content[0] = content[0].slice(1); - var cmd = new Command(content); - - if(ronin.modules[key]){ - ronin.modules[key].active(this.cmd); - } - - switch(key) { - case "~": - this.always(); - break; - } - this.hide(); - - ronin.history.add(content.join(" ")); - } - this.passive = function(content) - { - var key = content[0][0]; - content[0] = content[0].slice(1); - this.cmd = new Command(content); - ronin.module = null; - - if(ronin.modules[key]){ - ronin.modules[key].passive(this.cmd); - ronin.module = ronin.modules[key]; - } - } } diff --git a/scripts/core/init.js b/scripts/core/init.js index a2122ec..e0ddfde 100644 --- a/scripts/core/init.js +++ b/scripts/core/init.js @@ -23,5 +23,8 @@ var starting_canvas = new Rect(); starting_canvas.width = window.innerWidth - 200; starting_canvas.height = window.innerHeight - 200; + ronin.canvas.resize(starting_canvas); -ronin.overlay.resize(starting_canvas); \ No newline at end of file +ronin.overlay.resize(starting_canvas); + +commander.query("@ 200x200"); \ No newline at end of file diff --git a/scripts/core/keyboard.js b/scripts/core/keyboard.js index 5e0fdd2..6fe439c 100644 --- a/scripts/core/keyboard.js +++ b/scripts/core/keyboard.js @@ -51,8 +51,7 @@ function Keyboard() } // Passive - var cmd = commander.element_input.value; - commander.passive(cmd.split(" ")); + commander.passive(commander.element_input.value); ronin.hint.update(); ronin.cursor.set_mode(new Mode_Paint()); @@ -70,20 +69,7 @@ function Keyboard() this.key_enter = function() { - var cmd = commander.element_input.value; - - if(cmd.indexOf(";") > 0){ - var multi = cmd.split(";"); - var i = 0; - while(i < 100){ - if(multi[i]){commander.active(multi[i].split(" "));} - else{ break; } - i += 1; - } - } - else{ - commander.active(cmd.split(" ")); - } + commander.query(commander.element_input.value); } this.key_space = function() diff --git a/scripts/core/ronin.js b/scripts/core/ronin.js index 5a8a892..893428f 100644 --- a/scripts/core/ronin.js +++ b/scripts/core/ronin.js @@ -15,7 +15,7 @@ function Ronin() this.stroke = new Stroke("_"); this.vector = new Vector("+"); this.help = new Help("?"); - this.history = new History(";"); + this.history = new History("^"); this.cursor = new Cursor(); diff --git a/scripts/modules/history.js b/scripts/modules/history.js index fa0723b..dd7f748 100644 --- a/scripts/modules/history.js +++ b/scripts/modules/history.js @@ -17,6 +17,6 @@ function History(rune) this.widget = function() { if(this.lines.length === 0){ return "";} - return "; "+this.lines.length+" "; + return "^ "+this.lines.length+" "; } } \ No newline at end of file