Exemplo n.º 1
0
        public void CreateConsoleUI()
        {
            AssetBundle ab = LoadAssets.LoadBundle(this, "console.unity3d");

            UI = ab.LoadAsset <GameObject>("MSCLoader Console.prefab");
            Texture2D cursor = ab.LoadAsset <Texture2D>("resizeCur.png");

            ab.Unload(false);
            UI      = Object.Instantiate(UI);
            console = UI.AddComponent <ConsoleView>();
            console.viewContainer = UI.transform.GetChild(0).gameObject;
            console.inputField    = console.viewContainer.transform.GetChild(0).gameObject.GetComponent <InputField>();
            console.viewContainer.transform.GetChild(1).gameObject.GetComponent <Button>().onClick.AddListener(() => console.runCommand());
            console.logTextArea = console.viewContainer.transform.GetChild(2).GetChild(0).gameObject.GetComponent <Text>();
            console.viewContainer.transform.GetChild(4).gameObject.AddComponent <ConsoleUIResizer>().logview   = console.viewContainer.transform.GetChild(2).gameObject;
            console.viewContainer.transform.GetChild(4).gameObject.GetComponent <ConsoleUIResizer>().scrollbar = console.viewContainer.transform.GetChild(3).gameObject;
            console.viewContainer.transform.GetChild(4).gameObject.GetComponent <ConsoleUIResizer>().cursor    = cursor;
            EventTrigger trigger = console.viewContainer.transform.GetChild(4).gameObject.GetComponent <EventTrigger>();

            EventTrigger.Entry entry = new EventTrigger.Entry();
            entry.eventID = EventTriggerType.PointerEnter;
            entry.callback.AddListener((eventData) => { console.viewContainer.transform.GetChild(4).gameObject.GetComponent <ConsoleUIResizer>().OnMouseEnter(); });
            trigger.delegates.Add(entry);
            entry         = new EventTrigger.Entry();
            entry.eventID = EventTriggerType.PointerExit;
            entry.callback.AddListener((eventData) => { console.viewContainer.transform.GetChild(4).gameObject.GetComponent <ConsoleUIResizer>().OnMouseExit(); });
            trigger.delegates.Add(entry);

            UI.transform.SetParent(GameObject.Find("MSCLoader Canvas").transform, false);
        }
