Skip to content

Commit

Permalink
Merge branch 'feature-info'
Browse files Browse the repository at this point in the history
  • Loading branch information
dymanoid committed Aug 4, 2018
2 parents 9eb2bf7 + 5d7676e commit 1407aa0
Show file tree
Hide file tree
Showing 18 changed files with 550 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/RealTime/Core/RealTimeCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public static RealTimeCore Run(ConfigurationProvider<RealTimeConfig> configProvi
SimulationHandler.Buildings.InitializeLightState();
SimulationHandler.Statistics = statistics;

WorldInfoPanelPatches.CitizenInfoPanel = CustomCitizenInfoPanel.Enable(ResidentAIPatch.RealTimeAI, localizationProvider);
WorldInfoPanelPatches.VehicleInfoPanel = CustomVehicleInfoPanel.Enable(ResidentAIPatch.RealTimeAI, localizationProvider);

AwakeSleepSimulation.Install(configProvider.Configuration);

result.storageData.Add(eventManager);
Expand Down Expand Up @@ -214,6 +217,12 @@ public void Stop()
SimulationHandler.Statistics?.Close();
SimulationHandler.Statistics = null;

WorldInfoPanelPatches.CitizenInfoPanel?.Disable();
WorldInfoPanelPatches.CitizenInfoPanel = null;

WorldInfoPanelPatches.VehicleInfoPanel?.Disable();
WorldInfoPanelPatches.VehicleInfoPanel = null;

isEnabled = false;
}

Expand Down Expand Up @@ -249,6 +258,7 @@ private static IEnumerable<IPatch> GetMethodPatches()
ResidentAIPatch.ArriveAtTarget,
TouristAIPatch.Location,
TransferManagerPatch.AddOutgoingOffer,
WorldInfoPanelPatches.UpdateBindings,
UIGraphPatches.MinDataPoints,
UIGraphPatches.VisibleEndTime,
UIGraphPatches.BuildLabels
Expand Down Expand Up @@ -325,7 +335,7 @@ private static bool SetupCustomAI(

private static void CustomTimeBarCityEventClick(object sender, CustomTimeBarClickEventArgs e)
{
CameraHelper.NavigateToBuilding(e.CityEventBuildingId);
CameraHelper.NavigateToBuilding(e.CityEventBuildingId, true);
}

private static void LoadStorageData(IEnumerable<IStorageData> storageData, StorageBase storage)
Expand Down
15 changes: 15 additions & 0 deletions src/RealTime/CustomAI/RealTimeResidentAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,20 @@ public IStorageData GetStorageService()
{
return new CitizenScheduleStorage(residentSchedules, CitizenMgr.GetCitizensArray(), TimeInfo);
}

/// <summary>Gets the citizen schedule. Note that the method returns the reference
/// and thus doesn't prevent changing the schedule.</summary>
/// <param name="citizenId">The ID of the citizen to get the schedule for.</param>
/// <returns>The original schedule of the citizen.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="citizenId"/> is 0.</exception>
public ref CitizenSchedule GetCitizenSchedule(uint citizenId)
{
if (citizenId == 0)
{
throw new ArgumentOutOfRangeException(nameof(citizenId), citizenId, "The citizen ID cannot be 0");
}

return ref residentSchedules[citizenId];
}
}
}
55 changes: 55 additions & 0 deletions src/RealTime/GameConnection/Patches/WorldInfoPanelPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// <copyright file="WorldInfoPanelPatches.cs" company="dymanoid">
// Copyright (c) dymanoid. All rights reserved.
// </copyright>

