Пример #1
0
 protected override void Draw(GameTime gameTime)
 {
     if (_windowSizeChanged)
     {
         ExecuteForInstances(delegate(Game1 instance)
         {
             instance.Window_ClientSizeChanged(null, null);
         });
         _windowSizeChanged = false;
         SubscribeClientSizeChange();
     }
     foreach (Game1 instance2 in gameInstances)
     {
         LoadInstance(instance2);
         Viewport old_viewport = base.GraphicsDevice.Viewport;
         Game1.graphics.GraphicsDevice.Viewport = new Viewport(0, 0, Math.Min(instance2.localMultiplayerWindow.Width, Game1.graphics.GraphicsDevice.PresentationParameters.BackBufferWidth), Math.Min(instance2.localMultiplayerWindow.Height, Game1.graphics.GraphicsDevice.PresentationParameters.BackBufferHeight));
         instance2.Instance_Draw(gameTime);
         base.GraphicsDevice.Viewport = old_viewport;
         SaveInstance(instance2);
     }
     if (LocalMultiplayer.IsLocalMultiplayer())
     {
         base.GraphicsDevice.Clear(Game1.bgColor);
         foreach (Game1 gameInstance in gameInstances)
         {
             gameInstance.isRenderingScreenBuffer = true;
             gameInstance.DrawSplitScreenWindow();
             gameInstance.isRenderingScreenBuffer = false;
         }
     }
     base.Draw(gameTime);
 }
Пример #2
0
 public static void SaveInstance(InstanceGame instance, bool force = false)
 {
     if (force || LocalMultiplayer.IsLocalMultiplayer())
     {
         if (instance.staticVarHolder == null)
         {
             instance.staticVarHolder = Activator.CreateInstance(LocalMultiplayer.StaticVarHolderType);
         }
         LocalMultiplayer.StaticSave(instance.staticVarHolder);
     }
 }
Пример #3
0
 public Chunk()
 {
     NetFields.AddFields(position.NetFields, xVelocity, yVelocity, netDebrisType, xSpriteSheet, ySpriteSheet, netScale, netAlpha, hasPassedRestingLineOnce);
     if (LocalMultiplayer.IsLocalMultiplayer(is_local_only: true))
     {
         NetFields.DeltaAggregateTicks = 10;
     }
     else
     {
         NetFields.DeltaAggregateTicks = 30;
     }
 }
Пример #4
0
 public bool IsRemoteMoving()
 {
     if (LocalMultiplayer.IsLocalMultiplayer(is_local_only: true))
     {
         if (!position.moving.Value)
         {
             return(position.Field.IsInterpolating());
         }
         return(true);
     }
     return(position.Field.IsInterpolating());
 }
Пример #5
0
 public static void LoadInstance(InstanceGame instance, bool force = false)
 {
     Game1.game1 = (instance as Game1);
     if ((force || LocalMultiplayer.IsLocalMultiplayer()) && instance.staticVarHolder != null)
     {
         LocalMultiplayer.StaticLoad(instance.staticVarHolder);
         if (Game1.player != null && (bool)Game1.player.isCustomized && Game1.splitscreenOptions.ContainsKey(Game1.player.UniqueMultiplayerID))
         {
             Game1.options = Game1.splitscreenOptions[Game1.player.UniqueMultiplayerID];
             Game1.options.lightingQuality = GameRunner.instance.gameInstances[0].instanceOptions.lightingQuality;
         }
     }
 }
Пример #6
0
 public bool isVarReady(string varName)
 {
     if (!variables.ContainsKey(varName))
     {
         processMessages();
         if (shouldAbort())
         {
             throw new AbortNetSynchronizerException();
         }
         LocalMultiplayer.IsLocalMultiplayer();
         return(false);
     }
     return(true);
 }
Пример #7
0
 public void barrier(string name)
 {
     barrierPlayers(name).Add(Game1.player.UniqueMultiplayerID);
     sendMessage((byte)1, name);
     while (!barrierReady(name))
     {
         processMessages();
         if (shouldAbort())
         {
             throw new AbortNetSynchronizerException();
         }
         if (LocalMultiplayer.IsLocalMultiplayer())
         {
             break;
         }
     }
 }
