public static void Initialize() { System.Console.WriteLine("Loading Input contexts..."); string InputContextFile = Registry.ReadKeyValue("/input_context"); foreach (var Line in InputContextFile.Split(";")) { if (Line.Length < 3 || Line.StartsWith("#")) { System.Console.WriteLine("Skipped blank line"); continue; } string[] LineSplit = Line.Split(","); string ActionName = LineSplit[0]; string ActionKeyboard = LineSplit[1]; string ActionJoypad = LineSplit[2].TrimEnd(); System.Console.WriteLine("Loaded input context {" + ActionName + "}"); InputKeyArguments_key.Add(ActionName); InputKeyArgument NewWax = new InputKeyArgument(ActionName, ActionKeyboard, ActionJoypad); InputKeyArguments.Add(NewWax); } }
public static bool GetInputState(string KeyactionArg, bool KeyDown = false, bool ShowInViewer = false) { if (ShowInViewer) { InputViwer_Define(KeyactionArg); } ; InputKeyArgument Wax = GetInputKeyArg(KeyactionArg); if (Wax == null) { return(false); } // Check for Keyboard switch (CurrentInputMode) { case 0: if (KeyDown) { return(Utils.CheckKeyDown(oldState, Keyboard.GetState(), Wax.KeyObj)); } return(Utils.CheckKeyUp(oldState, Keyboard.GetState(), Wax.KeyObj)); case 1: if (KeyDown) { if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Wax.ThisGamePadButton) && oldPadState.IsButtonDown(Wax.ThisGamePadButton)) { PressedWaxer.Add(KeyactionArg); return(true); } return(false); } if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Wax.ThisGamePadButton) && oldPadState.IsButtonUp(Wax.ThisGamePadButton)) { PressedWaxer.Add(KeyactionArg); return(true); } ; return(false); } return(false); }
private static void DrawIconViewer(SpriteBatch spriteBatch) { spriteBatch.Begin(); //string AllWax = ""; int WaxWax = -1; Vector2 Position = new Vector2(0, 0); foreach (string Wax in Waxer) { WaxWax += 1; int ShowerIndex = InputKeyArguments_key.IndexOf(Wax); if (ShowerIndex == -1) { WaxWax -= 1; continue; } InputKeyArgument Equivalent = InputKeyArguments[ShowerIndex]; Position.X = 5 + WaxWax * 32; Position.Y = spriteBatch.GraphicsDevice.Viewport.Height - InputViwer_AnimationVal; int Opacity = 150; int TextOffset = 10; if (PressedWaxer.IndexOf(Wax) != -1) { Opacity = 255; TextOffset = 7; } spriteBatch.Draw(Sprites.GetSprite("/input_mode/gamepad_indicator/" + Equivalent.GamepadEq + ".png"), Position, color: Color.FromNonPremultiplied(255, 255, 255, Opacity)); if (Registry.KeyExists("/gamepad_actions/" + Wax)) { string ActionWax = Registry.ReadKeyValue("/gamepad_actions/" + Wax); spriteBatch.DrawString(Game1.Reference.Content.Load <SpriteFont>("default"), ActionWax, new Vector2(Position.X, Position.Y - TextOffset), Color.FromNonPremultiplied(230 - TextOffset, Opacity, Opacity, Opacity + 50), -0.7f, Vector2.Zero, 1f, SpriteEffects.None, default); } } spriteBatch.End(); Waxer.Clear(); PressedWaxer.Clear(); }