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);
                }

                ls.Gap();

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

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

                if (variableIncident)
                {
                    ls.Gap();
                    ls.GapLine();
                    ls.Label("Custom Settings");

                    int KeyIndex = 0;

                    if (storeIncidentVariables.customSettingStringValues != null)
                    {
                        foreach (string str in storeIncidentVariables.customSettingStringValues)
                        {
                            string key = storeIncidentVariables.customSettingKeys[KeyIndex];
                            CustomSettings.SetStringSetting(key, ls.TextEntryLabeled(StripSettingKey(key), CustomSettings.LookupStringSetting(key)));
                            KeyIndex++;
                        }
                    }

                    if (storeIncidentVariables.customSettingFloatValues != null)
                    {
                        foreach (float flt in storeIncidentVariables.customSettingFloatValues)
                        {
                            string key            = storeIncidentVariables.customSettingKeys[KeyIndex];
                            float  newValue       = CustomSettings.LookupFloatSetting(key);
                            string newValueBuffer = newValue.ToString();
                            ls.TextFieldNumericLabeled <float>(StripSettingKey(key), ref newValue, ref newValueBuffer);
                            CustomSettings.SetFloatSetting(key, newValue);
                            KeyIndex++;
                        }
                    }


                    ls.GapLine();
                }

                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 (storeIncident.defName != "Item" && ls.ButtonTextLabeled("Reset to Default", "Reset"))
            {
                Store_IncidentEditor.LoadBackup(storeIncident);
                if (storeIncident.cost < 1)
                {
                    storeIncident.cost = 50;
                }
                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();
        }
Esempio n. 2
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);
                }


                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;
                }
                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();
        }