コード例 #1
0
        public void TestIWadExclude()
        {
            //if the iwad has a file attached to it because of a source port, that file should not be included when the iwad is selected
            //e.g. GZDoom has noendgame.wad User launched DOOM2.WAD with GZDoom. This adds noendgame to the additional files of DOOM2.WAD.
            //if the user selects DOOM2.WAD with another file (and not GZDoom as the port), noendgame.wad should not be added

            IDataSourceAdapter adapter = TestUtil.CreateAdapter();
            var             mainFile   = adapter.GetGameFile("COOLGAMEFILE.WAD");
            FileLoadHandler handler    = new FileLoadHandler(adapter, mainFile);

            Assert.AreEqual(3, handler.GetCurrentAdditionalFiles().Count);

            var iwad       = adapter.GetGameFileIWads().First(x => x.FileName == "DOOM2.WAD");
            var sourceport = adapter.GetSourcePorts().First(x => x.Name == "zdoom.exe");

            iwad.SettingsFiles = "MOD4.WAD";
            adapter.UpdateGameFile(iwad);

            handler.CalculateAdditionalFiles(iwad, sourceport);
            var gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(5, gameFiles.Count);
            Assert.IsNotNull(gameFiles.FirstOrDefault(x => x.FileName == "MOD4.WAD"));

            //now set up the file so it should be excluded
            iwad.SettingsFilesSourcePort = "MOD4.WAD";
            adapter.UpdateGameFile(iwad);

            handler = new FileLoadHandler(adapter, mainFile);
            handler.CalculateAdditionalFiles(iwad, sourceport);
            gameFiles = handler.GetCurrentAdditionalFiles();
            Assert.AreEqual(4, gameFiles.Count);
            Assert.IsNull(gameFiles.FirstOrDefault(x => x.FileName == "MOD4.WAD"));
        }
コード例 #2
0
        public void TestHandlerIWad()
        {
            IDataSourceAdapter adapter = TestUtil.CreateAdapter();
            FileLoadHandler    handler = new FileLoadHandler(adapter, adapter.GetGameFile("COOLGAMEFILE.WAD"));

            Assert.AreEqual(3, handler.GetCurrentAdditionalFiles().Count);

            var iwad       = adapter.GetGameFileIWads().First(x => x.FileName == "PLUTONIA.WAD");
            var sourceport = adapter.GetSourcePorts().First(x => x.Name == "odamex.exe"); //no additional files for port

            handler.CalculateAdditionalFiles(iwad, sourceport);
            var gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(4, gameFiles.Count);
            Assert.IsNotNull(gameFiles.FirstOrDefault(x => x.FileName == "IWADMOD1.WAD"));

            //no change
            handler.CalculateAdditionalFiles(iwad, sourceport);
            gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.IsNotNull(gameFiles.FirstOrDefault(x => x.FileName == "IWADMOD1.WAD"));

            Assert.IsTrue(handler.IsIWadFile(gameFiles.First(x => x.FileName == "IWADMOD1.WAD")));
            Assert.IsFalse(handler.IsSourcePortFile(gameFiles.First(x => x.FileName == "IWADMOD1.WAD")));
        }
