Ejemplo n.º 1
0
 internal void Populate()
 {
     if (SynchronizationContext.Current == null)
     {
         SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
     }
     Task.Factory.StartNew(
         delegate
     {
         var modSources = ModLoader.FindModSources();
         var modFiles   = ModLoader.FindMods();
         return(Tuple.Create(modSources, modFiles));
     })
     .ContinueWith(task =>
     {
         var modSources = task.Result.Item1;
         var modFiles   = task.Result.Item2;
         foreach (string sourcePath in modSources)
         {
             var builtMod = modFiles.SingleOrDefault(m => m.Name == Path.GetFileName(sourcePath));
             items.Add(new UIModSourceItem(sourcePath, builtMod));
         }
         updateNeeded = true;
     }, TaskScheduler.FromCurrentSynchronizationContext());
 }
Ejemplo n.º 2
0
 public override void OnActivate()
 {
     modList.Clear();
     string[] mods = ModLoader.FindModSources();
     foreach (string mod in mods)
     {
         modList.Add(new UIModSourceItem(mod));
     }
 }
Ejemplo n.º 3
0
 public override void OnActivate()
 {
     modList.Clear();
     string[]   mods     = ModLoader.FindModSources();
     TmodFile[] modFiles = ModLoader.FindMods();
     foreach (string mod in mods)
     {
         bool publishable = false;
         foreach (TmodFile file in modFiles)
         {
             if (Path.GetFileNameWithoutExtension(file.Name).Equals(Path.GetFileName(mod)))
             {
                 publishable = true;
                 break;
             }
         }
         modList.Add(new UIModSourceItem(mod, publishable));
     }
 }
Ejemplo n.º 4
0
        internal void Populate()
        {
            loading = true;
            if (SynchronizationContext.Current == null)
            {
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            }
            Task.Factory
            .StartNew(delegate
            {
                var mods     = ModLoader.FindModSources();
                var modFiles = ModLoader.FindMods();
                return(new Tuple <string[], TmodFile[]>(mods, modFiles));
            })
            .ContinueWith(task =>
            {
                string[] mods       = task.Result.Item1;
                TmodFile[] modFiles = task.Result.Item2;
                foreach (string mod in mods)
                {
                    bool publishable       = false;
                    DateTime lastBuildTime = new DateTime();

                    foreach (TmodFile file in modFiles)
                    {
                        var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.path);
                        if (fileNameWithoutExtension != null && fileNameWithoutExtension.Equals(Path.GetFileName(mod)))
                        {
                            lastBuildTime = File.GetLastWriteTime(file.path);
                            publishable   = true;
                            break;
                        }
                    }
                    modList.Add(new UIModSourceItem(mod, publishable, lastBuildTime));
                }
                if (uIPanel.HasChild(uiLoader))
                {
                    uIPanel.RemoveChild(uiLoader);
                }
                loading = false;
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }