示例#1
0
 private void DrawOutline(Rect rect)
 {
     MapRerollUtility.DrawWithGUIColor(OutlineColor, () => Widgets.DrawBox(rect));
 }
示例#2
0
        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);
            }
        }
示例#3
0
        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();
        }