예제 #1
0
        private Task ProcessChanges(Dictionary <IAbsoluteDirectoryPath, FileObjectMapping[]> dict,
                                    IAbsoluteDirectoryPath downloadPath, Uri[] hosts, StatusRepo status,
                                    ProgressContainer progress)
        {
            var files = PrepareFiles(dict, downloadPath, hosts, status, progress);

            return(Process(files, downloadPath, hosts, status.CancelToken, SyncEvilGlobal.Limiter()));
        }
예제 #2
0
        public async Task DownloadPackages(Dictionary <IAbsoluteDirectoryPath, FileObjectMapping[]> dict,
                                           IAbsoluteDirectoryPath downloadPath, Uri[] hosts, StatusRepo status, ProgressLeaf cleanup,
                                           ProgressContainer progress)
        {
            await ProcessChanges(dict, downloadPath, hosts, status, progress).ConfigureAwait(false);

            // find all files that are too many, and delete them
            if (cleanup != null)
            {
                PerformCleanup(dict, cleanup);
            }
        }
예제 #3
0
        public static PackageProgress SetupSynqProgress(string title = "Network mods")
        {
            var packageFetching       = new ProgressLeaf("Preparing");
            var networkModsProcessing = new ProgressContainer("Downloading", 9);
            var cleanup = new ProgressLeaf("Cleaning");

            return(new PackageProgress {
                PackageFetching = packageFetching,
                Processing = networkModsProcessing,
                Cleanup = cleanup
            });
        }
예제 #4
0
    public void InitProfiles(ProgressContainer container)
    {
        DestroyAllTabs();

        /*
         *      GameObject newprofile = Instantiate(m_profilePrefab);
         *      ProfileButtonController script = (ProfileButtonController)newprofile.GetComponent (typeof(ProfileButtonController));
         *      script.SetButtonText("新进度", true);
         *      //script.AddBook("Default");
         *      newprofile.transform.SetParent(gameObject.transform, false);
         */
        container.AccessProfiles(AddProfile);
    }
예제 #5
0
        private static FileInfoWithData <State>[] PrepareFiles(
            Dictionary <IAbsoluteDirectoryPath, FileObjectMapping[]> dict, IAbsoluteDirectoryPath downloadPath,
            Uri[] hosts,
            StatusRepo status, ProgressContainer component)
        {
            var map = new Dictionary <string, List <IAbsoluteFilePath> >();

            foreach (var a in dict)
            {
                foreach (var v in a.Value)
                {
                    var fullPath = a.Key.GetChildFileWithName(v.FilePath);
                    if (map.ContainsKey(v.Checksum))
                    {
                        map[v.Checksum].Add(fullPath);
                    }
                    else
                    {
                        map[v.Checksum] = new List <IAbsoluteFilePath> {
                            fullPath
                        }
                    };
                }
            }

            return(map.Select(x => {
                var progressComponent = new ProgressComponent(x.Key);
                component.AddComponents(progressComponent);
                return new FileInfoWithData <State>(
                    new DownloadInfo(GetRemotePath(x.Key),
                                     downloadPath.GetChildFileWithName(SplitObjectName(x.Key)), hosts),
                    x.Value.ToArray(),
                    new State {
                    Checksum = x.Key,
                    Progress = new Progress(progressComponent)
                })
                {
                    CancelToken = status.CancelToken
                };
            }).OrderByDescending(x => Tools.FileUtil.SizePrediction(x.Destinations.First().FileName)).ToArray());
        }

        Dictionary <IAbsoluteDirectoryPath, FileObjectMapping[]> TransformPackages(IEnumerable <Package> p)
        => p.ToDictionary(x => x.WorkingPath,
                          x => x.MetaData.Files.Select(f => new FileObjectMapping(f.Key, f.Value)).ToArray());
예제 #6
0
        protected override void LoadComplete()
        {
            base.LoadComplete();
            game.LoadComponentSingleFile(progress = new ProgressContainer
            {
                Depth    = -1,
                Position = new Vector2(192, 614),
                Width    = 1536,
            }, Add);

            game.LoadComponentSingleFile(triangles = new Triangles {
                Velocity = 2.5f
            }, Add);
            game.LoadComponentSingleFile(coverContainer = new CoverContainer()
            {
                Position = new Vector2(192, 140),
                Size     = new Vector2(350),
            }, Add);
            game.LoadComponentSingleFile(new TitleContainer(Anchor.BottomLeft)
            {
                Position      = new Vector2(550, 140),
                TextSize      = 100,
                Font          = "Exo2.0-Bold",
                PreferredText = MetadataTypes.TitleUnicode,
                Width         = 1176,
            }, Add);
            game.LoadComponentSingleFile(new TitleContainer(Anchor.TopLeft)
            {
                Position        = new Vector2(550, 345),
                TextSize        = 70,
                Font            = "Exo2.0-Medium",
                PreferredText   = MetadataTypes.ArtistUnicode,
                Width           = 1176,
                Colour          = new Color4(200, 200, 200, 255),
                TransitionDelay = 75,
            }, Add);
            game.LoadComponentSingleFile(new Visualisation
            {
                Position = new Vector2(192, 614),
                Size     = new Vector2(1536, 460),
            }, Add);
            game.LoadComponentSingleFile(playlist = new PlaylistContainer(), Add);
        }
예제 #7
0
    public void Load(string rootpath)
    {
        string dir = ProgressContainer.ProgressDirectory(rootpath);

        Directory.CreateDirectory(dir);
        string fullpath = ProgressContainer.FullPath(rootpath, m_Id);

        if (File.Exists(fullpath))
        {
            using (BinaryReader file = new BinaryReader(File.Open(fullpath, FileMode.Open)))
            {
                int version = file.ReadInt32();
                if (version >= 1)
                {
                    int booknum = file.ReadInt32();
                    for (int i = 0; i < booknum; i++)
                    {
                        string book = file.ReadString();
                        if (!m_books.Exists(x => x == book))
                        {
                            m_books.Add(book);
                        }
                    }
                }
                int count = file.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    Record record = new Record();
                    record.Load(file, version);
                    record.ProcessRecord(new Record.ProcessRecordEntry(CountOneEntry));
                    m_wordSet.Add(record.m_word, record);
                }
            }
        }

        foreach (string book in m_books)
        {
            BookDict dict = new BookDict(rootpath, book);
            dict.ReadBook(this);
            dict.SaveBook();
        }
        ReOrganize();
    }
예제 #8
0
    public void Save(string rootpath)
    {
        string dir = ProgressContainer.ProgressDirectory(rootpath);

        Directory.CreateDirectory(dir);
        string fullpath = ProgressContainer.FullPath(rootpath, m_Id);

        using (BinaryWriter file = new BinaryWriter(File.Open(fullpath, FileMode.OpenOrCreate)))
        {
            file.Write(m_version);
            file.Write(m_books.Count);
            foreach (string book in m_books)
            {
                file.Write(book);
            }

            file.Write(m_wordSet.Count);
            foreach (KeyValuePair <string, Record> entry in m_wordSet)
            {
                Record record = entry.Value;
                record.Save(file);
            }
        }
    }
예제 #9
0
 public Main()
 {
     instance            = this;
     m_availableProgress = new ProgressContainer();
     m_panelRef          = new GameObject[4];
 }
예제 #10
0
 public Task DownloadPackages(Package[] p,
                              IAbsoluteDirectoryPath downloadPath, Uri[] hosts, StatusRepo status, ProgressLeaf cleanup,
                              ProgressContainer progress)
 => DownloadPackages(TransformPackages(p), downloadPath, hosts, status, cleanup, progress);