public void TestDateTime() { KSPDateTime dt2 = new KSPDateTime(235, 1); Double DateUT = 301.123; KSPDateTime dt = new KSPDateTime(DateUT); Assert.AreEqual(5, dt.Minute); Assert.AreEqual(1, dt.Second); Assert.AreEqual(123, dt.Millisecond); Assert.AreEqual(0, dt.Hour); Assert.AreEqual(1, dt.DayOfYear); Assert.AreEqual(1, dt.Year); dt = dt.AddMilliSeconds(456); Assert.AreEqual(5, dt.Minute); Assert.AreEqual(1, dt.Second); Assert.AreEqual(579, dt.Millisecond); dt = new KSPDateTime(2, 50, 0, 6, 8, 456); Assert.AreEqual(6, dt.Minute); Assert.AreEqual(8, dt.Second); Assert.AreEqual(456, dt.Millisecond); Assert.AreEqual(2, dt.Year, "Hello"); Assert.AreEqual(50, dt.DayOfYear); }
internal static Boolean DrawYearDay(ref KSPDateTime dateToDraw) { String strYear = dateToDraw.Year.ToString(); String strMonth = dateToDraw.Month.ToString(); String strDay = dateToDraw.Day.ToString(); //If the value changed Boolean blnReturn = false; if (KSPDateStructure.CalendarType == CalendarTypeEnum.Earth) { blnReturn = DrawYearMonthDay(ref strYear, ref strMonth, ref strDay); if (blnReturn) { dateToDraw = KSPDateTime.FromEarthValues(strYear, strMonth, strDay); } } else { blnReturn = DrawYearDay(ref strYear, ref strDay); if (blnReturn) { dateToDraw = new KSPDateTime(strYear, strDay); } } return(blnReturn); }
public void Update() { if (BudgetMultiplier <= 0 || BudgetMultiplier > 1000000) { return; //overflow protection } double time = Planetarium.GetUniversalTime(); KSPDateTime dt = new KSPDateTime(time); if (TimeWarp.CurrentRate < 1001 && dt.Hour < 4) { return; //We do budgets at 4am (so you can warp to next morning for it) } string budgetCode = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString(); if (budgetCode != LastBudget) { Log("Doing budget " + budgetCode); LastBudget = budgetCode; if (CasherDebug) { ScreenMessages.PostScreenMessage("[KSPCasher]: " + budgetCode); } double budget = (Reputation.Instance.reputation * BudgetMultiplier); if (budget > 0) { ScreenMessages.PostScreenMessage("[KSPCasher]: Budget received: " + budget.ToString("C")); Funding.Instance.AddFunds(budget, TransactionReasons.None); } else { ScreenMessages.PostScreenMessage("[KSPCasher]: No budget received, you need to work on your reputation."); } } }
internal static void SetLastFlightStatesToCurrent() { KACWorkerGameState.LastSaveGameName = KACWorkerGameState.CurrentSaveGameName; KACWorkerGameState.LastTime = KACWorkerGameState.CurrentTime; if (LastVessel != CurrentVessel) { if (VesselChanged != null) { VesselChanged(LastVessel, CurrentVessel); } } KACWorkerGameState.LastVessel = KACWorkerGameState.CurrentVessel; KACWorkerGameState.LastSOIBody = KACWorkerGameState.CurrentSOIBody; KACWorkerGameState.LastVesselTarget = KACWorkerGameState.CurrentVesselTarget; }
private void StartLongWorker() { if (CurrentPlot >= lstPlots.Count) { LogFormatted("No more plots to run"); Running = false; Done = true; return; } LogFormatted("Setting up plot:{0}", CurrentPlot); ddlOrigin.SelectedIndex = lstPlots[CurrentPlot].Source; SetupDestinationControls(); ddlDestination.SelectedIndex = lstPlots[CurrentPlot].Destination; SetupTransferParams(); strArrivalAltitude = "0"; strDepartureAltitude = "0"; dateMinDeparture = new KSPDateTime(lstPlots[CurrentPlot].DepMinYear, 1, 3, 0, 0, 0); dateMaxDeparture = new KSPDateTime(lstPlots[CurrentPlot].DepMaxYear, 1, 3, 0, 0, 0).AddDays(-1); strTravelMinDays = lstPlots[CurrentPlot].TravelMin; strTravelMaxDays = lstPlots[CurrentPlot].TravelMax; Double TravelRange = (new KSPTimeSpan(strTravelMaxDays, "0", "0", "0") - new KSPTimeSpan(strTravelMinDays, "0", "0", "0")).UT; Double DepartureRange = (dateMaxDeparture - dateMinDeparture).UT; PlotWidth = (Int32)(DepartureRange / KSPDateStructure.SecondsPerDay * mbTWP.windowDebug.intPlotDeparturePerDay) + 1; PlotHeight = (Int32)(TravelRange / KSPDateStructure.SecondsPerDay * mbTWP.windowDebug.intPlotTravelPointsPerDay) + 1; LogFormatted("Starting a LongWorker: {0}->{1}, Depart:Year {2}=>Year {3}, Travel:{4}=>{5}", cbOrigin.bodyName, cbDestination.bodyName, lstPlots[CurrentPlot].DepMinYear, lstPlots[CurrentPlot].DepMaxYear, lstPlots[CurrentPlot].TravelMin, lstPlots[CurrentPlot].TravelMax); SetWorkerVariables(); workingpercent = 0; Running = true; Done = false; bw = new BackgroundWorker(); bw.DoWork += bw_GenerateDataPorkchop; bw.RunWorkerCompleted += bw_GenerateDataPorkchopCompleted; bw.RunWorkerAsync(); }
//List<KSPMonth> Months; public string getDateTimeStr(string format) { // This uses the class from TriggerAu, as copied from the TransferWindowPlanner if (lastTimeChecked < 0) { if (KSPDateStructure.CalendarType == CalendarTypeEnum.KSPStock) { // If we are using the stock calendar, we need to initialize the // Months list, since the class doesn't do that // yearLen = dayLen * daysInYear; monthLen = yearLen / monthsInYear / dayLen; List <KSPMonth> Months = new List <KSPMonth>(); double x = 0; for (int i = 1; i < monthsInYear + 1; i++) { x += monthLen; //if (x >= 7) x -= 7f; KSPMonth m1 = new KSPMonth(i.ToString(), (int)x); Months.Add(m1); //Debug.Log("month list, i: " + i + ", x: " + ((int)x).ToString()); } KSPDateStructure.Months = Months; } } if (Math.Abs(Planetarium.GetUniversalTime() - lastTimeChecked) < 1) { return(lastDateTimeReturned); } //secKerbinInitial = (Calendar.Instance.dtKerbinInitial.Year - 1) * yearLen; secKerbinInitial = (Calendar.Instance.dtKerbinInitial.Year - 1) * Math.Truncate(daysInYear) * dayLen; lastTimeChecked = Planetarium.GetUniversalTime(); var dt = new KSPDateTime(lastTimeChecked + secKerbinInitial); //KSPDateStructure.Months = Months; lastDateTimeReturned = dt.ToString(format); return(lastDateTimeReturned); }
public override void OnDecodeFromConfigNode() { Notes = KACUtils.DecodeVarStrings(NotesStorage); AlarmTime = new KSPDateTime(AlarmTimeStorage); if (RepeatAlarmPeriodStorage != 0) { RepeatAlarmPeriod = new KSPTimeSpan(RepeatAlarmPeriodStorage); } //dont try and create a GUID from null or empty :) if (ContractGUIDStorage != null && ContractGUIDStorage != "") { ContractGUID = new Guid(ContractGUIDStorage); } _TargetObject = TargetDeserialize(TargetObjectStorage); ManNodes = ManNodeDeserializeList(ManNodesStorage); }
public void TestFormats() { KSPDateTime dt = new KSPDateTime(1, 100); KSPDateStructure.Months = new List <KSPMonth>(); Assert.AreEqual("100/00/0001", dt.ToString("dd/MM/yyyy")); Assert.AreEqual("Year 1, Day 100 - 0h, 0m", dt.ToString()); KSPDateStructure.SetEarthCalendar(); Assert.AreEqual("25/01/1951", dt.ToString("dd/MM/yyyy")); dt = new KSPDateTime(1951, 100); Assert.AreEqual("10/04/1951", dt.ToString("dd/MM/yyyy")); Assert.AreEqual("Hello there 1951", String.Format("Hello there {0:yyyy}", dt)); }
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); }
private void SetWindowStrings() { //KSPDateTime kTime = new KSPDateTime(DepartureMin); //strDepartureMinYear = (kTime.Year ).ToString(); //strDepartureMinDay = (kTime.Day).ToString(); //kTime.UT = DepartureMax; //strDepartureMaxYear = (kTime.Year).ToString(); //strDepartureMaxDay = (kTime.Day).ToString(); dateMinDeparture = new KSPDateTime(DepartureMin); dateMaxDeparture = new KSPDateTime(DepartureMax); KSPTimeSpan kSpan = new KSPTimeSpan(0); kSpan.UT = TravelMin; strTravelMinDays = ((Int32)kSpan.TotalDays).ToString(); kSpan.UT = TravelMax; strTravelMaxDays = ((Int32)kSpan.TotalDays).ToString(); strArrivalAltitude = (InitialOrbitAltitude / 1000).ToString(); strDepartureAltitude = (FinalOrbitAltitude / 1000).ToString(); }
public void TestEarthDateTime() { KSPDateStructure.SetEarthCalendar(); Double DateUT = 301.123; KSPDateTime dt = new KSPDateTime(DateUT); //Console.Write(dt.Day); Assert.AreEqual(5, dt.Minute); Assert.AreEqual(1, dt.Second); Assert.AreEqual(123, dt.Millisecond); Assert.AreEqual(0, dt.Hour); Assert.AreEqual(1, dt.DayOfYear); Assert.AreEqual(1951, dt.Year); dt = dt.AddMilliSeconds(456); Assert.AreEqual(5, dt.Minute); Assert.AreEqual(1, dt.Second); Assert.AreEqual(579, dt.Millisecond); //dt.Second = 68; //Assert.AreEqual(6, dt.Minute); //Assert.AreEqual(8, dt.Second); //Assert.AreEqual(456, dt.Millisecond); //dt.Year = 1969; //Assert.AreEqual(1969, dt.Year, "Hello"); //dt.DayOfYear = 50; //Assert.AreEqual(50, dt.DayOfYear); //KSPDateTimeStructure.SetCalendarTypeEarth(1951,1,1); //dt = new KSPDateTime(1951, 50, 10, 20, 30); //Assert.AreEqual(2, dt.Month); //Assert.AreEqual(19, dt.Day); }
private void SetDepartureMinToYesterday() { //Set the Departure min to be yesterday dateMinDeparture = new KSPDateTime(Planetarium.GetUniversalTime()).Date; DepartureMin = dateMinDeparture.UT; }
private void WindowLayout_AddPane_ClosestApproach() { GUILayout.BeginVertical(); GUILayout.Label(strAlarmEventName + " Details...", KACResources.styleAddSectionHeading); if (KACWorkerGameState.CurrentVessel == null) { GUILayout.Label("No Active Vessel"); } else { if (!(KACWorkerGameState.CurrentVesselTarget is Vessel) && !(KACWorkerGameState.CurrentVesselTarget is ModuleDockingNode)) { GUILayout.Label("No valid Vessel Target Selected", GUILayout.ExpandWidth(true)); } else { //GUILayout.Label("Adjust Lookahead amounts...", KACResources.styleAddSectionHeading); GUILayout.BeginVertical(KACResources.styleAddFieldAreas); GUILayout.BeginHorizontal(); GUILayout.Label("Orbits to Search:", KACResources.styleAddHeading, GUILayout.Width(110)); GUILayout.Label(((int)Math.Round((Decimal)fltOrbits, 0)).ToString(), KACResources.styleAddXferName, GUILayout.Width(25)); fltOrbits = GUILayout.HorizontalSlider(fltOrbits, 1, 20); fltOrbits = (float)Math.Floor((Decimal)fltOrbits); GUILayout.EndHorizontal(); intOrbits = (int)fltOrbits; int intClosestOrbitPass = 0; double dblClosestDistance = Double.MaxValue; double dblClosestUT = 0; double dblOrbitTestClosest = Double.MaxValue; double dblOrbitTestClosestUT = 0; if (KACWorkerGameState.CurrentVessel.orbit.eccentricity > 1) { intOrbits = 1; } for (int intOrbitToTest = 1; intOrbitToTest <= intOrbits; intOrbitToTest++) { dblOrbitTestClosestUT = KACUtils.timeOfClosestApproach(KACWorkerGameState.CurrentVessel.orbit, KACWorkerGameState.CurrentVesselTarget.GetOrbit(), KACWorkerGameState.CurrentTime.UT, intOrbitToTest, out dblOrbitTestClosest ); if (dblOrbitTestClosest < dblClosestDistance) { dblClosestDistance = dblOrbitTestClosest; dblClosestUT = dblOrbitTestClosestUT; intClosestOrbitPass = intOrbitToTest; } } GUILayout.BeginHorizontal(); GUILayout.Label("Distance:", KACResources.styleAddHeading, GUILayout.Width(70)); String strDistance = string.Format("{0:#}m", dblClosestDistance); if (dblClosestDistance > 999) { strDistance = string.Format("{0:#.0}km", dblClosestDistance / 1000); } GUILayout.Label(strDistance, KACResources.styleAddXferName, GUILayout.Width(90)); GUILayout.Label("On Orbit:", KACResources.styleAddHeading); GUILayout.Label(intClosestOrbitPass.ToString(), KACResources.styleAddXferName); GUILayout.EndHorizontal(); GUILayout.EndVertical(); String strMarginConversion = ""; KSPDateTime eventTime = new KSPDateTime(dblClosestUT); KSPTimeSpan eventInterval = new KSPTimeSpan(dblClosestUT - KACWorkerGameState.CurrentTime.UT); KSPDateTime eventAlarm; KSPTimeSpan eventAlarmInterval; try { eventAlarm = new KSPDateTime(eventTime.UT - timeMargin.UT); eventAlarmInterval = new KSPTimeSpan(eventTime.UT - KACWorkerGameState.CurrentTime.UT - timeMargin.UT); } catch (Exception) { eventAlarm = null; eventAlarmInterval = null; strMarginConversion = "Unable to Add the Margin Minutes"; } if ((eventTime.UT > KACWorkerGameState.CurrentTime.UT) && strMarginConversion == "") { if (DrawAddAlarm(eventTime, eventInterval, eventAlarmInterval)) { KACAlarm newAlarm = new KACAlarm(KACWorkerGameState.CurrentVessel.id.ToString(), strAlarmName, strAlarmNotes, eventAlarm.UT, timeMargin.UT, AddType, AddActions); newAlarm.TargetObject = KACWorkerGameState.CurrentVesselTarget; newAlarm.ManNodes = KACWorkerGameState.CurrentVessel.patchedConicSolver.maneuverNodes; alarms.Add(newAlarm); //settings.Save(); _ShowAddPane = false; } } else { strMarginConversion = "No Future Closest Approach found"; } if (strMarginConversion != "") { GUILayout.Label(strMarginConversion, GUILayout.ExpandWidth(true)); } } } GUILayout.EndVertical(); }
private void WindowLayout_AddPane_TargetDistance() { intAddDistanceHeight = 262;// 272; GUILayout.BeginVertical(); GUILayout.Label(strAlarmEventName + " Details...", KACResources.styleAddSectionHeading); //What are the possible targets?? List <ITargetable> iTargets = new List <ITargetable>(); if (!(KACWorkerGameState.CurrentVesselTarget == null)) { iTargets.Add(KACWorkerGameState.CurrentVesselTarget); //VesselTarget } iTargets.Add(KACWorkerGameState.CurrentVessel.mainBody); //Body we are orbiting if (KACWorkerGameState.SOIPointExists) { iTargets.Add(KACWorkerGameState.CurrentVessel.orbit.nextPatch.referenceBody); //Body we will orbit next } if (intSelectediTarget > iTargets.Count - 1) { intSelectediTarget = 0; } intAddDistanceHeight += (iTargets.Count * 30); //Now give the user the choice GUILayout.BeginHorizontal(); GUILayout.Label("Select Target:", KACResources.styleAddXferName); if (DrawRadioListVertical(ref intSelectediTarget, iTargets.Select(x => x.GetName()).ToArray())) { Log.info("Distance Target is:{0}", iTargets[intSelectediTarget].GetName()); } GUILayout.EndHorizontal(); //Set the tgt Object tgtSelectedDistance = iTargets[intSelectediTarget]; string strDistanceName = "Distance"; if (tgtSelectedDistance is CelestialBody) { strDistanceName = "Altitude"; } //Ask for the target distance/altitude GUILayout.BeginHorizontal(); GUILayout.Label(string.Format("Target {0} (m):", strDistanceName), KACResources.styleAddXferName); dblTargetDistance = Convert.ToDouble(GUILayout.TextField(dblTargetDistance.ToString(), KACResources.styleAddField)); GUILayout.EndHorizontal(); //If the body has an atmosphere then add an option to set the Altitude straight to that if (tgtSelectedDistance is CelestialBody) { if ((tgtSelectedDistance as CelestialBody).atmosphere) { GUILayout.BeginHorizontal(); GUILayout.Label(string.Format("Atmosphere: {0}", (tgtSelectedDistance as CelestialBody).atmosphereDepth)); if (GUILayout.Button("Set to Edge")) { dblTargetDistance = (tgtSelectedDistance as CelestialBody).atmosphereDepth; } GUILayout.EndHorizontal(); intAddDistanceHeight += 26; } } //For a vessel give some options for orbits to look forwards GUILayout.BeginVertical(KACResources.styleAddFieldAreas); if (!(tgtSelectedDistance is CelestialBody)) { GUILayout.BeginHorizontal(); GUILayout.Label("Orbits to Search:", KACResources.styleAddHeading, GUILayout.Width(110)); GUILayout.Label(((int)Math.Round((Decimal)fltOrbits_Distance, 0)).ToString(), KACResources.styleAddXferName, GUILayout.Width(25)); fltOrbits_Distance = GUILayout.HorizontalSlider(fltOrbits_Distance, 1, 20); fltOrbits_Distance = (float)Math.Floor((Decimal)fltOrbits_Distance); GUILayout.EndHorizontal(); intAddDistanceHeight += 18; } //What VesselOrbit do we care about Orbit VesselOrbitToCompare = KACWorkerGameState.CurrentVessel.GetOrbit(); if ((KACWorkerGameState.SOIPointExists) && ((tgtSelectedDistance as CelestialBody) == KACWorkerGameState.CurrentVessel.orbit.nextPatch.referenceBody)) { VesselOrbitToCompare = KACWorkerGameState.CurrentVessel.orbit.nextPatch; } //Get the startUT of the orbit Double VesselOrbitStartUT = KACWorkerGameState.CurrentVessel.GetOrbit().StartUT; //Set up some variables intOrbits_Distance = (int)fltOrbits_Distance; int intDistanceOrbitPass = 0; double dblClosestDistance = Double.MaxValue; double dblDistanceUT = 0; double dblOrbitTestDistance = Double.MaxValue; double dblOrbitTestDistanceUT = 0; //If its an Altitude alarm then do this if (tgtSelectedDistance is CelestialBody) { dblOrbitTestDistanceUT = KACUtils.timeOfTargetAltitude(VesselOrbitToCompare, VesselOrbitStartUT, out dblOrbitTestDistance, dblTargetDistance ); dblClosestDistance = dblOrbitTestDistance; dblDistanceUT = dblOrbitTestDistanceUT; } else { //Else Iterate through the orbits to find the target separation for (int intOrbitToTest = 1; intOrbitToTest <= intOrbits_Distance; intOrbitToTest++) { dblOrbitTestDistanceUT = KACUtils.timeOfTargetDistance(VesselOrbitToCompare, tgtSelectedDistance.GetOrbit(), KACWorkerGameState.CurrentTime.UT, intOrbitToTest, out dblOrbitTestDistance, dblTargetDistance ); if (dblOrbitTestDistance < dblClosestDistance) { dblClosestDistance = dblOrbitTestDistance; dblDistanceUT = dblOrbitTestDistanceUT; intDistanceOrbitPass = intOrbitToTest; } } } //Now display what we got GUILayout.BeginHorizontal(); GUILayout.Label(String.Format("{0}:", strDistanceName), KACResources.styleAddHeading, GUILayout.Width(70)); String strDistance = string.Format("{0:#}m", dblClosestDistance); if (dblClosestDistance > 999) { strDistance = string.Format("{0:#.0}km", dblClosestDistance / 1000); } GUILayout.Label(strDistance, KACResources.styleAddXferName, GUILayout.Width(90)); if (!(tgtSelectedDistance is CelestialBody)) { GUILayout.Label("On Orbit:", KACResources.styleAddHeading); GUILayout.Label(intDistanceOrbitPass.ToString(), KACResources.styleAddXferName); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); //Now do the stuff to draw the alarm button String strMarginConversion = ""; KSPDateTime eventTime = new KSPDateTime(dblDistanceUT); KSPTimeSpan eventInterval = new KSPTimeSpan(dblDistanceUT - KACWorkerGameState.CurrentTime.UT); KSPDateTime eventAlarm; KSPTimeSpan eventAlarmInterval; try { eventAlarm = new KSPDateTime(eventTime.UT - timeMargin.UT); eventAlarmInterval = new KSPTimeSpan(eventTime.UT - KACWorkerGameState.CurrentTime.UT - timeMargin.UT); } catch (Exception) { eventAlarm = null; eventAlarmInterval = null; strMarginConversion = "Unable to Add the Margin Minutes"; } if ((eventTime.UT > KACWorkerGameState.CurrentTime.UT) && strMarginConversion == "") { if (DrawAddAlarm(eventTime, eventInterval, eventAlarmInterval)) { KACAlarm newAlarm = new KACAlarm(KACWorkerGameState.CurrentVessel.id.ToString(), strAlarmName, strAlarmNotes, eventAlarm.UT, timeMargin.UT, AddType, AddActions); newAlarm.TargetObject = KACWorkerGameState.CurrentVesselTarget; newAlarm.ManNodes = KACWorkerGameState.CurrentVessel.patchedConicSolver.maneuverNodes; alarms.Add(newAlarm); //settings.Save(); _ShowAddPane = false; } } else { strMarginConversion = "No Target Distance Approach found"; } if (strMarginConversion != "") { GUILayout.Label(strMarginConversion, GUILayout.ExpandWidth(true)); } GUILayout.EndVertical(); }
//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(); }