Esempio n. 1
0
        /// <summary>
        /// Load all options from the disk.
        /// </summary>
        public static void LoadRouteShieldInfo()
        {
            if (File.Exists("RouteShieldOptions.xml"))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(RouteShieldObject[]), new XmlRootAttribute()
                {
                    ElementName = "RouteInfoItems"
                });
                StreamReader reader = new StreamReader("RouteShieldOptions.xml");
                Dictionary <string, RouteShieldInfo> routeShieldDict = ((RouteShieldObject[])serializer.Deserialize(reader)).ToDictionary(i => i.key, i => i.value);
                reader.Close();

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

                    LoggerUtils.Log("Loaded route shield info file.");
                }
                else
                {
                    Instance().routeShieldDictionary = fallbackDict;
                    LoggerUtils.LogError("Created route shield info is invalid!");
                }
            }
            else
            {
                Instance().routeShieldDictionary = fallbackDict;
                LoggerUtils.LogWarning("Could not load the route shield info file!");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Load all options from the disk.
        /// </summary>
        public static void LoadVmsMsgList()
        {
            if (File.Exists(FILE_NAME))
            {
                StreamReader reader = new StreamReader(FILE_NAME);

                ArrayList vmsMsgStrings = JSON.JsonDecode(reader.ReadToEnd()) as ArrayList;

                reader.Close();

                if (vmsMsgStrings != null)
                {
                    Instance().msgStrings = vmsMsgStrings.Cast <string>().ToList();

                    LoggerUtils.Log("Loaded route VMS message file.");
                }
                else
                {
                    Instance().msgStrings = fallbackMsgStrings;
                    LoggerUtils.LogError("Created route VMS message list is invalid!");
                }
            }
            else
            {
                Instance().msgStrings = fallbackMsgStrings;
                LoggerUtils.LogWarning("Could not load the VMS message list file!");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Save all options from the disk.
        /// </summary>
        public static void SaveSettings()
        {
            StreamWriter writer = new StreamWriter(FILE_NAME);

            writer.WriteLine(JSON.JsonEncode(Instance().settings));
            writer.Close();

            LoggerUtils.Log("Saved setting file.");
        }
Esempio n. 4
0
        /// <summary>
        /// Save all options from the disk.
        /// </summary>
        public static void SaveVmsMsgList()
        {
            StreamWriter writer = new StreamWriter(FILE_NAME);
            ArrayList    strs   = new ArrayList(Instance().msgStrings);

            writer.WriteLine(JSON.JsonEncode(strs));
            writer.Close();

            LoggerUtils.Log("Saved route shield info file.");
        }
Esempio n. 5
0
        /// <summary>
        /// Save all options from the disk.
        /// </summary>
        public static void SaveRouteShieldInfo()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(RouteShieldObject[]), new XmlRootAttribute()
            {
                ElementName = "RouteInfoItems"
            });
            StreamWriter writer = new StreamWriter("RouteShieldOptions.xml");

            serializer.Serialize(writer, instance.routeShieldDictionary.Select(kv => new RouteShieldObject()
            {
                key = kv.Key, value = kv.Value
            }).ToArray());
            writer.Close();

            LoggerUtils.Log("Saved route shield info file.");
        }
Esempio n. 6
0
        public static bool AddShader(string fullPath, string shaderName)
        {
            AssetBundle bundle = FileUtils.GetAssetBundle(fullPath);

            if (bundle == null)
            {
                return(false);
            }

            Shader shader = bundle.LoadAsset(shaderName + ".shader") as Shader;

            LoggerUtils.Log("Shader is loaded?" + (shader != null));
            if (shader != null)
            {
                m_shaderStore[shaderName] = shader;
            }
            bundle.Unload(false);
            return(true);
        }
Esempio n. 7
0
        public static AssetBundle GetAssetBundle(string path)
        {
            try
            {
                string      absUri = "file:///" + GetModPath().Replace("\\", "/") + "/" + path;
                WWW         www    = new WWW(absUri);
                AssetBundle bundle = www.assetBundle;

                LoggerUtils.Log(path + " bundle loading " + ((bundle == null) ? "failed " + www.error : "succeeded"));
                String[] allAssets = bundle.GetAllAssetNames();
                foreach (String asset in allAssets)
                {
                    LoggerUtils.Log("asset is: " + asset);
                }
                return(bundle);
            }
            catch (Exception e)
            {
                Debug.Log("Exception trying to load bundle file!" + e.ToString());
                return(null);
            }
        }
Esempio n. 8
0
        public static bool AddFonts()
        {
            foreach (KeyValuePair <string, string> pair in m_desiredFonts)
            {
                AssetBundle bundle = FileUtils.GetAssetBundle(pair.Value);

                if (bundle == null)
                {
                    return(false);
                }

                Font[] font = bundle.LoadAllAssets <Font>();

                LoggerUtils.Log("Font is loaded?" + (font.Length > 0));
                if (font != null)
                {
                    m_fontStore[pair.Key] = font[0];
                }
                bundle.Unload(false);
            }

            return(true);
        }