Ejemplo n.º 1
0
        public WorldGeneratorDialog(InstanceManager instanceManager)
        {
            _instanceManager = instanceManager;
            InitializeComponent();
            _loadLocalization();
            var scenarios = MyLocalCache.GetAvailableWorldInfos(Path.Combine(MyFileSystem.ContentPath, "CustomWorlds"));

            foreach (var tup in scenarios)
            {
                string      directory     = tup.Item1;
                MyWorldInfo info          = tup.Item2;
                string      localizedName = MyTexts.GetString(MyStringId.GetOrCompute(info.SessionName));
                var         checkpoint    = MyLocalCache.LoadCheckpoint(directory, out _);
                checkpoint.OnlineMode = MyOnlineModeEnum.PUBLIC;
                _checkpoints.Add(new PremadeCheckpointItem {
                    Name = localizedName, Icon = Path.Combine(directory, "thumb.jpg"), Path = directory, Checkpoint = checkpoint
                });
            }

            /*
             * var premadeCheckpoints = Directory.EnumerateDirectories(Path.Combine("Content", "CustomWorlds"));
             * foreach (var path in premadeCheckpoints)
             * {
             *  var thumbPath = Path.GetFullPath(Directory.EnumerateFiles(path).First(x => x.Contains("thumb")));
             *
             *  _checkpoints.Add(new PremadeCheckpointItem
             *  {
             *      Path = path,
             *      Icon = thumbPath,
             *      Name = Path.GetFileName(path)
             *  });
             * }*/
            PremadeCheckpoints.ItemsSource = _checkpoints;
        }
Ejemplo n.º 2
0
        public static void DoReload()
        {
            GC.Collect(2, GCCollectionMode.Forced);
            MySandboxGame.Log.WriteLine(String.Format("RELOAD TEST, Menu GC: {0} B", GC.GetTotalMemory(false).ToString("##,#")));
            MySandboxGame.Log.WriteLine(String.Format("RELOAD TEST, Menu WS: {0} B", Process.GetCurrentProcess().PrivateMemorySize64.ToString("##,#")));
            var session = MyLocalCache.GetAvailableWorldInfos().OrderByDescending(s => s.Item2.LastLoadTime).FirstOrDefault();

            if (session != null)
            {
                MySessionLoader.LoadSingleplayerSession(session.Item1);
            }
        }
Ejemplo n.º 3
0
        private void LoadListAsync(bool missions, bool appendBattleMaps)
        {
            if (missions)
            {
                AvailableSaves = MyLocalCache.GetAvailableMissionInfos();
            }
            else
            {
                AvailableSaves = MyLocalCache.GetAvailableWorldInfos();
                if (appendBattleMaps)
                {
                    var availableBattles = MyLocalCache.GetAvailableBattlesInfos();
                    AvailableSaves.AddList(availableBattles);
                }
            }
            ContainsCorruptedWorlds = false;

            StringBuilder corruptedWorlds = new StringBuilder();

            foreach (var pair in AvailableSaves)
            {
                Debug.Assert(pair != null);
                if (pair.Item2 == null)
                {
                    corruptedWorlds.Append(Path.GetFileNameWithoutExtension(pair.Item1)).Append("\n");
                    ContainsCorruptedWorlds = true;
                }
            }

            if (ContainsCorruptedWorlds)
            {
                AvailableSaves.RemoveAll(x => x == null || x.Item2 == null);
                MyLog.Default.WriteLine("Corrupted worlds: ");
                MyLog.Default.WriteLine(corruptedWorlds.ToString());
            }

            if (AvailableSaves.Count != 0)
            {
                AvailableSaves.Sort((a, b) => b.Item2.LastLoadTime.CompareTo(a.Item2.LastLoadTime));
            }

            VerifyUniqueWorldID(AvailableSaves);
        }
Ejemplo n.º 4
0
        private void LoadListAsync()
        {
            // Default saves
            List <Tuple <string, MyWorldInfo> > availableSaves = MyLocalCache.GetAvailableWorldInfos();

            // Battle original maps
            var availableBattles = GetAvailableOfficialBattlesInfos();

            availableSaves.AddList(availableBattles);

            ContainsCorruptedWorlds = false;

            StringBuilder corruptedWorlds = new StringBuilder();

            foreach (var pair in availableSaves)
            {
                Debug.Assert(pair != null);
                if (pair.Item2 == null)
                {
                    corruptedWorlds.Append(Path.GetFileNameWithoutExtension(pair.Item1)).Append("\n");
                    ContainsCorruptedWorlds = true;
                }
            }

            if (ContainsCorruptedWorlds)
            {
                availableSaves.RemoveAll(x => x == null || x.Item2 == null);
                if (MyLog.Default != null)
                {
                    MyLog.Default.WriteLine("Corrupted worlds: ");
                    MyLog.Default.WriteLine(corruptedWorlds.ToString());
                }
            }

            // Prepare battle maps
            AddBattleMaps(availableSaves, AvailableBattleMaps, m_officialBattlesPath, m_workshopBattlesPath);
        }
Ejemplo n.º 5
0
 protected override List <Tuple <string, MyWorldInfo> > GetAvailableSaves()
 {
     return(MyLocalCache.GetAvailableWorldInfos(CustomPath));
 }
    public static void DoReload()
    {
        GC.Collect(2, GCCollectionMode.Forced);
        MySandboxGame.Log.WriteLine(string.Format("RELOAD TEST, Menu GC: {0} B", GC.GetTotalMemory(forceFullCollection: false).ToString("##,#")));
        MySandboxGame.Log.WriteLine(string.Format("RELOAD TEST, Menu WS: {0} B", Process.GetCurrentProcess().PrivateMemorySize64.ToString("##,#")));
        Tuple <string, MyWorldInfo> tuple = Enumerable.FirstOrDefault(Enumerable.OrderByDescending(MyLocalCache.GetAvailableWorldInfos(), (Tuple <string, MyWorldInfo> s) => s.Item2.LastSaveTime));

        if (tuple != null)
        {
            MySessionLoader.LoadSingleplayerSession(tuple.Item1);
        }
    }