namespace RealTime.GameConnection.Patches
{
using System;
using System.Reflection;
using RealTime.UI;
using SkyTools.Patching;

/// <summary>
/// A static class that provides the patch objects for the world info panel game methods.
/// </summary>
internal static class WorldInfoPanelPatches
{
/// <summary>Gets or sets the customized citizen information panel.</summary>
public static CustomCitizenInfoPanel CitizenInfoPanel { get; set; }

/// <summary>Gets or sets the customized vehicle information panel.</summary>
public static CustomVehicleInfoPanel VehicleInfoPanel { get; set; }

/// <summary>Gets the patch for the update bindings method.</summary>
public static IPatch UpdateBindings { get; } = new WorldInfoPanel_UpdateBindings();

private sealed class WorldInfoPanel_UpdateBindings : PatchBase
{
protected override MethodInfo GetMethod()
{
return typeof(WorldInfoPanel).GetMethod(
"UpdateBindings",
BindingFlags.Instance | BindingFlags.NonPublic,
null,
new Type[0],
new ParameterModifier[0]);
}

#pragma warning disable SA1313 // Parameter names must begin with lower-case letter
private static void Postfix(WorldInfoPanel __instance, ref InstanceID ___m_InstanceID)
{
switch (__instance)
{
case CitizenWorldInfoPanel _:
CitizenInfoPanel?.UpdateCustomInfo(ref ___m_InstanceID);
break;

case VehicleWorldInfoPanel _:
VehicleInfoPanel?.UpdateCustomInfo(ref ___m_InstanceID);
break;
}
}
#pragma warning restore SA1313 // Parameter names must begin with lower-case letter
}
}
}
12 changes: 12 additions & 0 deletions src/RealTime/Localization/TranslationKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,17 @@ internal static class TranslationKeys

/// <summary>The key for the abbreviated 'minutes' text.</summary>
public const string Minutes = "Minutes";

/// <summary>The key for the scheduled action text.</summary>
public const string ScheduledAction = "ScheduledAction";

/// <summary>The key for the next scheduled action text.</summary>
public const string NextScheduledAction = "NextScheduledAction";

/// <summary>The key for the work shift text.</summary>
public const string WorkShiftKey = "WorkShift";

/// <summary>The key for the vacation text.</summary>
public const string WorkStatusOnVacation = "WorkStatus.OnVacation";
}
}
13 changes: 13 additions & 0 deletions src/RealTime/Localization/Translations/de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@
<translation id="MaxVacationLength" value="Max. Urlaubstage" />
<translation id="MaxVacationLengthTooltip" value="Wie viele Tage maximal können Cims im Urlaub sein. Setzen Sie den Wert auf 0, um Urlaub zu deaktivieren." />

<translation id="ScheduledAction" value="Geplant" />
<translation id="NextScheduledAction" value="Zunächst" />
<translation id="ScheduledAction.AtHome" value="Nach hause" />
<translation id="ScheduledAction.AtSchoolOrWork" value="Arbeiten/studieren" />
<translation id="ScheduledAction.Shopping" value="Einkaufen" />
<translation id="ScheduledAction.Relaxing" value="Entspannen" />
<translation id="ScheduledAction.Visiting" value="Besuchen" />
<translation id="ScheduledAction.InShelter" value="Bunker" />
<translation id="WorkShift.First" value="1. Schicht" />
<translation id="WorkShift.Second" value="2. Schicht" />
<translation id="WorkShift.Night" value="Nachtschicht" />
<translation id="WorkStatus.OnVacation" value="(Urlaub: {0} Tage)" />

<overrides type="Units">
<translation id="AIINFO_COAL_STORED" value="Kohle gespeichert für {0} × {unit}"/>
<translation id="AIINFO_CUMULATIVEUPKEEP" value="Unterhalt: {0} + {1} / {unit} / Zelle"/>
Expand Down
13 changes: 13 additions & 0 deletions src/RealTime/Localization/Translations/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@
<translation id="MaxVacationLength" value="Maximum vacation days" />
<translation id="MaxVacationLengthTooltip" value="For how long citizens can be on vacation. Set to 0 to disable vacations." />

