Пример #1
0
 public ProgressBar(int Width,int Height, Color FullColor, Color EmptyColor)
     : base(false)
 {
     Full = new Texture(Width, Height, FullColor);
     FullClipRect = new Rectangle(0,0,Width/2, Height);
     Empty = new Texture(Width, Height, EmptyColor);
     EmptyClipRect = new Rectangle(0, 0, Width, Height);
 }
Пример #2
0
 public ProgressBar(string FullImage, string EmptyImage)
     : base(true)
 {
     Full = OldSkullGame.Atlas[FullImage].Texture;
     FullClipRect = new Rectangle(0, 0, Full.Width, Full.Height);
     Empty = OldSkullGame.Atlas[EmptyImage].Texture;
     EmptyClipRect = new Rectangle(0, 0, Empty.Width, Empty.Height);
 }
Пример #3
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     base.LoadContent();
     // Create a new SpriteBatch, which can be used to draw textures.
     spriteBatch = new SpriteBatch(GraphicsDevice);
     image       = new Monocle.Texture(this.Content.Load <Texture2D>("wabbit_alpha"));
     //image = new Monocle.Texture("/wabbit_alpha", true);
     font = this.Content.Load <SpriteFont> ("test");
     //TODO: use this.Content to load your game content here
 }
Пример #4
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     base.LoadContent ();
     // Create a new SpriteBatch, which can be used to draw textures.
     spriteBatch = new SpriteBatch (GraphicsDevice);
     image = new Monocle.Texture(this.Content.Load<Texture2D>("wabbit_alpha"));
     //image = new Monocle.Texture("/wabbit_alpha", true);
     font = this.Content.Load<SpriteFont> ("test");
     //TODO: use this.Content to load your game content here
 }
Пример #5
0
        public static void LoadDir(string path)
        {
            ModData modData = GetModData(path);
            string  modName = modData.Name;

            if (modData.MinVersion > ModfallVersion)
            {
                Logger.Log($"[Modfall] Mod {modName} requires a newer version of Modfall: {modData.MinVersion}");
                Errors.Add($"{modName} requires a newer version of Modfall: {modData.MinVersion}");
                return;
            }
            Logger.Log($"[Modfall] Loading Mod: {modName}");
            ModPaths.Add(modName, path);
            ModPathsInv.Add(path, modName);
            // Code mods
            if (!string.IsNullOrEmpty(modData.DLL))
            {
                try
                {
                    Assembly asm = Assembly.LoadFile(Path.Combine(path, modData.DLL) + ".dll");

                    LoadModAssembly(asm, modData);
                }
                catch (Exception ex)
                {
                    Errors.Add($"{modName} threw an exception when loading: {ex.Message}");
                    Logger.Log(ex.Message);
                }
            }
            else
            {
                // No dll, so make a null module
                Mod mod = new NullMod();
                mod.Data = modData;
                Mods.Add(mod);
            }
            // Graphics
            string graphicsPath = Path.Combine(path, "Content", "Graphics");

            if (Directory.Exists(graphicsPath))
            {
                /*
                 * // Files directly in the Graphics/ folder
                 * foreach (string file in Directory.GetFiles(graphicsPath))
                 * {
                 *  AddSprite(file);
                 * }
                 * // files in subfolders
                 * foreach (string dir in Directory.GetDirectories(graphicsPath))
                 * {
                 *  foreach (string file in Directory.GetFiles(dir))
                 *  {
                 *      AddSprite(file);
                 *  }
                 * } */
                Crawl(graphicsPath, delegate(string s) { AddSprite(s); });

                void AddSprite(string spritePath)
                {
                    if (spritePath.EndsWith(".png"))
                    {
                        string virtualPath = spritePath.Substring(graphicsPath.Length + 1);
                        virtualPath = virtualPath.Remove(virtualPath.Length - 4, 4).Replace('\\', '/');
                        Monocle.Texture texture = new Monocle.Texture(spritePath, true);
                        Logger.Log($"[Modfall] Adding graphic {virtualPath}");
                        if (TFGame.Atlas.SubTextures.ContainsKey(virtualPath))
                        {
                            TFGame.Atlas.SubTextures[virtualPath] = new Subtexture(texture);
                        }
                        else
                        {
                            TFGame.Atlas.SubTextures.Add(virtualPath, new Subtexture(texture));
                        }
                    }
                }
            }
            // Atlases
            string atlasPath = Path.Combine(path, "Content", "Atlases");
            // SpriteData
            string spriteDataPath = Path.Combine(atlasPath, "SpriteData");

            if (Directory.Exists(spriteDataPath))
            {
                //foreach (string file in Directory.GetFiles(spriteDataPath))
                Crawl(spriteDataPath, delegate(string file)
                {
                    if (file.EndsWith(".xml"))
                    {
                        Logger.Log("[Modfall] Loading SpriteData: " + Path.GetFileNameWithoutExtension(file));
                        XmlNode xmlNode = Calc.LoadXML(file);

                        foreach (object obj in xmlNode["SpriteData"])
                        {
                            if (obj is XmlElement)
                            {
                                string id = (obj as XmlElement).Attr("id");
                                Logger.Log($"[Modfall] Adding sprite {id} to SpriteData");
                                ((patch_SpriteData)TFGame.SpriteData).Add(id, obj as XmlElement);
                            }
                        }
                    }
                });
            }
            // SFX
            string SFXPath = Path.Combine(path, "Content", "SFX");

            if (Directory.Exists(SFXPath))
            {
                Crawl(SFXPath, delegate(string file)
                {
                    string virtualPath = file.Substring(SFXPath.Length + 1);
                    int extLength      = Path.GetExtension(virtualPath).Length;
                    virtualPath        = virtualPath.Remove(virtualPath.Length - extLength, extLength).Replace('\\', '/');
                    Logger.Log($"[Modfall] Adding SFX {virtualPath}");
                    SFX sfx = new SFX(file);
                    patch_Sounds.ModSFX.Add(virtualPath, sfx);
                });
            }
        }
