Option to delete layers
This commit is contained in:
parent
550b31e8b7
commit
c02348a091
@ -7,20 +7,31 @@ function Commander(element,element_input)
|
|||||||
this.storage_index = 0;
|
this.storage_index = 0;
|
||||||
this.always_show = false;
|
this.always_show = false;
|
||||||
|
|
||||||
|
var queue = [];
|
||||||
|
|
||||||
this.query = function(input_str)
|
this.query = function(input_str)
|
||||||
{
|
{
|
||||||
if(input_str.indexOf(";") > 0){
|
if(input_str.indexOf(";") > 0){
|
||||||
var multi = input_str.split(";");
|
queue = input_str.split(";");
|
||||||
for (i = 0; i < multi.length; i++) {
|
|
||||||
this.query(multi[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.active(input_str);
|
queue.push(input_str)
|
||||||
|
}
|
||||||
|
run();
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function run()
|
||||||
|
{
|
||||||
|
active(queue[0].trim());
|
||||||
|
|
||||||
|
queue.shift();
|
||||||
|
if(queue.length > 0){
|
||||||
|
setTimeout(function(){ run(); }, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.active = function(content)
|
function active(content)
|
||||||
{
|
{
|
||||||
var key = content[0];
|
var key = content[0];
|
||||||
var cmd = new Command(content.substring(1).split(" "));
|
var cmd = new Command(content.substring(1).split(" "));
|
||||||
@ -29,8 +40,6 @@ function Commander(element,element_input)
|
|||||||
ronin.modules[key].active(cmd);
|
ronin.modules[key].active(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hide();
|
|
||||||
|
|
||||||
ronin.history.add(content);
|
ronin.history.add(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ var commander = new Commander(document.getElementById("commander"),document.getE
|
|||||||
commander.hint.element = document.getElementById('commander_hint');
|
commander.hint.element = document.getElementById('commander_hint');
|
||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
|
|
||||||
document.addEventListener('mousedown', function(e){ ronin.cursor.mouse_down(ronin.position_in_canvas(e));}, false);
|
document.addEventListener('mousedown', function(e){ ronin.cursor.mouse_down(ronin.position_in_canvas(e));}, false);
|
||||||
document.addEventListener('mousemove', function(e){ ronin.cursor.mouse_move(ronin.position_in_canvas(e));}, false);
|
document.addEventListener('mousemove', function(e){ ronin.cursor.mouse_move(ronin.position_in_canvas(e));}, false);
|
||||||
document.addEventListener('mouseup', function(e){ ronin.cursor.mouse_up(ronin.position_in_canvas(e));}, false);
|
document.addEventListener('mouseup', function(e){ ronin.cursor.mouse_up(ronin.position_in_canvas(e));}, false);
|
||||||
|
@ -8,15 +8,14 @@ function Keyboard()
|
|||||||
case "ArrowDown": this.key_arrow_down(); break;
|
case "ArrowDown": this.key_arrow_down(); break;
|
||||||
case "ArrowLeft": this.key_arrow_left(); break;
|
case "ArrowLeft": this.key_arrow_left(); break;
|
||||||
case "ArrowRight": this.key_arrow_right(); break;
|
case "ArrowRight": this.key_arrow_right(); break;
|
||||||
case ":": this.key_colon(); break;
|
// case ":": this.key_colon(); break;
|
||||||
case ";": if (event.shiftKey) this.key_colon(); break;
|
|
||||||
case "Escape": this.key_escape(); break;
|
case "Escape": this.key_escape(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(event.which)
|
switch(event.which)
|
||||||
{
|
{
|
||||||
case 13: this.key_enter(); break;
|
case 13: this.key_enter(); break;
|
||||||
case 186: this.key_colon(); break;
|
case 186: if(event.shiftKey){this.key_colon();} break;
|
||||||
case 27: this.key_escape(); break;
|
case 27: this.key_escape(); break;
|
||||||
case 219: ronin.brush.size_up(); break;
|
case 219: ronin.brush.size_up(); break;
|
||||||
case 221: ronin.brush.size_down(); break;
|
case 221: ronin.brush.size_down(); break;
|
||||||
|
@ -3,7 +3,7 @@ function Surface(rune)
|
|||||||
Module.call(this,rune);
|
Module.call(this,rune);
|
||||||
|
|
||||||
this.element = null;
|
this.element = null;
|
||||||
this.parameters = [Rect,Color];
|
this.parameters = [Rect,Color,Bang];
|
||||||
this.variables = {"layer" : "main"};
|
this.variables = {"layer" : "main"};
|
||||||
|
|
||||||
this.layers = {};
|
this.layers = {};
|
||||||
@ -24,6 +24,11 @@ function Surface(rune)
|
|||||||
this.context().fillStyle = cmd.color().hex;
|
this.context().fillStyle = cmd.color().hex;
|
||||||
this.context().fill();
|
this.context().fill();
|
||||||
}
|
}
|
||||||
|
if(cmd.bang() && Object.keys(ronin.surface.layers).length > 1){
|
||||||
|
delete this.layers[this.active_layer.name];
|
||||||
|
this.select_any_layer();
|
||||||
|
ronin.widget.update();
|
||||||
|
}
|
||||||
|
|
||||||
if(cmd.variable("layer")){
|
if(cmd.variable("layer")){
|
||||||
var name = cmd.variable("layer").value;
|
var name = cmd.variable("layer").value;
|
||||||
@ -32,7 +37,6 @@ function Surface(rune)
|
|||||||
}
|
}
|
||||||
this.select_layer(this.layers[name]);
|
this.select_layer(this.layers[name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.select_layer = function(layer)
|
this.select_layer = function(layer)
|
||||||
@ -41,6 +45,12 @@ function Surface(rune)
|
|||||||
this.active_layer = layer;
|
this.active_layer = layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.select_any_layer = function()
|
||||||
|
{
|
||||||
|
var layer_name = Object.keys(ronin.surface.layers)[0];
|
||||||
|
this.select_layer(ronin.surface.layers[layer_name]);
|
||||||
|
}
|
||||||
|
|
||||||
this.add_layer = function(layer)
|
this.add_layer = function(layer)
|
||||||
{
|
{
|
||||||
console.log("Creating layer:"+layer.name);
|
console.log("Creating layer:"+layer.name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user