using System.Collections; using System.IO; using System; using UnityEngine; using RPGCreationKit; using RPGCreationKit.SaveSystem; using UnityEngine.UI; public class ScreenshotTool : MonoBehaviour { [Header("Game Objects")] [SerializeField] private GameObject UI; [SerializeField] private Slider superSizeSlider; [SerializeField] private INIReader INI; [Header("Fills out on initialization")] [SerializeField] private string outputPath; [SerializeField] private string filePrefix; [SerializeField] private string lastSavedFileName; [SerializeField] private string ImageName; [SerializeField] private int SSCount = 0; [SerializeField, Range(0, 3)] public int Quality = 3; [SerializeField] private string Extension = "EXR"; private bool IsActing = false; void Start() { outputPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments)+@"\My Games\Firstborn\Screenshots"; if (Directory.Exists(outputPath) == false){ Directory.CreateDirectory(outputPath); } InitializeSettings(); } private void InitializeSettings() { SSCount = INI.ReadSettingInt("Screenshot Tool", "Screenshot", 0); superSizeSlider.value = (float)INI.ReadSettingInt("Screenshot Tool", "ScreenshotMultiplier", 0); } public void CaptureScreenshot() { if (IsActing == false) { IsActing = true; PlayerData data = SaveSystemManager.instance.saveFile.PlayerData; string saveFolder = Path.Combine(outputPath, data.playerName); if (Directory.Exists(saveFolder) == false) { Directory.CreateDirectory(saveFolder); } if (Directory.Exists(saveFolder)) { filePrefix = data.playerLocation; ImageName = SSCount + "_" + filePrefix + "." + Extension; string fileName = Path.Combine(saveFolder, ImageName); UI.SetActive(false); ScreenCapture.CaptureScreenshot(fileName, (int)superSizeSlider.value); StartCoroutine(UIOn()); } } else { Debug.Log("We are already taking a screenshot!"); } } public void SaveSuperSizeSlider() { INI.SaveSettingInt("Screenshot Tool", "ScreenshotMultiplier", (int)superSizeSlider.value); } IEnumerator UIOn() { yield return new WaitForSeconds(1f); UI.SetActive(true); AlertMessage.instance.InitAlertMessage("Saved as: " + ImageName, 3f); SSCount += 1; IsActing = false; INI.SaveSettingInt("Screenshot Tool", "Screenshot", SSCount); } public void SetQuality(int A) { Quality = A; if (A == 3) { Extension = "EXR"; } else if (A == 2) { Extension = "TIFF"; } else if (A == 1) { Extension = "PNG"; } else if (A == 0) { Extension = "JPG"; } INI.SaveSettingInt("Screenshot Tool", "ScreenshotExtension", A); } }