Skip to content

Commit

Permalink
Merge pull request #272 from evil-mad/upgrades
Browse files Browse the repository at this point in the history
Electron Upgrades
  • Loading branch information
techninja authored Jul 24, 2016
2 parents ea9adbd + 93927f2 commit d77315e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 152 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "techninja",
"stage": "development",
"license": "MIT",
"electronVersion": "0.37.5",
"electronVersion": "1.0.2",
"scripts": {
"start": "electron ."
},
Expand Down Expand Up @@ -34,6 +34,6 @@
"url": "https://github.com/evil-mad/robopaint.git"
},
"devDependencies": {
"electron-prebuilt": "0.37.5"
"electron-prebuilt": "1.0.2"
}
}
4 changes: 2 additions & 2 deletions resources/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ $.qtip = require('qtip2');
window.i18n = require('i18next-client');

// Include global main node process connector objects.
var remote = require('remote');
var remote = require('electron').remote;
var mainWindow = remote.getCurrentWindow();
var app = remote.require('app');
var app = remote.app;
var path = require('path');
var bytes = require('bytes');
var appPath = path.join(app.getAppPath(), '/');
Expand Down
83 changes: 49 additions & 34 deletions resources/mode.preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

try {

var remote = require('remote');
var remote = require('electron').remote;
var path = require('path');
var app = window.app = remote.require('app');
var app = window.app = remote.app;
var fs = require('fs-plus');
var ipc = window.ipc = require('electron').ipcRenderer;
var appPath = app.getAppPath();
Expand All @@ -42,6 +42,13 @@ var modePath = path.parse(decodeURIComponent(location.hash.substr(1)));
var mode = window.mode = require(path.join(modePath.dir, 'package.json'));
mode.path = modePath;

// Load jQuery early if the mode asks for it.
if (mode.robopaint.dependencies) {
if (mode.robopaint.dependencies.includes('jquery-early')) {
window.$ = window.jQuery = $;
}
}

// Load the central RP settings
var robopaint = window.robopaint = {
utils: rpRequire('utils'),
Expand Down Expand Up @@ -105,10 +112,12 @@ robopaint.pauseTillEmpty = function(starting) {
};

// Add the generic mode CSS for body drop shadow and basic button formatting.
$('<link>').attr({
href: robopaint.appPath + "resources/styles/modes.css",
rel: "stylesheet"
}).appendTo('head');
$(function(){
$('<link>').attr({
href: robopaint.appPath + "resources/styles/modes.css",
rel: "stylesheet"
}).appendTo('head');
});

// Define the local settings getters/setters
mode.settings = {
Expand Down Expand Up @@ -172,28 +181,31 @@ mode.settings.load();

// Manage loading roboPaintDependencies from mode package config
if (mode.robopaint.dependencies) {
_.each(mode.robopaint.dependencies, function(modName){
switch (modName) {
case 'jquery':
window.$ = window.jQuery = $;
break;
case 'underscore':
window._ = _;
break;
case 'qtip':
$.qtip = require('qtip2');
break;
case 'paper':
console.log('Loading Paper');
preloadCompleteAsyncChecklist.paperLoaded = false;
rpRequire('paper', function(){
preloadCompleteAsyncChecklist.paperLoaded = true;
preloadComplete();
});
break;
default:
rpRequire(modName);
}
$(function(){
_.each(mode.robopaint.dependencies, function(modName){
switch (modName) {
case 'jquery-early':
case 'jquery':
window.$ = window.jQuery = $;
break;
case 'underscore':
window._ = _;
break;
case 'qtip':
$.qtip = require('qtip2');
break;
case 'paper':
console.log('Loading Paper');
preloadCompleteAsyncChecklist.paperLoaded = false;
rpRequire('paper', function(){
preloadCompleteAsyncChecklist.paperLoaded = true;
preloadComplete();
});
break;
default:
rpRequire(modName);
}
});
});
}

Expand Down Expand Up @@ -392,12 +404,14 @@ function handleCNCServerMessages(name, data) {

// Load in the modes custom main JS
var mainHasLoaded = false;
rpRequire({
path: path.join(mode.path.dir, mode.main),
type: 'dom'
}, function(){
preloadCompleteAsyncChecklist.mainLoaded = true;
preloadComplete();
$(function(){
rpRequire({
path: path.join(mode.path.dir, mode.main),
type: 'dom'
}, function(){
preloadCompleteAsyncChecklist.mainLoaded = true;
preloadComplete();
});
});

function preloadComplete() {
Expand All @@ -419,6 +433,7 @@ function preloadComplete() {

} catch(e) {
console.error('Problem during mode load:' , e);
console.trace();
if (mode.robopaint.debug === true){
ipc.sendToHost('modeReady'); // Tell RP main host to show the window anyway.
} else {
Expand Down
3 changes: 1 addition & 2 deletions resources/rp_modules/robopaint.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,7 @@ var utils = {
* Full path to the svg-cache folder in the user data directory.
*/
getSVGCachePath: function () {
var remote = require('remote');
var app = remote.require('app');
var app = require('electron').remote.app;
return require('path').join(app.getPath('userData'), 'svg-cache');
},

Expand Down
3 changes: 1 addition & 2 deletions resources/rp_modules/rp.require.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* various named shortcut robopaint specific CommonJS modules listed below.
*/

var remote = require('remote');
var app = remote.require('app');
var app = require('electron').remote.app;
var appPath = app.getAppPath();
var _ = require('underscore');

Expand Down
7 changes: 4 additions & 3 deletions resources/scripts/root/window-main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var app = require('app'); // Module to control application life.
var app = require('electron').app; // Module to control application life.
var path = require('path');
var BrowserWindow = require('browser-window'); // Module to create native browser window.
var dialog = require('dialog');
// Module to create native browser window.
var BrowserWindow = require('electron').BrowserWindow;
var dialog = require('electron').dialog;

// Report crashes to our server.
//require('crash-reporter').start();
Expand Down
107 changes: 0 additions & 107 deletions resources/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -618,33 +618,6 @@ body.home #modalmask:before {
transform: translateZ(0) translateX(-50%) translateY(-50%);
}

@-webkit-keyframes load4 {
0%,
100% {
box-shadow: 0 -3em 0 0.2em #ffffff, 2em -2em 0 0em #ffffff, 3em 0 0 -1em #ffffff, 2em 2em 0 -1em #ffffff, 0 3em 0 -1em #ffffff, -2em 2em 0 -1em #ffffff, -3em 0 0 -1em #ffffff, -2em -2em 0 0 #ffffff;
}
12.5% {
box-shadow: 0 -3em 0 0 #ffffff, 2em -2em 0 0.2em #ffffff, 3em 0 0 0 #ffffff, 2em 2em 0 -1em #ffffff, 0 3em 0 -1em #ffffff, -2em 2em 0 -1em #ffffff, -3em 0 0 -1em #ffffff, -2em -2em 0 -1em #ffffff;
}
25% {
box-shadow: 0 -3em 0 -0.5em #ffffff, 2em -2em 0 0 #ffffff, 3em 0 0 0.2em #ffffff, 2em 2em 0 0 #ffffff, 0 3em 0 -1em #ffffff, -2em 2em 0 -1em #ffffff, -3em 0 0 -1em #ffffff, -2em -2em 0 -1em #ffffff;
}
37.5% {
box-shadow: 0 -3em 0 -1em #ffffff, 2em -2em 0 -1em #ffffff, 3em 0em 0 0 #ffffff, 2em 2em 0 0.2em #ffffff, 0 3em 0 0em #ffffff, -2em 2em 0 -1em #ffffff, -3em 0em 0 -1em #ffffff, -2em -2em 0 -1em #ffffff;
}
50% {
box-shadow: 0 -3em 0 -1em #ffffff, 2em -2em 0 -1em #ffffff, 3em 0 0 -1em #ffffff, 2em 2em 0 0em #ffffff, 0 3em 0 0.2em #ffffff, -2em 2em 0 0 #ffffff, -3em 0em 0 -1em #ffffff, -2em -2em 0 -1em #ffffff;
}
62.5% {
box-shadow: 0 -3em 0 -1em #ffffff, 2em -2em 0 -1em #ffffff, 3em 0 0 -1em #ffffff, 2em 2em 0 -1em #ffffff, 0 3em 0 0 #ffffff, -2em 2em 0 0.2em #ffffff, -3em 0 0 0 #ffffff, -2em -2em 0 -1em #ffffff;
}
75% {
box-shadow: 0em -3em 0 -1em #ffffff, 2em -2em 0 -1em #ffffff, 3em 0em 0 -1em #ffffff, 2em 2em 0 -1em #ffffff, 0 3em 0 -1em #ffffff, -2em 2em 0 0 #ffffff, -3em 0em 0 0.2em #ffffff, -2em -2em 0 0 #ffffff;
}
87.5% {
box-shadow: 0em -3em 0 0 #ffffff, 2em -2em 0 -1em #ffffff, 3em 0 0 -1em #ffffff, 2em 2em 0 -1em #ffffff, 0 3em 0 -1em #ffffff, -2em 2em 0 0 #ffffff, -3em 0em 0 0 #ffffff, -2em -2em 0 0.2em #ffffff;
}
}
@keyframes load4 {
0%,
100% {
Expand Down Expand Up @@ -693,86 +666,6 @@ body.home #remoteprint-mask:before {
opacity: 0.8;
}

/* Remote Paint/Print Window */
#remoteprint-window {
border-radius: 7em;
padding: 4em;
overflow: hidden;
z-index: 15;
position: absolute;
top: 10%;
bottom: 10%;
left: 10%;
right: 10%;
text-align: center;
background-color: rgb(223, 147, 233);
}

#remoteprint-window h3 {
margin-bottom: 1.3em;
font-size: 2.3em;
margin-top: -1.5em;
}

#remoteprint-window div.icons {
font-size: 6em;
margin-top: -49px;
}

#remoteprint-window div.icons span {
margin: -30px;
text-indent: 22px;
}

#remoteprint-window button {
margin: 1em;
}

/* Remote Paint/Print Preview and Auto scale container */
#remoteprint-window #preview-scale-container {
width: 2304px;
height: 864px;
left: 3em;
position: absolute;
-webkit-transform-origin: top left;
}

#remoteprint-window svg#preview {
background-color: white;
left: 0; /* Wacky requirements for double scaling container */
position: absolute;
}

#remoteprint-window #details {
-webkit-transform: scale(3.4);
-webkit-transform-origin: top left;
position: absolute;
left: 1210px;
width: 333px;
}

#remoteprint-window #details #statusmessage {
font-size: 19px;
}

#remoteprint-window #details legend {
text-align: left;
font-weight: bold;
}

#remoteprint-window #details button.cancel {
background: linear-gradient(to bottom, #C73030, #851C1C);
padding: 7px 10px;
}

#remoteprint-window #details button.cancel:hover {
background: linear-gradient(to bottom, #EC6D6D, #DD0000);
}

#remoteprint-window #details progress {
width: 100%;
}

/* qTip extra styles */
.qtip {
border-radius: 10px !important;
Expand Down

0 comments on commit d77315e

Please sign in to comment.