Exemplo n.º 1
0
        public static bool PoseSavePatch(OCIChar _ociChar, ref string _name)
        {
            var filename = $"{_name}_{DateTime.Now.ToString("yyyy_MMdd_HHmm_ss_fff")}{PngExt}";
            var path     = Path.Combine(SavePath.Value, filename);
            var fileInfo = new PauseCtrl.FileInfo(_ociChar);

            try
            {
                using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write))
                    using (var binaryWriter = new BinaryWriter(fileStream))
                    {
                        var buffer = Studio.Studio.Instance.gameScreenShot.CreatePngScreen(320, 180, false, false);
                        binaryWriter.Write(buffer);
                        binaryWriter.Write(PauseCtrl.saveIdentifyingCode);
                        binaryWriter.Write(PauseCtrl.saveVersion);
                        binaryWriter.Write(_ociChar.oiCharInfo.sex);
                        binaryWriter.Write(_name);
                        fileInfo.Save(binaryWriter);
                    }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Message, "PosePng plugin save path has not been set properly");
                Logger.Log(LogLevel.Error, ex);
            }

            return(false);
        }
Exemplo n.º 2
0
        private static bool PoseSavePatch(OCIChar _ociChar, ref string _name)
        {
            var filename = $"{DateTime.Now:yyyy_MMdd_HHmm_ss_fff}.png";

            if (ConfigPoseNamePrefix.Value && !_name.IsNullOrEmpty())
            {
                filename = $"{_name}_" + filename;
            }

            if (!ConfigSavePng.Value)
            {
                return(true);
            }

            var path     = Path.Combine(UserData.Create(GetFolder()), filename);
            var fileInfo = new PauseCtrl.FileInfo(_ociChar);

            try
            {
                using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write))
                    using (var binaryWriter = new BinaryWriter(fileStream))
                    {
#if PH
                        var buffer = Studio.Studio.Instance.sceneInfo.CreatePngScreen(320, 180);
#else
                        var buffer = Studio.Studio.Instance.gameScreenShot.CreatePngScreen(320, 180);
#endif

                        Texture2D screenshot = TextureFromBytes(buffer, mipmaps: false);
                        screenshot = OverwriteTexture(screenshot, Watermark, 0, screenshot.height - Watermark.height);
                        buffer     = screenshot.EncodeToPNG();

                        binaryWriter.Write(buffer);
                        binaryWriter.Write(PauseCtrl.saveIdentifyingCode);
                        binaryWriter.Write(PauseCtrl.saveVersion);
                        binaryWriter.Write(_ociChar.oiCharInfo.sex);
                        binaryWriter.Write(_name);
                        fileInfo.Save(binaryWriter);
                    }
            }
            catch (Exception ex)
            {
                Plugin.Logger.LogError("Failed to save pose .png, falling back to original game code.");
                Plugin.Logger.LogError(ex);
                return(true);
            }

            return(false);
        }