Пример #8
0
 protected override void Draw(GameTime gameTime)
 {
     if (_windowSizeChanged)
     {
         ExecuteForInstances(delegate(Game1 instance)
         {
             instance.Window_ClientSizeChanged(null, null);
         });
         _windowSizeChanged = false;
         SubscribeClientSizeChange();
     }
     foreach (Game1 instance2 in gameInstances)
     {
         LoadInstance(instance2);
         Viewport old_viewport = base.GraphicsDevice.Viewport;
         Game1.graphics.GraphicsDevice.Viewport = new Viewport(0, 0, Math.Min(instance2.localMultiplayerWindow.Width, Game1.graphics.GraphicsDevice.PresentationParameters.BackBufferWidth), Math.Min(instance2.localMultiplayerWindow.Height, Game1.graphics.GraphicsDevice.PresentationParameters.BackBufferHeight));
         instance2.Instance_Draw(gameTime);
         base.GraphicsDevice.Viewport = old_viewport;
         SaveInstance(instance2);
     }
     if (LocalMultiplayer.IsLocalMultiplayer())
     {
         base.GraphicsDevice.Clear(Game1.bgColor);
         foreach (Game1 gameInstance in gameInstances)
         {
             Game1.isRenderingScreenBuffer = true;
             gameInstance.DrawSplitScreenWindow();
             Game1.isRenderingScreenBuffer = false;
         }
     }
     if (Game1.shouldDrawSafeAreaBounds)
     {
         SpriteBatch spriteBatch = Game1.spriteBatch;
         spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
         Rectangle safe_area = Game1.safeAreaBounds;
         spriteBatch.Draw(Game1.staminaRect, new Rectangle(safe_area.X, safe_area.Y, safe_area.Width, 2), Color.White);
         spriteBatch.Draw(Game1.staminaRect, new Rectangle(safe_area.X, safe_area.Y + safe_area.Height - 2, safe_area.Width, 2), Color.White);
         spriteBatch.Draw(Game1.staminaRect, new Rectangle(safe_area.X, safe_area.Y, 2, safe_area.Height), Color.White);
         spriteBatch.Draw(Game1.staminaRect, new Rectangle(safe_area.X + safe_area.Width - 2, safe_area.Y, 2, safe_area.Height), Color.White);
         spriteBatch.End();
     }
     base.Draw(gameTime);
 }
Пример #9
0
 public GameRunner()
 {
     Program.sdk.EarlyInitialize();
     if (!Program.releaseBuild)
     {
         base.InactiveSleepTime = new TimeSpan(0L);
     }
     Game1.graphics = new GraphicsDeviceManager(this);
     Game1.graphics.PreparingDeviceSettings += delegate(object sender, PreparingDeviceSettingsEventArgs args)
     {
         args.GraphicsDeviceInformation.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
     };
     Game1.graphics.PreferredBackBufferWidth  = 1280;
     Game1.graphics.PreferredBackBufferHeight = 720;
     base.Content.RootDirectory = "Content";
     LocalMultiplayer.Initialize();
     base.Window.AllowUserResizing = true;
     SubscribeClientSizeChange();
     base.Exiting += delegate(object sender, EventArgs args)
     {
         ExecuteForInstances(delegate(Game1 instance)
         {
             instance.exitEvent(sender, args);
         });
         Process.GetCurrentProcess().Kill();
     };
     Thread.CurrentThread.CurrentCulture       = CultureInfo.InvariantCulture;
     LocalizedContentManager.OnLanguageChange += delegate
     {
         ExecuteForInstances(delegate(Game1 instance)
         {
             instance.TranslateFields();
         });
     };
     DebugTools.GameConstructed(this);
 }