<translation id="ScheduledAction" value="Scheduled" />
<translation id="NextScheduledAction" value="Next" />
<translation id="ScheduledAction.AtHome" value="Go home" />
<translation id="ScheduledAction.AtSchoolOrWork" value="Go to work/school" />
<translation id="ScheduledAction.Shopping" value="Go shopping" />
<translation id="ScheduledAction.Relaxing" value="Go relaxing" />
<translation id="ScheduledAction.Visiting" value="Go visit" />
<translation id="ScheduledAction.InShelter" value="Go to shelter" />
<translation id="WorkShift.First" value="1st work shift" />
<translation id="WorkShift.Second" value="2nd work shift" />
<translation id="WorkShift.Night" value="Night work shift" />
<translation id="WorkStatus.OnVacation" value="(vacation: {0} days)" />

<overrides type="Units">
<translation id="AIINFO_COAL_STORED" value="Coal stored for {0} × {unit}"/>
<translation id="AIINFO_CUMULATIVEUPKEEP" value="Upkeep: {0} + {1} / {unit} / cell"/>
Expand Down
13 changes: 13 additions & 0 deletions src/RealTime/Localization/Translations/es.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@
<translation id="MaxVacationLength" value="Maximum vacation days" />
<translation id="MaxVacationLengthTooltip" value="For how long citizens can be on vacation. Set to 0 to disable vacations." />

<translation id="ScheduledAction" value="Scheduled" />
<translation id="NextScheduledAction" value="Next" />
<translation id="ScheduledAction.AtHome" value="Go home" />
<translation id="ScheduledAction.AtSchoolOrWork" value="Go to work/school" />
<translation id="ScheduledAction.Shopping" value="Go shopping" />
<translation id="ScheduledAction.Relaxing" value="Go relaxing" />
<translation id="ScheduledAction.Visiting" value="Go visit" />
<translation id="ScheduledAction.InShelter" value="Go to shelter" />
<translation id="WorkShift.First" value="1st work shift" />
<translation id="WorkShift.Second" value="2nd work shift" />
<translation id="WorkShift.Night" value="Night work shift" />
<translation id="WorkStatus.OnVacation" value="(vacation: {0} days)" />

<overrides type="Units">
<translation id="AIINFO_COAL_STORED" value="Coal stored for {0} × {unit}"/>
<translation id="AIINFO_CUMULATIVEUPKEEP" value="Upkeep: {0} + {1} / {unit} / cell"/>
Expand Down
13 changes: 13 additions & 0 deletions src/RealTime/Localization/Translations/fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@
<translation id="MaxVacationLength" value="Maximum vacation days" />
<translation id="MaxVacationLengthTooltip" value="For how long citizens can be on vacation. Set to 0 to disable vacations." />

<translation id="ScheduledAction" value="Scheduled" />
<translation id="NextScheduledAction" value="Next" />
<translation id="ScheduledAction.AtHome" value="Go home" />
<translation id="ScheduledAction.AtSchoolOrWork" value="Go to work/school" />
<translation id="ScheduledAction.Shopping" value="Go shopping" />
<translation id="ScheduledAction.Relaxing" value="Go relaxing" />
<translation id="ScheduledAction.Visiting" value="Go visit" />
<translation id="ScheduledAction.InShelter" value="Go to shelter" />
<translation id="WorkShift.First" value="1st work shift" />
<translation id="WorkShift.Second" value="2nd work shift" />
<translation id="WorkShift.Night" value="Night work shift" />
<translation id="WorkStatus.OnVacation" value="(vacation: {0} days)" />

<overrides type="Units">
<translation id="AIINFO_COAL_STORED" value="Coal stored for {0} × {unit}"/>
<translation id="AIINFO_CUMULATIVEUPKEEP" value="Upkeep: {0} + {1} / {unit} / cell"/>
Expand Down
13 changes: 13 additions & 0 deletions src/RealTime/Localization/Translations/ko.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@
<translation id="MaxVacationLength" value="최대 휴가 일시" />
<translation id="MaxVacationLengthTooltip" value="시민들이 얼마나 휴가를 떠나는지를 나타냅니다. 0으로 설정할시 휴가를 가지 않게 됩니다." />

