Skip to content

Commit

Permalink
Updated call sites to use Prompt
Browse files Browse the repository at this point in the history
Not updated the `LoadingExtension` because PRs #773 and #699 will be changing it.
  • Loading branch information
originalfoo committed Mar 3, 2020
1 parent 5024bd5 commit 3ad3c5f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 37 deletions.
9 changes: 3 additions & 6 deletions TLM/TLM/State/Keybinds/KeybindUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace TrafficManager.State.Keybinds {
using System;
using TrafficManager.UI;
using UnityEngine;
using TrafficManager.UI.Helpers;

/// <summary>
/// Helper for creating keyboard bindings Settings page.
Expand Down Expand Up @@ -219,9 +220,7 @@ private void OnBindingKeyDown(UIComponent comp, UIKeyEventParameter evParam) {
var message = Translation.Options.Get("Keybinds.Dialog.Text:Keybind conflict")
+ "\n\n" + maybeConflict;
Log.Info($"Keybind conflict: {message}");
UIView.library
.ShowModal<ExceptionPanel>("ExceptionPanel")
.SetMessage("Key Conflict", message, false);
Prompt.Warning("Key Conflict", message);
} else {
editedBinding.Value.TargetKey.value = inputKey;
editedBinding.Value.Target.NotifyKeyChanged();
Expand Down Expand Up @@ -257,9 +256,7 @@ private void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter evParam)
var message = Translation.Options.Get("Keybinds.Dialog.Text:Keybind conflict")
+ "\n\n" + maybeConflict;
Log.Info($"Keybind conflict: {message}");
UIView.library
.ShowModal<ExceptionPanel>("ExceptionPanel")
.SetMessage("Key Conflict", message, false);
Prompt.Warning("Key Conflict", message);
} else {
editedBinding.Value.TargetKey.value = inputKey;
editedBinding.Value.Target.NotifyKeyChanged();
Expand Down
12 changes: 2 additions & 10 deletions TLM/TLM/ThreadingExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace TrafficManager {
using TrafficManager.State;
using TrafficManager.UI;
using UnityEngine;
using TrafficManager.UI.Helpers;

[UsedImplicitly]
public sealed class ThreadingExtension : ThreadingExtensionBase {
Expand Down Expand Up @@ -98,16 +99,7 @@ public override void OnBeforeSimulationFrame() {
Log.Info(log);

if (GlobalConfig.Instance.Main.ShowCompatibilityCheckErrorMessage) {
Singleton<SimulationManager>.instance.m_ThreadingWrapper.QueueMainThread(
() => {
UIView
.library
.ShowModal<ExceptionPanel>(
"ExceptionPanel").SetMessage(
"Incompatibility Issue",
error,
true);
});
Prompt.Error("TM:PE Incompatibility Issue", error);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions TLM/TLM/UI/SubTools/ManualTrafficLightsTool.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace TrafficManager.UI.SubTools {
namespace TrafficManager.UI.SubTools {
using ColossalFramework;
using JetBrains.Annotations;
using TrafficLight;
using TrafficManager.API.Manager;
using TrafficManager.API.Traffic.Data;
using TrafficManager.API.Traffic.Enums;
Expand Down Expand Up @@ -62,8 +61,7 @@ ref Singleton<NetManager>.instance.m_nodes.m_buffer[
// }
// }
} else {
MainTool.ShowError(
Translation.TrafficLights.Get("Dialog.Text:Node has timed TL script"));
MainTool.WarningPrompt(Translation.TrafficLights.Get("Dialog.Text:Node has timed TL script"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion TLM/TLM/UI/SubTools/PrioritySignsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ private bool MayNodeHavePrioritySigns(ushort nodeId) {
// Log._Debug($"PrioritySignsTool.MayNodeHavePrioritySigns: Node {nodeId} does not
// allow priority signs: {reason}");
if (reason == SetPrioritySignError.HasTimedLight) {
MainTool.ShowError(
MainTool.WarningPrompt(
Translation.TrafficLights.Get("Dialog.Text:Node has timed TL script"));
}

Expand Down
11 changes: 6 additions & 5 deletions TLM/TLM/UI/SubTools/TimedTrafficLightsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public override void OnPrimaryClickOverlay() {
bool ctrlDown = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
if(ctrlDown) {
AutoTimedTrafficLights.ErrorResult res = AutoTimedTrafficLights.Setup(HoveredNodeId);
string message = null;
string message = null;

switch (res) {
case AutoTimedTrafficLights.ErrorResult.NotSupported:
MainTool.Guide.Activate("TimedTrafficLightsTool_Auto TL no need");
Expand All @@ -126,7 +127,7 @@ public override void OnPrimaryClickOverlay() {
Translation.TrafficLights.Get("Dialog.Text:Auto TL create failed because") +
"\n" +
Translation.TrafficLights.Get(message);
MainTool.ShowError(message);
MainTool.WarningPrompt(message);
return;
}
RefreshCurrentTimedNodeIds(HoveredNodeId);
Expand Down Expand Up @@ -160,7 +161,7 @@ public override void OnPrimaryClickOverlay() {
MainTool.SetToolMode(ToolMode.TimedLightsShowLights);
}
} else {
MainTool.ShowError(T("Dialog.Text:Node has timed TL script"));
MainTool.WarningPrompt(T("Dialog.Text:Node has timed TL script"));
}
}

Expand Down Expand Up @@ -242,14 +243,14 @@ public override void OnPrimaryClickOverlay() {
.CountSegments();

if (numSourceSegments != numTargetSegments) {
MainTool.ShowError(
MainTool.WarningPrompt(
T("Dialog.Text:Incompatible traffic light script"));
return;
}

// check for existing simulation
if (tlsMan.HasTimedSimulation(HoveredNodeId)) {
MainTool.ShowError(
MainTool.WarningPrompt(
T("Dialog.Text:Node has timed TL script"));
return;
}
Expand Down
4 changes: 2 additions & 2 deletions TLM/TLM/UI/SubTools/ToggleTrafficLightsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public void ToggleTrafficLight(ushort nodeId,
if (showMessageOnError) {
switch (reason) {
case ToggleTrafficLightError.HasTimedLight: {
MainTool.ShowError(
MainTool.WarningPrompt(
Translation.TrafficLights.Get("Dialog.Text:Node has timed TL script"));
break;
}

case ToggleTrafficLightError.IsLevelCrossing: {
MainTool.ShowError(
MainTool.WarningPrompt(
Translation.TrafficLights.Get("Dialog.Text:Node is level crossing"));
break;
}
Expand Down
19 changes: 10 additions & 9 deletions TLM/TLM/UI/TrafficManagerTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ namespace TrafficManager.UI {
using JetBrains.Annotations;
using TrafficManager.Manager.Impl;
using TrafficManager.State;
#if DEBUG
using TrafficManager.State.ConfigData;
#endif
using TrafficManager.UI.MainMenu;
using TrafficManager.UI.SubTools;
using TrafficManager.UI.SubTools.SpeedLimits;
using TrafficManager.Util;
using UnityEngine;
using TrafficManager.UI.Helpers;
using GenericGameBridge.Service;
using CitiesGameBridge.Service;

[UsedImplicitly]
public class TrafficManagerTool
Expand Down Expand Up @@ -1871,16 +1871,17 @@ internal bool CheckClicked() {
return false;
}

/// <summary>Displays modal popup with an error</summary>
/// <param name="text">The localized message</param>
public void ShowError(string text) {
if (text == null) {
/// <summary>
/// Displays a warning prompt in center of the screen.
/// </summary>
///
/// <param name="message">The localized body text of the prompt.</param>
public void WarningPrompt(string message) {
if (string.IsNullOrEmpty(message)) {
return;
}

UIView.library
.ShowModal<ExceptionPanel>("ExceptionPanel")
.SetMessage("Info", text, false);
Prompt.Warning("Warning", message);
}
}
}

0 comments on commit 3ad3c5f

Please sign in to comment.