Example #1
0
        public static bool TryOpen(string filename, out StageList stageList)
        {
            stageList = null;

            SarcData sarc = SARC.UnpackRamN(YAZ0.Decompress(filename));

            BymlFileData byml;

            if (sarc.Files.ContainsKey("StageList.byml"))
            {
                byml = ByamlFile.LoadN(new MemoryStream(sarc.Files["StageList.byml"]), true, ByteOrder.BigEndian);
            }
            else
            {
                throw new Exception("Failed to find the StageList");
            }


            if (!byml.RootNode.TryGetValue("WorldList", out dynamic worldList))
            {
                return(false);
            }


            List <World> worlds = new List <World>();

            for (int i = 0; i < worldList.Count; i++)
            {
                worlds.Add(new World(worldList[i]));
            }

            stageList = new StageList(filename, worlds, byml.byteOrder);

            return(true);
        }
Example #2
0
        public LevelSelectForm(StageList stagelist, bool showMisc = false)
        {
            InitializeComponent();
            CenterToScreen();

            Text = Program.CurrentLanguage.GetTranslation("LevelSelectTitle") ?? "Spotlight - Choose a Level";
            CourseIDColumnHeader.Text  = Program.CurrentLanguage.GetTranslation("CourseIDColumnHeader") ?? "CourseID";
            LevelNameColumnHeader.Text = Program.CurrentLanguage.GetTranslation("LevelNameColumnHeader") ?? "Level Name";

            this.stagelist = stagelist;

            for (int i = 0; i < SectionComboBox.Items.Count - 1; i++)
            {
                if (Program.CurrentLanguage.Translations.TryGetValue("WorldName" + (i + 1), out string value))
                {
                    SectionComboBox.Items[i] = value;
                }
            }

            if (!showMisc)
            {
                SectionComboBox.Items.RemoveAt(12); //Misc
                SectionComboBox.Items.RemoveAt(12); //Bowsers Fury
            }
            else
            {
                //Misc
                SectionComboBox.Items[12] = Program.CurrentLanguage.GetTranslation("WorldNameMisc") ?? "Miscellaneous";
                SectionComboBox.Items[13] = Program.CurrentLanguage.GetTranslation("WorldNameFury") ?? "Bowser's Fury";

                //Bowsers Fury
                string oceanStagepath = Program.TryGetPathViaProject("StageData", "SingleModeOceanStage.szs");
                if (File.Exists(oceanStagepath))
                {
                    islandInfos = new List <Level.LevelIO.ObjectInfo>();

                    Level.LevelIO.GetObjectInfosCombined(oceanStagepath, new Dictionary <string, List <Level.LevelIO.ObjectInfo> >()
                    {
                        ["IslandList"] = islandInfos
                    }, new Dictionary <string, List <Level.LevelIO.ObjectInfo> >(), new Dictionary <string, List <Level.LevelIO.ObjectInfo> >());
                }
                else
                {
                    SectionComboBox.Items.RemoveAt(13); //Bowsers Fury
                }
            }

            SectionComboBox.SelectedIndex = 0;
        }
        public LevelParameterForm(StageList stageList, string LevelName = "")
        {
            InitializeComponent();
            CenterToParent();
            Loading = true;

            StageTypeComboBox.DataSource    = new BindingSource(comboSource, null);
            StageTypeComboBox.DisplayMember = "Value";
            StageTypeComboBox.ValueMember   = "Key";

            StageList = stageList;

            WorldIDNumericUpDown.Maximum = StageList.Worlds.Count;

            Localize();

            if (!LevelName.Equals(""))
            {
                bool Breakout = false;
                for (int x = 0; x < StageList.Worlds.Count; x++)
                {
                    for (int y = 0; y < StageList.Worlds[x].Levels.Count; y++)
                    {
                        if (StageList.Worlds[x].Levels[y].StageName == LevelName)
                        {
                            WorldComboBox.SelectedIndex      = x;
                            LevelsListView.Items[y].Selected = true;
                            Breakout = true;
                            break;
                        }
                    }
                    if (Breakout)
                    {
                        break;
                    }
                }
            }
            else
            {
                WorldComboBox.SelectedIndex = 0;
            }

            Loading = false;
        }