Beispiel #1
0
        public CommandLine(SourcePort sourcePort, Iwad iwad, List <Pwad> pwads)
        {
            SourcePort = sourcePort;
            Iwad       = iwad;
            Pwads      = pwads;
            var launchGame = new ProcessStartInfo();

            launchGame.WorkingDirectory = sourcePort.FileFolder;
            launchGame.FileName         = sourcePort.FileLocation;
            launchGame.Arguments       += "-iwad \"" + iwad.FileLocation + "\"";
            //if (!String.IsNullOrEmpty(sourcePort.ConfigFileLocation))
            //{
            //    launchGame.Arguments += " -config \"" + sourcePort.ConfigFileLocation + "\"";
            //}

            if (Pwads.Any()) // PWADs are optional.  If launched without PWADs, the command line doesn't need the -file argument.
            {
                command += " -file ";
                foreach (Pwad p in Pwads)
                {
                    command += "\"" + p.FileLocation + "\" "; // encloses file path and name in quotes
                }
                command = command.Remove(command.Length - 1); //just getting rid of that trailing space at the end
                launchGame.Arguments += command;
            }
            Debug.WriteLine(launchGame.Arguments);
            Process.Start(launchGame);
        }
Beispiel #2
0
        static public bool CheckIfIwadExistsByFileLocation(Iwad iwad)
        {
            var    optionsBuilder   = new DbContextOptionsBuilder <Context>();
            string databaseLocation = "Data Source=";

            databaseLocation += System.AppDomain.CurrentDomain.BaseDirectory;
            databaseLocation += "malo.db";
            optionsBuilder.UseSqlite(databaseLocation);
            using (Context context = new Context(optionsBuilder.Options))
            {
                return(context.Iwads.Any <Iwad>(i => i.FileLocation == iwad.FileLocation)); // returns true if file location match found; false if not.
            }
        }
Beispiel #3
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     if (CheckValidity())
     {
         tbFileLocation.Text     = iwadInProgress.FileFolder;
         iwadInProgress.FileName = iwadInProgress.FileLocation.Substring(iwadInProgress.FileFolder.Length);
         tbFileName.Text         = iwadInProgress.FileName;
         tbIwadName.Text         = Iwad.LookupIwadByFilename(iwadInProgress.FileName);
     }
     else
     {
         //handle invalid file info
     }
 }
Beispiel #4
0
        static public bool DeleteIwadByName(Iwad iwad)
        {
            var    optionsBuilder   = new DbContextOptionsBuilder <Context>();
            string databaseLocation = "Data Source=";

            databaseLocation += System.AppDomain.CurrentDomain.BaseDirectory;
            databaseLocation += "malo.db";
            optionsBuilder.UseSqlite(databaseLocation);
            using (Context context = new Context(optionsBuilder.Options))
            {
                try
                {
                    var iwadToUpdate = context.Iwads.First(i => i.FileName == iwad.FileName);
                    context.Iwads.Remove(iwadToUpdate);
                    context.SaveChanges();
                }
                catch
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #5
0
        static public bool AddNewIwad(Iwad iwad)
        {
            iwad.IsConfigured = true;

            var    optionsBuilder   = new DbContextOptionsBuilder <Context>();
            string databaseLocation = "Data Source=";

            databaseLocation += System.AppDomain.CurrentDomain.BaseDirectory;
            databaseLocation += "malo.db";
            optionsBuilder.UseSqlite(databaseLocation);
            using (Context context = new Context(optionsBuilder.Options))
            {
                try
                {
                    context.Iwads.Add(iwad);
                    context.SaveChanges();
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #6
0
        public IwadOptions(Iwad iwad)
        {
            iwadInProgress = iwad;

            InitializeComponent();
        }
Beispiel #7
0
        public ModifyIwad(Iwad iwad)
        {
            iwadInProgress = iwad;

            InitializeComponent();
        }
Beispiel #8
0
        public EstablishDummyData()
        {
            var    optionsBuilder   = new DbContextOptionsBuilder <Context>();
            string databaseLocation = "Data Source=";

            databaseLocation += System.AppDomain.CurrentDomain.BaseDirectory;
            databaseLocation += "malo.db";
            Debug.WriteLine(databaseLocation);
            optionsBuilder.UseSqlite(databaseLocation);
            using (Context context = new Context(optionsBuilder.Options))
            {
                //test data goes here

                Pwad scythe = new Pwad
                {
                    FileName     = "scythe.zip",
                    Name         = "Scythe",
                    Description  = "Scythe by Erik Alm",
                    FileLocation = "C:\\DOOM\\scythe.wad",
                    IsALevelPack = true,
                    IsAMod       = false
                };
                context.Pwads.Add(scythe);
                Pwad tenSector = new Pwad
                {
                    FileName     = "10sector.zip",
                    Name         = "10 Sectors",
                    Description  = "Ten Sectors",
                    FileLocation = "C:\\DOOM\\10sector.zip",
                    IsALevelPack = true,
                    IsAMod       = false
                };
                context.Pwads.Add(tenSector);

                Iwad doom2Iwad = new Iwad
                {
                    FileName        = "doom2.wad",
                    Name            = "Doom II",
                    DescriptiveName = "Doom II v1.9",
                    FileLocation    = "C:\\DOOM\\doom2.wad"
                };
                context.Iwads.Add(doom2Iwad);

                SourcePort crispyDoom = new SourcePort
                {
                    FileName             = "crispy-doom.exe",
                    Name                 = "Crispy Doom",
                    FileLocation         = "C:\\DOOM\\crispy-doom.exe",
                    ConfigFileLocation   = "C:\\DOOM\\crispy-doom.cfg",
                    HasCompLevel         = false,
                    MaximumCompatibility = Compatibility.LimitRemoving
                };
                context.SourcePorts.Add(crispyDoom);

                context.SaveChanges();

                var readwad = context.Pwads.ToList();
                foreach (Pwad p in readwad)
                {
                    Debug.WriteLine($"PWAD PK ID number {p.Id}");
                    Debug.WriteLine($"Name: {p.Name}");
                    Debug.WriteLine($"Description: {p.Description}");
                    Debug.WriteLine("---");
                }

                new CommandLine(crispyDoom, doom2Iwad, new List <Pwad> {
                    scythe
                });
            }
        }