public IEnumerable<ConfigurationEntry> Parse(string data) { ConfigurationSection currentSection = null; foreach (var line in data.Split(new[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries)) { var sectionMatch = _configurationSectionRegex.Match(line); if (sectionMatch.Success) { if (currentSection != null) yield return currentSection; currentSection = new ConfigurationSection { Type = sectionMatch.Groups["type"].Value, Name = sectionMatch.Groups["name"].Success ? sectionMatch.Groups["name"].Value : string.Empty }; continue; } var lineMatch = _configurationLineRegex.Match(line); if (lineMatch.Success) { var configLine = new ConfigurationLine { Name = lineMatch.Groups["name"].Value, Value = lineMatch.Groups["value"].Value }; if (currentSection != null) currentSection.Lines.Add(configLine); else yield return configLine; } } if (currentSection != null) yield return currentSection; }
public override void PreOpen() { base.PreOpen(); Page_VerifyStartConfiguration.visibleWorkTypesInPriorityOrder = new List <ConfigurationLine>(); using (List <ConfigurationLine> .Enumerator enumerator = VerifyStart.Instance.Config.GetEnumerator()) { while (enumerator.MoveNext()) { ConfigurationLine current = enumerator.Current; if (DefDatabase <SkillDef> .AllDefsListForReading.FindIndex((SkillDef x) => (int)x.index == current.skillId) >= 0) { SkillDef skillDef = DefDatabase <SkillDef> .AllDefsListForReading.Find((SkillDef x) => (int)x.index == current.skillId); Page_VerifyStartConfiguration.cachedLabelSizes[skillDef] = Text.CalcSize(current.skillName); Page_VerifyStartConfiguration.visibleWorkTypesInPriorityOrder.Add(current); } } } }
public IEnumerable <ConfigurationEntry> Parse(string data) { ConfigurationSection currentSection = null; foreach (var line in data.Split(new[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries)) { var sectionMatch = _configurationSectionRegex.Match(line); if (sectionMatch.Success) { if (currentSection != null) { yield return(currentSection); } currentSection = new ConfigurationSection { Type = sectionMatch.Groups["type"].Value, Name = sectionMatch.Groups["name"].Success ? sectionMatch.Groups["name"].Value : string.Empty }; continue; } var lineMatch = _configurationLineRegex.Match(line); if (lineMatch.Success) { var configLine = new ConfigurationLine { Name = lineMatch.Groups["name"].Value, Value = lineMatch.Groups["value"].Value }; if (currentSection != null) { currentSection.Lines.Add(configLine); } else { yield return(configLine); } } } if (currentSection != null) { yield return(currentSection); } }
public override void DoWindowContents(Rect rect) { if (this.searching) { this.RollColonists(-1); } base.DrawPageTitle(rect); Widgets.Checkbox(new Vector2(rect.width - 235f, 5f), ref VerifyStart.Instance.bypass, 24f, false); Widgets.Label(new Rect(rect.width - 205f, 5f, 200f, 25f), "Bypass Check"); Rect rect2 = new Rect(0f, 60f, rect.width, rect.height - 100f); GUI.BeginGroup(rect2); Text.Font = GameFont.Small; GUI.color = Color.white; Rect rect3 = new Rect(0f, 70f, rect2.width, rect2.height - 70f); this.workColumnSpacing = (rect2.width - 16f - 201f) / (float)Page_VerifyStartConfiguration.visibleWorkTypesInPriorityOrder.Count; float num = 201f; for (int i = 0; i < Page_VerifyStartConfiguration.visibleWorkTypesInPriorityOrder.Count; i = checked (i + 1)) { ConfigurationLine cline = Page_VerifyStartConfiguration.visibleWorkTypesInPriorityOrder[i]; if (DefDatabase <SkillDef> .AllDefsListForReading.FindIndex((SkillDef x) => (int)x.index == cline.skillId) >= 0) { SkillDef skillDef = DefDatabase <SkillDef> .AllDefsListForReading.Find((SkillDef x) => (int)x.index == cline.skillId); Vector2 vector = Page_VerifyStartConfiguration.cachedLabelSizes[skillDef]; float num2 = num + 15f; Rect rect4 = new Rect(num2 - vector.x / 2f, 0f, vector.x + 20f, vector.y + 5f); if (i % 2 == 1) { rect4.y += 20f; } if (Mouse.IsOver(rect4)) { Widgets.DrawHighlight(rect4); } Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect4, cline.skillName); string text = cline.skillName + " " + cline.skillId; TooltipHandler.TipRegion(rect4, new TipSignal(text)); GUI.color = new Color(1f, 1f, 1f, 0.3f); Widgets.DrawLineVertical(num2, rect4.yMax - 3f, 50f - rect4.yMax + 3f); Widgets.DrawLineVertical(num2 + 1f, rect4.yMax - 3f, 50f - rect4.yMax + 3f); GUI.color = Color.white; num += this.workColumnSpacing; } } this.pawns = Find.GameInitData.startingPawns; Rect rect5 = rect2; rect5.height = rect5.height - 100f; Rect rect6 = new Rect(0f, 0f, rect5.width - 16f, (float)(checked (this.pawns.Count + 1)) * 30f); Widgets.BeginScrollView(rect5, ref this.scrollPosition, rect6); float num3 = 0f; Rect rect7 = new Rect(0f, num3, rect6.width, 30f); GUI.color = new Color(1f, 1f, 1f, 0.2f); Widgets.DrawLineHorizontal(0f, num3, rect6.width); GUI.color = Color.white; this.PreDrawPawnRow(rect7, null, true, -1); this.DrawPawnRow(rect7, null, true, -1); this.PostDrawPawnRow(rect7, null, true, -1); num3 += 30f; for (int i = 0; i < this.pawns.Count; i = checked (i + 1)) { Pawn p = this.pawns[i]; rect7 = new Rect(0f, num3, rect6.width, 30f); if (num3 - this.scrollPosition.y + 30f >= 0f && num3 - this.scrollPosition.y <= rect5.height) { GUI.color = new Color(1f, 1f, 1f, 0.2f); Widgets.DrawLineHorizontal(0f, num3, rect6.width); GUI.color = Color.white; this.PreDrawPawnRow(rect7, p, false, i); this.DrawPawnRow(rect7, p, false, i); this.PostDrawPawnRow(rect7, p, false, i); } num3 += 30f; } Widgets.EndScrollView(); GUI.EndGroup(); Text.Anchor = TextAnchor.UpperLeft; base.DoBottomButtons(rect, null, null, null, false); }
protected void DrawPawnRow(Rect rect, Pawn p, bool colony = false, int pawnIndex = -1) { Rect rect2 = new Rect(146f, rect.y + 3f, 50f, 25f); Rect rect3 = rect2; rect3.x = rect3.x - rect2.width; List <ConfigurationLine> config; if (colony) { config = VerifyStart.Instance.Config; if (Widgets.ButtonText(rect2, "Roll", true, false, true)) { Find.WindowStack.Add(new Dialog_rolling(this)); this.iterations = 0; this.RollColonists(-1); } } else { if (VerifyStart.Instance.ColonistConfig.ElementAtOrDefault(pawnIndex) == null) { VerifyStart.Instance.ColonistConfig.Insert(pawnIndex, new ColonistConfiguration()); } if (Widgets.ButtonText(rect2, VerifyStart.Instance.ColonistConfig[pawnIndex].isUsing.ToString(), true, true, true)) { VerifyStart.Instance.ColonistConfig[pawnIndex].isUsing = this.NextValue(VerifyStart.Instance.ColonistConfig[pawnIndex].isUsing); } string text = string.Concat(new string[] { "Colony - Use the colony reroll stats.", Environment.NewLine, "Locked - Do not reroll this colonist but count their stats.", Environment.NewLine, "Ignored = Do not reroll this colonist and ignore their stats" }); TooltipHandler.TipRegion(rect2, text); enumIsUsing isUsing = VerifyStart.Instance.ColonistConfig[pawnIndex].isUsing; if (isUsing != enumIsUsing.Colony) { config = VerifyStart.Instance.Config; } else { config = VerifyStart.Instance.Config; } } int num = 0; checked { using (List <ConfigurationLine> .Enumerator enumerator = config.GetEnumerator()) { while (enumerator.MoveNext()) { ConfigurationLine skill = enumerator.Current; if (DefDatabase <SkillDef> .AllDefsListForReading.FindIndex((SkillDef x) => (int)x.index == skill.skillId) >= 0) { num++; Rect rect4 = unchecked (new Rect(this.workColumnSpacing * (float)num + 126f, rect.y + 3f, 25f, 25f)); Text.Anchor = TextAnchor.MiddleCenter; if (colony) { if (!skill.useSkill) { Widgets.DrawTextureFitted(rect4, Widgets.CheckboxOffTex, 1f); } Widgets.Label(rect4, skill.minLevel.ToString()); Widgets.DrawBox(rect4, 1); VerifyStartWarning verifyStartWarning; try { verifyStartWarning = VerifyStart.Instance.GetWarnings().Find((VerifyStartWarning x) => x.skillId == skill.skillId); } catch (Exception ex) { verifyStartWarning = null; Log.Error("Couldn't find the warning in GetWarnings." + Environment.NewLine + ex.ToString()); } if (Mouse.IsOver(rect4)) { if (verifyStartWarning == null || verifyStartWarning.passed) { Widgets.DrawBoxSolid(rect4, new Color(0.5f, 1f, 0.5f, 0.6f)); } else { Widgets.DrawBoxSolid(rect4, new Color(1f, 0.5f, 0.5f, 0.6f)); } } else if (verifyStartWarning == null || verifyStartWarning.passed) { Widgets.DrawBoxSolid(rect4, new Color(0.5f, 1f, 0.5f, 0.3f)); } else { Widgets.DrawBoxSolid(rect4, new Color(1f, 0.5f, 0.5f, 0.3f)); } if (Widgets.ButtonInvisible(rect4, true)) { if (Input.GetMouseButtonUp(2)) { skill.useSkill = !skill.useSkill; } else if (Input.GetMouseButtonUp(0) && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))) { skill.useSkill = !skill.useSkill; } else if (Input.GetMouseButtonUp(1)) { if (skill.minLevel > 0) { skill.minLevel--; } } else if (Input.GetMouseButtonUp(0)) { if (skill.minLevel < 20) { skill.minLevel++; } } } string text2 = string.Concat(new string[] { "Left Click to increase.", Environment.NewLine, "Right click to decrease.", Environment.NewLine, "Middle click or Shift click to enable/disable." }); TooltipHandler.TipRegion(rect4, text2); Text.Anchor = TextAnchor.UpperLeft; } else { SkillRecord skill2 = Find.GameInitData.startingPawns[pawnIndex].skills.GetSkill(DefDatabase <SkillDef> .AllDefsListForReading.Find((SkillDef x) => (int)x.index == skill.skillId)); if (skill2.TotallyDisabled) { Widgets.Label(rect4, "-"); } else { Widgets.Label(rect4, skill2.Level.ToString()); } } } } } } }