Example #1
0
        void RenderGeneralWindow(int id)
        {
            // using (var scope = new GUILayout.VerticalScope("box"))
            // {
            if (GUILayout.Button("Hello World"))
            {
                ModLogger.Log("{Mod Manager} Hello World");
            }

            if (GUILayout.Button("Main menu"))
            {
                _gameRoot.MainMenu.ExitSession();
            }

            if (GUILayout.Button("Quit Game"))
            {
                _gameRoot.MainMenu.ExitGame();

                ModLogger.Log("Quit Game!");
            }

            foreach (var pair in _windows)
            {
                _windows[pair.Key].Activated = GUILayout.Toggle(pair.Value.Activated, pair.Key);
            }
            // }

            GUI.DragWindow();
        }
Example #2
0
        void Awake()
        {
            Harmony harmony = new Harmony("com.github.seppahbaws.gc-testmod");

            harmony.PatchAll(Assembly.GetExecutingAssembly());
            ModLogger.Log("Loaded!");
        }
Example #3
0
        void RenderSceneWindow(int id)
        {
            const float Y_OFFSET = 20.0f;

            GUI.Label(new Rect(20, 20, 300, 20), $"{_sceneObjects.Count} roots in scene");

            if (GUI.Button(new Rect(150, 20, 100, 20), "Refresh scene"))
            {
                RefreshSceneTree();
            }

            sceneScrollPos = GUI.BeginScrollView(new Rect(10, 50, 280, 450), sceneScrollPos,
                                                 new Rect(0, 0, 280, _sceneObjects.Count * Y_OFFSET));
            for (int i = 0; i < _sceneObjects.Count; i++)
            {
                float yPos = i * Y_OFFSET;

                if (_sceneObjects[i])
                {
                    // GUILayout.BeginHorizontal();
                    if (GUI.Button(new Rect(0, yPos, 20, 20), "+"))
                    {
                        SelectInspectObject(_sceneObjects[i]);
                        ModLogger.Log($"ModManager - Selecting {_sceneObjects[i].name}");
                    }

                    GUI.Label(new Rect(30, yPos, 300, 20), $"{_sceneObjects[i].name}");
                    // GUILayout.EndHorizontal();
                }
            }

            GUI.EndScrollView(true);

            GUI.DragWindow();
        }
Example #4
0
        void RefreshSceneTree()
        {
            _sceneObjects = GameObjectUtil.FindSceneRoots();
            _sceneObjects.OrderBy(obj => obj.name).ToList();

            ModLogger.Log($"Found {_sceneObjects.Count} roots in the game scene");
        }
        static void Postfix(GameRoot __instance)
        {
            _modManager = UnityEngine.Object.Instantiate <GameObject>(new GameObject("SeppahBaws_TestModManager"));
            ModManager manager = _modManager.AddComponent <ModManager>();

            manager.SetGameRoot(__instance);

            ModLogger.Log("Game Root Awake!");
        }
Example #6
0
        public static void DrawGUI()
        {
            ModLogger.Log("DrawGUI handler is being called!");

            if (GUI.Button(new Rect(10, 10, 150, 100), "Hello World"))
            {
                ModLogger.Log("Hello World from custom button!");
            }
        }
Example #7
0
 public void SetGameRoot(GameRoot gameRoot)
 {
     _gameRoot = gameRoot;
     // GameSettings.SetBool("console", true);
     ModLogger.Log("{Mod Manager} " + $"found {GameSettings.Entries.Count} GameSettings entries");
     foreach (var pair in GameSettings.Entries)
     {
         ModLogger.Log("{Mod Manager} Setting \"" + pair.Key + "\" : " + pair.Value);
     }
     ModLogger.Log("{Mod Manager} Console activation key: " + gameRoot.ConsolePrefab.ActivationKey);
 }
