Skip to content

Commit eaa3d83

Browse files
author
Matt Karl
committed
Preview can now be opened remotely
1 parent 330baf3 commit eaa3d83

File tree

13 files changed

+187
-57
lines changed

13 files changed

+187
-57
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.11",
3+
"version": "0.2.12",
44
"private": true,
55
"dependencies": {
66
"jqueryui": "*",

deploy/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "SpringRollStudio",
33
"description": "Application for SpringRoll projects",
4-
"version": "0.2.11",
4+
"version": "0.2.12",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/SpringRoll/SpringRollStudio"
@@ -29,6 +29,7 @@
2929
"fs-extra": "~0.12.0",
3030
"glob": "~4.0.6",
3131
"grunt-cli": "^0.1.13",
32+
"ip": "^0.3.3",
3233
"lodash": "^3.7.0",
3334
"node-watch": "~0.3.4",
3435
"replace": "~0.3.0",

installer/win32.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# These three must be integers
55
!define VERSIONMAJOR 0
66
!define VERSIONMINOR 2
7-
!define VERSIONBUILD 11
7+
!define VERSIONBUILD 12
88
# These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
99
# It is possible to use "mailto:" links in here to open the email client
1010
!define HELPURL "https://github.com/SpringRoll/SpringRollStudio/issues"

installer/win64.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# These three must be integers
55
!define VERSIONMAJOR 0
66
!define VERSIONMINOR 2
7-
!define VERSIONBUILD 11
7+
!define VERSIONBUILD 12
88
# These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
99
# It is possible to use "mailto:" links in here to open the email client
1010
!define HELPURL "https://github.com/SpringRoll/SpringRollStudio/issues"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "SpringRollStudio",
33
"private": true,
4-
"version": "0.2.11",
4+
"version": "0.2.12",
55
"dependencies": {
66
"grunt": "^0.4.5",
77
"grunt-appdmg": "^0.3.1",

project.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.11",
3+
"version": "0.2.12",
44
"main": [
55
"components/node-webkit-app/src/utils/UpdateChecker.js",
66
"components/node-webkit-app/src/utils/Browser.js",
@@ -91,9 +91,15 @@
9191
"src/less/new/NewProject.less"
9292
],
9393
"preview": [
94+
"src/js/preview/PreviewServer.js",
9495
"src/js/preview/PreviewContainer.js",
9596
"src/js/preview/Preview.js",
9697
"src/less/preview/Preview.less"
98+
],
99+
"preview-client": [
100+
"src/js/preview/PreviewContainer.js",
101+
"src/js/preview/PreviewClient.js",
102+
"src/less/preview/Preview.less"
97103
]
98104
}
99105
}

