ghorsington 4 years ago
commit
21b81c8626

+ 428 - 0
.gitignore

@@ -0,0 +1,428 @@
+*.dll
+
+.idea/
+
+# Created by https://www.gitignore.io/api/rider,csharp
+# Edit at https://www.gitignore.io/?templates=rider,csharp
+
+### Csharp ###
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+### Rider ###
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn.  Uncomment if using
+# auto-import.
+# .idea/modules.xml
+# .idea/*.iml
+# .idea/modules
+# *.iml
+# *.ipr
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+# End of https://www.gitignore.io/api/rider,csharp

+ 22 - 0
COM3D2.ToukaScreenShot.Plugin.sln

@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26228.4
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COM3D2.ToukaScreenShot.Plugin", "COM3D2.ToukaScreenShot.Plugin\COM3D2.ToukaScreenShot.Plugin.csproj", "{FC33D4E6-E930-4AB3-A4A8-2FC3D8F277B9}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{FC33D4E6-E930-4AB3-A4A8-2FC3D8F277B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FC33D4E6-E930-4AB3-A4A8-2FC3D8F277B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FC33D4E6-E930-4AB3-A4A8-2FC3D8F277B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FC33D4E6-E930-4AB3-A4A8-2FC3D8F277B9}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 71 - 0
COM3D2.ToukaScreenShot.Plugin/COM3D2.ToukaScreenShot.Plugin.csproj

@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{FC33D4E6-E930-4AB3-A4A8-2FC3D8F277B9}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>CM3D2.ToukaScreenShot.Plugin</RootNamespace>
+    <AssemblyName>COM3D2.ToukaScreenShot.Plugin</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <LangVersion>8</LangVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Assembly-CSharp">
+      <HintPath>A:\Gams\KISS\CMUlt\KISS\COM3D2\COM3D2x64_Data\Managed\Assembly-CSharp.dll</HintPath>
+    </Reference>
+    <Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
+      <HintPath>..\lib\Assembly-CSharp.dll</HintPath>
+    </Reference>
+    <Reference Include="Assembly-UnityScript-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
+      <HintPath>..\lib\Assembly-UnityScript-firstpass.dll</HintPath>
+    </Reference>
+    <Reference Include="ExIni">
+      <HintPath>A:\Gams\KISS\CMUlt\KISS\COM3D2\sybaris_old\ExIni.dll</HintPath>
+    </Reference>
+    <Reference Include="ExIni, Version=1.0.2.1, Culture=neutral, PublicKeyToken=null">
+      <HintPath>..\lib\ExIni.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine">
+      <HintPath>A:\Gams\KISS\CMUlt\KISS\COM3D2\COM3D2x64_Data\Managed\UnityEngine.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
+      <HintPath>..\lib\UnityEngine.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityInjector">
+      <HintPath>A:\Gams\KISS\CMUlt\KISS\COM3D2\sybaris_old\UnityInjector.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityInjector, Version=1.0.4.1, Culture=neutral, PublicKeyToken=null">
+      <HintPath>..\lib\UnityInjector.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <AppDesigner Include="Properties\" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ToukaScreenShot.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 6 - 0
COM3D2.ToukaScreenShot.Plugin/Properties/AssemblyInfo.cs

