Skip to content

Commit

Permalink
Merge branch 'hotfix-1.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dymanoid committed Jul 7, 2018
2 parents 102438e + c55e2eb commit ae03912
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 13 deletions.
3 changes: 0 additions & 3 deletions src/RealTime/Core/RealTimeCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace RealTime.Core
{
using System;
using System.Collections.Generic;
using System.Security.Permissions;
using RealTime.Config;
using RealTime.CustomAI;
using RealTime.Events;
Expand Down Expand Up @@ -54,7 +53,6 @@ private RealTimeCore(TimeAdjustment timeAdjustment, CustomTimeBar timeBar, RealT
///
/// <returns>A <see cref="RealTimeCore"/> instance that can be used to stop the mod.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "This is the entry point and needs to instantiate all parts")]
[PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
public static RealTimeCore Run(RealTimeConfig config, string rootPath, LocalizationProvider localizationProvider)
{
if (config == null)
Expand Down Expand Up @@ -147,7 +145,6 @@ public static RealTimeCore Run(RealTimeConfig config, string rootPath, Localizat
/// <summary>
/// Stops the mod by deactivating all its parts.
/// </summary>
[PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
public void Stop()
{
if (!isEnabled)
Expand Down
9 changes: 6 additions & 3 deletions src/RealTime/Core/RealTimeMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace RealTime.Core
{
using System;
using System.Linq;
using System.Security.Permissions;
using ColossalFramework;
using ColossalFramework.Globalization;
using ColossalFramework.Plugins;
Expand Down Expand Up @@ -94,7 +93,6 @@ public void OnSettingsUI(UIHelperBase helper)
/// </summary>
///
/// <param name="mode">The <see cref="LoadMode"/> a game level is loaded in.</param>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void OnLevelLoaded(LoadMode mode)
{
switch (mode)
Expand All @@ -110,13 +108,18 @@ public override void OnLevelLoaded(LoadMode mode)
}

core = RealTimeCore.Run(config, modPath, localizationProvider);
if (core == null)
{
MessageBox.Show(
localizationProvider.Translate(TranslationKeys.Warning),
localizationProvider.Translate(TranslationKeys.ModNotWorkingMessage));
}
}

/// <summary>
/// Called when a game level is about to be unloaded. If the Real Time mod was activated
/// for this level, deactivates the mod for this level.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void OnLevelUnloading()
{
if (core != null)
Expand Down
3 changes: 0 additions & 3 deletions src/RealTime/Localization/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ internal static class Constants
/// <summary>The placeholder string.</summary>
public const string Placeholder = "Placeholder";

/// <summary>The tool tip string.</summary>
public const string Tooltip = "Tooltip";

/// <summary>The 'no locale' placeholder string.</summary>
public const string NoLocale = "No Locale found";

Expand Down
21 changes: 21 additions & 0 deletions src/RealTime/Localization/TranslationKeys.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// <copyright file="TranslationKeys.cs" company="dymanoid">
// Copyright (c) dymanoid. All rights reserved.
// </copyright>

namespace RealTime.Localization
{
/// <summary>
/// A class containing constant string values that describe keys of the strings to be translated in various languages.
/// </summary>
internal static class TranslationKeys
{
/// <summary>The tool tip string.</summary>
public const string Tooltip = "Tooltip";

/// <summary>The warning key.</summary>
public const string Warning = "Warning";

/// <summary>The key for a 'mod not working' message.</summary>
public const string ModNotWorkingMessage = "ModNotWorkingMessage";
}
}
3 changes: 3 additions & 0 deletions src/RealTime/Localization/Translations/de.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="de" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="Warning" value="Warnung" />
<translation id="ModNotWorkingMessage" value="Oh je! Etwas ist schief gelaufen - die Mod 'Real Time' kann nicht aktiviert werden. Bitte zeigen Sie das Log-File von Cities:Skylines dem Entwickler." />

<translation id="Tools" value="Tools" />
<translation id="ResetToDefaults" value="Alle Optionen zurücksetzen" />

Expand Down
3 changes: 3 additions & 0 deletions src/RealTime/Localization/Translations/en.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="en" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="Warning" value="Warning" />
<translation id="ModNotWorkingMessage" value="Oops! Something went wrong - the 'Real Time' mod could not be activated. Please share your game log file with the mod's developer." />

<translation id="Tools" value="Tools" />
<translation id="ResetToDefaults" value="Reset all to defaults" />

Expand Down
5 changes: 4 additions & 1 deletion src/RealTime/Localization/Translations/es.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="es" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="Warning" value="Warning" />
<translation id="ModNotWorkingMessage" value="Oops! Something went wrong - the 'Real Time' mod could not be activated. Please share your game log file with the mod's developer." />

<translation id="Tools" value="Herramientas" />
<translation id="ResetToDefaults" value="Restablecer todo por defecto" />

<translation id="1General" value="General" />
<translation id="DayTimeSpeed" value="Velocidad del tiempo (día)" />
<translation id="DayTimeSpeedTooltip" value="La velocidad a la que fluye el tiempo diurno. '1' es muy lento, ¡casi en tiempo real!" />
<translation id="NightTimeSpeed" value="Velocidad del tiempo (noche)" />
Expand All @@ -16,7 +20,6 @@
<translation id="VirtualCitizens.Few" value="Casi todos los ciudadanos reales" />
<translation id="VirtualCitizens.Vanilla" value="Como en juego Original" />
<translation id="VirtualCitizens.Many" value="Más ciudadanos virtuales" />
<translation id="1General" value="General" />
<translation id="IsWeekendEnabled" value="Activar Fines de Semana" />
<translation id="IsWeekendEnabledTooltip" value="Los ciudadanos no van al trabajo ni a la escuela los fines de semana" />
<translation id="IsLunchtimeEnabled" value="Activar hora de Almorzar" />
Expand Down
3 changes: 3 additions & 0 deletions src/RealTime/Localization/Translations/fr.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="fr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="Warning" value="Warning" />
<translation id="ModNotWorkingMessage" value="Oops! Something went wrong - the 'Real Time' mod could not be activated. Please share your game log file with the mod's developer." />

<translation id="Tools" value="Tools" />
<translation id="ResetToDefaults" value="Reset all to defaults" />

Expand Down
3 changes: 3 additions & 0 deletions src/RealTime/Localization/Translations/ko.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="ko" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="Warning" value="Warning" />
<translation id="ModNotWorkingMessage" value="Oops! Something went wrong - the 'Real Time' mod could not be activated. Please share your game log file with the mod's developer." />

<translation id="Tools" value="Tools" />
<translation id="ResetToDefaults" value="Reset all to defaults" />

Expand Down
3 changes: 3 additions & 0 deletions src/RealTime/Localization/Translations/pl.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="pl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="Warning" value="Warning" />
<translation id="ModNotWorkingMessage" value="Oops! Something went wrong - the 'Real Time' mod could not be activated. Please share your game log file with the mod's developer." />

<translation id="Tools" value="Tools" />
<translation id="ResetToDefaults" value="Reset all to defaults" />

Expand Down
3 changes: 3 additions & 0 deletions src/RealTime/Localization/Translations/pt.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="pt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="Warning" value="Warning" />
<translation id="ModNotWorkingMessage" value="Oops! Something went wrong - the 'Real Time' mod could not be activated. Please share your game log file with the mod's developer." />

<translation id="Tools" value="Tools" />
<translation id="ResetToDefaults" value="Reset all to defaults" />

Expand Down
3 changes: 3 additions & 0 deletions src/RealTime/Localization/Translations/ru.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="ru" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="Warning" value="Предупреждение" />
<translation id="ModNotWorkingMessage" value="Упс! Что-то пошло не так - мод 'Real Time' не может быть активирован. Пожалуйста, покажите лог-файл игры разработчику мода." />

<translation id="Tools" value="Утилиты" />
<translation id="ResetToDefaults" value="Вернуть опции по умолчанию" />

Expand Down
3 changes: 3 additions & 0 deletions src/RealTime/Localization/Translations/zh.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<language id="zh" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<translation id="Warning" value="Warning" />
<translation id="ModNotWorkingMessage" value="Oops! Something went wrong - the 'Real Time' mod could not be activated. Please share your game log file with the mod's developer." />

<translation id="Tools" value="Tools" />
<translation id="ResetToDefaults" value="Reset all to defaults" />

Expand Down
2 changes: 2 additions & 0 deletions src/RealTime/RealTime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<Compile Include="GameConnection\WeatherManagerConnection.cs" />
<Compile Include="Localization\Constants.cs" />
<Compile Include="Localization\LocalizationProvider.cs" />
<Compile Include="Localization\TranslationKeys.cs" />
<Compile Include="Patching\FastDelegate.cs" />
<Compile Include="Patching\MethodPatcher.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down Expand Up @@ -143,6 +144,7 @@
<Compile Include="UI\IValueViewItem.cs" />
<Compile Include="UI\IViewItem.cs" />
<Compile Include="UI\IViewItemFactory.cs" />
<Compile Include="UI\MessageBox.cs" />
<Compile Include="UI\RealTimeUIDateTimeWrapper.cs" />
<Compile Include="UI\CustomTimeBar.cs" />
<Compile Include="UI\SliderValueType.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/RealTime/UI/CitiesCheckBoxItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void Translate(LocalizationProvider localizationProvider)
}

UIComponent.text = localizationProvider.Translate(UIComponent.name);
UIComponent.tooltip = localizationProvider.Translate(UIComponent.name + Constants.Tooltip);
UIComponent.tooltip = localizationProvider.Translate(UIComponent.name + TranslationKeys.Tooltip);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/RealTime/UI/CitiesComboBoxItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public override void Translate(LocalizationProvider localizationProvider)
throw new ArgumentNullException(nameof(localizationProvider));
}

UIComponent.tooltip = localizationProvider.Translate(UIComponent.name + Constants.Tooltip);
UIComponent.tooltip = localizationProvider.Translate(UIComponent.name + TranslationKeys.Tooltip);

UILabel label = UIComponent.parent?.Find<UILabel>(LabelName);
if (label != null)
Expand Down
2 changes: 1 addition & 1 deletion src/RealTime/UI/CitiesSliderItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public override void Translate(LocalizationProvider localizationProvider)
return;
}

panel.tooltip = localizationProvider.Translate(UIComponent.name + Constants.Tooltip);
panel.tooltip = localizationProvider.Translate(UIComponent.name + TranslationKeys.Tooltip);

UILabel label = panel.Find<UILabel>(LabelName);
if (label != null)
Expand Down
24 changes: 24 additions & 0 deletions src/RealTime/UI/MessageBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// <copyright file="MessageBox.cs" company="dymanoid">
// Copyright (c) dymanoid. All rights reserved.
// </copyright>

namespace RealTime.UI
{
using ColossalFramework.UI;

/// <summary>
/// Displays a message box that can contain text that informs and instructs the user.
/// </summary>
internal static class MessageBox
{
private const string DialogPanelName = "ExceptionPanel";

/// <summary>Displays a message box with specified text and caption.</summary>
/// <param name="caption">The caption of the message to display.</param>
/// <param name="message">The message text.</param>
public static void Show(string caption, string message)
{
UIView.library.ShowModal<ExceptionPanel>(DialogPanelName).SetMessage(caption ?? string.Empty, message ?? string.Empty, false);
}
}
}

0 comments on commit ae03912

Please sign in to comment.