Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarDev committed Feb 5, 2015
2 parents 63248d4 + c32ec61 commit 0c76f54
Show file tree
Hide file tree
Showing 30 changed files with 930 additions and 84 deletions.
693 changes: 690 additions & 3 deletions LICENSE.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ Sparkiy is fully-featured platform for game and application development. Touch f
- [Fluent Assertions](https://github.com/dennisdoomen/fluentassertions)
- [MetroLog](https://github.com/mbrit/MetroLog)
- [Syntax Editor for WinRT](https://gallery.technet.microsoft.com/scriptcenter/Syntax-Editor-for-WinRT-c556d223/view/Reviews)

## Powered by:

<img src="https://brandfolder.com/raygun/assets/14l8cwle" alt="Logo Black">
16 changes: 16 additions & 0 deletions SparkiyClient/SparkiyClient - Copy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Global
{921B2FE9-7AD1-4F92-8465-77C03DD95B4F}.Release|Win32.Build.0 = Release|x86
{921B2FE9-7AD1-4F92-8465-77C03DD95B4F}.Release|Win32.Deploy.0 = Release|x86
{921B2FE9-7AD1-4F92-8465-77C03DD95B4F}.Release|x64.ActiveCfg = Release|Any CPU
{921B2FE9-7AD1-4F92-8465-77C03DD95B4F}.Release|x64.Build.0 = Release|Any CPU
{921B2FE9-7AD1-4F92-8465-77C03DD95B4F}.Release|x86.ActiveCfg = Release|x86
{921B2FE9-7AD1-4F92-8465-77C03DD95B4F}.Release|x86.Build.0 = Release|x86
{921B2FE9-7AD1-4F92-8465-77C03DD95B4F}.Release|x86.Deploy.0 = Release|x86
Expand Down Expand Up @@ -224,11 +225,14 @@ Global
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|Any CPU.Build.0 = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|ARM.ActiveCfg = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|ARM.Build.0 = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|Win32.ActiveCfg = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|x64.ActiveCfg = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|x64.Build.0 = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|x86.ActiveCfg = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Release|x86.Build.0 = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Sign|Any CPU.ActiveCfg = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Sign|Any CPU.Build.0 = Release|Any CPU
{F911B0B9-7C40-4A76-B8E8-48FAC2341F4F}.Sign|ARM.ActiveCfg = Release|ARM
Expand Down Expand Up @@ -426,11 +430,14 @@ Global
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|Any CPU.Build.0 = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|ARM.ActiveCfg = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|ARM.Build.0 = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|Win32.ActiveCfg = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|x64.ActiveCfg = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|x64.Build.0 = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|x86.ActiveCfg = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Release|x86.Build.0 = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Sign|Any CPU.ActiveCfg = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Sign|Any CPU.Build.0 = Release|Any CPU
{E9172DFA-125C-4C68-8DF8-EF88E36AB410}.Sign|ARM.ActiveCfg = Release|ARM
Expand Down Expand Up @@ -458,11 +465,14 @@ Global
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|Any CPU.Build.0 = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|ARM.ActiveCfg = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|ARM.Build.0 = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|Win32.ActiveCfg = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|x64.ActiveCfg = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|x64.Build.0 = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|x86.ActiveCfg = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Release|x86.Build.0 = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Sign|Any CPU.ActiveCfg = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Sign|Any CPU.Build.0 = Release|Any CPU
{76C266AE-873F-490A-9124-DB60916D0F95}.Sign|ARM.ActiveCfg = Release|ARM
Expand Down Expand Up @@ -544,11 +554,14 @@ Global
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|Any CPU.Build.0 = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|ARM.ActiveCfg = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|ARM.Build.0 = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|Win32.ActiveCfg = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|x64.ActiveCfg = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|x64.Build.0 = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|x86.ActiveCfg = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Release|x86.Build.0 = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Sign|Any CPU.ActiveCfg = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Sign|Any CPU.Build.0 = Release|Any CPU
{79259DB5-4D17-450E-9861-09FA93BFF6FD}.Sign|ARM.ActiveCfg = Release|ARM
Expand Down Expand Up @@ -576,11 +589,14 @@ Global
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|Any CPU.Build.0 = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|ARM.ActiveCfg = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|ARM.Build.0 = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|Win32.ActiveCfg = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|x64.ActiveCfg = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|x64.Build.0 = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|x86.ActiveCfg = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Release|x86.Build.0 = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Sign|Any CPU.ActiveCfg = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Sign|Any CPU.Build.0 = Release|Any CPU
{8CDE3F03-4EFA-4F3D-823E-62F7A93E077B}.Sign|ARM.ActiveCfg = Release|ARM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public CreateProjectPageViewModel(IProjectService projectService, INavigationSer
new Script()
{
Name = "Entry",
Code = "function Created()\r\n\r\nend\r\n\r\nfunction Started()\r\n\r\nend\r\n\r\nfunction Draw()\r\n\r\nend\r\n\r\nfunction Touched(type, x, y)\r\n\r\nend\r\n\r\nfunction Stopped()\r\n\r\nend\r\n"
Code = "function created()\r\n\r\nend\r\n\r\nfunction started()\r\n\r\nend\r\n\r\nfunction draw()\r\n\r\nend\r\n\r\nfunction touched(touchType, x, y)\r\n\r\nend\r\n\r\nfunction stopped()\r\n\r\nend\r\n"
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ public async override void OnNavigatedTo(NavigationEventArgs e)

private void NavigateToEditorCommandExecute()
{
this.navigationService.GoBack();
this.projectPlayStateManager.StopProject();
this.navigationService.GoBack();
}

private void NavigateToHomeCommandExecute()
{
this.navigationService.GoHome();
this.projectPlayStateManager.StopProject();
this.navigationService.GoHome();
}

private void MessagesCheckTimerOnTick(object sender, object o)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public interface IProjectPlayStateManagment

void PauseProject();

void StopProject();

void RestartProject();

void TakeScreenshot();
Expand Down
137 changes: 137 additions & 0 deletions SparkiyClient/SparkiyClient.UILogic/Services/ISamplesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Windows.Security.Cryptography.Core;
using Windows.Storage;
using MetroLog;
using SparkiyClient.Common.Helpers;

namespace SparkiyClient.UILogic.Services
{
public interface ISamplesService
{
Task GetSamplesAsync();
}

public class SamplesService : ISamplesService
{
private static readonly ILogger Log = LogManagerFactory.DefaultLogManager.GetLogger<SamplesService>();

private const string SamplesSourceUrl = "https://github.com/Sparkiy/sparkiy-projects/archive/master.zip";
private const string SamplesPath = @"sparkiy-projects-master/Samples";

private readonly IStorageService storageService;


public SamplesService(IStorageService storageService)
{
this.storageService = storageService;
}


public async Task GetSamplesAsync()
{
HttpClient client = new HttpClient();

// Request the data
HttpResponseMessage responseMessage = await client.GetAsync(
new Uri(SamplesSourceUrl, UriKind.Absolute),
HttpCompletionOption.ResponseHeadersRead);

// Get the size of the content
long? contentLength = responseMessage.Content.Headers.ContentLength;

// Create stream to store data
using (var mstream = new MemoryStream())
{
// Read the content into the stream
int totalNumberOfBytesRead = 0;
using (var responseStream = await responseMessage.Content.ReadAsStreamAsync())
{
int numberOfReadBytes;
do
{
// Read a data block into the buffer
const int bufferSize = 1048576; // 1MB
byte[] responseBuffer = new byte[bufferSize];
numberOfReadBytes = await responseStream.ReadAsync(
responseBuffer, 0, responseBuffer.Length);
totalNumberOfBytesRead += numberOfReadBytes;

// Write the data block into the file stream
mstream.Write(responseBuffer, 0, numberOfReadBytes);

// Calculate the progress
if (contentLength.HasValue)
{
// Calculate the progress
double progressPercent = (totalNumberOfBytesRead/(double) contentLength)*100;

// Display the progress
Log.Debug("\t{0}% done", progressPercent);
}
else
{
// Just display the read bytes
Log.Debug("\t{0} bytes done", totalNumberOfBytesRead);
}
} while (numberOfReadBytes != 0);
}

// Unzip package
using (var archive = new ZipArchive(mstream, ZipArchiveMode.Read))
{
// Go through all items in package
foreach (var entry in archive.Entries)
{
// Only process files that are in /Sample/ folder path
if (entry.FullName.StartsWith(SamplesPath) && Path.HasExtension(entry.FullName))
{
// Get new file path and ensure folder structure is ready
var newFilePath = Path.Combine(this.storageService.WorkspaceFolder.Path, entry.FullName.Replace(SamplesPath, ""));
var folder = await this.EnsureFolderExists(newFilePath);

// Open zipped item
using (var fstream = entry.Open())
{
// Save zipped item to the file
await this.storageService.SaveFileSafeAsync(
folder,
Path.GetFileName(newFilePath),
async file =>
{
// Open destination file as a stream
using (var deststream = await file.OpenStreamForWriteAsync())
{
// Copy content to destination stream and flush
await fstream.CopyToAsync(deststream);
await deststream.FlushAsync();
Log.Debug("Saved entry \"{0}\"", entry.FullName);
}
});
}
}
}
}
}
}

private async Task<StorageFolder> EnsureFolderExists(string path)
{
var folderPath = Path.GetDirectoryName(path);
var currentFolder = this.storageService.WorkspaceFolder;
foreach (var innerFolder in folderPath.Replace(this.storageService.WorkspaceFolder.Path, "").Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries))
{
await currentFolder.EnsureFolderExistsAsync(innerFolder);
currentFolder = await currentFolder.GetFolderAsync(innerFolder);
}

return currentFolder;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Compile Include="Services\IProjectPlayEngineManagement.cs" />
<Compile Include="Services\IProjectPlayStateManagment.cs" />
<Compile Include="Services\IProjectService.cs" />
<Compile Include="Services\ISamplesService.cs" />
<Compile Include="Services\IStorageService.cs" />
<Compile Include="Services\ProjectPlayStateEventHandler.cs" />
<Compile Include="Services\ProjectService.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,26 @@ public class MainPageViewModel : ExtendedViewModel, IMainPageViewModel
private readonly IAlertMessageService alertMessageService;
private readonly IStorageService storageService;
private readonly IProjectService projectService;
private readonly ISamplesService samplesService;

private readonly DispatcherTimer nextReleaseCountdownTimer;


public MainPageViewModel(INavigationService navigationService, IAlertMessageService alertMessageService, IStorageService storageService, IProjectService projectService)
public MainPageViewModel(INavigationService navigationService, IAlertMessageService alertMessageService, IStorageService storageService, IProjectService projectService, ISamplesService samplesService)
{
this.navigationService = navigationService;
this.alertMessageService = alertMessageService;
this.storageService = storageService;
this.projectService = projectService;
this.samplesService = samplesService;

this.RequiresWorkspaceInitialization = this.storageService.RequiresHardStorageInitialization();

this.InitializeWorkspaceCommand = new RelayCommand(this.InitializeWorkspaceCommandExecuteAsync);
this.ProjectSelectedCommand = new RelayCommand<Project>(this.ProjectSelectedCommandExecute);
this.NewProjectCommand = new RelayCommand(this.NewProjectCommandExecute, NewProjectCommandCanExecute);

this.NextReleaseCountdown = (new DateTime(2015, 2, 9, 0, 0, 0)) - DateTime.Now;
this.NextReleaseCountdown = (new DateTime(2015, 2, 16, 0, 0, 0)) - DateTime.Now;
this.nextReleaseCountdownTimer = new DispatcherTimer();
this.nextReleaseCountdownTimer.Interval = TimeSpan.FromSeconds(1);
this.nextReleaseCountdownTimer.Tick += NextReleaseCountdownTimerOnTick;
Expand Down Expand Up @@ -123,9 +125,10 @@ protected async void InitializeWorkspaceCommandExecuteAsync()
{
await this.storageService.InitializeStorageAsync();
this.RequiresWorkspaceInitialization = this.storageService.RequiresHardStorageInitialization();
await this.LoadProjectsAsync();
await this.samplesService.GetSamplesAsync();
await this.LoadProjectsAsync();
this.NewProjectCommand?.RaiseCanExecuteChanged();
}
}

public bool LoadingData
{
Expand Down Expand Up @@ -165,7 +168,7 @@ public bool IsNextReleaseReady
[ComVisible(false)]
public class MainPageViewModelDesignTime : MainPageViewModel
{
public MainPageViewModelDesignTime() : base(null, null, new StorageService(), new ProjectService(new StorageService()))
public MainPageViewModelDesignTime() : base(null, null, new StorageService(), new ProjectService(new StorageService()), null)
{
this.Projects.Add(new Project() { Name = "Project One" });
this.Projects.Add(new Project() { Name = "Project Two" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public PlayPageViewModel(IProjectService projectService, INavigationService navi

private void StopCommandExecute()
{
this.projectPlayStateManager.PauseProject();
this.projectPlayStateManager.StopProject();
this.navigationService.GoBack();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<AdSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CultureDescriptors CultureName="">
<AdDuplex AppId="135231" Probability="0" />
<Smaato AppId="101002420" SecondaryId="1001001131" Probability="100" />
</CultureDescriptors>
</AdSettings>
9 changes: 5 additions & 4 deletions SparkiyClient/SparkiyClient/SparkiyClient.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ protected async override void OnLaunched(LaunchActivatedEventArgs e)
if (!storageService.RequiresHardStorageInitialization())
await storageService.InitializeStorageAsync();

// Navigate to home page if navigation stack isn't restored
if (rootFrame.Content == null)
// Navigate to home page if navigation stack isn't restored
if (rootFrame.Content == null)
navigationService.NavigateTo<MainPage>();

// Ensure the current window is active
Expand Down Expand Up @@ -217,9 +217,10 @@ private void OnContainerRegistration(IUnityContainer container)
this.container.RegisterType<EngineProviderService, EngineProviderService>(new ContainerControlledLifetimeManager());
this.container.RegisterType<IStorageService, StorageService>(new ContainerControlledLifetimeManager());
this.container.RegisterType<IProjectService, ProjectService>(new ContainerControlledLifetimeManager());
this.container.RegisterType<ISamplesService, SamplesService>(new ContainerControlledLifetimeManager());

// Register ViewModels
this.container.RegisterType<IMainPageViewModel, MainPageViewModel>(new PerResolveLifetimeManager());
// Register ViewModels
this.container.RegisterType<IMainPageViewModel, MainPageViewModel>(new PerResolveLifetimeManager());
this.container.RegisterType<IProjectPageViewModel, ProjectPageViewModel>(new PerResolveLifetimeManager());
this.container.RegisterType<IPlayPageViewModel, PlayPageViewModel>(new PerResolveLifetimeManager());

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void AssignProject(Project project)
this.RebuildEngine();
}

private void StopProject()
public void StopProject()
{
this.isInitialized = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,8 @@
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)Assets\sparkiy.png" />
<Content Include="$(MSBuildThisFileDirectory)Controls\CodeEditor\Yellow.png" />
<Content Include="$(MSBuildThisFileDirectory)AdSettings.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
Binary file not shown.
Loading

0 comments on commit 0c76f54

Please sign in to comment.