Improved Terminal
This commit is contained in:
parent
a9f76f6100
commit
748fec89f4
@ -1,4 +1,3 @@
|
||||
|
||||
frame.resize 300x300
|
||||
frame.select main
|
||||
layer.fill #ff0000
|
||||
@ -12,3 +11,5 @@ type.write 38,262 "RONIN"
|
||||
type.write 38,252 "B08"
|
||||
brush:color #000000
|
||||
brush:size 10
|
||||
path:line_width 20
|
||||
path:line_color #999999
|
@ -117,5 +117,6 @@ function Ronin()
|
||||
}
|
||||
rawFile.send(null);
|
||||
ronin.widget.update();
|
||||
ronin.terminal.update();
|
||||
}
|
||||
}
|
@ -14,7 +14,10 @@ function Cursor(rune)
|
||||
|
||||
this.update = function(event = null)
|
||||
{
|
||||
if(event && event.altKey == true && event.shiftKey == true){
|
||||
if(ronin.terminal.cmd().module()){
|
||||
this.set_mode(ronin.terminal.cmd().module());
|
||||
}
|
||||
else if(event && event.altKey == true && event.shiftKey == true){
|
||||
this.set_mode(ronin.frame.active_layer);
|
||||
}
|
||||
else if(event && event.altKey == true){
|
||||
|
@ -15,7 +15,7 @@ function Frame(rune)
|
||||
this.install = function()
|
||||
{
|
||||
this.blink();
|
||||
this.select(new Command("background"));
|
||||
this.select(new Command("frame.select main"));
|
||||
|
||||
// Canvas
|
||||
var starting_canvas = new Rect();
|
||||
@ -62,7 +62,7 @@ function Frame(rune)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
var layer_name = params.content;
|
||||
var layer_name = "main";
|
||||
if(!ronin.frame.layers[layer_name]){
|
||||
this.add_layer(new Layer(layer_name));
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ function Overlay(rune)
|
||||
this.draw = function(position,rect)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); this.layer.is_blinking = true; }
|
||||
this.get_layer().clear();
|
||||
|
||||
if(!position){ position = new Position("0,0"); }
|
||||
|
||||
@ -163,45 +162,9 @@ function Overlay(rune)
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
this.live_draw_from = null;
|
||||
|
||||
this.mouse_down = function(position)
|
||||
this.clear = function()
|
||||
{
|
||||
ronin.overlay.clear();
|
||||
ronin.overlay.draw_pointer(position);
|
||||
this.live_draw_from = position;
|
||||
// ronin.terminal.input_element.value = "| "+this.live_draw_from.render();
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
if(this.live_draw_from === null){ return; }
|
||||
|
||||
ronin.overlay.clear();
|
||||
|
||||
var rect = new Rect();
|
||||
rect.width = position.x - this.live_draw_from.x;
|
||||
rect.height = position.y - this.live_draw_from.y;
|
||||
|
||||
ronin.overlay.draw_rect(this.live_draw_from,rect);
|
||||
// ronin.terminal.input_element.value = "| "+this.live_draw_from.render()+" "+rect.render();
|
||||
|
||||
ronin.terminal.update_hint();
|
||||
}
|
||||
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
this.live_draw_from = null;
|
||||
// ronin.terminal.input_element.focus();
|
||||
}
|
||||
|
||||
// Widget
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Guide";
|
||||
this.layer.remove(this);
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
|
@ -27,7 +27,7 @@ function Path(rune)
|
||||
context.stroke(new Path2D(cmd.values()));
|
||||
context.closePath();
|
||||
|
||||
if(!preview){ this.coordinates = []; this.last_pos = null; }
|
||||
if(!preview){ this.coordinates = []; this.last_pos = null; if(!preview){ this.layer.remove(this); } }
|
||||
|
||||
return 1, preview ? "preview" : "ok";
|
||||
}
|
||||
|
@ -7,19 +7,16 @@ function Source(rune)
|
||||
this.add_method(new Method("save",["name","rect","format"]));
|
||||
this.add_method(new Method("load",["path","position","rect"]),"Add point");
|
||||
|
||||
this.load = function(params,preview = false) // source.load ../assets/todo.jpg 200x200 40,40
|
||||
this.load = function(params,preview = false) // source.load /01.jpg 0,0 100x100
|
||||
{
|
||||
if(!params.filepath()){ return 0, "Path?"; }
|
||||
if(!params.rect()){ return 0,"Rect?"; }
|
||||
|
||||
this.get_layer(true).clear();
|
||||
ronin.overlay.draw_rect(position,params.rect());
|
||||
|
||||
var target_layer = preview ? this.get_layer(true) : ronin.frame.active_layer;
|
||||
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
if(preview){ return; }
|
||||
|
||||
var position = params.position() ? params.position() : new Position("0,0");
|
||||
ronin.overlay.draw_rect(position,params.rect());
|
||||
|
||||
base_image = new Image();
|
||||
base_image.src = "../assets/"+params.filepath().path;
|
||||
@ -38,12 +35,12 @@ function Source(rune)
|
||||
width = isNaN(width) && height > 0 ? (height*base_image.naturalWidth)/base_image.naturalHeight : width;
|
||||
height = isNaN(height) && width > 0 ? (width*base_image.naturalHeight)/base_image.naturalWidth : height;
|
||||
|
||||
target_layer.context().drawImage(base_image, position.x, position.y, width, height);
|
||||
ronin.frame.active_layer.context().drawImage(base_image, position.x, position.y, width, height);
|
||||
}
|
||||
|
||||
if(!preview){ ronin.overlay.get_layer(true).clear(); }
|
||||
ronin.overlay.clear();
|
||||
|
||||
return 1,"ok";
|
||||
return 1,"Loaded "+params.filepath().path+" at "+position.render();
|
||||
}
|
||||
|
||||
this.save = function(params,preview = false)
|
||||
|
@ -41,6 +41,7 @@ function Terminal(rune)
|
||||
}
|
||||
if(setting){
|
||||
module.settings[setting] = command.values();
|
||||
this.log(new Log(module,setting+" = "+command.values()));
|
||||
}
|
||||
this.hint_element.innerHTML = "";
|
||||
this.input.value = "";
|
||||
@ -48,7 +49,8 @@ function Terminal(rune)
|
||||
|
||||
this.update = function(value = null)
|
||||
{
|
||||
this.input.value = value ? value : this.input.value;
|
||||
if(value){ this.input.value = value; this.input.focus(); }
|
||||
|
||||
var command = this.cmd();
|
||||
var module = command.module();
|
||||
var method = command.method();
|
||||
@ -58,7 +60,6 @@ function Terminal(rune)
|
||||
}
|
||||
this.hint_element.innerHTML = "<span class='input'>"+this.input.value+"</span>"+(this.input.value ? " " : "")+(module ? module.hint(method) : this.hint(method));
|
||||
ronin.cursor.set_mode(module);
|
||||
this.input.focus();
|
||||
}
|
||||
|
||||
this.run_multi = function(lines)
|
||||
|
@ -23,7 +23,7 @@ function Type(rune)
|
||||
target_layer.context().fillStyle = color;
|
||||
target_layer.context().fillText(text,position.x,position.y);
|
||||
|
||||
if(!preview){ this.layer.clear(); }
|
||||
if(!preview){ this.layer.remove(this); }
|
||||
|
||||
return 1, "Wrote "+text+" at "+position.render();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user