Пример #1
0
        /// <summary>
        /// Add strings and icon for a world
        /// </summary>
        /// <param name="NAME"> Name of the world </param>
        /// <param name="DESCRIPTION"> Description of the world </param>
        /// <param name="iconName"> DDS icon name (incorporated ressources only) </param>
        /// <param name="className"> Class containing the locstrings </param>
        public static void addWorldYaml(string NAME, string DESCRIPTION, string iconName, Type className)
        {
            // Add strings used in Fuleria.yaml
            Strings.Add($"STRINGS.WORLDS." + NAME.ToUpper() + ".NAME", NAME);
            Strings.Add($"STRINGS.WORLDS." + NAME.ToUpper() + ".DESCRIPTION", DESCRIPTION);

            Logs.LogIfDebugging("Strings added at: " + "STRINGS.WORLDS." + NAME.ToUpper() + ".NAME");

            // Generate a translation .pot
            ModUtil.RegisterForTranslation(className);

            if (!iconName.IsNullOrWhiteSpace())
            {
                //Load the sprite from Asteroid_Fuleria.dds (converted online from png) and set "generation action" to incorporated ressources
                try
                {
                    Sprite sprite = Sprites.CreateSpriteDXT5(Assembly.GetExecutingAssembly().GetManifestResourceStream(className.AssemblyQualifiedName + "." + iconName + ".dds"), 512, 512);
                    Assets.Sprites.Add(iconName, sprite);
                }
                catch (Exception e)
                {
                    Logs.Log(e.ToString());
                    throw new ArgumentException();
                }
            }
        }
Пример #2
0
 // Get the property of the Json config of this mod
 public T GetProperty <T>(string propertyName)
 {
     try
     {
         JToken token = configValues.GetValue(propertyName);
         return(token.ToObject <T>());
     }
     catch (Exception)
     {
         Logs.Log("Error during json reading. Property not found. Try to default value.");
         return(default);
Пример #3
0
        // Write the Json
        private void WriteJson()
        {
            var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            var configPath = Path.Combine(directory, fileName);

            try
            {
                using (StreamWriter r = new StreamWriter(configPath))
                {
                    r.Write(configValues.ToString());
                }
            }
            catch (Exception)
            {
                Logs.Log("Error during json writing.");
            }
        }
Пример #4
0
        public JsonReader()
        {
            var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            var configPath = Path.Combine(directory, fileName);

            try
            {
                using (StreamReader r = new StreamReader(configPath))
                {
                    configValues = JObject.Parse(r.ReadToEnd());
                }
            }
            catch (Exception)
            {
                Logs.Log("Error during json reading.");
            }
        }
Пример #5
0
 public static bool IsOnWorld(string worldName)
 {
     Logs.Log(CustomGameSettings.Instance.name);
     return(CustomGameSettings.Instance.name == worldName);
 }