Exemplo n.º 2
0
        public void CreateSettingsUI()
        {
            AssetBundle ab = LoadAssets.LoadBundle(this, "settingsui.unity3d");

            UI = ab.LoadAsset("MSCLoader Settings.prefab") as GameObject;

            ModButton         = ab.LoadAsset("ModButton.prefab") as GameObject;
            ModButton_Invalid = ab.LoadAsset("ModButton_Invalid.prefab") as GameObject;
            ModViewLabel      = ab.LoadAsset("ModViewLabel.prefab") as GameObject;

            KeyBind = ab.LoadAsset("KeyBind.prefab") as GameObject;

            Checkbox = ab.LoadAsset("Checkbox.prefab") as GameObject;
            setBtn   = ab.LoadAsset("Button.prefab") as GameObject;
            slider   = ab.LoadAsset("Slider.prefab") as GameObject;

            UI = GameObject.Instantiate(UI);
            UI.AddComponent <ModUIDrag>();
            settings = UI.AddComponent <SettingsView>();
            UI.GetComponent <SettingsView>().settingView          = UI;
            UI.GetComponent <SettingsView>().settingViewContainer = UI.transform.GetChild(0).gameObject;

            UI.GetComponent <SettingsView>().modList = UI.GetComponent <SettingsView>().settingViewContainer.transform.GetChild(3).gameObject;
            UI.GetComponent <SettingsView>().modView = UI.GetComponent <SettingsView>().modList.transform.GetChild(0).gameObject;
            UI.GetComponent <SettingsView>().modInfo = UI.GetComponent <SettingsView>().settingViewContainer.transform.GetChild(2).gameObject;
            GameObject ModSettingsView = UI.GetComponent <SettingsView>().modInfo.transform.GetChild(0).gameObject;

            UI.GetComponent <SettingsView>().ModKeyBinds  = UI.GetComponent <SettingsView>().settingViewContainer.transform.GetChild(1).gameObject;
            UI.GetComponent <SettingsView>().keybindsList = UI.GetComponent <SettingsView>().ModKeyBinds.transform.GetChild(0).GetChild(4).gameObject;

            UI.GetComponent <SettingsView>().modSettings     = UI.GetComponent <SettingsView>().settingViewContainer.transform.GetChild(4).gameObject;
            UI.GetComponent <SettingsView>().modSettingsList = UI.GetComponent <SettingsView>().modSettings.transform.GetChild(0).GetChild(4).gameObject;

            UI.GetComponent <SettingsView>().goBackBtn = UI.GetComponent <SettingsView>().settingViewContainer.transform.GetChild(0).GetChild(0).gameObject;
            UI.GetComponent <SettingsView>().goBackBtn.GetComponent <Button>().onClick.AddListener(() => UI.GetComponent <SettingsView>().goBack());
            UI.GetComponent <SettingsView>().DisableMod = ModSettingsView.transform.GetChild(5).GetComponent <Toggle>();
            UI.GetComponent <SettingsView>().DisableMod.onValueChanged.AddListener(UI.GetComponent <SettingsView>().disableMod);
            ModSettingsView.transform.GetChild(7).GetComponent <Button>().onClick.AddListener(() => UI.GetComponent <SettingsView>().goToKeybinds());
            ModSettingsView.transform.GetChild(9).GetComponent <Button>().onClick.AddListener(() => UI.GetComponent <SettingsView>().goToSettings());

            UI.GetComponent <SettingsView>().ModButton         = ModButton;
            UI.GetComponent <SettingsView>().ModButton_Invalid = ModButton_Invalid;
            UI.GetComponent <SettingsView>().ModViewLabel      = ModViewLabel;
            UI.GetComponent <SettingsView>().KeyBind           = KeyBind;

            UI.GetComponent <SettingsView>().Checkbox = Checkbox;
            UI.GetComponent <SettingsView>().setBtn   = setBtn;
            UI.GetComponent <SettingsView>().slider   = slider;

            UI.GetComponent <SettingsView>().IDtxt      = ModSettingsView.transform.GetChild(0).GetComponent <Text>();
            UI.GetComponent <SettingsView>().Nametxt    = ModSettingsView.transform.GetChild(1).GetComponent <Text>();
            UI.GetComponent <SettingsView>().Versiontxt = ModSettingsView.transform.GetChild(2).GetComponent <Text>();
            UI.GetComponent <SettingsView>().Authortxt  = ModSettingsView.transform.GetChild(3).GetComponent <Text>();

            UI.transform.SetParent(GameObject.Find("MSCLoader Canvas").transform, false);
            settings.setVisibility(false);
            ab.Unload(false);
        }
