From 55790bcaf930d2ca98c1d20efe7de4c32e229f70 Mon Sep 17 00:00:00 2001 From: Andy De George <2672110+Thraka@users.noreply.github.com> Date: Wed, 12 Jun 2024 23:22:39 -0700 Subject: [PATCH] Delete monogame with sadconsole example.txt --- monogame with sadconsole example.txt | 169 --------------------------- 1 file changed, 169 deletions(-) delete mode 100644 monogame with sadconsole example.txt diff --git a/monogame with sadconsole example.txt b/monogame with sadconsole example.txt deleted file mode 100644 index 6cb1d83b0..000000000 --- a/monogame with sadconsole example.txt +++ /dev/null @@ -1,169 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using MonoGame.Extended.Screens; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp8 -{ - public class SadConsoleScreen : GameScreen - { - // How many columns/rows the screen for sadcosnole will display at normal font size - public const int WidthCellCount = 80; - public const int HeightCellCount = 25; - - SpriteBatch spriteBatch; - - public SadConsoleScreen(Game game) - : base(game) - { - // Basics used for rendering - SadConsole.Global.GraphicsDevice = GraphicsDevice; - SadConsole.Global.SpriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(GraphicsDevice); - - // Load the default font. This is an internal method so use reflection - // SadConsole.Global.LoadEmbeddedFont(); - if (SadConsole.Global.Fonts.Count == 0) - typeof(SadConsole.Global).InvokeMember("LoadEmbeddedFont", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.NonPublic, null, null, null); - - SadConsole.Global.RenderWidth = WidthCellCount * SadConsole.Global.FontDefault.Size.X; - SadConsole.Global.RenderHeight = HeightCellCount * SadConsole.Global.FontDefault.Size.Y; - SadConsole.Global.RenderOutput = new RenderTarget2D(GraphicsDevice, SadConsole.Global.RenderWidth, SadConsole.Global.RenderHeight); - SadConsole.Global.RenderRect = new Rectangle(0, 0, SadConsole.Global.RenderWidth, SadConsole.Global.RenderHeight); - SadConsole.Global.RenderScale = new Vector2(1); - - spriteBatch = new SpriteBatch(GraphicsDevice); - } - - public override void Initialize() - { - //var startingConsole = new TestConsole(); - var startingConsole = new SadConsole.Console(10, 10); - startingConsole.FillWithRandomGarbage(); - SadConsole.Global.CurrentScreen = startingConsole; - - base.Initialize(); - } - - public override void LoadContent() - { - base.LoadContent(); - } - - public override void Draw(GameTime gameTime) - { - if (SadConsole.Settings.DoDraw) - { - SadConsole.Global.GameTimeRender = gameTime; - SadConsole.Global.GameTimeElapsedRender = gameTime.ElapsedGameTime.TotalSeconds; - - // Clear draw calls for next run - SadConsole.Global.DrawCalls.Clear(); - - // Make sure all items in the screen are drawn. (Build a list of draw calls) - SadConsole.Global.CurrentScreen?.Draw(gameTime.ElapsedGameTime); - - // Comment this out as it's global logic used by a standalone sadconsole game. You really can just add your own logic here. Or uncomment it and use it. - //SadConsole.Game.OnDraw?.Invoke(gameTime); - - // Render to the global output texture - GraphicsDevice.SetRenderTarget(SadConsole.Global.RenderOutput); - GraphicsDevice.Clear(SadConsole.Settings.ClearColor); - - // Render each draw call - SadConsole.Global.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone); - foreach (SadConsole.DrawCalls.IDrawCall call in SadConsole.Global.DrawCalls) - { - call.Draw(); - } - - SadConsole.Global.SpriteBatch.End(); - GraphicsDevice.SetRenderTarget(null); - - // If we're going to draw to the screen, do it. - if (SadConsole.Settings.DoFinalDraw) - { - // This is the original draw to screen code from SadConsole - //Global.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone); - //Global.SpriteBatch.Draw(Global.RenderOutput, Global.RenderRect, Color.White); - //Global.SpriteBatch.End(); - - // This is the code you wrote but modified to draw the output texture from SadConsole. - GraphicsDevice.Clear(Color.Black); - - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, - SamplerState.LinearClamp, DepthStencilState.Default, - RasterizerState.CullNone); - - spriteBatch.Draw(SadConsole.Global.RenderOutput, new Rectangle(0, 0, 300, 100), Color.Red); - - spriteBatch.End(); - } - } - - - - } - - public override void Update(GameTime gameTime) - { - if (SadConsole.Settings.DoUpdate) - { - SadConsole.Global.GameTimeUpdate = gameTime; - SadConsole.Global.GameTimeElapsedUpdate = gameTime.ElapsedGameTime.TotalSeconds; - - if (Game.IsActive) - { - if (SadConsole.Settings.Input.DoKeyboard) - { - SadConsole.Global.KeyboardState.Update(gameTime); - SadConsole.Global.KeyboardState.Process(); - } - - if (SadConsole.Settings.Input.DoMouse) - { - SadConsole.Global.MouseState.Update(gameTime); - SadConsole.Global.MouseState.Process(); - } - } - - SadConsole.Global.CurrentScreen?.Update(gameTime.ElapsedGameTime); - - // Comment this out as it's global logic used by a standalone sadconsole game. You really can just add your own logic here. Or uncomment it and use it. - //SadConsole.Game.OnUpdate?.Invoke(gameTime); - } - } - - class Program - { - static void Main(string[] args) - { - new MonoGameGame().Run(); - } - } - - // My test game to make this code work. you didn't provide this so I came up with this :) - class MonoGameGame : Microsoft.Xna.Framework.Game - { - public GraphicsDeviceManager GraphicsDeviceManager; - - public MonoGameGame() - { - GraphicsDeviceManager = new GraphicsDeviceManager(this); - } - - protected override void Initialize() - { - base.Initialize(); - - ScreenManager manager = new ScreenManager(); - manager.LoadScreen(new SadConsoleScreen(this)); - Components.Add(manager); - - } - } - } -} \ No newline at end of file