Support for multiline commands.

This commit is contained in:
Devine Lu Linvega 2016-11-13 09:22:05 -08:00
parent 57b57c3a91
commit 490af4a725
3 changed files with 32 additions and 8 deletions

View File

@ -2,9 +2,18 @@ function Brush()
{
this.position = new Position();
this.is_drawing = false;
this.size = 1;
this.opacity = 1;
// Commander
this.settings = function(p)
{
if(p[0]){ this.size = parseInt(p[0]); }
if(p[1]){ this.opacity = parseFloat(p[1]); }
if(p[2]){ this.color = new Color(p[2]); }
}
this.add = function(p)
{
if(p.length > 1){

View File

@ -15,25 +15,29 @@ function Commander(element,element_input)
this.element_input.value = "";
}
this.validate = function()
this.validate = function(command)
{
var parts = this.element_input.value.split(" ");
var parts = command;
// Canvas
if(parts[0] == "@"){
canvas.setAttribute('width',parts[1]+"px");
canvas.setAttribute('height',parts[2]+"px");
ronin.guides_element.setAttribute('width',parts[1]+"px");
ronin.guides_element.setAttribute('height',parts[2]+"px");
}
// Brush
if(parts[0] == "+"){
if(parts[0] == "&"){
parts.shift();
brush.settings(parts);
}
// Pointers
if(parts[0] == ">"){
parts.shift();
brush.add(parts);
}
if(parts[0] == "-"){
parts.shift();
brush.remove(parts);
}
// Save
if(parts[0] == "$"){

View File

@ -41,7 +41,18 @@ function Keyboard()
this.key_enter = function()
{
commander.validate();
var cmd = commander.element_input.value;
if(cmd.indexOf(";") > 0){
var cmds = cmd.split(";");
for (i = 0; i < cmds.length; i++) {
cmd = cmds[i].replace(/^\s+|\s+$/g, '');
commander.validate(cmd.split(" "));
}
}
else{
commander.validate(cmd.split(" "));
}
}
this.key_space = function()