示例#1
0
        public void TestMonths()
        {
            KSPDateStructure.SetCustomCalendar();

            //empty months structure
            KSPDateTime dt = new KSPDateTime(1, 100);

            Assert.AreEqual(0, dt.Month);
            Assert.AreEqual(100, dt.Day);

            //set up some months
            KSPDateStructure.Months.Add(new KSPMonth("Billtember", 200));
            KSPDateStructure.Months.Add(new KSPMonth("Jebuary", 265));

            Assert.AreEqual(1, dt.Month);
            Assert.AreEqual(100, dt.Day);
            dt = dt.AddDays(100);
            Assert.AreEqual(1, dt.Month);
            Assert.AreEqual(200, dt.Day);
            dt = dt.AddDays(100);
            Assert.AreEqual(2, dt.Month);
            dt = dt.AddDays(100);
        }
示例#2
0
        //MainGUI Window Content
        private void MainGUI(int WindowID)
        {
            double budget = (Reputation.Instance.reputation * BudgetMultiplier);
            double bonus  = (ResearchAndDevelopment.Instance.Science * ScienceSellMultiplier);

            double      time = Planetarium.GetUniversalTime();
            KSPDateTime dt   = new KSPDateTime(time);
            KSPDateTime next = dt.AddDays(1);

            next = next.AddHours(4 - next.Hour);
            next = next.AddMinutes(-next.Minute);
            next = next.AddSeconds(-next.Second);

            KSPDateTime span = next.Subtract(dt);

            GUILayout.BeginVertical(GUILayout.Width(300), GUILayout.ExpandWidth(false));

            if (ShowSettings)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Budget Multiplier", headerText, GUILayout.Width(150));
                string text = GUILayout.TextField(BudgetMultiplier.ToString());
                int    temp = 0;
                if (int.TryParse(text, out temp))
                {
                    BudgetMultiplier = Mathf.Clamp(temp, 0, 1000000);
                }
                else if (text == "")
                {
                    BudgetMultiplier = 10;
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Science Bonus", headerText, GUILayout.Width(150));
                text = GUILayout.TextField(ScienceSellMultiplier.ToString());
                temp = 0;
                if (int.TryParse(text, out temp))
                {
                    ScienceSellMultiplier = Mathf.Clamp(temp, 0, 1000000);
                }
                else if (text == "")
                {
                    ScienceSellMultiplier = 10000;
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Tech Multiplier", headerText, GUILayout.Width(150));
                text = GUILayout.TextField(ScienceBuyMultiplier.ToString());
                temp = 0;
                if (int.TryParse(text, out temp))
                {
                    ScienceBuyMultiplier = Mathf.Clamp(temp, 0, 1000000);
                }
                else if (text == "")
                {
                    ScienceBuyMultiplier = 10000;
                }
                GUILayout.EndHorizontal();

                if (GUILayout.Button("< Back"))
                {
                    ShowSettings = false;
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Next Budget", headerText, GUILayout.Width(100));
                GUILayout.Label(budget.ToString("C"), normalText);
                if (GUILayout.Button("$", GUILayout.Width(20), GUILayout.ExpandHeight(false)))
                {
                    ShowSettings = true;
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Due In", headerText, GUILayout.Width(100));
                GUILayout.Label(span.ToString("H\\h m\\m s\\s"), normalText);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Science Bonus", headerText, GUILayout.Width(100));
                GUILayout.Label(bonus.ToString("C"), normalText);
                GUILayout.EndHorizontal();

                GUILayout.Label("Cash out science", bigHeaderText);

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("1"))
                {
                    CashOutScience(1);
                }
                if (GUILayout.Button("10"))
                {
                    CashOutScience(10);
                }
                if (GUILayout.Button("100"))
                {
                    CashOutScience(100);
                }
                GUILayout.EndHorizontal();

                if (GUILayout.Button("All"))
                {
                    CashOutScience(ResearchAndDevelopment.Instance.Science);
                }
            }

            GUILayout.EndVertical();
        }