Moved Hint to modules
This commit is contained in:
parent
4040964505
commit
fe9e2c9475
@ -15,7 +15,7 @@ canvas:hover { cursor: none;}
|
||||
#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 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 log { display: block; font-size:10px; line-height:25px; padding:0px 5px; color:#666;}
|
||||
#terminal logs log .rune { color:white; }
|
||||
|
@ -36,40 +36,26 @@ function Module(rune)
|
||||
}
|
||||
}
|
||||
|
||||
this.hint = function(cmd)
|
||||
this.hint = function(content)
|
||||
{
|
||||
var s = this.pad(cmd.content.join(" "));
|
||||
|
||||
s += cmd.content.join(" ").length == 0 ? "<span class='module'>"+this.constructor.name+"</span>" : "";
|
||||
|
||||
// Params
|
||||
|
||||
var e = 0;
|
||||
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;
|
||||
var h = "<span class='name'>"+ronin.module.constructor.name+"</span> ";
|
||||
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]+" ";
|
||||
}
|
||||
|
||||
// Variables
|
||||
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;
|
||||
return this.pad(content)+h;
|
||||
}
|
||||
|
||||
this.pad = function(input)
|
||||
{
|
||||
var s = "";
|
||||
for (i = 0; i < input.length+2; i++){
|
||||
for (i = 0; i < input.length+1; i++){
|
||||
s += "_";
|
||||
}
|
||||
|
||||
return "<span style='color:#000'>"+s+"</span>";
|
||||
}
|
||||
|
||||
|
@ -30,28 +30,27 @@ function Render(rune)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
this.hint = function(cmd)
|
||||
this.hint = function(content)
|
||||
{
|
||||
var input = cmd.content.join(" ").trim().split(" ")[0];
|
||||
var s = this.pad(cmd.content.join(" "));
|
||||
var name = content.trim().replace(this.rune,"").trim().split(" ");
|
||||
|
||||
if(this.collection[input]){
|
||||
for (i = 0; i < this.collection[input].parameters.length; i++) {
|
||||
s += this.collection[input].parameters[i].name+" ";
|
||||
var h = "";
|
||||
if(this.collection[name]){
|
||||
for (i = 0; i < this.collection[name].parameters.length; i++) {
|
||||
h += this.collection[name].parameters[i].name+" ";
|
||||
}
|
||||
}
|
||||
else{
|
||||
for (var key in this.collection){
|
||||
s += key+" ";
|
||||
h += key+" ";
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
return this.pad(content)+h;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -121,34 +121,20 @@ function Terminal(rune)
|
||||
|
||||
this.update_hint = function(content = this.input_element.value)
|
||||
{
|
||||
var padding = "";
|
||||
for (var i = 0; i < this.input_element.value.length; i++) {
|
||||
padding += " ";
|
||||
}
|
||||
ronin.terminal.input_element.setAttribute("style","color:"+ronin.brush.color.hex);
|
||||
|
||||
if(content.indexOf(";") > -1){
|
||||
var h = padding+" "+content.split(";").length+" commands";
|
||||
this.hint_element.innerHTML = padding+" "+content.split(";").length+" commands";
|
||||
}
|
||||
else if(ronin.module){
|
||||
var h = padding+" <span class='name'>"+ronin.module.constructor.name+"</span> ";
|
||||
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]+" ";
|
||||
}
|
||||
this.hint_element.innerHTML = ronin.module.hint(content);
|
||||
}
|
||||
else{
|
||||
var h = "";
|
||||
this.hint_element.innerHTML = "";
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user