Пример #1
0
 public void VpkVtfCollectionTest()
 {
     TextureProvider.Register(new VmtProvider());
     var collection = TextureProvider.CreateCollection(new[]
     {
         @"F:\Steam\SteamApps\common\Team Fortress 2\tf"
     }, null, null, null);
 }
Пример #2
0
        public Document(string mapFile, Map map, Game game)
        {
            MapFile     = mapFile;
            Map         = map;
            Game        = game;
            Environment = new GameEnvironment(game);
            MapFileName = mapFile == null
                              ? DocumentManager.GetUntitledDocumentName()
                              : Path.GetFileName(mapFile);

            SelectListTransform = Matrix4.Identity;

            _subscriptions = new DocumentSubscriptions(this);

            _memory = new DocumentMemory();

            var cam = Map.GetActiveCamera();

            if (cam != null)
            {
                _memory.SetCamera(cam.EyePosition, cam.LookPosition);
            }

            Selection = new SelectionManager(this);
            History   = new HistoryManager(this);
            if (Map.GridSpacing <= 0)
            {
                Map.GridSpacing = Grid.DefaultSize;
            }

            try
            {
                GameData = GameDataProvider.GetGameDataFromFiles(game.Fgds.Select(f => f.Path));
            }
            catch (ProviderException)
            {
                // TODO: Error logging
                GameData = new GameData();
            }

            if (game.OverrideMapSize)
            {
                GameData.MapSizeLow  = game.OverrideMapSizeLow;
                GameData.MapSizeHigh = game.OverrideMapSizeHigh;
            }

            TextureCollection = TextureProvider.CreateCollection(Environment.GetGameDirectories(), Game.AdditionalPackages, Game.GetTextureBlacklist(), Game.GetTextureWhitelist());
            /* .Union(GameData.MaterialExclusions) */ // todo material exclusions

            var texList = Map.GetAllTextures();
            var items   = TextureCollection.GetItems(texList);

            TextureProvider.LoadTextureItems(items);

            Map.PostLoadProcess(GameData, GetTexture, SettingsManager.GetSpecialTextureOpacity);
            Map.UpdateDecals(this);
            Map.UpdateModels(this);
            Map.UpdateSprites(this);

            HelperManager = new HelperManager(this);
            Renderer      = new RenderManager(this);

            if (MapFile != null)
            {
                Mediator.Publish(EditorMediator.FileOpened, MapFile);
            }

            // Autosaving
            if (Game.Autosave)
            {
                var at = Math.Max(1, Game.AutosaveTime);
                Scheduler.Schedule(this, Autosave, TimeSpan.FromMinutes(at));
            }
        }