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); }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Rect rect; Rect outRect = (rect = inRect.ContractedBy(4f)); rect.xMax -= 33f; Rect rect2 = new Rect(0f, 0f, CategoryWidth, Text.CalcHeight("test", 1000f)); Rect rect3 = new Rect(rect2.xMax, 0f, TitleWidth, rect2.height); Rect rect4 = new Rect(rect3.xMax, 0f, NumberWidth, rect2.height); Rect rect5 = new Rect(rect4.xMax, 0f, rect.width - rect4.xMax, rect2.height); Widgets.BeginScrollView(outRect, ref scrollPosition, new Rect(0f, 0f, rect.width, rect2.height * (float)tweakValueFields.Count)); foreach (TweakInfo tweakValueField in tweakValueFields) { Widgets.Label(rect2, tweakValueField.tweakValue.category); Widgets.Label(rect3, $"{tweakValueField.field.DeclaringType.Name}.{tweakValueField.field.Name}"); float num; bool flag; if (tweakValueField.field.FieldType == typeof(float) || tweakValueField.field.FieldType == typeof(int) || tweakValueField.field.FieldType == typeof(ushort)) { float asFloat = GetAsFloat(tweakValueField.field); num = Widgets.HorizontalSlider(rect5, GetAsFloat(tweakValueField.field), tweakValueField.tweakValue.min, tweakValueField.tweakValue.max); SetFromFloat(tweakValueField.field, num); flag = asFloat != num; } else if (tweakValueField.field.FieldType == typeof(bool)) { bool num2 = (bool)tweakValueField.field.GetValue(null); bool checkOn = num2; Widgets.Checkbox(rect5.xMin, rect5.yMin, ref checkOn); tweakValueField.field.SetValue(null, checkOn); num = (checkOn ? 1 : 0); flag = num2 != checkOn; } else { Log.ErrorOnce($"Attempted to tweakvalue unknown field type {tweakValueField.field.FieldType}", 83944645); flag = false; num = tweakValueField.initial; } if (num != tweakValueField.initial) { GUI.color = Color.red; Widgets.Label(rect4, $"{tweakValueField.initial} -> {num}"); GUI.color = Color.white; if (Widgets.ButtonInvisible(rect4)) { flag = true; if (tweakValueField.field.FieldType == typeof(float) || tweakValueField.field.FieldType == typeof(int) || tweakValueField.field.FieldType == typeof(ushort)) { SetFromFloat(tweakValueField.field, tweakValueField.initial); } else if (tweakValueField.field.FieldType == typeof(bool)) { tweakValueField.field.SetValue(null, tweakValueField.initial != 0f); } else { Log.ErrorOnce($"Attempted to tweakvalue unknown field type {tweakValueField.field.FieldType}", 83944646); } } } else { Widgets.Label(rect4, $"{tweakValueField.initial}"); } if (flag) { MethodInfo method = tweakValueField.field.DeclaringType.GetMethod(tweakValueField.field.Name + "_Changed", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(null, null); } } rect2.y += rect2.height; rect3.y += rect2.height; rect4.y += rect2.height; rect5.y += rect2.height; } Widgets.EndScrollView(); }
protected void DoLabel(string label) { Text.Font = GameFont.Small; listing.Label(label); totalOptionsHeight += Text.CalcHeight(label, 300f) + 2f; }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Rect rect = inRect.ContractedBy(4f); Rect rect2 = rect; rect2.xMax -= 33f; Rect rect3 = new Rect(0f, 0f, EditWindow_TweakValues.CategoryWidth, Text.CalcHeight("test", 1000f)); Rect rect4 = new Rect(rect3.xMax, 0f, EditWindow_TweakValues.TitleWidth, rect3.height); Rect rect5 = new Rect(rect4.xMax, 0f, EditWindow_TweakValues.NumberWidth, rect3.height); Rect rect6 = new Rect(rect5.xMax, 0f, rect2.width - rect5.xMax, rect3.height); Widgets.BeginScrollView(rect, ref this.scrollPosition, new Rect(0f, 0f, rect2.width, rect3.height * (float)EditWindow_TweakValues.tweakValueFields.Count), true); foreach (EditWindow_TweakValues.TweakInfo tweakInfo in EditWindow_TweakValues.tweakValueFields) { Widgets.Label(rect3, tweakInfo.tweakValue.category); Widgets.Label(rect4, string.Format("{0}.{1}", tweakInfo.field.DeclaringType.Name, tweakInfo.field.Name)); float num; bool flag; if (tweakInfo.field.FieldType == typeof(float) || tweakInfo.field.FieldType == typeof(int) || tweakInfo.field.FieldType == typeof(ushort)) { float asFloat = this.GetAsFloat(tweakInfo.field); num = Widgets.HorizontalSlider(rect6, this.GetAsFloat(tweakInfo.field), tweakInfo.tweakValue.min, tweakInfo.tweakValue.max, false, null, null, null, -1f); this.SetFromFloat(tweakInfo.field, num); flag = (asFloat != num); } else if (tweakInfo.field.FieldType == typeof(bool)) { bool flag2 = (bool)tweakInfo.field.GetValue(null); bool flag3 = flag2; Widgets.Checkbox(rect6.xMin, rect6.yMin, ref flag3, 24f, false, false, null, null); tweakInfo.field.SetValue(null, flag3); num = (float)((!flag3) ? 0 : 1); flag = (flag2 != flag3); } else { Log.ErrorOnce(string.Format("Attempted to tweakvalue unknown field type {0}", tweakInfo.field.FieldType), 83944645, false); flag = false; num = tweakInfo.initial; } if (num != tweakInfo.initial) { GUI.color = Color.red; Widgets.Label(rect5, string.Format("{0} -> {1}", tweakInfo.initial, num)); GUI.color = Color.white; if (Widgets.ButtonInvisible(rect5, false)) { flag = true; if (tweakInfo.field.FieldType == typeof(float) || tweakInfo.field.FieldType == typeof(int) || tweakInfo.field.FieldType == typeof(ushort)) { this.SetFromFloat(tweakInfo.field, tweakInfo.initial); } else if (tweakInfo.field.FieldType == typeof(bool)) { tweakInfo.field.SetValue(null, tweakInfo.initial != 0f); } else { Log.ErrorOnce(string.Format("Attempted to tweakvalue unknown field type {0}", tweakInfo.field.FieldType), 83944646, false); } } } else { Widgets.Label(rect5, string.Format("{0}", tweakInfo.initial)); } if (flag) { MethodInfo method = tweakInfo.field.DeclaringType.GetMethod(tweakInfo.field.Name + "_Changed", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(null, null); } } rect3.y += rect3.height; rect4.y += rect3.height; rect5.y += rect3.height; rect6.y += rect3.height; } Widgets.EndScrollView(); }
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { Text.Font = GameFont.Tiny; Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f); bool flag = false; if (Mouse.IsOver(rect)) { flag = true; if (!disabled) { GUI.color = GenUI.MouseoverColor; } } Texture2D badTex = icon; if (badTex == null) { badTex = BaseContent.BadTex; } Material material = (!disabled) ? null : TexUI.GrayscaleGUI; GenUI.DrawTextureWithMaterial(rect, BGTex, material); MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command); Rect outerRect = rect; Vector2 position = outerRect.position; float x = iconOffset.x; Vector2 size = outerRect.size; float x2 = x * size.x; float y = iconOffset.y; Vector2 size2 = outerRect.size; outerRect.position = position + new Vector2(x2, y * size2.y); GUI.color = IconDrawColor; Widgets.DrawTextureFitted(outerRect, badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords, iconAngle, material); GUI.color = Color.white; bool flag2 = false; KeyCode keyCode = (hotKey != null) ? hotKey.MainKey : KeyCode.None; if (keyCode != 0 && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode)) { Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f); Widgets.Label(rect2, keyCode.ToStringReadable()); GizmoGridDrawer.drawnHotKeys.Add(keyCode); if (hotKey.KeyDownEvent) { flag2 = true; Event.current.Use(); } } if (Widgets.ButtonInvisible(rect)) { flag2 = true; } string labelCap = LabelCap; if (!labelCap.NullOrEmpty()) { float num = Text.CalcHeight(labelCap, rect.width); Rect rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num); GUI.DrawTexture(rect3, TexUI.GrayTextBG); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect3, labelCap); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } GUI.color = Color.white; if (DoTooltip) { TipSignal tip = Desc; if (disabled && !disabledReason.NullOrEmpty()) { string text = tip.text; tip.text = text + "\n\n" + "DisabledCommand".Translate() + ": " + disabledReason; } TooltipHandler.TipRegion(rect, tip); } if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect))) { UIHighlighter.HighlightOpportunity(rect, HighlightTag); } Text.Font = GameFont.Small; if (flag2) { if (disabled) { if (!disabledReason.NullOrEmpty()) { Messages.Message(disabledReason, MessageTypeDefOf.RejectInput, historical: false); } return(new GizmoResult(GizmoState.Mouseover, null)); } GizmoResult result; if (Event.current.button == 1) { result = new GizmoResult(GizmoState.OpenedFloatMenu, Event.current); } else { if (!TutorSystem.AllowAction(TutorTagSelect)) { return(new GizmoResult(GizmoState.Mouseover, null)); } result = new GizmoResult(GizmoState.Interacted, Event.current); TutorSystem.Notify_Event(TutorTagSelect); } return(result); } if (flag) { return(new GizmoResult(GizmoState.Mouseover, null)); } return(new GizmoResult(GizmoState.Clear, null)); }
public override GizmoResult GizmoOnGUI(Vector2 topLeft) { Rect rect = new Rect(topLeft.x, topLeft.y, this.Width, 75f); bool flag = false; if (Mouse.IsOver(rect)) { flag = true; GUI.color = GenUI.MouseoverColor; } Texture2D badTex = this.icon; if ((Object)badTex == (Object)null) { badTex = BaseContent.BadTex; } GUI.DrawTexture(rect, Command.BGTex); MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand); GUI.color = this.IconDrawColor; Widgets.DrawTextureFitted(rect, badTex, (float)(this.iconDrawScale * 0.85000002384185791), this.iconProportions, this.iconTexCoords, this.iconAngle); GUI.color = Color.white; bool flag2 = false; KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None; if (keyCode != 0 && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode)) { Rect rect2 = new Rect((float)(rect.x + 5.0), (float)(rect.y + 5.0), (float)(rect.width - 10.0), 18f); Widgets.Label(rect2, keyCode.ToStringReadable()); GizmoGridDrawer.drawnHotKeys.Add(keyCode); if (this.hotKey.KeyDownEvent) { flag2 = true; Event.current.Use(); } } if (Widgets.ButtonInvisible(rect, false)) { flag2 = true; } string labelCap = this.LabelCap; if (!labelCap.NullOrEmpty()) { float num = Text.CalcHeight(labelCap, rect.width); Rect rect3 = new Rect(rect.x, (float)(rect.yMax - num + 12.0), rect.width, num); GUI.DrawTexture(rect3, TexUI.GrayTextBG); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect3, labelCap); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } GUI.color = Color.white; if (this.DoTooltip) { TipSignal tip = this.Desc; if (base.disabled && !base.disabledReason.NullOrEmpty()) { string text = tip.text; tip.text = text + "\n\n" + "DisabledCommand".Translate() + ": " + base.disabledReason; } TooltipHandler.TipRegion(rect, tip); } if (!this.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect))) { UIHighlighter.HighlightOpportunity(rect, this.HighlightTag); } if (flag2) { if (base.disabled) { if (!base.disabledReason.NullOrEmpty()) { Messages.Message(base.disabledReason, MessageTypeDefOf.RejectInput); } return(new GizmoResult(GizmoState.Mouseover, null)); } if (!TutorSystem.AllowAction(this.TutorTagSelect)) { return(new GizmoResult(GizmoState.Mouseover, null)); } GizmoResult result = new GizmoResult(GizmoState.Interacted, Event.current); TutorSystem.Notify_Event(this.TutorTagSelect); return(result); } if (flag) { return(new GizmoResult(GizmoState.Mouseover, null)); } return(new GizmoResult(GizmoState.Clear, null)); }
public override void DoWindowContents(Rect inRect) { float num = inRect.y; if (!this.title.NullOrEmpty()) { Text.Font = GameFont.Medium; Widgets.Label(new Rect(0f, num, inRect.width, 42f), this.title); num += 42f; } Text.Font = GameFont.Small; Rect outRect = new Rect(inRect.x, num, inRect.width, inRect.height - 35f - 5f - num); float width = outRect.width - 16f; Rect viewRect = new Rect(0f, 0f, width, Text.CalcHeight(this.text, width)); Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect, true); Widgets.Label(new Rect(0f, 0f, viewRect.width, viewRect.height), this.text); Widgets.EndScrollView(); int num2 = (!this.buttonCText.NullOrEmpty()) ? 3 : 2; float num3 = inRect.width / (float)num2; float width2 = num3 - 20f; if (this.buttonADestructive) { GUI.color = new Color(1f, 0.3f, 0.35f); } string label = (!this.InteractionDelayExpired) ? (this.buttonAText + "(" + Mathf.Ceil(this.TimeUntilInteractive).ToString("F0") + ")") : this.buttonAText; if (Widgets.ButtonText(new Rect(num3 * (float)(num2 - 1) + 10f, inRect.height - 35f, width2, 35f), label, true, false, true)) { if (this.InteractionDelayExpired) { if (this.buttonAAction != null) { this.buttonAAction(); } this.Close(true); } } GUI.color = Color.white; if (this.buttonBText != null) { if (Widgets.ButtonText(new Rect(0f, inRect.height - 35f, width2, 35f), this.buttonBText, true, false, true)) { if (this.buttonBAction != null) { this.buttonBAction(); } this.Close(true); } } if (this.buttonCText != null) { if (Widgets.ButtonText(new Rect(num3 + 10f, inRect.height - 35f, width2, 35f), this.buttonCText, true, false, true)) { if (this.buttonCAction != null) { this.buttonCAction(); } if (this.buttonCClose) { this.Close(true); } } } }
public override float DrawHeight(float width) { return(Text.CalcHeight(text, width)); }
protected void DoLabel(string label) { Text.Font = GameFont.Small; base.listing.Label(label, -1f); base.totalOptionsHeight += (float)(Text.CalcHeight(label, 300f) + 2.0); }
static Text() { Font font = (Font)Resources.Load("Fonts/Calibri_tiny"); Font font2 = (Font)Resources.Load("Fonts/Arial_small"); Font font3 = (Font)Resources.Load("Fonts/Arial_medium"); Text.fontStyles[0] = new GUIStyle(GUI.skin.label); Text.fontStyles[0].font = font; Text.fontStyles[1] = new GUIStyle(GUI.skin.label); Text.fontStyles[1].font = font2; Text.fontStyles[1].contentOffset = new Vector2(0f, -1f); Text.fontStyles[2] = new GUIStyle(GUI.skin.label); Text.fontStyles[2].font = font3; for (int i = 0; i < Text.textFieldStyles.Length; i++) { Text.textFieldStyles[i] = new GUIStyle(GUI.skin.textField); Text.textFieldStyles[i].alignment = TextAnchor.MiddleLeft; } Text.textFieldStyles[0].font = font; Text.textFieldStyles[1].font = font2; Text.textFieldStyles[2].font = font3; for (int j = 0; j < Text.textAreaStyles.Length; j++) { Text.textAreaStyles[j] = new GUIStyle(Text.textFieldStyles[j]); Text.textAreaStyles[j].alignment = TextAnchor.UpperLeft; Text.textAreaStyles[j].wordWrap = true; } for (int k = 0; k < Text.textAreaReadOnlyStyles.Length; k++) { Text.textAreaReadOnlyStyles[k] = new GUIStyle(Text.textAreaStyles[k]); GUIStyle guistyle = Text.textAreaReadOnlyStyles[k]; guistyle.normal.background = null; guistyle.active.background = null; guistyle.onHover.background = null; guistyle.hover.background = null; guistyle.onFocused.background = null; guistyle.focused.background = null; } GUI.skin.settings.doubleClickSelectsWord = true; int num = 0; IEnumerator enumerator = Enum.GetValues(typeof(GameFont)).GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; GameFont font4 = (GameFont)obj; Text.Font = font4; Text.lineHeights[num] = Text.CalcHeight("W", 999f); Text.spaceBetweenLines[num] = Text.CalcHeight("W\nW", 999f) - Text.CalcHeight("W", 999f) * 2f; num++; } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } Text.Font = GameFont.Small; }