Esempio n. 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();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Add strings and icon for a world
        /// Don't call this method OnLoad !
        /// Should be called at Db.Initialize
        /// </summary>
        /// <param name="iconName"> DDS icon name (incorporated ressources only) </param>
        /// <param name="className"> Class containing the locstrings </param>
        public static void AddWorldYaml(string iconName, Type className)
        {
            // Generate a translation .pot and prepare translation strings for loading
            if (!alreadyLoaded.Contains(className))
            {
                ModUtil.RegisterForTranslation(className);
                alreadyLoaded.Add(className);
            }


            if (!iconName.IsNullOrWhiteSpace())
            {
                //Load the sprite from Asteroid_****.dds (converted online from png) and set "generation action" to incorporated ressources
                Logs.LogIfDebugging("Loading Sprite: " + className.Assembly.GetName().Name + "." + iconName + ".dds");
                Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(className.Assembly.GetName().Name + "." + iconName + ".dds");
                if (stream == null)
                {
                    throw new ArgumentException("Sprite name is not valid.");
                }
                Sprite sprite = CreateSpriteDXT5(stream, 512, 512);
                Assets.Sprites.Add(iconName, sprite);
            }
        }