<commit_before>﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewValley;
using StardewValley.BellsAndWhistles;
using StardewValley.Menus;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace StardewValleyMP.Vanilla
{
    public class NewSaveGameMenu : SaveGameMenu
    {
        private IEnumerator<int> loader;

        private int completePause = -1;

        //public bool quit;

        //public bool hasDrawn;

        ////////////////////////////////////////
        private SparklingText waitingText;
        ////////////////////////////////////////
        private SparklingText saveText;

        private int margin = 500;

        private StringBuilder _stringBuilder = new StringBuilder();

        private float _ellipsisDelay = 0.5f;

        private int _ellipsisCount;

        public NewSaveGameMenu()
        {
            ////////////////////////////////////////
            //Log.Async("New save menu created");
            /*if ( Multiplayer.mode == Mode.Host )
            {
                //Multiplayer.server.playing = false;
            }
            else if ( Multiplayer.mode == Mode.Client )
            {
                Multiplayer.client.stage = Client.NetStage.Waiting;
                //Multiplayer.sendFunc(new ClientFarmerDataPacket(Util.serialize<SFarmer>(Game1.player)));
                Multiplayer.sendFunc(new NextDayPacket());
            }*/
            this.waitingText = new SparklingText(Game1.dialogueFont, "Waiting on host", Color.DodgerBlue, Color.Black * 0.001f, false, 0.1, 1500, Game1.tileSize / 2, 500);
            ////////////////////////////////////////
            this.saveText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\StringsFromCSFiles:SaveGameMenu.cs.11378", new object[0]), Color.LimeGreen, Color.Black * 0.001f, false, 0.1, 1500, Game1.tileSize / 2, 500);
        }

        public override void receiveRightClick(int x, int y, bool playSound = true)
        {
        }

        public override void update(GameTime time)
        {
            if (this.quit)
            {
                if ( Game1.currentLoader.Current < 100 )
                {
                    Game1.currentLoader.MoveNext();
                }
                else Game1.exitActiveMenu();
                return;
            }

            ////////////////////////////////////////
            if (Multiplayer.mode == Mode.Client)
            {
                Log.info("Reloading world for next day");

                // Yes, it is necessary to do this again (previously done when the next day packet was sent before the fade)
                // This time newDayAfterFade has run, and so mail and stuff has changed
                var it = NewSaveGame.Save(true);
                while (it.Current < 100)
                {
                    it.MoveNext();
                    Thread.Sleep(5);
                }

                Multiplayer.client.processDelayedPackets();
                NewSaveGame.Load("MEOW", true);
                quit = true;
                return;
            }
            ////////////////////////////////////////
            
            if (!Game1.saveOnNewDay)
            {
                this.quit = true;
                if (Game1.activeClickableMenu.Equals(this))
                {
                    Game1.player.checkForLevelTenStatus();
                    Game1.exitActiveMenu();
                }
                return;
            }
            if (this.loader != null)
            {
                this.loader.MoveNext();
                if (this.loader.Current >= 100)
                {
                    this.margin -= time.ElapsedGameTime.Milliseconds;
                    if (this.margin <= 0)
                    {
                        Game1.playSound("money");
                        this.completePause = 1500;
                        this.loader = null;
                    }
                }
                this._ellipsisDelay -= (float)time.ElapsedGameTime.TotalSeconds;
                if (this._ellipsisDelay <= 0f)
                {
                    this._ellipsisDelay += 0.75f;
                    this._ellipsisCount++;
                    if (this._ellipsisCount > 3)
                    {
                        this._ellipsisCount = 1;<commit_msg>Possibly fixed host stuck on black screen after saving. Need to test one more time.<commit_after>﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewValley;
using StardewValley.BellsAndWhistles;
using StardewValley.Menus;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace StardewValleyMP.Vanilla
{
    public class NewSaveGameMenu : SaveGameMenu
    {
        private IEnumerator<int> loader;

        private int completePause = -1;

        //public bool quit;

        //public bool hasDrawn;

        ////////////////////////////////////////
        private SparklingText waitingText;
        ////////////////////////////////////////
        private SparklingText saveText;

        private int margin = 500;

        private StringBuilder _stringBuilder = new StringBuilder();

        private float _ellipsisDelay = 0.5f;

        private int _ellipsisCount;

        public NewSaveGameMenu()
        {
            ////////////////////////////////////////
            //Log.Async("New save menu created");
            /*if ( Multiplayer.mode == Mode.Host )
            {
                //Multiplayer.server.playing = false;
            }
            else if ( Multiplayer.mode == Mode.Client )
            {
                Multiplayer.client.stage = Client.NetStage.Waiting;
                //Multiplayer.sendFunc(new ClientFarmerDataPacket(Util.serialize<SFarmer>(Game1.player)));
                Multiplayer.sendFunc(new NextDayPacket());
            }*/
            this.waitingText = new SparklingText(Game1.dialogueFont, "Waiting on host", Color.DodgerBlue, Color.Black * 0.001f, false, 0.1, 1500, Game1.tileSize / 2, 500);
            ////////////////////////////////////////
            this.saveText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\StringsFromCSFiles:SaveGameMenu.cs.11378", new object[0]), Color.LimeGreen, Color.Black * 0.001f, false, 0.1, 1500, Game1.tileSize / 2, 500);
        }

        public override void receiveRightClick(int x, int y, bool playSound = true)
        {
        }

        public override void update(GameTime time)
        {
            if (this.quit)
            {
                if ( Game1.currentLoader.Current < 100 )
                {
                    Game1.currentLoader.MoveNext();
                }
                else Game1.exitActiveMenu();
                return;
            }

            ////////////////////////////////////////
            if (Multiplayer.mode == Mode.Client)
            {
                Log.info("Reloading world for next day");

                // Yes, it is necessary to do this again (previously done when the next day packet was sent before the fade)
                // This time newDayAfterFade has run, and so mail and stuff has changed
                var it = NewSaveGame.Save(true);
                while (it.Current < 100)
                {
                    it.MoveNext();
                    Thread.Sleep(5);
                }

                Multiplayer.client.processDelayedPackets();
                NewSaveGame.Load("MEOW", true);
                quit = true;
                return;
            }
            ////////////////////////////////////////
            
            if (!Game1.saveOnNewDay)
            {
                this.quit = true;
                if (Game1.activeClickableMenu.Equals(this))
                {
                    Game1.player.checkForLevelTenStatus();
                    Game1.exitActiveMenu();
                }
                return;
            }
            if (this.loader != null)
            {
                this.loader.MoveNext();
                if (this.loader.Current >= 100)
                {
                    this.margin -= time.ElapsedGameTime.Milliseconds;
                    if (this.margin <= 0)
                    {
                        Game1.playSound("money");
                        this.completePause = 1500;
                        this.loader = null;
                        Game1.game1.IsSaving = false;
                    }
                }
                this._ellipsisDelay -= (float)time.ElapsedGameTime.TotalSeconds;
                if (this._ellipsisDelay <= 0f)
                {
                    this._ellipsisDelay += 0.75f;
                    this._ellipsisCount++;
                    if (this._ellipsisCount > 3)
                    {
                        this._ellipsisCount = 1;
{'fraction_non_alphanumeric': 0.13688728258414276, 'fraction_numerical': 0.017167381974248927, 'mean_word_length': 1.1821094135041892, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4727957', 'n_tokens_mistral': 2349, 'n_tokens_neox': 2101, 'n_words': 465}