From b24715da8dbcaac6f986d4ff11674e4cf313a600 Mon Sep 17 00:00:00 2001 From: Lucas Rodrigues Date: Sun, 30 Aug 2026 22:11:19 -0300 Subject: [PATCH 1/4] Add interface method for taking screenshot --- src/ArcadeMaker.Core/IGame.Funcs.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ArcadeMaker.Core/IGame.Funcs.cs b/src/ArcadeMaker.Core/IGame.Funcs.cs index 47e7512..07b3d9c 100644 --- a/src/ArcadeMaker.Core/IGame.Funcs.cs +++ b/src/ArcadeMaker.Core/IGame.Funcs.cs @@ -1017,4 +1017,13 @@ IValue SetViewFollowingTarget(Exp.Instance? _, IValue?[] args) /// The index of the currently activated room as a . [EngineFunc] IValue GetRoomIndex(Exp.Instance? _, IValue?[] args) => Rooms.IndexOf(GetActivatedRoom().Model).ToExp(); + + /// + /// Takes screenshot from texture. + /// + /// + /// + /// + [EngineFunc] + Exp.Void TakeScreenshot(Exp.Instance? _, IValue?[] args); } \ No newline at end of file From a9f45bd00d49a65ef985e675107e736774383652 Mon Sep 17 00:00:00 2001 From: Lucas Rodrigues Date: Sun, 30 Aug 2026 22:13:40 -0300 Subject: [PATCH 2/4] Move drawing code into a private method --- src/Engines/MonoGame/Core/ArcadeMakerMonoGame.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Engines/MonoGame/Core/ArcadeMakerMonoGame.cs b/src/Engines/MonoGame/Core/ArcadeMakerMonoGame.cs index f84286c..fa184da 100644 --- a/src/Engines/MonoGame/Core/ArcadeMakerMonoGame.cs +++ b/src/Engines/MonoGame/Core/ArcadeMakerMonoGame.cs @@ -381,6 +381,13 @@ protected override void Draw(GameTime gameTime) if (isOnError || CurrentRoom == null) return; + DrawScene(); + + base.Draw(gameTime); + } + + private void DrawScene() + { GraphicsDevice.Clear(backColor); // if views are defined, we need to draw the room for each view, applying the corresponding camera transformations. @@ -451,8 +458,6 @@ protected override void Draw(GameTime gameTime) SpriteBatch.End(); } - - base.Draw(gameTime); } public void DrawBackgrounds(int w, int h, Matrix transformMatrix) From 82c612d84e98b9acdd38abd8393864e17982569e Mon Sep 17 00:00:00 2001 From: Lucas Rodrigues Date: Sun, 30 Aug 2026 22:35:28 -0300 Subject: [PATCH 3/4] Implement method TakeScreenshot on class ArcadeMakerMonoGame --- .../MonoGame/Core/ArcadeMakerMonoGame.cs | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Engines/MonoGame/Core/ArcadeMakerMonoGame.cs b/src/Engines/MonoGame/Core/ArcadeMakerMonoGame.cs index fa184da..06ecac4 100644 --- a/src/Engines/MonoGame/Core/ArcadeMakerMonoGame.cs +++ b/src/Engines/MonoGame/Core/ArcadeMakerMonoGame.cs @@ -19,6 +19,7 @@ using MonoGame.Extended.ViewportAdapters; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Pipes; @@ -86,6 +87,9 @@ public RoomInstance? CurrentRoom public TextureAtlas MainTextureAtlas { get; private set; } public string MainTextureAtlasFilePath { get; set; } + private RenderTarget2D renderTarget = null; + private bool IsInsideDraw = false; + // runtime private data private GameRunner GameRunner { get; set; } private RectangleF roomBounds; @@ -182,6 +186,10 @@ protected override void Initialize() LocalizationManager.SetCulture(selectedLanguage); SpriteBatch = new SpriteBatch(GraphicsDevice); + renderTarget = new RenderTarget2D( + GraphicsDevice, + graphicsDeviceManager.PreferredBackBufferWidth, + graphicsDeviceManager.PreferredBackBufferHeight); try { @@ -380,8 +388,15 @@ protected override void Draw(GameTime gameTime) { if (isOnError || CurrentRoom == null) return; - - DrawScene(); + IsInsideDraw = true; + try + { + DrawScene(); + } + finally + { + IsInsideDraw = false; + } base.Draw(gameTime); } @@ -749,6 +764,18 @@ public Exp.Void DrawEllipse(Exp.Instance? _, IValue?[] args) return Exp.Void.Return; } + + public Exp.Void TakeScreenshot(Exp.Instance? _, IValue?[] args) + { + if(!IsInsideDraw) + throw new InvalidOperationException( + "TakeScreenshot must be called from inside Draw()."); + GraphicsDevice.SetRenderTarget(renderTarget); + DrawScene(); + GraphicsDevice.SetRenderTarget(null); + return Exp.Void.Return; + } + public (int x, int y) MousePositionInWindow { get From b028f6b22bbfff4e802d437eb962ea1cb48103e9 Mon Sep 17 00:00:00 2001 From: Lucas Rodrigues Date: Sun, 30 Aug 2026 22:38:09 -0300 Subject: [PATCH 4/4] Implement method TakeScreenshot on class FutileGame --- src/ArcadeMaker.IDE/Debugging/FutileGame.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ArcadeMaker.IDE/Debugging/FutileGame.cs b/src/ArcadeMaker.IDE/Debugging/FutileGame.cs index 6b8decb..41b59cd 100644 --- a/src/ArcadeMaker.IDE/Debugging/FutileGame.cs +++ b/src/ArcadeMaker.IDE/Debugging/FutileGame.cs @@ -74,4 +74,6 @@ public void SetCaption(string caption) { } public Exp.Void ResumeSound(Exp.Instance? _, IValue?[] args) => Exp.Void.Return; public Exp.Void ResumeAllSounds(Exp.Instance? _, IValue?[] args) => Exp.Void.Return; + + public Exp.Void TakeScreenshot(Exp.Instance? _, IValue?[] args) => Exp.Void.Return; } \ No newline at end of file