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 void DoMouseWheelPageTurning(BasePreviewPageProvider pageProvider) { if (Event.current.type != EventType.ScrollWheel) { return; } var scrollAmount = Event.current.delta.y; if (scrollAmount > 0) { // scroll within purchased pages unless shift is held if (pageProvider.CurrentPage < mapState.NumPreviewPagesPurchased - 1 || HugsLibUtility.ShiftIsHeld || !MapRerollController.Instance.PaidRerollsSetting) { PageForward(pageProvider); } } else if (scrollAmount < 0) { PageBackwards(pageProvider); } }
public void PageBackwards(BasePreviewPageProvider pageProvider, int numPages = 1) { numPages = Mathf.Min(pageProvider.CurrentPage, numPages); pageProvider.OpenPage(pageProvider.CurrentPage - numPages); }
private void DoBottomBarControls(BasePreviewPageProvider pageProvider, Rect inRect) { var currentZoomedPreview = pageProvider.CurrentZoomedInPreview; if (currentZoomedPreview != null) { // zoomed in controls var generateBtnRect = new Rect(inRect.xMin, inRect.yMin, GenerateButtonSize.x, inRect.height); MapRerollUtility.DrawWithGUIColor(GenerateButtonColor, () => { if (Widgets.ButtonText(generateBtnRect, "Reroll2_previews_generateMap".Translate())) { SoundDefOf.Click.PlayOneShotOnCamera(); Close(); HugsLibController.Instance.DoLater.DoNextUpdate(() => { previewGenerator.WaitForDisposal(); MapRerollController.Instance.RerollMap(currentZoomedPreview.Seed); }); } }); var favoritesControlRect = new Rect(generateBtnRect.xMax + ElementSpacing, inRect.yMin, FavoriteControlSize.x, inRect.height); var favoriteCheckRect = new Rect(favoritesControlRect.xMin + ElementSpacing, favoritesControlRect.center.y - FavoriteControlSize.y / 2f, FavoriteControlSize.y, FavoriteControlSize.y); var checkLabelRect = new Rect(favoriteCheckRect.x + FavoriteControlSize.y + ElementSpacing, favoriteCheckRect.y - 7f, FavoriteControlSize.x, inRect.height); if (Widgets.ButtonInvisible(favoritesControlRect)) { OnPreviewFavoriteToggled(currentZoomedPreview); } GUI.DrawTextureWithTexCoords(favoriteCheckRect, currentZoomedPreview.IsFavorite ? Resources.Textures.UIFavoriteStarOn : Resources.Textures.UIFavoriteStarOff, new Rect(0, 0, FavoriteIconScale, FavoriteIconScale)); if (Mouse.IsOver(favoritesControlRect)) { Widgets.DrawHighlight(favoritesControlRect); } Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(checkLabelRect, "Reroll2_previews_favoriteCheck".Translate()); Text.Anchor = TextAnchor.UpperLeft; var zoomOutBtnRect = new Rect(inRect.xMax - PageButtonSize.x, inRect.yMin, PageButtonSize.x, inRect.height); if (Widgets.ButtonText(zoomOutBtnRect, "Reroll2_previews_zoomOut".Translate())) { currentZoomedPreview.ZoomOut(); } } else { // paging controls var numPagesToTurn = HugsLibUtility.ControlIsHeld ? 5 : 1; if (pageProvider.PageIsAvailable(pageProvider.CurrentPage - numPagesToTurn)) { if (Widgets.ButtonText(new Rect(inRect.xMin, inRect.yMin, PageButtonSize.x, inRect.height), "Reroll2_previews_prevPage".Translate())) { PageBackwards(pageProvider, numPagesToTurn); } } Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(inRect, "Page " + (pageProvider.CurrentPage + 1)); Text.Anchor = TextAnchor.UpperLeft; if (pageProvider.PageIsAvailable(pageProvider.CurrentPage + numPagesToTurn)) { var paidNextBtnLabel = MapRerollUtility.WithCostSuffix("Reroll2_previews_nextPage", PaidOperationType.GeneratePreviews, pageProvider.CurrentPage + numPagesToTurn); var nextBtnLabel = activeTab == previewsTab ? paidNextBtnLabel : "Reroll2_previews_nextPage".Translate("").ToString(); if (Widgets.ButtonText(new Rect(inRect.xMax - PageButtonSize.x, inRect.yMin, PageButtonSize.x, inRect.height), nextBtnLabel)) { PageForward(pageProvider, numPagesToTurn); } } DoMouseWheelPageTurning(pageProvider); } }