/// <summary> /// Display an info message dialog in the center of the screen /// </summary> /// /// <param name="title">Dialog title.</param> /// <param name="message">Dialog body text.</param> private static void MessageBoxPanel(string title, string message) { Action prompt = () => { MessageBoxPanel messageBoxPanel = UIView.library .ShowModal <MessageBoxPanel>("MessageBoxPanel"); messageBoxPanel.Find <UILabel>("Message").text = message; messageBoxPanel.Find <UILabel>("Caption").text = title; UIButton uiButton = messageBoxPanel.Find <UIButton>("Close"); if (!uiButton) { return; } uiButton.isVisible = false; }; try { if (TMPELifecycle.InGameOrEditor()) { Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(prompt); } else { prompt(); } } catch (Exception e) { Log.ErrorFormat( "Error displaying a Prompt:\n{0}", e.ToString()); } }
/// <summary> /// When lane routing feature activation is toggled, all junctions /// need to be updated to reflect the change. /// </summary> internal static void UpdateRoutingManager() { if (TMPELifecycle.Instance.Deserializing) { Log._Debug("OptionsManager.UpdateRoutingManager() - Ignoring; Deserialising"); return; } if (TMPELifecycle.InGameOrEditor()) { Log.Info("OptionsManager.UpdateRoutingManager()"); RoutingManager.Instance.RequestFullRecalculation(); } }
/// <summary> /// When dedicated turning lane policy is toggled, all junctions /// need to be checked and updated if necessary. /// </summary> internal static void UpdateDedicatedTurningLanes() { if (TMPELifecycle.Instance.Deserializing) { Log._Debug("Options.UpdateDedicatedTurningLanes() - Waiting for deserialisation"); _needUpdateDedicatedTurningLanes = true; return; } if (TMPELifecycle.InGameOrEditor()) { Log.Info("OptionsManager.UpdateDedicatedTurningLanes()"); LaneArrowManager.Instance.UpdateDedicatedTurningLanePolicy(true); } }
/// <summary> /// When junction restriction policies are toggled, all junctions /// need to reflect the new default settings. /// </summary> internal static void UpdateJunctionRestrictionsManager() { if (TMPELifecycle.Instance.Deserializing) { Log._Debug("Options.UpdateJunctionRestrictionsManager() - Waiting for deserialisation"); _needUpdateJunctionRestrictionsManager = true; return; } if (TMPELifecycle.InGameOrEditor()) { Log.Info("OptionsManager.UpdateJunctionRestrictionsManager()"); JunctionRestrictionsManager.Instance.UpdateAllDefaults(); } }
/// <summary> /// If the game is not loaded and warn is true, will display a warning about options being /// local to each savegame. /// </summary> /// <param name="warn">Whether to display a warning popup</param> /// <returns>The game is loaded</returns> internal static bool IsGameLoaded(bool warn = true) { if (TMPELifecycle.InGameOrEditor()) { return(true); } if (warn) { Prompt.Warning( "Nope!", Translation.Options.Get("Dialog.Text:Settings are stored in savegame") + " https://github.com/CitiesSkylinesMods/TMPE/wiki/Settings"); } return(false); }
/// <summary> /// Display an exception message in the center of the screen, optionally /// styled as an error. /// </summary> /// /// <param name="title">Dialog title.</param> /// <param name="message">Dialog body text.</param> /// <param name="isError">If <c>true</c>, the dialog is styled as an error.</param> private static void ExceptionPanel(string title, string message, bool isError) { Action prompt = () => { UIView.library .ShowModal <ExceptionPanel>("ExceptionPanel") .SetMessage(title, message, isError); }; try { if (TMPELifecycle.InGameOrEditor()) { Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(prompt); } else { prompt(); } } catch (Exception e) { Log.ErrorFormat( "Error displaying a Prompt:\n{0}", e.ToString()); } }
internal static void MakeSettings_Maintenance(ExtUITabstrip tabStrip) { UIHelper panelHelper = tabStrip.AddTabPage(Translation.Options.Get("Tab:Maintenance")); UIHelperBase maintenanceGroup = panelHelper.AddGroup(T("Tab:Maintenance")); _resetStuckEntitiesBtn = maintenanceGroup.AddButton( T("Maintenance.Button:Reset stuck cims and vehicles"), onClickResetStuckEntities) as UIButton; _removeParkedVehiclesBtn = maintenanceGroup.AddButton( T("Maintenance.Button:Remove parked vehicles"), OnClickRemoveParkedVehicles) as UIButton; _removeAllExistingTrafficLightsBtn = maintenanceGroup.AddButton( T("Maintenance.Button:Remove all existing traffic lights"), OnClickRemoveAllExistingTrafficLights) as UIButton; #if DEBUG _resetSpeedLimitsBtn = maintenanceGroup.AddButton( T("Maintenance.Button:Reset custom speed limits"), OnClickResetSpeedLimits) as UIButton; #endif _reloadGlobalConfBtn = maintenanceGroup.AddButton( T("Maintenance.Button:Reload global configuration"), OnClickReloadGlobalConf) as UIButton; _resetGlobalConfBtn = maintenanceGroup.AddButton( T("Maintenance.Button:Reset global configuration"), OnClickResetGlobalConf) as UIButton; #if QUEUEDSTATS _showPathFindStatsToggle = maintenanceGroup.AddCheckbox( T("Maintenance.Checkbox:Show path-find stats"), Options.showPathFindStats, OnShowPathFindStatsChanged) as UICheckBox; #endif var featureGroup = panelHelper.AddGroup(T("Maintenance.Group:Activated features")) as UIHelper; EnablePrioritySignsToggle = featureGroup.AddCheckbox( T("Checkbox:Priority signs"), Options.prioritySignsEnabled, OnPrioritySignsEnabledChanged) as UICheckBox; EnableTimedLightsToggle = featureGroup.AddCheckbox( T("Checkbox:Timed traffic lights"), Options.timedLightsEnabled, OnTimedLightsEnabledChanged) as UICheckBox; _enableCustomSpeedLimitsToggle = featureGroup.AddCheckbox( T("Checkbox:Speed limits"), Options.customSpeedLimitsEnabled, OnCustomSpeedLimitsEnabledChanged) as UICheckBox; _enableVehicleRestrictionsToggle = featureGroup.AddCheckbox( T("Checkbox:Vehicle restrictions"), Options.vehicleRestrictionsEnabled, OnVehicleRestrictionsEnabledChanged) as UICheckBox; _enableParkingRestrictionsToggle = featureGroup.AddCheckbox( T("Checkbox:Parking restrictions"), Options.parkingRestrictionsEnabled, OnParkingRestrictionsEnabledChanged) as UICheckBox; _enableJunctionRestrictionsToggle = featureGroup.AddCheckbox( T("Checkbox:Junction restrictions"), Options.junctionRestrictionsEnabled, OnJunctionRestrictionsEnabledChanged) as UICheckBox; _turnOnRedEnabledToggle = featureGroup.AddCheckbox( T("Maintenance.Checkbox:Turn on red"), Options.turnOnRedEnabled, OnTurnOnRedEnabledChanged) as UICheckBox; _enableLaneConnectorToggle = featureGroup.AddCheckbox( T("Maintenance.Checkbox:Lane connector"), Options.laneConnectorEnabled, OnLaneConnectorEnabledChanged) as UICheckBox; Options.Indent(_turnOnRedEnabledToggle); // TODO [issue ##959] remove when TTL is implemented in asset editor. bool inEditor = TMPELifecycle.InGameOrEditor() && TMPELifecycle.AppMode != AppMode.Game; if (inEditor) { EnableTimedLightsToggle.isChecked = false; EnableTimedLightsToggle.isEnabled = false; // since this is temprory I don't want to go through the trouble of creating translation key. EnableTimedLightsToggle.tooltip = "TTL is not yet supported in asset editor"; } }
public bool MayPublishSegmentChanges() { return(Options.instantEffects && TMPELifecycle.InGameOrEditor() && !TMPELifecycle.Instance.Deserializing); }