public static Video LoadVideo(Mod mod, string path)
        {
            if (!IsTMLFNA64())
            {
                throw new Exception("Cannot load video on XNA tML, pls install tML 64bit to use this feature.");
            }

            Video  result   = null;
            string fileName = path.Split('/')[path.Split('/').Length - 1];

            try
            {
                if (File.Exists(Path.Combine(Main.SavePath, "video", mod.Name + "." + fileName + ".ogv")))
                {
                    ConstructorInfo info = typeof(Video).GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(string), typeof(GraphicsDevice) }, null);
                    object[]        obj  = new object[] { Path.Combine(Main.SavePath, "video", mod.Name + "." + fileName + ".ogv"), Main.graphics.GraphicsDevice };
                    return((Video)info.Invoke(obj));
                }
                byte[] stream = ModContent.GetFileBytes(path + ".ogv");
                if (!Directory.Exists(Path.Combine(Main.SavePath, "video")))
                {
                    Directory.CreateDirectory(Path.Combine(Main.SavePath, "video"));
                }
                File.WriteAllBytes(Path.Combine(Main.SavePath, "video", mod.Name + "." + fileName + ".ogv"), stream);
                return(LoadVideo(mod, path));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(result);
        }
示例#2
0
        private void LoadFileStream()        //filestream loading stuff
        {
            byte[] file   = ModContent.GetFileBytes("PlanetMod/Skies/MilkyWay.jpg");
            Stream stream = new MemoryStream(file);

            spaceBackground = Texture2D.FromStream(Main.graphics.GraphicsDevice, stream);
        }
示例#3
0
        public byte[] Get(string name)
        {
            if (files.ContainsKey(name))
            {
                return(files[name]);
            }
            var path = $"{resourceFolder}{name}";

            if (!ModContent.FileExists(path))
            {
                files.Add(name, null);
                return(null);
            }
            var data = ModContent.GetFileBytes(path);

            files.Add(name, data);
            return(files[name]);
        }