Esempio n. 1
0
        private void DrawMissionTab(Rect rect, Mission mission, StoryControlDef SCD, int num)
        {
            mission.Notify_Seen();
            rect = rect.ContractedBy(1f);
            if (Mouse.IsOver(rect) || SelectedMission == mission)
            {
                Widgets.DrawHighlight(rect);
            }
            float     offset = (rect.height - 24f) * 0.5f;
            WidgetRow tab    = new WidgetRow(rect.x + offset, rect.y + offset);
            MOState   state  = mission.LatestState;

            if (mission.def.repeatable)
            {
                tab.Icon(ContentFinder <Texture2D> .Get(SCD.repeatableIconPath, false));
            }
            else if (state == MOState.Active)
            {
                tab.Icon(ContentFinder <Texture2D> .Get(SCD.activeIconPath, false));
            }
            else if (state == MOState.Finished)
            {
                tab.Icon(ContentFinder <Texture2D> .Get(SCD.finishedIconPath, false));
            }
            else if (state == MOState.Failed)
            {
                tab.Icon(ContentFinder <Texture2D> .Get(SCD.failedIconPath, false));
            }
            tab.Gap(5f);
            string  label       = mission.def.LabelCap;
            Vector2 labelSize   = Text.CalcSize(label);
            float   width       = rect.width - tab.FinalX;
            float   labelHeight = Text.CalcHeight(label, width);

            offset = (rect.height - labelHeight) * 0.5f;
            Rect labelRect = new Rect(tab.FinalX, rect.y + offset, width, rect.height);

            Widgets.Label(labelRect, label);

            if (Widgets.ButtonInvisible(rect, true))
            {
                SoundDefOf.Click.PlayOneShotOnCamera(null);
                selectedLockedMission = null;
                this.SelectedMission  = mission;
                SetActiveObjective();
            }

            /*
             * bool mouseOver = Mouse.IsOver(rect);
             * if (mouseOver || this.SelectedMission == mission)
             * {
             *  Color color = SCD.borderColor.ToColor;
             *  Color half = color;
             *  half.a = 0.5f;
             *  GUI.color = mouseOver ? half : color;
             *  Widgets.DrawBox(rect, 1);
             *  GUI.color = Color.white;
             * }
             */
        }
Esempio n. 2
0
        private void DrawLockedMissionTab(Rect rect, MissionDef def, StoryControlDef SCD)
        {
            rect = rect.ContractedBy(1f);
            if (Mouse.IsOver(rect) || selectedLockedMission == def)
            {
                Widgets.DrawHighlight(rect);
            }
            float     offset = (rect.height - 24f) * 0.5f;
            WidgetRow tab    = new WidgetRow(rect.x + offset, rect.y + offset);

            tab.Label(def.LabelCap);
            if (Widgets.ButtonInvisible(rect))
            {
                SoundDefOf.Click.PlayOneShotOnCamera(null);
                selectedLockedMission = def;
                SelectedMission       = null;
            }
            bool mouseOver = Mouse.IsOver(rect);

            /*
             * if (mouseOver || selectedLockedMission == def)
             * {
             *  Color color = SCD.borderColor.ToColor;
             *  Color half = color;
             *  half.a = 0.5f;
             *  GUI.color = mouseOver ? half : color;
             *  Widgets.DrawBox(rect, 1);
             *  GUI.color = Color.white;
             * }
             */
        }
 public MOState GetMissionState(MissionDef def)
 {
     if (Missions.Any(m => m.def == def))
     {
         return(Missions.Find(m => m.def == def).LatestState);
     }
     return(MOState.Inactive);
 }
 public Mission ActivateMission(MissionDef missionDef)
 {
     if (!Missions.Any(m => m.def == missionDef))
     {
         Mission mission = new Mission(missionDef);
         Missions.Add(mission);
         return(mission);
     }
     return(Missions.Find(m => m.def == missionDef));
 }
Esempio n. 5
0
        private float InfoHeightFor(float width, MissionDef def)
        {
            Requisites req   = def.requisites;
            float      total = 0f;

            total += Text.CalcHeight("MissionInfoMain_SMO".Translate("'" + selectedLockedMission.label + "'"), width);
            total += 12f;
            total += ReqHeight(req.researchProjects);
            total += ReqHeight(req.missions);
            total += ReqHeight(req.objectives);
            total += ReqHeight(req.jobs);
            total += ReqHeight(req.things.AllThingDefs());
            return(total);
        }
 public bool GetMissionSeen(MissionDef def)
 {
     return(Missions.Find(m => m.def == def)?.Seen ?? false);
 }
 public Mission GetMission(MissionDef def)
 {
     return(Missions.Find(m => m.def == def));
 }