コード例 #3
0
        public void Initialize(IEnumerable <ITabView> additionalFileViews, IGameFile gameFile)
        {
            m_init = true;
            m_additionalFileViews = additionalFileViews.ToArray();

            GameFile = gameFile;

            m_handler = new FileLoadHandler(m_adapter, gameFile);

            cmbSourcePorts.DataSource = m_adapter.GetSourcePorts();
            cmbIwad.DataSource        = Util.GetIWadsDataSource(m_adapter);

            if (gameFile != null)
            {
                Text = "Launch - " + (string.IsNullOrEmpty(gameFile.Title) ? gameFile.FileName : gameFile.Title);
                if (!string.IsNullOrEmpty(gameFile.Map))
                {
                    cmbMap.DataSource = gameFile.Map.Split(new string[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
                }
                chkSaveStats.Checked = gameFile.SettingsStat;
            }

            cmbSkill.DataSource   = Util.GetSkills();
            cmbSkill.SelectedItem = "3";

            if (gameFile != null && IsIwad(gameFile))
            {
                pbInfo.Image = DoomLauncher.Properties.Resources.bon2b;
                lblInfo.Text = string.Format("These files will automatically be added{0} when this IWAD is selected for play.", Environment.NewLine);
            }
            else
            {
                tblFiles.RowStyles[0].Height = 0;
            }
        }
コード例 #4
0
        public void SetGameProfile(IGameProfile gameProfile)
        {
            SetIwadInfoLabel();

            UnregisterEvents();
            m_handler = new FileLoadHandler(m_adapter, GameFile, gameProfile);

            SetDefaultSelections();
            GameProfile.ApplyDefaultsToProfile(gameProfile, m_appConfig);
            cmbProfiles.SelectedValue = gameProfile.GameProfileID;

            if (GameFile != null)
            {
                chkSaveStats.Checked      = gameProfile.SettingsStat;
                chkLoadLatestSave.Checked = gameProfile.SettingsLoadLatestSave;

                if (gameProfile.SourcePortID.HasValue)
                {
                    SelectedSourcePort = m_adapter.GetSourcePort(gameProfile.SourcePortID.Value);
                }

                // Selected GameFile is an IWAD so lock the IWAD selection
                if (IsIwad(GameFile))
                {
                    cmbIwad.Enabled = false;
                    SelectedIWad    = GameFile;
                }
                else if (gameProfile.IWadID.HasValue)
                {
                    SelectedIWad = m_adapter.GetGameFileIWads().FirstOrDefault(x => x.IWadID == gameProfile.IWadID);
                }

                if (!string.IsNullOrEmpty(gameProfile.SettingsMap))
                {
                    SelectedMap = gameProfile.SettingsMap;
                }
                if (!string.IsNullOrEmpty(gameProfile.SettingsSkill))
                {
                    SelectedSkill = gameProfile.SettingsSkill;
                }
                if (!string.IsNullOrEmpty(gameProfile.SettingsExtraParams))
                {
                    ExtraParameters = gameProfile.SettingsExtraParams;
                }
                if (!string.IsNullOrEmpty(gameProfile.SettingsSpecificFiles))
                {
                    SpecificFiles = Util.SplitString(gameProfile.SettingsSpecificFiles);
                }
            }

            bool reset = ShouldRecalculateAdditionalFiles();

            HandleSourcePortSelectionChange(reset);
            HandleIwadSelectionChanged(reset);
            SetAdditionalFiles(reset);
            HandleDemoChange();
            RegisterEvents();
        }
コード例 #5
0
        public void TestUserSet()
        {
            //base test
            IDataSourceAdapter adapter = TestUtil.CreateAdapter();
            var             mainFile   = adapter.GetGameFile("COOLGAMEFILE.WAD");
            FileLoadHandler handler    = new FileLoadHandler(adapter, mainFile);

            Assert.AreEqual(3, handler.GetCurrentAdditionalFiles().Count);

            var iwad       = adapter.GetGameFileIWads().First(x => x.FileName == "PLUTONIA.WAD");
            var sourceport = adapter.GetSourcePorts().First(x => x.Name == "zdoom.exe");

            handler.CalculateAdditionalFiles(iwad, sourceport);
            var gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(5, gameFiles.Count);
            Assert.AreEqual("COOLGAMEFILE.WAD", gameFiles[0].FileName);
            Assert.AreEqual("SUPERCOOLMOD.WAD", gameFiles[1].FileName);
            Assert.AreEqual("MOD2.WAD", gameFiles[2].FileName);
            Assert.AreEqual("IWADMOD1.WAD", gameFiles[3].FileName);
            Assert.AreEqual("PORTMOD1.WAD", gameFiles[4].FileName);

            //**user removes iwad add file
            var addFiles = handler.GetCurrentAdditionalFiles();

            addFiles.RemoveAll(x => x.FileName == "IWADMOD1.WAD");
            SetAddFiles(mainFile, handler, addFiles);

            handler = new FileLoadHandler(adapter, mainFile);
            //do not call calculate, this will reset user set files
            gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(4, gameFiles.Count);
            Assert.AreEqual("COOLGAMEFILE.WAD", gameFiles[0].FileName);
            Assert.AreEqual("SUPERCOOLMOD.WAD", gameFiles[1].FileName);
            Assert.AreEqual("MOD2.WAD", gameFiles[2].FileName);
            Assert.AreEqual("PORTMOD1.WAD", gameFiles[3].FileName);

            //**user removes source port add file
            addFiles = handler.GetCurrentAdditionalFiles();
            addFiles.RemoveAll(x => x.FileName == "PORTMOD1.WAD");
            SetAddFiles(mainFile, handler, addFiles);

            handler = new FileLoadHandler(adapter, mainFile);
            //do not call calculate, this will reset user set files
            gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(3, gameFiles.Count);
            Assert.AreEqual("COOLGAMEFILE.WAD", gameFiles[0].FileName);
            Assert.AreEqual("SUPERCOOLMOD.WAD", gameFiles[1].FileName);
            Assert.AreEqual("MOD2.WAD", gameFiles[2].FileName);
        }
コード例 #6
0
        public void TestSimpleFileWithIwad()
        {
            //This was a bug, for an iwad like DOOM2 Doom Launcher sets the SettingsFile to DOOM2.WAD if the user loaded it. We need to exclude this when using DOOM2 as the iwad for another file
            IDataSourceAdapter adapter = TestUtil.CreateAdapter();
            var iwad = adapter.GetGameFileIWads().First(x => x.FileName == "DOOM2.WAD");

            iwad.SettingsFiles = "DOOM2.WAD";
            adapter.UpdateGameFile(iwad);

            FileLoadHandler handler = new FileLoadHandler(adapter, adapter.GetGameFile("COOLGAMEFILE.WAD"));

            iwad = adapter.GetGameFileIWads().First(x => x.FileName == "DOOM2.WAD");
            var sourceport = adapter.GetSourcePorts().First(x => x.Name == "zdoom.exe");

            handler.CalculateAdditionalFiles(iwad, sourceport);

            Assert.IsNull(handler.GetCurrentAdditionalFiles().FirstOrDefault(x => x.FileName == "DOOM2.WAD"));
        }
コード例 #7
0
        public void TestHandlerMixed()
        {
            IDataSourceAdapter adapter = TestUtil.CreateAdapter();
            FileLoadHandler    handler = new FileLoadHandler(adapter, adapter.GetGameFile("COOLGAMEFILE.WAD"));

            Assert.AreEqual(3, handler.GetCurrentAdditionalFiles().Count);

            var iwad       = adapter.GetGameFileIWads().First(x => x.FileName == "PLUTONIA.WAD");
            var sourceport = adapter.GetSourcePorts().First(x => x.Name == "zdoom.exe");

            handler.CalculateAdditionalFiles(iwad, sourceport);
            var gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(5, gameFiles.Count);
            Assert.IsNotNull(gameFiles.First(x => x.FileName == "IWADMOD1.WAD"));
            Assert.IsNotNull(gameFiles.First(x => x.FileName == "PORTMOD1.WAD"));

            Assert.IsTrue(handler.IsIWadFile(gameFiles.First(x => x.FileName == "IWADMOD1.WAD")));
            Assert.IsTrue(handler.IsSourcePortFile(gameFiles.First(x => x.FileName == "PORTMOD1.WAD")));
        }
コード例 #8
0
 private static void SetAddFiles(IGameFile mainFile, FileLoadHandler handler, List <IGameFile> addFiles)
 {
     mainFile.SettingsFiles           = string.Join(";", addFiles.Select(x => x.FileName));
     mainFile.SettingsFilesIWAD       = string.Join(";", addFiles.Intersect(handler.GetIWadFiles()).Select(x => x.FileName));
     mainFile.SettingsFilesSourcePort = string.Join(";", addFiles.Intersect(handler.GetSourcePortFiles()).Select(x => x.FileName));
 }
コード例 #9
0
        public void TestHandlerOrder()
        {
            IDataSourceAdapter adapter = TestUtil.CreateAdapter();
            var             mainFile   = adapter.GetGameFile("COOLGAMEFILE.WAD");
            FileLoadHandler handler    = new FileLoadHandler(adapter, mainFile);

            Assert.AreEqual(3, handler.GetCurrentAdditionalFiles().Count);

            var iwad       = adapter.GetGameFileIWads().First(x => x.FileName == "PLUTONIA.WAD");
            var sourceport = adapter.GetSourcePorts().First(x => x.Name == "zdoom.exe");

            handler.CalculateAdditionalFiles(iwad, sourceport);
            var gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(5, gameFiles.Count);
            Assert.AreEqual("COOLGAMEFILE.WAD", gameFiles[0].FileName);
            Assert.AreEqual("SUPERCOOLMOD.WAD", gameFiles[1].FileName);
            Assert.AreEqual("MOD2.WAD", gameFiles[2].FileName);
            Assert.AreEqual("IWADMOD1.WAD", gameFiles[3].FileName);
            Assert.AreEqual("PORTMOD1.WAD", gameFiles[4].FileName);

            //user changed the order - the files should be returned in the order the user set
            string newOrder = "IWADMOD1.WAD;SUPERCOOLMOD.WAD;PORTMOD1.WAD;MOD2.WAD";

            mainFile.SettingsFiles = newOrder;
            handler = new FileLoadHandler(adapter, mainFile);

            handler.CalculateAdditionalFiles(iwad, sourceport);
            gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(5, gameFiles.Count);
            Assert.AreEqual("COOLGAMEFILE.WAD", gameFiles[0].FileName);
            Assert.AreEqual("IWADMOD1.WAD", gameFiles[1].FileName);
            Assert.AreEqual("SUPERCOOLMOD.WAD", gameFiles[2].FileName);
            Assert.AreEqual("PORTMOD1.WAD", gameFiles[3].FileName);
            Assert.AreEqual("MOD2.WAD", gameFiles[4].FileName);

            //change source port - PORTMOD1 will be removed, PORTMOD2 should be added last
            sourceport = adapter.GetSourcePorts().First(x => x.Name == "prboom.exe");

            handler.CalculateAdditionalFiles(iwad, sourceport);
            gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(5, gameFiles.Count);
            Assert.AreEqual("COOLGAMEFILE.WAD", gameFiles[0].FileName);
            Assert.AreEqual("IWADMOD1.WAD", gameFiles[1].FileName);
            Assert.AreEqual("SUPERCOOLMOD.WAD", gameFiles[2].FileName);
            Assert.AreEqual("MOD2.WAD", gameFiles[3].FileName);
            Assert.AreEqual("PORTMOD2.WAD", gameFiles[4].FileName);

            //change iwad - IWADMOD1 should be removed
            iwad = adapter.GetGameFileIWads().First(x => x.FileName == "DOOM2.WAD");

            handler.CalculateAdditionalFiles(iwad, sourceport);
            gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(4, gameFiles.Count);
            Assert.AreEqual("COOLGAMEFILE.WAD", gameFiles[0].FileName);
            Assert.AreEqual("SUPERCOOLMOD.WAD", gameFiles[1].FileName);
            Assert.AreEqual("MOD2.WAD", gameFiles[2].FileName);
            Assert.AreEqual("PORTMOD2.WAD", gameFiles[3].FileName);

            //set source port back - order has chaged, PORTMOD1 will be last
            sourceport = adapter.GetSourcePorts().First(x => x.Name == "zdoom.exe");

            handler.CalculateAdditionalFiles(iwad, sourceport);
            gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(4, gameFiles.Count);
            Assert.AreEqual("COOLGAMEFILE.WAD", gameFiles[0].FileName);
            Assert.AreEqual("SUPERCOOLMOD.WAD", gameFiles[1].FileName);
            Assert.AreEqual("MOD2.WAD", gameFiles[2].FileName);
            Assert.AreEqual("PORTMOD1.WAD", gameFiles[3].FileName);

            //RESET - should load original files, but with new order specified in the gamefile
            handler.Reset();

            handler.CalculateAdditionalFiles(iwad, sourceport);
            gameFiles = handler.GetCurrentAdditionalFiles();

            Assert.AreEqual(5, gameFiles.Count);
            Assert.AreEqual("COOLGAMEFILE.WAD", gameFiles[0].FileName);
            Assert.AreEqual("IWADMOD1.WAD", gameFiles[1].FileName);
            Assert.AreEqual("SUPERCOOLMOD.WAD", gameFiles[2].FileName);
            Assert.AreEqual("PORTMOD1.WAD", gameFiles[3].FileName);
            Assert.AreEqual("MOD2.WAD", gameFiles[4].FileName);
        }