public void CheckForNewMods() { foreach (ModContentPack mcp in LoadedModManager.RunningMods.Where(mcp => mcp.AllDefs.Any(def => def is StoryControlDef))) { if (mcp != null) { if (!ModFolder.Any(mcpw => mcpw.identifier == mcp.Identifier)) { ModContentPackWrapper mcpw = new ModContentPackWrapper(mcp.Identifier); ModFolder.Add(mcpw); } } } }
public void DrawMissionMenu(Rect inRect) { //Draw Tabs Text.Font = GameFont.Small; Rect tabRect = new Rect(inRect.x + 10f, inRect.y - 20f, inRect.width - 30f, 20f); string missions = "Missions_SMO".Translate(); string themes = "Themes_SMO".Translate(); string locked = "LockedTab_SMO".Translate(); Vector2 v1 = Text.CalcSize(missions); Vector2 v2 = Text.CalcSize(themes); Vector2 v3 = Text.CalcSize(locked); v1.x += 6; v2.x += 6; v3.x += 6; Rect missionTab = new Rect(new Vector2(tabRect.x, tabRect.y), v1); Rect themeTab = new Rect(new Vector2(missionTab.xMax, missionTab.y), v2); Rect lockedButton = new Rect(new Vector2(themeTab.xMax, themeTab.y), v3); Text.Anchor = TextAnchor.MiddleCenter; StoryUtils.DrawMenuSectionColor(missionTab, 1, StoryMats.defaultFill, StoryMats.defaultBorder); Widgets.Label(missionTab, missions); StoryUtils.DrawMenuSectionColor(themeTab, 1, StoryMats.defaultFill, StoryMats.defaultBorder); Widgets.Label(themeTab, themes); float opacity = Mouse.IsOver(lockedButton) ? 1f : 0.5f; ColorInt border = showLocked ? new ColorInt(142, 200, 154, (int)(255f * opacity)) : new ColorInt(243, 153, 123, (int)(255f * opacity)); StoryUtils.DrawMenuSectionColor(lockedButton, 1, StoryMats.defaultFill, border); if (Widgets.ButtonInvisible(lockedButton, true)) { showLocked = !showLocked; if (!showLocked) { SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); selectedLockedMission = null; } else { SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null); } } Widgets.Label(lockedButton, locked); GUI.color = new Color(0.8f, 0.8f, 0.8f); if (Widgets.ButtonInvisible(missionTab)) { SoundDefOf.Click.PlayOneShotOnCamera(null); TabFlag = true; } if (Mouse.IsOver(missionTab) || TabFlag) { Widgets.DrawBox(missionTab, 1); } if (Widgets.ButtonInvisible(themeTab)) { SoundDefOf.Click.PlayOneShotOnCamera(null); TabFlag = false; } if (Mouse.IsOver(themeTab) || !TabFlag) { Widgets.DrawBox(themeTab, 1); } GUI.color = Color.white; StoryUtils.DrawMenuSectionColor(inRect, 1, new ColorInt(55, 55, 55), new ColorInt(135, 135, 135)); Rect rect = inRect.ContractedBy(5f); float selectionHeight = 45f; float viewHeight = 0f; float selectionYPos = 0f; if (TabFlag) { //Mission Tab GUI.BeginGroup(rect); viewHeight = MissionTabHeight(selectionHeight); Rect outRect = new Rect(0f, 0f, rect.width, rect.height); Rect viewRect = new Rect(0f, 0f, rect.width, viewHeight); Widgets.BeginScrollView(outRect, ref StoryManager.missionScrollPos, viewRect, false); for (int i = 0; i < StoryManager.ModFolder.Count; i++) { ModContentPackWrapper MCPW = StoryManager.ModFolder[i]; if (MCPW.SCD != SCD.MainStoryControlDef) { List <Mission> Missions = MissionsForMod(MCPW.MCP); //Identifier string appendix = MCPW.Toggled ? "-" : "+"; string identifier = MCPW.SCD.label + " " + appendix; Vector2 identifierSize = Text.CalcSize(identifier); identifierSize.x += 6f; Rect identifierRect = new Rect(new Vector2(0f, selectionYPos), identifierSize); selectionYPos += identifierRect.height; Widgets.DrawMenuSection(identifierRect); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(identifierRect, identifier); Text.Anchor = 0; Text.Font = GameFont.Small; if (Widgets.ButtonInvisible(identifierRect) && MCPW.HasActiveMissions) { MCPW.Toggle(); if (MCPW.Toggled) { SoundDefOf.TabOpen.PlayOneShotOnCamera(null); } else { SoundDefOf.TabClose.PlayOneShotOnCamera(null); } } if (Mouse.IsOver(identifierRect)) { GUI.color = new Color(0.8f, 0.8f, 0.8f); Widgets.DrawBox(identifierRect, 1); GUI.color = Color.white; } UIHighlighter.HighlightOpportunity(identifierRect, MCPW.MCP.Identifier + "-StoryHighlight"); if (MCPW.Toggled) { //Group float lockedCount = 0; string lockedLabel = ""; Vector2 lockedSize = Vector2.zero; List <Def> cachedLocked = new List <Def>(); if (showLocked) { cachedLocked = MCPW.MCP.AllDefs.Where(d => d is MissionDef && !(d as MissionDef).HardLocked && (d as MissionDef).CurrentState == MOState.Inactive).ToList(); lockedCount = cachedLocked.Count(); lockedLabel = "Locked_SMO".Translate() + ":"; lockedSize = Text.CalcSize(lockedLabel); } bool lockedBool = lockedCount > 0; float height = (lockedCount + Missions.Count) * selectionHeight + (lockedBool ? lockedSize.y : 0f); Rect groupRect = new Rect(0f, selectionYPos, rect.width, height); StoryUtils.DrawMenuSectionColor(groupRect, 1, MCPW.SCD.color, MCPW.SCD.borderColor); float missionTabY = groupRect.y; for (int ii = 0; ii < Missions.Count; ii++) { Mission mission = Missions[ii]; Rect rect4 = new Rect(groupRect.x, missionTabY, groupRect.width, selectionHeight); StoryControlDef scd = StoryManager.Theme != null ? StoryManager.Theme.SCD : SCD.MainStoryControlDef; DrawMissionTab(rect4, mission, scd, ii); missionTabY += selectionHeight; } if (showLocked && lockedBool) { float h = height - (Missions.Count * selectionHeight); Rect boxRect = new Rect(groupRect.x, groupRect.y + (height - h), groupRect.width, h); Widgets.DrawBoxSolid(boxRect.ContractedBy(2f), new Color(0.2f, 0.2f, 0.2f, 0.2f)); GUI.color = MCPW.SCD.borderColor.ToColor; Widgets.DrawLineHorizontal(boxRect.x, boxRect.y, boxRect.width); GUI.color = Color.white; Widgets.Label(new Rect(new Vector2(groupRect.x + 5f, missionTabY), lockedSize), lockedLabel); missionTabY += lockedSize.y; foreach (MissionDef def in cachedLocked) { Rect rect4 = new Rect(groupRect.x, missionTabY, groupRect.width, selectionHeight); DrawLockedMissionTab(rect4, def, MCPW.SCD); missionTabY += selectionHeight; } } selectionYPos += height; } } selectionYPos += 5f; } Widgets.EndScrollView(); GUI.EndGroup(); } else { //Theme Tab GUI.BeginGroup(rect); viewHeight = selectionHeight * StoryManager.ModFolder.Count; Rect outRect = new Rect(0f, 0f, rect.width, rect.height); Rect viewRect = new Rect(0f, 0f, rect.width, viewHeight); Widgets.BeginScrollView(outRect, ref StoryManager.missionScrollPos, viewRect, false); for (int i = 0; i < StoryManager.ModFolder.Count + 1; i++) { Rect selection = new Rect(0f, selectionYPos, rect.width, selectionHeight).ContractedBy(5f); Text.Anchor = TextAnchor.MiddleCenter; if (i == 0) { Widgets.DrawMenuSection(selection); Widgets.Label(selection, "None"); if (Mouse.IsOver(selection) || StoryManager.Theme == null) { GUI.color = new Color(0.8f, 0.8f, 0.8f); Widgets.DrawBox(selection, 1); GUI.color = Color.white; if (Widgets.ButtonInvisible(selection)) { UpdateTheme(null); SoundDefOf.Click.PlayOneShotOnCamera(null); } } } else { ModContentPackWrapper mcp = StoryManager.ModFolder.ElementAt(i - 1); if (mcp.SCD != SCD.MainStoryControlDef ? mcp.SCD.backGroundPath != SCD.MainStoryControlDef.backGroundPath : true) { Widgets.DrawMenuSection(selection); Widgets.Label(selection, mcp.SCD.LabelCap); if (Mouse.IsOver(selection) || StoryManager.Theme == mcp) { GUI.color = new Color(0.8f, 0.8f, 0.8f); Widgets.DrawBox(selection, 1); GUI.color = Color.white; if (Widgets.ButtonInvisible(selection, true)) { UpdateTheme(mcp.MCP); SoundDefOf.Click.PlayOneShotOnCamera(null); } } } } Text.Anchor = 0; selectionYPos += selectionHeight; } Widgets.EndScrollView(); GUI.EndGroup(); } }