Thursday, April 19, 2012

Wow - PlayStationSuite Open Beta - C# on the PS Vita

Someone tweeted about this -  http://www.playstation.com/pss/developer/index_e.html

So I downloaded it and had thirty minutes of playtime :)

Here's a video of my experience: http://youtu.be/FSZl1-FvUgE





Firstly I played with the UI Composer (designer) - and set up a tip calc like display (like the one in https://github.com/slodge/MvvmCross/ for MonoTouch, MonoDroid, WP7 and WinRT)

It was easy to do - just drag and drop the UI elements, then set their properties, including the generated variable name to use.

When finished, I just hit "Build" in the designer - this spits out:
  • a language csv resource file
  • a C# wrapper for that resource file
  • a scene.cs file - just a partial class with a constructor - this then becomes your "view controller" file for you to edit as you please
  • a scene.composer.cs file - this contains the generated code for the rest of the partial class - basically lots of layout code which matches what you drew in the designer


With that done I then I opened the main PSS Studio (looks and feels like MonoDevelop)

In this studio I:
- ran the new project wizard
- followed the simple instructions in the bundled help file to add the high level ui reference to the project and to add a little code (3 lines?) to help it render
- used project|add to add the files generated above
- tweaked the BuildAction Property for the Csv file to 'content'
- used the monodevelop editor to add the code for tipCalc - this was normal C# code:





using System;
using System.Collections.Generic;
using Sce.Pss.Core;
using Sce.Pss.Core.Imaging;
using Sce.Pss.Core.Environment;
using Sce.Pss.HighLevel.UI;
 
namespace PssUI1
{
    public partial class Scene1 : Scene
    {
        public Scene1()
        {
            InitializeWidget();
   HookThingsUp();
  }
  
  private void HookThingsUp()
  {
   SliderPercent.ValueChanged += (s, e) => {
    TipPercentText.Text = ((int)e.Value).ToString();
    Recalc();
   };
   TipPercentText.TextChanged += (s, e) => {
    SliderPercent.Value = int.Parse(TipPercentText.Text);
    Recalc();
   };
   TotalText.TextChanged += (s, e) => {
    Recalc();
   };
   Recalc();
  }
  
  private void Recalc()
  {
   var total = double.Parse(TotalText.Text);
   var tip = SliderPercent.Value * total / 100.0;
   total += tip;
   this.TipLabel.Text = tip.ToString();
   this.TotalLabel.Text = total.ToString(); 
  } 
    }
}


That was it!

Then I could hit F5 and the code ran in a PS Vita simulator:

That was it!

:) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :)

 
For a full blow by blow video: 
http://youtu.be/FSZl1-FvUgE


Really impressed - good job Mono (Xamarin?) and Sony - really good job :)

2 comments: