Beispiel #1
0
 /// <summary>Perform any required update logic.</summary>
 internal void Update()
 {
     // perform passive save
     if (this.WaitingToSave && Game1.activeClickableMenu == null)
     {
         this.currentSaveMenu = new NewSaveGameMenu();
         this.currentSaveMenu.SaveComplete += this.CurrentSaveMenu_SaveComplete;
         Game1.activeClickableMenu          = this.currentSaveMenu;
         this.WaitingToSave = false;
     }
 }
Beispiel #2
0
        /// <summary>Initiate a game save.</summary>
        internal void BeginSaveData()
        {
            // save game data
            Farm farm = Game1.getFarm();

            if (farm.shippingBin.Any())
            {
                Game1.activeClickableMenu = new NewShippingMenu(farm.shippingBin, ModMain.Reflection);
                farm.shippingBin.Clear();
                farm.lastItemShipped = null;
                this.WaitingToSave   = true;
            }
            else
            {
                this.currentSaveMenu = new NewSaveGameMenu();
                this.currentSaveMenu.SaveComplete += this.CurrentSaveMenu_SaveComplete;
                Game1.activeClickableMenu          = this.currentSaveMenu;
            }

            // By Cookie
            // Bookkeeping tag label
            string tag = $"{Constants.SaveFolderName} Day {SDate.Now().DaysSinceStart} {Game1.timeOfDay.ToString("0000")}"
                         + $" @ {DateTime.Now:yyyy-MM-dd HH:mm:ss}\n";

            // save data to disk
            PlayerData data = new PlayerData
            {
                Tag                 = tag,
                Time                = Game1.timeOfDay,
                Characters          = this.GetPositions().ToArray(),
                IsCharacterSwimming = Game1.player.swimming.Value
            };

            ModMain.ModHelper.Data.WriteJsonFile(CharRelativePath, data);

            // By Cookie
            // copy saved char data to game save folder for backup
            if (File.Exists(CharSavePath))
            {
                File.Delete(CharSavePath + "_old");
                File.Move(CharSavePath, CharSavePath + "_old");
            }
            File.Copy(CharFullPath, CharSavePath);

            // clear any legacy data (no longer needed as backup)
            this.RemoveLegacyDataForThisPlayer();
        }
 public override void update(GameTime time)
 {
     if (this.bQuit)
     {
         return;
     }
     //base.update(time);
     if (Game1.client != null && Game1.client.timedOut)
     {
         this.bQuit = true;
         if (!Game1.activeClickableMenu.Equals((object)this))
         {
             return;
         }
         Game1.player.checkForLevelTenStatus();
         Game1.exitActiveMenu();
     }
     else
     {
         TimeSpan elapsedGameTime;
         if (this.loader != null)
         {
             this.loader.MoveNext();
             if (this.loader.Current >= 100)
             {
                 int num = this.margin;
                 elapsedGameTime = time.ElapsedGameTime;
                 int milliseconds = elapsedGameTime.Milliseconds;
                 this.margin = num - milliseconds;
                 if (this.margin <= 0)
                 {
                     this.complete();
                 }
             }
             double num1 = (double)this._ellipsisDelay;
             elapsedGameTime = time.ElapsedGameTime;
             double totalSeconds = elapsedGameTime.TotalSeconds;
             this._ellipsisDelay = (float)(num1 - totalSeconds);
             if ((double)this._ellipsisDelay <= 0.0)
             {
                 this._ellipsisDelay = this._ellipsisDelay + 0.75f;
                 this._ellipsisCount = this._ellipsisCount + 1;
                 if (this._ellipsisCount > 3)
                 {
                     this._ellipsisCount = 1;
                 }
             }
         }
         else if (this.bHasDrawn && this.completePause == -1)
         {
             Game1.game1.IsSaving = true;
             if (Game1.IsMasterGame)
             {
                 if (Game1.saveOnNewDay)
                 {
                     this.loader = SaveGame.Save();
                 }
                 else
                 {
                     this.margin = -1;
                     this.complete();
                 }
             }
             else
             {
                 NewSaveGameMenu.saveClientOptions();
                 this.complete();
             }
         }
         if (this.completePause < 0)
         {
             return;
         }
         int num2 = this.completePause;
         elapsedGameTime = time.ElapsedGameTime;
         int milliseconds1 = elapsedGameTime.Milliseconds;
         this.completePause = num2 - milliseconds1;
         this.saveText.update(time);
         if (this.completePause >= 0)
         {
             return;
         }
         this.bQuit         = true;
         this.completePause = -9999;
         if (Game1.activeClickableMenu.Equals((object)this))
         {
             Game1.player.checkForLevelTenStatus();
             Game1.exitActiveMenu();
         }
         Game1.currentLocation.resetForPlayerEntry();
     }
 }
Beispiel #4
0
 /// <summary>Event function for NewSaveGameMenu event SaveComplete</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void CurrentSaveMenu_SaveComplete(object sender, EventArgs e)
 {
     this.currentSaveMenu.SaveComplete -= this.CurrentSaveMenu_SaveComplete;
     this.currentSaveMenu = null;
     //AfterSave.Invoke(this, EventArgs.Empty);
 }