Esempio n. 1
0
        protected override void Install()
        {
            if (Done) // Only one Assets installation throughout the application
            {
                return;
            }

            foreach (var action in AssetManager.instance.CreateLoadingSequence(Mod.GetPath()))
            {
                var localAction = action;

                Loading.QueueAction(() =>
                {
                    try
                    {
                        localAction();
                    }
                    catch (Exception ex)
                    {
                        Debug.Log("REx: Crashed-AssetsInstaller");
                        Debug.Log("REx: " + ex.Message);
                        Debug.Log("REx: " + ex.ToString());
                    }
                });
            }

            Done = true;
        }
Esempio n. 2
0
        public void Save()
        {
            if (Mod.GetPath() == Mod.PATH_NOT_FOUND)
            {
                return;
            }

            Debug.Log(string.Format("REx: Saving config at {0}", FILENAME));

            try
            {
                var xDoc     = new XmlDocument();
                var settings = xDoc.CreateElement("NetworkExtensionsSettings");

                xDoc.AppendChild(settings);

                foreach (var part in PartsEnabled)
                {
                    var xmlElem = xDoc.CreateElement(part.Key);
                    xmlElem.InnerText = part.Value.ToString();

                    settings.AppendChild(xmlElem);
                }

                xDoc.Save(FILENAME);
            }
            catch (Exception ex)
            {
                Debug.Log(string.Format("REx: Crashed saving config at {0} {1}", FILENAME, ex));
            }
        }
        protected override void Install()
        {
            if (Done) //Only one localization throughout the application
            {
                return;
            }

            Loading.QueueAction(() =>
            {
                try
                {
                    //Debug.Log("REx: Localization");
                    var locale = SingletonLite <LocaleManager> .instance.GetLocale();

                    locale.CreateMenuTitleLocalizedString(Menus.AdditionnalMenus.ROADS_SMALL_HV, "Small Heavy Roads");

                    foreach (var builder in Mod.NetInfoBuilders)
                    {
                        locale.CreateNetTitleLocalizedString(builder.Name, builder.DisplayName);
                        locale.CreateNetDescriptionLocalizedString(builder.Name, builder.Description);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Log("REx: Crashed-Localization");
                    Debug.Log("REx: " + ex.Message);
                    Debug.Log("REx: " + ex.ToString());
                }

                Done = true;
            });
        }
        protected override void Install()
        {
            Loading.QueueAction(() =>
            {
                try
                {
                    var menuInstalled = false;

                    var group = FindObjectsOfType <RoadsGroupPanel>().FirstOrDefault();

                    if (InstallRoadSmallHV(group))
                    {
                        menuInstalled = true;
                    }

                    if (menuInstalled)
                    {
                        Debug.Log("REx: Additionnal Menus have been installed successfully");
                    }
#if DEBUG
                    else
                    {
                        Debug.Log("REx: Something has happened, Additionnal Menus have not been installed");
                    }
#endif
                }
                catch (Exception ex)
                {
                    Debug.Log("REx: Crashed-Initialized Additionnal Menus");
                    Debug.Log("REx: " + ex.Message);
                    Debug.Log("REx: " + ex.ToString());
                }
            });
        }
Esempio n. 5
0
        protected override void Install()
        {
            var version = GetType().Assembly.GetName().Version;

            Debug.Log(string.Format("REx: Version {0}", version));

            InstallRedirections();
        }
Esempio n. 6
0
        private static Options Load()
        {
            if (Mod.GetPath() == Mod.PATH_NOT_FOUND)
            {
                return(new Options());
            }

            Debug.Log(string.Format("REx: Loading config at {0}", FILENAME));

            if (!File.Exists(FILENAME))
            {
                return(new Options());
            }

            try
            {
                var configuration = new Options();
                var xDoc          = new XmlDocument();
                xDoc.Load(FILENAME);

                if (xDoc.DocumentElement == null)
                {
                    return(configuration);
                }

                foreach (XmlNode node in xDoc.DocumentElement.ChildNodes)
                {
                    var nodeValue = true;

                    if (!bool.TryParse(node.InnerText, out nodeValue))
                    {
                        nodeValue = true;
                    }

                    configuration.PartsEnabled[node.Name] = nodeValue;
                }

                return(configuration);
            }
            catch (Exception ex)
            {
                Debug.Log(string.Format("REx: Crashed load config at {0} {1}", FILENAME, ex));
                return(new Options());
            }
        }
Esempio n. 7
0
        private void InstallRoadsGroupPanelRedirect()
        {
            var originalMethod = typeof(RoadsGroupPanel).GetMethod("GetCategoryOrder", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            if (originalMethod == null)
            {
                Debug.Log("REx: Cannot find the GetCategoryOrder original method, continuing");
                return;
            }

            var newMethod = typeof(RExRoadsGroupPanel).GetMethod("GetCategoryOrder", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            if (newMethod == null)
            {
                Debug.Log("REx: Cannot find the GetCategoryOrder new method, continuing");
                return;
            }

            s_rmoRedirect = RedirectionHelper.RedirectCalls(originalMethod, newMethod);
        }
Esempio n. 8
0
        private void InstallRedirections()
        {
            if (s_redirectionsInstalled)
            {
                return;
            }

            try
            {
                InstallRoadsGroupPanelRedirect();
            }
            catch (Exception ex)
            {
                Debug.Log("REx: Crashed-RedirectionsInstall");
                Debug.Log("REx: " + ex.Message);
                Debug.Log("REx: " + ex.ToString());
            }
            finally
            {
                s_redirectionsInstalled = true;
            }
        }
Esempio n. 9
0
        protected override void Install()
        {
            var localNewRoads = NewRoads;

            Loading.QueueAction(() =>
            {
                //Debug.Log("REx: Setting up new Roads and Logic");


                // Builders -----------------------------------------------------------------------
                var newInfos = new List <NetInfo>();

                foreach (var builder in Mod.NetInfoBuilders)
                {
                    try
                    {
                        newInfos.AddRange(builder.Build());

                        Debug.Log(string.Format("REx: {0} installed", builder.DisplayName));
                    }
                    catch (Exception ex)
                    {
                        Debug.Log(string.Format("REx: Crashed-Network builders {0}", builder));
                        Debug.Log("REx: " + ex.Message);
                        Debug.Log("REx: " + ex.ToString());
                    }
                }

                if (newInfos.Count > 0)
                {
                    localNewRoads.m_prefabs = newInfos.ToArray();
                    PrefabCollection <NetInfo> .InitializePrefabs(localNewRoads.name, localNewRoads.m_prefabs, new string[] { });
                    PrefabCollection <NetInfo> .BindPrefabs();
                }


                // Modifiers ----------------------------------------------------------------------
                foreach (var modifier in Mod.NetInfoModifiers)
                {
                    try
                    {
                        modifier.ModifyExistingNetInfo();

                        Debug.Log(string.Format("REx: {0} modifications applied", modifier.DisplayName));
                    }
                    catch (Exception ex)
                    {
                        Debug.Log(string.Format("REx: Crashed-Network modifiers {0}", modifier));
                        Debug.Log("REx: " + ex.Message);
                        Debug.Log("REx: " + ex.ToString());
                    }
                }


                // Cross mods support -------------------------------------------------------------
                foreach (var compatibilityPart in Mod.CompatibilityParts)
                {
                    try
                    {
                        if (compatibilityPart.IsPluginActive)
                        {
                            compatibilityPart.Setup(newInfos);

                            Debug.Log(string.Format("REx: {0} compatibility activated", compatibilityPart.Name));
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Log(string.Format("REx: Crashed-CompatibilitySupport {0}", compatibilityPart.Name));
                        Debug.Log("REx: " + ex.Message);
                        Debug.Log("REx: " + ex.ToString());
                    }
                }
            });
        }