Skip to content

Commit

Permalink
Merge pull request play-co#24 from gameclosure/fix-splash
Browse files Browse the repository at this point in the history
Fix splash
  • Loading branch information
mikehenrty committed Feb 23, 2013
2 parents 2051cbd + ad07fd0 commit e98eeb4
Show file tree
Hide file tree
Showing 43 changed files with 226 additions and 65 deletions.
2 changes: 1 addition & 1 deletion lib/gcapi
Submodule gcapi updated from c52ea7 to a60d0c
2 changes: 1 addition & 1 deletion lib/timestep
2 changes: 1 addition & 1 deletion projects/whack-that-mole
72 changes: 57 additions & 15 deletions src/build/packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var CONFIG_GLOBAL_TEMPLATE = {
servicesURL: null, // String
noRedirect: false, // boolean
inviteURLTemplate: null, // String
preload: {} // Map<String, String>
splash: {} // Map<String, String>
};

// Return a JSON object for the global CONFIG object.
Expand Down Expand Up @@ -149,8 +149,8 @@ function getConfigObject (project, opts, target) {

logger.log("Using services URL " + config.servicesURL);

if (manifest.preload != null) {
config.preload = JSON.parse(JSON.stringify(manifest.preload));
if (manifest.splash != null) {
config.splash = JSON.parse(JSON.stringify(manifest.splash));
}

var urlOpts = {
Expand Down Expand Up @@ -295,7 +295,6 @@ function useURISlashes (str) { return str.replace(regexSlash, '/'); }
// The spriter sprites images, but also returns a list of resources. It is a
// tool of many faces.
function getResources(manifest, target, appDir, output, cb) {

// object on success to pass to cb(err, res);
var result = {};

Expand Down Expand Up @@ -339,7 +338,23 @@ function getResources(manifest, target, appDir, output, cb) {
};
});

var filteredPaths = [];

result.resources = resources.other.map(function (filename) {
if (path.basename(filename) === "metadata.json") {
try {
var filedata = fs.readFileSync(path.resolve(appDir, filename), 'utf8');
var fileobj = JSON.parse(filedata);
if (fileobj.package === false) {
var filterPath = path.dirname(filename);
logger.log("Not packaging resources from", filterPath);
filteredPaths.push(filterPath);
}
} catch (ex) {
logger.error("WARNING:", filename, "format is not valid JSON so cannot parse it.");
}
}

var ext = path.extname(filename);
return {
basename: path.basename(filename, ext),
Expand All @@ -349,6 +364,26 @@ function getResources(manifest, target, appDir, output, cb) {
};
});

// remove paths that have metadata package:false
for (var ii = 0; ii < result.resources.length; ++ii) {
var filespec = result.resources[ii];
var filename = filespec.relative;

if (path.basename(filename) === "metadata.json") {
logger.log("Did not package the metadata file", filename);
result.resources.splice(ii--, 1);
continue;
}

for (var fp in filteredPaths) {
if (filename.indexOf(filteredPaths[fp]) === 0) {
logger.log("Did not package resource", filename);
result.resources.splice(ii--, 1);
continue;
}
}
}

var mapPath = path.resolve(fullSpriteDir, resources.map);
f(mapPath);
fs.readFile(mapPath, 'utf8', f());
Expand Down Expand Up @@ -390,33 +425,40 @@ function getResources(manifest, target, appDir, output, cb) {
});
}

function writeMetadata(opts, dir, json) {
var fontsDir = path.join(opts.fullPath, dir);
var fontsMetadata = path.join(fontsDir, "metadata.json");
if (fs.existsSync(fontsDir) && fs.lstatSync(fontsDir).isDirectory() && !fs.existsSync(fontsMetadata)) {
fs.writeFileSync(fontsMetadata, json);
}
}

// Compile resources together and pass a cache object to the next function.
// runs the spriter and compiles the build code.
function compileResources (project, opts, target, initialImport, cb) {
logger.log("Packaging resources...");

// Font sheets cannot be sprited; add a metadata.json file for fonts (for compatibility)
var fontsDir = path.join(opts.fullPath, "resources/fonts");
var fontsMetadata = path.join(fontsDir, "metadata.json");
if (fs.existsSync(fontsDir) && fs.lstatSync(fontsDir).isDirectory() && !fs.existsSync(fontsMetadata)) {
fs.writeFileSync(fontsMetadata, JSON.stringify({"sprite": false}));
}
writeMetadata(opts, "resources/fonts", '{"sprite": false}');
writeMetadata(opts, "resources/icons", '{"sprite": false, "package": false}');
writeMetadata(opts, "resources/splash", '{"sprite": false, "package": false}');

var f = ff(function () {
getResources(project.manifest, target, opts.fullPath, opts.localBuildPath, f());
packageJS(opts, initialImport, false, f());
}, function (files, jsSrc) {
logger.log("finished packaging resources");
logger.log("Finished packaging resources");

// merge results into a single object
f({
files: files,
jsSrc: jsSrc
})
})
.cb(cb)
.error(function (e) {
logger.error("unexpected error when packaging resources");
console.error(e);
});
.cb(cb)
.error(function (e) {
logger.error("ERROR: While packaging resources:", e);
});
};

/**
Expand Down
61 changes: 30 additions & 31 deletions src/init/templates/empty/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,42 @@
"supportedOrientations": [
"landscape"
],
"icons": {
"28": "preload/icons/icon28.png",
"38": "preload/icons/icon38.png",
"48": "preload/icons/icon48.png",
"56": "preload/icons/icon56.png",
"57": "preload/icons/icon57.png",
"72": "preload/icons/icon72.png",
"114": "preload/icons/icon114.png",
"144": "preload/icons/icon144.png",
"512": "preload/icons/icon512.png"
},
"preload": {
"icon": "resources/icons/icon512.png",
"splash": {
"autoHide": true,
"img": "preload/splash.png",
"iphone": {
"launch": "preload/iphone/Default.png",
"launchRetina": "preload/iphone/[email protected]",
"launchRetina4": "preload/iphone/[email protected]"
},
"ipad": {
"portrait": "preload/ipad/Default-Portrait~ipad.png",
"portraitRetina": "preload/ipad/Default-Portrait@2x~ipad.png",
"landscape": "preload/ipad/Default-Landscape~ipad.png",
"landscapeRetina": "preload/ipad/Default-Landscape@2x~ipad.png"
"scaleMethod": "cover",
"portrait480": "resources/splash/portrait480.png",
"portrait960": "resources/splash/portrait960.png",
"portrait1024": "resources/splash/portrait1024.png",
"portrait1136": "resources/splash/portrait1136.png",
"portrait2048": "resources/splash/portrait2048.png",
"landscape768": "resources/splash/landscape768.png",
"landscape1536": "resources/splash/landscape1536.png"
},
"android": {
"versionCode": 1,
"icons": {
"36": "resources/icons/android36.png",
"48": "resources/icons/android48.png",
"72": "resources/icons/android72.png",
"96": "resources/icons/android96.png"
}
},
"ios": {
"bundleID": "example.bundle",
"appleID": "12345678",
"version": "1.0.0",
"icons": {
"renderGloss": true,
"57": "resources/icons/ios57.png",
"72": "resources/icons/ios72.png",
"114": "resources/icons/ios114.png",
"144": "resources/icons/ios144.png"
}
},
"studio": {
"name": "Example Studio Name",
"domain": "studio.example.com",
"stagingDomain": "staging.example.com"
},
"android": {
"versionCode": 1
},
"ios": {
"bundleID": "example.bundle",
"appleID": "1234567",
"version": "1.0.0"
}
}
Binary file removed src/init/templates/empty/preload/icons/icon114.png
Binary file not shown.
Binary file removed src/init/templates/empty/preload/icons/icon144.png
Binary file not shown.
Binary file removed src/init/templates/empty/preload/icons/icon28.png
Binary file not shown.
Binary file removed src/init/templates/empty/preload/icons/icon38.png
Binary file not shown.
Binary file removed src/init/templates/empty/preload/icons/icon48.png
Binary file not shown.
Binary file removed src/init/templates/empty/preload/icons/icon56.png
Binary file not shown.
Binary file removed src/init/templates/empty/preload/icons/icon57.png
Binary file not shown.
Binary file removed src/init/templates/empty/preload/icons/icon72.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed src/init/templates/empty/preload/iphone/Default.png
Binary file not shown.
Binary file not shown.
Binary file removed src/init/templates/empty/preload/splash.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions src/init/templates/empty/resources/splash/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Your game must incorporate the Game Closure logo provided in the GC DevKit
(or another logo expressly made available to you by Game Closure) (“Logo”)
in the following manner:

+ The Logo must be unmodified.

+ The Logo must conform to any instructions or directives provided with the
splash screen source, including but not limited to directives on the duration
of exposure, timing of exposure, pixel density, aspect ratio, and overall
quality of presentation.

+ Unless otherwise specified, the Logo must be displayed for 3 seconds at full
resolution and maximum quality allowed by the phone.

+ The Logo must not be stretched or skewed, but the background content may be
truncated in the case that the Logo does not exactly fit the aspect ratio of
the physical device.

+ The Logo must be shown before any menu is displayed or user input is received
and processed by the game.


Subject to the terms of conditions of this Agreement and any guidelines that
may be provided or updated by Game Closure from time to time, Game Closure
hereby grants you a non-exclusive, revocable, worldwide, non-sublicesable,
nontransferable right to use the Logo solely in accordance with the foregoing
guidelines.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 39 additions & 6 deletions src/init/templates/stackview/manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,46 @@
{
"title": "StackView Template",
"icons": {
"128": "resources/images/icon.png"
"appID": "stackviewtemplate",
"shortName": "stackview",
"title": "Stack View Template",
"studio": {
"name": "Lil' Varmit Studios",
"domain": "lilvarmit.com",
"stagingDomain": "staging.lilvarmit.com"
},
"supportedOrientations": [
"portrait"
],
"preload": {
"icon": "resources/icons/icon512.png",
"splash": {
"autoHide": true,
"img": "resources/images/splash.png"
}
"scaleMethod": "cover",
"portrait480": "resources/splash/portrait480.png",
"portrait960": "resources/splash/portrait960.png",
"portrait1024": "resources/splash/portrait1024.png",
"portrait1136": "resources/splash/portrait1136.png",
"portrait2048": "resources/splash/portrait2048.png",
"landscape768": "resources/splash/landscape768.png",
"landscape1536": "resources/splash/landscape1536.png"
},
"android": {
"versionCode": 1,
"icons": {
"36": "resources/icons/android36.png",
"48": "resources/icons/android48.png",
"72": "resources/icons/android72.png",
"96": "resources/icons/android96.png"
}
},
"ios": {
"bundleID": "whackamole",
"appleID": "123456789",
"version": "1.0.0",
"icons": {
"57": "resources/icons/ios57.png",
"72": "resources/icons/ios72.png",
"114": "resources/icons/ios114.png",
"144": "resources/icons/ios144.png",
"renderGloss": true
}
},
}
2 changes: 1 addition & 1 deletion src/serve/plugins/projects/static/Pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var ProjectCell = Class(squill.Cell, function() {
var defaultIcon = '/images/defaultIcon.png';
this.icon.style.backgroundImage = 'url(' + (project.getIcon(512) || defaultIcon) + ')';

if (project.manifest.icons.renderGloss) {
if (project.manifest.ios && project.manifest.ios.icons && project.manifest.ios.icons.renderGloss) {
$.addClass(this.icon, 'gloss');
} else {
$.removeClass(this.icon, 'gloss');
Expand Down
43 changes: 40 additions & 3 deletions src/serve/plugins/simulate/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,49 @@ exports.load = function (app, argv) {
}
});

app.get('/simulate/:shortName/:target/loading.png', function (req, res, next) {
app.get('/simulate/:shortName/:target/splash/:splash', function (req, res, next) {
var projects = common.getProjectList();
var project = projects[req.params.shortName];
var splash = req.params.splash;

var img = project && project.manifest.preload && project.manifest.preload.img;
var img = project && project.manifest.splash && project.manifest.splash[splash];
if (!img) {
return next();
//if the key does not exist in the manifest we need to generate one
var splashSizes = {
"portrait480": "320x480",
"portrait960": "640x960",
"portrait1024": "768x1024",
"portrait1136": "640x1136",
"portrait2048": "1536x2048",
"landscape768": "1024x768",
"landscape1536": "2048x1496"
};
var outSize = splashSizes[splash];
if (project.manifest.splash && project.manifest.splash["universal"] && outSize) {
//run the splasher to generate a splash of the desired size
logger.log("Splash image mapped from universal ->", splash);
var outImg = path.join(project.paths.root,".tempsplash.png");
build.jvmtools.exec('splasher', [
"-i", path.resolve(project.paths.root, project.manifest.splash["universal"]),
"-o", outImg,
"-resize", outSize,
"-rotate", "auto"
], function (splasher) {
var formatter = new build.common.Formatter('splasher');
splasher.on('out', formatter.out);
splasher.on('err', formatter.err);
splasher.on('end', function (data) {
var stream = fs.createReadStream(outImg);
stream.pipe(res)
stream.on('end', function () {
//remove out remporary file
fs.unlinkSync(outImg);
});
})
});
} else {
return next();
}
} else {
img = path.resolve(project.paths.root, img);
var f = ff(function () {
Expand All @@ -140,6 +176,7 @@ exports.load = function (app, argv) {
if (!exists) {
next();
} else {
logger.log("Splash image mapped from", splash, "->", img);
fs.createReadStream(img).pipe(res);
}
}).error(next);
Expand Down
12 changes: 10 additions & 2 deletions src/serve/plugins/simulate/static/util/Simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ var Chrome = exports = Class(squill.Widget, function (supr) {
this.global.ACCESSIBILITY.mute(this.isMuted());
});
this.global.CONFIG.preload.hide = bind(this, 'hideLoadingImage');
this.global.CONFIG.splash.hide = bind(this, 'hideLoadingImage');
// update muted state
this.mute(this._isMuted);
Expand Down Expand Up @@ -292,7 +292,15 @@ var Chrome = exports = Class(squill.Widget, function (supr) {
};

this.getLoadingImageURL = function () {
return new std.uri(this._params.target + '/loading.png').toString();
var splash;
if (this._rotation % 2 == 0) {
//even amounts of rotations mean portrait
splash = "/splash/portrait2048";
} else {
//oods mean landscape
splash = "/splash/landscape1536";
}
return new std.uri(this._params.target + splash).toString();
};

this.rebuild = function (next) {
Expand Down
Loading

0 comments on commit e98eeb4

Please sign in to comment.