Beispiel #1
0
 public static void DeleteFolder(string folder)
 {
     if (!Directory.Exists(folder))
     {
         return;
     }
     foreach (string directory in DuckFile.GetDirectories(folder))
     {
         DuckFile.DeleteFolder(directory);
     }
     foreach (string file in DuckFile.GetFiles(folder))
     {
         DuckFile.Delete(file);
     }
     Directory.Delete(folder);
 }
        public void SetDirectory(string dir)
        {
            dir = Path.GetFullPath(dir);
            dir = dir.Replace('\\', '/');
            while (dir.StartsWith("/"))
            {
                dir = dir.Substring(1);
            }
            if (dir.EndsWith("/"))
            {
                dir = dir.Substring(0, dir.Length - 1);
            }
            if (dir.Length < this._rootFolder.Length)
            {
                dir = this._rootFolder;
            }
            int num1 = 0;

            this._currentDirectory = dir;
            if (this._currentDirectory != this._rootFolder)
            {
                ++num1;
            }
            if (this._save)
            {
                ++num1;
            }
            string[] directories = DuckFile.GetDirectories(this._currentDirectory);
            string[] files       = DuckFile.GetFiles(this._currentDirectory);
            int      num2        = num1 + (directories.Length + files.Length);
            float    x           = 338f;

            this._scrollBar      = false;
            this._scrollPosition = 0.0f;
            if (num2 > this._maxItems)
            {
                x = 326f;
                this._scrollBar = true;
            }
            if (this._save)
            {
                this.AddItem(new ContextMenu((IContextListener)this)
                {
                    text     = "@NEWICONTINY@New File...",
                    data     = "New File...",
                    itemSize = new Vec2(x, 16f)
                });
            }
            if (this._currentDirectory != this._rootFolder)
            {
                this.AddItem(new ContextMenu((IContextListener)this)
                {
                    text     = "@LOADICONTINY@../",
                    data     = "../",
                    itemSize = new Vec2(x, 16f)
                });
            }
            foreach (string path in directories)
            {
                string fileName = Path.GetFileName(path);
                this.AddItem(new ContextMenu((IContextListener)this)
                {
                    fancy    = true,
                    text     = "@LOADICONTINY@" + fileName,
                    data     = fileName,
                    itemSize = new Vec2(x, 16f)
                });
            }
            foreach (string path in files)
            {
                string fileName = Path.GetFileName(path);
                if (!this._selectLevels)
                {
                    if (fileName.EndsWith(this.TypeExtension()))
                    {
                        ContextMenu contextMenu = new ContextMenu((IContextListener)this)
                        {
                            fancy = true,
                            text  = fileName
                        };
                        contextMenu.text     = fileName.Substring(0, fileName.Length - 4);
                        contextMenu.data     = fileName;
                        contextMenu.itemSize = new Vec2(x, 16f);
                        this.AddItem(contextMenu);
                    }
                }
                else
                {
                    string          str1            = path.Replace('\\', '/');
                    string          str2            = str1.Substring(0, str1.Length - 4);
                    string          str3            = str2.Substring(str2.IndexOf("/levels/", StringComparison.InvariantCultureIgnoreCase) + 8);
                    ContextCheckBox contextCheckBox = new ContextCheckBox(fileName, (IContextListener)this);
                    contextCheckBox.fancy     = true;
                    contextCheckBox.path      = str3;
                    contextCheckBox.isChecked = Editor.activatedLevels.Contains(str3);
                    contextCheckBox.itemSize  = new Vec2(x, 16f);
                    this.AddItem((ContextMenu)contextCheckBox);
                }
            }
            int num3 = (int)Math.Round((double)(this._items.Count - 1 - this._maxItems) * (double)this._scrollPosition);
            int num4 = 0;

            for (int index = 0; index < this._items.Count; ++index)
            {
                if (index < num3 || index > num3 + this._maxItems)
                {
                    this._items[index].visible = false;
                }
                else
                {
                    this._items[index].visible  = true;
                    this._items[index].position = new Vec2(this._items[index].position.x, (float)((double)this.y + 3.0 + (double)num4 * ((double)this._items[index].itemSize.y + 1.0)));
                    ++num4;
                }
            }
            this.menuSize.y = this._fdHeight;
        }
 private static void SearchDirLevels(string dir, LevelLocation location)
 {
     foreach (string path in location == LevelLocation.Content ? DuckGame.Content.GetFiles(dir) : DuckFile.GetFiles(dir))
     {
         DuckGame.Content.ProcessLevel(path, location);
     }
     foreach (string dir1 in location == LevelLocation.Content ? DuckGame.Content.GetDirectories(dir) : DuckFile.GetDirectories(dir))
     {
         DuckGame.Content.SearchDirLevels(dir1, location);
     }
 }
Beispiel #4
0
 public void SetCurrentFolder(string folder)
 {
     this._currentDirectory = folder;
     HUD.CloseCorner(HUDCorner.TopRight);
     if (this._currentDirectory == this._rootDirectory)
     {
         this._selectedItem = 0;
         HUD.AddCornerControl(HUDCorner.TopRight, "@START@Done");
         HUD.AddCornerControl(HUDCorner.TopRight, "@GRAB@Delete");
     }
     else
     {
         this._selectedItem = 1;
         HUD.AddCornerControl(HUDCorner.TopRight, "@START@Done @QUACK@Back");
         HUD.AddCornerControl(HUDCorner.TopRight, "@GRAB@Delete");
     }
     this._topIndex = 0;
     this._items.Clear();
     if (this._currentDirectory != this._rootDirectory)
     {
         this.AddItem(new LSItem(0.0f, 0.0f, this, "../"));
     }
     else if (Steam.GetNumWorkshopItems() > 0)
     {
         this.AddItem(new LSItem(0.0f, 0.0f, this, "@WORKSHOP@", true));
     }
     if (folder.EndsWith(".play"))
     {
         foreach (string PATH in LSItem.GetLevelsInside(this, folder))
         {
             this.AddItem(new LSItem(0.0f, 0.0f, this, PATH));
         }
         this.PositionItems();
     }
     else if (folder == "@WORKSHOP@")
     {
         foreach (string PATH in LSItem.GetLevelsInside(this, folder))
         {
             this.AddItem(new LSItem(0.0f, 0.0f, this, PATH));
         }
         this.PositionItems();
     }
     else
     {
         string[] directories = DuckFile.GetDirectories(folder);
         string[] files       = DuckFile.GetFiles(folder);
         foreach (string PATH in directories)
         {
             this.AddItem(new LSItem(0.0f, 0.0f, this, PATH));
         }
         List <string> stringList = new List <string>();
         foreach (string str in files)
         {
             string file = str;
             if (Path.GetExtension(file) == ".lev" && this._filters.TrueForAll((Predicate <IFilterLSItems>)(a => a.Filter(file))))
             {
                 stringList.Add(file);
             }
             else if (Path.GetExtension(file) == ".play")
             {
                 this.AddItem(new LSItem(0.0f, 0.0f, this, file));
             }
         }
         foreach (string PATH in stringList)
         {
             this.AddItem(new LSItem(0.0f, 0.0f, this, PATH));
         }
         this.PositionItems();
     }
 }