From 8ab6b8ddbfc4c8af1817b9c02acc71ba3464dbd5 Mon Sep 17 00:00:00 2001 From: Aleksandar Toplek Date: Thu, 8 Jan 2015 01:28:04 +0100 Subject: [PATCH 1/7] Now catching all exceptions --- .../BundleArtifacts/arm.txt | 4 ++ .../BundleArtifacts/x64.txt | 2 + .../BundleArtifacts/x86.txt | 2 + .../Package.StoreAssociation.xml | 18 +++++- .../Package.appxmanifest | 2 +- SparkiyClient/SparkiyEngine.Engine/Sparkiy.cs | 63 ++++++++++++------- .../SparkiyGame.cs | 24 ++----- 7 files changed, 71 insertions(+), 44 deletions(-) create mode 100644 SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/arm.txt create mode 100644 SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/x64.txt create mode 100644 SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/x86.txt diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/arm.txt b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/arm.txt new file mode 100644 index 0000000..29c9dcd --- /dev/null +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/arm.txt @@ -0,0 +1,4 @@ +MainPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\ARM\Release\SparkiyClient.Windows_1.1.1.1_ARM.appx +SymbolPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\AppPackages\SparkiyClient.Windows_1.1.1.1_Test\SparkiyClient.Windows_1.1.1.1_ARM.appxsym +ResourcePack=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\ARM\Release\SparkiyClient.Windows_1.1.1.1_scale-140.appx +ResourcePack=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\ARM\Release\SparkiyClient.Windows_1.1.1.1_scale-180.appx diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/x64.txt b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/x64.txt new file mode 100644 index 0000000..eb200ec --- /dev/null +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/x64.txt @@ -0,0 +1,2 @@ +MainPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\x64\Release\SparkiyClient.Windows_1.1.1.1_x64.appx +SymbolPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\AppPackages\SparkiyClient.Windows_1.1.1.1_Test\SparkiyClient.Windows_1.1.1.1_x64.appxsym diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/x86.txt b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/x86.txt new file mode 100644 index 0000000..50e4042 --- /dev/null +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/BundleArtifacts/x86.txt @@ -0,0 +1,2 @@ +MainPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\bin\x86\Release\SparkiyClient.Windows_1.1.1.1_x86.appx +SymbolPackage=C:\Users\Aleksandar\Documents\GitHub\sparkiy-client\SparkiyClient\SparkiyClient\SparkiyClient.Windows\AppPackages\SparkiyClient.Windows_1.1.1.1_Test\SparkiyClient.Windows_1.1.1.1_x86.appxsym diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Windows/Package.StoreAssociation.xml b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/Package.StoreAssociation.xml index dbfb0e9..069822d 100644 --- a/SparkiyClient/SparkiyClient/SparkiyClient.Windows/Package.StoreAssociation.xml +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/Package.StoreAssociation.xml @@ -357,5 +357,21 @@ 53858AleksandarToplek.Project-Code 53858AleksandarToplek.Quantastic - + + + 6.3.0.0 + x86 + 1.1.0.3 + + + 6.3.0.0 + arm + 1.1.0.3 + + + 6.3.0.0 + x64 + 1.1.0.3 + + \ No newline at end of file diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Windows/Package.appxmanifest b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/Package.appxmanifest index aa72b49..6ccd120 100644 --- a/SparkiyClient/SparkiyClient/SparkiyClient.Windows/Package.appxmanifest +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Windows/Package.appxmanifest @@ -1,6 +1,6 @@  - + Sparkiy Aleksandar Toplek diff --git a/SparkiyClient/SparkiyEngine.Engine/Sparkiy.cs b/SparkiyClient/SparkiyEngine.Engine/Sparkiy.cs index b51b7c3..4d56f08 100644 --- a/SparkiyClient/SparkiyEngine.Engine/Sparkiy.cs +++ b/SparkiyClient/SparkiyEngine.Engine/Sparkiy.cs @@ -173,8 +173,8 @@ public void CallDrawFunction() this.pointerManager.PrimaryPointer.UpdateType(); } - // Call use draw method - this.LanguageBindings.CallMethod("Draw", new MethodDeclarationOverloadDetails() {Type = MethodTypes.Call}, new object[] {}); + // Call use draw method + this.CallFunction(null, "Draw", MethodTypes.Call); } private void CallCreated(string script = null) @@ -209,28 +209,45 @@ private void CallStopped(string script = null) this.CallFunction(script, "Stopped", MethodTypes.Call); } - private object CallFunction(string script, string name, MethodTypes type, Dictionary inputParameters = null) + public object CallFunction(string script, string name, MethodTypes type, Dictionary inputParameters = null) { - if (script != null) - { - return this.LanguageBindings.CallMethod(script, name, - new MethodDeclarationOverloadDetails() - { - Type = type, - Input = inputParameters?.Values.ToArray() ?? new DataTypes[0] - }, - inputParameters?.Keys.ToArray() ?? new object[0]); - } - else - { - return this.LanguageBindings.CallMethod(name, - new MethodDeclarationOverloadDetails() - { - Type = type, - Input = inputParameters?.Values.ToArray() ?? new DataTypes[0] - }, - inputParameters?.Keys.ToArray() ?? new object[0]); - } + try + { + if (script != null) + { + return this.LanguageBindings.CallMethod(script, name, + new MethodDeclarationOverloadDetails() + { + Type = type, + Input = inputParameters?.Values.ToArray() ?? new DataTypes[0] + }, + inputParameters?.Keys.ToArray() ?? new object[0]); + } + else + { + return this.LanguageBindings.CallMethod(name, + new MethodDeclarationOverloadDetails() + { + Type = type, + Input = inputParameters?.Values.ToArray() ?? new DataTypes[0] + }, + inputParameters?.Keys.ToArray() ?? new object[0]); + } + } + catch (Exception ex) + { + this.Pause(); + this.Reset(); + + this.AddMessage(new EngineMessage() + { + Message = String.Format("Function \"{0}\" throw an exception:\n{1}", name, ex.Message), + Source = this, + SourceType = BindingTypes.Engine + }); + + return null; + } } #region Messages diff --git a/SparkiyClient/SparkiyEngine.Graphics.DirectX/SparkiyGame.cs b/SparkiyClient/SparkiyEngine.Graphics.DirectX/SparkiyGame.cs index 3f3e4ff..e62acc1 100644 --- a/SparkiyClient/SparkiyEngine.Graphics.DirectX/SparkiyGame.cs +++ b/SparkiyClient/SparkiyEngine.Graphics.DirectX/SparkiyGame.cs @@ -272,28 +272,20 @@ public void DrawTexture(string assetName, float x, float y, float width = -1f, f protected override void Draw(GameTime gameTime) { - if (!isPlaying) return; - - base.Draw(gameTime); + base.Draw(gameTime); // Clears the screen with the Color.CornflowerBlue this.GraphicsDevice.Clear(this.BackgroundColor); // Draw 2D this.Reset(); - //this.Canvas.Render(); - // Execute users draw loop - try - { - this.engine.CallDrawFunction(); - } - catch(Exception ex) + if (this.isPlaying) { - this.StoppedByException(ex); + // Execute users draw loop + this.engine.CallDrawFunction(); + this.Canvas.Render(); } - - this.Canvas.Render(); } public void Reset() @@ -322,12 +314,6 @@ public void Reset() this.engine.LanguageBindings.SetVariable("HEIGHT", (double)this.GraphicsDevice.Viewport.Height, DataTypes.Number); } - private void StoppedByException(Exception ex) - { - this.Pause(); - this.Reset(); - } - #region Surface public Color4 BackgroundColor From bd3970ece8557a21b4eff55163a0a994ccf56c65 Mon Sep 17 00:00:00 2001 From: Aleksandar Toplek Date: Thu, 8 Jan 2015 06:53:35 +0100 Subject: [PATCH 2/7] Now showing real error messages --- .../Controls/PlayView/PlayViewControl.xaml.cs | 12 ++- .../Converters/BooleanToBrushConverter.cs | 30 ++++++ .../SparkiyClient.Shared.projitems | 1 + .../Views/DebugPage.xaml | 10 +- .../Engine/EngineMessage.cs | 2 + .../Engine/IEngineBindings.cs | 2 +- .../Language/ILanguageBindings.cs | 7 +- .../Language/LanguageScriptError.cs | 8 ++ .../SparkiyEngine.Bindings.Component.csproj | 3 +- SparkiyClient/SparkiyEngine.Engine/Sparkiy.cs | 59 +++++++++--- .../LanguageBindings.cpp | 14 ++- .../LanguageBindings.h | 6 +- .../LuaImplementation.cpp | 18 ++++ .../LuaImplementation.h | 6 +- .../LuaScript.cpp | 93 +++++++++++++------ .../LuaScript.h | 7 +- 16 files changed, 221 insertions(+), 57 deletions(-) create mode 100644 SparkiyClient/SparkiyClient/SparkiyClient.Shared/Converters/BooleanToBrushConverter.cs create mode 100644 SparkiyClient/SparkiyEngine.Bindings.Component/Language/LanguageScriptError.cs diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml.cs b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml.cs index 337b091..0e965cd 100644 --- a/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml.cs +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml.cs @@ -59,8 +59,6 @@ public void AssignProject(Project project) this.project = project; this.RebuildEngine(); - - this.isInitialized = true; } private void StopProject() @@ -75,7 +73,7 @@ private void StopProject() public void PlayProject() { - if (this.IsPlaying) + if (!this.IsInitialized || this.IsPlaying) return; this.Engine.Play(); @@ -87,7 +85,7 @@ public void PlayProject() public void PauseProject() { - if (this.IsPause) + if (!this.IsInitialized || this.IsPause) return; this.Engine.Pause(); @@ -138,8 +136,12 @@ private void RebuildEngine() // TODO Add assets to the engine // Add scripts to the engine + bool allScriptsValid = true; foreach (var script in this.project.Files.OfType