public static void LongEventsOnGUI() { if (LongEventHandler.currentEvent == null) { return; } float num = LongEventHandler.GUIRectSize.x; object currentEventTextLock = LongEventHandler.CurrentEventTextLock; lock (currentEventTextLock) { Text.Font = GameFont.Small; num = Mathf.Max(num, Text.CalcSize(LongEventHandler.currentEvent.eventText + "...").x + 40f); } Rect rect = new Rect(((float)UI.screenWidth - num) / 2f, ((float)UI.screenHeight - LongEventHandler.GUIRectSize.y) / 2f, num, LongEventHandler.GUIRectSize.y); rect = rect.Rounded(); if (!LongEventHandler.currentEvent.UseStandardWindow || Find.UIRoot == null || Find.WindowStack == null) { if (UIMenuBackgroundManager.background == null) { UIMenuBackgroundManager.background = new UI_BackgroundMain(); } UIMenuBackgroundManager.background.BackgroundOnGUI(); Widgets.DrawShadowAround(rect); Widgets.DrawWindowBackground(rect); LongEventHandler.DrawLongEventWindowContents(rect); } else { Find.WindowStack.ImmediateWindow(62893994, rect, WindowLayer.Super, delegate { LongEventHandler.DrawLongEventWindowContents(rect.AtZero()); }, true, false, 1f); } }
public override void ExtraOnGUI() { base.ExtraOnGUI(); if (!title.NullOrEmpty()) { Vector2 vector = new Vector2(windowRect.x, windowRect.y); Text.Font = GameFont.Small; float width = Mathf.Max(150f, 15f + Text.CalcSize(title).x); Rect titleRect = new Rect(vector.x + TitleOffset.x, vector.y + TitleOffset.y, width, 23f); Find.WindowStack.ImmediateWindow(6830963, titleRect, WindowLayer.Super, delegate { GUI.color = baseColor; Text.Font = GameFont.Small; Rect position = titleRect.AtZero(); position.width = 150f; GUI.DrawTexture(position, TexUI.TextBGBlack); Rect rect = titleRect.AtZero(); rect.x += 15f; Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect, title); Text.Anchor = TextAnchor.UpperLeft; }, doBackground: false, absorbInputAroundWindow: false, 0f); } }
public Dialog_DebugTables(string[,] tables) { this.table = tables; base.doCloseButton = true; base.doCloseX = true; Text.Font = GameFont.Tiny; for (int i = 0; i < this.table.GetLength(0); i++) { float num = 0f; for (int j = 0; j < this.table.GetLength(1); j++) { string text = this.table[i, j]; Vector2 vector = Text.CalcSize(text); float x = vector.x; if (x > num) { num = x; } } float num2 = (float)(num + 8.0); this.colWidths.Add(num2); this.totalWidth += num2; } }
private static float GetPawnLabelNameWidth(Pawn pawn, float truncateToWidth, Dictionary <string, string> truncatedLabelsCache, GameFont font) { GameFont font2 = Text.Font; Text.Font = font; string pawnLabel = GetPawnLabel(pawn, truncateToWidth, truncatedLabelsCache, font); float num; if (font == GameFont.Tiny) { num = pawnLabel.GetWidthCached(); } else { Vector2 vector = Text.CalcSize(pawnLabel); num = vector.x; } if (num < 20f) { num = 20f; } Text.Font = font2; return(num); }
public virtual void DrawButtonAt(float topY) { float num = (float)UI.screenWidth - 38f - 12f; Rect rect = new Rect(num, topY, 38f, 30f); Rect rect2 = new Rect(rect); float num2 = Time.time - arrivalTime; Color color = def.color; if (num2 < 1f) { rect2.y -= (1f - num2) * 200f; color.a = num2 / 1f; } if (!Mouse.IsOver(rect) && def.bounce && num2 > 15f && num2 % 5f < 1f) { float num3 = (float)UI.screenWidth * 0.06f; float num4 = 2f * (num2 % 1f) - 1f; float num5 = num3 * (1f - num4 * num4); rect2.x -= num5; } if (Event.current.type == EventType.Repaint) { if (def.flashInterval > 0f) { float num6 = Time.time - (arrivalTime + 1f); if (num6 > 0f && num6 % def.flashInterval < 1f) { GenUI.DrawFlash(num, topY, (float)UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, num6) * 0.55f, def.flashColor); } } GUI.color = color; Widgets.DrawShadowAround(rect2); GUI.DrawTexture(rect2, def.Icon); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperRight; string text = PostProcessedLabel(); Vector2 vector = Text.CalcSize(text); float x = vector.x; float y = vector.y; Vector2 vector2 = new Vector2(rect2.x + rect2.width / 2f, rect2.center.y - y / 2f + 4f); float num7 = vector2.x + x / 2f - (float)(UI.screenWidth - 2); if (num7 > 0f) { vector2.x -= num7; } GUI.DrawTexture(new Rect(vector2.x - x / 2f - 6f - 1f, vector2.y, x + 12f, 16f), TexUI.GrayTextBG); GUI.color = new Color(1f, 1f, 1f, 0.75f); Widgets.Label(new Rect(vector2.x - x / 2f, vector2.y - 3f, x, 999f), text); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; } if (CanDismissWithRightClick && Event.current.type == EventType.MouseDown && Event.current.button == 1 && Mouse.IsOver(rect)) { SoundDefOf.Click.PlayOneShotOnCamera(); Find.LetterStack.RemoveLetter(this); Event.current.Use(); } if (Widgets.ButtonInvisible(rect2)) { OpenLetter(); Event.current.Use(); } }
public virtual bool DoGUI(Rect rect, bool colonistOrdering, FloatMenu floatMenu) { Rect rect2 = rect; rect2.height--; bool flag = !Disabled && Mouse.IsOver(rect2); bool flag2 = false; Text.Font = CurrentFont; Rect rect3 = rect; rect3.xMin += 4f; rect3.xMax = rect.x + 27f; rect3.yMin += 4f; rect3.yMax = rect.y + 27f; if (flag) { rect3.x += 4f; } Rect rect4 = rect; rect4.xMin += HorizontalMargin; rect4.xMax -= HorizontalMargin; rect4.xMax -= 4f; rect4.xMax -= extraPartWidth + IconOffset; rect4.x += IconOffset; if (flag) { rect4.x += 4f; } Rect rect5 = default(Rect); if (extraPartWidth != 0f) { float num = Mathf.Min(Text.CalcSize(Label).x, rect4.width - 4f); rect5 = new Rect(rect4.xMin + num, rect4.yMin, extraPartWidth, 30f); flag2 = Mouse.IsOver(rect5); } if (!Disabled) { MouseoverSounds.DoRegion(rect2); } Color color = GUI.color; if (Disabled) { GUI.color = ColorBGDisabled * color; } else if (flag && !flag2) { GUI.color = ColorBGActiveMouseover * color; } else { GUI.color = ColorBGActive * color; } GUI.DrawTexture(rect, BaseContent.WhiteTex); GUI.color = ((!Disabled) ? ColorTextActive : ColorTextDisabled) * color; if (sizeMode == FloatMenuSizeMode.Tiny) { rect4.y += 1f; } Widgets.DrawAtlas(rect, TexUI.FloatMenuOptionBG); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect4, Label); Text.Anchor = TextAnchor.UpperLeft; GUI.color = iconColor; if (shownItem != null || drawPlaceHolderIcon) { Widgets.DefIcon(rect3, shownItem, null, 1f, drawPlaceHolderIcon); } else if ((bool)itemIcon) { GUI.DrawTexture(rect3, itemIcon); } GUI.color = color; if (extraPartOnGUI != null) { bool num2 = extraPartOnGUI(rect5); GUI.color = color; if (num2) { return(true); } } if (flag && mouseoverGuiAction != null) { mouseoverGuiAction(); } if (tutorTag != null) { UIHighlighter.HighlightOpportunity(rect, tutorTag); } if (Widgets.ButtonInvisible(rect2)) { if (tutorTag != null && !TutorSystem.AllowAction(tutorTag)) { return(false); } Chosen(colonistOrdering, floatMenu); if (tutorTag != null) { TutorSystem.Notify_Event(tutorTag); } return(true); } return(false); }
private void BuildTableSorted() { if (sortMode == SortMode.Off) { tableSorted = tableRaw; } else { List <List <string> > list = new List <List <string> >(); for (int i = 1; i < tableRaw.GetLength(1); i++) { list.Add(new List <string>()); for (int j = 0; j < tableRaw.GetLength(0); j++) { list[i - 1].Add(tableRaw[j, i]); } } NumericStringComparer comparer = new NumericStringComparer(); switch (sortMode) { case SortMode.Ascending: list = list.OrderBy((List <string> x) => x[sortColumn], comparer).ToList(); break; case SortMode.Descending: list = list.OrderByDescending((List <string> x) => x[sortColumn], comparer).ToList(); break; case SortMode.Off: throw new Exception(); } tableSorted = new string[tableRaw.GetLength(0), tableRaw.GetLength(1)]; for (int k = 0; k < tableRaw.GetLength(1); k++) { for (int l = 0; l < tableRaw.GetLength(0); l++) { if (k == 0) { tableSorted[l, k] = tableRaw[l, k]; } else { tableSorted[l, k] = list[k - 1][l]; } } } } colWidths.Clear(); for (int m = 0; m < tableRaw.GetLength(0); m++) { float item; if (colVisible[m]) { float num = 0f; for (int n = 0; n < tableRaw.GetLength(1); n++) { float x2 = Text.CalcSize(tableRaw[m, n]).x; if (x2 > num) { num = x2; } } item = num + 2f; } else { item = 10f; } colWidths.Add(item); } rowHeights.Clear(); for (int num2 = 0; num2 < tableSorted.GetLength(1); num2++) { float num3 = 0f; for (int num4 = 0; num4 < tableSorted.GetLength(0); num4++) { float y = Text.CalcSize(tableSorted[num4, num2]).y; if (y > num3) { num3 = y; } } rowHeights.Add(num3 + 2f); } }
protected virtual GizmoResult GizmoOnGUIInt(Rect butRect, bool shrunk = false) { Text.Font = GameFont.Tiny; bool flag = false; if (Mouse.IsOver(butRect)) { flag = true; if (!disabled) { GUI.color = GenUI.MouseoverColor; } } MouseoverSounds.DoRegion(butRect, SoundDefOf.Mouseover_Command); Material material = (disabled ? TexUI.GrayscaleGUI : null); GenUI.DrawTextureWithMaterial(butRect, shrunk ? BGTextureShrunk : BGTexture, material); DrawIcon(butRect, material); bool flag2 = false; KeyCode keyCode = ((hotKey != null) ? hotKey.MainKey : KeyCode.None); if (keyCode != 0 && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode)) { Vector2 vector = (shrunk ? new Vector2(3f, 0f) : new Vector2(5f, 3f)); Widgets.Label(new Rect(butRect.x + vector.x, butRect.y + vector.y, butRect.width - 10f, 18f), keyCode.ToStringReadable()); GizmoGridDrawer.drawnHotKeys.Add(keyCode); if (hotKey.KeyDownEvent) { flag2 = true; Event.current.Use(); } } if (Widgets.ButtonInvisible(butRect)) { flag2 = true; } if (!shrunk) { string topRightLabel = TopRightLabel; if (!topRightLabel.NullOrEmpty()) { Vector2 vector2 = Text.CalcSize(topRightLabel); Rect position; Rect rect = (position = new Rect(butRect.xMax - vector2.x - 2f, butRect.y + 3f, vector2.x, vector2.y)); position.x -= 2f; position.width += 3f; GUI.color = Color.white; Text.Anchor = TextAnchor.UpperRight; GUI.DrawTexture(position, TexUI.GrayTextBG); Widgets.Label(rect, topRightLabel); Text.Anchor = TextAnchor.UpperLeft; } string labelCap = LabelCap; if (!labelCap.NullOrEmpty()) { float num = Text.CalcHeight(labelCap, butRect.width); Rect rect2 = new Rect(butRect.x, butRect.yMax - num + 12f, butRect.width, num); GUI.DrawTexture(rect2, TexUI.GrayTextBG); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect2, labelCap); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } GUI.color = Color.white; } if (Mouse.IsOver(butRect) && DoTooltip) { TipSignal tip = Desc; if (disabled && !disabledReason.NullOrEmpty()) { ref string text = ref tip.text; text += "\n\n" + "DisabledCommand".Translate() + ": " + disabledReason; } TooltipHandler.TipRegion(butRect, tip); }
private void BuildTableSorted() { if (this.sortMode == Window_DebugTable.SortMode.Off) { this.tableSorted = this.tableRaw; } else { List <List <string> > list = new List <List <string> >(); for (int i = 1; i < this.tableRaw.GetLength(1); i++) { list.Add(new List <string>()); for (int j = 0; j < this.tableRaw.GetLength(0); j++) { list[i - 1].Add(this.tableRaw[j, i]); } } Window_DebugTable.NumericStringComparer comparer = new Window_DebugTable.NumericStringComparer(); Window_DebugTable.SortMode sortMode = this.sortMode; if (sortMode != Window_DebugTable.SortMode.Ascending) { if (sortMode != Window_DebugTable.SortMode.Descending) { if (sortMode == Window_DebugTable.SortMode.Off) { throw new Exception(); } } else { list = list.OrderByDescending((List <string> x) => x[this.sortColumn], comparer).ToList <List <string> >(); } } else { list = list.OrderBy((List <string> x) => x[this.sortColumn], comparer).ToList <List <string> >(); } this.tableSorted = new string[this.tableRaw.GetLength(0), this.tableRaw.GetLength(1)]; for (int k = 0; k < this.tableRaw.GetLength(1); k++) { for (int l = 0; l < this.tableRaw.GetLength(0); l++) { if (k == 0) { this.tableSorted[l, k] = this.tableRaw[l, k]; } else { this.tableSorted[l, k] = list[k - 1][l]; } } } } this.colWidths.Clear(); for (int m = 0; m < this.tableRaw.GetLength(0); m++) { float item; if (this.colVisible[m]) { float num = 0f; for (int n = 0; n < this.tableRaw.GetLength(1); n++) { string text = this.tableRaw[m, n]; float x2 = Text.CalcSize(text).x; if (x2 > num) { num = x2; } } item = num + 2f; } else { item = 10f; } this.colWidths.Add(item); } this.rowHeights.Clear(); for (int num2 = 0; num2 < this.tableSorted.GetLength(1); num2++) { float num3 = 0f; for (int num4 = 0; num4 < this.tableSorted.GetLength(0); num4++) { string text2 = this.tableSorted[num4, num2]; float y = Text.CalcSize(text2).y; if (y > num3) { num3 = y; } } this.rowHeights.Add(num3 + 2f); } }
public virtual bool DoGUI(Rect rect, bool colonistOrdering, FloatMenu floatMenu) { Rect rect2 = rect; rect2.height -= 1f; bool flag = !this.Disabled && Mouse.IsOver(rect2); bool flag2 = false; Text.Font = this.CurrentFont; Rect rect3 = rect; rect3.xMin += this.HorizontalMargin; rect3.xMax -= this.HorizontalMargin; rect3.xMax -= 4f; rect3.xMax -= this.extraPartWidth; if (flag) { rect3.x += 4f; } Rect rect4 = default(Rect); if (this.extraPartWidth != 0f) { float num = Mathf.Min(Text.CalcSize(this.Label).x, rect3.width - 4f); rect4 = new Rect(rect3.xMin + num, rect3.yMin, this.extraPartWidth, 30f); flag2 = Mouse.IsOver(rect4); } if (!this.Disabled) { MouseoverSounds.DoRegion(rect2); } Color color = GUI.color; if (this.Disabled) { GUI.color = FloatMenuOption.ColorBGDisabled * color; } else if (flag && !flag2) { GUI.color = FloatMenuOption.ColorBGActiveMouseover * color; } else { GUI.color = FloatMenuOption.ColorBGActive * color; } GUI.DrawTexture(rect, BaseContent.WhiteTex); GUI.color = (this.Disabled ? FloatMenuOption.ColorTextDisabled : FloatMenuOption.ColorTextActive) * color; if (this.sizeMode == FloatMenuSizeMode.Tiny) { rect3.y += 1f; } Widgets.DrawAtlas(rect, TexUI.FloatMenuOptionBG); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect3, this.Label); Text.Anchor = TextAnchor.UpperLeft; GUI.color = color; if (this.extraPartOnGUI != null) { bool flag3 = this.extraPartOnGUI(rect4); GUI.color = color; if (flag3) { return(true); } } if (flag && this.mouseoverGuiAction != null) { this.mouseoverGuiAction(); } if (this.tutorTag != null) { UIHighlighter.HighlightOpportunity(rect, this.tutorTag); } if (!Widgets.ButtonInvisible(rect2, false)) { return(false); } if (this.tutorTag != null && !TutorSystem.AllowAction(this.tutorTag)) { return(false); } this.Chosen(colonistOrdering, floatMenu); if (this.tutorTag != null) { TutorSystem.Notify_Event(this.tutorTag); } return(true); }
public static void LongEventsOnGUI() { if (currentEvent == null) { GameplayTipWindow.ResetTipTimer(); return; } float num = StatusRectSize.x; lock (CurrentEventTextLock) { Text.Font = GameFont.Small; num = Mathf.Max(num, Text.CalcSize(currentEvent.eventText + "...").x + 40f); } bool flag = Find.UIRoot != null && !currentEvent.UseStandardWindow && currentEvent.showExtraUIInfo; bool flag2 = Find.UIRoot != null && Current.Game != null && !currentEvent.UseStandardWindow && currentEvent.showExtraUIInfo; Vector2 vector = flag2 ? ModSummaryWindow.GetEffectiveSize() : Vector2.zero; float num2 = StatusRectSize.y; if (flag2) { num2 += 17f + vector.y; } if (flag) { num2 += 17f + GameplayTipWindow.WindowSize.y; } float num3 = ((float)UI.screenHeight - num2) / 2f; Vector2 offset = new Vector2(((float)UI.screenWidth - GameplayTipWindow.WindowSize.x) / 2f, num3 + StatusRectSize.y + 17f); Vector2 offset2 = new Vector2(((float)UI.screenWidth - vector.x) / 2f, offset.y + GameplayTipWindow.WindowSize.y + 17f); Rect r = new Rect(((float)UI.screenWidth - num) / 2f, num3, num, StatusRectSize.y); r = r.Rounded(); if (!currentEvent.UseStandardWindow || Find.UIRoot == null || Find.WindowStack == null) { if (UIMenuBackgroundManager.background == null) { UIMenuBackgroundManager.background = new UI_BackgroundMain(); } UIMenuBackgroundManager.background.BackgroundOnGUI(); Widgets.DrawShadowAround(r); Widgets.DrawWindowBackground(r); DrawLongEventWindowContents(r); if (flag) { GameplayTipWindow.DrawWindow(offset, useWindowStack: false); } if (flag2) { ModSummaryWindow.DrawWindow(offset2, useWindowStack: false); TooltipHandler.DoTooltipGUI(); } } else { DrawLongEventWindow(r); if (flag) { GameplayTipWindow.DrawWindow(offset, useWindowStack: true); } } }
private void BuildTableSorted() { if (sortMode == SortMode.Off) { tableSorted = tableRaw; } else { List <List <string> > list = new List <List <string> >(); for (int i = 1; i < tableRaw.GetLength(1); i++) { list.Add(new List <string>()); for (int j = 0; j < tableRaw.GetLength(0); j++) { list[i - 1].Add(tableRaw[j, i]); } } NumericStringComparer comparer = new NumericStringComparer(); switch (sortMode) { case SortMode.Ascending: list = list.OrderBy((List <string> x) => x[sortColumn], comparer).ToList(); break; case SortMode.Descending: list = list.OrderByDescending((List <string> x) => x[sortColumn], comparer).ToList(); break; case SortMode.Off: throw new Exception(); } tableSorted = new string[tableRaw.GetLength(0), tableRaw.GetLength(1)]; for (int k = 0; k < tableRaw.GetLength(1); k++) { for (int l = 0; l < tableRaw.GetLength(0); l++) { if (k == 0) { string[,] array = tableSorted; int num = l; int num2 = k; string text = tableRaw[l, k]; array[num, num2] = text; } else { string[,] array2 = tableSorted; int num3 = l; int num4 = k; string text2 = list[k - 1][l]; array2[num3, num4] = text2; } } } } colWidths.Clear(); for (int m = 0; m < tableRaw.GetLength(0); m++) { float item; if (colVisible[m]) { float num5 = 0f; for (int n = 0; n < tableRaw.GetLength(1); n++) { string text3 = tableRaw[m, n]; Vector2 vector = Text.CalcSize(text3); float x2 = vector.x; if (x2 > num5) { num5 = x2; } } item = num5 + 2f; } else { item = 10f; } colWidths.Add(item); } rowHeights.Clear(); for (int num6 = 0; num6 < tableSorted.GetLength(1); num6++) { float num7 = 0f; for (int num8 = 0; num8 < tableSorted.GetLength(0); num8++) { string text4 = tableSorted[num8, num6]; Vector2 vector2 = Text.CalcSize(text4); float y = vector2.y; if (y > num7) { num7 = y; } } rowHeights.Add(num7 + 2f); } }
public virtual void DrawButtonAt(float topY) { float num = (float)((float)UI.screenWidth - 38.0 - 12.0); Rect rect = new Rect(num, topY, 38f, 30f); Rect rect2 = new Rect(rect); float num2 = Time.time - this.arrivalTime; Color color = this.def.color; if (num2 < 1.0) { rect2.y -= (float)((1.0 - num2) * 200.0); color.a = (float)(num2 / 1.0); } if (!Mouse.IsOver(rect) && this.def.bounce && num2 > 15.0 && num2 % 5.0 < 1.0) { float num3 = (float)((float)UI.screenWidth * 0.059999998658895493); float num4 = (float)(2.0 * (num2 % 1.0) - 1.0); float num5 = (float)(num3 * (1.0 - num4 * num4)); rect2.x -= num5; } if (this.def.flashInterval > 0.0) { float num6 = (float)(Time.time - (this.arrivalTime + 1.0)); if (num6 > 0.0 && num6 % this.def.flashInterval < 1.0) { GenUI.DrawFlash(num, topY, (float)((float)UI.screenWidth * 0.60000002384185791), (float)(Pulser.PulseBrightness(1f, 1f, num6) * 0.550000011920929), this.def.flashColor); } } GUI.color = color; Widgets.DrawShadowAround(rect2); GUI.DrawTexture(rect2, this.def.Icon); GUI.color = Color.white; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperRight; string text = this.PostProcessedLabel(); Vector2 vector = Text.CalcSize(text); float x = vector.x; float y = vector.y; double x2 = rect2.x + rect2.width / 2.0; Vector2 center = rect2.center; Vector2 vector2 = new Vector2((float)x2, (float)(center.y - y / 4.0)); float num7 = (float)(vector2.x + x / 2.0 - (float)(UI.screenWidth - 2)); if (num7 > 0.0) { vector2.x -= num7; } Rect position = new Rect((float)(vector2.x - x / 2.0 - 4.0 - 1.0), vector2.y, (float)(x + 8.0), 12f); GUI.DrawTexture(position, TexUI.GrayTextBG); GUI.color = new Color(1f, 1f, 1f, 0.75f); Rect rect3 = new Rect((float)(vector2.x - x / 2.0), (float)(vector2.y - 3.0), x, 999f); Widgets.Label(rect3, text); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Mouse.IsOver(rect)) { SoundDefOf.Click.PlayOneShotOnCamera(null); Find.LetterStack.RemoveLetter(this); Event.current.Use(); } if (Widgets.ButtonInvisible(rect2, false)) { this.OpenLetter(); Event.current.Use(); } }