Пример #10
0
        public GameRunner()
        {
            Program.sdk.EarlyInitialize();
            if (!Program.releaseBuild)
            {
                base.InactiveSleepTime = new TimeSpan(0L);
            }
            Game1.graphics = new GraphicsDeviceManager(this);
            Game1.graphics.PreparingDeviceSettings += delegate(object sender, PreparingDeviceSettingsEventArgs args)
            {
                args.GraphicsDeviceInformation.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
            };
            Game1.graphics.PreferredBackBufferWidth  = 1280;
            Game1.graphics.PreferredBackBufferHeight = 720;
            base.Content.RootDirectory = "Content";
            LocalMultiplayer.Initialize();
            bool first_attempt = true;

            MaxTextureSize = 65536;
            try
            {
                do
                {
                    if (!first_attempt)
                    {
                        MaxTextureSize /= 2;
                    }
                    first_attempt = false;
                    Type profile_capabilities2 = Assembly.GetAssembly(typeof(GraphicsProfile)).GetType("Microsoft.Xna.Framework.Graphics.ProfileCapabilities", throwOnError: true);
                    if (profile_capabilities2 != null)
                    {
                        FieldInfo max_texture_size2 = profile_capabilities2.GetField("MaxTextureSize", BindingFlags.Instance | BindingFlags.NonPublic);
                        FieldInfo hidef_profile2    = profile_capabilities2.GetField("HiDef", BindingFlags.Static | BindingFlags.NonPublic);
                        if (max_texture_size2 != null && hidef_profile2 != null)
                        {
                            hidef_profile2.GetValue(null);
                            max_texture_size2.SetValue(hidef_profile2.GetValue(null), MaxTextureSize);
                        }
                    }
                }while (MaxTextureSize > 4096 && !GraphicsAdapter.DefaultAdapter.IsProfileSupported(GraphicsProfile.HiDef));
            }
            catch (Exception)
            {
                MaxTextureSize = 4096;
                try
                {
                    Type profile_capabilities = Assembly.GetAssembly(typeof(GraphicsProfile)).GetType("Microsoft.Xna.Framework.Graphics.ProfileCapabilities", throwOnError: true);
                    if (profile_capabilities != null)
                    {
                        FieldInfo max_texture_size = profile_capabilities.GetField("MaxTextureSize", BindingFlags.Instance | BindingFlags.NonPublic);
                        FieldInfo hidef_profile    = profile_capabilities.GetField("HiDef", BindingFlags.Static | BindingFlags.NonPublic);
                        if (max_texture_size != null && hidef_profile != null)
                        {
                            hidef_profile.GetValue(null);
                            max_texture_size.SetValue(hidef_profile.GetValue(null), MaxTextureSize);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            base.Window.AllowUserResizing = true;
            SubscribeClientSizeChange();
            base.Exiting += delegate(object sender, EventArgs args)
            {
                ExecuteForInstances(delegate(Game1 instance)
                {
                    instance.exitEvent(sender, args);
                });
                Process.GetCurrentProcess().Kill();
            };
            Thread.CurrentThread.CurrentCulture       = CultureInfo.InvariantCulture;
            LocalizedContentManager.OnLanguageChange += delegate
            {
                ExecuteForInstances(delegate(Game1 instance)
                {
                    instance.TranslateFields();
                });
            };
            DebugTools.GameConstructed(this);
        }
Пример #11
0
        public static void handleException(object sender, UnhandledExceptionEventArgs args)
        {
            if (handlingException || !GameTesterMode)
            {
                return;
            }
            Game1.gameMode    = 11;
            handlingException = true;
            Exception     e  = (Exception)args.ExceptionObject;
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Message: " + e.Message);
            sb.AppendLine("InnerException: " + e.InnerException);
            sb.AppendLine("Stack Trace: " + e.StackTrace);
            sb.AppendLine("");
            sb.AppendLine("Game Version: " + Game1.version);
            try
            {
                if (sdk != null)
                {
                    sb.AppendLine("SDK Helper: " + sdk.GetType().Name);
                }
                sb.AppendLine("Game Language: " + LocalizedContentManager.CurrentLanguageCode);
                sb.AppendLine("GPU: " + Game1.graphics.GraphicsDevice.Adapter.Description);
                sb.AppendLine(string.Concat("OS: ", Environment.OSVersion.Platform, " ", Environment.OSVersion.VersionString));
                if (GameRunner.instance != null && GameRunner.instance.GetType().FullName.StartsWith("StardewModdingAPI."))
                {
                    sb.AppendLine("Running SMAPI");
                }
                if (Game1.IsMultiplayer)
                {
                    if (LocalMultiplayer.IsLocalMultiplayer())
                    {
                        sb.AppendLine("Multiplayer (Split Screen)");
                    }
                    else if (Game1.IsMasterGame)
                    {
                        sb.AppendLine("Multiplayer (Host)");
                    }
                    else
                    {
                        sb.AppendLine("Multiplayer (Client)");
                    }
                }
                if (Game1.options.gamepadControls)
                {
                    sb.AppendLine("Playing on Controller");
                }
                sb.AppendLine("In-game Date: " + Game1.currentSeason + " " + Game1.dayOfMonth + " Y" + Game1.year + " Time of Day: " + Game1.timeOfDay);
                sb.AppendLine("Game Location: " + ((Game1.currentLocation == null) ? "null" : Game1.currentLocation.NameOrUniqueName));
            }
            catch (Exception)
            {
            }
            Game1.errorMessage = sb.ToString();
            long targetTime = DateTime.Now.Ticks / 10000 + 25000;

            if (!hasTriedToPrintLog)
            {
                hasTriedToPrintLog = true;
                string successfulErrorPath = WriteLog(LogType.Error, Game1.errorMessage);
                if (successfulErrorPath != null)
                {
                    successfullyPrintedLog = true;
                    Game1.errorMessage     = "(Error Report created at " + successfulErrorPath + ")" + Environment.NewLine + Game1.errorMessage;
                }
            }
            Game1.gameMode = 3;
        }