コード例 #1
0
        private void MakeBuffers()
        {
            if (this.globalOtBuffers == null)
            {
                this.globalOtBuffers = new OrbitalTradeBuffers(Settings.GlobalOrbitalTrade);
            }
            if (Settings.GlobalWeightBuffer.NullOrEmpty())
            {
                Settings.GlobalWeightBuffer = "1.0";
                Settings.GlobalWeight       = 1.0f;
            }

            if (this.gameOtBuffers == null && Current.Game != null && Settings.GameOrbitalTrade != null)
            {
                this.gameOtBuffers = new OrbitalTradeBuffers(Settings.GameOrbitalTrade);
            }

            if (Settings.GameWeightBuffer.NullOrEmpty() && Current.Game != null)
            {
                Settings.GameWeightBuffer = Settings.GlobalWeightBuffer;
                if (!float.TryParse(Settings.GameWeightBuffer, out Settings.GameWeight))
                {
                    Settings.GameWeight       = 1.0f;
                    Settings.GameWeightBuffer = "1.0";
                }
            }
        }
コード例 #2
0
        private void MakeBuffers()
        {
            if (this.globalOtBuffers == null)
            {
                this.globalOtBuffers = new OrbitalTradeBuffers(Settings.GlobalOrbitalTrade);
            }

            if (this.gameOtBuffers == null && Current.Game != null && Settings.GameOrbitalTrade != null)
            {
                this.gameOtBuffers = new OrbitalTradeBuffers(Settings.GameOrbitalTrade);
            }
        }
コード例 #3
0
        public override void DoSettingsWindowContents(Rect inRect)
        {
            this.Init();

            // Draw Contents
            // Global
            Text.Font = GameFont.Small;
            float y = 60;

            Widgets.Label(new Rect(0, y, 600, 40), "AdjustableTradeShips.Global".Translate());
            y += 40;

            Widgets.Label(new Rect(20, y, 600, 40), "AdjustableTradeShips.TradeShips".Translate());
            y += 40;


            NumberInput(40, y, ref Settings.GlobalOrbitalTrade.Instances, ref globalOtBuffers.Instances, MIN_ONOFF_VALUE, MAX_VALUE);

            Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.OTS".Translate());
            y += 40;

            NumberInput(40, y, ref Settings.GlobalOrbitalTrade.Days, ref globalOtBuffers.Days, MIN_ONOFF_VALUE, MAX_VALUE);

            Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.Days".Translate());
            y += 40;

            if (Widgets.ButtonText(new Rect(0, y, 100, 32), "AdjustableTradeShips.Default".Translate()))
            {
                OnOffIncident ooi = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
                Settings.GlobalOrbitalTrade.Days      = ooi.Days;
                globalOtBuffers.Days                  = ooi.Days.ToString();
                Settings.GlobalOrbitalTrade.Instances = ooi.Instances;
                globalOtBuffers.Instances             = ooi.Instances.ToString();
            }

            if (Widgets.ButtonText(new Rect(200, y, 100, 32), "AdjustableTradeShips.Apply".Translate()))
            {
                StoryTellerUtil.ApplyOrbitalTrade(Settings.GlobalOrbitalTrade.Days, Settings.GlobalOrbitalTrade.Instances);
                Messages.Message("AdjustableTradeShips.GlobalSettingsApplied".Translate(), MessageTypeDefOf.PositiveEvent);
                this.globalOtBuffers = null;
            }
            y += 40;

            // Current Game
            if (Current.Game != null)
            {
                Widgets.DrawLineHorizontal(20, y, inRect.width - 40);
                y += 40;

                Widgets.Label(new Rect(0, y, 600, 40), "AdjustableTradeShips.CurrentGame".Translate());
                y += 40;

                if (StoryTellerUtil.HasOrbitalTraders() && Settings.GameOrbitalTrade != null)
                {
                    Widgets.Label(new Rect(20, y, 600, 40), "AdjustableTradeShips.TradeShips".Translate());
                    y += 40;

                    // Game Orbital Trade
                    NumberInput(40, y, ref Settings.GameOrbitalTrade.Instances, ref gameOtBuffers.Instances, MIN_ONOFF_VALUE, MAX_VALUE);

                    Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.OTS".Translate());
                    y += 40;

                    NumberInput(40, y, ref Settings.GameOrbitalTrade.Days, ref gameOtBuffers.Days, MIN_ONOFF_VALUE, MAX_VALUE);

                    Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.Days".Translate());
                    y += 40;

                    if (Widgets.ButtonText(new Rect(0, y, 100, 32), "AdjustableTradeShips.Default".Translate()))
                    {
                        if (StoryTellerDefaultsUtil.TryGetStoryTellerDefault(IncidentDefOf.OrbitalTraderArrival, out OnOffIncident ooi))
                        {
                            Settings.GameOrbitalTrade.Days      = ooi.Days;
                            gameOtBuffers.Days                  = ooi.Days.ToString();
                            Settings.GameOrbitalTrade.Instances = ooi.Instances;
                            gameOtBuffers.Instances             = ooi.Instances.ToString();
                        }
                        else
                        {
                            ooi = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
                            Settings.GameOrbitalTrade.Days      = ooi.Days;
                            gameOtBuffers.Days                  = ooi.Days.ToString();
                            Settings.GameOrbitalTrade.Instances = ooi.Instances;
                            gameOtBuffers.Instances             = ooi.Instances.ToString();
                        }
                    }

                    if (Widgets.ButtonText(new Rect(200, y, 100, 32), "AdjustableTradeShips.Apply".Translate()))
                    {
                        StoryTellerUtil.ApplyOrbitalTrade(Settings.GameOrbitalTrade.Days, Settings.GameOrbitalTrade.Instances);
                        Messages.Message("AdjustableTradeShips.GameSettingsApplied".Translate(), MessageTypeDefOf.PositiveEvent);
                        this.gameOtBuffers = null;
                    }
                }
                else if (StoryTellerUtil.HasRandom())
                {
                    if (this.weightBuffer == null)
                    {
                        if (StoryTellerUtil.TryGetRandomWeight(IncidentCategoryDefOf.OrbitalVisitor, out float weight))
                        {
                            this.weight       = weight;
                            this.weightBuffer = weight.ToString();
                        }
                    }

                    NumberInput(20, y, "Orbital Visitor Weight", ref this.weight, ref this.weightBuffer, MIN_VALUE, MAX_VALUE);
                    y += 40;

                    if (Widgets.ButtonText(new Rect(0, y, 100, 32), "AdjustableTradeShips.Default".Translate()))
                    {
                        this.weight       = 1.0f;
                        this.weightBuffer = "1.0";
                    }

                    if (Widgets.ButtonText(new Rect(200, y, 100, 32), "AdjustableTradeShips.Apply".Translate()))
                    {
                        StoryTellerUtil.ApplyRandom(IncidentCategoryDefOf.OrbitalVisitor, this.weight);
                        Messages.Message("AdjustableTradeShips.GameSettingsApplied".Translate(), MessageTypeDefOf.PositiveEvent);
                        this.weightBuffer = this.weight.ToString();
                    }
                }
                else
                {
                    Widgets.Label(new Rect(20, y, 300, 32), Current.Game.storyteller.def.label + ": " + "AdjustableTradeShips.CannotModifyOrbitalTraderTimes".Translate());
                }
                y += 25;
            }
        }