123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityInjector;
- using UnityInjector.Attributes;
- namespace COM3D2.MeidoPhotoStudio.Plugin
- {
- [PluginName("Meido Photo Studio"), PluginVersion("0.0.0")]
- public class MeidoPhotoStudio : PluginBase
- {
- private static MonoBehaviour instance;
- private WindowManager windowManager;
- private MeidoManager meidoManager;
- private EnvironmentManager environmentManager;
- private MessageWindowManager messageWindowManager;
- private Constants.Scene currentScene;
- private bool initialized = false;
- private bool isActive = false;
- private bool uiActive = false;
- private MeidoPhotoStudio()
- {
- MeidoPhotoStudio.instance = this;
- }
- private void Awake()
- {
- DontDestroyOnLoad(this);
- Translation.Initialize("en");
- Constants.Initialize();
- }
- private void Start()
- {
- SceneManager.sceneLoaded += OnSceneLoaded;
- }
- private void Update()
- {
- if (currentScene == Constants.Scene.Daily)
- {
- if (Input.GetKeyDown(KeyCode.F6))
- {
- if (!initialized)
- {
- Initialize();
- windowManager.MainWindowVisible = true;
- }
- else
- {
- ReturnToMenu();
- }
- }
- if (isActive)
- {
- bool qFlag = Input.GetKey(KeyCode.Q);
- if (!qFlag && Input.GetKeyDown(KeyCode.S))
- {
- StartCoroutine(TakeScreenShot());
- }
- meidoManager.Update();
- windowManager.Update();
- environmentManager.Update();
- }
- }
- }
- private IEnumerator TakeScreenShot()
- {
-
- GameObject editUI = GameObject.Find("/UI Root/Camera");
- GameObject fpsViewer =
- UTY.GetChildObject(GameMain.Instance.gameObject, "SystemUI Root/FpsCounter", false);
- GameObject sysDialog =
- UTY.GetChildObject(GameMain.Instance.gameObject, "SystemUI Root/SystemDialog", false);
- GameObject sysShortcut =
- UTY.GetChildObject(GameMain.Instance.gameObject, "SystemUI Root/SystemShortcut", false);
- if (editUI != null) editUI.SetActive(false);
- fpsViewer.SetActive(false);
- sysDialog.SetActive(false);
- sysShortcut.SetActive(false);
- uiActive = false;
- List<Meido> activeMeidoList = this.meidoManager.ActiveMeidoList;
- bool[] isIK = new bool[activeMeidoList.Count];
- for (int i = 0; i < activeMeidoList.Count; i++)
- {
- Meido meido = activeMeidoList[i];
- isIK[i] = meido.IsIK;
- if (meido.IsIK) meido.SetIKActive(false);
- }
- GizmoRender.UIVisible = false;
- yield return new WaitForEndOfFrame();
-
- int[] superSize = new[] { 1, 2, 4 };
- int selectedSuperSize = superSize[(int)GameMain.Instance.CMSystem.ScreenShotSuperSize];
- Application.CaptureScreenshot(Utility.ScreenshotFilename(), selectedSuperSize);
- GameMain.Instance.SoundMgr.PlaySe("se022.ogg", false);
- yield return new WaitForEndOfFrame();
-
- uiActive = true;
- if (editUI != null) editUI.SetActive(true);
- fpsViewer.SetActive(GameMain.Instance.CMSystem.ViewFps);
- sysDialog.SetActive(true);
- sysShortcut.SetActive(true);
- for (int i = 0; i < activeMeidoList.Count; i++)
- {
- Meido meido = activeMeidoList[i];
- if (isIK[i]) meido.SetIKActive(true);
- }
- GizmoRender.UIVisible = true;
- }
- private void OnGUI()
- {
- if (uiActive)
- {
- windowManager.OnGUI();
- }
- }
- private void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
- {
- currentScene = (Constants.Scene)scene.buildIndex;
- }
- private void ReturnToMenu()
- {
- if (meidoManager.IsBusy) return;
- meidoManager.DeactivateMeidos();
- environmentManager.Deactivate();
- messageWindowManager.Deactivate();
- isActive = false;
- uiActive = false;
- initialized = false;
- windowManager.MainWindowVisible = false;
- GameMain.Instance.SoundMgr.PlayBGM("bgm009.ogg", 1f, true);
- GameObject go = GameObject.Find("UI Root").transform.Find("DailyPanel").gameObject;
- go.SetActive(true);
- bool isNight = GameMain.Instance.CharacterMgr.status.GetFlag("時間帯") == 3;
- if (isNight)
- {
- GameMain.Instance.BgMgr.ChangeBg("ShinShitsumu_ChairRot_Night");
- }
- else
- {
- GameMain.Instance.BgMgr.ChangeBg("ShinShitsumu_ChairRot");
- }
- GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
- GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0.5609447f, 1.380762f, -1.382336f), true);
- GameMain.Instance.MainCamera.SetDistance(1.6f, true);
- GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(245.5691f, 6.273283f), true);
- }
- private void Initialize()
- {
- initialized = true;
- meidoManager = new MeidoManager();
- meidoManager.BeginCallMeidos += (s, a) => this.uiActive = false;
- meidoManager.EndCallMeidos += (s, a) => this.uiActive = true;
- environmentManager = new EnvironmentManager();
- messageWindowManager = new MessageWindowManager();
- windowManager = new WindowManager(meidoManager, environmentManager, messageWindowManager);
- environmentManager.Initialize();
- isActive = true;
- uiActive = true;
- #region maid stuff
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #endregion
- GameObject dailyPanel = GameObject.Find("UI Root").transform.Find("DailyPanel").gameObject;
- dailyPanel.SetActive(false);
- }
- }
- }
|