Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Throw FileNotFoundException instead of Exception when an asset is mis…
Browse files Browse the repository at this point in the history
…sing from the manifest so apps can respond to it.
  • Loading branch information
kg committed Jul 11, 2012
1 parent 2b752bf commit 05665d9
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 36 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -36,7 +36,9 @@ Tests/*Cases/*.js
/jsil.org/demos/Sully/*.js
/jsil.org/demos/Sully/Content
/jsil.org/demos/Soulcaster/*.js
/jsil.org/demos/Soulcaster/Soulcaster2Content
/jsil.org/demos/Soulcaster/Soulcaster1Content
/jsil.org/demos/Soulcaster2/*.js
/jsil.org/demos/Soulcaster2/Soulcaster2Content
/jsil.org/demos/RPG/Content
/jsil.org/demos/GameType/*.js
/jsil.org/demos/GameType/Content
Expand Down
20 changes: 20 additions & 0 deletions Libraries/JSIL.Bootstrap.js
Expand Up @@ -1073,13 +1073,33 @@ JSIL.ImplementExternals(
}
);

JSIL.ImplementExternals(
"System.IO.FileNotFoundException", function ($) {
$.Method({Static:false, Public:true }, ".ctor",
new JSIL.MethodSignature(null, [$.String], []),
function (message) {
System.Exception.prototype._ctor.call(this, message);
}
);

$.Method({Static:false, Public:true }, ".ctor",
(new JSIL.MethodSignature(null, [$.String, $.String], [])),
function _ctor (message, fileName) {
System.Exception.prototype._ctor.call(this, message);
this._fileName = fileName;
}
);
}
);

JSIL.MakeClass(Error, "System.Exception", true, [], function ($) {
$.Property({Public: true , Static: false, Virtual: true }, "Message");
$.Property({Public: true , Static: false}, "InnerException");
});

JSIL.MakeClass("System.Exception", "System.InvalidCastException", true);
JSIL.MakeClass("System.Exception", "System.InvalidOperationException", true);
JSIL.MakeClass("System.Exception", "System.IO.FileNotFoundException", true);

JSIL.ImplementExternals("System.Console", function ($) {
$.RawMethod(true, "WriteLine", function () {
Expand Down
7 changes: 4 additions & 3 deletions Libraries/JSIL.Browser.js
Expand Up @@ -92,14 +92,15 @@ JSIL.Host.getFile = function (filename) {
}

if (!JSIL.Host.doesFileExist(filename))
throw new System.Exception(errorMessage);
throw new System.IO.FileNotFoundException(errorMessage, filename);

return allFiles[JSIL.Host.translateFilename(filename)];
};
JSIL.Host.getImage = function (filename) {
var key = getAssetName(filename, false);
if (!allAssets.hasOwnProperty(key))
throw new System.Exception("The image '" + key + "' is not in the asset manifest.");
throw new System.IO.FileNotFoundException("The image '" + key + "' is not in the asset manifest.", filename);

return allAssets[key].image;
};
JSIL.Host.doesAssetExist = function (filename, stripRoot) {
Expand Down Expand Up @@ -130,7 +131,7 @@ JSIL.Host.getAsset = function (filename, stripRoot) {

var key = getAssetName(filename, false);
if (!allAssets.hasOwnProperty(key))
throw new System.Exception("The asset '" + key + "' is not in the asset manifest.");
throw new System.IO.FileNotFoundException("The asset '" + key + "' is not in the asset manifest.", filename);

return allAssets[key];
};
Expand Down
3 changes: 2 additions & 1 deletion build_demos.bat
@@ -1,8 +1,9 @@
pushd bin
del /s/q ..\jsil.org\demos\*.js
JSILc "C:\Users\Kevin\Documents\Projects\EscapeGoat\bastille\bastille.sln" "C:\Users\Kevin\Documents\Projects\EscapeGoat\bastille\Bastille\Bastille\bin\x86\DebugPC\EscapeGoat.XmlSerializers.dll" "C:\Users\Kevin\Documents\Projects\JSIL\jsil.org\demos\EscapeGoat\EscapeGoat.jsilconfig" --platform:x86 --configuration:DebugPC
JSILc "C:\Users\Kevin\Documents\Projects\Soulcaster\Soulcaster1HTML5.sln" "C:\Users\Kevin\Documents\Projects\Soulcaster\Soulcaster1\Soulcaster1\bin\x86\DebugPC\TarchonData.XmlSerializers.dll" "C:\Users\Kevin\Documents\Projects\JSIL\jsil.org\demos\Soulcaster\Soulcaster.jsilconfig" --platform:x86 --configuration:DebugPC
JSILc "C:\Users\Kevin\Documents\Projects\Soulcaster\Soulcaster2HTML5.sln" "C:\Users\Kevin\Documents\Projects\Soulcaster\Soulcaster2\Soulcaster2\bin\x86\DebugPC\TarchonData.XmlSerializers.dll" "C:\Users\Kevin\Documents\Projects\JSIL\jsil.org\demos\Soulcaster2\Soulcaster2.jsilconfig" --platform:x86 --configuration:DebugPC
JSILc "C:\Game Design\Game Type\CodeNew\GameType\GameType.sln" "C:\Users\Kevin\Documents\Projects\JSIL\jsil.org\demos\GameType\GameType.jsilconfig" --platform:x86 --configuration:Debug
JSILc "C:\Users\Kevin\Documents\Projects\Soulcaster\SoulcasterHTML5.sln" "C:\Users\Kevin\Documents\Projects\Soulcaster\Soulcaster2\Soulcaster2\bin\x86\DebugPC\TarchonData.XmlSerializers.dll" "C:\Users\Kevin\Documents\Projects\JSIL\jsil.org\demos\Soulcaster\Soulcaster.jsilconfig" --platform:x86 --configuration:DebugPC
JSILc "C:\Users\Kevin\Documents\Projects\XNAVERGE\Sully.sln" "C:\Users\Kevin\Documents\Projects\JSIL\jsil.org\demos\Sully\Sully.jsilconfig" --platform:x86 --configuration:Debug
JSILc "C:\Users\Kevin\Documents\Projects\lumberjack\LumberjackPC.sln" "C:\Users\Kevin\Documents\Projects\lumberjack\Lumberjack\Lumberjack\bin\x86\Debug\Lumberjack.XmlSerializers.dll" "C:\Users\Kevin\Documents\Projects\JSIL\jsil.org\demos\Lumberjack\Lumberjack.jsilconfig" --platform:x86 --configuration:Debug
JSILc "C:\Users\Kevin\Documents\Projects\JSIL\Examples\SimpleRaytracer.sln"
Expand Down
24 changes: 4 additions & 20 deletions jsil.org/demos/Soulcaster/Soulcaster.css
Expand Up @@ -15,22 +15,6 @@ a, a:visited {
left: 0px;
top: 0px;
cursor: none;

/*
-moz-transform: scale(2);
-webkit-transform: scale(2);
-o-transform: scale(2);
-ms-transform: scale(2);
transform: scale(2);
-moz-transform-origin: top left;
-webkit-transform-origin: top left;
-o-transform-origin: top left;
-ms-transform-origin: top left;
transform-origin: top left;
*/
}
#welcomeMessage {
width: 620px;
Expand Down Expand Up @@ -60,20 +44,20 @@ a, a:visited {
height: 40px;
}
#log {
width: 704px;
width: 640px;
height: 200px;
left: 2px;
top: 544px;
top: 484px;
overflow-x: hidden;
overflow-y: scroll;
}
#fullscreenButton {
left: 708px;
left: 644px;
top: 2px;
height: 45px;
}
#stats {
left: 708px;
left: 644px;
top: 50px;
}
.boxCaption {
Expand Down
20 changes: 10 additions & 10 deletions jsil.org/demos/Soulcaster/Soulcaster.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Soulcaster 2</title>
<title>Soulcaster 1</title>

<link rel="stylesheet" href="../Common/browser.css">
<link rel="stylesheet" href="Soulcaster.css">
Expand All @@ -18,8 +18,8 @@
localStorage: true,

manifests: [
"Soulcaster2.exe",
"Soulcaster2Content.contentproj"
"Soulcaster.exe",
"Soulcaster1Content.contentproj"
],

showProgressBar: true,
Expand All @@ -29,8 +29,8 @@
</script>
<script src="../Libraries/JSIL.js" type="text/javascript"></script>

<!-- 352x272 -->
<canvas id="canvas" width="704" height="544">
<!-- 320x240 -->
<canvas id="canvas" width="640" height="480">
</canvas><br>

<div id="welcomeMessage">
Expand All @@ -44,8 +44,8 @@
<script type="text/javascript">
var scriptRoot = "";
var libraryRoot = "../Libraries/";
var fileRoot = "Soulcaster2Content/";
var contentRoot = "Soulcaster2Content/";
var fileRoot = "Soulcaster1Content/";
var contentRoot = "Soulcaster1Content/";

var assetsToLoad = [
// Used to read the levels
Expand All @@ -64,11 +64,11 @@
overrideFullscreenBaseSize = [352, 272]

// Set up the localStorage backend
JSIL.LocalStorage.Initialize("Soulcaster2");
JSIL.LocalStorage.Initialize("Soulcaster");

// We can't invoke Main() since it disposes the Game immediately, breaking everything.
var asm = JSIL.GetAssembly("Soulcaster2", true);
var game = new asm.Tarchon.SoulcasterTwo();
var asm = JSIL.GetAssembly("Soulcaster", true);
var game = new asm.Tarchon.SoulcasterOne();
game.Run();
};
</script>
Expand Down
2 changes: 1 addition & 1 deletion jsil.org/demos/Soulcaster/Soulcaster.jsilconfig
Expand Up @@ -13,7 +13,7 @@
},
"ProfileSettings": {
"OverwriteExistingContent": true,
"ContentOutputDirectory": "%configpath%/Soulcaster2Content",
"ContentOutputDirectory": "%configpath%/Soulcaster1Content",
"UsePNGQuant": true,
"FileSettings": {
}
Expand Down
72 changes: 72 additions & 0 deletions jsil.org/demos/Soulcaster2/Soulcaster2.css
@@ -0,0 +1,72 @@
html {
margin: 0px;
padding: 0px;
}
body {
background-color: black;
color: white;
margin: 0px;
padding: 0px;
}
a, a:visited {
color: silver;
}
#canvas {
left: 0px;
top: 0px;
cursor: none;
}
#welcomeMessage {
width: 620px;
height: 140px;
left: 42px;
top: 162px;
}
#loadButton {
width: 200px;
height: 40px;
left: 539px;
top: 320px;
}
#quitButton {
width: 32px;
height: 32px;
left: 1284px;
top: 2px;
}
#loadingProgress {
width: 600px;
height: 40px;
left: 52px;
top: 252px;
}
#progressBar {
height: 40px;
}
#log {
width: 704px;
height: 200px;
left: 2px;
top: 544px;
overflow-x: hidden;
overflow-y: scroll;
}
#fullscreenButton {
left: 708px;
top: 2px;
height: 45px;
}
#stats {
left: 708px;
top: 50px;
}
.boxCaption {
position: absolute;
font-size: 10pt;
font-family: Consolas, Courier New, Courier;
z-index: -999;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
88 changes: 88 additions & 0 deletions jsil.org/demos/Soulcaster2/Soulcaster2.html
@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html>
<head>
<title>Soulcaster 2</title>

<link rel="stylesheet" href="../Common/browser.css">
<link rel="stylesheet" href="Soulcaster2.css">

<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body onload="onLoad()">
<script type="text/javascript">
var jsilConfig = {
printStackTrace: false,
webgl2d: true,
winForms: true,
xna: 4,
localStorage: true,

manifests: [
"Soulcaster2.exe",
"Soulcaster2Content.contentproj"
],

showProgressBar: true,
showStats: true,
showFullscreenButton: true
};
</script>
<script src="../Libraries/JSIL.js" type="text/javascript"></script>

<!-- 352x272 -->
<canvas id="canvas" width="704" height="544">
</canvas><br>

<div id="welcomeMessage">
<p align="center"><a href="http://jsil.org/"><img src="http://jsil.org/images/jsil_48px.png" alt="JSIL logo" border="0"></a></p>
</div>
<div id="log"><center><span style="font-size: 16pt; text-align: center; display: inline-block">
Use mouse to move and interact with menus.<br>
For best performance, play in <a href="https://www.google.com/chrome">Google Chrome</a>.<br>
</span></center><br></div>

<script type="text/javascript">
var scriptRoot = "";
var libraryRoot = "../Libraries/";
var fileRoot = "Soulcaster2Content/";
var contentRoot = "Soulcaster2Content/";

var assetsToLoad = [
// Used to read the levels
["Script", "TarchonData.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js", { "sizeBytes": 10127 }],
];

function runMain () {
try {
document.getElementById("welcomeMessage").setAttribute("style", "display: none");
} catch (ex) {
}

// Crisp square pixels!
integralFullscreenScaling = true;
// We default the canvas to 2x native framebuffer size, but we want fullscreen scaling to be based on 1x
overrideFullscreenBaseSize = [352, 272]

// Set up the localStorage backend
JSIL.LocalStorage.Initialize("Soulcaster2");

// We can't invoke Main() since it disposes the Game immediately, breaking everything.
var asm = JSIL.GetAssembly("Soulcaster2", true);
var game = new asm.Tarchon.SoulcasterTwo();
game.Run();
};
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6375004-2']);
_gaq.push(['_setDomainName', '.luminance.org']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
21 changes: 21 additions & 0 deletions jsil.org/demos/Soulcaster2/Soulcaster2.jsilconfig
@@ -0,0 +1,21 @@
{
"UseThreads": true,
"OutputDirectory": "%configpath%",
"Assemblies": {
"Proxies": [
"C:/Users/Kevin/Documents/Projects/Soulcaster/Proxies/bin/Debug/Proxies.dll"
],
"Ignored": [
"System.Data.*",
"System.Deployment",
"Proxies"
]
},
"ProfileSettings": {
"OverwriteExistingContent": true,
"ContentOutputDirectory": "%configpath%/Soulcaster2Content",
"UsePNGQuant": true,
"FileSettings": {
}
}
}

0 comments on commit 05665d9

Please sign in to comment.