diff --git a/README.md b/README.md index 60f086f..580ffd9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -# Sparkiy for Windows -_Sparkiy/sparkiy-client_ +# Sparkiy +_[Sparkiy/sparkiy-client](https://github.com/Sparkiy/sparkiy-client)_ + +[![GratiPay Tips](https://img.shields.io/gratipay/sparkiy.svg?style=flat-square)](https://gratipay.com/sparkiy/) +[![Bountysource](https://www.bountysource.com/badge/team?team_id=54298&style=bounties_posted)](https://www.bountysource.com/teams/sparkiy-client/bounties?utm_source=sparkiy-client&utm_medium=shield&utm_campaign=bounties_posted) ## Overview Bring your ideas to life. Make something everyone can play on their computer, tablet, phone and console. @@ -12,6 +15,7 @@ Sparkiy is fully-featured platform for game and application development. Touch f - Xbox One ## Project status + | | master | beta | development | edge | | ------------- | ------ | ---- | ----------- | ---- | | Windows | [![master build status](https://ci.appveyor.com/api/projects/status/gvxevc5yih5oodnn/branch/master?svg=true&pendingText=pending...&passingText=OK&failingText=failed)](https://ci.appveyor.com/project/AleksandarDev/sparkiy-client/branch/master) | [![beta build status](https://ci.appveyor.com/api/projects/status/gvxevc5yih5oodnn/branch/beta?svg=true&pendingText=pending...&passingText=OK&failingText=failed)](https://ci.appveyor.com/project/AleksandarDev/sparkiy-client/branch/beta) | [![development build status](https://ci.appveyor.com/api/projects/status/gvxevc5yih5oodnn/branch/development?svg=true&pendingText=pending...&passingText=OK&failingText=failed)](https://ci.appveyor.com/project/AleksandarDev/sparkiy-client/branch/development) | [![edge build status](https://ci.appveyor.com/api/projects/status/gvxevc5yih5oodnn/branch/edge?svg=true&pendingText=pending...&passingText=OK&failingText=failed)](https://ci.appveyor.com/project/AleksandarDev/sparkiy-client/branch/edge) | diff --git a/SparkiyClient/SparkiyClient.Common/SparkiyClient.Common.csproj b/SparkiyClient/SparkiyClient.Common/SparkiyClient.Common.csproj index cffe72f..146f3ce 100644 --- a/SparkiyClient/SparkiyClient.Common/SparkiyClient.Common.csproj +++ b/SparkiyClient/SparkiyClient.Common/SparkiyClient.Common.csproj @@ -99,4 +99,4 @@ --> - + \ No newline at end of file diff --git a/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/CreateProjectPageViewModel.cs b/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/CreateProjectPageViewModel.cs index ad90221..1dd65d5 100644 --- a/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/CreateProjectPageViewModel.cs +++ b/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/CreateProjectPageViewModel.cs @@ -1,15 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.ObjectModel; using System.Threading.Tasks; using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Views; +using Nito.AsyncEx; using SparkiyClient.Common; using SparkiyClient.UILogic.Models; using SparkiyClient.UILogic.Services; -namespace SparkiyClient.UILogic.ViewModels +namespace SparkiyClient.UILogic.Windows.ViewModels { public interface ICreateProjectPageViewModel { @@ -30,6 +28,21 @@ public CreateProjectPageViewModel(IProjectService projectService, INavigationSer this.projectService = projectService; this.CreateProjectCommand = new RelayCommand(this.CreateProjectCommandExecuteAsync); + + this.Project = new Project() + { + Files = NotifyTaskCompletion.Create(async () => + { + return new ObservableCollection() + { + new Script() + { + Name = "Entry", + Code = "function Created()\n\nend\n\nfunction Started()\n\nend\n\nfunction Draw()\n\nend\n\nfunction Touched(type, x, y)\n\nend\n\nfunction Stopped()\n\nend\n" + } + }; + }) + }; } @@ -41,10 +54,17 @@ private async void CreateProjectCommandExecuteAsync() public Project Project { - get { return this.GetProperty(defaultValue: new Project()); } + get { return this.GetProperty(); } set { this.SetProperty(value); } } public RelayCommand CreateProjectCommand { get; } } + + public sealed class CreateProjectPageViewModelDesignTime : CreateProjectPageViewModel + { + public CreateProjectPageViewModelDesignTime() : base(null, null) + { + } + } } diff --git a/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/DebugPageViewModel.cs b/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/DebugPageViewModel.cs index 1ae460f..0a811a6 100644 --- a/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/DebugPageViewModel.cs +++ b/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/DebugPageViewModel.cs @@ -1,13 +1,47 @@ -using SparkiyClient.Common; +using System.Threading.Tasks; +using SparkiyClient.Common; +using SparkiyClient.UILogic.Models; +using SparkiyClient.UILogic.Services; -namespace SparkiyClient.UILogic.ViewModels +namespace SparkiyClient.UILogic.Windows.ViewModels { public interface IDebugPageViewModel { - + void AssignProjectPlayEngineManager(IProjectPlayEngineManagement projectPlayEngineManagement); + + void AssignProjectPlayStateManager(IProjectPlayStateManagment projectPlayStateManagment); + + Task AssignProjectAsync(Project project); } public class DebugPageViewModel : ExtendedViewModel, IDebugPageViewModel + { + private IProjectPlayEngineManagement projectPlayEngineManager; + private IProjectPlayStateManagment projectPlayStateManager; + private Project project; + + + + public void AssignProjectPlayEngineManager(IProjectPlayEngineManagement projectPlayEngineManager) + { + this.projectPlayEngineManager = projectPlayEngineManager; + } + + public void AssignProjectPlayStateManager(IProjectPlayStateManagment projectPlayStateManager) + { + this.projectPlayStateManager = projectPlayStateManager; + } + + public async Task AssignProjectAsync(Project project) + { + this.project = project; + this.projectPlayEngineManager.AssignProject(this.project); + + this.projectPlayStateManager.PlayProject(); + } + } + + public sealed class DebugPageViewModelDesignTime : DebugPageViewModel { } diff --git a/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/EditPageViewModel.cs b/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/EditPageViewModel.cs index fe378fe..6649e0e 100644 --- a/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/EditPageViewModel.cs +++ b/SparkiyClient/SparkiyClient.UILogic.Windows/ViewModels/EditPageViewModel.cs @@ -1,10 +1,8 @@ using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.IO; using System.Linq; -using System.Runtime.CompilerServices; using System.Threading.Tasks; using Windows.Storage.Pickers; using Windows.UI.Xaml.Navigation; @@ -16,7 +14,7 @@ using SparkiyClient.UILogic.Models; using SparkiyClient.UILogic.Services; -namespace SparkiyClient.UILogic.ViewModels +namespace SparkiyClient.UILogic.Windows.ViewModels { public interface INewFileViewModel { @@ -159,7 +157,7 @@ private async void AddNewAssetCommandExecuteAsync() foreach (var selectedFile in selectedFiles) await this.projectService.ImportAsset(this.Project, selectedFile); - var img = new Image(); + var img = new ImageAsset(); } @@ -211,7 +209,7 @@ public INewFileViewModel NewFileViewModel public RelayCommand PlayProjectCommand { get; } } - public class EditPageViewModelDesignTime : EditPageViewModel + public sealed class EditPageViewModelDesignTime : EditPageViewModel { public EditPageViewModelDesignTime() : base(null, null) { diff --git a/SparkiyClient/SparkiyClient.UILogic/Models/Image.cs b/SparkiyClient/SparkiyClient.UILogic/Models/ImageAsset.cs similarity index 77% rename from SparkiyClient/SparkiyClient.UILogic/Models/Image.cs rename to SparkiyClient/SparkiyClient.UILogic/Models/ImageAsset.cs index 720826f..f294602 100644 --- a/SparkiyClient/SparkiyClient.UILogic/Models/Image.cs +++ b/SparkiyClient/SparkiyClient.UILogic/Models/ImageAsset.cs @@ -5,9 +5,9 @@ namespace SparkiyClient.UILogic.Models { - public class Image : AssetWithData + public class ImageAsset : AssetWithData { - private static readonly ILogger Log = LogManagerFactory.DefaultLogManager.GetLogger(); + private static readonly ILogger Log = LogManagerFactory.DefaultLogManager.GetLogger(); /// /// Gets the data asynchronously from given path. @@ -17,7 +17,7 @@ public class Image : AssetWithData public override async Task GetDataAsync() { this.Data = new BitmapImage(new Uri(this.Path, UriKind.Absolute)); - Log.Debug("Loaded Image \"{0}\"", this.Name); + Log.Debug("Loaded ImageAsset \"{0}\"", this.Name); } #pragma warning restore 1998 } diff --git a/SparkiyClient/SparkiyClient.UILogic/Models/Project.cs b/SparkiyClient/SparkiyClient.UILogic/Models/Project.cs index f127a11..c233b63 100644 --- a/SparkiyClient/SparkiyClient.UILogic/Models/Project.cs +++ b/SparkiyClient/SparkiyClient.UILogic/Models/Project.cs @@ -28,7 +28,7 @@ public async Task LoadAsync(IProjectService projectService) await file.GetCodeAsync(); // Load images - foreach (var image in this.Assets.Result.OfType()) + foreach (var image in this.Assets.Result.OfType()) await image.GetDataAsync(); } diff --git a/SparkiyClient/SparkiyClient.UILogic/Services/IProjectPlayEngineManagement.cs b/SparkiyClient/SparkiyClient.UILogic/Services/IProjectPlayEngineManagement.cs new file mode 100644 index 0000000..3e62901 --- /dev/null +++ b/SparkiyClient/SparkiyClient.UILogic/Services/IProjectPlayEngineManagement.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using SparkiyClient.UILogic.Models; +using SparkiyEngine.Bindings.Component.Engine; + +namespace SparkiyClient.UILogic.Services +{ + public interface IProjectPlayEngineManagement + { + void AssignProject(Project project); + + IEngineBindings Engine { get; } + } +} \ No newline at end of file diff --git a/SparkiyClient/SparkiyClient.UILogic/Services/IProjectPlayStateManagment.cs b/SparkiyClient/SparkiyClient.UILogic/Services/IProjectPlayStateManagment.cs new file mode 100644 index 0000000..666d9a8 --- /dev/null +++ b/SparkiyClient/SparkiyClient.UILogic/Services/IProjectPlayStateManagment.cs @@ -0,0 +1,20 @@ +namespace SparkiyClient.UILogic.Services +{ + public interface IProjectPlayStateManagment + { + void PlayProject(); + + void PauseProject(); + + void RestartProject(); + + void TakeScreenshot(); + + + bool IsInitialized { get; } + + bool IsPlaying { get; } + + bool IsPause { get; } + } +} \ No newline at end of file diff --git a/SparkiyClient/SparkiyClient.UILogic/Services/ProjectService.cs b/SparkiyClient/SparkiyClient.UILogic/Services/ProjectService.cs index e63f5e5..35699f4 100644 --- a/SparkiyClient/SparkiyClient.UILogic/Services/ProjectService.cs +++ b/SparkiyClient/SparkiyClient.UILogic/Services/ProjectService.cs @@ -61,7 +61,7 @@ public async Task ImportAsset(Project project, StorageFile file) private Asset ResolveAsset(StorageFile file) { if (file.ContentType == "image/png") - return new Image() + return new ImageAsset() { Name = file.DisplayName, Path = file.Path diff --git a/SparkiyClient/SparkiyClient.UILogic/SparkiyClient.UILogic.csproj b/SparkiyClient/SparkiyClient.UILogic/SparkiyClient.UILogic.csproj index 2e35523..bd6a887 100644 --- a/SparkiyClient/SparkiyClient.UILogic/SparkiyClient.UILogic.csproj +++ b/SparkiyClient/SparkiyClient.UILogic/SparkiyClient.UILogic.csproj @@ -60,7 +60,7 @@ - + @@ -70,6 +70,8 @@ + + @@ -140,4 +142,4 @@ --> - + \ No newline at end of file diff --git a/SparkiyClient/SparkiyClient.UILogic/ViewModels/PlayPageViewModel.cs b/SparkiyClient/SparkiyClient.UILogic/ViewModels/PlayPageViewModel.cs index 9d34207..0bfec93 100644 --- a/SparkiyClient/SparkiyClient.UILogic/ViewModels/PlayPageViewModel.cs +++ b/SparkiyClient/SparkiyClient.UILogic/ViewModels/PlayPageViewModel.cs @@ -11,4 +11,9 @@ public class PlayPageViewModel : ExtendedViewModel, IPlayPageViewModel { } + + public sealed class PlayPageViewModelDesignTime : PlayPageViewModel + { + + } } \ No newline at end of file diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Shared/App.xaml.cs b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/App.xaml.cs index 84e3b97..5987738 100644 --- a/SparkiyClient/SparkiyClient/SparkiyClient.Shared/App.xaml.cs +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/App.xaml.cs @@ -42,6 +42,7 @@ using MetroLog.Internal; using Microsoft.Practices.ServiceLocation; using SparkiyClient.Common; +using SparkiyClient.UILogic.Windows.ViewModels; using SparkiyClient.Views; namespace SparkiyClient @@ -195,10 +196,11 @@ private void OnContainerRegistration(IUnityContainer container) // Register instances this.container.RegisterInstance(this.container); - + // Register services this.container.RegisterType(new ContainerControlledLifetimeManager()); this.container.RegisterType(new ContainerControlledLifetimeManager()); + this.container.RegisterType(new ContainerControlledLifetimeManager()); this.container.RegisterType(new ContainerControlledLifetimeManager()); this.container.RegisterType(new ContainerControlledLifetimeManager()); diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/CodeEditor/CodeEditorControl.xaml.cs b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/CodeEditor/CodeEditorControl.xaml.cs index b05d7a8..1120698 100644 --- a/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/CodeEditor/CodeEditorControl.xaml.cs +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/CodeEditor/CodeEditorControl.xaml.cs @@ -10,8 +10,6 @@ public sealed partial class CodeEditorControl : UserControl, ICodeEditor { public event EventHandler OnCodeChanged; - private const string DebugTemplate = "function Created()\n\t\nend\n\nfunction Started()\n\t\nend\n\nfunction Draw()\n\t\nend\n\nfunction Touched(state, x, y)\n\t\nend\n\nfunction Stopped()\n\t\nend\n"; - public CodeEditorControl() { @@ -22,10 +20,6 @@ public CodeEditorControl() private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { -#if DEBUG - this.CodeEditor.Text = DebugTemplate; -#endif - this.CodeEditor.TextView.TextChanged += (o, args) => { this.OnCodeChanged?.Invoke(this, null); diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml new file mode 100644 index 0000000..7165aef --- /dev/null +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml @@ -0,0 +1,15 @@ + + + + + + diff --git a/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml.cs b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml.cs new file mode 100644 index 0000000..f908507 --- /dev/null +++ b/SparkiyClient/SparkiyClient/SparkiyClient.Shared/Controls/PlayView/PlayViewControl.xaml.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using System.Threading.Tasks; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Notifications; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; +using MetroLog; +using Microsoft.Practices.ServiceLocation; +using SparkiyClient.Services; +using SparkiyClient.UILogic.Models; +using SparkiyClient.UILogic.Services; +using SparkiyEngine.Bindings.Component.Engine; + +// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 + +namespace SparkiyClient.Controls.PlayView +{ + public sealed partial class PlayViewControl : UserControl, IProjectPlayStateManagment, IProjectPlayEngineManagement + { + private static ILogger Log = LogManagerFactory.DefaultLogManager.GetLogger(); + + private Project project; + private IEngineBindings engine; + + // State tracking + private bool isPaused = true; + private bool isInitialized = false; + + + public PlayViewControl() + { + this.InitializeComponent(); + } + + + public void AssignProject(Project project) + { + Log.Debug("Assigned project \"{0}\" to the PlayView", project.Name); + + // Stop currently running project + if (this.IsInitialized) + this.StopProject(); + + // Assign new project + this.project = project; + + // Load assets from project + var imageAssets = new List(); + foreach (var asset in this.project.Assets.Result) + { + if (asset is ImageAsset) + { + var imageAsset = asset as ImageAsset; + imageAssets.Add(imageAsset); + Log.Debug("Added Asset:Image \"{0}\"", imageAsset.Name); + } + else { + throw new NotSupportedException("Provided asset type is not supported by this player."); + } + } + + // Combine all classes into one string + var classesCombined = project.Files.Result + .OfType() + .Aggregate( + String.Empty, + (combined, current) => combined + current.Code); + + // Instantiate new engine + this.engine = ServiceLocator.Current.GetInstance().GetLuaDxEngine(this.SwapChainPanel); + this.engine.Initialize(); + + // TODO Add assets to the engine + + // Add scripts to the engine + foreach (var script in project.Files.Result.OfType