Exemple #1
0
        /// <summary>
        /// Gets the OrbitItems from this item
        /// </summary>
        /// <returns>An Array of OrbitItems</returns>
        public override OrbitItem[] GetItems()
        {
            // bail out if dir no longer exists
            if (!System.IO.Directory.Exists(ItemPath))
            {
                return(null);
            }

            try
            {
                LoadedPercentage = 0.0f;
                // Get directory list
                string[] Dirs = System.IO.Directory.GetDirectories(ItemPath);
                int      i    = 0;

                // find out how many of those directories are items
                int ItemQuantity = 0;
                while (i < Dirs.Length)
                {
                    if (System.IO.File.Exists(System.IO.Path.Combine(Dirs[i], "item.ini")))
                    {
                        ItemQuantity++;
                    }
                    i++;
                }
                // if there are no items, create an empty item
                if (i == 0)
                {
                    LoadedPercentage = 0;
                    return(new OrbitItem[] { new EmptyItem(display) });
                }

                // allocate space
                OrbitItem[] ItemRegistry = new OrbitItem[ItemQuantity];

                // Load item if there's an item configuration
                i = 0;
                int s = 0;
                while (i < Dirs.Length)
                {
                    if (System.IO.File.Exists(Dirs[i] + "\\item.ini"))
                    {
                        // if has an ini
                        // load the item
                        ItemRegistry[i - s] = OrbitItemLoader.FromIni(display, System.IO.Path.Combine(Dirs[i], "item.ini"));
                        // set the parent name
                        if (ItemRegistry[i - s] != null)
                        {
                            ItemRegistry[i - s].Parent = this.Name;
                            ItemRegistry[i - s].Line   = 0;
                        }
                    }
                    else
                    {
                        // if not, take note that yet another index is NOT an item
                        s++;
                    }
                    LoadedPercentage = (float)i / Dirs.Length;
                    OnPaint();
                    i++;
                }

                LoadedPercentage = 0;

                // return the just loaded array
                return(ItemRegistry);
            }
            catch (Exception)
            {
                // return null if failed
                LoadedPercentage = 0;
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Loads the first loop
        /// </summary>
        /// <param name="Device">Direct3D Device to load the resources into</param>
        /// <param name="Path">Path to the INI file to load this item from</param>
        /// <returns>An OrbitItem object corresponding to the root loop</returns>
        public static OrbitItem[] LoadOrbitFolder(Device Device, string Path)
        {
            // bail out if dir no longer exists
            if (!System.IO.Directory.Exists(Path))
            {
                return(null);
            }

            try
            {
                // Get directory list
                string[] Dirs = System.IO.Directory.GetDirectories(Path);
                int      i    = 0;

                // find out how many of those directories are items
                int ItemQuantity = 0;
                while (i < Dirs.Length)
                {
                    if (System.IO.File.Exists(System.IO.Path.Combine(Dirs[i], "item.ini")))
                    {
                        ItemQuantity++;
                    }
                    i++;
                }
                // if there are no items, create an empty item
                if (i == 0)
                {
                    return(null);
                }

                // allocate space
                OrbitItem[] ItemRegistry = new OrbitItem[ItemQuantity];

                // Load item if there's an item configuration
                i = 0;
                int s = 0;
                while (i < Dirs.Length)
                {
                    if (System.IO.File.Exists(Dirs[i] + "\\item.ini"))
                    {
                        // if has an ini
                        // load the item
                        ItemRegistry[i - s] = OrbitItemLoader.FromIni(Device, System.IO.Path.Combine(Dirs[i], "item.ini"));
                        // set the parent name
                        if (ItemRegistry[i - s] != null)
                        {
                            ItemRegistry[i - s].Parent = "Orbit";
                            ItemRegistry[i - s].Line   = 0;
                        }
                    }
                    else
                    {
                        // if not, take note that yet another index is NOT an item
                        s++;
                    }
                    i++;
                }

                // return the just loaded array
                return(ItemRegistry);
            }
            catch (Exception)
            {
                // return null if failed
                return(null);
            }
        }