예제 #1
0
        public static void DownloadAllCloudData()
        {
            bool cloudOnly = MonoMain.cloudOnly;
            bool cloud     = Options.Data.cloud;

            MonoMain.cloudOnly = true;
            Options.Data.cloud = true;
            foreach (string file in DuckFile.GetFiles(DuckFile.profileDirectory, "*.*", SearchOption.AllDirectories))
            {
                DuckFile.CreatePath(file);
                DuckFile.PrepareToLoadCloudFile(file);
            }
            foreach (string file in DuckFile.GetFiles(DuckFile.levelDirectory, "*.*", SearchOption.AllDirectories))
            {
                DuckFile.CreatePath(file);
                DuckFile.PrepareToLoadCloudFile(file);
            }
            foreach (string file in DuckFile.GetFiles(DuckFile.optionsDirectory, "*.*", SearchOption.AllDirectories))
            {
                DuckFile.CreatePath(file);
                DuckFile.PrepareToLoadCloudFile(file);
            }
            MonoMain.cloudOnly = cloudOnly;
            Options.Data.cloud = cloud;
        }
예제 #2
0
 public static string[] GetFiles(string path, string filter, SearchOption option = SearchOption.TopDirectoryOnly)
 {
     DuckFile._getFilesOption = option;
     string[] files = DuckFile.GetFiles(path, filter);
     DuckFile._getFilesOption = SearchOption.TopDirectoryOnly;
     return(files);
 }
예제 #3
0
 public static void DeleteAllSaveData()
 {
     foreach (string allPath in DuckFile._allPaths)
     {
         foreach (string file in DuckFile.GetFiles(DuckFile.saveDirectory + allPath))
         {
             DuckFile.Delete(file);
         }
     }
 }
예제 #4
0
 public static void Initialize()
 {
     foreach (string level1 in Content.GetLevels("challenge", LevelLocation.Content))
     {
         LevelData level2 = Content.GetLevel(level1);
         string    guid   = level2.metaData.guid;
         foreach (BinaryClassChunk node in level2.objects.objects)
         {
             string property = node.GetProperty <string>("type");
             if (property != null)
             {
                 if (property.Contains("DuckGame.ChallengeMode,"))
                 {
                     try
                     {
                         if (Thing.LoadThing(node, false) is ChallengeMode challengeMode)
                         {
                             challengeMode.challenge.fileName = level1;
                             challengeMode.challenge.levelID  = guid;
                             challengeMode.challenge.preview  = level2.previewData.preview;
                             if (challengeMode.challenge.trophies[5].goodies == -1 && challengeMode.challenge.trophies[5].targets == -1)
                             {
                                 int timeRequirement = challengeMode.challenge.trophies[5].timeRequirement;
                             }
                             Challenges._challenges.Add(level2.metaData.guid, challengeMode.challenge);
                         }
                     }
                     catch (Exception ex)
                     {
                     }
                 }
             }
         }
     }
     foreach (string file in DuckFile.GetFiles(DuckFile.challengeDirectory))
     {
         XDocument xdocument = DuckFile.LoadXDocument(file);
         if (xdocument != null)
         {
             string   withoutExtension = Path.GetFileNameWithoutExtension(file);
             XElement xelement         = xdocument.Element((XName)"Data");
             if (xelement != null)
             {
                 foreach (XElement element1 in xelement.Elements((XName)"challengeSaveData"))
                 {
                     ChallengeSaveData element2 = new ChallengeSaveData();
                     element2.LegacyDeserialize(element1);
                     element2.challenge = withoutExtension;
                     Challenges._saveData.Add(withoutExtension, element2);
                 }
             }
         }
     }
 }
예제 #5
0
 public static List <string> GetFilesInternal <T>(string path, List <string> files, string ext)
 {
     foreach (string file in DuckFile.GetFiles(path, ext))
     {
         files.Add(file);
     }
     foreach (string directory in DuckGame.Content.GetDirectories(path))
     {
         DuckGame.Content.GetFilesInternal <T>(directory, files, ext);
     }
     return(files);
 }
예제 #6
0
 protected override void OnStart()
 {
     Options.Initialize();
     Global.Initialize();
     Teams.Initialize();
     DuckRig.Initialize();
     Unlocks.Initialize();
     ConnectionStatusUI.Initialize();
     Unlocks.CalculateTreeValues();
     Profiles.Initialize();
     Dialogue.Initialize();
     DuckTitle.Initialize();
     News.Initialize();
     Script.Initialize();
     DuckNews.Initialize();
     VirtualBackground.InitializeBack();
     AmmoType.InitializeTypes();
     DestroyType.InitializeTypes();
     VirtualTransition.Initialize();
     Unlockables.Initialize();
     UIInviteMenu.Initialize();
     LevelGenerator.Initialize();
     DuckFile.CompleteSteamCloudInitializate();
     Main.ResetMatchStuff();
     foreach (Profile profile in Profiles.active)
     {
         profile.RecordPreviousStats();
     }
     Main.editor = new DuckGameEditor();
     foreach (string file in DuckFile.GetFiles(Directory.GetCurrentDirectory(), "*.hat"))
     {
         Team t = Team.Deserialize(file);
         if (t != null)
         {
             Teams.AddExtraTeam(t);
         }
     }
     Main.SetPurchaseDetails(9.99f, "USD");
     if (Main.connectID != 0UL)
     {
         NCSteam.inviteLobbyID = Main.connectID;
         Level.current         = (Level) new JoinServer(Main.connectID);
     }
     else
     {
         Level.current = !MonoMain.noIntro ? (Level) new BIOSScreen() : (!MonoMain.startInEditor ? (Level) new TitleScreen() : (Level)Main.editor);
     }
     this._font = new BitmapFont("biosFont", 8);
     Highlights.StartRound();
 }
예제 #7
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;
        }
예제 #9
0
 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);
     }
 }
예제 #10
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();
     }
 }