Example #8
0
		static bool Prefix(MainMenuController __instance, ref GameRoot ____root)
		{
			ModLogger.Log("{MainMenuController} -- altered headstart called!");
			BackendThreadManager.StartParams parameters = new BackendThreadManager.StartParams();
			parameters.Savegame = (string)null;
			parameters.Mod = "custom/freeplay";
			bool useLoginWindow = false;
			____root.InitializeSession(MainMenu.StartMode.SingleplayerWithMod, parameters, useLoginWindow);
			
			return false; // skip the original method
		}
        static void Postfix(SessionManager __instance)
        {
            SessionManagerStatic.Instance = __instance;

            ModLogger.Log("{SessionManager} " + $"{SessionManagerStatic.Instance.AssetCollection.Models.Assets.Count} models found in AssetCollection!");

            string path = Path.Combine(Application.dataPath, "AssetCollection.json");

            using (StreamWriter writer = new StreamWriter(path, false))
            {
                string json = JsonUtility.ToJson(SessionManagerStatic.Instance.AssetCollection);
                writer.Write(json);
            }
        }
Example #10
0
        void RenderInspectChildrenWindow(int id)
        {
            GUI.Label(new Rect(20, 20, 300, 20),
                      $"{_inspectedObjChildren.Count} children in {_inspectedObject.name}");

            if (GUI.Button(new Rect(20, 45, 100, 20), "Dump Object"))
            {
                const string path = @"E:/GoodCompanyDump.txt";
                SceneDumper.Dump(_inspectedObject, path);
                ModLogger.Log($"Object {_inspectedObject} dumped to {path}");
            }

            if (_inspectedObject.transform.parent)
            {
                if (GUI.Button(new Rect(130, 45, 100, 20), "View parent"))
                {
                    SelectInspectObject(_inspectedObject.transform.parent.gameObject);
                }
            }

            const float Y_OFFSET = 20.0f;

            inspectChildrenScrollPos = GUI.BeginScrollView(new Rect(10, 70, 280, 450), inspectChildrenScrollPos,
                                                           new Rect(0, 0, 260, _inspectedObjChildren.Count * Y_OFFSET));
            for (int i = 0; i < _inspectedObjChildren.Count; i++)
            {
                float yPos = i * Y_OFFSET;

                if (GUI.Button(new Rect(0, yPos, 20, 20), "+"))
                {
                    SelectInspectObject(_inspectedObjChildren[i].gameObject);
                }

                if (GUI.Button(new Rect(25, yPos, 20, 20), "x"))
                {
                    GameObject.Destroy(_inspectedObjChildren[i].gameObject);
                    SelectInspectObject(_inspectedObject);
                }

                GUI.Label(new Rect(50, yPos, 300, 20), _inspectedObjChildren[i].gameObject.name);
            }

            GUI.EndScrollView(true);

            GUI.DragWindow();
        }
Example #11
0
        static bool Prefix(uint buildingID)
        {
            ModLogger.Log($"Unlocking Building ID: {buildingID}");

            return(false);            // Skip the actual building unlocking stuff
        }