src/jade/preview.jade renamed to src/jade/preview-client.jade

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ html
44
meta(charset='utf-8')
55
title Preview
66
include partials/libraries
7-
include partials/shared
8-
link(href='assets/css/preview.css', rel='stylesheet')
9-
script(src='assets/js/preview.js')
7+
8+
block head
9+
10+
link(href='assets/css/shared.css', rel='stylesheet')
11+
link(href='assets/css/preview.css', rel='stylesheet')
12+
script(src='assets/js/preview-client.js')
13+
meta(name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0")
1014
body
1115
#frame.loading.show-title.show-controls
1216
#pausedScreen
@@ -16,7 +20,7 @@ html
1620
span.icon.icon-play
1721
| Resume
1822
#appTitle Loading...
19-
.controls
23+
.controls.text-right
2024
button#helpButton.btn.btn-primary.main.disabled(data-toggle='tooltip', title='Play Help')
2125
span.icon.icon-help
2226
button#soundButton.btn.btn-primary.main.muted.disabled(data-toggle='tooltip', title='Toggle All Sounds')
@@ -139,9 +143,8 @@ html
139143
button#pauseButton.btn.btn-primary.main.unpaused.disabled(data-toggle='tooltip', title='Play/Pause')
140144
span.icon.icon-pause.on
141145
span.icon.icon-play.off
142-
button#refreshButton.btn.btn-primary.main(data-toggle='tooltip', title='Reload')
143-
span.glyphicon.glyphicon-refresh
144-
button#devToolsButton.btn.btn-primary.main(data-toggle='tooltip', title='Toggle Console')
145-
span.glyphicon.glyphicon-list
146+
147+
block controls
148+
146149
.appWrapper
147150
iframe#appContainer(frameborder='0', scrolling='no')

src/js/preview/Preview.js

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
(function(){
2-
3-
if (APP)
4-
{
5-
var connect = require('connect');
6-
var serveStatic = require('serve-static');
7-
var path = require('path');
8-
}
9-
1+
(function()
2+
{
103
// Import classes
114
var Module = springroll.Module,
12-
PreviewContainer = springroll.PreviewContainer;
13-
14-
// The local port to use for the preview server
15-
var SERVER_PORT = 3030;
5+
PreviewContainer = springroll.PreviewContainer,
6+
Server = springroll.PreviewServer;
167

178
/**
189
* Preview the current project
@@ -24,50 +15,33 @@
2415
Module.call(this);
2516

2617
/**
27-
* The web server
28-
* @property {Server} server
18+
* The web server for project view
19+
* @property {springroll.PreviewServer} server
2920
*/
30-
this.server = null;
21+
this.server = new Server(localStorage.getItem('project'));
3122

3223
/**
3324
* The local location for the iframe
3425
* @property {string} location
3526
*/
36-
this.location = "http://localhost:" + SERVER_PORT;
27+
this.location = "http://localhost:" + this.server.port + '/game';
3728

3829
/**
3930
* The current iframe
4031
* @property {jquery} iframe
4132
*/
4233
this.container = new PreviewContainer();
4334

44-
// Grab the opened project
45-
this.project = localStorage.getItem('project');
46-
4735
$("#refreshButton").click(this.refresh.bind(this));
4836
$("#devToolsButton").click(this.toggleDevTools.bind(this));
49-
50-
// Disable the form submitting
51-
$('form').submit(function(e)
52-
{
53-
return false;
54-
});
5537

5638
if (APP)
5739
{
58-
var app = connect();
59-
this.server = app.listen(SERVER_PORT);
60-
app.use(serveStatic(
61-
path.join(this.project, 'deploy'),
62-
{'index': ['index.html']}
63-
));
64-
6540
// Initialize the menu
6641
this.initMenubar(false, true);
6742
}
68-
69-
// When the app closes re-open it
70-
this.open();
43+
44+
this.open();
7145
};
7246

7347
// Reference to the prototype
@@ -91,11 +65,12 @@
9165
if (APP)
9266
{
9367
// Set the project title and
94-
this.container.appTitle.text(path.basename(this.project));
95-
this.container.remoteChannel.val(path.basename(this.project));
68+
this.container.appTitle.text(this.server.title);
69+
this.container.remoteChannel.val(this.server.title);
9670
this.container.connectLoggingService();
9771
}
9872

73+
console.log("Open location " + this.location);
9974
this.container.open(this.location);
10075
this.container.once('closed', this.open.bind(this));
10176
};
@@ -125,14 +100,20 @@
125100
p.shutdown = function()
126101
{
127102
this.container = null;
128-
this.project = null;
129103

130104
if (this.server)
131105
{
132-
this.server.close();
133-
this.server = null;
106+
this.server.destroy(function()
107+
{
108+
this.server = null;
109+
this.close(true);
110+
}
111+
.bind(this));
112+
}
113+
else
114+
{
115+
this.close(true);
134116
}
135-
this.close(true);
136117
};
137118

138119
// Create the module

src/js/preview/PreviewClient.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$(function()
2+
{
3+
// Get the server info like the path etc
4+
$.getJSON('/title', function(title)
5+
{
6+
var container = new springroll.PreviewContainer();
7+
container.appTitle.text(title);
8+
container.remoteChannel.val(title);
9+
container.connectLoggingService();
10+
container.open('/game');
11+
});
12+
13+
});

src/js/preview/PreviewContainer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
pauseButton: "#pauseButton, #resumeButton"
2424
});
2525

26+
// Disable the form submitting
27+
$('form').submit(function(e)
28+
{
29+
return false;
30+
});
31+
2632
/**
2733
* The entire game view including the standard game buttons
2834
* @property {jquery} frame

0 commit comments

Comments
 (0)