59 lines
1.5 KiB
JavaScript
59 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; }
|
|
|
|
var command = new Command(params);
|
|
|
|
this.layer.clear();
|
|
|
|
var text = "Hello there.".replace("_"," ");
|
|
var position = command.position() ? command.position() : new Position(40,80);
|
|
var 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();
|
|
}
|
|
} |