private float GetTabButtonWidth(MainTabDef tab) { int tabButtonsCount = this.TabButtonsCount; int num = 0; for (int i = 0; i < this.allTabs.Count; i++) { if (this.allTabs[i].showTabButton) { num = i; } } int num2 = (int)((float)Screen.width / (float)tabButtonsCount); int num3 = 0; for (int j = 0; j < this.allTabs.Count; j++) { if (this.allTabs[j].showTabButton) { if (this.allTabs[j] == tab) { if (j == num) { return((float)(Screen.width - num3)); } return((float)num2); } else { num3 += num2; } } } return(0f); }
public void SetCurrentTab(MainTabDef tab, bool playSound = true) { if (tab == this.OpenTab) { return; } this.ToggleTab(tab, playSound); }
public MainTabWindow FindWindow(string defName) { MainTabDef mainTabDef = this.AllTabs.FirstOrDefault((MainTabDef d) => d.defName == defName); if (mainTabDef != null) { return(mainTabDef.Window); } return(null); }
public T FindWindow <T>() where T : MainTabWindow { Type targetType = typeof(T); MainTabDef mainTabDef = this.AllTabs.FirstOrDefault((MainTabDef d) => d.Window != null && targetType.IsAssignableFrom(d.Window.GetType())); if (mainTabDef != null) { return((T)((object)mainTabDef.Window)); } return((T)((object)null)); }
public void PrepareDependencies(UserInterface userInterface) { this.inventoryManager = new InventoryManager(); this.inventoryManager.PreferenceCompressedStorage = this.preferenceCompressedStorage; this.inventoryManager.PreferenceIncludeUnfinished = this.preferenceIncludeUnfinished; MainTabDef mainTabDef = userInterface.MainTabsRoot.FindTabDef("EdB_Interface_Inventory"); MainTabWindow_Inventory mainTabWindow_Inventory = mainTabDef.Window as MainTabWindow_Inventory; if (mainTabWindow_Inventory != null) { mainTabWindow_Inventory.InventoryManager = this.inventoryManager; } }
public void SquadsEnabledValueChanged(bool value, MainTabDef squadsWindowTabDef, ComponentColonistBar colonistBarComponent) { this.supervisor.Enabled = value; squadsWindowTabDef.showTabButton = value; if (value) { this.supervisor.SyncSquadsToColonistBar(); this.supervisor.UpdateColonistBarGroups(); } else { colonistBarComponent.ColonistBar.UpdateGroups(colonistBarComponent.DefaultGroups, colonistBarComponent.DefaultGroup); } SquadManager.Instance.SyncThingToMap(); }
private float GetTabButtonPosition(MainTabDef tab) { int tabButtonsCount = this.TabButtonsCount; int num = (int)((float)Screen.width / (float)tabButtonsCount); int num2 = 0; for (int i = 0; i < this.allTabs.Count; i++) { if (this.allTabs[i].showTabButton) { if (this.allTabs[i] == tab) { return((float)num2); } num2 += num; } } return(0f); }
private void DoTabButton(MainTabDef def, float posX, float width) { Text.Font = GameFont.Small; Rect rect = new Rect(posX, (float)(Screen.height - 35), width, 35f); SoundDef mouseoverButtonCategory = SoundDefOf.MouseoverButtonCategory; if (WidgetsSubtle.ButtonSubtle(rect, def.LabelCap, def.Window.TabButtonBarPercent, -1f, mouseoverButtonCategory)) { this.ToggleTab(def, true); } if (!def.tutorHighlightTag.NullOrEmpty()) { TutorUIHighlighter.HighlightOpportunity(def.tutorHighlightTag, rect); } if (!def.description.NullOrEmpty()) { TooltipHandler.TipRegion(rect, def.description); } }
public void ToggleTab(MainTabDef newTab, bool playSound = true) { MainTabDef openTab = this.OpenTab; if (openTab == null && newTab == null) { return; } if (openTab == newTab) { Find.WindowStack.TryRemove(openTab.Window, true); if (playSound) { SoundDefOf.TabClose.PlayOneShotOnCamera(); } } else { if (openTab != null) { Find.WindowStack.TryRemove(openTab.Window, true); } if (newTab != null) { Find.WindowStack.Add(newTab.Window); } if (playSound) { if (newTab == null) { SoundDefOf.TabClose.PlayOneShotOnCamera(); } else { SoundDefOf.TabOpen.PlayOneShotOnCamera(); } } } }
public void PrepareDependencies(UserInterface userInterface) { MainTabsRoot mainTabsRoot = userInterface.MainTabsRoot; this.preferenceEnableSquadFiltering.PreferenceEnableSquads = this.preferenceEnableSquads; this.preferenceEnableSquadRow.PreferenceEnableSquads = this.preferenceEnableSquads; SquadManager.Instance.PreferenceEnableSquads = this.preferenceEnableSquads; ColonistTracker.Instance.ColonistChanged += new ColonistNotificationHandler(SquadManager.Instance.ColonistChanged); ComponentColonistBar colonistBarComponent = userInterface.FindNamedComponentAs <ComponentColonistBar>("ColonistBar"); if (colonistBarComponent == null) { return; } colonistBarComponent.ColonistBar.AlwaysShowGroupName = this.preferenceAlwaysShowSquadName.Value; this.preferenceAlwaysShowSquadName.ValueChanged += delegate(bool value) { colonistBarComponent.ColonistBar.AlwaysShowGroupName = value; }; MainTabDef squadsWindowTabDef = mainTabsRoot.FindTabDef("EdB_Interface_Squads"); MainTabWindow_Squads mainTabWindow_Squads = squadsWindowTabDef.Window as MainTabWindow_Squads; if (squadsWindowTabDef != null) { this.preferenceEnableSquads.ValueChanged += delegate(bool value) { this.SquadsEnabledValueChanged(value, squadsWindowTabDef, colonistBarComponent); }; } this.supervisor = new ColonistBarSquadSupervisor(colonistBarComponent.ColonistBar); SquadManager.Instance.SquadAdded += delegate(Squad Squad) { this.supervisor.SyncSquadsToColonistBar(); this.supervisor.UpdateColonistBarGroups(); }; SquadManager.Instance.SquadChanged += delegate(Squad Squad) { this.supervisor.SyncSquadsToColonistBar(); this.supervisor.UpdateColonistBarGroups(); }; SquadManager.Instance.SquadRemoved += delegate(Squad s, int i) { this.supervisor.SyncSquadsToColonistBar(); this.supervisor.UpdateColonistBarGroups(); }; SquadManager.Instance.SquadDisplayPreferenceChanged += delegate(Squad Squad) { this.supervisor.SyncSquadsToColonistBar(); this.supervisor.UpdateColonistBarGroups(); }; SquadManager.Instance.SquadOrderChanged += delegate { this.supervisor.SyncSquadsToColonistBar(); this.supervisor.UpdateColonistBarGroups(); }; colonistBarComponent.ColonistBar.SelectedGroupChanged += new ColonistBar.SelectedGroupChangedHandler(this.supervisor.SelectedGroupChanged); this.supervisor.SelectedSquadChanged += delegate(Squad squad) { SquadManager.Instance.CurrentSquad = squad; }; if (mainTabWindow_Squads != null) { SquadManager.Instance.SquadChanged += new SquadNotificationHandler(mainTabWindow_Squads.SquadChanged); } this.initializeAction = delegate { this.SquadsEnabledValueChanged(this.preferenceEnableSquads.Value, squadsWindowTabDef, colonistBarComponent); }; foreach (MainTabWindow_PawnListWithSquads current in mainTabsRoot.FindWindows <MainTabWindow_PawnListWithSquads>()) { current.PreferenceEnableSquadFiltering = this.preferenceEnableSquadFiltering; current.PreferenceEnableSquadRow = this.preferenceEnableSquadRow; current.PreferenceEnableSquads = this.preferenceEnableSquads; } this.shortcuts.ColonistBarSquadSupervisor = this.supervisor; }