18 public static void Run() {
27 float num2 = width / (float)height;
28 width = Math.Min(width, 2048);
29 height = (int)MathF.Round(width / num2);
35 height = (int)MathF.Round(width * 9f / 16f);
51 DateTime now = DateTime.Now;
55 $
"Survivalcraft {now.Year:D4}-{now.Month:D2}-{now.Day:D2} {now.Hour:D2}-{now.Minute:D2}-{now.Second:D2}.png"
60 catch (Exception ex) {
61 Log.
Error($
"Error capturing screen. Reason: {ex.Message}");
72 public static void CapturePhoto(Action success, Action<Exception> failure) {
80 public static void Capture(
int width,
int height,
string filename) {
82#pragma warning disable CA1416
83 if (Android.OS.Build.VERSION.SdkInt < (Android.OS.BuildVersionCodes)21) {
90 Dictionary<ComponentGui, bool> dictionary =
new();
96 componentPlayer.ComponentGui.ControlsContainerWidget.IsVisible =
false;
101 Display.RenderTarget = renderTarget2D;
106 Vector2 vector =
new((width - texture2D.
Width) / 2, 0f);
110 primitivesRenderer2D.
Flush();
114 Display.RenderTarget = renderTarget;
115 foreach (KeyValuePair<ComponentGui, bool> item
in dictionary) {
116 item.Key.ControlsContainerWidget.IsVisible = item.Value;
145 Intent intent =
new(
"android.intent.action.MEDIA_SCANNER_SCAN_FILE");
147 Window.Activity.SendBroadcast(intent);
148#pragma warning restore CA1416
static readonly DepthStencilState None
static int MaxTextureSize
static RenderTarget2D RenderTarget
TexturedBatch2D TexturedBatch(Texture2D texture, bool useAlphaTest=false, int layer=0, DepthStencilState depthStencilState=null, RasterizerState rasterizerState=null, BlendState blendState=null, SamplerState samplerState=null)
void Flush(bool clearAfterFlush=true, int maxLayer=int.MaxValue)
unsafe Image GetData(Rectangle sourceRectangle)
void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Vector2 texCoord1, Vector2 texCoord2, Color color)
static void Error(object message)
static string GetSystemPath(string path)
static void CreateDirectory(string path)
static bool DirectoryExists(string path)
static Stream OpenFile(string path, OpenFileMode openFileMode)
static string CombinePaths(params string[] paths)
ContainerWidget ControlsContainerWidget
ComponentGui ComponentGui
static object Get(Type type, string name)
static readonly string ScreenshotDir
static void Capture(int width, int height, string filename)
static bool m_captureRequested
static Action< Exception > m_failureHandler
static Action m_successHandler
static void CapturePhoto(Action success, Action< Exception > failure)
static bool ShowGuiInScreenshots
static int[] ScreenshotSizeCustomWidths
static int ScreenshotSizeCustomWidthIndex
static ScreenshotSize ScreenshotSize
static float[] ScreenshotSizeCustomAspectRatios
static ResolutionMode ResolutionMode
static bool ShowLogoInScreenshots
static int ScreenshotSizeCustomAspectRatioIndex
ReadOnlyList< ComponentPlayer > ComponentPlayers
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static string ScreenCapturePath