public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo) { tmpAllGizmos.Clear(); tmpAllGizmos.AddRange(gizmos); tmpAllGizmos.SortStable((Gizmo lhs, Gizmo rhs) => lhs.order.CompareTo(rhs.order)); gizmoGroups.Clear(); for (int i = 0; i < tmpAllGizmos.Count; i++) { Gizmo gizmo = tmpAllGizmos[i]; bool flag = false; for (int j = 0; j < gizmoGroups.Count; j++) { if (gizmoGroups[j][0].GroupsWith(gizmo)) { flag = true; gizmoGroups[j].Add(gizmo); gizmoGroups[j][0].MergeWith(gizmo); break; } } if (!flag) { List <Gizmo> list = new List <Gizmo>(); list.Add(gizmo); gizmoGroups.Add(list); } } firstGizmos.Clear(); for (int k = 0; k < gizmoGroups.Count; k++) { List <Gizmo> list2 = gizmoGroups[k]; Gizmo gizmo2 = null; for (int l = 0; l < list2.Count; l++) { if (!list2[l].disabled) { gizmo2 = list2[l]; break; } } if (gizmo2 == null) { gizmo2 = list2.FirstOrDefault(); } if (gizmo2 != null) { firstGizmos.Add(gizmo2); } } drawnHotKeys.Clear(); float num = (float)(UI.screenWidth - 147); float maxWidth = num - startX; Text.Font = GameFont.Tiny; float num2 = (float)(UI.screenHeight - 35); Vector2 gizmoSpacing = GizmoSpacing; Vector2 topLeft = new Vector2(startX, num2 - gizmoSpacing.y - 75f); mouseoverGizmo = null; Gizmo interactedGiz = null; Event ev = null; Gizmo floatMenuGiz = null; for (int m = 0; m < firstGizmos.Count; m++) { Gizmo gizmo3 = firstGizmos[m]; if (gizmo3.Visible) { if (topLeft.x + gizmo3.GetWidth(maxWidth) > num) { topLeft.x = startX; float y = topLeft.y; Vector2 gizmoSpacing2 = GizmoSpacing; topLeft.y = y - (75f + gizmoSpacing2.x); } heightDrawnFrame = Time.frameCount; heightDrawn = (float)UI.screenHeight - topLeft.y; GizmoResult gizmoResult = gizmo3.GizmoOnGUI(topLeft, maxWidth); if (gizmoResult.State == GizmoState.Interacted) { ev = gizmoResult.InteractEvent; interactedGiz = gizmo3; } else if (gizmoResult.State == GizmoState.OpenedFloatMenu) { floatMenuGiz = gizmo3; } if ((int)gizmoResult.State >= 1) { mouseoverGizmo = gizmo3; } float x2 = topLeft.x; float y2 = topLeft.y; float width = gizmo3.GetWidth(maxWidth); Vector2 gizmoSpacing3 = GizmoSpacing; Rect rect = new Rect(x2, y2, width, 75f + gizmoSpacing3.y); rect = rect.ContractedBy(-12f); GenUI.AbsorbClicksInRect(rect); float x3 = topLeft.x; float width2 = gizmo3.GetWidth(maxWidth); Vector2 gizmoSpacing4 = GizmoSpacing; topLeft.x = x3 + (width2 + gizmoSpacing4.x); } } if (interactedGiz != null) { List <Gizmo> list3 = gizmoGroups.First((List <Gizmo> group) => group.Contains(interactedGiz)); for (int n = 0; n < list3.Count; n++) { Gizmo gizmo4 = list3[n]; if (gizmo4 != interactedGiz && !gizmo4.disabled && interactedGiz.InheritInteractionsFrom(gizmo4)) { gizmo4.ProcessInput(ev); } } interactedGiz.ProcessInput(ev); Event.current.Use(); } else if (floatMenuGiz != null) { List <FloatMenuOption> list4 = new List <FloatMenuOption>(); foreach (FloatMenuOption rightClickFloatMenuOption in floatMenuGiz.RightClickFloatMenuOptions) { list4.Add(rightClickFloatMenuOption); } List <Gizmo> list5 = gizmoGroups.First((List <Gizmo> group) => group.Contains(floatMenuGiz)); Action prevAction; Action localOptionAction; for (int num3 = 0; num3 < list5.Count; num3++) { Gizmo gizmo5 = list5[num3]; if (gizmo5 != floatMenuGiz && !gizmo5.disabled && floatMenuGiz.InheritFloatMenuInteractionsFrom(gizmo5)) { foreach (FloatMenuOption rightClickFloatMenuOption2 in gizmo5.RightClickFloatMenuOptions) { FloatMenuOption floatMenuOption = list4.Find((FloatMenuOption x) => x.Label == rightClickFloatMenuOption2.Label); if (floatMenuOption == null) { list4.Add(rightClickFloatMenuOption2); } else if (!rightClickFloatMenuOption2.Disabled) { if (!floatMenuOption.Disabled) { prevAction = floatMenuOption.action; localOptionAction = rightClickFloatMenuOption2.action; floatMenuOption.action = delegate { prevAction(); localOptionAction(); }; } else if (floatMenuOption.Disabled) { list4[list4.IndexOf(floatMenuOption)] = rightClickFloatMenuOption2; } } } } } Event.current.Use(); if (list4.Any()) { Find.WindowStack.Add(new FloatMenu(list4)); } } gizmoGroups.Clear(); firstGizmos.Clear(); tmpAllGizmos.Clear(); }
public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo) { GizmoGridDrawer.tmpAllGizmos.Clear(); GizmoGridDrawer.tmpAllGizmos.AddRange(gizmos); GizmoGridDrawer.tmpAllGizmos.SortStable((Gizmo lhs, Gizmo rhs) => lhs.order.CompareTo(rhs.order)); GizmoGridDrawer.gizmoGroups.Clear(); for (int i = 0; i < GizmoGridDrawer.tmpAllGizmos.Count; i++) { Gizmo gizmo = GizmoGridDrawer.tmpAllGizmos[i]; bool flag = false; for (int j = 0; j < GizmoGridDrawer.gizmoGroups.Count; j++) { if (GizmoGridDrawer.gizmoGroups[j][0].GroupsWith(gizmo)) { flag = true; GizmoGridDrawer.gizmoGroups[j].Add(gizmo); GizmoGridDrawer.gizmoGroups[j][0].MergeWith(gizmo); break; } } if (!flag) { List <Gizmo> list = new List <Gizmo>(); list.Add(gizmo); GizmoGridDrawer.gizmoGroups.Add(list); } } GizmoGridDrawer.firstGizmos.Clear(); for (int k = 0; k < GizmoGridDrawer.gizmoGroups.Count; k++) { List <Gizmo> list2 = GizmoGridDrawer.gizmoGroups[k]; Gizmo gizmo2 = null; for (int l = 0; l < list2.Count; l++) { if (!list2[l].disabled) { gizmo2 = list2[l]; break; } } if (gizmo2 == null) { gizmo2 = list2.FirstOrDefault <Gizmo>(); } if (gizmo2 != null) { GizmoGridDrawer.firstGizmos.Add(gizmo2); } } GizmoGridDrawer.drawnHotKeys.Clear(); float num = (float)(UI.screenWidth - 147); float maxWidth = num - startX; Text.Font = GameFont.Tiny; Vector2 topLeft = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoGridDrawer.GizmoSpacing.y - 75f); mouseoverGizmo = null; Gizmo interactedGiz = null; Event ev = null; Gizmo floatMenuGiz = null; for (int m = 0; m < GizmoGridDrawer.firstGizmos.Count; m++) { Gizmo gizmo3 = GizmoGridDrawer.firstGizmos[m]; if (gizmo3.Visible) { if (topLeft.x + gizmo3.GetWidth(maxWidth) > num) { topLeft.x = startX; topLeft.y -= 75f + GizmoGridDrawer.GizmoSpacing.x; } GizmoGridDrawer.heightDrawnFrame = Time.frameCount; GizmoGridDrawer.heightDrawn = (float)UI.screenHeight - topLeft.y; GizmoResult gizmoResult = gizmo3.GizmoOnGUI(topLeft, maxWidth); if (gizmoResult.State == GizmoState.Interacted) { ev = gizmoResult.InteractEvent; interactedGiz = gizmo3; } else if (gizmoResult.State == GizmoState.OpenedFloatMenu) { floatMenuGiz = gizmo3; } if (gizmoResult.State >= GizmoState.Mouseover) { mouseoverGizmo = gizmo3; } Rect rect = new Rect(topLeft.x, topLeft.y, gizmo3.GetWidth(maxWidth), 75f + GizmoGridDrawer.GizmoSpacing.y); rect = rect.ContractedBy(-12f); GenUI.AbsorbClicksInRect(rect); topLeft.x += gizmo3.GetWidth(maxWidth) + GizmoGridDrawer.GizmoSpacing.x; } } if (interactedGiz != null) { List <Gizmo> list3 = GizmoGridDrawer.gizmoGroups.First((List <Gizmo> group) => group.Contains(interactedGiz)); for (int n = 0; n < list3.Count; n++) { Gizmo gizmo4 = list3[n]; if (gizmo4 != interactedGiz && !gizmo4.disabled && interactedGiz.InheritInteractionsFrom(gizmo4)) { gizmo4.ProcessInput(ev); } } interactedGiz.ProcessInput(ev); Event.current.Use(); } else if (floatMenuGiz != null) { List <FloatMenuOption> list4 = new List <FloatMenuOption>(); foreach (FloatMenuOption item in floatMenuGiz.RightClickFloatMenuOptions) { list4.Add(item); } List <Gizmo> list5 = GizmoGridDrawer.gizmoGroups.First((List <Gizmo> group) => group.Contains(floatMenuGiz)); for (int num2 = 0; num2 < list5.Count; num2++) { Gizmo gizmo5 = list5[num2]; if (gizmo5 != floatMenuGiz && !gizmo5.disabled && floatMenuGiz.InheritFloatMenuInteractionsFrom(gizmo5)) { using (IEnumerator <FloatMenuOption> enumerator2 = gizmo5.RightClickFloatMenuOptions.GetEnumerator()) { while (enumerator2.MoveNext()) { FloatMenuOption option = enumerator2.Current; FloatMenuOption floatMenuOption = list4.Find((FloatMenuOption x) => x.Label == option.Label); if (floatMenuOption == null) { list4.Add(option); } else if (!option.Disabled) { if (!floatMenuOption.Disabled) { Action prevAction = floatMenuOption.action; Action localOptionAction = option.action; floatMenuOption.action = delegate() { prevAction(); localOptionAction(); }; } else if (floatMenuOption.Disabled) { list4[list4.IndexOf(floatMenuOption)] = option; } } } } } } Event.current.Use(); if (list4.Any <FloatMenuOption>()) { Find.WindowStack.Add(new FloatMenu(list4)); } } GizmoGridDrawer.gizmoGroups.Clear(); GizmoGridDrawer.firstGizmos.Clear(); GizmoGridDrawer.tmpAllGizmos.Clear(); }
public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo) { tmpAllGizmos.Clear(); tmpAllGizmos.AddRange(gizmos); tmpAllGizmos.SortStable(SortByOrder); gizmoGroups.Clear(); for (int i = 0; i < tmpAllGizmos.Count; i++) { Gizmo gizmo = tmpAllGizmos[i]; bool flag = false; for (int j = 0; j < gizmoGroups.Count; j++) { if (gizmoGroups[j][0].GroupsWith(gizmo)) { flag = true; gizmoGroups[j].Add(gizmo); gizmoGroups[j][0].MergeWith(gizmo); break; } } if (!flag) { List <Gizmo> list = SimplePool <List <Gizmo> > .Get(); list.Add(gizmo); gizmoGroups.Add(list); } } firstGizmos.Clear(); for (int k = 0; k < gizmoGroups.Count; k++) { List <Gizmo> list2 = gizmoGroups[k]; Gizmo gizmo2 = null; for (int l = 0; l < list2.Count; l++) { if (!list2[l].disabled) { gizmo2 = list2[l]; break; } } if (gizmo2 == null) { gizmo2 = list2.FirstOrDefault(); } else { Command_Toggle command_Toggle = gizmo2 as Command_Toggle; if (command_Toggle != null) { if (!command_Toggle.activateIfAmbiguous && !command_Toggle.isActive()) { for (int m = 0; m < list2.Count; m++) { Command_Toggle command_Toggle2 = list2[m] as Command_Toggle; if (command_Toggle2 != null && !command_Toggle2.disabled && command_Toggle2.isActive()) { gizmo2 = list2[m]; break; } } } if (command_Toggle.activateIfAmbiguous && command_Toggle.isActive()) { for (int n = 0; n < list2.Count; n++) { Command_Toggle command_Toggle3 = list2[n] as Command_Toggle; if (command_Toggle3 != null && !command_Toggle3.disabled && !command_Toggle3.isActive()) { gizmo2 = list2[n]; break; } } } } } if (gizmo2 != null) { firstGizmos.Add(gizmo2); } } drawnHotKeys.Clear(); float num = UI.screenWidth - 147; float maxWidth = num - startX; Text.Font = GameFont.Tiny; Vector2 topLeft = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoSpacing.y - 75f); mouseoverGizmo = null; Gizmo gizmo3 = null; Event ev = null; Gizmo gizmo4 = null; for (int num2 = 0; num2 < firstGizmos.Count; num2++) { Gizmo gizmo5 = firstGizmos[num2]; if (gizmo5.Visible) { if (topLeft.x + gizmo5.GetWidth(maxWidth) > num) { topLeft.x = startX; topLeft.y -= 75f + GizmoSpacing.x; } heightDrawnFrame = Time.frameCount; heightDrawn = (float)UI.screenHeight - topLeft.y; GizmoResult gizmoResult = gizmo5.GizmoOnGUI(topLeft, maxWidth); if (gizmoResult.State == GizmoState.Interacted || (gizmoResult.State == GizmoState.OpenedFloatMenu && gizmo5.RightClickFloatMenuOptions.FirstOrDefault() == null)) { ev = gizmoResult.InteractEvent; gizmo3 = gizmo5; } else if (gizmoResult.State == GizmoState.OpenedFloatMenu) { gizmo4 = gizmo5; } if ((int)gizmoResult.State >= 1) { mouseoverGizmo = gizmo5; } GenUI.AbsorbClicksInRect(new Rect(topLeft.x, topLeft.y, gizmo5.GetWidth(maxWidth), 75f + GizmoSpacing.y).ContractedBy(-12f)); topLeft.x += gizmo5.GetWidth(maxWidth) + GizmoSpacing.x; } } if (gizmo3 != null) { List <Gizmo> list3 = FindMatchingGroup(gizmo3); for (int num3 = 0; num3 < list3.Count; num3++) { Gizmo gizmo6 = list3[num3]; if (gizmo6 != gizmo3 && !gizmo6.disabled && gizmo3.InheritInteractionsFrom(gizmo6)) { gizmo6.ProcessInput(ev); } } gizmo3.ProcessInput(ev); Event.current.Use(); } else if (gizmo4 != null) { List <FloatMenuOption> list4 = new List <FloatMenuOption>(); foreach (FloatMenuOption rightClickFloatMenuOption in gizmo4.RightClickFloatMenuOptions) { list4.Add(rightClickFloatMenuOption); } List <Gizmo> list5 = FindMatchingGroup(gizmo4); Action prevAction; Action localOptionAction; for (int num4 = 0; num4 < list5.Count; num4++) { Gizmo gizmo7 = list5[num4]; if (gizmo7 != gizmo4 && !gizmo7.disabled && gizmo4.InheritFloatMenuInteractionsFrom(gizmo7)) { foreach (FloatMenuOption rightClickFloatMenuOption2 in gizmo7.RightClickFloatMenuOptions) { FloatMenuOption floatMenuOption = null; for (int num5 = 0; num5 < list4.Count; num5++) { if (list4[num5].Label == rightClickFloatMenuOption2.Label) { floatMenuOption = list4[num5]; break; } } if (floatMenuOption == null) { list4.Add(rightClickFloatMenuOption2); } else if (!rightClickFloatMenuOption2.Disabled) { if (!floatMenuOption.Disabled) { prevAction = floatMenuOption.action; localOptionAction = rightClickFloatMenuOption2.action; floatMenuOption.action = delegate { prevAction(); localOptionAction(); }; } else if (floatMenuOption.Disabled) { list4[list4.IndexOf(floatMenuOption)] = rightClickFloatMenuOption2; } } } } } Event.current.Use(); if (list4.Any()) { Find.WindowStack.Add(new FloatMenu(list4)); } } for (int num6 = 0; num6 < gizmoGroups.Count; num6++) { gizmoGroups[num6].Clear(); SimplePool <List <Gizmo> > .Return(gizmoGroups[num6]); } gizmoGroups.Clear(); firstGizmos.Clear(); tmpAllGizmos.Clear(); List <Gizmo> FindMatchingGroup(Gizmo toMatch) { for (int num7 = 0; num7 < gizmoGroups.Count; num7++) { if (gizmoGroups[num7].Contains(toMatch)) { return(gizmoGroups[num7]); } } return(null); } }
public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo) { GizmoGridDrawer.gizmoGroups.Clear(); foreach (Gizmo current in gizmos) { bool flag = false; for (int i = 0; i < GizmoGridDrawer.gizmoGroups.Count; i++) { if (GizmoGridDrawer.gizmoGroups[i][0].GroupsWith(current)) { flag = true; GizmoGridDrawer.gizmoGroups[i].Add(current); break; } } if (!flag) { List <Gizmo> list = new List <Gizmo>(); list.Add(current); GizmoGridDrawer.gizmoGroups.Add(list); } } GizmoGridDrawer.firstGizmos.Clear(); for (int j = 0; j < GizmoGridDrawer.gizmoGroups.Count; j++) { List <Gizmo> source = GizmoGridDrawer.gizmoGroups[j]; Gizmo gizmo = source.FirstOrDefault((Gizmo opt) => !opt.disabled); if (gizmo == null) { gizmo = source.FirstOrDefault <Gizmo>(); } GizmoGridDrawer.firstGizmos.Add(gizmo); } GizmoGridDrawer.drawnHotKeys.Clear(); float num = (float)(UI.screenWidth - 140); Text.Font = GameFont.Tiny; Vector2 topLeft = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoGridDrawer.GizmoSpacing.y - 75f); mouseoverGizmo = null; Gizmo interactedGiz = null; Event ev = null; for (int k = 0; k < GizmoGridDrawer.firstGizmos.Count; k++) { Gizmo gizmo2 = GizmoGridDrawer.firstGizmos[k]; if (gizmo2.Visible) { if (topLeft.x + gizmo2.Width + GizmoGridDrawer.GizmoSpacing.x > num) { topLeft.x = startX; topLeft.y -= 75f + GizmoGridDrawer.GizmoSpacing.x; } GizmoGridDrawer.heightDrawnFrame = Time.frameCount; GizmoGridDrawer.heightDrawn = (float)UI.screenHeight - topLeft.y; GizmoResult gizmoResult = gizmo2.GizmoOnGUI(topLeft); if (gizmoResult.State == GizmoState.Interacted) { ev = gizmoResult.InteractEvent; interactedGiz = gizmo2; } if (gizmoResult.State >= GizmoState.Mouseover) { mouseoverGizmo = gizmo2; } Rect rect = new Rect(topLeft.x, topLeft.y, gizmo2.Width, 75f + GizmoGridDrawer.GizmoSpacing.y); rect = rect.ContractedBy(-12f); GenUI.AbsorbClicksInRect(rect); topLeft.x += gizmo2.Width + GizmoGridDrawer.GizmoSpacing.x; } } if (interactedGiz != null) { List <Gizmo> list2 = GizmoGridDrawer.gizmoGroups.First((List <Gizmo> group) => group.Contains(interactedGiz)); for (int l = 0; l < list2.Count; l++) { Gizmo gizmo3 = list2[l]; if (gizmo3 != interactedGiz && !gizmo3.disabled && interactedGiz.InheritInteractionsFrom(gizmo3)) { gizmo3.ProcessInput(ev); } } interactedGiz.ProcessInput(ev); Event.current.Use(); } }
public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo) { GizmoGridDrawer.gizmoGroups.Clear(); foreach (Gizmo gizmo4 in gizmos) { bool flag = false; int num = 0; while (num < GizmoGridDrawer.gizmoGroups.Count) { if (!GizmoGridDrawer.gizmoGroups[num][0].GroupsWith(gizmo4)) { num++; continue; } flag = true; GizmoGridDrawer.gizmoGroups[num].Add(gizmo4); break; } if (!flag) { List <Gizmo> list = new List <Gizmo>(); list.Add(gizmo4); GizmoGridDrawer.gizmoGroups.Add(list); } } GizmoGridDrawer.firstGizmos.Clear(); for (int i = 0; i < GizmoGridDrawer.gizmoGroups.Count; i++) { List <Gizmo> source = GizmoGridDrawer.gizmoGroups[i]; Gizmo gizmo = source.FirstOrDefault((Gizmo opt) => !opt.disabled); if (gizmo == null) { gizmo = source.FirstOrDefault(); } GizmoGridDrawer.firstGizmos.Add(gizmo); } GizmoGridDrawer.drawnHotKeys.Clear(); float num2 = (float)(UI.screenWidth - 140); Text.Font = GameFont.Tiny; float num3 = (float)(UI.screenHeight - 35); Vector2 gizmoSpacing = GizmoGridDrawer.GizmoSpacing; Vector2 topLeft = new Vector2(startX, (float)(num3 - gizmoSpacing.y - 75.0)); mouseoverGizmo = null; Gizmo interactedGiz = null; Event ev = null; for (int j = 0; j < GizmoGridDrawer.firstGizmos.Count; j++) { Gizmo gizmo2 = GizmoGridDrawer.firstGizmos[j]; if (gizmo2.Visible) { float num4 = topLeft.x + gizmo2.Width; Vector2 gizmoSpacing2 = GizmoGridDrawer.GizmoSpacing; if (num4 + gizmoSpacing2.x > num2) { topLeft.x = startX; float y = topLeft.y; Vector2 gizmoSpacing3 = GizmoGridDrawer.GizmoSpacing; topLeft.y = (float)(y - (75.0 + gizmoSpacing3.x)); } GizmoGridDrawer.heightDrawnFrame = Time.frameCount; GizmoGridDrawer.heightDrawn = (float)UI.screenHeight - topLeft.y; GizmoResult gizmoResult = gizmo2.GizmoOnGUI(topLeft); if (gizmoResult.State == GizmoState.Interacted) { ev = gizmoResult.InteractEvent; interactedGiz = gizmo2; } if ((int)gizmoResult.State >= 1) { mouseoverGizmo = gizmo2; } float x = topLeft.x; float y2 = topLeft.y; float width = gizmo2.Width; Vector2 gizmoSpacing4 = GizmoGridDrawer.GizmoSpacing; Rect rect = new Rect(x, y2, width, (float)(75.0 + gizmoSpacing4.y)); rect = rect.ContractedBy(-12f); GenUI.AbsorbClicksInRect(rect); float x2 = topLeft.x; float width2 = gizmo2.Width; Vector2 gizmoSpacing5 = GizmoGridDrawer.GizmoSpacing; topLeft.x = x2 + (width2 + gizmoSpacing5.x); } } if (interactedGiz != null) { List <Gizmo> list2 = GizmoGridDrawer.gizmoGroups.First((List <Gizmo> group) => group.Contains(interactedGiz)); for (int k = 0; k < list2.Count; k++) { Gizmo gizmo3 = list2[k]; if (gizmo3 != interactedGiz && !gizmo3.disabled && interactedGiz.InheritInteractionsFrom(gizmo3)) { gizmo3.ProcessInput(ev); } } interactedGiz.ProcessInput(ev); Event.current.Use(); } }
public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo) { if (Event.current.type == EventType.Layout) { mouseoverGizmo = null; return; } tmpAllGizmos.Clear(); tmpAllGizmos.AddRange(gizmos); tmpAllGizmos.SortStable(SortByOrder); gizmoGroups.Clear(); for (int i = 0; i < tmpAllGizmos.Count; i++) { Gizmo gizmo = tmpAllGizmos[i]; bool flag = false; for (int j = 0; j < gizmoGroups.Count; j++) { if (gizmoGroups[j][0].GroupsWith(gizmo)) { flag = true; gizmoGroups[j].Add(gizmo); gizmoGroups[j][0].MergeWith(gizmo); break; } } if (!flag) { List <Gizmo> list = SimplePool <List <Gizmo> > .Get(); list.Add(gizmo); gizmoGroups.Add(list); } } firstGizmos.Clear(); shrinkableCommands.Clear(); float num = UI.screenWidth - 147; Vector2 vector = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoSpacing.y - 75f); float maxWidth = num - startX; int num2 = 0; for (int k = 0; k < gizmoGroups.Count; k++) { List <Gizmo> list2 = gizmoGroups[k]; Gizmo gizmo2 = null; for (int l = 0; l < list2.Count; l++) { if (!list2[l].disabled) { gizmo2 = list2[l]; break; } } if (gizmo2 == null) { gizmo2 = list2.FirstOrDefault(); } else { Command_Toggle command_Toggle = gizmo2 as Command_Toggle; if (command_Toggle != null) { if (!command_Toggle.activateIfAmbiguous && !command_Toggle.isActive()) { for (int m = 0; m < list2.Count; m++) { Command_Toggle command_Toggle2 = list2[m] as Command_Toggle; if (command_Toggle2 != null && !command_Toggle2.disabled && command_Toggle2.isActive()) { gizmo2 = list2[m]; break; } } } if (command_Toggle.activateIfAmbiguous && command_Toggle.isActive()) { for (int n = 0; n < list2.Count; n++) { Command_Toggle command_Toggle3 = list2[n] as Command_Toggle; if (command_Toggle3 != null && !command_Toggle3.disabled && !command_Toggle3.isActive()) { gizmo2 = list2[n]; break; } } } } } if (gizmo2 != null) { Command command; if ((command = gizmo2 as Command) != null && command.shrinkable && command.Visible) { shrinkableCommands.Add(command); } if (vector.x + gizmo2.GetWidth(maxWidth) > num) { vector.x = startX; vector.y -= 75f + GizmoSpacing.x; num2++; } vector.x += gizmo2.GetWidth(maxWidth) + GizmoSpacing.x; firstGizmos.Add(gizmo2); } } if (num2 > 1 && shrinkableCommands.Count > 1) { for (int num3 = 0; num3 < shrinkableCommands.Count; num3++) { firstGizmos.Remove(shrinkableCommands[num3]); } } else { shrinkableCommands.Clear(); } drawnHotKeys.Clear(); Text.Font = GameFont.Tiny; Vector2 vector2 = new Vector2(startX, (float)(UI.screenHeight - 35) - GizmoSpacing.y - 75f); mouseoverGizmo = null; Gizmo interactedGiz = null; Event interactedEvent = null; Gizmo floatMenuGiz = null; for (int num4 = 0; num4 < firstGizmos.Count; num4++) { Gizmo gizmo3 = firstGizmos[num4]; if (gizmo3.Visible) { if (vector2.x + gizmo3.GetWidth(maxWidth) > num) { vector2.x = startX; vector2.y -= 75f + GizmoSpacing.x; } heightDrawnFrame = Time.frameCount; heightDrawn = (float)UI.screenHeight - vector2.y; GizmoResult result2 = gizmo3.GizmoOnGUI(vector2, maxWidth); ProcessGizmoState(gizmo3, result2, ref mouseoverGizmo); GenUI.AbsorbClicksInRect(new Rect(vector2.x, vector2.y, gizmo3.GetWidth(maxWidth), 75f + GizmoSpacing.y).ContractedBy(-12f)); vector2.x += gizmo3.GetWidth(maxWidth) + GizmoSpacing.x; } } float x = vector2.x; int num5 = 0; for (int num6 = 0; num6 < shrinkableCommands.Count; num6++) { Command command2 = shrinkableCommands[num6]; float getShrunkSize = command2.GetShrunkSize; if (vector2.x + getShrunkSize > num) { num5++; if (num5 > 1) { x = startX; } vector2.x = x; vector2.y -= getShrunkSize + 3f; } Vector2 topLeft = vector2; topLeft.y += getShrunkSize + 3f; heightDrawnFrame = Time.frameCount; heightDrawn = Mathf.Min(heightDrawn, (float)UI.screenHeight - topLeft.y); GizmoResult result3 = command2.GizmoOnGUIShrunk(topLeft, getShrunkSize); ProcessGizmoState(command2, result3, ref mouseoverGizmo); GenUI.AbsorbClicksInRect(new Rect(topLeft.x, topLeft.y, getShrunkSize, getShrunkSize + 3f).ExpandedBy(3f)); vector2.x += getShrunkSize + 3f; } if (interactedGiz != null) { List <Gizmo> list3 = FindMatchingGroup(interactedGiz); for (int num7 = 0; num7 < list3.Count; num7++) { Gizmo gizmo4 = list3[num7]; if (gizmo4 != interactedGiz && !gizmo4.disabled && interactedGiz.InheritInteractionsFrom(gizmo4)) { gizmo4.ProcessInput(interactedEvent); } } interactedGiz.ProcessInput(interactedEvent); Event.current.Use(); } else if (floatMenuGiz != null) { List <FloatMenuOption> list4 = new List <FloatMenuOption>(); foreach (FloatMenuOption rightClickFloatMenuOption in floatMenuGiz.RightClickFloatMenuOptions) { list4.Add(rightClickFloatMenuOption); } List <Gizmo> list5 = FindMatchingGroup(floatMenuGiz); for (int num8 = 0; num8 < list5.Count; num8++) { Gizmo gizmo5 = list5[num8]; if (gizmo5 == floatMenuGiz || gizmo5.disabled || !floatMenuGiz.InheritFloatMenuInteractionsFrom(gizmo5)) { continue; } foreach (FloatMenuOption rightClickFloatMenuOption2 in gizmo5.RightClickFloatMenuOptions) { FloatMenuOption floatMenuOption = null; for (int num9 = 0; num9 < list4.Count; num9++) { if (list4[num9].Label == rightClickFloatMenuOption2.Label) { floatMenuOption = list4[num9]; break; } } if (floatMenuOption == null) { list4.Add(rightClickFloatMenuOption2); } else { if (rightClickFloatMenuOption2.Disabled) { continue; } if (!floatMenuOption.Disabled) { Action prevAction = floatMenuOption.action; Action localOptionAction = rightClickFloatMenuOption2.action; floatMenuOption.action = delegate { prevAction(); localOptionAction(); }; } else if (floatMenuOption.Disabled) { list4[list4.IndexOf(floatMenuOption)] = rightClickFloatMenuOption2; } } } } Event.current.Use(); if (list4.Any()) { Find.WindowStack.Add(new FloatMenu(list4)); } } for (int num10 = 0; num10 < gizmoGroups.Count; num10++) { gizmoGroups[num10].Clear(); SimplePool <List <Gizmo> > .Return(gizmoGroups[num10]); } gizmoGroups.Clear(); firstGizmos.Clear(); tmpAllGizmos.Clear();