Пример #1
0
        private void DrawGeneralSettings([NotNull] Listing listing)
        {
            (Rect abbrLabel, Rect abbrField) = listing.GetRect(Text.LineHeight).Split(0.6f);

            UiHelper.Label(abbrLabel, _codeText);

            if (UiHelper.TextField(abbrField, storeIncident.abbreviation, out string newAbbr))
            {
                storeIncident.abbreviation = newAbbr;
            }

            if (_eventType == EventTypes.Default || _eventType == EventTypes.Variable)
            {
                (Rect costLabel, Rect costField) = listing.GetRect(Text.LineHeight).Split(0.6f);

                listing.Gap();
                Widgets.Label(costLabel, _priceText);

                if (UiHelper.NumberField(costField, out int value, ref _costBuffer, ref _costBufferValid, 1, int.MaxValue))
                {
                    storeIncident.cost = value;
                }
            }

            if (!storeIncident.defName.Equals("Sanctuary"))
            {
                (Rect capLabel, Rect capField) = listing.Split(0.6f);

                listing.Gap();
                Widgets.Label(capLabel, _timesText);

                if (UiHelper.NumberField(capField, out int value, ref _capBuffer, ref _capBufferValid, 1, 200))
                {
                    storeIncident.eventCap = value;
                }
            }

            if (storeIncidentVariables?.maxWager > 0)
            {
                listing.Gap();

                (Rect wagerLabel, Rect wagerField) = listing.Split(0.6f);
                Widgets.Label(wagerLabel, _wagerText);

                if (UiHelper.NumberField(wagerField, out int wager, ref _wagerBuffer, ref _wagerBufferValid, storeIncidentVariables.minPointsToFire, 20000))
                {
                    storeIncidentVariables.maxWager = wager;
                }
            }

            listing.Gap();
            (Rect karmaLabel, Rect karmaField) = listing.Split(0.6f);
            Widgets.Label(karmaLabel, _karmaText);

            if (Widgets.ButtonText(karmaField, storeIncident.karmaType.ToString()))
            {
                Find.WindowStack.Add(new FloatMenu(_karmaTypeOptions));
            }
        }
Пример #2
0
        private static void DrawOrders(Listing listing, TaggedString label, [NotNull] IReadOnlyCollection <Order> orders)
        {
            // Label
            var rect = CustomLabelDouble(listing, label, $"{orders.Count}: ", out var countSize);

            var grouped = orders.GroupBy(o => o.consumableDef);

            var rectImage = rect.RightHalf();

            rectImage.xMin += countSize.x;
            rectImage.width = rectImage.height = countSize.y;

            // Icons for each type of order
            foreach (var group in grouped)
            {
                if (group.Key == null)
                {
                    continue;
                }
                // A list of the patrons for the order
                DrawDefIcon(rectImage, group.Key, $"{group.Key.LabelCap}: {group.Select(o => o.patron.Name.ToStringShort).ToCommaList()}");
                rectImage.x += 2 + rectImage.width;

                // Will the next one fit?
                if (rectImage.xMax > rect.xMax)
                {
                    break;
                }
            }
            listing.Gap(listing.verticalSpacing);
        }
Пример #3
0
        private void DrawSettingsPanel(Listing listing)
        {
            (Rect nameLabel, Rect nameField) = listing.GetRect(Text.LineHeight).ToForm();
            Widgets.Label(nameLabel, "Points Base Name:");
            pointsBaseName = Widgets.TextField(nameField, pointsBaseName);

            if (!pointsBaseName.NullOrEmpty() && SettingsHelper.DrawClearButton(nameField))
            {
                pointsBaseName = "";
            }

            listing.Gap(Text.LineHeight);
            (Rect awardLabel, Rect awardField) = listing.GetRect(Text.LineHeight).ToForm();
            Widgets.Label(awardLabel, $"Reward viewers with {pointsBaseName}?");
            Widgets.Checkbox(awardField.x + awardField.width - 24f, awardField.y, ref rewardPoints);

            if (!rewardPoints)
            {
                return;
            }

            string minutesBuffer = minutesBetweenRewards.ToString();

            (Rect minutesLabel, Rect minutesField) = listing.GetRect(Text.LineHeight).ToForm();
            Widgets.Label(minutesLabel, $"Minutes Between {pointsBaseName} Rewards");
            Widgets.TextFieldNumeric(minutesField, ref minutesBetweenRewards, ref minutesBuffer);

            string pointsBuffer = pointsPerReward.ToString();

            (Rect pointsLabel, Rect pointsField) = listing.GetRect(Text.LineHeight).ToForm();
            Widgets.Label(pointsLabel, $"{pointsBaseName} Per Reward");
            Widgets.TextFieldNumeric(pointsField, ref pointsPerReward, ref pointsBuffer);
        }
