Terminal.load default.rin
This commit is contained in:
parent
c36e5cc612
commit
07a959f777
@ -11,6 +11,7 @@
|
||||
<script type="text/javascript" src="scripts/units/any.js"></script>
|
||||
<script type="text/javascript" src="scripts/units/setting.js"></script>
|
||||
<script type="text/javascript" src="scripts/units/range.js"></script>
|
||||
<script type="text/javascript" src="scripts/units/option.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/units/method.js"></script>
|
||||
<script type="text/javascript" src="scripts/units/setting.js"></script>
|
||||
|
@ -26,8 +26,9 @@ body { margin:0px; padding:0px; overflow:hidden; font-family:"input_mono_medium"
|
||||
#terminal #hint .setting { display: inline-block; color:#fff; font-style: italic }
|
||||
|
||||
#modal { position: fixed; bottom:80px; right:20px; height:100px; background:#111; border-radius:3px; overflow:hidden; display: block}
|
||||
#modal.text { display: block;background: white;width:calc(60vw - 60px);height:calc(100vh - 160px);padding:30px;font-size:12px; white-space:pre; column-count: 2; line-height: 16px}
|
||||
#modal.text .module { font-family: 'input_mono_regular';}
|
||||
#modal.text { display: block;background: #000;width: calc(100vw - 100px);height: calc(100vh - 160px);padding: 30px;font-size: 12px;white-space: pre;column-count: 3;line-height: 20px;color:white}
|
||||
#modal.text .module { font-family: 'input_mono_regular'; border-bottom:1px solid #333; display: block; line-height: 30px}
|
||||
/*#modal.text .module:before { content: "-";margin-left:-15px;margin-right:15px;display:inline-block }*/
|
||||
#modal.text .setting { font-style: italic; color:#999;}
|
||||
#modal.text .mode { text-decoration: underline}
|
||||
#modal.image img { display: block; max-height: 100%; width:inherit;}
|
||||
|
@ -12,6 +12,6 @@ type.write 38,262 "RONIN"
|
||||
type:font "DIN Medium"
|
||||
type.write 38,252 "B09"
|
||||
brush:color #ff0000
|
||||
brush:size 2
|
||||
brush:size 5
|
||||
path:line_width 20
|
||||
path:line_color #999999
|
@ -116,6 +116,14 @@ function Command(content)
|
||||
return null;
|
||||
}
|
||||
|
||||
this.option = function(name)
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
if(this.parts[i].indexOf(name+"=") >= 0){ return new Option(this.parts[i]); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.bang = function()
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
|
@ -63,6 +63,23 @@ function Ronin()
|
||||
ronin.terminal.input.focus();
|
||||
ronin.load(target_file);
|
||||
}
|
||||
|
||||
this.hint = function(method)
|
||||
{
|
||||
var html = "";
|
||||
if(this.terminal.input.value){
|
||||
for(id in ronin.modules){
|
||||
if(this.terminal.input.value != ronin.modules[id].name.substr(0,this.terminal.input.value.length)){ continue; }
|
||||
html += "<span class='module'>"+ronin.modules[id].name+"</span> ";
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(id in ronin.modules){
|
||||
html += "<span class='module'>"+ronin.modules[id].name+"</span> ";
|
||||
}
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
this.cursors = [];
|
||||
|
||||
|
@ -8,16 +8,31 @@ function Brush(rune)
|
||||
this.add_mode(new Mode("erase","alt"));
|
||||
this.add_setting(new Setting("color","#00ff00"));
|
||||
this.add_setting(new Setting("size","2"));
|
||||
this.add_method(new Method("add_pointer",["Position","Color","Scale"]));
|
||||
this.add_method(new Method("add_pointer",["Position","Color","Scale","mirror_x","mirror_y"]));
|
||||
|
||||
this.add_pointer = function(cmd, preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
if(cmd.option("mirror_x")){
|
||||
var mirror_x = parseFloat(cmd.option("mirror_x").value);
|
||||
ronin.overlay.draw(new Position(mirror_x+",0"))
|
||||
}
|
||||
if(cmd.option("mirror_y")){
|
||||
var mirror_y = parseFloat(cmd.option("mirror_y").value);
|
||||
ronin.overlay.draw(new Position("0,"+mirror_y))
|
||||
}
|
||||
|
||||
if(preview){
|
||||
return;
|
||||
}
|
||||
|
||||
var pointer = new Pointer();
|
||||
pointer.offset = cmd.position() ? cmd.position() : new Position("0,0");
|
||||
pointer.color = cmd.color().hex ? cmd.color().hex : this.settings["color"].value;
|
||||
pointer.scale = cmd.value().float ? cmd.value().float : 1;
|
||||
pointer.color = cmd.color() ? cmd.color().hex : this.settings["color"].value;
|
||||
pointer.scale = cmd.value() ? cmd.value().float : 1;
|
||||
|
||||
if(mirror_x){ pointer.mirror_x = mirror_x; }
|
||||
if(mirror_y){ pointer.mirror_y = mirror_y; }
|
||||
|
||||
this.pointers.push(pointer);
|
||||
|
||||
ronin.terminal.log(new Log(this,"Added pointer at: "+pointer.offset.render()));
|
||||
|
@ -4,7 +4,9 @@ function Pointer(offset = new Position(), color = null, scale = 1)
|
||||
this.color = color;
|
||||
this.scale = scale;
|
||||
|
||||
this.mirror = null;
|
||||
this.mirror_x = null;
|
||||
this.mirror_y = null;
|
||||
|
||||
this.position_prev = null;
|
||||
this.angle = null;
|
||||
this.distance = 0;
|
||||
@ -16,16 +18,12 @@ function Pointer(offset = new Position(), color = null, scale = 1)
|
||||
this.thickness = function()
|
||||
{
|
||||
var radius = ronin.brush.settings["size"].to_f() * this.scale;
|
||||
|
||||
var ratio = this.position().distance_to(this.position_prev[0]);
|
||||
// ratio = ratio > 1 ? 1 : ratio;
|
||||
|
||||
var ratio = 1 - this.position().distance_to((this.position_prev ? this.position_prev[0] : 1)) / 10;
|
||||
var target = radius * ratio;
|
||||
var rate = ronin.brush.settings["size"].to_f()/8;
|
||||
|
||||
// return target;
|
||||
|
||||
if(this.actual_thickness < target){ this.actual_thickness += 0.25; }
|
||||
if(this.actual_thickness > target){ this.actual_thickness -= 0.25; }
|
||||
if(this.actual_thickness < target){ this.actual_thickness += rate; }
|
||||
if(this.actual_thickness > target){ this.actual_thickness -= rate; }
|
||||
|
||||
return this.actual_thickness;
|
||||
}
|
||||
@ -79,12 +77,16 @@ function Pointer(offset = new Position(), color = null, scale = 1)
|
||||
|
||||
this.position = function()
|
||||
{
|
||||
if(this.mirror_x && this.mirror_x > 0){
|
||||
return this.position_mirror_x();
|
||||
}
|
||||
if(this.mirror_y && this.mirror_y > 0){
|
||||
return this.position_mirror_y();
|
||||
}
|
||||
|
||||
if(this.angle && this.offset){
|
||||
return this.position_rotation();
|
||||
}
|
||||
else if(this.mirror && this.mirror.width > 0){
|
||||
return this.position_mirror_x();
|
||||
}
|
||||
else if(this.mirror && this.mirror.height > 0){
|
||||
return this.position_mirror_y();
|
||||
}
|
||||
@ -100,12 +102,12 @@ function Pointer(offset = new Position(), color = null, scale = 1)
|
||||
|
||||
this.position_mirror_x = function()
|
||||
{
|
||||
return new Position((2 * this.mirror.width) - (ronin.cursor.position.x + this.offset.x), 0 + (ronin.cursor.position.y + this.offset.y));
|
||||
return new Position((2 * this.mirror_x) - (ronin.cursor.position.x + this.offset.x), 0 + (ronin.cursor.position.y + this.offset.y));
|
||||
}
|
||||
|
||||
this.position_mirror_y = function()
|
||||
{
|
||||
return new Position((ronin.cursor.position.x + this.offset.x), (2 * this.mirror.height) - (ronin.cursor.position.y + this.offset.y));
|
||||
return new Position((ronin.cursor.position.x + this.offset.x), (2 * this.mirror_y) - (ronin.cursor.position.y + this.offset.y));
|
||||
}
|
||||
|
||||
this.position_rotation = function()
|
||||
@ -123,9 +125,9 @@ function Pointer(offset = new Position(), color = null, scale = 1)
|
||||
this.start = function()
|
||||
{
|
||||
var radius = ronin.brush.settings["size"].to_f() * this.scale;
|
||||
this.actual_thickness = radius/2;
|
||||
this.actual_thickness = radius/4;
|
||||
ronin.frame.context().beginPath();
|
||||
ronin.frame.context().arc(this.position().x, this.position().y, radius/2, 0, 2 * Math.PI, false);
|
||||
ronin.frame.context().arc(this.position().x, this.position().y, this.thickness(), 0, 2 * Math.PI, false);
|
||||
ronin.frame.context().lineWidth = 0;
|
||||
ronin.frame.context().fillStyle = this.color ? this.color : ronin.brush.settings["color"].value;
|
||||
ronin.frame.context().fill();
|
||||
|
@ -139,7 +139,7 @@ function Overlay(rune)
|
||||
this.context().beginPath();
|
||||
|
||||
this.context().moveTo(position.x,0);
|
||||
this.context().lineTo(position.x,this.element.height);
|
||||
this.context().lineTo(position.x,ronin.frame.size.height);
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
@ -153,7 +153,7 @@ function Overlay(rune)
|
||||
this.context().beginPath();
|
||||
|
||||
this.context().moveTo(0,position.y);
|
||||
this.context().lineTo(this.element.width,position.y);
|
||||
this.context().lineTo(ronin.frame.size.width,position.y);
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
|
@ -1,6 +1,6 @@
|
||||
function Terminal(rune)
|
||||
{
|
||||
Module.call(this,">");
|
||||
Module.call(this);
|
||||
|
||||
this.element = document.createElement("div");
|
||||
this.input = document.createElement("input");
|
||||
@ -13,8 +13,7 @@ function Terminal(rune)
|
||||
this.history = [];
|
||||
this.locks = [];
|
||||
|
||||
this.add_method(new Method("save",["text"]));
|
||||
this.add_method(new Method("load",["path"]));
|
||||
this.add_method(new Method("load",["file_name.rin"]));
|
||||
|
||||
// Module
|
||||
this.install = function(cmd)
|
||||
@ -59,7 +58,7 @@ function Terminal(rune)
|
||||
if(method){
|
||||
method.preview(command);
|
||||
}
|
||||
this.hint_element.innerHTML = "<span class='input'>"+this.input.value+"</span>"+(this.input.value ? " " : "")+(module ? module.hint(method) : this.hint(method));
|
||||
this.hint_element.innerHTML = "<span class='input'>"+this.input.value+"</span>"+(this.input.value ? " " : "")+(module ? module.hint(method) : ronin.hint(method));
|
||||
ronin.cursor.update();
|
||||
}
|
||||
|
||||
@ -74,23 +73,6 @@ function Terminal(rune)
|
||||
if(lines.length > 0){ setTimeout(function(){ ronin.terminal.run_multi(lines.join(";")) }, 50); }
|
||||
}
|
||||
|
||||
this.hint = function(method)
|
||||
{
|
||||
var html = "";
|
||||
if(this.input.value){
|
||||
for(id in ronin.modules){
|
||||
if(this.input.value != ronin.modules[id].name.substr(0,this.input.value.length)){ continue; }
|
||||
html += "<span class='module'>"+ronin.modules[id].name+"</span> ";
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(id in ronin.modules){
|
||||
html += "<span class='module'>"+ronin.modules[id].name+"</span> ";
|
||||
}
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
this.log = function(log)
|
||||
{
|
||||
this.logs_element.innerHTML = "";
|
||||
@ -101,6 +83,15 @@ function Terminal(rune)
|
||||
{
|
||||
return new Command(this.input.value);
|
||||
}
|
||||
|
||||
this.load = function(cmd,preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
ronin.load(cmd.values());
|
||||
|
||||
return "Loading "+cmd.values();
|
||||
}
|
||||
}
|
||||
|
||||
// Log
|
||||
|
7
scripts/units/option.js
Normal file
7
scripts/units/option.js
Normal file
@ -0,0 +1,7 @@
|
||||
function Option(name)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.name = name.split("=")[0];
|
||||
this.value = name.split("=")[1];
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user