private void DoCustomBottomButtons() { int num; int num1 = (!TutorSystem.TutorialMode ? 5 : 4); num = (num1 < 4 || (float)UI.screenWidth >= 1340f ? 1 : 2); int num2 = Mathf.CeilToInt((float)num1 / (float)num); Vector2 bottomButSize = Page.BottomButSize; float single = bottomButSize.x * (float)num2 + 10f * (float)(num2 + 1); float single1 = (float)num; Vector2 vector2 = Page.BottomButSize; float single2 = single1 * vector2.y + 10f * (float)(num + 1); Rect rect = new Rect(((float)UI.screenWidth - single) / 2f, (float)UI.screenHeight - single2 - 4f, single, single2); if (Find.WindowStack.IsOpen <WorldInspectPane>() && rect.x < InspectPaneUtility.PaneSize.x + 4f) { rect.x = InspectPaneUtility.PaneSize.x + 4f; } Widgets.DrawWindowBackground(rect); float bottomButSize1 = rect.xMin + 10f; float bottomButSize2 = rect.yMin + 10f; Text.Font = GameFont.Small; if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "Back".Translate(), true, false, true) && this.CanDoBack()) { this.DoBack(); } bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f); if (!TutorSystem.TutorialMode) { if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "Advanced".Translate(), true, false, true)) { Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile)); } bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f); } if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "SelectRandomSite".Translate(), true, false, true)) { SoundDefOf.Click.PlayOneShotOnCamera(null); Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile(); Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f); if (num == 2) { bottomButSize1 = rect.xMin + 10f; bottomButSize2 = bottomButSize2 + (Page.BottomButSize.y + 10f); } if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "WorldFactionsTab".Translate(), true, false, true)) { Find.WindowStack.Add(new Dialog_FactionDuringLanding()); } bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f); if (Widgets.ButtonText(new Rect(bottomButSize1, bottomButSize2, Page.BottomButSize.x, Page.BottomButSize.y), "Next".Translate(), true, false, true) && this.CanDoNext()) { this.DoNext(); } bottomButSize1 = bottomButSize1 + (Page.BottomButSize.x + 10f); GenUI.AbsorbClicksInRect(rect); }
private void DoCustomBottomButtons() { int num = TutorSystem.TutorialMode ? 4 : 5; int num2 = (num < 4 || !((float)UI.screenWidth < 1340f)) ? 1 : 2; int num3 = Mathf.CeilToInt((float)num / (float)num2); float num4 = Page.BottomButSize.x * (float)num3 + 10f * (float)(num3 + 1); float num5 = (float)num2 * Page.BottomButSize.y + 10f * (float)(num2 + 1); Rect rect = new Rect(((float)UI.screenWidth - num4) / 2f, (float)UI.screenHeight - num5 - 4f, num4, num5); WorldInspectPane worldInspectPane = Find.WindowStack.WindowOfType <WorldInspectPane>(); if (worldInspectPane != null && rect.x < InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f) { rect.x = InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f; } Widgets.DrawWindowBackground(rect); float num6 = rect.xMin + 10f; float num7 = rect.yMin + 10f; Text.Font = GameFont.Small; if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "Back".Translate()) && CanDoBack()) { DoBack(); } num6 += Page.BottomButSize.x + 10f; if (!TutorSystem.TutorialMode) { if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "Advanced".Translate())) { Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile)); } num6 += Page.BottomButSize.x + 10f; } if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "SelectRandomSite".Translate())) { SoundDefOf.Click.PlayOneShotOnCamera(); Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile(); Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } num6 += Page.BottomButSize.x + 10f; if (num2 == 2) { num6 = rect.xMin + 10f; num7 += Page.BottomButSize.y + 10f; } if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "WorldFactionsTab".Translate())) { Find.WindowStack.Add(new Dialog_FactionDuringLanding()); } num6 += Page.BottomButSize.x + 10f; if (Widgets.ButtonText(new Rect(num6, num7, Page.BottomButSize.x, Page.BottomButSize.y), "Next".Translate()) && CanDoNext()) { DoNext(); } num6 += Page.BottomButSize.x + 10f; GenUI.AbsorbClicksInRect(rect); }
protected override void FillTab() { Text.Font = GameFont.Small; Rect fullRect = GenUI.GetInnerRect(new Rect(10f, 10f, size.x - 10, size.y - 10)); Rect leftRect = fullRect.LeftHalf().Rounded(); Rect rightRect = fullRect.RightHalf().Rounded(); GUI.BeginGroup(fullRect); Widgets.Label(leftRect, "Pause at: "); minimumToAdd = (int)Widgets.HorizontalSlider(rightRect, minimumToAdd, 1, 50); GenUI.AbsorbClicksInRect(fullRect); GUI.EndGroup(); }
protected override void FillTab() { Building_SecurityCamera bpm = this.SelThing as Building_SecurityCamera; Text.Font = GameFont.Small; Rect innerRect1 = GenUI.GetInnerRect(new Rect(10.0f, 10.0f, this.size.x - 10, this.size.y - 10)); GUI.BeginGroup(innerRect1); Widgets.Label(new Rect(0, 5, this.size.x / 2, 30), "Area Name:"); bpm.markerName = Widgets.TextField(new Rect(90, 0, this.size.x / 2, 30), bpm.markerName.Substring(0, Math.Min(bpm.markerName.Length, 20))); GenUI.AbsorbClicksInRect(innerRect1); GUI.EndGroup(); }
public static void TickManagerUi(Rect timerRect) { TickManager tickManager = Find.TickManager; GUI.BeginGroup(timerRect); Rect rect = new Rect(0f, 0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y); DrawSlider(rect); if (Find.TickManager.slower.ForcedNormalSpeed) { Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f); } GUI.EndGroup(); GenUI.AbsorbClicksInRect(timerRect); UIHighlighter.HighlightOpportunity(timerRect, "TimeControls"); }
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { if (!caravan.Spawned) { return(new GizmoResult(GizmoState.Clear)); } Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f); Widgets.DrawWindowBackground(rect); GUI.BeginGroup(rect); Rect rect2 = rect.AtZero(); int? ticksToArrive = (caravan.pather.Moving ? new int?(CaravanArrivalTimeEstimator.EstimatedTicksToArrive(caravan, allowCaching: true)) : null); StringBuilder stringBuilder = new StringBuilder(); CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(tilesPerDay: TilesPerDayCalculator.ApproxTilesPerDay(caravan, stringBuilder), massUsage: caravan.MassUsage, massCapacity: caravan.MassCapacity, massCapacityExplanation: caravan.MassCapacityExplanation, tilesPerDayExplanation: stringBuilder.ToString(), daysWorthOfFood: caravan.DaysWorthOfFood, foragedFoodPerDay: caravan.forage.ForagedFoodPerDay, foragedFoodPerDayExplanation: caravan.forage.ForagedFoodPerDayExplanation, visibility: caravan.Visibility, visibilityExplanation: caravan.VisibilityExplanation), null, caravan.Tile, ticksToArrive, -9999f, rect2, lerpMassColor: true, null, multiline: true); GUI.EndGroup(); GenUI.AbsorbClicksInRect(rect); return(new GizmoResult(GizmoState.Clear)); }
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { if (!this.caravan.Spawned) { return(new GizmoResult(GizmoState.Clear)); } Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f); Widgets.DrawWindowBackground(rect); GUI.BeginGroup(rect); Rect rect2 = rect.AtZero(); int? ticksToArrive = (!this.caravan.pather.Moving) ? null : new int?(CaravanArrivalTimeEstimator.EstimatedTicksToArrive(this.caravan, true)); StringBuilder stringBuilder = new StringBuilder(); float tilesPerDay = TilesPerDayCalculator.ApproxTilesPerDay(this.caravan, stringBuilder); CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(this.caravan.MassUsage, this.caravan.MassCapacity, this.caravan.MassCapacityExplanation, tilesPerDay, stringBuilder.ToString(), this.caravan.DaysWorthOfFood, this.caravan.forage.ForagedFoodPerDay, this.caravan.forage.ForagedFoodPerDayExplanation, this.caravan.Visibility, this.caravan.VisibilityExplanation, -1f, -1f, null), null, this.caravan.Tile, ticksToArrive, -9999f, rect2, true, null, true); GUI.EndGroup(); GenUI.AbsorbClicksInRect(rect); return(new GizmoResult(GizmoState.Clear)); }
public static void DoTimeControlsGUI(Rect timerRect) { TickManager tickManager = Find.TickManager; GUI.BeginGroup(timerRect); Rect rect = new Rect(0f, 0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y); for (int i = 0; i < TimeControls.CachedTimeSpeedValues.Length; i++) { TimeSpeed timeSpeed = TimeControls.CachedTimeSpeedValues[i]; if (timeSpeed != TimeSpeed.Ultrafast) { if (Widgets.ButtonImage(rect, TexButton.SpeedButtonTextures[(int)timeSpeed])) { if (timeSpeed == TimeSpeed.Paused) { tickManager.TogglePaused(); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction); } else { tickManager.CurTimeSpeed = timeSpeed; PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); } TimeControls.PlaySoundOf(tickManager.CurTimeSpeed); } if (tickManager.CurTimeSpeed == timeSpeed) { GUI.DrawTexture(rect, TexUI.HighlightTex); } rect.x += rect.width; } } if (Find.TickManager.slower.ForcedNormalSpeed) { Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f); } GUI.EndGroup(); GenUI.AbsorbClicksInRect(timerRect); UIHighlighter.HighlightOpportunity(timerRect, "TimeControls"); if (Event.current.type == EventType.KeyDown) { if (KeyBindingDefOf.TogglePause.KeyDownEvent) { Find.TickManager.TogglePaused(); TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeed_Normal.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Normal; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeed_Fast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Fast; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeed_Superfast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Superfast; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (Prefs.DevMode) { if (KeyBindingDefOf.TimeSpeed_Ultrafast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Ultrafast; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); Event.current.Use(); } if (KeyBindingDefOf.Dev_TickOnce.KeyDownEvent && tickManager.CurTimeSpeed == TimeSpeed.Paused) { tickManager.DoSingleTick(); SoundDefOf.Clock_Stop.PlayOneShotOnCamera(null); } } } }
/// <summary> /// This is a rip of the DoCustomButtons() function in RimWorld.Page_SelectLandingSite with a new button. /// </summary> public void DoCustomButtons() { // HACK : changed the number of buttons from '5 : 4' to '6 : 5' as we add a button var num = !TutorSystem.TutorialMode ? 6 : 5; int num2; if (num >= 4 && UI.screenWidth < 1340f) { num2 = 2; } else { num2 = 1; } var num3 = Mathf.CeilToInt(num / (float)num2); var num4 = BottomButSize.x * num3 + 10f * (num3 + 1); var num5 = num2 * BottomButSize.y + 10f * (num2 + 1); var rect = new Rect((UI.screenWidth - num4) / 2f, UI.screenHeight - num5 - 4f, num4, num5); if (Find.WindowStack.IsOpen <WorldInspectPane>() && rect.x < InspectPaneUtility.PaneSize.x + 4f) { rect.x = InspectPaneUtility.PaneSize.x + 4f; } Widgets.DrawWindowBackground(rect); var num6 = rect.xMin + 10f; var num7 = rect.yMin + 10f; Text.Font = GameFont.Small; if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Back".Translate()) && CanDoBack()) { /* ADDED CODE */ #region INSERTED_CODE // make sure the prepare landing window (or its minimized window) is closed when we go back if (Find.WindowStack.IsOpen <MainWindow>() || Find.WindowStack.IsOpen <MinimizedWindow>()) { if (PrepareLanding.Instance.MainWindow != null) { PrepareLanding.Instance.MainWindow.ForceClose(); } } #endregion /* END ADDED CODE*/ DoBack(); } num6 += BottomButSize.x + 10f; if (!TutorSystem.TutorialMode) { if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Advanced".Translate())) { Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile)); } num6 += BottomButSize.x + 10f; } if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "SelectRandomSite".Translate())) { SoundDefOf.Click.PlayOneShotOnCamera(); Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile(); Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } num6 += BottomButSize.x + 10f; if (num2 == 2) { num6 = rect.xMin + 10f; num7 += BottomButSize.y + 10f; } if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "WorldFactionsTab".Translate())) { Find.WindowStack.Add(new Dialog_FactionDuringLanding()); } num6 += BottomButSize.x + 10f; /* inserted button code */ #region INSERTED_CODE if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Prepare Landing")) { Log.Message("[PrepareLanding] Page button pressed!"); // don't add a new window if the window is already there if (PrepareLanding.Instance.MainWindow == null) { PrepareLanding.Instance.MainWindow = new MainWindow(PrepareLanding.Instance.UserData); } PrepareLanding.Instance.MainWindow.Show(); } num6 += BottomButSize.x + 10f; #endregion INSERTED_CODE /* end of inserted code */ if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Next".Translate()) && CanDoNext()) { /* ADDED CODE */ #region INSERTED_CODE // make sure the prepare landing window (or its minimized window) is closed when we go to the next window / game stage if (Find.WindowStack.IsOpen <MainWindow>() || Find.WindowStack.IsOpen <MinimizedWindow>()) { if (PrepareLanding.Instance.MainWindow != null) { PrepareLanding.Instance.MainWindow.ForceClose(); } } #endregion /* END ADDED CODE*/ // go to next window DoNext(); } //num6 += BottomButSize.x + 10f; GenUI.AbsorbClicksInRect(rect); }
private void DoCustomBottomButtons() { int num = (!TutorSystem.TutorialMode) ? 5 : 4; int num2 = (num < 4 || !((float)UI.screenWidth < 1340f)) ? 1 : 2; int num3 = Mathf.CeilToInt((float)num / (float)num2); Vector2 bottomButSize = Page.BottomButSize; float num4 = bottomButSize.x * (float)num3 + 10f * (float)(num3 + 1); float num5 = (float)num2; Vector2 bottomButSize2 = Page.BottomButSize; float num6 = num5 * bottomButSize2.y + 10f * (float)(num2 + 1); Rect rect = new Rect(((float)UI.screenWidth - num4) / 2f, (float)UI.screenHeight - num6 - 4f, num4, num6); WorldInspectPane worldInspectPane = Find.WindowStack.WindowOfType <WorldInspectPane>(); if (worldInspectPane != null && rect.x < InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f) { rect.x = InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f; } Widgets.DrawWindowBackground(rect); float num7 = rect.xMin + 10f; float num8 = rect.yMin + 10f; Text.Font = GameFont.Small; float x = num7; float y = num8; Vector2 bottomButSize3 = Page.BottomButSize; float x2 = bottomButSize3.x; Vector2 bottomButSize4 = Page.BottomButSize; if (Widgets.ButtonText(new Rect(x, y, x2, bottomButSize4.y), "Back".Translate()) && CanDoBack()) { DoBack(); } float num9 = num7; Vector2 bottomButSize5 = Page.BottomButSize; num7 = num9 + (bottomButSize5.x + 10f); if (!TutorSystem.TutorialMode) { float x3 = num7; float y2 = num8; Vector2 bottomButSize6 = Page.BottomButSize; float x4 = bottomButSize6.x; Vector2 bottomButSize7 = Page.BottomButSize; if (Widgets.ButtonText(new Rect(x3, y2, x4, bottomButSize7.y), "Advanced".Translate())) { Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile)); } float num10 = num7; Vector2 bottomButSize8 = Page.BottomButSize; num7 = num10 + (bottomButSize8.x + 10f); } float x5 = num7; float y3 = num8; Vector2 bottomButSize9 = Page.BottomButSize; float x6 = bottomButSize9.x; Vector2 bottomButSize10 = Page.BottomButSize; if (Widgets.ButtonText(new Rect(x5, y3, x6, bottomButSize10.y), "SelectRandomSite".Translate())) { SoundDefOf.Click.PlayOneShotOnCamera(); Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile(); Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } float num11 = num7; Vector2 bottomButSize11 = Page.BottomButSize; num7 = num11 + (bottomButSize11.x + 10f); if (num2 == 2) { num7 = rect.xMin + 10f; float num12 = num8; Vector2 bottomButSize12 = Page.BottomButSize; num8 = num12 + (bottomButSize12.y + 10f); } float x7 = num7; float y4 = num8; Vector2 bottomButSize13 = Page.BottomButSize; float x8 = bottomButSize13.x; Vector2 bottomButSize14 = Page.BottomButSize; if (Widgets.ButtonText(new Rect(x7, y4, x8, bottomButSize14.y), "WorldFactionsTab".Translate())) { Find.WindowStack.Add(new Dialog_FactionDuringLanding()); } float num13 = num7; Vector2 bottomButSize15 = Page.BottomButSize; num7 = num13 + (bottomButSize15.x + 10f); float x9 = num7; float y5 = num8; Vector2 bottomButSize16 = Page.BottomButSize; float x10 = bottomButSize16.x; Vector2 bottomButSize17 = Page.BottomButSize; if (Widgets.ButtonText(new Rect(x9, y5, x10, bottomButSize17.y), "Next".Translate()) && CanDoNext()) { DoNext(); } float num14 = num7; Vector2 bottomButSize18 = Page.BottomButSize; num7 = num14 + (bottomButSize18.x + 10f); GenUI.AbsorbClicksInRect(rect); }
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); } Verse.GizmoGridDrawer.drawnHotKeys.Clear(); float num = (float)(Screen.width - 140); Text.Font = GameFont.Tiny; Vector2 topLeft = new Vector2(startX, (float)(Screen.height - 35) - GizmoGridDrawer.GizmoSpacing.y - 75f); mouseoverGizmo = null; Gizmo interactedGiz = null; Event @event = 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)Screen.height - topLeft.y; GizmoResult gizmoResult = gizmo2.GizmoOnGUI(topLeft); if (gizmoResult.State == GizmoState.Interacted) { @event = 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 && gizmo3.InheritInteractionsFrom(interactedGiz)) { gizmo3.ProcessInput(@event); } } if (interactedGiz is Designator_Build) { if (@event.button != 1 && GizmoGridDrawer.rightClickMaterialPreference != null && GizmoGridDrawer.rightClickMaterialPreference.Value) { Command command = interactedGiz as Command; if (command != null && command.CurActivateSound != null) { command.CurActivateSound.PlayOneShotOnCamera(); } Designator designator = interactedGiz as Designator; if (designator != null) { DesignatorManager.Select(designator); } } else { interactedGiz.ProcessInput(@event); } } else { interactedGiz.ProcessInput(@event); } Event.current.Use(); } }
public static void DoTimeControlsGUI(Rect timerRect) { DoConfigGUI(timerRect); timerRect.x -= 14f; var tickManager = Find.TickManager; GUI.BeginGroup(timerRect); var rect = new Rect(0f, 0f, 28f, 24f); for (var i = 0; i < CachedTimeSpeedValues.Length; i++) { var timeSpeed = CachedTimeSpeedValues[i]; if (Widgets.ButtonImage(rect, TexButton._SpeedButtonTextures[(int)timeSpeed])) { if (timeSpeed == TimeSpeed.Paused) { tickManager.TogglePaused(); } else { tickManager.CurTimeSpeed = timeSpeed; } PlaySoundOf(tickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); } if (tickManager.CurTimeSpeed == timeSpeed) { GUI.DrawTexture(rect, TexUI.HighlightTex); } rect.x += rect.width; } if (Find.TickManager.slower.ForcedNormalSpeed) { Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 3f); } GUI.EndGroup(); GenUI.AbsorbClicksInRect(timerRect); UIHighlighter.HighlightOpportunity(timerRect, "TimeControls"); if (Event.current.type == EventType.KeyDown) { if (KeyBindingDefOf.TogglePause.KeyDownEvent) { Find.TickManager.TogglePaused(); PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeedNormal.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Normal; PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeedFast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Fast; PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeedSuperfast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Superfast; PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeedUltrafast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Ultrafast; PlaySoundOf(Find.TickManager.CurTimeSpeed); Event.current.Use(); } if (Prefs.DevMode) { if (KeyBindingDefOf.TickOnce.KeyDownEvent && (tickManager.CurTimeSpeed == TimeSpeed.Paused)) { tickManager.DoSingleTick(); SoundDef.Named(SpeedSounds[0]).PlayOneShotOnCamera(); } } } }
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { var room = Room; if (room == null) { return(new GizmoResult(GizmoState.Clear)); } Rect rectWindow = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f); Widgets.DrawWindowBackground(rectWindow); Text.WordWrap = false; GUI.BeginGroup(rectWindow); Rect rectInner = rectWindow.AtZero().ContractedBy(10f); Text.Font = GameFont.Small; Rect rectTitle = new Rect(rectInner.x, rectInner.y - 2f, rectInner.width, 100f); var title = bed.Stats.title; Widgets.Label(rectTitle, title.Truncate(rectTitle.width)); float y = (float)(rectInner.y + (double)Text.LineHeight + Text.SpaceBetweenLines + 7.0); GUI.color = GuestBedStatsColor; Text.Font = GameFont.Tiny; IEnumerable <TaggedString> stats = bed.Stats.textAsArray; foreach (var label in stats) { Rect rectStat = new Rect(rectInner.x, y, rectInner.width, 100f); Widgets.Label(rectStat, label.Truncate(rectStat.width)); y += Text.LineHeight + Text.SpaceBetweenLines; } GUI.color = Color.white; Text.Font = GameFont.Small; GUI.EndGroup(); Text.WordWrap = true; GenUI.AbsorbClicksInRect(rectWindow); // Royal title info box if (!Mouse.IsOver(rectWindow) || !ModLister.RoyaltyInstalled) { return(new GizmoResult(GizmoState.Clear)); } Rect windowRect = BedStatsDrawer.GetWindowRect(); Find.WindowStack.ImmediateWindow(74975, windowRect, WindowLayer.Super, () => { BedStatsDrawer.DoBedInfos(windowRect, bed); }); // Can't get this to work :( //if (Widgets.ButtonInvisible(rectWindow)) //{ // ProcessInput(Event.current); // return new GizmoResult(GizmoState.Interacted, Event.current); //} //if (Mouse.IsOver(rectWindow)) //{ // TipSignal tip = new TipSignal(() => "ClickToLearnMore".Translate().Resolve(), (int) y * 37); // TooltipHandler.TipRegion(rectWindow, tip); //} return(new GizmoResult(GizmoState.Mouseover)); }
public static bool DoTimeControlsGUI(Rect timerRect) { TickManager tickManager = Find.TickManager; GUI.BeginGroup(timerRect); Rect rect = new Rect(0.0f, 0.0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y); for (int index = 0; index < TimeControls.CachedTimeSpeedValues.Length; ++index) { TimeSpeed timeSpeed = TimeControls.CachedTimeSpeedValues[index]; if (timeSpeed != TimeSpeed.Ultrafast) { if (Widgets.ButtonImage(rect, TexButton.SpeedButtonTextures[(int)timeSpeed])) { if (timeSpeed == TimeSpeed.Paused) { tickManager.TogglePaused(); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction); } else { tickManager.CurTimeSpeed = timeSpeed; PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); } TimeControls.PlaySoundOf(tickManager.CurTimeSpeed); } if (tickManager.CurTimeSpeed == timeSpeed) { GUI.DrawTexture(rect, (Texture)TexUI.HighlightTex); } rect.x += rect.width; } } if (Find.TickManager.slower.ForcedNormalSpeed) { Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f); } GUI.EndGroup(); GenUI.AbsorbClicksInRect(timerRect); UIHighlighter.HighlightOpportunity(timerRect, "TimeControls"); if (Event.current.type != EventType.KeyDown) { return(false); } if (KeyBindingDefOf.TogglePause.KeyDownEvent) { Find.TickManager.TogglePaused(); TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeedNormal.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Normal; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeedFast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Fast; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeedSuperfast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Superfast; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } //Removed to Allow Speed 4 Without Dev Mode. //if (!Prefs.DevMode) // return false; if (KeyBindingDefOf.TimeSpeedUltrafast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Ultrafast; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); Event.current.Use(); } if (!KeyBindingDefOf.TickOnce.KeyDownEvent || tickManager.CurTimeSpeed != TimeSpeed.Paused) { return(false); } tickManager.DoSingleTick(); SoundStarter.PlayOneShotOnCamera(SoundDef.Named(TimeControls.SpeedSounds[0]), (Map)null); return(false); }
public static bool DoTimeControlsGUI(Rect timerRect) { TickManager tickManager = Find.TickManager; GUI.BeginGroup(timerRect); Rect rect = new Rect(0f, 0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y); for (int i = 0; i < CachedTimeSpeedValues.Length; i++) { TimeSpeed timeSpeed = CachedTimeSpeedValues[i]; if (timeSpeed == TimeSpeed.Ultrafast) { continue; } if (Widgets.ButtonImage(rect, TexButton.SpeedButtonTextures[(uint)timeSpeed])) { if (timeSpeed == TimeSpeed.Paused) { tickManager.TogglePaused(); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction); } else { tickManager.CurTimeSpeed = timeSpeed; PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); } PlaySoundOf(tickManager.CurTimeSpeed); } if (tickManager.CurTimeSpeed == timeSpeed) { GUI.DrawTexture(rect, TexUI.HighlightTex); } rect.x += rect.width; } if (Find.TickManager.slower.ForcedNormalSpeed && !RimThreadedMod.Settings.disableforcedslowdowns) { Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f); } GUI.EndGroup(); GenUI.AbsorbClicksInRect(timerRect); UIHighlighter.HighlightOpportunity(timerRect, "TimeControls"); if (Event.current.type != EventType.KeyDown) { return(false); } if (KeyBindingDefOf.TogglePause.KeyDownEvent) { Find.TickManager.TogglePaused(); PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (!Find.WindowStack.WindowsForcePause) { if (KeyBindingDefOf.TimeSpeed_Normal.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Normal; PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeed_Fast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Fast; if (lastTickForcedSlow) { overrideForcedSlow = true; } //forceNormalSpeedUntil(Find.TickManager.slower) = 0; PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeed_Superfast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Superfast; if (lastTickForcedSlow) { overrideForcedSlow = true; } //forceNormalSpeedUntil(Find.TickManager.slower) = 0; PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeed_Ultrafast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Ultrafast; if (lastTickForcedSlow) { overrideForcedSlow = true; } //forceNormalSpeedUntil(Find.TickManager.slower) = 0; PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } } if (Prefs.DevMode) { if (KeyBindingDefOf.Dev_TickOnce.KeyDownEvent && tickManager.CurTimeSpeed == TimeSpeed.Paused) { tickManager.DoSingleTick(); SoundDefOf.Clock_Stop.PlayOneShotOnCamera(); } } return(false); }