From 3184fb36c4c17f09c4187548ac7c69a9edf77aa2 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sat, 23 Jun 2012 22:58:57 +0000 Subject: Added setting to reverse joysticks. --- wpspec/wpspec/GamePage.xaml.cs | 32 +++++++++++++++++++-------- wpspec/wpspec/Resources/Strings.Designer.cs | 9 ++++++++ wpspec/wpspec/Resources/Strings.resx | 3 +++ wpspec/wpspec/Settings.cs | 12 ++++++++++ wpspec/wpspec/SettingsPage.xaml | 8 +++++-- wpspec/wpspec/SettingsPage.xaml.cs | 10 --------- wpspec/wpspec/ViewModels/SettingsViewModel.cs | 11 +++++++++ 7 files changed, 64 insertions(+), 21 deletions(-) diff --git a/wpspec/wpspec/GamePage.xaml.cs b/wpspec/wpspec/GamePage.xaml.cs index 5e483d5..0e5bb7e 100644 --- a/wpspec/wpspec/GamePage.xaml.cs +++ b/wpspec/wpspec/GamePage.xaml.cs @@ -111,7 +111,7 @@ namespace wpspec // Initialise locations for normal and zoomed display // location = new Vector2(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width / 2 - Shared.Spectrum.Width / 2, 10); - locationZoomed = new Rectangle(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width / 2 - Shared.Spectrum.Width * 100 / 120, -20, + locationZoomed = new Rectangle(SharedGraphicsDeviceManager.Current.GraphicsDevice.DisplayMode.Width / 2 - Shared.Spectrum.Width * 100 / 120, -52, Shared.Spectrum.Height * 100 / 60, Shared.Spectrum.Width * 100 / 60); // Reset settings @@ -149,14 +149,28 @@ namespace wpspec control.KeyEvent += HandleControlEvent; - joystick = new JoystickDriver(inputManager, - SharedGraphicsDeviceManager.Current.GraphicsDevice, - JoystickType.Digital, - joystickBackgroundImage, joystickImage, joystickButtonImage, - new Vector2(0, 490), - new Vector2(125), - new Vector2[2] {new Vector2(280, 100), new Vector2(380, 125)}, - 20, 75); + if (Settings.Instance.JoystickLeftHanded) + { + joystick = new JoystickDriver(inputManager, + SharedGraphicsDeviceManager.Current.GraphicsDevice, + JoystickType.Digital, + joystickBackgroundImage, joystickImage, joystickButtonImage, + new Vector2(0, 490), + new Vector2(350, 125), + new Vector2[2] {new Vector2(150, 100), new Vector2(50, 125)}, + 30, 75); + } + else + { + joystick = new JoystickDriver(inputManager, + SharedGraphicsDeviceManager.Current.GraphicsDevice, + JoystickType.Digital, + joystickBackgroundImage, joystickImage, joystickButtonImage, + new Vector2(0, 490), + new Vector2(125), + new Vector2[2] {new Vector2(280, 100), new Vector2(380, 125)}, + 30, 75); + } joystick.LockType = Settings.Instance.JoystickLock; diff --git a/wpspec/wpspec/Resources/Strings.Designer.cs b/wpspec/wpspec/Resources/Strings.Designer.cs index bd74210..8e505a0 100644 --- a/wpspec/wpspec/Resources/Strings.Designer.cs +++ b/wpspec/wpspec/Resources/Strings.Designer.cs @@ -451,6 +451,15 @@ namespace wpspec.Resources { } } + /// + /// Looks up a localized string similar to Reserve joystick/buttons. + /// + public static string SettingsJoystickLeftHanded { + get { + return ResourceManager.GetString("SettingsJoystickLeftHanded", resourceCulture); + } + } + /// /// Looks up a localized string similar to Joystick Lock. /// diff --git a/wpspec/wpspec/Resources/Strings.resx b/wpspec/wpspec/Resources/Strings.resx index 9c58111..40ec107 100644 --- a/wpspec/wpspec/Resources/Strings.resx +++ b/wpspec/wpspec/Resources/Strings.resx @@ -304,4 +304,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY Value + + Reserve joystick/buttons + \ No newline at end of file diff --git a/wpspec/wpspec/Settings.cs b/wpspec/wpspec/Settings.cs index 6c6a06c..e87c071 100644 --- a/wpspec/wpspec/Settings.cs +++ b/wpspec/wpspec/Settings.cs @@ -111,6 +111,16 @@ namespace wpspec set {joystickKeyFire2.Setting = value;} } + /// + /// Get/set whether the joystick is left handed. + /// + public bool JoystickLeftHanded + { + get {return joystickLeftHanded.Setting;} + set {joystickLeftHanded.Setting = value;} + } + + /// /// Get singleton instance of this class. /// @@ -134,6 +144,7 @@ namespace wpspec joystickKeyFire1 = new SettingValue("JoystickKeyFire1", SpectrumKeySymbol.Key0); joystickKeyFire2 = new SettingValue("JoystickKeyFire2", SpectrumKeySymbol.Key0); joystickLock = new SettingValue("JoystickLock", JoystickLock.EightWay); + joystickLeftHanded = new SettingValue("JoystickLefthanded", false); #if DEBUG tapeUrl = new SettingValue("tapeurl", "http://noddybox.co.uk/spec"); @@ -201,6 +212,7 @@ namespace wpspec private SettingValue joystickKeyFire2; private SettingValue joystickLock; private SettingValue tapeUrl; + private SettingValue joystickLeftHanded; #endregion } diff --git a/wpspec/wpspec/SettingsPage.xaml b/wpspec/wpspec/SettingsPage.xaml index 9ad95cb..4a3e846 100644 --- a/wpspec/wpspec/SettingsPage.xaml +++ b/wpspec/wpspec/SettingsPage.xaml @@ -35,15 +35,19 @@ + + - + Grid.Row="2" /> + diff --git a/wpspec/wpspec/SettingsPage.xaml.cs b/wpspec/wpspec/SettingsPage.xaml.cs index 98854fa..29ca02d 100644 --- a/wpspec/wpspec/SettingsPage.xaml.cs +++ b/wpspec/wpspec/SettingsPage.xaml.cs @@ -33,15 +33,5 @@ namespace wpspec model.JoystickKeyFire1 = SpectrumKeySymbol.Key0; model.JoystickKeyFire2 = SpectrumKeySymbol.Key0; } - - private void MinerWillyClick(object sender, RoutedEventArgs e) - { - model.JoystickKeyLeft = SpectrumKeySymbol.KeyQ; - model.JoystickKeyUp = SpectrumKeySymbol.KeyEnter; - model.JoystickKeyDown = SpectrumKeySymbol.KeyEnter; - model.JoystickKeyRight = SpectrumKeySymbol.KeyW; - model.JoystickKeyFire1 = SpectrumKeySymbol.KeyEnter; - model.JoystickKeyFire2 = SpectrumKeySymbol.KeySpace; - } } } \ No newline at end of file diff --git a/wpspec/wpspec/ViewModels/SettingsViewModel.cs b/wpspec/wpspec/ViewModels/SettingsViewModel.cs index c7df925..7fb14f8 100644 --- a/wpspec/wpspec/ViewModels/SettingsViewModel.cs +++ b/wpspec/wpspec/ViewModels/SettingsViewModel.cs @@ -103,6 +103,17 @@ namespace wpspec.ViewModels private bool keyboardJoystick = Settings.Instance.KeyboardJoystick; + /// + /// Get/set whether the joystick is left handed. + /// + public bool JoystickLeftHanded + { + get {return joystickLeftHanded;} + set {SetValue(ref joystickLeftHanded, value, "JoystickLeftHanded"); Settings.Instance.JoystickLeftHanded = value;} + } + + private bool joystickLeftHanded = Settings.Instance.JoystickLeftHanded; + /// /// Get/set the joystick lock type. /// -- cgit v1.2.3