private static void FinishSaving(string TargetDir, string customName, MySessionSnapshot snapshot)
        {
            if (TargetDir != null)
            {
                snapshot.SavingDir = $"{TargetDir}.new";
                snapshot.TargetDir = TargetDir;
            }

            snapshot.SaveParallel(null, null, Complete);

            Log.Info($"Backing up to {TargetDir}");
        }
Example #2
0
        private static void OnSnapshotDone(bool snapshotSuccess, MySessionSnapshot snapshot)
        {
            if (snapshotSuccess)
            {
                if (!MySandboxGame.IsDedicated)
                {
                    var thumbPath = MySession.Static.ThumbPath;
                    try
                    {
                        if (File.Exists(thumbPath))
                        {
                            File.Delete(thumbPath);
                        }
                        MyGuiSandbox.TakeScreenshot(1200, 672, saveToPath: thumbPath, ignoreSprites: true, showNotification: false);
                    }
                    catch (Exception ex)
                    {
                        MySandboxGame.Log.WriteLine("Could not take session thumb screenshot. Exception:");
                        MySandboxGame.Log.WriteLine(ex);
                    }
                }

                snapshot.SaveParallel(completionCallback: () =>
                {
                    if (!MySandboxGame.IsDedicated)
                    {
                        MyHud.PopRotatingWheelVisible();

                        if (MySession.Static != null)
                        {
                            if (snapshot.SavingSuccess)
                            {
                                var notification = new MyHudNotification(MySpaceTexts.WorldSaved, 2500);
                                notification.SetTextFormatArguments(MySession.Static.Name);
                                MyHud.Notifications.Add(notification);
                            }
                            else
                            {
                                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                           messageText: new StringBuilder().AppendFormat(MyTexts.GetString(MySpaceTexts.WorldNotSaved), MySession.Static.Name),
                                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError)));
                            }
                        }
                    }

                    PopInProgress();
                });
            }
            else
            {
                if (!MySandboxGame.IsDedicated)
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageText: new StringBuilder().AppendFormat(MyTexts.GetString(MySpaceTexts.WorldNotSaved), MySession.Static.Name),
                                               messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError)));
                }

                PopInProgress();
            }

            if (m_callbackOnFinished != null)
            {
                m_callbackOnFinished();
            }

            m_callbackOnFinished = null;

            MyAudio.Static.Mute = false;
        }