2017-03-28 00:18:04 -07:00

57 lines
1.5 KiB
JavaScript

function Type(rune)
{
Module.call(this,rune);
this.add_method(new Method("write",["Position","Text"],"Add position"));
this.settings = {"color":"#ffffff","size":"10","font":"Din"};
this.write = function(params,preview = false)
{
if(!this.layer){ this.create_layer(); this.layer.is_blinking = true; }
this.layer.clear();
var text = "Hello.".replace("_"," ");
var position = params.position() ? params.position() : new Position(40,80);
var color = params.color() ? params.color() :new Color("#ffffff");
var size = 40;
var font = "Georgia";
this.layer.context().font = size+"px "+font;
this.layer.context().fillStyle = color.hex;
this.layer.context().fillText(text,position.x,position.y);
}
// Mouse
this.mouse_mode = function()
{
return "Type";
}
this.mouse_down = function(position)
{
ronin.terminal.input_element.value = "type."+ronin.terminal.method_name+" "+position.render();
ronin.terminal.passive();
}
this.mouse_move = function(position,rect)
{
ronin.terminal.input_element.value = "type."+ronin.terminal.method_name+" "+position.render();
ronin.terminal.passive();
}
this.mouse_up = function(position)
{
ronin.terminal.input_element.value = "type."+ronin.terminal.method_name+" "+position.render();
ronin.terminal.passive();
}
this.key_escape = function()
{
if(this.layer){ this.layer.remove(this); }
ronin.terminal.input_element.value = "";
ronin.terminal.passive();
}
}