コード例 #1
0
        // A quick method to make the Run History UI re-fetch runs.
        private static void UpdateHistoryUI(RunHistoryScreen screen)
        {
            RunHistoryUI ui    = Traverse.Create(screen).Field("runHistoryUI").GetValue <RunHistoryUI>();
            MethodInfo   fetch = ui.GetType().GetMethod("FetchGameRuns", BindingFlags.NonPublic | BindingFlags.Instance);

            fetch.Invoke(ui, new object[] { 1 });
        }
コード例 #2
0
 public static void Postfix(ref RunHistoryScreen __instance, ref SaveManager saveManager)
 {
     // Only do this if the elements are actually usable
     if (CustomUIManager.AreTemplatesUsable())
     {
         // Add a few UI elements. TODO: Currenty, these are added directly to the screen. It might be nicer to add
         // them to the screen's content, but I'm too lazy for it right now.
         CustomUIManager.AddLabelToComponent(__instance, "Apply Filters:", 170, 145, 200, 50);
         AdvancedRunHistory.applyFiltersToggle      = CustomUIManager.AddToggleToComponent(__instance, "ApplyFiltersToggle", 310, 146);
         AdvancedRunHistory.applyFiltersToggle.isOn = AdvancedRunHistory.filterManager.Active;
         AdvancedRunHistory.openFilterDialogButton  = CustomUIManager.AddButtonToComponent(__instance, "OpenFilterScreenButton", "Edit Filters", 570, 140, 250, 60);
         // If the Filter dialog has not yet been created, do so. Otherwise, reinitalize it.
         if (AdvancedRunHistory.filterDialog == null)
         {
             AdvancedRunHistory.filterDialog = new RunFilterDialog(__instance, saveManager, AdvancedRunHistory.filterManager);
         }
         else
         {
             AdvancedRunHistory.filterDialog.Reinit(__instance);
         }
     }
     else
     {
         AdvancedRunHistory.Log("At least one UI template has not been initalized successfully", LogLevel.Error);
     }
 }
コード例 #3
0
 /// <summary>
 /// Create a new filter dialog.
 /// </summary>
 /// <param name="parent">The container for this dialog. This probably doesn't need to be the RunHistoryScreen,
 /// but it seems reasonable to be. Should contain a child named "Content"</param>
 /// <param name="saveManager">The main game's save manager.</param>
 /// <param name="filterManager">The filter manager. Should be empty when this constructor is called.</param>
 public RunFilterDialog(RunHistoryScreen parent, SaveManager saveManager, FilterManager filterManager)
 {
     this.saveManager   = saveManager;
     this.filterManager = filterManager;
     // (a little fail-safe to avoid duplicate filters in the filter manager if the constructor is called again)
     filterManager.Clear();
     Reinit(parent);
 }
コード例 #4
0
 /// <summary>
 /// Reinitalize the dialog. Use this if the dialog has already been created, but the UI elements have been
 /// destroyed due to a screen transition.
 /// </summary>
 /// <param name="parent">The container for this dialog, see <see cref="RunFilterDialog.RunFilterDialog"/></param>
 public void Reinit(RunHistoryScreen parent)
 {
     this.dialog = CustomUIManager.CreateCustomDialog(parent, "FilterDialog", "Run Data Filters");
     content     = dialog.transform.Find("Content");
     dropdowns   = new List <GameUISelectableDropdown>();
     sliders     = new List <SelectableSliderHelper>();
     MakeOutcomeFilter(firstColumn, firstLine);
     MakeRunTypeFilter(firstColumn, firstLine + lineHeight);
     MakeCovenantFilter(firstColumn, firstLine + lineHeight * 2);
     MakeClanFilter(firstColumn, firstLine + lineHeight * 4);
     MakeProgressFilter(firstColumn, firstLine + lineHeight * 6);
 }
コード例 #5
0
 public static bool Prefix(ref RunHistoryScreen __instance, ref bool __result, ref CoreInputControlMapping mapping, ref IGameUIComponent triggeredUI, ref InputManager.Controls triggeredMappingID)
 {
     // If the filter dialog is null, abort.
     if (AdvancedRunHistory.filterDialog == null)
     {
         AdvancedRunHistory.Log("Filter dialog does not seem to have initalized successfully.", LogLevel.Warning);
         return(true);
     }
     // If the filter dialog is open, handle it first.
     if (AdvancedRunHistory.filterDialog.IsActive())
     {
         if (AdvancedRunHistory.filterDialog.ApplyScreenInput(mapping, triggeredUI, triggeredMappingID))
         {
             __result = true;
         }
         // If one of the filters was changed, re-fetch runs.
         if (AdvancedRunHistory.filterDialog.WasUpdated() && AdvancedRunHistory.filterManager.Active)
         {
             UpdateHistoryUI(__instance);
         }
         return(false);
     }
     // "Edit Filters" button clicked: Open the filter dialog.
     if (AdvancedRunHistory.openFilterDialogButton.TryTrigger(triggeredUI, triggeredMappingID))
     {
         AdvancedRunHistory.filterDialog.Open();
         __result = true;
         return(false);
     }
     // "Apply Filters" toggle clicked: Toggle the filter manager's active state and re-fetch runs.
     if (AdvancedRunHistory.applyFiltersToggle.TryTrigger(triggeredUI, triggeredMappingID))
     {
         AdvancedRunHistory.filterManager.Active = AdvancedRunHistory.applyFiltersToggle.Toggle();
         UpdateHistoryUI(__instance);
         return(false);
     }
     // If nothing else has been found, run the original method.
     return(true);
 }