public static void LoadControls() { InitDefaultControls(); if (IO.FileExists("controls.xml") == false) { SaveControls(); } using (XmlReader reader = XmlReader.Create(Paths.StartupPath + "controls.xml")) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "Up": { UpKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.UpArrow); } break; case "Down": { DownKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.DownArrow); } break; case "Left": { LeftKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.LeftArrow); } break; case "Right": { RightKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.RightArrow); } break; case "Turn": { TurnKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.Home); } break; case "Run": { RunKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.LeftShift); } break; //case "StandardAttack": { // AttackKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.Z); // } // break; } } } } }
protected override int procKeyEvent(SdlDotNet.Input.Key key) { if (key == SdlDotNet.Input.Key.Return) { return(0); } return(-1); }
public static void InitDefaultControls() { UpKey = SdlInput.Key.UpArrow; DownKey = SdlInput.Key.DownArrow; LeftKey = SdlInput.Key.LeftArrow; RightKey = SdlInput.Key.RightArrow; TurnKey = SdlInput.Key.Home; RunKey = SdlInput.Key.LeftShift; AttackKey = SdlInput.Key.F; }
public static void LoadControls() { InitDefaultControls(); if (IO.FileExists("controls.xml") == false) { SaveControls(); } using (XmlReader reader = XmlReader.Create(Paths.StartupPath + "controls.xml")) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "Up": { UpKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.UpArrow); } break; case "Down": { DownKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.DownArrow); } break; case "Left": { LeftKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.LeftArrow); } break; case "Right": { RightKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.RightArrow); } break; case "Turn": { TurnKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.Home); } break; case "Run": { RunKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.LeftShift); } break; //case "StandardAttack": { // AttackKey = (SdlInput.Key)reader.ReadString().ToInt((int)SdlInput.Key.Z); // } // break; } } } } }
public static void InitDefaultControls() { UpKey = SdlInput.Key.UpArrow; DownKey = SdlInput.Key.DownArrow; LeftKey = SdlInput.Key.LeftArrow; RightKey = SdlInput.Key.RightArrow; TurnKey = SdlInput.Key.Home; RunKey = SdlInput.Key.LeftShift; AttackKey = SdlInput.Key.F; }
protected override int procKeyEvent(SdlDotNet.Input.Key key) { int idx = -1; switch (key) { case Key.UpArrow: { switch (_state) { case SelectionState.Device: if (_devRects.Length > 0) { _devSelectedIdx = (_devSelectedIdx - 1 < 0 ? (_devSelectedIdx + _devRects.Length - 1) : _devSelectedIdx - 1) % _devRects.Length; updateDevicesIndex(); idx = 2; } break; case SelectionState.Calibration: stopCalibration(); if (_calSelectedIdx == 0) { _state = SelectionState.Back; } _calSelectedIdx = _calSelectedIdx - 1; break; case SelectionState.Back: _state = SelectionState.Calibration; _calSelectedIdx = _calRects.Length - 1; break; } } break; case Key.DownArrow: { switch (_state) { case SelectionState.Device: if (_devRects.Length > 0) { _devSelectedIdx = (_devSelectedIdx + 1) % _devRects.Length; updateDevicesIndex(); idx = 2; } break; case SelectionState.Calibration: stopCalibration(); if (_calSelectedIdx == _calRects.Length - 1) { _calSelectedIdx = -1; _state = SelectionState.Back; } else { _calSelectedIdx = (_calSelectedIdx + 1) % _calRects.Length; } break; case SelectionState.Back: _calSelectedIdx = 0; _state = SelectionState.Calibration; break; } } break; case Key.RightArrow: case Key.LeftArrow: { switch (_state) { case SelectionState.Device: _state = SelectionState.Calibration; if (_calSelectedIdx < 0) { _calSelectedIdx = 0; } break; case SelectionState.Calibration: stopCalibration(); _state = SelectionState.Device; break; case SelectionState.Back: _state = SelectionState.Device; break; } } break; case Key.Return: switch (_state) { case SelectionState.Device: //_state = SelectionState.Calibration; break; case SelectionState.Calibration: break; case SelectionState.Back: idx = 0; break; } break; case Key.Escape: stopCalibration(); idx = 3; break; } return(idx); }