diff --git a/main.js b/main.js index 2b47d9a..c869ae3 100644 --- a/main.js +++ b/main.js @@ -56,7 +56,7 @@ app.on('ready', () => is_shown = true; }) // Open the DevTools. - // win.webContents.openDevTools() + win.webContents.openDevTools() }) app.on('window-all-closed', () => diff --git a/sources/index.html b/sources/index.html index cfd93c1..4d89bad 100644 --- a/sources/index.html +++ b/sources/index.html @@ -1,6 +1,7 @@
+ diff --git a/sources/links/main.css b/sources/links/main.css index 06f2c30..f479b67 100644 --- a/sources/links/main.css +++ b/sources/links/main.css @@ -16,4 +16,5 @@ yu { display:block; } #commander { z-index: 9000 } #commander input { background: transparent;width: calc(100vw - 30px);display: block;line-height: 40px;font-size: 11px;color: white; margin-left:20px; } #hint { background:black; color:#666; padding-left:20px;} -#hint b { font-family: 'input_mono_regular' } \ No newline at end of file +#hint b { font-family: 'input_mono_regular'; color:#999;} +#hint i { font-style: italic; } \ No newline at end of file diff --git a/sources/scripts/core/commander.js b/sources/scripts/core/commander.js index 36a41ee..0156e5e 100644 --- a/sources/scripts/core/commander.js +++ b/sources/scripts/core/commander.js @@ -30,7 +30,7 @@ function Commander() for(method_id in q.methods){ var method_param = q.methods[method_id]; if(!ronin.modules[q.module].methods[method_id]){ console.log("Missing method",method_id); return; } - ronin.modules[q.module].methods[method_id](method_param); + ronin.modules[q.module].methods[method_id].run(method_param); } ronin.commander.input_el.value = ""; diff --git a/sources/scripts/core/hint.js b/sources/scripts/core/hint.js index 9227d5f..80ac373 100644 --- a/sources/scripts/core/hint.js +++ b/sources/scripts/core/hint.js @@ -19,10 +19,14 @@ function Hint() } var target_module = ronin.commander.query().module; + var target_method = Object.keys(ronin.commander.query().methods).length > 0 ? Object.keys(ronin.commander.query().methods)[0] : null if(ronin.commander.input_el.value == ""){ this.el.innerHTML = html; } + else if(ronin.modules[target_module] && ronin.modules[target_module].methods[target_method]){ + this.el.innerHTML = this.pad(ronin.commander.input_el.value)+ronin.modules[target_module].methods[target_method].docs(); + } else if(ronin.modules[target_module]){ this.el.innerHTML = this.pad(ronin.commander.input_el.value)+ronin.modules[target_module].hint(); } diff --git a/sources/scripts/core/method.js b/sources/scripts/core/method.js new file mode 100644 index 0000000..e2598a6 --- /dev/null +++ b/sources/scripts/core/method.js @@ -0,0 +1,18 @@ +function Method(name,params,info = "Missing documentation") +{ + this.name = name; + this.params = params; + this.info = info; + + this.run = null; + + this.hint = function() + { + return ""+this.name+":"+this.params+" "; + } + + this.docs = function() + { + return "["+this.params+"] "+this.info+""; + } +} \ No newline at end of file diff --git a/sources/scripts/core/module.js b/sources/scripts/core/module.js index e088c4b..3a351ee 100644 --- a/sources/scripts/core/module.js +++ b/sources/scripts/core/module.js @@ -13,7 +13,7 @@ function Module(name,docs = "Missing documentation.") for(id in this.methods){ var v = this.methods[id]; - html += id+": "; + html += v.hint(); } for(setting_id in this.settings){ @@ -26,6 +26,6 @@ function Module(name,docs = "Missing documentation.") html += route_id+"->"+route_val+" "; } - return html.trim() != "" ? ""+this.name+" "+html.trim() : ""; + return html.trim() != "" ? " "+html.trim() : ""; } } \ No newline at end of file diff --git a/sources/scripts/modules/frame.js b/sources/scripts/modules/frame.js index 8c68efe..313912a 100644 --- a/sources/scripts/modules/frame.js +++ b/sources/scripts/modules/frame.js @@ -6,7 +6,9 @@ function Frame() this.methods = {}; - this.methods.resize = function(q) + this.methods.resize = new Method("resize","WxH"); + + this.methods.resize.run = function(q) { var data = ronin.render.select(0,0,ronin.frame.settings.width,ronin.frame.settings.height); @@ -15,7 +17,9 @@ function Frame() ronin.render.context().putImageData(data, 0, 0); } - this.methods.rescale = function(p) + this.methods.rescale = new Method("rescale","X,Y|WxH"); + + this.methods.rescale.run = function(p) { // Create a canvas copy var copy_canvas = document.createElement("canvas"); @@ -32,7 +36,8 @@ function Frame() ronin.render.context().drawImage(copy_ctx.canvas,0,0,new_size.width * 2,new_size.height * 2); } - this.methods.crop = function(p) + this.methods.crop = new Method("crop","X,Y|WxH"); + this.methods.crop.run = function(p) { var data = ronin.render.select(p.x,p.y,p.width,p.height); @@ -41,12 +46,14 @@ function Frame() ronin.render.context().putImageData(data, 0, 0); } - this.methods.clear = function(q) + this.methods.clear = new Method("clear","X,Y|WxH"); + this.methods.clear.run = function(q) { ronin.render.fill("blue"); } - this.methods.fill = function(q) + this.methods.fill = new Method("fill","X,Y|WxH"); + this.methods.fill.run = function(q) { ronin.render.fill(q); } diff --git a/sources/scripts/modules/io.js b/sources/scripts/modules/io.js index d3be174..344f97e 100644 --- a/sources/scripts/modules/io.js +++ b/sources/scripts/modules/io.js @@ -5,28 +5,12 @@ function IO() this.settings = {anchor:{x:0,y:0,width:200,height:200}}; this.methods = {}; - - this.methods.import = function(q) - { - var filepath = dialog.showOpenDialog({properties: ['openFile']}); - - if(!filepath){ console.log("Nothing to load"); return; } - - fs.readFile(filepath[0], 'utf-8', (err, data) => { - if(err){ alert("An error ocurred reading the file :" + err.message); return; } - - var img = new Image(); - img.src = filepath[0]; - - img.onload = function() { - ronin.io.draw_image(ronin.render.context(),img,ronin.commander.query()); - } - }); - } - + this.image = null; - this.methods.load = function(q) + this.methods.load = new Method("load","browser","Press enter to open the file browser."); + + this.methods.load.run = function(q) { var filepath = dialog.showOpenDialog({properties: ['openFile']}); @@ -34,10 +18,8 @@ function IO() fs.readFile(filepath[0], 'utf-8', (err, data) => { if(err){ alert("An error ocurred reading the file :" + err.message); return; } - var img = new Image(); img.src = filepath[0]; - img.onload = function() { ronin.io.image = img; ronin.commander.inject("io draw:20,20|100x100"); @@ -45,14 +27,20 @@ function IO() }); } - this.methods.draw = function(q) + this.methods.draw = new Method("draw","X,Y|WxH","Draw the loaded image pixels."); + + this.methods.draw.run = function(q) { + if(!ronin.io.image){ return; } + ronin.io.draw_image(ronin.render.context(),ronin.io.image,ronin.commander.query().methods.draw); ronin.io.image = null; ronin.preview.clear(); } - this.methods.save = function(q) + this.methods.save = new Method("save","name"); + + this.methods.save.run = function(q) { // TODO ronin.io.render(); @@ -130,13 +118,10 @@ function IO() this.draw_image = function(ctx = ronin.preview.context(),img,params) { - var anchor = params ? params : ronin.io.settings.anchor; - - console.log("draw",ctx) var width = parseInt(img.naturalWidth * 0.5); var height = parseInt(img.naturalHeight * 0.5); - var scale = (anchor.width/width) * 2; + var scale = (params.width/width) * 2; - ctx.drawImage(img, anchor.x * 2,anchor.y * 2,width * scale,height * scale); + ctx.drawImage(img, params.x * 2,params.y * 2,width * scale,height * scale); } } \ No newline at end of file diff --git a/sources/scripts/modules/path.js b/sources/scripts/modules/path.js index 3bb844e..d18bb4a 100644 --- a/sources/scripts/modules/path.js +++ b/sources/scripts/modules/path.js @@ -3,8 +3,9 @@ function Path() Module.call(this,"path","Trace lines and to draw shapes."); this.settings = {thickness:30,color:"black",cap:"square"}; - - this.methods.stroke = function(q) + + this.methods.stroke = new Method("stroke","x,y&"); + this.methods.stroke.run = function(q) { ronin.preview.clear(); @@ -20,7 +21,8 @@ function Path() ctx.closePath(); } - this.methods.fill = function(q) + this.methods.fill = new Method("fill","x,y&"); + this.methods.fill.run = function(q) { ronin.preview.clear();