Ejemplo n.º 1
0
        public override void OnSaveData()
        {
            LoggerUtils.Log("Saving props");

            BinaryFormatter binaryFormatter  = new BinaryFormatter();
            MemoryStream    propMemoryStream = new MemoryStream();

            try
            {
                PropWrapper[] propInfos = PropUnlimiterManager.instance.GetAllPropWrappers();
                if (propInfos != null)
                {
                    binaryFormatter.Serialize(propMemoryStream, propInfos);
                    serializableDataManager.SaveData(dataKey, propMemoryStream.ToArray());
                    LoggerUtils.Log("Props have been saved!");
                }
                else
                {
                    LoggerUtils.LogWarning("Couldn't save props, as the array is null!");
                }
            }
            catch (Exception e)
            {
                LoggerUtils.LogError(e);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load all options from the disk.
        /// </summary>
        public static void LoadPropInfo()
        {
            if (File.Exists("BAPropPositioningInfo.xml"))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(PropPositioningInfoObject[]), new XmlRootAttribute()
                {
                    ElementName = "PropPositioningInfo"
                });
                StreamReader reader = new StreamReader("BAPropPositioningInfo.xml");
                Dictionary <string, PropPositioningInfo> routeShieldDict = ((PropPositioningInfoObject[])serializer.Deserialize(reader)).ToDictionary(i => i.key, i => i.value);
                reader.Close();

                if (routeShieldDict != null)
                {
                    Instance().propPositioningDict = routeShieldDict;

                    LoggerUtils.Log("Loaded prop position info file.");
                }
                else
                {
                    Instance().propPositioningDict = fallbackDict;
                    LoggerUtils.LogError("Created prop position file is invalid!");
                }
            }
            else
            {
                Instance().propPositioningDict = fallbackDict;
                LoggerUtils.LogWarning("Could not load the prop position file!");
            }
        }
        /// <summary>
        /// Loads all custom sprites
        /// </summary>
        private void LoadSprites()
        {
            bool spriteSuccess = true;

            PropConfig.LoadPropInfo();

            String[] files = Directory.GetFiles(FileUtils.GetModPath() + Path.DirectorySeparatorChar + FileUtils.IMAGES_DIR);
            foreach (string file in files)
            {
                string[] splitValues = file[0] == Path.DirectorySeparatorChar ? file.Substring(1).Split(Path.DirectorySeparatorChar) : file.Split(Path.DirectorySeparatorChar);
                string   fileName    = splitValues[splitValues.Length - 1];
                string   fileKey     = fileName.Split('.')[0];
                spriteSuccess = TextureUtils.AddTexture(file, fileKey) && spriteSuccess;
            }

            files = Directory.GetFiles(FileUtils.GetAltPath(true));
            foreach (string file in files)
            {
                string[] splitValues = file[0] == Path.DirectorySeparatorChar ? file.Substring(1).Split(Path.DirectorySeparatorChar) : file.Split(Path.DirectorySeparatorChar);
                string   fileName    = splitValues[splitValues.Length - 1];
                string   fileKey     = fileName.Split('.')[0];
                spriteSuccess = TextureUtils.AddTexture(file, fileKey) && spriteSuccess;
            }

            if (!spriteSuccess)
            {
                LoggerUtils.LogError("Failed to load some sprites!");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads all custom sprites
        /// </summary>
        private void LoadSprites()
        {
            bool spriteSuccess = true;

            //TODO: Replace with a loader function( JSON mapping available )

            //We probably need this before we load any displays
            DynamicSignConfig.LoadVmsMsgList();

            RouteShieldConfig.LoadRouteShieldInfo();
            String[] files = Directory.GetFiles(FileUtils.GetModPath() + Path.DirectorySeparatorChar + "Icons");
            foreach (string file in files)
            {
                string[] splitValues = file[0] == Path.DirectorySeparatorChar ? file.Substring(1).Split(Path.DirectorySeparatorChar) : file.Split(Path.DirectorySeparatorChar);
                string   fileName    = splitValues[splitValues.Length - 1];
                string   fileKey     = fileName.Split('.')[0];
                spriteSuccess = SpriteUtils.AddTexture(file, fileKey) && spriteSuccess;
                if (!RouteShieldConfig.Instance().routeShieldDictionary.ContainsKey(fileKey))
                {
                    RouteShieldConfig.Instance().routeShieldDictionary[fileKey] = new RouteShieldInfo(fileKey);
                }
            }

            //TODO: When we need it, load a json descriptor file for relevant shaders here
            ShaderUtils.AddShader("Shaders/font", "font");

            //TODO: When we need it, load a json descriptor file for relevant fonts here
            FontUtils.AddFonts();

            if (!spriteSuccess)
            {
                LoggerUtils.LogError("Failed to load some sprites!");
            }
            else
            {
                RouteShieldConfig.SaveRouteShieldInfo();
            }
        }
Ejemplo n.º 5
0
        protected override void Awake()
        {
            base.Awake();

            LoggerUtils.Log("Initialising RoadRenderingManager");

            if (!LoadPropMeshes())
            {
                LoggerUtils.LogError("Failed to load some props!");
            }
            else
            {
                LoggerUtils.Log("Props loaded!");
            }

            replaceProp(ModSettings.Instance().settings.Contains("loadMotorwaySigns") ? (bool)ModSettings.Instance().settings["loadMotorwaySigns"] : true);

            DistrictManager districtManager = DistrictManager.instance;

            ShaderUtils.m_shaderStore.Add("fallback", districtManager.m_properties.m_areaNameShader);

            //Only start dynamic signs after everything's loaded
            RenderingManager.instance.initTimer();
        }