/// <summary> /// Enables the time bar customization. If the customization is already enabled, has no effect. /// </summary> /// <param name="currentDate">The current game date to set as the time bar's initial value.</param> public void Enable(DateTime currentDate) { if (originalWrapper != null) { Log.Warning("Trying to enable the CustomTimeBar multiple times."); return; } customDateTimeWrapper = new RealTimeUIDateTimeWrapper(currentDate); originalWrapper = SetUIDateTimeWrapper(customDateTimeWrapper, true); }
/// <summary> /// Enables the time bar customization. If the customization is already enabled, has no effect. /// </summary> /// <param name="currentDate">The current game date to set as the time bar's initial value.</param> public void Enable(DateTime currentDate) { if (originalWrapper != null) { Log.Warning("Trying to enable the CustomTimeBar multiple times."); return; } customDateTimeWrapper = new RealTimeUIDateTimeWrapper(currentDate); originalWrapper = SetCustomUIDateTimeWrapper(customDateTimeWrapper, enableWrapper: true); SetEventColorUpdater(progressSprite, enableUpdater: true); }
public static bool CheckPrefix(ref UIDateTimeWrapper __instance, DateTime newVal, ref DateTime ___m_Value, ref string ___m_String) { if (UserModSettings.Settings.Enabled && UserModSettings.Settings.DateTimeBar_Modify) { ___m_Value = newVal; ___m_String = ___m_Value.ToString(UserModSettings.Settings.Time_24Hour ? "dddd HH:mm" : "ddd hh:mm tt"); return(false); } return(true); }
/// <summary> /// Disables the time bar configuration. If the customization is already disabled or was not /// enabled, has no effect. /// </summary> public void Disable() { if (originalWrapper == null) { return; } RemoveAllCityEvents(); SetUIDateTimeWrapper(originalWrapper, false); originalWrapper = null; progressSprite = null; customDateTimeWrapper = null; }
/// <summary> /// Disables the time bar configuration. If the customization is already disabled or was not /// enabled, has no effect. /// </summary> public void Disable() { if (originalWrapper == null) { return; } RemoveAllCityEvents(); SetCustomUIDateTimeWrapper(originalWrapper, enableWrapper: false); SetEventColorUpdater(progressSprite, enableUpdater: false); originalWrapper = null; progressSprite = null; customDateTimeWrapper = null; }
private UIDateTimeWrapper SetCustomUIDateTimeWrapper(UIDateTimeWrapper wrapper, bool enableWrapper) { UIPanel infoPanel = UIView.Find <UIPanel>(UIInfoPanel); if (infoPanel == null) { Log.Warning("No UIPanel found: " + UIInfoPanel); return(null); } progressSprite = GetProgressSprite(infoPanel); if (progressSprite != null) { SetCustomTooltip(progressSprite, currentCulture, enableWrapper); SetCustomTimePanelLayout(progressSprite, enableWrapper); } return(ReplaceUIDateTimeWrapperInPanel(infoPanel, wrapper)); }
private UIDateTimeWrapper SetUIDateTimeWrapper(UIDateTimeWrapper wrapper, bool customize) { UIPanel infoPanel = UIView.Find <UIPanel>(UIInfoPanel); if (infoPanel == null) { Log.Warning("No UIPanel found: " + UIInfoPanel); return(null); } progressSprite = GetProgressSprite(infoPanel); if (progressSprite != null) { SetTooltip(progressSprite, currentCulture, customize); if (customize) { CustomizeTimePanel(progressSprite); } } return(ReplaceUIDateTimeWrapperInPanel(infoPanel, wrapper)); }
private static UIDateTimeWrapper ReplaceUIDateTimeWrapperInPanel(UIPanel infoPanel, UIDateTimeWrapper wrapper) { Bindings bindings = infoPanel.GetUIView().GetComponent <Bindings>(); if (bindings == null) { Log.Warning($"The UIPanel '{UIInfoPanel}' contains no '{nameof(Bindings)}' component"); return(null); } FieldInfo field = typeof(Bindings).GetField(UIWrapperField, BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance); if (field == null) { Log.Warning($"The UIPanel {UIInfoPanel} has no field '{UIWrapperField}'"); return(null); } var originalWrapper = field.GetValue(bindings) as UIDateTimeWrapper; if (originalWrapper == null) { Log.Warning($"The '{nameof(Bindings)}' component has no '{nameof(UIDateTimeWrapper)}'"); return(null); } field.SetValue(bindings, wrapper); return(originalWrapper); }