Example #1
0
        public Texture2D FindTextureByPath(string path)
        {
            if (loadedTextures.ContainsKey(path))
            {
                return(loadedTextures[path]);
            }
            var e = VFileSystemManager.GetFile(path);

            if (e == null)
            {
                return(null);
            }
            string    ext    = e.GetExtension();
            Texture2D result = null;

            switch (ext)
            {
            case ".dds":
                System.Drawing.Bitmap bmp = new DDSImage(e.ReadAllBytes()).BitmapImage;
                result = CreateTexture2DFromBitmap(engine.device, CreateWICBitmapFromGDI(bmp));
                bmp.Dispose();
                break;
            }
            if (result != null)
            {
                loadedTextures.Add(path, result);
            }
            return(result);
        }
        public static int MountArchive(object variable, object variable2)
        {
            var archivePath = Path.Combine(Application.StartupPath, "mods", "bf2", Convert.ToString(variable));

            VFileSystemManager.MountArchive(Convert.ToString(variable2), archivePath);
            return(0);
        }
 public void ExecuteConFile(string file)
 {
     string[] commands;
     if (!File.Exists(file))
     {
         if (file.StartsWith("/"))
         {
             file = file.Substring(1);
         }
         var vfile = VFileSystemManager.GetFile(file);
         if (vfile == null)
         {
             return;//return for now, so we can actually load
         }
         commands = vfile.ReadAllLines();
     }
     else
     {
         commands = File.ReadAllLines(file);
     }
     foreach (var command in commands)
     {
         var data = command.Split(' ');
         if (string.IsNullOrEmpty(data[0]) || string.IsNullOrWhiteSpace(data[0]))
         {
             continue;
         }
         if (data[0].StartsWith("rem"))
         {
             continue;
         }
         if (data[0] == "if")
         {
             InIf = true;
             continue;
         }
         if (InIf && (data[0] == "else" || data[0] == "endIf"))
         {
             InIf = false;
             continue;
         }
         if (InIf)
         {
             continue;
         }
         if (data[0] == "endIf")
         {
             continue;
         }
         if (!registeredMethods.ContainsKey(data[0]))
         {
             Console.WriteLine("[CONPROCESSOR] Unknown con function: " + command);
             continue;
         }
         var variable1 = data[1];
         if (variable1.StartsWith(Convert.ToString('"')))
         {
             for (int i = 2; i < data.Length; i++)
             {
                 variable1 += data[i];
                 if (data[i].EndsWith(Convert.ToString('"')))
                 {
                     break;
                 }
             }
         }
         string variable2 = null;
         if (data.Length > 2)
         {
             variable2 = data[2];
             if (variable2.StartsWith(Convert.ToString('"')))
             {
                 for (int i = 2; i < data.Length; i++)
                 {
                     variable2 += data[i];
                     if (data[i].EndsWith(Convert.ToString('"')))
                     {
                         break;
                     }
                 }
             }
         }
         registeredMethods[data[0]](variable1, variable2);
     }
 }
 public Level(IMap map)
 {
     Map             = map;
     GameWorld       = new World();
     LevelFileSystem = VFileSystemManager.MountArchive("CurrentLevel", Path.Combine(Config.ModPath, "Levels", Map.MapName, "server.zip"));
 }