/********* ** Private methods *********/ /// <summary>The method invoked when the player presses an input button.</summary> /// <typeparam name="TKey">The input type.</typeparam> /// <param name="key">The pressed input.</param> /// <param name="map">The configured input mapping.</param> private void ReceiveKeyPress <TKey>(TKey key, InputMapConfiguration <TKey> map) { if (!map.IsValidKey(key)) { return; } // perform bound action this.Monitor.InterceptErrors("handling your input", $"handling input '{key}'", () => { if (key.Equals(map.ToggleMap)) { if (this.CurrentOverlay != null) { this.CurrentOverlay.Dispose(); this.CurrentOverlay = null; } else { this.CurrentOverlay = new TraversableOverlay(); } this.Monitor.Log($"set overlay: {this.CurrentOverlay?.GetType().Name ?? "none"}", LogLevel.Trace); } }); }
/// <summary>The method invoked when the player presses an input button.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void InputEvents_ButtonPressed(object sender, EventArgsInput e) { // perform bound action this.Monitor.InterceptErrors("handling your input", $"handling input '{e.Button}'", () => { // check context if (!this.CanOverlayNow()) { return; } bool overlayVisible = this.CurrentOverlay != null; var controls = this.Config.Controls; // toggle overlay if (controls.ToggleMap.Contains(e.Button)) { if (overlayVisible) { this.CurrentOverlay.Dispose(); this.CurrentOverlay = null; } else { this.CurrentOverlay = new DataMapOverlay(this.Maps, this.CanOverlayNow, this.Config.CombineOverlappingBorders); } e.SuppressButton(); } // cycle data maps else if (overlayVisible && controls.NextMap.Contains(e.Button)) { this.CurrentOverlay.NextMap(); e.SuppressButton(); } else if (overlayVisible && controls.PrevMap.Contains(e.Button)) { this.CurrentOverlay.PrevMap(); e.SuppressButton(); } }); }
/********* ** Private methods *********/ /// <summary>The method invoked when the player presses an input button.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void InputEvents_ButtonPressed(object sender, EventArgsInput e) { // perform bound action this.Monitor.InterceptErrors("handling your input", $"handling input '{e.Button}'", () => { var controls = this.Config.Controls; if (controls.ToggleMap.Contains(e.Button)) { if (this.CurrentOverlay != null) { this.CurrentOverlay.Dispose(); this.CurrentOverlay = null; } else { this.CurrentOverlay = new TraversableOverlay(); } this.Monitor.Log($"set overlay: {this.CurrentOverlay?.GetType().Name ?? "none"}", LogLevel.Trace); } }); }
/// <summary>The method invoked when the player returns to the title screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void SaveEvents_AfterReturnToTitle(object sender, EventArgs e) { this.CurrentOverlay?.Dispose(); this.CurrentOverlay = null; }