@@ -0,0 +1,6 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion("0.0.0.0")]
+[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
+[assembly: CompilationRelaxations(8)]

+ 230 - 0
COM3D2.ToukaScreenShot.Plugin/ToukaScreenShot.cs

@@ -0,0 +1,230 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Reflection;
+using ExIni;
+using UnityEngine;
+using UnityInjector;
+using UnityInjector.Attributes;
+
+namespace CM3D2.ToukaScreenShot.Plugin
+{
+    [PluginVersion("0.1.0.2")]
+    [PluginName("Com3d2.ToukaScreenShot.Plugin")]
+    [PluginFilter("COM3D2x64")]
+    public class ToukaScreenShot : PluginBase
+    {
+        private readonly bool[] bLayerMask = new bool[32];
+
+        private readonly FieldInfo fBloom =
+            typeof(CameraMain).GetField("m_gcBloom", BindingFlags.Instance | BindingFlags.NonPublic);
+
+        private bool altKey;
+        private bool bgActiveBack = true;
+        private Color bgColorBack = Color.black;
+        private bool bgVisible = true;
+        private bool bloomBack;
+        private bool bloomOff = true;
+        private bool ctrlKey = true;
+
+        private string fileNameEnd = "";
+        private string fileNameHead = "img";
+        private string folderName = "ScreenShot";
+        private Camera mainCamera;
+        private int maskBack;
+        private bool noConfigFlg;
+        private bool shiftKey;
+        private IniFile sPreferences;
+        private string triggerKey = "s";
+
+        private void Start()
+        {
+            sPreferences = Preferences;
+            var defaultVisibleLayers = new HashSet<int>
+            {
+                0,
+                1,
+                10
+            };
+            for (var i = 0; i < bLayerMask.Length; i++)
+                bLayerMask[i] = GetValueIni("Visible", $"Layer{i}", defaultVisibleLayers.Contains(i));
+
+            folderName = GetValueIni("File", "Folder", "ScreenShot");
+            fileNameHead = GetValueIni("File", "Head", "img");
+            fileNameEnd = GetValueIni("File", "End", "");
+            bgVisible = GetValueIni("Visible", "BG", false);
+            bloomOff = GetValueIni("Effect", "BloomOff", true);
+            altKey = GetValueIni("Command", "Alt", false);
+            ctrlKey = GetValueIni("Command", "Ctrl", true);
+            shiftKey = GetValueIni("Command", "Shift", false);
+            triggerKey = GetValueIni("Command", "Trigger", "s");
+            if (noConfigFlg) SaveConfig();
+        }
+
+        private T GetValueIni<T>(string section, string key, T @default)
+        {
+            bool TryParse(string value, out T resultVal)
+            {
+                try
+                {
+                    resultVal = (T) Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
+                    return true;
+                }
+                catch (Exception e)
+                {
+                    Debug.LogWarning($"Failed to parse {section} => {key} value {value} because {e.Message}");
+                    resultVal = default;
+                    return false;
+                }
+            }
+            
+            var iniKey = sPreferences[section][key];
+            if (iniKey != null && !string.IsNullOrEmpty(iniKey.Value) &&
+                TryParse(iniKey.Value, out var result)) return result;
+            iniKey.Value = Convert.ToString(@default, CultureInfo.InvariantCulture);
+            result = @default;
+            noConfigFlg = true;
+
+            return result;
+        }
+
+        private void Update()
+        {
+            var pressedAlt = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt);
+            var pressedCtrl = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
+            var pressedShift = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
+            if (altKey == pressedAlt && ctrlKey == pressedCtrl && shiftKey == pressedShift && Input.GetKeyDown(triggerKey))
+                StartCoroutine(ExecScreenShot());
+        }
+
+        private IEnumerator ExecScreenShot()
+        {
+            yield return new WaitForEndOfFrame();
+            mainCamera = Camera.main;
+            BackUpCamera();
+            
+            var ss = GetToukaScreenShot();
+            File.WriteAllBytes(GetTimeFileName(), ss.EncodeToPNG());
+            
+            // Actually unload textures and GC unused stuff to free up memory
+            yield return Resources.UnloadUnusedAssets();
+            GC.Collect();
+            
+            GameMain.Instance.SoundMgr.PlaySe("se022.ogg", false);
+        }
+        
+        private Texture2D GetToukaScreenShot()
+        {
+            var ss = GameMain.Instance.CMSystem.ScreenShotSuperSize switch
+            {
+                CMSystem.SSSuperSizeType.X1 => 1,
+                CMSystem.SSSuperSizeType.X2 => 2,
+                CMSystem.SSSuperSizeType.X4 => 4,
+                _ => 1
+            };
+
+            var aa = GameMain.Instance.CMSystem.Antialias switch
+            {
+                CMSystem.AntiAliasType.None => 0,
+                CMSystem.AntiAliasType.X2 => 1,
+                CMSystem.AntiAliasType.X4 => 4,
+                CMSystem.AntiAliasType.X8 => 8,
+                _ => 8,
+            };
+
+            var w = Screen.width * ss;
+            var h = Screen.height * ss;
+
+            var rt = RenderTexture.GetTemporary(w, h, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, aa);
+            rt.filterMode = FilterMode.Bilinear;
+            SetCameraMask();
+            
+            mainCamera.backgroundColor = new Color(0f, 0f, 0f, 1f);
+            var blackBgTex = RenderScreenShot(rt, w, h);
+            
+            mainCamera.backgroundColor = new Color(1f, 1f, 1f, 1f);
+            var whiteBgTex = RenderScreenShot(rt, w, h);
+            
+            ResetCamera();
+            mainCamera.targetTexture = null;
+            RenderTexture.ReleaseTemporary(rt);
+            
+            var blackPix = blackBgTex.GetPixels32();
+            var whitePix = whiteBgTex.GetPixels32();
+            var resultPix = new Color32[blackPix.Length];
+            
+            for (var i = 0; i < resultPix.Length; i++)
+            {
+                var wp = whitePix[i];
+                var bp = blackPix[i];
+                var diff = wp.r - bp.r;
+                if (diff < 0) diff = 0;
+                resultPix[i] = new Color32((byte)((wp.r + bp.r) >> 1), (byte)((wp.g + bp.g) >> 1), (byte)((wp.b + bp.b) >> 1), (byte) ~diff);
+            }
+            
+            var result = new Texture2D(w, h);
+            result.SetPixels32(resultPix);
+            
+            // Mark both for destroying so they can be unloaded by UnloadUnusedAssets
+            Destroy(blackBgTex);
+            Destroy(whiteBgTex);
+
+            return result;
+        }
+
+        private string GetTimeFileName(string postfix = "")
+        {
+            var targetFolder = Path.Combine(UTY.gameProjectPath, folderName);
+            if (!Directory.Exists(targetFolder)) Directory.CreateDirectory(targetFolder);
+            return Path.Combine(targetFolder, $"{fileNameHead}{DateTime.Now:yyyyMMddHHmmss}{postfix}{fileNameEnd}.png");
+        }
+
+        private void BackUpCamera()
+        {
+            maskBack = mainCamera.cullingMask;
+            bgColorBack = mainCamera.backgroundColor;
+            if (!bgVisible) bgActiveBack = GameMain.Instance.BgMgr.current_bg_object.activeSelf;
+            if (!bloomOff) return;
+            var bloom = (Bloom) fBloom.GetValue(GameMain.Instance.MainCamera);
+            bloomBack = bloom.enabled;
+        }
+
+        private void ResetCamera()
+        {
+            mainCamera.cullingMask = maskBack;
+            mainCamera.backgroundColor = bgColorBack;
+            if (!bgVisible) GameMain.Instance.BgMgr.current_bg_object.SetActive(bgActiveBack);
+            if (!bloomOff) return;
+            var bloom = (Bloom) fBloom.GetValue(GameMain.Instance.MainCamera);
+            bloom.enabled = bloomBack;
+        }
+
+        private void SetCameraMask()
+        {
+            var num = 0;
+            for (var i = 0; i < bLayerMask.Length; i++)
+                if (bLayerMask[i])
+                    num += 1 << i;
+            
+            mainCamera.cullingMask = num;
+            if (!bgVisible) GameMain.Instance.BgMgr.current_bg_object.SetActive(false);
+            if (!bloomOff) return;
+            var bloom = (Bloom) fBloom.GetValue(GameMain.Instance.MainCamera);
+            bloom.enabled = false;
+        }
+
+        private Texture2D RenderScreenShot(RenderTexture rt, int w, int h)
+        {
+            mainCamera.targetTexture = rt;
+            mainCamera.Render();
+            var texture2D = new Texture2D(w, h, TextureFormat.ARGB32, false);
+            var prev = RenderTexture.active;
+            RenderTexture.active = rt;
+            texture2D.ReadPixels(new Rect(0f, 0f, w, h), 0, 0, false);
+            RenderTexture.active = prev;
+            return texture2D;
+        }
+    }
+}