<translation id="ScheduledAction" value="Scheduled" />
<translation id="NextScheduledAction" value="Next" />
<translation id="ScheduledAction.AtHome" value="Go home" />
<translation id="ScheduledAction.AtSchoolOrWork" value="Go to work/school" />
<translation id="ScheduledAction.Shopping" value="Go shopping" />
<translation id="ScheduledAction.Relaxing" value="Go relaxing" />
<translation id="ScheduledAction.Visiting" value="Go visit" />
<translation id="ScheduledAction.InShelter" value="Go to shelter" />
<translation id="WorkShift.First" value="1st work shift" />
<translation id="WorkShift.Second" value="2nd work shift" />
<translation id="WorkShift.Night" value="Night work shift" />
<translation id="WorkStatus.OnVacation" value="(vacation: {0} days)" />

<overrides type="Units">
<translation id="AIINFO_COAL_STORED" value="석탄이 {0} × {unit} 저장됨"/>
<translation id="AIINFO_CUMULATIVEUPKEEP" value="유지비: {0} + {1} / {unit} / 셀"/>
Expand Down
13 changes: 13 additions & 0 deletions src/RealTime/Localization/Translations/pl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@
<translation id="MaxVacationLength" value="Maximum vacation days" />
<translation id="MaxVacationLengthTooltip" value="For how long citizens can be on vacation. Set to 0 to disable vacations." />

<translation id="ScheduledAction" value="Scheduled" />
<translation id="NextScheduledAction" value="Next" />
<translation id="ScheduledAction.AtHome" value="Go home" />
<translation id="ScheduledAction.AtSchoolOrWork" value="Go to work/school" />
<translation id="ScheduledAction.Shopping" value="Go shopping" />
<translation id="ScheduledAction.Relaxing" value="Go relaxing" />
<translation id="ScheduledAction.Visiting" value="Go visit" />
<translation id="ScheduledAction.InShelter" value="Go to shelter" />
<translation id="WorkShift.First" value="1st work shift" />
<translation id="WorkShift.Second" value="2nd work shift" />
<translation id="WorkShift.Night" value="Night work shift" />
<translation id="WorkStatus.OnVacation" value="(vacation: {0} days)" />

<overrides type="Units">
<translation id="AIINFO_COAL_STORED" value="Coal stored for {0} × {unit}"/>
<translation id="AIINFO_CUMULATIVEUPKEEP" value="Upkeep: {0} + {1} / {unit} / cell"/>
Expand Down
13 changes: 13 additions & 0 deletions src/RealTime/Localization/Translations/pt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@
<translation id="MaxVacationLength" value="Maximum vacation days" />
<translation id="MaxVacationLengthTooltip" value="For how long citizens can be on vacation. Set to 0 to disable vacations." />

<translation id="ScheduledAction" value="Scheduled" />
<translation id="NextScheduledAction" value="Next" />
<translation id="ScheduledAction.AtHome" value="Go home" />
<translation id="ScheduledAction.AtSchoolOrWork" value="Go to work/school" />
<translation id="ScheduledAction.Shopping" value="Go shopping" />
<translation id="ScheduledAction.Relaxing" value="Go relaxing" />
<translation id="ScheduledAction.Visiting" value="Go visit" />
<translation id="ScheduledAction.InShelter" value="Go to shelter" />
<translation id="WorkShift.First" value="1st work shift" />
<translation id="WorkShift.Second" value="2nd work shift" />
<translation id="WorkShift.Night" value="Night work shift" />
<translation id="WorkStatus.OnVacation" value="(vacation: {0} days)" />

<overrides type="Units">
<translation id="AIINFO_COAL_STORED" value="Coal stored for {0} × {unit}"/>
<translation id="AIINFO_CUMULATIVEUPKEEP" value="Upkeep: {0} + {1} / {unit} / cell"/>
Expand Down
13 changes: 13 additions & 0 deletions src/RealTime/Localization/Translations/ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@
<translation id="MaxVacationLength" value="Максимум дней отпуска" />
<translation id="MaxVacationLengthTooltip" value="Сколько дней отпуска горожане могут максимально взять. Установите 0, чтобы отключить отпуска." />

