Beispiel #1
0
        /* Menu handlers */

        /***    File     ***/
        /*      New      */
        private void NewProject(object sender, RoutedEventArgs e)
        {
            var dialog = new SaveFileDialog
            {
                InitialDirectory = ProjectFileHandler.GetFormattedUserSpacePath("projects"),
                Title            = "New Project"
            };

            var res = dialog.ShowDialog();

            if (res == true)
            {
                if (Directory.Exists(dialog.FileName))
                {
                    var msg     = "Project already exists";
                    var caption = "Unable to create projects";
                    var btn     = MessageBoxButton.OK;
                    var icon    = MessageBoxImage.Error;
                    MessageBox.Show(msg, caption, btn, icon);
                }
                else
                {
                    _projectManager.NewProject(dialog.FileName);
                    UpdateWindowTitle();
                    LockComponents(GuiLockMode.UNLOCK_ALL);
                }
            }
        }
Beispiel #2
0
        public bool DeleteMap(string id = null)
        {
            if (id == null && _currentMap == null)
            {
                return(false);
            }
            else
            {
            }

            var path = ProjectFileHandler.GetFormattedUserSpacePath(@$ "projects\\{id}\\maps");

            return(true);
        }
Beispiel #3
0
        private void RefreshMapFiles()
        {
            if (ProjectManager.GetProjectName() == null)
            {
                return;
            }

            _maps = new Dictionary <uint, MapInfo>();

            var dir = ProjectFileHandler.GetFormattedUserSpacePath("maps", true);

            if (dir == null)
            {
                return;
            }

            var dirInfo = new DirectoryInfo(dir);

            uint maxMapIndex = 0;

            foreach (FileInfo file in dirInfo.GetFiles())
            {
                if (file.Extension.ToLower() != ".map")
                {
                    continue;
                }

                var json = File.ReadAllText(file.FullName);
                var map  = JsonConvert.DeserializeObject <MapInfo>(json);
                _maps.Add(map.MapId, map);

                if (map.MapId > maxMapIndex)
                {
                    maxMapIndex = map.MapId;
                }

                _currentMap = map;
            }

            _mapIdCounter = maxMapIndex;
            ProjectManager.SetMapCounter(_mapIdCounter);
        }
Beispiel #4
0
        /*      Open     */
        private void OpenProject(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog
            {
                InitialDirectory = ProjectFileHandler.GetFormattedUserSpacePath("projects"),
                Filter           = "Hermes Projects (*.hrms)|*.hrms",
                Title            = "Open Project"
            };
            var res = dialog.ShowDialog();

            if (res == true)
            {
                _projectManager.LoadProject(dialog.FileName);
                _mapManager = new MapManager();
                UpdateWindowTitle();
                LockComponents(GuiLockMode.UNLOCK_ALL);

                var mapList = _mapManager.GetMapsAsList();
                foreach (var pair in mapList)
                {
                    SpawnMapItem(pair.Value.Name, pair.Key);
                }
            }
        }
Beispiel #5
0
 private string GetMapPath(string id)
 {
     return(ProjectFileHandler.GetFormattedUserSpacePath($@"\maps\{id}.map", true));
 }