예제 #1
0
        private void HandleDemoChange()
        {
            if (chkDemo.Checked && cmbDemo.SelectedItem != null)
            {
                var file   = cmbDemo.SelectedItem as IFileData;
                var parser = DemoUtil.GetDemoParser(Path.Combine(m_appConfig.DemoDirectory.GetFullPath(), file.FileName));

                if (parser != null)
                {
                    m_handler.Reset();
                    SetAdditionalFiles(true);

                    string[]         requiredFiles = parser.GetRequiredFiles();
                    List <string>    unavailable   = new List <string>();
                    List <IGameFile> iwads         = new List <IGameFile>();
                    List <IGameFile> gameFiles     = GetGameFiles(requiredFiles, unavailable, iwads);
                    ctrlFiles.SetDataSource(gameFiles);
                    if (iwads.Count > 0)
                    {
                        SelectedIWad = iwads.First();
                    }

                    if (unavailable.Count > 0)
                    {
                        TextBoxForm form = new TextBoxForm(true, MessageBoxButtons.OK)
                        {
                            StartPosition = FormStartPosition.CenterParent,
                            Text          = "Not Found",
                            HeaderText    = "The following required files were not found:",
                            DisplayText   = string.Join(Environment.NewLine, unavailable.ToArray())
                        };
                        form.ShowDialog(this);
                    }

                    m_demoChangedAdditionalFiles = true;
                    ResetSpecificFilesSelections(ctrlFiles.GetFiles().Cast <IGameFile>().ToArray()); //don't use the handler in this case, we are overriding it
                }
            }
            else
            {
                m_demoChangedAdditionalFiles = false;
            }
        }
예제 #2
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);
        }
예제 #3
0
 private void ResetAdditionalFiles()
 {
     m_handler.Reset();
     InitializeComplete();
 }