예제 #1
0
        public override void DoWindowContents(Rect inRect)
        {
            if (!checkedForBackup || !haveBackup)
            {
                MakeSureSaveExists();
                return;
            }

            Listing_Standard ls = new Listing_Standard();

            ls.Begin(inRect);
            ls.Label(storeIncident.label.CapitalizeFirst());

            ls.Gap();

            if (storeIncident.cost > 0)
            {
                storeIncident.abbreviation = ls.TextEntryLabeled("Purchase Code:", storeIncident.abbreviation);

                ls.Gap();

                ls.AddLabeledNumericalTextField <int>("Cost", ref storeIncident.cost);

                ls.SliderLabeled("Max times per " + ToolkitSettings.EventCooldownInterval + " ingame day(s)", ref storeIncident.eventCap, storeIncident.eventCap.ToString(), 0, 15);

                if (variableIncident && storeIncidentVariables.maxWager > 0)
                {
                    ls.Gap();
                    ls.SliderLabeled("Maximum coin wager", ref storeIncidentVariables.maxWager, storeIncidentVariables.cost.ToString(), storeIncident.cost, 20000f);
                    if (storeIncidentVariables.maxWager < storeIncidentVariables.cost)
                    {
                        storeIncidentVariables.maxWager = storeIncidentVariables.cost * 2;
                    }
                }


                ls.Gap();

                ls.AddLabeledRadioList("Karma Type", karmaTypeStrings, ref setKarmaType);

                storeIncident.karmaType = (KarmaType)Enum.Parse(typeof(KarmaType), setKarmaType);

                ls.Gap();

                if (ls.ButtonTextLabeled("Disable Store Incident", "Disable"))
                {
                    storeIncident.cost = -10;
                }
            }

            ls.Gap();

            if (storeIncident.defName == "Item")
            {
                ls.SliderLabeled("Max times per " + ToolkitSettings.EventCooldownInterval + " ingame day(s)", ref storeIncident.eventCap, storeIncident.eventCap.ToString(), 0, 15);

                ls.Gap();
            }

            if (variableIncident && storeIncidentVariables.customSettings)
            {
                ls.Gap();

                if (ls.ButtonTextLabeled("Edit Extra Settings", "Settings"))
                {
                    storeIncidentVariables.settings.EditSettings();
                }
            }

            ls.Gap();

            if (storeIncident.defName != "Item" && ls.ButtonTextLabeled("Reset to Default", "Reset"))
            {
                Store_IncidentEditor.LoadBackup(storeIncident);
                if (storeIncident.cost < 1)
                {
                    storeIncident.cost = 50;
                }
                setKarmaType = storeIncident.karmaType.ToString();
                MakeSureSaveExists(true);
            }

            if (storeIncident.defName == "Item" && ls.ButtonTextLabeled("Edit item prices", "Edit"))
            {
                Type type = typeof(StoreItemsWindow);
                Find.WindowStack.TryRemove(type);

                Window window = new StoreItemsWindow();
                Find.WindowStack.Add(window);
            }

            ls.End();
        }
예제 #2
0
        /// <summary>
        ///     Draws the given <see cref="EventItem"/> in the pre-defined row
        ///     space.
        /// </summary>
        /// <param name="canvas">
        ///     The region to draw the <see cref="EventItem"/>
        ///     in
        /// </param>
        /// <param name="ev">The <see cref="EventItem"/> to draw</param>
        protected virtual void DrawEvent(Rect canvas, [NotNull] TableSettingsItem <EventItem> ev)
        {
            Rect checkboxRect      = LayoutHelper.IconRect(_stateHeaderRect.x + 2f, canvas.y + 2f, _stateHeaderRect.width - 4f, RowLineHeight - 4f);
            var  nameMouseOverRect = new Rect(NameHeaderRect.x, canvas.y, NameHeaderRect.width, RowLineHeight);
            var  nameRect          = new Rect(NameHeaderTextRect.x, canvas.y, NameHeaderTextRect.width, RowLineHeight);
            var  priceRect         = new Rect(PriceHeaderTextRect.x, canvas.y, PriceHeaderTextRect.width, RowLineHeight);
            var  karmaRect         = new Rect(KarmaHeaderTextRect.x, canvas.y, KarmaHeaderTextRect.width, RowLineHeight);

            Rect settingRect = LayoutHelper.IconRect(
                _expandedHeaderRect.x + 2f,
                canvas.y + Mathf.FloorToInt(Mathf.Abs(_expandedHeaderRect.width - RowLineHeight) / 2f) + 2f,
                _expandedHeaderRect.width - 4f,
                _expandedHeaderRect.width - 4f
                );

            bool proxy = ev.Data.Enabled;

            if (UiHelper.DrawCheckbox(checkboxRect, ref proxy))
            {
                if (!ev.Data.Enabled && proxy)
                {
                    Store_IncidentEditor.LoadBackup(ev.Data.Incident);
                }

                ev.Data.Enabled = proxy;

                if (!Store_IncidentEditor.CopyExists(ev.Data.Incident))
                {
                    Store_IncidentEditor.SaveCopy(ev.Data.Incident);
                }
            }

            DrawConfigurableEventName(nameRect, ev);

            if (!ev.EditingName)
            {
                Widgets.DrawHighlightIfMouseover(nameMouseOverRect);

                if (!ev.Data.Incident.description.NullOrEmpty())
                {
                    TooltipHandler.TipRegion(nameMouseOverRect, ev.Data.Incident.description);
                }
            }

            if (ev.Data.Enabled && ev.Data.CostEditable)
            {
                int cost = ev.Data.Cost;
                SettingsHelper.DrawPriceField(priceRect, ref cost);
                ev.Data.Cost = cost;
            }

            UiHelper.Label(karmaRect, ev.Data.KarmaType.ToString());

            if (Widgets.ButtonImage(settingRect, Textures.Gear))
            {
                ev.SettingsVisible = !ev.SettingsVisible;
            }

            if (!ev.SettingsVisible)
            {
                return;
            }

            var expandedRect = new Rect(
                NameHeaderRect.x + 10f,
                canvas.y + RowLineHeight + 10f,
                canvas.width - checkboxRect.width - settingRect.width - 20f,
                canvas.height - RowLineHeight - 20f
                );

            GUI.BeginGroup(expandedRect);
            DrawExpandedSettings(expandedRect.AtZero(), ev);
            GUI.EndGroup();
        }