<translation id="ScheduledAction" value="Запланировано" />
<translation id="NextScheduledAction" value="След." />
<translation id="ScheduledAction.AtHome" value="Домой" />
<translation id="ScheduledAction.AtSchoolOrWork" value="На работу/в школу" />
<translation id="ScheduledAction.Shopping" value="Покупки" />
<translation id="ScheduledAction.Relaxing" value="Развлечения" />
<translation id="ScheduledAction.Visiting" value="В гости" />
<translation id="ScheduledAction.InShelter" value="В убежище" />
<translation id="WorkShift.First" value="Первая смена" />
<translation id="WorkShift.Second" value="Вторая смена" />
<translation id="WorkShift.Night" value="Ночная смена" />
<translation id="WorkStatus.OnVacation" value="(отпуск: {0} дн.)" />

<overrides type="Units">
<translation id="AIINFO_COAL_STORED" value="Запасов угля на {0} × {unit}"/>
<translation id="AIINFO_CUMULATIVEUPKEEP" value="Содержание: {0} + {1} / {unit} / клетка"/>
Expand Down
13 changes: 13 additions & 0 deletions src/RealTime/Localization/Translations/zh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@
<translation id="MaxVacationLength" value="Maximum vacation days" />
<translation id="MaxVacationLengthTooltip" value="For how long citizens can be on vacation. Set to 0 to disable vacations." />

<translation id="ScheduledAction" value="Scheduled" />
<translation id="NextScheduledAction" value="Next" />
<translation id="ScheduledAction.AtHome" value="Go home" />
<translation id="ScheduledAction.AtSchoolOrWork" value="Go to work/school" />
<translation id="ScheduledAction.Shopping" value="Go shopping" />
<translation id="ScheduledAction.Relaxing" value="Go relaxing" />
<translation id="ScheduledAction.Visiting" value="Go visit" />
<translation id="ScheduledAction.InShelter" value="Go to shelter" />
<translation id="WorkShift.First" value="1st work shift" />
<translation id="WorkShift.Second" value="2nd work shift" />
<translation id="WorkShift.Night" value="Night work shift" />
<translation id="WorkStatus.OnVacation" value="(vacation: {0} days)" />

<overrides type="Units">
<translation id="AIINFO_COAL_STORED" value="Coal stored for {0} × {unit}"/>
<translation id="AIINFO_CUMULATIVEUPKEEP" value="Upkeep: {0} + {1} / {unit} / cell"/>
Expand Down
4 changes: 4 additions & 0 deletions src/RealTime/RealTime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<Compile Include="GameConnection\Patches\TransferManagerPatch.cs" />
<Compile Include="GameConnection\Patches\UIGraphPatches.cs" />
<Compile Include="GameConnection\Patches\WeatherManagerPatch.cs" />
<Compile Include="GameConnection\Patches\WorldInfoPanelPatches.cs" />
<Compile Include="GameConnection\TouristAIConnection.cs" />
<Compile Include="GameConnection\Patches\TouristAIPatch.cs" />
<Compile Include="GameConnection\Patches\ResidentAIPatch.cs" />
Expand Down Expand Up @@ -148,9 +149,12 @@
<Compile Include="Simulation\TimeAdjustment.cs" />
<Compile Include="GameConnection\TimeInfo.cs" />
<Compile Include="LogCategory.cs" />
<Compile Include="UI\CustomCitizenInfoPanel.cs" />
<Compile Include="UI\CustomTimeBarClickEventArgs.cs" />
<Compile Include="UI\ConfigUI.cs" />
<Compile Include="UI\CustomVehicleInfoPanel.cs" />
<Compile Include="UI\DateTooltipBehavior.cs" />
<Compile Include="UI\RealTimeInfoPanelBase.cs" />
<Compile Include="UI\RealTimeUIDateTimeWrapper.cs" />
<Compile Include="UI\CustomTimeBar.cs" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 1407aa0

Please sign in to comment.