Moved Hint to modules

This commit is contained in:
Devine Lu Linvega 2017-03-14 13:38:46 -07:00
parent 4040964505
commit fe9e2c9475
4 changed files with 27 additions and 56 deletions

View File

@ -15,7 +15,7 @@ canvas:hover { cursor: none;}
#terminal { position: fixed; bottom:0px; left:0px; background:#000; width:100vw; height: 120px;overflow: hidden;} #terminal { position: fixed; bottom:0px; left:0px; background:#000; width:100vw; height: 120px;overflow: hidden;}
#terminal input { display: block; position:absolute; bottom:0px; width:100vw; padding:0px 5px; font-size:10px; line-height: 20px; background:none; z-index:900; color:white;} #terminal input { display: block; position:absolute; bottom:0px; width:100vw; padding:0px 5px; font-size:10px; line-height: 20px; background:none; z-index:900; color:white;}
#terminal hint { background:#000; position:absolute; bottom:0px; line-height: 20px; padding:0px 5px; width:100vw; color:#777; font-size:10px; white-space: pre;} #terminal hint { background:#000; position:absolute; bottom:0px; line-height: 20px; padding:0px 5px; width:100vw; color:#777; font-size:10px; white-space: pre;}
#terminal hint .name { font-family: "input_mono_regular"; color:#999; } #terminal hint b { font-family: "input_mono_regular"; color:#999; }
#terminal logs { display: block;position: absolute;bottom:20px;width:100vw;color:white} #terminal logs { display: block;position: absolute;bottom:20px;width:100vw;color:white}
#terminal logs log { display: block; font-size:10px; line-height:25px; padding:0px 5px; color:#666;} #terminal logs log { display: block; font-size:10px; line-height:25px; padding:0px 5px; color:#666;}
#terminal logs log .rune { color:white; } #terminal logs log .rune { color:white; }

View File

@ -36,40 +36,26 @@ function Module(rune)
} }
} }
this.hint = function(cmd) this.hint = function(content)
{ {
var s = this.pad(cmd.content.join(" ")); var h = "<span class='name'>"+ronin.module.constructor.name+"</span> ";
for(param in ronin.module.parameters){
s += cmd.content.join(" ").length == 0 ? "<span class='module'>"+this.constructor.name+"</span>" : ""; var name = new ronin.module.parameters[param]().constructor.name;
h += name+" ";
// Params }
for(variable in ronin.module.variables){
var e = 0; h += variable+"="+ronin.module.variables[variable]+" ";
while(e < 10){
if(!this.parameters[e]){ break; }
var param_name = this.parameters[e].name;
s += cmd[param_name.toLowerCase()]() ? "" : "<span class='param'>"+param_name+"</span>";
e += 1;
} }
// Variables return this.pad(content)+h;
if(this.variables){
for (var key in this.variables){
if(cmd.variable(key)){continue;}
s += "<span class='variable_key'>"+key+"</span>=<span class='variable_value'>"+this.variables[key]+"</span> ";
}
}
return s;
} }
this.pad = function(input) this.pad = function(input)
{ {
var s = ""; var s = "";
for (i = 0; i < input.length+2; i++){ for (i = 0; i < input.length+1; i++){
s += "_"; s += "_";
} }
return "<span style='color:#000'>"+s+"</span>"; return "<span style='color:#000'>"+s+"</span>";
} }

View File

@ -30,28 +30,27 @@ function Render(rune)
var name = cmd.content[0]; var name = cmd.content[0];
if(!this.collection[name]){ console.log("unknown ",name); return; } if(!this.collection[name]){ return; }
return this.collection[name].preview(cmd); return this.collection[name].preview(cmd);
} }
this.hint = function(cmd) this.hint = function(content)
{ {
var input = cmd.content.join(" ").trim().split(" ")[0]; var name = content.trim().replace(this.rune,"").trim().split(" ");
var s = this.pad(cmd.content.join(" "));
if(this.collection[input]){ var h = "";
for (i = 0; i < this.collection[input].parameters.length; i++) { if(this.collection[name]){
s += this.collection[input].parameters[i].name+" "; for (i = 0; i < this.collection[name].parameters.length; i++) {
h += this.collection[name].parameters[i].name+" ";
} }
} }
else{ else{
for (var key in this.collection){ for (var key in this.collection){
s += key+" "; h += key+" ";
} }
} }
return this.pad(content)+h;
return s;
} }
} }

View File

@ -121,34 +121,20 @@ function Terminal(rune)
this.update_hint = function(content = this.input_element.value) this.update_hint = function(content = this.input_element.value)
{ {
var padding = ""; ronin.terminal.input_element.setAttribute("style","color:"+ronin.brush.color.hex);
for (var i = 0; i < this.input_element.value.length; i++) {
padding += " ";
}
if(content.indexOf(";") > -1){ if(content.indexOf(";") > -1){
var h = padding+" "+content.split(";").length+" commands"; this.hint_element.innerHTML = padding+" "+content.split(";").length+" commands";
} }
else if(ronin.module){ else if(ronin.module){
var h = padding+" <span class='name'>"+ronin.module.constructor.name+"</span> "; this.hint_element.innerHTML = ronin.module.hint(content);
for(param in ronin.module.parameters){
var name = new ronin.module.parameters[param]().constructor.name;
h += name+" ";
}
for(variable in ronin.module.variables){
h += variable+"="+ronin.module.variables[variable]+" ";
}
} }
else{ else{
var h = ""; this.hint_element.innerHTML = "";
for(module in ronin.modules){ for(module in ronin.modules){
h += module+" "; this.hint_element.innerHTML += "<b>"+module+"</b> "+ronin.modules[module].constructor.name+" ";
} }
} }
this.hint_element.innerHTML = h;
ronin.terminal.input_element.setAttribute("style","color:"+ronin.brush.color.hex);
} }
this.update_menu = function() this.update_menu = function()