Exemplo n.º 3
0
        public void CreateSettingsUI()
        {
            AssetBundle ab = LoadAssets.LoadBundle(this, "settingsui.unity3d");

            UI = ab.LoadAsset <GameObject>("MSCLoader Settings.prefab");

            ModButton         = ab.LoadAsset <GameObject>("ModButton.prefab");
            ModButton_Invalid = ab.LoadAsset <GameObject>("ModButton_Invalid.prefab");

            ModLabel = ab.LoadAsset <GameObject>("ModViewLabel.prefab");

            KeyBind = ab.LoadAsset <GameObject>("KeyBind.prefab");

            //For mod settings
            Checkbox = ab.LoadAsset <GameObject>("Checkbox.prefab");
            setBtn   = ab.LoadAsset <GameObject>("Button.prefab");
            slider   = ab.LoadAsset <GameObject>("Slider.prefab");
            textBox  = ab.LoadAsset <GameObject>("TextBox.prefab");
            header   = ab.LoadAsset <GameObject>("Header.prefab");

            UI = GameObject.Instantiate(UI);
            UI.AddComponent <ModUIDrag>();

            settings    = UI.AddComponent <SettingsView>();
            settings.ms = this;
            settings.settingViewContainer = UI.transform.GetChild(0).gameObject;
            settings.modList = settings.settingViewContainer.transform.GetChild(3).gameObject;
            settings.modView = settings.modList.transform.GetChild(0).gameObject;
            settings.modInfo = settings.settingViewContainer.transform.GetChild(2).gameObject;
            GameObject ModSettingsView = settings.modInfo.transform.GetChild(0).gameObject;

            settings.ModKeyBinds     = settings.settingViewContainer.transform.GetChild(1).gameObject;
            settings.keybindsList    = settings.ModKeyBinds.transform.GetChild(0).GetChild(4).gameObject;
            settings.modSettings     = settings.settingViewContainer.transform.GetChild(4).gameObject;
            settings.modSettingsList = settings.modSettings.transform.GetChild(0).GetChild(4).gameObject;
            settings.coreModCheckbox = settings.settingViewContainer.transform.GetChild(6).GetChild(0).GetComponent <Toggle>();
            settings.coreModCheckbox.onValueChanged.AddListener(delegate { settings.ToggleCoreCheckbox(); });
            settings.noOfMods  = settings.settingViewContainer.transform.GetChild(6).GetChild(1).GetComponent <Text>();
            settings.goBackBtn = settings.settingViewContainer.transform.GetChild(0).GetChild(1).gameObject;
            settings.goBackBtn.GetComponent <Button>().onClick.AddListener(() => settings.goBack());
            settings.settingViewContainer.transform.GetChild(0).GetChild(2).GetComponent <Button>().onClick.AddListener(() => settings.setVisibility(false));
            settings.DisableMod = ModSettingsView.transform.GetChild(5).GetComponent <Toggle>();
            settings.DisableMod.onValueChanged.AddListener(settings.disableMod);

            settings.IDtxt      = ModSettingsView.transform.GetChild(0).GetComponent <Text>();
            settings.Nametxt    = ModSettingsView.transform.GetChild(1).GetComponent <Text>();
            settings.Versiontxt = ModSettingsView.transform.GetChild(2).GetComponent <Text>();
            settings.Authortxt  = ModSettingsView.transform.GetChild(3).GetComponent <Text>();

            UI.transform.SetParent(GameObject.Find("MSCLoader Canvas").transform, false);
            settings.setVisibility(false);
            ab.Unload(false);
        }
Exemplo n.º 4
0
        static void LoadCoreAssets()
        {
            ModConsole.Print("Loading core assets...");
            AssetBundle ab = LoadAssets.LoadBundle(new ModCore(), "core.unity3d");

            guiskin          = ab.LoadAsset("MSCLoader.guiskin") as GUISkin;
            ModUI.messageBox = ab.LoadAsset("MSCLoader MB.prefab") as GameObject;
            mainMenuInfo     = ab.LoadAsset("MSCLoader Info.prefab") as GameObject;
            loading          = ab.LoadAsset("LoadingMods.prefab") as GameObject;
            loading.SetActive(false);
            loading = GameObject.Instantiate(loading);
            loading.transform.SetParent(GameObject.Find("MSCLoader Canvas").transform, false);
            ModConsole.Print("Loading core assets completed!");
            ab.Unload(false); //freeup memory
        }
