Esempio n. 1
0
        // Returns a list of the resources
        public DataLocationList GetResources()
        {
            DataLocationList list = new DataLocationList();

            // Go for all items
            for (int i = 0; i < resourceitems.Items.Count; i++)
            {
                // Item not grayed?
                if (resourceitems.Items[i].ForeColor == SystemColors.WindowText)
                {
                    // Add item to list
                    list.Add((DataLocation)resourceitems.Items[i].Tag);
                }
            }

            // Return result
            return(list);
        }
Esempio n. 2
0
        //mxd
        private static void AddResourcesFrom(string path, DataLocationType type, DataLocationList addto)
        {
            string pattern;

            switch (type)
            {
            case DataLocationType.RESOURCE_ART: pattern = "*.art"; break;

            case DataLocationType.RESOURCE_GRP: pattern = "*.grp"; break;

            default: throw new NotSupportedException("Unsupported DataLocationType!");
            }

            string[] files = Directory.GetFiles(path, pattern);
            foreach (string file in files)
            {
                addto.Add(new DataLocation(type, file));
            }
        }
        private void CopySelectedResources()
        {
            // Don't do stupid things
            if (resourceitems.SelectedItems.Count == 0)
            {
                return;
            }

            copiedresources.Clear();
            foreach (ListViewItem item in resourceitems.SelectedItems)
            {
                if (item.Tag is DataLocation)
                {
                    copiedresources.Add((DataLocation)item.Tag);
                }
            }

            // Display notification
            General.Interface.DisplayStatus(StatusType.Info, copiedresources.Count + " Resource" + (copiedresources.Count > 1 ? "s" : "") + " Copied to Clipboard");
        }
Esempio n. 4
0
        // This adds a resource location and returns the index where the item was added
        internal int AddResource(DataLocation res)
        {
            // Get a fully qualified path
            res.location = Path.GetFullPath(res.location);

            // Go for all items in the list
            for (int i = 0; i < resources.Count; i++)
            {
                // Check if location is already added
                if (Path.GetFullPath(resources[i].location) == res.location)
                {
                    // Update the item in the list
                    resources[i] = res;
                    return(i);
                }
            }

            // Add to list
            resources.Add(res);
            return(resources.Count - 1);
        }
        // Returns a list of the resources
        public DataLocationList GetResources()
        {
            DataLocationList list = new DataLocationList();

            // Go for all items
            for (int i = 0; i < resourceitems.Items.Count; i++)
            {
                // Item not grayed?
                if (resourceitems.Items[i].ForeColor == SystemColors.WindowText)
                {
                    // Add item to list
                    DataLocation dl = (DataLocation)resourceitems.Items[i].Tag;
                    if (!list.Contains(dl))
                    {
                        list.Add(dl);                                        //mxd. Duplicates check
                    }
                }
            }

            // Return result
            return(list);
        }
