private Rect GroupFrameRect(int group) { float num = 99999f; float num2 = 0f; float num3 = 0f; List <ColonistBar.Entry> entries = ColonistBar.Entries; List <Vector2> drawLocs = ColonistBar.DrawLocs; for (int i = 0; i < entries.Count; i++) { ColonistBar.Entry entry = entries[i]; if (entry.group == group) { float a = num; Vector2 vector = drawLocs[i]; num = Mathf.Min(a, vector.x); float a2 = num2; Vector2 vector2 = drawLocs[i]; float x = vector2.x; Vector2 size = ColonistBar.Size; num2 = Mathf.Max(a2, x + size.x); float a3 = num3; Vector2 vector3 = drawLocs[i]; float y = vector3.y; Vector2 size2 = ColonistBar.Size; num3 = Mathf.Max(a3, y + size2.y); } } return(new Rect(num, 0f, num2 - num, num3).ContractedBy(-12f * ColonistBar.Scale)); }
public void HandleGroupFrameClicks(int group) { Rect rect = this.GroupFrameRect(group); if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && Mouse.IsOver(rect) && !this.ColonistBar.AnyColonistOrCorpseAt(UI.MousePositionOnUIInverted)) { bool worldRenderedNow = WorldRendererUtility.WorldRenderedNow; if (!worldRenderedNow && !Find.Selector.dragBox.IsValidAndActive) { goto IL_0093; } if (worldRenderedNow && !Find.WorldSelector.dragBox.IsValidAndActive) { goto IL_0093; } } goto IL_014c; IL_0093: Find.Selector.dragBox.active = false; Find.WorldSelector.dragBox.active = false; ColonistBar.Entry entry = this.ColonistBar.Entries.Find((ColonistBar.Entry x) => x.group == group); Map map = entry.map; if (map == null) { if (WorldRendererUtility.WorldRenderedNow) { CameraJumper.TrySelect(entry.pawn); } else { CameraJumper.TryJumpAndSelect(entry.pawn); } } else { if (!CameraJumper.TryHideWorld() && Current.Game.VisibleMap != map) { SoundDefOf.MapSelected.PlayOneShotOnCamera(null); } Current.Game.VisibleMap = map; } goto IL_014c; IL_014c: if (Event.current.button == 1 && Widgets.ButtonInvisible(rect, false)) { ColonistBar.Entry entry2 = this.ColonistBar.Entries.Find((ColonistBar.Entry x) => x.group == group); if (entry2.map != null) { CameraJumper.TryJumpAndSelect(CameraJumper.GetWorldTargetOfMap(entry2.map)); } else if (entry2.pawn != null) { CameraJumper.TryJumpAndSelect(entry2.pawn); } } }
public void DrawGroupFrame(int group) { Rect position = GroupFrameRect(group); List <ColonistBar.Entry> entries = ColonistBar.Entries; ColonistBar.Entry entry = entries.Find((ColonistBar.Entry x) => x.group == group); Map map = entry.map; float num = (map == null) ? ((!WorldRendererUtility.WorldRenderedNow) ? 0.75f : 1f) : ((map == Find.CurrentMap && !WorldRendererUtility.WorldRenderedNow) ? 1f : 0.75f); Widgets.DrawRectFast(position, new Color(0.5f, 0.5f, 0.5f, 0.4f * num)); }
public void DrawGroupFrame(int group) { Rect position = this.GroupFrameRect(group); List <ColonistBar.Entry> entries = this.ColonistBar.Entries; ColonistBar.Entry entry = entries.Find((ColonistBar.Entry x) => x.group == group); Map map = entry.map; float num = (float)((map != null) ? ((map == Find.VisibleMap && !WorldRendererUtility.WorldRenderedNow) ? 1.0 : 0.75) : ((!WorldRendererUtility.WorldRenderedNow) ? 0.75 : 1.0)); Widgets.DrawRectFast(position, new Color(0.5f, 0.5f, 0.5f, (float)(0.40000000596046448 * num)), null); }
private float FindBestScale(out bool onlyOneRow, out int maxPerGlobalRow) { float num = 1f; List <ColonistBar.Entry> entries = this.ColonistBar.Entries; int num2 = this.CalculateGroupsCount(); while (true) { Vector2 baseSize = ColonistBar.BaseSize; float num3 = (float)((baseSize.x + 24.0) * num); float num4 = (float)(ColonistBarDrawLocsFinder.MaxColonistBarWidth - (float)(num2 - 1) * 25.0 * num); maxPerGlobalRow = Mathf.FloorToInt(num4 / num3); onlyOneRow = true; if (this.TryDistributeHorizontalSlotsBetweenGroups(maxPerGlobalRow)) { int allowedRowsCountForScale = ColonistBarDrawLocsFinder.GetAllowedRowsCountForScale(num); bool flag = true; int num5 = -1; for (int i = 0; i < entries.Count; i++) { int num6 = num5; ColonistBar.Entry entry = entries[i]; if (num6 != entry.group) { ColonistBar.Entry entry2 = entries[i]; num5 = entry2.group; List <int> list = this.entriesInGroup; ColonistBar.Entry entry3 = entries[i]; float num7 = (float)list[entry3.group]; List <int> list2 = this.horizontalSlotsPerGroup; ColonistBar.Entry entry4 = entries[i]; int num8 = Mathf.CeilToInt(num7 / (float)list2[entry4.group]); if (num8 > 1) { onlyOneRow = false; } if (num8 > allowedRowsCountForScale) { flag = false; break; } } } if (flag) { break; } } num = (float)(num * 0.949999988079071); } return(num); }
private void CalculateDrawLocs(List <Vector2> outDrawLocs, float scale, bool onlyOneRow, int maxPerGlobalRow) { outDrawLocs.Clear(); int num = maxPerGlobalRow; if (onlyOneRow) { for (int i = 0; i < this.horizontalSlotsPerGroup.Count; i++) { this.horizontalSlotsPerGroup[i] = Mathf.Min(this.horizontalSlotsPerGroup[i], this.entriesInGroup[i]); } num = this.ColonistBar.Entries.Count; } int num2 = this.CalculateGroupsCount(); Vector2 baseSize = ColonistBar.BaseSize; float num3 = (float)((baseSize.x + 24.0) * scale); float num4 = (float)((float)num * num3 + (float)(num2 - 1) * 25.0 * scale); List <ColonistBar.Entry> entries = this.ColonistBar.Entries; int num5 = -1; int num6 = -1; float num7 = (float)(((float)UI.screenWidth - num4) / 2.0); for (int j = 0; j < entries.Count; j++) { int num8 = num5; ColonistBar.Entry entry = entries[j]; if (num8 != entry.group) { if (num5 >= 0) { num7 = (float)(num7 + 25.0 * scale); float num9 = num7; float num10 = (float)this.horizontalSlotsPerGroup[num5] * scale; Vector2 baseSize2 = ColonistBar.BaseSize; num7 = (float)(num9 + num10 * (baseSize2.x + 24.0)); } num6 = 0; ColonistBar.Entry entry2 = entries[j]; num5 = entry2.group; } else { num6++; } float groupStartX = num7; ColonistBar.Entry entry3 = entries[j]; Vector2 drawLoc = this.GetDrawLoc(groupStartX, 21f, entry3.group, num6, scale); outDrawLocs.Add(drawLoc); } }
public void ColonistBarOnGUI() { if (!this.Visible) { return; } if (Event.current.type != EventType.Layout) { List <ColonistBar.Entry> entries = this.Entries; int num = -1; bool showGroupFrames = this.ShowGroupFrames; for (int i = 0; i < this.cachedDrawLocs.Count; i++) { Rect rect = new Rect(this.cachedDrawLocs[i].x, this.cachedDrawLocs[i].y, this.Size.x, this.Size.y); ColonistBar.Entry entry = entries[i]; bool flag = num != entry.group; num = entry.group; if (entry.pawn != null) { this.drawer.HandleClicks(rect, entry.pawn); } if (Event.current.type == EventType.Repaint) { if (flag && showGroupFrames) { this.drawer.DrawGroupFrame(entry.group); } if (entry.pawn != null) { this.drawer.DrawColonist(rect, entry.pawn, entry.map); } } } num = -1; if (showGroupFrames) { for (int j = 0; j < this.cachedDrawLocs.Count; j++) { ColonistBar.Entry entry2 = entries[j]; bool flag2 = num != entry2.group; num = entry2.group; if (flag2) { this.drawer.HandleGroupFrameClicks(entry2.group); } } } } }
public bool TryGetEntryAt(Vector2 pos, out ColonistBar.Entry entry) { List <Vector2> drawLocs = this.DrawLocs; List <ColonistBar.Entry> entries = this.Entries; Vector2 size = this.Size; for (int i = 0; i < drawLocs.Count; i++) { Rect rect = new Rect(drawLocs[i].x, drawLocs[i].y, size.x, size.y); if (rect.Contains(pos)) { entry = entries[i]; return(true); } } entry = default(ColonistBar.Entry); return(false); }
private int CalculateGroupsCount() { List <ColonistBar.Entry> entries = this.ColonistBar.Entries; int num = -1; int num2 = 0; for (int i = 0; i < entries.Count; i++) { int num3 = num; ColonistBar.Entry entry = entries[i]; if (num3 != entry.group) { num2++; ColonistBar.Entry entry2 = entries[i]; num = entry2.group; } } return(num2); }
private void CalculateColonistsInGroup() { this.entriesInGroup.Clear(); List <ColonistBar.Entry> entries = this.ColonistBar.Entries; int num = this.CalculateGroupsCount(); for (int i = 0; i < num; i++) { this.entriesInGroup.Add(0); } for (int j = 0; j < entries.Count; j++) { List <int> list; List <int> list2 = list = this.entriesInGroup; ColonistBar.Entry entry = entries[j]; int group; list2[group = entry.group] = list[group] + 1; } }
public void HandleGroupFrameClicks(int group) { Rect rect = this.GroupFrameRect(group); if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && Mouse.IsOver(rect) && !this.ColonistBar.AnyColonistOrCorpseAt(UI.MousePositionOnUIInverted)) { bool worldRenderedNow = WorldRendererUtility.WorldRenderedNow; if ((!worldRenderedNow && !Find.Selector.dragBox.IsValidAndActive) || (worldRenderedNow && !Find.WorldSelector.dragBox.IsValidAndActive)) { Find.Selector.dragBox.active = false; Find.WorldSelector.dragBox.active = false; ColonistBar.Entry entry = this.ColonistBar.Entries.Find((ColonistBar.Entry x) => x.group == group); Map map = entry.map; if (map == null) { if (WorldRendererUtility.WorldRenderedNow) { CameraJumper.TrySelect(entry.pawn); } else { CameraJumper.TryJumpAndSelect(entry.pawn); } } else { if (!CameraJumper.TryHideWorld() && Find.CurrentMap != map) { SoundDefOf.MapSelected.PlayOneShotOnCamera(null); } Current.Game.CurrentMap = map; } } } if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Mouse.IsOver(rect)) { Event.current.Use(); } }
public void ColonistBarOnGUI() { if (this.Visible) { if (Event.current.type != EventType.Layout) { List <ColonistBar.Entry> entries = this.Entries; int num = -1; bool showGroupFrames = this.ShowGroupFrames; int reorderableGroup = -1; for (int i = 0; i < this.cachedDrawLocs.Count; i++) { Rect rect = new Rect(this.cachedDrawLocs[i].x, this.cachedDrawLocs[i].y, this.Size.x, this.Size.y); ColonistBar.Entry entry = entries[i]; bool flag = num != entry.group; num = entry.group; if (flag) { reorderableGroup = ReorderableWidget.NewGroup(delegate(int from, int to) { this.Reorder(from, to, entry.group); }, ReorderableDirection.Horizontal, this.SpaceBetweenColonistsHorizontal, delegate(int index, Vector2 dragStartPos) { this.DrawColonistMouseAttachment(index, dragStartPos, entry.group); }); } bool reordering; if (entry.pawn != null) { this.drawer.HandleClicks(rect, entry.pawn, reorderableGroup, out reordering); } else { reordering = false; } if (Event.current.type == EventType.Repaint) { if (flag && showGroupFrames) { this.drawer.DrawGroupFrame(entry.group); } if (entry.pawn != null) { this.drawer.DrawColonist(rect, entry.pawn, entry.map, this.colonistsToHighlight.Contains(entry.pawn), reordering); } } } num = -1; if (showGroupFrames) { for (int j = 0; j < this.cachedDrawLocs.Count; j++) { ColonistBar.Entry entry2 = entries[j]; bool flag2 = num != entry2.group; num = entry2.group; if (flag2) { this.drawer.HandleGroupFrameClicks(entry2.group); } } } } if (Event.current.type == EventType.Repaint) { this.colonistsToHighlight.Clear(); } } }
internal bool <> m__0(ColonistBar.Entry x) { return(x.group == this.group); }