From 86310ae73f6ae5ffcb74906d316a03f8f19dade9 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 27 Mar 2017 23:53:56 -0700 Subject: [PATCH] Improved Hint() --- scripts/core/ronin.js | 24 ++++++++++++------------ scripts/modules/default.js | 25 +++++++++++++++++++++++-- scripts/modules/module.js | 2 +- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/scripts/core/ronin.js b/scripts/core/ronin.js index 3d3091e..35bf471 100644 --- a/scripts/core/ronin.js +++ b/scripts/core/ronin.js @@ -17,19 +17,19 @@ function Ronin() this.terminal = new Terminal(">"); this.magnet = new Magnet("^"); - this.modules[this.surface.rune] = this.surface; - this.modules[this.fileload.rune] = this.fileload; - this.modules[this.filesave.rune] = this.filesave; - this.modules[this.render.rune] = this.render; - this.modules[this.brush.rune] = this.brush; - this.modules[this.eye.rune] = this.eye; - this.modules[this.type.rune] = this.type; - this.modules[this.path.rune] = this.path; - this.modules[this.terminal.rune] = this.terminal; - this.modules[this.overlay.rune] = this.overlay; - this.modules[this.magnet.rune] = this.magnet; + this.modules[this.surface.constructor.name] = this.surface; + this.modules[this.fileload.constructor.name] = this.fileload; + this.modules[this.filesave.constructor.name] = this.filesave; + this.modules[this.render.constructor.name] = this.render; + this.modules[this.brush.constructor.name] = this.brush; + this.modules[this.eye.constructor.name] = this.eye; + this.modules[this.type.constructor.name] = this.type; + this.modules[this.path.constructor.name] = this.path; + this.modules[this.terminal.constructor.name] = this.terminal; + this.modules[this.overlay.constructor.name] = this.overlay; + this.modules[this.magnet.constructor.name] = this.magnet; - this.modules[this.cursor.rune] = this.cursor; + this.modules[this.cursor.constructor.name] = this.cursor; // diff --git a/scripts/modules/default.js b/scripts/modules/default.js index e961bab..89f964e 100644 --- a/scripts/modules/default.js +++ b/scripts/modules/default.js @@ -4,11 +4,32 @@ function Default(rune) this.hint = function() { - var s = ""; + if(ronin.terminal.input_element.value == ""){ + var s = ""; + for(module in ronin.modules){ + s += ronin.modules[module].constructor.name+" "; + } + return s; + } + + // + + var candidates = []; for(module in ronin.modules){ - s += ronin.modules[module].constructor.name+" "; + for(method in ronin.modules[module].methods){ + candidates.push(module.toLowerCase()+"."+method); + } } + + var s = ""; + + for(candidate in candidates){ + if(candidates[candidate].indexOf(ronin.terminal.input_element.value) > -1){ + s += candidates[candidate]+" "; + } + } + return s; } diff --git a/scripts/modules/module.js b/scripts/modules/module.js index 3824cf0..a5327f5 100644 --- a/scripts/modules/module.js +++ b/scripts/modules/module.js @@ -10,7 +10,7 @@ function Module(rune) this.install = function() { - console.log("Installing "+ronin.modules[this.rune].constructor.name); + // console.log("Installing "+ronin.modules[this.rune].constructor.name); } this.context = function()