Exemplo n.º 1
0
        public Document(string mapFile, Map map, Game game)
        {
            MapFile = mapFile;
            Map = map;
            Game = game;
            MapFileName = mapFile == null
                              ? DocumentManager.GetUntitledDocumentName()
                              : Path.GetFileName(mapFile);

            _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();
            }

            TextureCollection = TextureProvider.CreateCollection(game.Wads.Select(x => x.Path).Distinct());
            var texList = Map.GetAllTextures();
            var items = TextureCollection.GetItems(texList);
            TextureCollection.LoadTextureItems(items);

            Map.PostLoadProcess(GameData, GetTexture, SettingsManager.GetSpecialTextureOpacity);

            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));
            }
        }
Exemplo n.º 2
0
 public Batch(Game game, Build build, string targetFile, string originalFile)
 {
     // TODO: this properly
     BeforeExecute = "";
     AfterExecute = "";
     BeforeExecuteStep = "";
     AfterExecuteStep = "";
     TargetFile = targetFile;
     var fileFlag = '"' + targetFile + '"';
     var bspFile = '"' + Path.ChangeExtension(targetFile, "bsp") + '"';
     var copyBsp = '"' + Path.ChangeExtension(originalFile, "bsp") + '"';
     Steps = new List<BatchCompileStep>
                 {
                     new BatchCompileStep { Operation = Path.Combine(build.Path, build.Csg), Flags = fileFlag },
                     new BatchCompileStep { Operation = Path.Combine(build.Path, build.Bsp), Flags = fileFlag },
                     new BatchCompileStep { Operation = Path.Combine(build.Path, build.Vis), Flags = fileFlag },
                     new BatchCompileStep { Operation = Path.Combine(build.Path, build.Rad), Flags = fileFlag },
                     new BatchCompileStep { Operation = "move", SystemCommand = true, Flags = bspFile + " " + copyBsp }
                     //new BatchCompileStep { Operation = "copy"}
                 };
 }
Exemplo n.º 3
0
 public static IEnumerable<Game> Scan(string dir)
 {
     foreach (var d in Directory.GetDirectories(dir))
     {
         var di = new DirectoryInfo(d);
         var gam = Directory.GetFiles(d, "liblist.gam");
         if (gam.Any())
         {
             var lines = File.ReadAllLines(gam[0]).Select(x => x.Trim());
             var dict = GetGamKeyVals(lines);
             if (!dict.ContainsKey("game")) continue;
             var game = new Game();
             game.Engine = Engine.Goldsource;
             // game.Fgds lookup
             // game.BaseDir
             game.ModDir = di.Name;
             game.Name = dict["game"];
             game.SteamInstall = false;
             game.WonGameDir = dir;
             yield return game;
         }
     }
 }
Exemplo n.º 4
0
 private static void LoadFileGame(string fileName, Game game)
 {
     try
     {
         var map = MapProvider.GetMapFromFile(fileName);
         DocumentManager.AddAndSwitch(new Document(fileName, map, game));
     }
     catch (ProviderException e)
     {
         Error.Warning("The map file could not be opened:\n" + e.Message);
     }
 }
Exemplo n.º 5
0
        public static void Read()
        {
            Builds.Clear();
            Games.Clear();
            RecentFiles.Clear();
            Settings.Clear();

            var root = ReadSettingsFile();

            if (root == null) return;

            var settings = root.Children.FirstOrDefault(x => x.Name == "Settings");
            if (settings != null)
            {
                foreach (var key in settings.GetPropertyKeys())
                {
                    Settings.Add(new Setting {Key = key, Value = settings[key]});
                }
            }
            var recents = root.Children.FirstOrDefault(x => x.Name == "RecentFiles");
            if (recents != null)
            {
                foreach (var key in recents.GetPropertyKeys())
                {
                    int i;
                    if (int.TryParse(key, out i))
                    {
                        RecentFiles.Add(new RecentFile {Location = recents[key], Order = i});
                    }
                }
            }
            var games = root.Children.Where(x => x.Name == "Game");
            foreach (var game in games)
            {
                var g = new Game();
                g.Read(game);
                Games.Add(g);
            }
            var builds = root.Children.Where(x => x.Name == "Build");
            foreach (var build in builds)
            {
                var b = new Build();
                b.Read(build);
                Builds.Add(b);
            }
            Serialise.DeserialiseSettings(Settings.ToDictionary(x => x.Key, x => x.Value));

            if (!File.Exists(SettingsFile))
            {
                Write();
            }
        }
Exemplo n.º 6
0
 private void SelectGame(Game game)
 {
     SelectedGameID = game.ID;
     Close();
 }
Exemplo n.º 7
0
 public GameEnvironment(Game game)
 {
     Game = game;
 }