예제 #1
0
 private static void RecacheIfDirty()
 {
     if (ScenarioLister.dirty)
     {
         ScenarioLister.RecacheData();
     }
 }
예제 #2
0
 private void EnsureValidSelection()
 {
     if (curScen == null || !ScenarioLister.ScenarioIsListedAnywhere(curScen))
     {
         curScen = ScenarioLister.ScenariosInCategory(ScenarioCategory.FromDef).FirstOrDefault();
     }
 }
 public static IEnumerable <Scenario> ScenariosInCategory(ScenarioCategory cat)
 {
     ScenarioLister.RecacheIfDirty();
     if (cat == ScenarioCategory.FromDef)
     {
         foreach (ScenarioDef scenDef in DefDatabase <ScenarioDef> .AllDefs)
         {
             yield return(scenDef.scenario);
         }
     }
     else if (cat == ScenarioCategory.CustomLocal)
     {
         foreach (Scenario scen in ScenarioFiles.AllScenariosLocal)
         {
             yield return(scen);
         }
     }
     else if (cat == ScenarioCategory.SteamWorkshop)
     {
         foreach (Scenario scen2 in ScenarioFiles.AllScenariosWorkshop)
         {
             yield return(scen2);
         }
     }
     yield break;
 }
예제 #4
0
        private void DoScenarioListEntry(Rect rect, Scenario scen)
        {
            bool flag = this.curScen == scen;

            Widgets.DrawOptionBackground(rect, flag);
            MouseoverSounds.DoRegion(rect);
            Rect rect2 = rect.ContractedBy(4f);

            Text.Font = GameFont.Small;
            Rect rect3 = rect2;

            rect3.height = Text.CalcHeight(scen.name, rect3.width);
            Widgets.Label(rect3, scen.name);
            Text.Font = GameFont.Tiny;
            Rect rect4 = rect2;

            rect4.yMin = rect3.yMax;
            Widgets.Label(rect4, scen.GetSummary());
            if (scen.enabled)
            {
                WidgetRow widgetRow = new WidgetRow(rect.xMax, rect.y, UIDirection.LeftThenDown, 99999f, 4f);
                if (scen.Category == ScenarioCategory.CustomLocal && widgetRow.ButtonIcon(TexButton.DeleteX, "Delete".Translate(), new Color?(GenUI.SubtleMouseoverColor)))
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDelete".Translate(scen.File.Name), delegate
                    {
                        scen.File.Delete();
                        ScenarioLister.MarkDirty();
                    }, true, null));
                }
                if (scen.Category == ScenarioCategory.SteamWorkshop && widgetRow.ButtonIcon(TexButton.DeleteX, "Unsubscribe".Translate(), new Color?(GenUI.SubtleMouseoverColor)))
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(scen.File.Name), delegate
                    {
                        scen.enabled = false;
                        if (this.curScen == scen)
                        {
                            this.curScen = null;
                            this.EnsureValidSelection();
                        }
                        Workshop.Unsubscribe(scen);
                    }, true, null));
                }
                if (scen.GetPublishedFileId() != PublishedFileId_t.Invalid)
                {
                    if (widgetRow.ButtonIcon(ContentSource.SteamWorkshop.GetIcon(), "WorkshopPage".Translate(), null))
                    {
                        SteamUtility.OpenWorkshopPage(scen.GetPublishedFileId());
                    }
                    if (scen.CanToUploadToWorkshop())
                    {
                        widgetRow.Icon(Page_SelectScenario.CanUploadIcon, "CanBeUpdatedOnWorkshop".Translate());
                    }
                }
                if (!flag && Widgets.ButtonInvisible(rect, false))
                {
                    this.curScen = scen;
                    SoundDefOf.Click.PlayOneShotOnCamera(null);
                }
            }
        }
예제 #5
0
        internal void Notify_ScenarioListChanged()
        {
            PublishedFileId_t selModId = curScen.GetPublishedFileId();

            curScen = ScenarioLister.AllScenarios().FirstOrDefault((Scenario sc) => sc.GetPublishedFileId() == selModId);
            EnsureValidSelection();
        }
예제 #6
0
 public override void PreOpen()
 {
     base.PreOpen();
     infoScrollPosition = Vector2.zero;
     ScenarioLister.MarkDirty();
     EnsureValidSelection();
 }
