public override void PreOpen() { var map = Find.CurrentMap; var resourceBalance = map == null ? 0f : RerollToolbox.GetStateForMap(map).ResourceBalance; balanceWidget = new Widget_ResourceBalance(resourceBalance); }
public GeneratedPreviewPageProvider(Map currentMap, World world) { startingMap = currentMap; this.world = world; var mapState = RerollToolbox.GetStateForMap(currentMap); lastGeneratedSeed = RerollToolbox.CurrentMapSeed(mapState); previewGenerator = new MapPreviewGenerator(); }
private bool MapWasCommitted(Map map) { if (map != lastSeenMap) { lastSeenMap = map; lastSeenMapCommitted = RerollToolbox.GetStateForMap().MapCommitted; } return(lastSeenMapCommitted); }
public void PageForward(BasePreviewPageProvider pageProvider, int numPages = 1) { var pageToOpen = pageProvider.CurrentPage + numPages; if (activeTab == previewsTab && RerollToolbox.GetOperationCost(PaidOperationType.GeneratePreviews, pageToOpen) > 0) { RerollToolbox.ChargeForOperation(PaidOperationType.GeneratePreviews, pageToOpen); } pageProvider.OpenPage(pageToOpen); }
private Widget_MapPreview CreatePreview() { lastGeneratedSeed = RerollToolbox.GetNextRerollSeed(lastGeneratedSeed); var promise = previewGenerator.QueuePreviewForSeed(lastGeneratedSeed, startingMap.Tile, world.info.initialMapSize.x, MapRerollController.Instance.PreviewCavesSetting); numQueuedPreviews++; promise.Finally(() => numQueuedPreviews--); return(new Widget_MapPreview(promise, lastGeneratedSeed) { OnFavoriteToggled = OnFavorite }); }
public Dialog_MapPreviews() { layer = WindowLayer.SubSuper; forcePause = true; absorbInputAroundWindow = true; draggable = false; doCloseX = true; doCloseButton = false; SetUpTabs(); mapState = RerollToolbox.GetStateForMap(); favoritesProvider = new ListPreviewPageProvider(); previewGenerator = new GeneratedPreviewPageProvider(Find.CurrentMap, Find.World); previewGenerator.OpenPage(0); previewGenerator.OnFavoriteToggled = OnPreviewFavoriteToggled; }
public static void RecordPodContents(ActiveDropPod __instance) { RerollToolbox.RecordPlayerAddedMapThings(__instance, __instance.Map); }
private float GetResourceBalance(Map map) { return(RerollToolbox.GetStateForMap(map).ResourceBalance); }
public static void RecordPlayerAddedMapThings(Caravan caravan, Map map) { RerollToolbox.RecordPlayerAddedMapThings(caravan.pawns.Owner, map); }
public override void DoWindowContents(Rect inRect) { // close on world map, on committed maps var mapState = RerollToolbox.GetStateForMap(); if (Find.World.renderer.wantedMode != WorldRenderMode.None || Find.CurrentMap == null || mapState.MapCommitted) { Close(); return; } float diceButtonSize = MapRerollController.Instance.WidgetSizeSetting; var buttonRect = new Rect((inRect.width - diceButtonSize) + Margin, -Margin, diceButtonSize, diceButtonSize); if (Widgets.ButtonImage(buttonRect, Resources.Textures.UIDiceActive)) { Close(); } var contentsRect = inRect.ContractedBy(ContentsPadding); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Medium; var headerRect = new Rect(contentsRect.x, contentsRect.y, contentsRect.width, 30f); Widgets.Label(headerRect, "MapReroll_windowTitle".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; var layoutRect = new Rect(contentsRect.x, contentsRect.y + headerRect.yMax, contentsRect.width, contentsRect.height - headerRect.yMax); GUILayout.BeginArea(layoutRect); GUILayout.BeginVertical(); var extraResourcesHeight = 0f; var separatorHeight = ContentsPadding + 1; var controlHeight = (layoutRect.height - (ControlSpacing * 2f + separatorHeight + extraResourcesHeight)) / 4f; balanceWidget.DrawLayout(controlHeight + extraResourcesHeight); GUILayout.Space(ControlSpacing); DoRerollTabButton(Resources.Textures.UIRerollMapOn, Resources.Textures.UIRerollMapOff, MapRerollUtility.WithCostSuffix("Reroll2_rerollMap", PaidOperationType.GeneratePreviews), null, controlHeight, () => { if (RerollToolbox.GetOperationCost(PaidOperationType.GeneratePreviews) > 0) { RerollToolbox.ChargeForOperation(PaidOperationType.GeneratePreviews); } Find.WindowStack.Add(new Dialog_MapPreviews()); }); GUILayout.Space(ControlSpacing); DoRerollTabButton(Resources.Textures.UIRerollGeysersOn, Resources.Textures.UIRerollGeysersOff, MapRerollUtility.WithCostSuffix("Reroll2_rerollGeysers", PaidOperationType.RerollGeysers), null, controlHeight, () => { if (!MapRerollController.Instance.GeyserRerollInProgress) { MapRerollController.Instance.RerollGeysers(); } else { Messages.Message("Reroll2_rerollInProgress".Translate(), MessageTypeDefOf.RejectInput); } }); DrawSeparator(separatorHeight); DoRerollTabButton(Resources.Textures.UICommitMapOn, Resources.Textures.UICommitMapOff, MapRerollUtility.WithCostSuffix("Reroll2_commitMap", PaidOperationType.RerollGeysers), "Reroll2_commitMap_tip".Translate(), controlHeight, () => { RerollToolbox.GetStateForMap().MapCommitted = true; MapRerollController.Instance.UIController.ResetCache(); }); GUILayout.EndVertical(); GUILayout.EndArea(); }