Esempio n. 8
0
 public Mission(MissionDef def)
 {
     this.def = def;
     SetUp();
     StoryManager.StoryHandler.Notify_NewMission(this);
 }
Esempio n. 9
0
        public void DrawLockedMissionInfo(Rect rect)
        {
            Rect InfoRect = new Rect(rect.x, rect.y, rect.width / 3f, rect.height);

            StoryUtils.DrawMenuSectionColor(InfoRect, 1, new ColorInt(55, 55, 55), new ColorInt(135, 135, 135));
            float TotalHeight = InfoHeightFor(InfoRect.width, selectedLockedMission);
            Rect  ViewRect    = new Rect(InfoRect.x, InfoRect.y, InfoRect.width, TotalHeight);

            Widgets.BeginScrollView(InfoRect, ref missionInfoScrollPos, ViewRect, false);
            InfoRect = InfoRect.ContractedBy(5f);
            GUI.BeginGroup(InfoRect);
            //MainPart
            float      CurY           = 0f;
            Requisites requisites     = selectedLockedMission.requisites;
            string     MainInfo       = requisites.anyList ? "MissionInfoMainAny_SMO".Translate("'" + selectedLockedMission.label + "'") : "MissionInfoMain_SMO".Translate("'" + selectedLockedMission.label + "'");
            float      MainInfoHeight = Text.CalcHeight(MainInfo, InfoRect.width);
            Rect       MainInfoRect   = new Rect(0, 0, InfoRect.width, MainInfoHeight);

            Widgets.Label(MainInfoRect, MainInfo);
            CurY += MainInfoRect.height;

            GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.researchProjects, requisites.anyResearch ? "MissionInfoResearchAny_SMO".Translate() : "MissionInfoResearch_SMO".Translate(), delegate(ResearchProjectDef def)
            {
                Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Research, true);
                MainTabWindow_Research window = (Find.WindowStack.Windows.Where(w => w is MainTabWindow_Research).FirstOrDefault() as MainTabWindow_Research);
                Traverse.Create(window).Field("selectedProject").SetValue(def);
            });
            GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.missions, requisites.anyMission ? "MissionInfoMissionsAny_SMO".Translate() : "MissionInfoMissions_SMO".Translate(), delegate(MissionDef def)
            {
                SelectedMission       = StoryManager.GetMission(def);
                selectedLockedMission = null;
            });
            GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.objectives, requisites.anyObjective ? "MissionInfoObjectivesAny_SMO".Translate() : "MissionInfoObjectives_SMO".Translate(), delegate(ObjectiveDef def)
            {
                SelectedMission       = StoryManager.GetMission(def);
                SelectedObjective     = SelectedMission.objectives.Find(o => o.def == def);
                selectedLockedMission = null;
            });
            GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.things, requisites.anyThing ? "MissionInfoThingsAny_SMO".Translate() : "MissionInfoThings_SMO".Translate(), null, delegate(Rect selection, ThingValue tv)
            {
                ThingDef thingDef   = tv.ThingDef;
                string stuffLabel   = tv.Stuff != null ? tv.ResolvedStuff.LabelCap : "Any_SMO".Translate();
                string qualityLabel = !thingDef.CountAsResource ? tv.CustomQuality ? " (" + tv.QualityCategory.GetLabel() + ")" : "" : "";
                string fullLabel    = "  - " + (tv.ResolvedStuff != null ? stuffLabel + " " : "") + thingDef.LabelCap + qualityLabel + " (x" + tv.value + ")";
                Vector2 labelSize   = Text.CalcSize(fullLabel);
                bool oversized      = labelSize.x > selection.width;
                string label        = oversized ? "  - " + tv.ThingDef.LabelCap + "(...)" : fullLabel;
                Widgets.Label(selection, label);
                if (oversized)
                {
                    TooltipHandler.TipRegion(selection, fullLabel);
                }
            });
            GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.jobs, "MissionInfoJobs_SMO".Translate(), null, delegate(Rect selection, JobDef def)
            {
                string label = "  ..." + def.reportString;
                Widgets.Label(selection, label);
            });
            GUI.EndGroup();
            Widgets.EndScrollView();
        }
Esempio n. 10
0
        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();
            }
        }
 public Mission(MissionDef def)
 {
     this.def = def;
     SetUp();
 }
 public static string GetModNameFromMission(MissionDef def)
 {
     return(LoadedModManager.RunningMods.Where(mcp => mcp.AllDefs.Contains(def)).RandomElement().Identifier);
 }