Add support for enabling the screenshot taker, even in sim

This commit is contained in:
Norbi Peti 2021-06-11 19:51:32 +02:00
parent 52ccbe4dad
commit 76faa69c74
4 changed files with 25 additions and 1 deletions

View file

@ -1,7 +1,6 @@
using System; using System;
using RobocraftX.GUI.MyGamesScreen; using RobocraftX.GUI.MyGamesScreen;
using RobocraftX.GUI;
using Svelto.ECS; using Svelto.ECS;
using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Engines;
using TechbloxModdingAPI.Utility; using TechbloxModdingAPI.Utility;

View file

@ -473,6 +473,15 @@ namespace TechbloxModdingAPI.App
return blocks; return blocks;
} }
/// <summary>
/// Enable the screenshot taker for updating the game's screenshot. Breaks the pause menu in a new save.
/// </summary>
public void EnableScreenshotTaker()
{
if (!VerifyMode()) return;
gameEngine.EnableScreenshotTaker();
}
~Game() ~Game()
{ {
foreach (string id in debugIds) foreach (string id in debugIds)

View file

@ -10,6 +10,7 @@ using Svelto.ECS;
using Svelto.Tasks; using Svelto.Tasks;
using Svelto.Tasks.Lean; using Svelto.Tasks.Lean;
using RobocraftX.Blocks; using RobocraftX.Blocks;
using RobocraftX.ScreenshotTaker;
using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Blocks;
using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Engines;
using TechbloxModdingAPI.Utility; using TechbloxModdingAPI.Utility;
@ -129,5 +130,14 @@ namespace TechbloxModdingAPI.App
return blockEGIDs.ToArray(); return blockEGIDs.ToArray();
} }
} }
public void EnableScreenshotTaker()
{
ref var local = ref entitiesDB.QueryEntity<ScreenshotModeEntityStruct>(ScreenshotTakerEgids.ScreenshotTaker);
if (local.enabled)
return;
local.enabled = true;
entitiesDB.PublishEntityChange<ScreenshotModeEntityStruct>(ScreenshotTakerEgids.ScreenshotTaker);
}
} }
} }

View file

@ -282,6 +282,12 @@ namespace TechbloxModdingAPI.Tests
.Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}") .Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}")
.Aggregate((a, b) => a + "\n" + b)); .Aggregate((a, b) => a + "\n" + b));
};*/ };*/
CommandBuilder.Builder("takeScreenshot", "Enables the screenshot taker")
.Action(() =>
{
Game.CurrentGame().EnableScreenshotTaker();
}).Build();
#if TEST #if TEST
TestRoot.RunTests(); TestRoot.RunTests();
#endif #endif