Esempio n. 6
0
        // This takes the unconverted parameters (with placeholders) and converts it
        // to parameters with full paths, names and numbers where placeholders were put.
        // The tempfile must be the full path and filename to the PWAD file to test.
        public string ConvertParameters(string parameters, int skill, bool shortpaths)
        {
            string       outp = parameters;
            DataLocation iwadloc;
            string       p_wp = "", p_wf = "";
            string       p_ap = "", p_apq = "";
            string       p_l1 = "", p_l2 = "";
            string       p_nm = "";
            string       f    = tempwad;

            // Make short path if needed
            if (shortpaths)
            {
                f = General.GetShortFilePath(f);
            }

            // Find the first IWAD file
            if (General.Map.Data.FindFirstIWAD(out iwadloc))
            {
                // %WP and %WF result in IWAD file
                p_wp = iwadloc.location;
                p_wf = Path.GetFileName(p_wp);
                if (shortpaths)
                {
                    p_wp = General.GetShortFilePath(p_wp);
                    p_wf = General.GetShortFilePath(p_wf);
                }
            }

            // Make a list of all data locations, including map location
            DataLocation     maplocation = new DataLocation(DataLocation.RESOURCE_WAD, General.Map.FilePathName, false, false, false);
            DataLocationList locations   = new DataLocationList();

            locations.AddRange(General.Map.ConfigSettings.Resources);
            locations.AddRange(General.Map.Options.Resources);
            locations.Add(maplocation);

            // Go for all data locations
            foreach (DataLocation dl in locations)
            {
                // Location not the IWAD file?
                if ((dl.type != DataLocation.RESOURCE_WAD) || (dl.location != iwadloc.location))
                {
                    // Location not included?
                    if (!dl.notfortesting)
                    {
                        // Add to string of files
                        if (shortpaths)
                        {
                            p_ap  += General.GetShortFilePath(dl.location) + " ";
                            p_apq += "\"" + General.GetShortFilePath(dl.location) + "\" ";
                        }
                        else
                        {
                            p_ap  += dl.location + " ";
                            p_apq += "\"" + dl.location + "\" ";
                        }
                    }
                }
            }

            // Trim last space from resource file locations
            p_ap  = p_ap.TrimEnd(' ');
            p_apq = p_apq.TrimEnd(' ');

            // Try finding the L1 and L2 numbers from the map name
            string numstr = "";
            bool   first  = true;

            foreach (char c in General.Map.Options.CurrentName)
            {
                // Character is a number?
                if (NUMBERS.IndexOf(c) > -1)
                {
                    // Include it
                    numstr += c;
                }
                else
                {
                    // Store the number if we found one
                    if (numstr.Length > 0)
                    {
                        int num = 0;
                        int.TryParse(numstr, out num);
                        if (first)
                        {
                            p_l1 = num.ToString();
                        }
                        else
                        {
                            p_l2 = num.ToString();
                        }
                        numstr = "";
                        first  = false;
                    }
                }
            }

            // Store the number if we found one
            if (numstr.Length > 0)
            {
                int num = 0;
                int.TryParse(numstr, out num);
                if (first)
                {
                    p_l1 = num.ToString();
                }
                else
                {
                    p_l2 = num.ToString();
                }
            }

            // No monsters?
            if (!General.Settings.TestMonsters)
            {
                p_nm = "-nomonsters";
            }

            // Make sure all our placeholders are in uppercase
            outp = outp.Replace("%f", "%F");
            outp = outp.Replace("%wp", "%WP");
            outp = outp.Replace("%wf", "%WF");
            outp = outp.Replace("%wP", "%WP");
            outp = outp.Replace("%wF", "%WF");
            outp = outp.Replace("%Wp", "%WP");
            outp = outp.Replace("%Wf", "%WF");
            outp = outp.Replace("%l1", "%L1");
            outp = outp.Replace("%l2", "%L2");
            outp = outp.Replace("%l", "%L");
            outp = outp.Replace("%ap", "%AP");
            outp = outp.Replace("%aP", "%AP");
            outp = outp.Replace("%Ap", "%AP");
            outp = outp.Replace("%s", "%S");
            outp = outp.Replace("%nM", "%NM");
            outp = outp.Replace("%Nm", "%NM");
            outp = outp.Replace("%nm", "%NM");

            // Replace placeholders with actual values
            outp = outp.Replace("%F", f);
            outp = outp.Replace("%WP", p_wp);
            outp = outp.Replace("%WF", p_wf);
            outp = outp.Replace("%L1", p_l1);
            outp = outp.Replace("%L2", p_l2);
            outp = outp.Replace("%L", General.Map.Options.CurrentName);
            outp = outp.Replace("\"%AP\"", p_apq);
            outp = outp.Replace("%AP", p_ap);
            outp = outp.Replace("%S", skill.ToString());
            outp = outp.Replace("%NM", p_nm);

            // Return result
            return(outp);
        }