From 6bef56432282b2d2604ad5764faf71c985262666 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sat, 9 Jun 2012 22:28:39 +0000 Subject: Changing settings page to a panorama page, and in progress for setting definable keyboard joystick. --- wpspec/wpspec/Resources/Strings.Designer.cs | 87 ++++++++++++++- wpspec/wpspec/Resources/Strings.resx | 31 +++++- wpspec/wpspec/Settings.cs | 58 +++++----- wpspec/wpspec/SettingsPage.xaml | 160 ++++++++++++++++++---------- wpspec/wpspec/Spectrum/Emulation.cs | 14 ++- wpspec/wpspec/wpspec.csproj | 1 + 6 files changed, 262 insertions(+), 89 deletions(-) diff --git a/wpspec/wpspec/Resources/Strings.Designer.cs b/wpspec/wpspec/Resources/Strings.Designer.cs index 44e24e3..e0ff595 100644 --- a/wpspec/wpspec/Resources/Strings.Designer.cs +++ b/wpspec/wpspec/Resources/Strings.Designer.cs @@ -433,6 +433,69 @@ namespace wpspec.Resources { } } + /// + /// Looks up a localized string similar to Keyboard. + /// + public static string SettingsKeyboardJoystick { + get { + return ResourceManager.GetString("SettingsKeyboardJoystick", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Down. + /// + public static string SettingsKeyDown { + get { + return ResourceManager.GetString("SettingsKeyDown", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fire 1. + /// + public static string SettingsKeyFire1 { + get { + return ResourceManager.GetString("SettingsKeyFire1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fire 2. + /// + public static string SettingsKeyFire2 { + get { + return ResourceManager.GetString("SettingsKeyFire2", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Left. + /// + public static string SettingsKeyLeft { + get { + return ResourceManager.GetString("SettingsKeyLeft", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Right. + /// + public static string SettingsKeyRight { + get { + return ResourceManager.GetString("SettingsKeyRight", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Up. + /// + public static string SettingsKeyUp { + get { + return ResourceManager.GetString("SettingsKeyUp", resourceCulture); + } + } + /// /// Looks up a localized string similar to Miner Willy. /// @@ -443,11 +506,29 @@ namespace wpspec.Resources { } /// - /// Looks up a localized string similar to Settings. + /// Looks up a localized string similar to Joysticks. + /// + public static string SettingsPageTitleJoystick { + get { + return ResourceManager.GetString("SettingsPageTitleJoystick", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sound. + /// + public static string SettingsPageTitleSound { + get { + return ResourceManager.GetString("SettingsPageTitleSound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Tapes. /// - public static string SettingsPageTitle { + public static string SettingsPageTitleTapes { get { - return ResourceManager.GetString("SettingsPageTitle", resourceCulture); + return ResourceManager.GetString("SettingsPageTitleTapes", resourceCulture); } } diff --git a/wpspec/wpspec/Resources/Strings.resx b/wpspec/wpspec/Resources/Strings.resx index 8751701..8dd4f93 100644 --- a/wpspec/wpspec/Resources/Strings.resx +++ b/wpspec/wpspec/Resources/Strings.resx @@ -214,8 +214,8 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY Ignore MIME type of tape files - - Settings + + Tapes Sound @@ -268,4 +268,31 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY Joysticks + + Joysticks + + + Sound + + + Keyboard + + + Fire 1 + + + Fire 2 + + + Down + + + Left + + + Right + + + Up + \ No newline at end of file diff --git a/wpspec/wpspec/Settings.cs b/wpspec/wpspec/Settings.cs index 872384f..45d8a90 100644 --- a/wpspec/wpspec/Settings.cs +++ b/wpspec/wpspec/Settings.cs @@ -11,13 +11,15 @@ using System.Windows.Shapes; using System.IO.IsolatedStorage; using System.Collections.Generic; using Noddybox.Emulation.Xna.Input.Joystick; +using wpspec.Spectrum; +using wpspec.ViewModels; namespace wpspec { /// /// Holds global settings /// - public class Settings + public class Settings : BaseViewModel { /// /// Get/set whether sound is enabled. @@ -56,21 +58,12 @@ namespace wpspec } /// - /// Get/set whether cursor joystick emulation is enabled. + /// Get/set whether a keyboard-based joystick emulation is enabled. /// - public bool CursorJoystick + public bool KeyboardJoystick { - get {return cursorJoystick.Setting;} - set {cursorJoystick.Setting = value;} - } - - /// - /// Get/set whether joystick emulation for pressing Manic Miner-style keys is enabled. - /// - public bool ManicJoystick - { - get {return manicJoystick.Setting;} - set {manicJoystick.Setting = value;} + get {return keyboardJoystick.Setting;} + set {keyboardJoystick.Setting = value;} } /// @@ -96,17 +89,22 @@ namespace wpspec private Settings() { - sound = new SettingValue("sound", true); - kempstonJoystick = new SettingValue("kempstonJoystick", true); - fullerJoystick = new SettingValue("fullerJoystick", true); - cursorJoystick = new SettingValue("cursorJoystick", false); - manicJoystick = new SettingValue("manicJoystick", false); - joystickLock = new SettingValue("joystickLock", JoystickLock.EightWay); + sound = new SettingValue("Sound", true, this); + kempstonJoystick = new SettingValue("KempstonJoystick", true, this); + fullerJoystick = new SettingValue("FullerJoystick", true, this); + keyboardJoystick = new SettingValue("KeyboardJoystick", false, this); + joystickKeyUp = new SettingValue("JoystickKeyUp", SpectrumKeySymbol.Key7, this); + joystickKeyDown = new SettingValue("JoystickKeyDown", SpectrumKeySymbol.Key6, this); + joystickKeyLeft = new SettingValue("JoystickKeyLeft", SpectrumKeySymbol.Key5, this); + joystickKeyRight = new SettingValue("JoystickKeyRight", SpectrumKeySymbol.Key8, this); + joystickKeyFire1 = new SettingValue("JoystickKeyFire1", SpectrumKeySymbol.Key0, this); + joystickKeyFire2 = new SettingValue("JoystickKeyFire2", SpectrumKeySymbol.Key0, this); + joystickLock = new SettingValue("JoystickLock", JoystickLock.EightWay, this); #if DEBUG - tapeUrl = new SettingValue("tapeurl", "http://noddybox.co.uk/spec"); + tapeUrl = new SettingValue("tapeurl", "http://noddybox.co.uk/spec", this); #else - tapeUrl = new SettingValue("tapeurl", "http://enter-a-url.here/possible-path"); + tapeUrl = new SettingValue("tapeurl", "http://enter-a-url.here/possible-path", this); #endif } @@ -114,6 +112,7 @@ namespace wpspec { private string name; private T setting; + private Settings parent; public T Setting { @@ -138,13 +137,15 @@ namespace wpspec } IsolatedStorageSettings.ApplicationSettings.Save(); + parent.NotifyPropertyChanged(name); } } } - public SettingValue(string name, T defaultValue) + public SettingValue(string name, T defaultValue, Settings parent) { this.name = name; + this.parent = parent; try { @@ -154,14 +155,21 @@ namespace wpspec { setting = defaultValue; } + + parent.NotifyPropertyChanged(name); } } private SettingValue sound; private SettingValue kempstonJoystick; private SettingValue fullerJoystick; - private SettingValue cursorJoystick; - private SettingValue manicJoystick; + private SettingValue keyboardJoystick; + private SettingValue joystickKeyUp; + private SettingValue joystickKeyDown; + private SettingValue joystickKeyLeft; + private SettingValue joystickKeyRight; + private SettingValue joystickKeyFire1; + private SettingValue joystickKeyFire2; private SettingValue joystickLock; private SettingValue tapeUrl; diff --git a/wpspec/wpspec/SettingsPage.xaml b/wpspec/wpspec/SettingsPage.xaml index af2fb4d..6c12dda 100644 --- a/wpspec/wpspec/SettingsPage.xaml +++ b/wpspec/wpspec/SettingsPage.xaml @@ -4,6 +4,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" + xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:res="clr-namespace:wpspec.Resources" @@ -19,75 +20,120 @@ + - - - - + - - - - - + + + + + + + + + + + + + + Eight Way + Four Way + Two Way Horizontal + Two Way Vertical + + + + + + + + + + + + + + + Test 1 + Test 2 + Test 3 + Test 4 + + + Test 1 + Test 2 + Test 3 + Test 4 + + + Test 1 + Test 2 + Test 3 + Test 4 + + + Test 1 + Test 2 + Test 3 + Test 4 + + + Test 1 + Test 2 + Test 3 + Test 4 + + + Test 1 + Test 2 + Test 3 + Test 4 + + + + + - - - - - - - - - - - - - - + + + - - - Eight Way - Four Way - Two Way Horizontal - Two Way Vertical - - - + + + + + + - - - - - - + + - - + + diff --git a/wpspec/wpspec/Spectrum/Emulation.cs b/wpspec/wpspec/Spectrum/Emulation.cs index 11e84f2..ac01a31 100644 --- a/wpspec/wpspec/Spectrum/Emulation.cs +++ b/wpspec/wpspec/Spectrum/Emulation.cs @@ -73,6 +73,8 @@ namespace wpspec.Spectrum private readonly byte[] mem = new byte[0x10000]; private readonly Clock clock = new Clock(0, 224, 312, 0); + // Keyboard matrix. The 9th entry is used to store the joystick state. + // private readonly byte[] matrix = new byte[9]; private readonly Dictionary matrixLookup; @@ -574,8 +576,16 @@ namespace wpspec.Spectrum /// The state of the buttons. public void Joystick(DigitalJoystickState state, bool[] buttons) { - joystickState = state; - joystickButtons = buttons; + matrix[8] = (byte)state; + + if (buttons[0] || buttons[1]) + { + matrix[8] |= 0x10; + } + + if (Settings.Instance.KeyboardJoystick) + { + } } /// diff --git a/wpspec/wpspec/wpspec.csproj b/wpspec/wpspec/wpspec.csproj index 0b7e639..5795046 100644 --- a/wpspec/wpspec/wpspec.csproj +++ b/wpspec/wpspec/wpspec.csproj @@ -49,6 +49,7 @@ + -- cgit v1.2.3