static void Prefix() { #if DEBUG Log.Warning("Patch_Game_InitNewGame Postfix"); #endif WorldComp.InitializeNewGame(); }
public override void DoSettingsWindowContents(Rect rect) { GUI.BeginGroup(new Rect(0, 60, 600, 200)); { Text.Font = GameFont.Medium; Widgets.Label(new Rect(0, 0, 300, 40), "ChangeResearchSpeed.Global".Translate()); Text.Font = GameFont.Small; Widgets.Label(new Rect(0, 40, 300, 20), "ChangeResearchSpeed.Factor".Translate() + ":"); Settings.GlobalFactor.AsString = Widgets.TextField(new Rect(320, 40, 100, 20), Settings.GlobalFactor.AsString); if (Widgets.ButtonText(new Rect(320, 65, 100, 20), "ChangeResearchSpeed.Apply".Translate())) { if (Settings.GlobalFactor.ValidateInput()) { base.GetSettings <Settings>().Write(); Messages.Message("ChangeResearchSpeed.Global".Translate() + " " + "ChangeResearchSpeed.ResearchTimesUpdated".Translate(), MessageTypeDefOf.PositiveEvent); } } if (Current.Game != null) { Text.Font = GameFont.Medium; Widgets.Label(new Rect(0, 90, 300, 40), "ChangeResearchSpeed.CurrentGame".Translate()); Text.Font = GameFont.Small; Widgets.Label(new Rect(0, 130, 300, 20), "ChangeResearchSpeed.Factor".Translate() + ":"); Settings.GameFactor.AsString = Widgets.TextField(new Rect(320, 130, 100, 20), Settings.GameFactor.AsString); if (Widgets.ButtonText(new Rect(320, 155, 100, 20), "ChangeResearchSpeed.Apply".Translate())) { if (Settings.GameFactor.ValidateInput()) { WorldComp.UpdateFactor(Settings.GameFactor.AsFloat); Messages.Message( "ChangeResearchSpeed.CurrentGame".Translate() + " " + "ChangeResearchSpeed.ResearchTimesUpdated".Translate(), MessageTypeDefOf.PositiveEvent); } } } } GUI.EndGroup(); Listing_Standard l = new Listing_Standard(GameFont.Small); l.BeginScrollView(new Rect(0, 300, rect.width, rect.height - 300), ref scroll, ref view); //l.Begin(new Rect(0, 300, 400, 300)); l.ColumnWidth = rect.width - 100; l.CheckboxLabeled( "ChangeResearchSpeed.AllowTechAdvance".Translate(), ref Settings.AllowTechAdvance, "ChangeResearchSpeed.AllowTechAdvanceToolTip".Translate()); if (Settings.AllowTechAdvance) { l.CheckboxLabeled("ChangeResearchSpeed.StaticNumberResearchPerTier".Translate(), ref Settings.StaticNumberResearchPerTier); if (Settings.StaticNumberResearchPerTier) { neolithicInput = l.TextEntryLabeled("ChangeResearchSpeed.NeolithicNeeded".Translate() + ": ", neolithicInput); medievalInput = l.TextEntryLabeled("ChangeResearchSpeed.MedievalNeeded".Translate() + ": ", medievalInput); industrialInput = l.TextEntryLabeled("ChangeResearchSpeed.IndustrialNeeded".Translate() + ": ", industrialInput); spacerInput = l.TextEntryLabeled("ChangeResearchSpeed.SpacerNeeded".Translate() + ": ", spacerInput); } Rect c = l.GetRect(32f); if (Widgets.ButtonText(new Rect(c.xMin, c.yMin, 100, c.height), "Confirm".Translate())) { if (!int.TryParse(neolithicInput, out Settings.NeolithicNeeded)) { Messages.Message("ChangeResearchSpeed.InvalidNeolithicInput".Translate(), MessageTypeDefOf.RejectInput); return; } if (!int.TryParse(medievalInput, out Settings.MedievalNeeded)) { Messages.Message("ChangeResearchSpeed.InvalidMedievalInput".Translate(), MessageTypeDefOf.RejectInput); return; } if (!int.TryParse(industrialInput, out Settings.IndustrialNeeded)) { Messages.Message("ChangeResearchSpeed.InvalidIndustrialInput".Translate(), MessageTypeDefOf.RejectInput); return; } if (!int.TryParse(spacerInput, out Settings.SpacerNeeded)) { Messages.Message("ChangeResearchSpeed.InvalidSpacerInput".Translate(), MessageTypeDefOf.RejectInput); return; } Messages.Message("ChangeResearchSpeed.ResearchNeededSet".Translate(), MessageTypeDefOf.PositiveEvent); } if (Widgets.ButtonText(new Rect(c.xMax - 100, c.yMin, 100, c.height), "ChangeResearchSpeed.Default".Translate())) { Settings.NeolithicNeeded = Settings.DEFAULT_NEOLITHIC_NEEDED; Settings.MedievalNeeded = Settings.DEFAULT_MEDIEVAL_NEEDED; Settings.IndustrialNeeded = Settings.DEFAULT_INDUSTRIAL_NEEDED; Settings.SpacerNeeded = Settings.DEFAULT_SPACER_NEEDED; neolithicInput = Settings.NeolithicNeeded.ToString(); medievalInput = Settings.MedievalNeeded.ToString(); industrialInput = Settings.IndustrialNeeded.ToString(); spacerInput = Settings.SpacerNeeded.ToString(); Messages.Message("ChangeResearchSpeed.ResearchNeededDefaulted".Translate(), MessageTypeDefOf.PositiveEvent); } } l.CheckboxLabeled( "ChangeResearchSpeed.ChangeBaseCosts".Translate(), ref Settings.ChangeBaseCosts, "ChangeResearchSpeed.ChangeBaseCostsToolTip".Translate()); if (Settings.ChangeBaseCosts) { if (techValues == null) { techValues = new Dictionary <string, string>(); } var techs = ResearchTimeUtil.GetResearchBaseCosts(); foreach (var tech in techs.Keys) { var techDef = ResearchTimeUtil.GetResearchDef(tech); if (techDef != null) { float cost; string value; if ((value = techValues.TryGetValue(tech, null)) == null) { if (Settings.ResearchBaseCosts.TryGetValue(tech, out cost)) { value = ((int)cost).ToString(); } else { value = techDef.baseCost.ToString(); } techValues.Add(tech, value); } value = l.TextEntryLabeled(techDef.LabelCap + "(default: " + techs[tech] + ")", value); int costInt; if (int.TryParse(value, out costInt) && costInt >= 100) { if (costInt != (int)techDef.baseCost) { ResearchTimeUtil.ChangeBaseCost(techDef, costInt); } if (Settings.ResearchBaseCosts.ContainsKey(tech)) { Settings.ResearchBaseCosts[tech] = costInt; } else { Settings.ResearchBaseCosts.Add(tech, costInt); } } techValues[tech] = value; } } } //l.End(); l.EndScrollView(ref view); }