Progress with params in methods
This commit is contained in:
parent
3f17f37458
commit
1bd42e15c8
@ -104,4 +104,12 @@ function Command(content)
|
|||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.method = function(name)
|
||||||
|
{
|
||||||
|
for(i in this.methods()){
|
||||||
|
var m = new Method(this.methods()[i]);
|
||||||
|
if(m.name == name){ return m; }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,6 +13,11 @@ function Module(rune)
|
|||||||
console.log("Installing "+ronin.modules[this.rune].constructor.name);
|
console.log("Installing "+ronin.modules[this.rune].constructor.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.context = function()
|
||||||
|
{
|
||||||
|
return this.select_layer().context();
|
||||||
|
}
|
||||||
|
|
||||||
this.create_layer = function()
|
this.create_layer = function()
|
||||||
{
|
{
|
||||||
this.layer = new Layer(this.constructor.name+".Preview",this);
|
this.layer = new Layer(this.constructor.name+".Preview",this);
|
||||||
|
@ -127,11 +127,6 @@ function Overlay(rune)
|
|||||||
this.context().closePath();
|
this.context().closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clear = function()
|
|
||||||
{
|
|
||||||
this.context().clearRect(0, 0, ronin.surface.settings["size"].width, ronin.surface.settings["size"].height);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
|
|
||||||
this.live_draw_from = null;
|
this.live_draw_from = null;
|
||||||
|
@ -4,7 +4,7 @@ function Surface(rune)
|
|||||||
|
|
||||||
this.element = null;
|
this.element = null;
|
||||||
this.settings = {"size":new Rect("200x200")};
|
this.settings = {"size":new Rect("200x200")};
|
||||||
this.methods = [new Method("resize",[new Rect().name])]
|
this.methods = [new Method("resize",[new Rect().name]),new Method("crop",[new Position().name,new Rect().name])]
|
||||||
|
|
||||||
this.layers = {};
|
this.layers = {};
|
||||||
this.active_layer = null;
|
this.active_layer = null;
|
||||||
@ -130,11 +130,19 @@ function Surface(rune)
|
|||||||
if(keys[loc-1] != null){this.select_layer(ronin.surface.layers[keys[loc-1]]);}
|
if(keys[loc-1] != null){this.select_layer(ronin.surface.layers[keys[loc-1]]);}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layers
|
this.passive = function(cmd)
|
||||||
|
|
||||||
this.context = function()
|
|
||||||
{
|
{
|
||||||
return this.active_layer.context();
|
var crop = ronin.terminal.cmd().method("crop");
|
||||||
|
|
||||||
|
if(crop && crop.params.length == 2){
|
||||||
|
console.log(crop);
|
||||||
|
ronin.overlay.select_layer().clear();
|
||||||
|
ronin.overlay.draw_rect(new Position(crop.params[0]),new Rect(crop.params[1]));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log("Missing params")
|
||||||
|
}
|
||||||
|
ronin.terminal.update_hint();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
@ -146,19 +154,14 @@ function Surface(rune)
|
|||||||
|
|
||||||
this.mouse_down = function(position)
|
this.mouse_down = function(position)
|
||||||
{
|
{
|
||||||
ronin.overlay.clear();
|
ronin.overlay.select_layer().clear();
|
||||||
ronin.overlay.draw_pointer(position);
|
ronin.overlay.draw_pointer(position);
|
||||||
ronin.terminal.input_element.value = "| "+this.mouse_from.render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mouse_move = function(position,rect)
|
this.mouse_move = function(position,rect)
|
||||||
{
|
{
|
||||||
ronin.overlay.clear();
|
ronin.terminal.input_element.value = "@ crop:"+this.mouse_from.render()+":"+rect.render()+" ";
|
||||||
|
this.passive();
|
||||||
ronin.overlay.draw_rect(this.mouse_from,rect);
|
|
||||||
ronin.terminal.input_element.value = "@ "+this.mouse_from.render()+" "+rect.render();
|
|
||||||
|
|
||||||
ronin.terminal.update_hint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mouse_up = function(position,rect)
|
this.mouse_up = function(position,rect)
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
function Method(name,params)
|
function Method(method_str)
|
||||||
{
|
{
|
||||||
Unit.call(this);
|
Unit.call(this);
|
||||||
|
|
||||||
this.name = name;
|
var content = method_str.split(":");
|
||||||
this.params = params;
|
this.name = content.shift();
|
||||||
|
this.params = content;
|
||||||
this.example = "";
|
this.example = "";
|
||||||
|
|
||||||
this.render = function()
|
this.render = function()
|
||||||
{
|
{
|
||||||
var s = name+":";
|
var s = name+":";
|
||||||
for(param in this.params){
|
for(param in this.params){
|
||||||
s += this.params[param]+","
|
s += this.params[param]+":"
|
||||||
}
|
}
|
||||||
s = s.substr(0,s.length-1);
|
s = s.substr(0,s.length-1);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user