Пример #4
0
 public void DrawModSetting(Listing list)
 {
     ListDrawAction().ForEach(a =>
     {
         a(list);
         list.Gap();
     });
     this.FinishDrawModSetting();
 }
 public static bool CustomCheckboxLabeled(Listing listing, string label, ref bool checkOn, string tooltip = null)
 {
     bool result = false;
     float lineHeight = Text.LineHeight;
     bool val = checkOn;
     Func<bool, bool> check = delegate (bool pressed) { result = pressed; if (pressed) val = !val; return val; };
     Rect rect = listing.GetRect(lineHeight);
     CustomCheckboxLabeled(rect, label, check, tooltip);
     checkOn = val;
     listing.Gap(listing.verticalSpacing);
     return result;
 }
Пример #6
0
        private static void DrawStockExpanded(Listing listing, TaggedString label, [NotNull] IReadOnlyCollection <Thing> stock)
        {
            // Label
            var rect = CustomLabelDouble(listing, label, $"{stock.Count}:", out var countSize);

            var grouped = stock.GroupBy(s => s.def);

            var rectImage = rect.RightHalf();

            rectImage.xMin  += countSize.x;
            rectImage.height = countSize.y;

            // Icons for each type of stock
            foreach (var group in grouped)
            {
                if (group.Key == null)
                {
                    continue;
                }
                // Amount label
                string amountText = $" {group.Count()}x";
                var    amountSize = Text.CalcSize(amountText);
                rectImage.width = amountSize.x;

                // Will it fit?
                if (rectImage.xMax + rectImage.height > rect.xMax)
                {
                    break;
                }

                // Draw label
                Widgets.Label(rectImage, amountText);
                rectImage.x += rectImage.width;
                // Icon
                rectImage.width = rectImage.height;
                DrawDefIcon(rectImage, group.Key, group.Key.LabelCap);
                rectImage.x += rectImage.width;

                // Will the next one fit?
                if (rectImage.xMax > rect.xMax)
                {
                    break;
                }
            }
            listing.Gap(listing.verticalSpacing);
        }
Пример #7
0
        private static void DrawDebts(Listing listing, TaggedString label, [NotNull] ReadOnlyCollection <Debt> debts)
        {
            // Label
            var rect = CustomLabelDouble(listing, label, $"{debts.Sum(debt => debt.amount).ToStringMoney()}", out var countSize);

            var rectIcon = rect.RightHalf();
            //rectIcon.xMin += countSize.x;
            var iconSize = rectIcon.width = rectIcon.height = countSize.y;

            var iconCols = Mathf.FloorToInt(rect.width / iconSize);
            var iconRows = Mathf.CeilToInt((float)debts.Count / iconCols);
            var height   = iconRows * iconSize;

            var rectIcons = listing.GetRect(height);

            rectIcon.x = rectIcons.x;
            rectIcon.y = rectIcons.y;

            // Icons for each type of stock
            int col = 0;

            foreach (var debt in debts)
            {
                if (debt.patron == null)
                {
                    continue;
                }
                if (debt.amount <= 0)
                {
                    continue;
                }

                // Icon
                DrawDefIcon(rectIcon, ThingDefOf.Silver, "TabRegisterDebtTooltip".Translate(debt.patron.Name.ToStringFull, debt.amount.ToStringMoney()), () => debt.amount = 0);
                rectIcon.x += iconSize;

                col++;
                if (col == iconCols)
                {
                    col        = 0;
                    rectIcon.x = rectIcons.x;
                }
            }

            listing.Gap(listing.verticalSpacing);
        }