예제 #7
0
        private void DoScenarioSelectionList(Rect rect)
        {
            rect.xMax += 2f;
            Rect rect2 = new Rect(0f, 0f, rect.width - 16f - 2f, totalScenarioListHeight + 250f);

            Widgets.BeginScrollView(rect, ref scenariosScrollPosition, rect2);
            Rect rect3 = rect2.AtZero();

            rect3.height = 999999f;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.ColumnWidth = rect2.width;
            listing_Standard.Begin(rect3);
            Text.Font = GameFont.Small;
            ListScenariosOnListing(listing_Standard, ScenarioLister.ScenariosInCategory(ScenarioCategory.FromDef));
            listing_Standard.Gap();
            Text.Font = GameFont.Small;
            listing_Standard.Label("ScenariosCustom".Translate());
            ListScenariosOnListing(listing_Standard, ScenarioLister.ScenariosInCategory(ScenarioCategory.CustomLocal));
            listing_Standard.Gap();
            Text.Font = GameFont.Small;
            listing_Standard.Label("ScenariosSteamWorkshop".Translate());
            if (listing_Standard.ButtonText("OpenSteamWorkshop".Translate()))
            {
                SteamUtility.OpenSteamWorkshopPage();
            }
            ListScenariosOnListing(listing_Standard, ScenarioLister.ScenariosInCategory(ScenarioCategory.SteamWorkshop));
            listing_Standard.End();
            totalScenarioListHeight = listing_Standard.CurHeight;
            Widgets.EndScrollView();
        }
예제 #8
0
 private void EnsureValidSelection()
 {
     if (this.curScen != null && ScenarioLister.ScenarioIsListedAnywhere(this.curScen))
     {
         return;
     }
     this.curScen = ScenarioLister.ScenariosInCategory(ScenarioCategory.FromDef).FirstOrDefault();
 }
예제 #9
0
        public static int ScenarioListHash()
        {
            int num = 9826121;

            foreach (Scenario item in ScenarioLister.AllScenarios())
            {
                num ^= 791 * item.GetHashCode() * 6121;
            }
            return(num);
        }
예제 #10
0
        private static void RecacheData()
        {
            ScenarioLister.dirty = false;
            int num = ScenarioLister.ScenarioListHash();

            ScenarioFiles.RecacheData();
            if (ScenarioLister.ScenarioListHash() != num && !LongEventHandler.ShouldWaitForEvent)
            {
                Page_SelectScenario page_SelectScenario = Find.WindowStack.WindowOfType <Page_SelectScenario>();
                if (page_SelectScenario != null)
                {
                    page_SelectScenario.Notify_ScenarioListChanged();
                }
            }
        }