Example #12
0
        static void Postfix(MainMenu __instance,
                            ref GUIButtonMainmenu ____quitGameBtn,
                            GUIButtonMainmenu ____settingsBtn,
                            Settings ____settings,
                            MainMenu.IControl ____control,
                            ref MainMenu.SessionType ____sessionType,
                            ref TMP_Text ____version)
        {
            ____version.color              = Color.magenta;
            ____version.margin             = Vector4.one;
            ____version.transform.position = new Vector3(-10, 5, 1);

            // Don't show the disclaimer when going to the main menu
            // typeof(MainMenu).GetMethod("ShowDisclaimer", BindingFlags.NonPublic | BindingFlags.Instance)
            //  .Invoke(__instance, new object[] { false });

            // Removes the "are you sure you want to quit" warning
            // ____quitGameBtn.OnClick.RemoveAllListeners();
            // ____quitGameBtn.OnClick.AddListener(new UnityAction(____control.QuitToDesktop));


            // Instantiate the text
            // TMP_Text modInfoText = UnityEngine.Object.Instantiate<TMP_Text>(new TMP_Text(), new Vector3(500, 200, 0), Quaternion.identity);
            // // TMP_Text modInfoText = new TMP_Text();
            // modInfoText.text = "Hello World";
            // modInfoText.color = new Color(200, 200, 200);

            // GUIButtonSimple btn = new GUIButtonSimple();

            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(____settings.gameObject);

            UnityEngine.Object.Destroy((UnityEngine.Object)gameObject.GetComponent <ChooseSaveLoadFile>());
            MainMenu_Initialize_Patch._modsPanel = gameObject.AddComponent <ModsPanel>();
            MainMenu_Initialize_Patch._modsPanel.Initialize();
            MainMenu_Initialize_Patch._modsButton      = UnityEngine.Object.Instantiate <GUIButtonMainmenu>(____settingsBtn);
            MainMenu_Initialize_Patch._modsButton.name = "ModsBtn";
            MainMenu_Initialize_Patch._modsButton.transform.SetParent(____settingsBtn.transform.parent);
            MainMenu_Initialize_Patch._modsButton.transform.position += Vector3.up * 50f;
            MainMenu_Initialize_Patch._modsButton.GetComponentInChildren <TextMeshProUGUI>(true).text = "Mods";
            MainMenu_Initialize_Patch._modsButton.GetComponentInChildren <LocalizeThis>().enabled     = false;
            MainMenu_Initialize_Patch._modsButton.transform.SetSiblingIndex(MainMenu_Initialize_Patch._modsButton.transform.GetSiblingIndex() - 1);
            MainMenu_Initialize_Patch._modsButton.OnClick.AddListener((UnityAction)(() =>
            {
                // if (!MainMenu_Initialize_Patch._modsPanel.gameObject.activeSelf)
                // {
                //  ModLogger.Log("{ModsPanel} Opening!");
                //  MainMenu_Initialize_Patch._modsPanel.Initialize();
                //  typeof(MainMenu).GetMethod("ShowContent", BindingFlags.Instance | BindingFlags.NonPublic).Invoke((object)__instance, new object[2]
                //  {
                //      (object) MainMenu_Initialize_Patch._modsPanel.gameObject,
                //      (object) MainMenu_Initialize_Patch._modsButton
                //  });
                // }
                // else
                // {
                //  ModLogger.Log("{ModsPanel} Closing!");
                //  typeof(MainMenu).GetMethod("HideCurrentContent", BindingFlags.Instance | BindingFlags.NonPublic).Invoke((object)__instance, (object[])null);
                // }

                ____control.StartHeadstartGame();
            }));

            // Test player character in main menu.
            // CharacterLookManager.

            // Test spawn object.
            // _testObj = GameObject.CreatePrimitive(PrimitiveType.Cube);
            // _testObj.transform.Translate(0, 0, 0);
            // _testObj.transform.localScale = Vector3.one * 10.0f;

            // AssetBundle test
            // AssetBundle myAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.dataPath, "../CustomAssets/mytestbundle"));
            // var prefab = myAssetBundle.LoadAsset<GameObject>("test");
            // _testObj = GameObject.Instantiate(prefab);
            // _testObj.transform.Translate(0, 0, 0);
            // _testObj.transform.localScale = Vector3.one * 5.0f;

            Transform    startRoot = Camera.main.gameObject.transform.parent;
            FollowCamera followCam = GameObject.Instantiate(new FollowCamera());

            followCam.transform.SetParent(startRoot);
            Camera.main.enabled          = false;
            followCam.MainCamera.enabled = true;
            followCam.SetTargetObject(_testObj.transform);
            // Camera.main.GetComponent<FollowCamera>().SetTargetObject(_testObj.transform);
            // End Test player character in main menu

            ModLogger.Log("Main menu initialized! version text should be magenta now.");
        }
Example #13
0
 static void Postfix(MainMenu __instance, TMP_Text ____version)
 {
     ____version.color = Color.magenta;
     // ____version.text = "Test Test";
     ModLogger.Log("Toggled settings menu!");
 }
Example #14
0
 void Awake()
 {
     ModLogger.Log("{Mod Manager} Awake()");
     Instance = this;
 }