Пример #8
0
        private static void DrawStock(Listing listing, TaggedString label, [NotNull] IReadOnlyDictionary <ThingDef, RestaurantStock.Stock> stock)
        {
            // Label
            var rect = CustomLabelDouble(listing, label, $"{stock.Values.Sum(pair => pair.items.Sum(item=>item.stackCount))}", out var countSize);

            var rectIcon = rect.RightHalf();
            //rectIcon.xMin += countSize.x;
            var iconSize = rectIcon.width = rectIcon.height = countSize.y;

            var iconCols = Mathf.FloorToInt(rect.width / iconSize);
            var iconRows = Mathf.CeilToInt((float)stock.Count / iconCols);
            var height   = iconRows * iconSize;

            var rectIcons = listing.GetRect(height);

            rectIcon.x = rectIcons.x;
            rectIcon.y = rectIcons.y;

            // Icons for each type of stock
            int col = 0;

            foreach (var group in stock.Values)
            {
                if (group.def == null)
                {
                    continue;
                }
                if (group.items.Count == 0)
                {
                    continue;
                }

                // Icon
                var value = (group.def.BaseMarketValue * MarketPriceFactor).ToStringMoney();
                DrawDefIcon(rectIcon, group.def, $"{group.items.Sum(item => item.stackCount)}x {group.def.LabelCap} ({value})");
                rectIcon.x += iconSize;

                col++;
                if (col == iconCols)
                {
                    col        = 0;
                    rectIcon.x = rectIcons.x;
                }
            }
            listing.Gap(listing.verticalSpacing);
        }
Пример #9
0
        public static void DecimalBox(this Listing listing,
                                      string label,
                                      ref decimal value,
                                      string tooltip = null,
                                      decimal min    = 0M,
                                      decimal max    = 1E+09M)
        {
            var lineHeight = Text.LineHeight;
            var rect       = listing.GetRect(lineHeight);

            if (!tooltip.NullOrEmpty())
            {
                if (Mouse.IsOver(rect))
                {
                    Widgets.DrawHighlight(rect);
                }

                TooltipHandler.TipRegion(rect, tooltip);
            }

            DrawDecimalBox(rect, label, ref value, min, max);
            listing.Gap(listing.verticalSpacing);
        }
Пример #10
0
        public static void ComboBox(this Listing listing,
                                    string label,
                                    Type type,
                                    ref string value,
                                    Action <string> callback,
                                    string tooltip = null)
        {
            var lineHeight = Text.LineHeight;
            var rect       = listing.GetRect(lineHeight);

            if (!tooltip.NullOrEmpty())
            {
                if (Mouse.IsOver(rect))
                {
                    Widgets.DrawHighlight(rect);
                }

                TooltipHandler.TipRegion(rect, tooltip);
            }

            DrawComboBox(rect, label, type, ref value, callback);
            listing.Gap(listing.verticalSpacing);
        }
Пример #11
0
        private void DrawCustomFields([NotNull] Listing listing)
        {
            (Rect levelLabel, Rect levelField) = listing.Split(0.6f);
            UiHelper.Label(levelLabel, _userLevelText);

            if (Widgets.ButtonText(levelField, GetInferredUserLevelText()))
            {
                Find.WindowStack.Add(new FloatMenu(_userLevelOptions));
            }

            listing.Gap(24f);

            if (UiHelper.FieldButton(listing.GetRect(Text.SmallFontHeight), Textures.QuestionMark, _tagTooltip))
            {
                Application.OpenURL("https://storytoolkit.fandom.com/wiki/Commands#Tags");
            }

            Rect editorPosition = listing.GetRect(Text.SmallFontHeight * 11f);

            GUI.BeginGroup(editorPosition);
            _command.outputMessage = Widgets.TextAreaScrollable(editorPosition.AtZero(), _command.outputMessage, ref _scrollPos);
            _editor ??= GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.GetControlID(FocusType.Keyboard, editorPosition)) as TextEditor;
            GUI.EndGroup();
        }
Пример #12
0
 public static void BigGap(this Listing listing)
 {
     listing.Gap(12f * 3);
 }
Пример #13
0
 public static void MediumGap(this Listing listing)
 {
     listing.Gap(12f * 2);
 }