Exemplo n.º 5
0
        public void CreateSettingsUI()
        {
            AssetBundle ab = LoadAssets.LoadBundle(this, "settingsui.unity3d");

            UI = ab.LoadAsset <GameObject>("MSCLoader Settings.prefab");

            ModButton         = ab.LoadAsset <GameObject>("ModButton.prefab");
            ModButton_Invalid = ab.LoadAsset <GameObject>("ModButton_Invalid.prefab");

            ModLabel = ab.LoadAsset <GameObject>("ModViewLabel.prefab");

            KeyBind = ab.LoadAsset <GameObject>("KeyBind.prefab");

            Button_ms = ab.LoadAsset <GameObject>("Button_ms.prefab");
            // For mod settings
            Checkbox = ab.LoadAsset <GameObject>("Checkbox.prefab");
            setBtn   = ab.LoadAsset <GameObject>("Button.prefab");
            slider   = ab.LoadAsset <GameObject>("Slider.prefab");
            textBox  = ab.LoadAsset <GameObject>("TextBox.prefab");
            header   = ab.LoadAsset <GameObject>("Header.prefab");

            UI = GameObject.Instantiate(UI);
            UI.AddComponent <ModUIDrag>();
            UI.name = "MSCLoader Settings";

            settings    = UI.AddComponent <SettingsView>();
            settings.ms = this;
            settings.settingViewContainer = UI.transform.GetChild(0).gameObject;
            settings.modList =
                settings.settingViewContainer.transform.GetChild(3).gameObject;
            settings.modView = settings.modList.transform.GetChild(0).gameObject;
            settings.modInfo =
                settings.settingViewContainer.transform.GetChild(2).gameObject;
            GameObject ModSettingsView = settings.modInfo.transform.GetChild(0).gameObject;

            settings.ModKeyBinds =
                settings.settingViewContainer.transform.GetChild(1).gameObject;
            settings.keybindsList =
                settings.ModKeyBinds.transform.GetChild(0).GetChild(4).gameObject;
            settings.modSettings =
                settings.settingViewContainer.transform.GetChild(4).gameObject;
            settings.modSettingsList =
                settings.modSettings.transform.GetChild(0).GetChild(4).gameObject;
            settings.coreModCheckbox = settings.settingViewContainer.transform.GetChild(6)
                                       .GetChild(0)
                                       .GetComponent <Toggle>();
            settings.coreModCheckbox.onValueChanged.AddListener(
                delegate { settings.ToggleCoreCheckbox(); });
            settings.noOfMods = settings.settingViewContainer.transform.GetChild(6)
                                .GetChild(1)
                                .GetComponent <Text>();
            settings.goBackBtn =
                settings.settingViewContainer.transform.GetChild(0).GetChild(1).gameObject;
            settings.goBackBtn.GetComponent <Button>().onClick.AddListener(
                () => settings.goBack());
            settings.settingViewContainer.transform.GetChild(0)
            .GetChild(2)
            .GetComponent <Button>()
            .onClick.AddListener(() => settings.toggleVisibility());
            settings.DisableMod =
                ModSettingsView.transform.GetChild(2).GetComponent <Toggle>();
            settings.DisableMod.onValueChanged.AddListener(settings.disableMod);

            settings.InfoTxt        = ModSettingsView.transform.GetChild(0).GetComponent <Text>();
            settings.descriptionTxt =
                ModSettingsView.transform.GetChild(8).GetComponent <Text>();

            settings.nexusLink =
                ModSettingsView.transform.GetChild(4).GetComponent <Button>();
            settings.rdLink = ModSettingsView.transform.GetChild(5).GetComponent <Button>();
            settings.ghLink = ModSettingsView.transform.GetChild(6).GetComponent <Button>();

            UI.transform.SetParent(ModUI.GetCanvas().transform, false);
            settings.SetVisibility(false);
            Button_ms      = GameObject.Instantiate(Button_ms);
            Button_ms.name = "MSCLoader Settings button";
            Button_ms.transform.SetParent(ModUI.GetCanvas().transform, false);
            Button_ms.GetComponent <Button>().onClick.AddListener(
                () => settings.toggleVisibility());
            Button_ms.SetActive(true);
            if (!(bool)modSetButton.GetValue())
            {
                Button_ms.SetActive(false);
            }
            ab.Unload(false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Main function to initialize the ModLoader
        /// </summary>
        public static void Init()
        {
            //Set config and Assets folder in selected mods folder
            ConfigFolder = Path.Combine(ModsFolder, @"Config\");
            AssetsFolder = Path.Combine(ModsFolder, @"Assets\");
            //if mods not loaded and game is loaded.
            if (GameObject.Find("MSCUnloader") == null)
            {
                GameObject go = new GameObject();
                go.name = "MSCUnloader";
                go.AddComponent <MSCUnloader>();
                MSCUnloaderInstance = go.GetComponent <MSCUnloader>();
                DontDestroyOnLoad(go);
            }
            if (IsModsDoneLoading && Application.loadedLevelName == "MainMenu")
            {
                MSCUnloaderInstance.reset = false;
                MSCUnloaderInstance.MSCLoaderReset();
            }
            if (!IsModsDoneLoading && Application.loadedLevelName == "GAME")
            {
                // Load all mods
                ModConsole.Print("Loading mods...");
                Stopwatch s = new Stopwatch();
                s.Start();
                LoadMods();
                ModSettings.LoadBinds();
                IsModsDoneLoading = true;
                s.Stop();
                if (s.ElapsedMilliseconds < 1000)
                {
                    ModConsole.Print(string.Format("Loading mods completed in {0}ms!", s.ElapsedMilliseconds));
                }
                else
                {
                    ModConsole.Print(string.Format("Loading mods completed in {0} sec(s)!", s.Elapsed.Seconds));
                }
            }

            if (IsDoneLoading && Application.loadedLevelName == "MainMenu" && GameObject.Find("MSCLoader Info") == null)
            {
                MainMenuInfo();
            }

            if (IsDoneLoading || Instance)
            {
                if (Application.loadedLevelName != "MainMenu")
                {
                    menuInfoAnim.SetBool("isHidden", true);
                }
                if (Application.loadedLevelName != "GAME")
                {
                    ModConsole.Print("<color=#505050ff>MSCLoader is already loaded!</color>");//debug
                }
            }
            else
            {
                // Create game object and attach self
                GameObject go = new GameObject();
                go.name = "MSCModLoader";
                go.AddComponent <ModLoader>();
                go.AddComponent <LoadAssets>();
                Instance   = go.GetComponent <ModLoader>();
                loadAssets = go.GetComponent <LoadAssets>();
                DontDestroyOnLoad(go);

                // Init variables
                ModUI.CreateCanvas();
                IsDoneLoading     = false;
                IsModsDoneLoading = false;
                LoadedMods        = new List <Mod>();
                InvalidMods       = new List <string>();

                // Init mod loader settings
                if (!Directory.Exists(ModsFolder))
                {
                    //if mods folder not exists, create it.
                    Directory.CreateDirectory(ModsFolder);
                }

                if (!Directory.Exists(ConfigFolder))
                {
                    //if config folder not exists, create it.
                    Directory.CreateDirectory(ConfigFolder);
                }

                if (!Directory.Exists(AssetsFolder))
                {
                    //if config folder not exists, create it.
                    Directory.CreateDirectory(AssetsFolder);
                }
                // Loading internal tools (console and settings)
                LoadMod(new ModConsole(), Version);
                LoadMod(new ModSettings(), Version);

                IsDoneLoading = true;
                ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color>", Version));
                PreLoadMods();
                ModConsole.Print(string.Format("<color=orange>Found <color=green><b>{0}</b></color> mods!</color>", LoadedMods.Count - 2));
                try
                {
                    Steamworks.SteamAPI.Init();
                    steamID = Steamworks.SteamUser.GetSteamID().ToString();
                    ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", Steamworks.SteamFriends.GetPersonaName()));
                    if (!modStats)
                    {
                        ModStats();
                        modStats = true;
                    }
                }
                catch (Exception)
                {
                    ModConsole.Error("Steam not detected, only steam version is supported.");
                }
                ModConsole.Print("Loading core assets...");
                Instance.StartCoroutine(Instance.LoadSkin());
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Main function to initialize the ModLoader
        /// </summary>
        public static void Init()
        {
            //Set config and Assets folder in selected mods folder
            ConfigFolder = Path.Combine(ModsFolder, @"Config\");
            AssetsFolder = Path.Combine(ModsFolder, @"Assets\");
            //if mods not loaded and game is loaded.
            if (GameObject.Find("MSCUnloader") == null)
            {
                GameObject go = new GameObject();
                go.name = "MSCUnloader";
                go.AddComponent <MSCUnloader>();
                MSCUnloaderInstance = go.GetComponent <MSCUnloader>();
                DontDestroyOnLoad(go);
            }
            if (IsModsDoneLoading && Application.loadedLevelName == "MainMenu")
            {
                MSCUnloaderInstance.reset = false;
                MSCUnloaderInstance.MSCLoaderReset();
            }
            if (!IsModsDoneLoading && Application.loadedLevelName == "GAME" && fullyLoaded && !IsModsLoading)
            {
                // Load all mods
                IsModsLoading = true;
                Instance.StartCoroutine(Instance.LoadMods());
            }

            if (IsDoneLoading && Application.loadedLevelName == "MainMenu" && GameObject.Find("MSCLoader Info") == null)
            {
                MainMenuInfo();
            }

            if (IsDoneLoading || Instance)
            {
                if (Application.loadedLevelName != "MainMenu")
                {
                    menuInfoAnim.SetBool("isHidden", true);
                }
            }
            else
            {
                // Create game object and attach self
                GameObject go = new GameObject();
                go.name = "MSCModLoader";
                go.AddComponent <ModLoader>();
                go.AddComponent <LoadAssets>();
                Instance   = go.GetComponent <ModLoader>();
                loadAssets = go.GetComponent <LoadAssets>();
                DontDestroyOnLoad(go);

                // Init variables
                ModUI.CreateCanvas();
                IsDoneLoading     = false;
                IsModsDoneLoading = false;
                LoadedMods        = new List <Mod>();
                InvalidMods       = new List <string>();

                // Init mod loader settings
                if (!Directory.Exists(ModsFolder))
                {
                    //if mods folder not exists, create it.
                    Directory.CreateDirectory(ModsFolder);
                }

                if (!Directory.Exists(ConfigFolder))
                {
                    //if config folder not exists, create it.
                    Directory.CreateDirectory(ConfigFolder);
                }

                if (!Directory.Exists(AssetsFolder))
                {
                    //if config folder not exists, create it.
                    Directory.CreateDirectory(AssetsFolder);
                }
                // Loading internal tools (console and settings)
                LoadMod(new ModConsole(), Version);
                LoadedMods[0].ModSettings();
                LoadMod(new ModSettings_menu(), Version);
                LoadedMods[1].ModSettings();
                ModSettings_menu.LoadSettings();
                LoadCoreAssets();
                IsDoneLoading = true;
                ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color>", Version));
                LoadReferences();
                PreLoadMods();
                ModConsole.Print(string.Format("<color=orange>Found <color=green><b>{0}</b></color> mods!</color>", LoadedMods.Count - 2));
                try
                {
                    if (File.Exists(Path.GetFullPath(Path.Combine("LAUNCHER.exe", ""))) || File.Exists(Path.GetFullPath(Path.Combine("SmartSteamEmu64.dll", ""))) || File.Exists(Path.GetFullPath(Path.Combine("SmartSteamEmu.dll", ""))))
                    {
                        ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", "PIRATE IS FREE!!!"));
                        throw new Exception("Do What You Want, Cause A Pirate Is Free... You Are A Pirate!");
                        //exclude emulators from stats (spam weird stuff sometimes)
                    }
                    Steamworks.SteamAPI.Init();
                    steamID = Steamworks.SteamUser.GetSteamID().ToString();
                    ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", Steamworks.SteamFriends.GetPersonaName()));
                    if (!modStats)
                    {
                        ModStats();
                        modStats = true;
                    }

                    string Name;
                    bool   ret = Steamworks.SteamApps.GetCurrentBetaName(out Name, 128);
                    if (ret && !(bool)ModSettings_menu.expWarning.GetValue())
                    {
                        ModUI.ShowMessage(string.Format("<color=orange><b>Warning:</b></color>{1}You are using beta build: <color=orange><b>{0}</b></color>{1}{1}Remember that some mods may not work correctly on beta branches.", Name, Environment.NewLine), "Experimental build warning");
                    }
                }
                catch (Exception e)
                {
                    ModConsole.Error("Steam not detected, only steam version is supported.");
                    UnityEngine.Debug.Log(e);
                }
                MainMenuInfo();
                LoadModsSettings();
            }
        }