예제 #11
0
        public static IEnumerable <Scenario> ScenariosInCategory(ScenarioCategory cat)
        {
            ScenarioLister.RecacheIfDirty();
            switch (cat)
            {
            case ScenarioCategory.FromDef:
                using (IEnumerator <ScenarioDef> enumerator3 = DefDatabase <ScenarioDef> .AllDefs.GetEnumerator())
                {
                    if (enumerator3.MoveNext())
                    {
                        ScenarioDef scenDef = enumerator3.Current;
                        yield return(scenDef.scenario);

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
                break;

            case ScenarioCategory.CustomLocal:
                using (IEnumerator <Scenario> enumerator2 = ScenarioFiles.AllScenariosLocal.GetEnumerator())
                {
                    if (enumerator2.MoveNext())
                    {
                        Scenario scen2 = enumerator2.Current;
                        yield return(scen2);

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
                break;

            case ScenarioCategory.SteamWorkshop:
                using (IEnumerator <Scenario> enumerator = ScenarioFiles.AllScenariosWorkshop.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        Scenario scen = enumerator.Current;
                        yield return(scen);

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
                break;
            }
            yield break;
IL_0201:
            /*Error near IL_0202: Unexpected return in MoveNext()*/;
        }
예제 #12
0
 public static IEnumerable <Scenario> AllScenarios()
 {
     ScenarioLister.RecacheIfDirty();
     foreach (ScenarioDef scenDef in DefDatabase <ScenarioDef> .AllDefs)
     {
         yield return(scenDef.scenario);
     }
     foreach (Scenario scen in ScenarioFiles.AllScenariosLocal)
     {
         yield return(scen);
     }
     foreach (Scenario scen2 in ScenarioFiles.AllScenariosWorkshop)
     {
         yield return(scen2);
     }
 }
예제 #13
0
 public static bool ScenarioIsListedAnywhere(Scenario scen)
 {
     ScenarioLister.RecacheIfDirty();
     foreach (ScenarioDef allDef in DefDatabase <ScenarioDef> .AllDefs)
     {
         if (allDef.scenario == scen)
         {
             return(true);
         }
     }
     foreach (Scenario item in ScenarioFiles.AllScenariosLocal)
     {
         if (scen == item)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #14
0
 public static bool ScenarioIsListedAnywhere(Scenario scen)
 {
     ScenarioLister.RecacheIfDirty();
     foreach (ScenarioDef current in DefDatabase <ScenarioDef> .AllDefs)
     {
         if (current.scenario == scen)
         {
             bool result = true;
             return(result);
         }
     }
     foreach (Scenario current2 in ScenarioFiles.AllScenariosLocal)
     {
         if (scen == current2)
         {
             bool result = true;
             return(result);
         }
     }
     return(false);
 }
예제 #15
0
        public static IEnumerable <Scenario> AllScenarios()
        {
            ScenarioLister.RecacheIfDirty();
            using (IEnumerator <ScenarioDef> enumerator = DefDatabase <ScenarioDef> .AllDefs.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    ScenarioDef scenDef = enumerator.Current;
                    yield return(scenDef.scenario);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            using (IEnumerator <Scenario> enumerator2 = ScenarioFiles.AllScenariosLocal.GetEnumerator())
            {
                if (enumerator2.MoveNext())
                {
                    Scenario scen2 = enumerator2.Current;
                    yield return(scen2);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            using (IEnumerator <Scenario> enumerator3 = ScenarioFiles.AllScenariosWorkshop.GetEnumerator())
            {
                if (enumerator3.MoveNext())
                {
                    Scenario scen = enumerator3.Current;
                    yield return(scen);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield break;
IL_01d3:
            /*Error near IL_01d4: Unexpected return in MoveNext()*/;
        }
예제 #16
0
 internal void <> m__0()
 {
     this.scen.File.Delete();
     ScenarioLister.MarkDirty();
 }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                bool flag = false;

                switch (num)
                {
                case 0u:
                    ScenarioLister.RecacheIfDirty();
                    enumerator = DefDatabase <ScenarioDef> .AllDefs.GetEnumerator();

                    num = 4294967293u;
                    break;

                case 1u:
                    break;

                case 2u:
                    goto IL_CF;

                case 3u:
                    goto IL_156;

                default:
                    return(false);
                }
                try
                {
                    switch (num)
                    {
                    }
                    if (enumerator.MoveNext())
                    {
                        scenDef       = enumerator.Current;
                        this.$current = scenDef.scenario;
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        flag = true;
                        return(true);
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        if (enumerator != null)
                        {
                            enumerator.Dispose();
                        }
                    }
                }
                enumerator2 = ScenarioFiles.AllScenariosLocal.GetEnumerator();
                num         = 4294967293u;
                try
                {
IL_CF:
                    switch (num)
                    {
                    }
                    if (enumerator2.MoveNext())
                    {
                        scen          = enumerator2.Current;
                        this.$current = scen;
                        if (!this.$disposing)
                        {
                            this.$PC = 2;
                        }
                        flag = true;
                        return(true);
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        if (enumerator2 != null)
                        {
                            enumerator2.Dispose();
                        }
                    }
                }
                enumerator3 = ScenarioFiles.AllScenariosWorkshop.GetEnumerator();
                num         = 4294967293u;
                try
                {
IL_156:
                    switch (num)
                    {
                    }
                    if (enumerator3.MoveNext())
                    {
                        scen2         = enumerator3.Current;
                        this.$current = scen2;
                        if (!this.$disposing)
                        {
                            this.$PC = 3;
                        }
                        flag = true;
                        return(true);
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        if (enumerator3 != null)
                        {
                            enumerator3.Dispose();
                        }
                    }
                }
                this.$PC = -1;
                return(false);
            }