protected override void UpdateImpl() { this.Alpha = AnimationUtility.IncreaseAlpha(this.Alpha); contentSprite.Position = new SharpDX.Vector2(AnimationUtility.GetAnimationValue(contentSprite.Position.X, -currentPageIndex * 800), 0); left.Alpha = currentPageIndex != 0 ? AnimationUtility.IncreaseAlpha(left.Alpha) : AnimationUtility.DecreaseAlpha(left.Alpha); if (clickedTextButton != null) { bool found = false; if (myGame.Input.GetPressedButton(out int button)) { keyConfig.SetButtonMap((ButtonType)clickedTextButton.Index, button); buttons[clickedTextButton.Index].Text = button.ToString(); found = true; } if (myGame.Input.GetPressedKey(out Key key)) { keyConfig.SetKeyMap((ButtonType)clickedTextButton.Index, key); keys[clickedTextButton.Index].Text = key.ToString(); found = true; } if (found) { clickedTextButton.Text = Utility.Language["Change"]; clickedTextButton = null; myGame.Input.AssignMode = false; } } }
protected override void UpdateImpl() { if (myGame.Input.AssignMode) { bool found = false; if (myGame.Input.GetPressedButton(out int button)) { keyConfig.SetButtonMap((ButtonType)clickedTextButton.Index, button); buttons[clickedTextButton.Index].Text = button.ToString(); found = true; } if (myGame.Input.GetPressedKey(out Key key)) { keyConfig.SetKeyMap((ButtonType)clickedTextButton.Index, key); keys[clickedTextButton.Index].Text = key.ToString(); found = true; } if (found) { DisableAssignMode(); } } if (clickedTextButton != null && !myGame.Input.AssignMode) { myGame.Input.AssignMode = true; } select.Position = new SharpDX.Vector2(select.Position.X, AnimationUtility.GetAnimationValue(select.Position.Y, currentIndex * 30 + 90, 0.2f)); }
private void ReadKeySettingFromIni(string fileName) { var keyConfig = new KeyConfig(); var sr = new StreamReader(fileName); var s = sr.ReadToEnd().Replace("\r\n", "\n").Replace("\r", "\n"); sr.Close(); var sp = s.Split('\n'); for (int i = 0; i < Math.Min(sp.Length, ButtonUtility.Array.Length); i++) { var secondsp = sp[i].Split(':'); if (secondsp.Length >= 2) { keyConfig.SetKeyMap(ButtonUtility.Array[i], (Key)int.Parse(secondsp[0])); keyConfig.SetButtonMap(ButtonUtility.Array[i], int.Parse(secondsp[1])); } } keyConfigs.Add(keyConfig); }
private void ReadKeySetting(XmlReader reader, KeyConfig keyConfig) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.LocalName) { case "Config": var key = (Key)int.Parse(reader.GetAttribute("Key")); int button = int.Parse(reader.GetAttribute("Button")), index = FindIndex(reader.GetAttribute("Type")); if (index >= 0) { keyConfig.SetKeyMap(ButtonUtility.Array[index], key); keyConfig.SetButtonMap(ButtonUtility.Array[index], button); } break; } } } reader.Close(); }