Пример #6
0
        public void Load()
        {
            if (map.Mode != MainMenu.RollcallModes.Quest)
            {
                orig_Load();
                return;
            }
            int num = 0;
            int id  = 14;

            foreach (string file in ModLoader.mm.ModLoader.ModPaths.Values)
            {
                // Load custom Co-Op levels

                if (Directory.Exists(Path.Combine(file, "Levels", "Quest")))
                {
                    string questPath = Path.Combine(file, "Levels", "Quest");
                    foreach (string file3 in Directory.EnumerateFiles(questPath, "*.tower"))
                    {
                        // if there isn't a .oel file already, convert a .tower file to .oel
                        string pathNoExt = Path.Combine(questPath, Path.GetFileNameWithoutExtension(file3));
                        if (!File.Exists(pathNoExt + ".oel"))
                        {
                            TowerToOel.Convert(pathNoExt);
                        }
                    }
                    foreach (string file2 in Directory.EnumerateFiles(questPath, "*.oel"))
                    {
                        try
                        {
                            Logger.Log("Loading map:" + file2);
                            patch_QuestLevelData data2 = (patch_QuestLevelData)GameData.QuestLevels[0];
                            QuestLevelData       data  = data2.DeepClone();
                            data.Path     = file2;
                            data.DataPath = Path.Combine(Path.GetDirectoryName(file2), Path.GetFileNameWithoutExtension(file2)) + "data.xml";
                            data.ID.X     = id;
                            XmlElement xmlElement = Calc.LoadXML(data.Path)["level"];

                            // Theme preset
                            if (xmlElement.HasChild("theme"))
                            {
                                data.Theme = new TowerTheme(GameData.Themes[xmlElement.ChildText("theme")]);
                            }
                            else
                            {
                                data.Theme = new TowerTheme(GameData.Themes["SacredGround"]);
                            }
                            if (xmlElement.HasAttribute("Darkness"))
                            {
                                data.Theme.DarknessOpacity = float.Parse(xmlElement.Attributes["Darkness"].InnerText, NumberFormatInfo.InvariantInfo);
                            }
                            if (xmlElement.HasChild("darkColor"))
                            {
                                data.Theme.DarknessColor = Calc.HexToColor(xmlElement.ChildText("darkColor"));
                            }
                            if (xmlElement.HasChild("music"))
                            {
                                data.Theme.Music = xmlElement.ChildText("music");
                            }
                            if (xmlElement.HasChild("cold"))
                            {
                                data.Theme.Cold = xmlElement.ChildBool("cold");
                            }
                            if (xmlElement.HasChild("tileset"))
                            {
                                data.Theme.Tileset = xmlElement.ChildText("tileset");
                            }
                            if (xmlElement.HasChild("raining"))
                            {
                                data.Theme.Raining = bool.Parse(xmlElement.ChildText("raining"));
                            }
                            if (xmlElement.HasChild("mapPosition"))
                            {
                                data.Theme.MapPosition = patch_Calc.StringToVec2(xmlElement.ChildText("mapPosition"));
                            }
                            // Build Icon
                            if (xmlElement.HasChild("icon"))
                            {
                                Texture2D       icon    = TowerMapData.BuildIcon(xmlElement["icon"].ChildText("data"), data.Theme.TowerType);
                                Monocle.Texture texture = new Monocle.Texture(icon);
                                data.Theme.Icon = new Subtexture(texture);
                            }
                            // Get name
                            if (xmlElement.HasChild("title"))
                            {
                                data.Theme.Name = xmlElement.ChildText("title");
                            }
                            else
                            {
                                data.Theme.Name = Path.GetFileNameWithoutExtension(file2).ToUpper() + " - " + ModLoader.mm.ModLoader.ModPathsInv[file].ToUpper();
                            }
                            // Music

                            /*
                             * if (xmlElement.HasChild("music"))
                             *  data.Theme.Music = xmlElement.ChildText("music");
                             * if (data.Theme.Music == "Custom")
                             * {
                             *  this.customMusicData = new CustomMusicData(xmlElement["custommusic"]);
                             *  data.Theme.Music
                             * }
                             */
                            Array.Resize(ref GameData.QuestLevels, id + 1);
                            Array.Resize(ref SaveData.Instance.Quest.Towers, id + 1);

                            GameData.QuestLevels[id] = data;

                            SaveData.Instance.Quest.Towers[id]          = new QuestTowerStats();
                            SaveData.Instance.Quest.Towers[id].Revealed = true;
                            QuestMapButton item = new QuestMapButton(data);
                            //if (xmlElement.HasChild("author"))
                            //{
                            //    item.Data.Author = xmlElement.ChildText("author");
                            //}
                            item.Data.Author = "FROM: " + ModLoader.mm.ModLoader.ModPathsInv[file].ToUpper();
                            ((patch_MapButton)(MapButton)item).SetAuthor("FROM: " + ModLoader.mm.ModLoader.ModPathsInv[file].ToUpper());
                            buttons.Add(item);
                            id++;
                        }
                        catch (Exception e)
                        {
                            num++;
                            Logger.Log(e.Message + e.StackTrace);
                        }
                    }
                }
            }
        }
Пример #7
0
 public FlashingImage(Texture texture, Rectangle? clipRect = null)
     : base(texture, clipRect, true)
 {
 }