| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using GadgetCore.API;
- using GadgetCore.API.ConfigMenu;
- using System;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- namespace ScreenshotMode
- {
- [Gadget("ScreenshotMode", RequiredOnClients: false)]
- public class ScreenshotMode : Gadget<ScreenshotMode>
- {
- public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
- public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
- public override IGadgetConfigMenu GetConfigMenu() { return null; }
- public override string GetModDescription()
- {
- return "A mod that adds options to hide hud elements and the player to be able to take clean screenshots.";
- }
- protected override void Initialize()
- {
- Logger.Log("Screenshot Mode v" + Info.Mod.Version);
- Core.logger = Logger;
- SceneManager.sceneLoaded += OnSceneLoaded;
- }
- internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
- {
- if (scene.buildIndex == 1)
- {
- AddOptions();
- }
- }
- private static void AddOptions()
- {
- try
- {
- var options = GameObject.Find("Main Camera").transform.Find("menuPause").Find("optionsmenu").gameObject;
- var fulls = options.transform.Find("bFullscreen");
- fulls.localPosition = new Vector3(0.446f, 0.284f, 0.39f);
- var mode = GameObject.Instantiate(options.transform.Find("bFullscreen").gameObject);
- mode.transform.SetParent(options.transform);
- mode.transform.localPosition = new Vector3(0.446f, 0.431f, 0.39f);
- mode.transform.localEulerAngles = fulls.transform.localEulerAngles;
- mode.transform.localScale = fulls.transform.localScale;
- mode.name = "bScreenshotMode";
- Update();
- }
- catch (Exception e) { Core.logger.Log(e); }
- }
- internal static void Update()
- {
- var text = "";
- switch (Core.state)
- {
- case 0:
- text = "Screenshot Mode";
- SetHudState(true);
- SetPlayerState(true);
- break;
- case 1:
- text = "No Hud";
- SetHudState(false);
- SetPlayerState(true);
- break;
- case 2:
- text = "No Hud/Player";
- SetHudState(false);
- SetPlayerState(false);
- break;
- }
- var options = GameObject.Find("Main Camera").transform.Find("menuPause").Find("optionsmenu").gameObject;
- var mode = options.transform.Find("bScreenshotMode");
- mode.transform.GetChild(0).GetComponent<TextMesh>().text = text;
- mode.transform.GetChild(0).GetChild(0).GetComponent<TextMesh>().text = text;
- }
- private static void SetPlayerState(bool visible)
- {
- if (MenuScript.player != null)
- {
- SetState(MenuScript.player.transform.Find("e").Find("newplayer"), visible);
- SetState(MenuScript.player.transform.Find("W"), visible);
- }
- }
- private static void SetHudState(bool visible)
- {
- SetState(GameObject.Find("Main Camera").transform.Find("inventoryBar"), visible);
- SetState(GameObject.Find("Main Camera").transform.Find("barObjective"), visible);
- SetState(GameObject.Find("Main Camera").transform.Find("buildBar"), visible);
- SetState(GameObject.Find("Main Camera").transform.Find("txtBuild"), visible, 0);
- }
- private static void SetState(Transform t, bool v, int defaultRot = -180)
- {
- t.localEulerAngles = new Vector3(t.localEulerAngles.x, v ? defaultRot : 90, t.localEulerAngles.z);
- }
- }
- }
|