コード例 #1
0
        public TilesetImporterViewModel(TilesetDocument tileset)
        {
            _importer = new TilesetImporter(tileset);
            SetTileset(tileset);
            ImportImagesCommand = new RelayCommand(x => ImportImages());
            ExtractCommand = new RelayCommand(x => ExtractImages());
            CompactSheetCommand = new RelayCommand(x => CompactSheet());

            RefreshSheet();
        }
コード例 #2
0
        public StageDocument(ProjectDocument project, StageInfo info, StageLinkInfo linkInfo)
        {
            Project  = project;
            History  = new History();
            _map     = info;
            Tileset  = new TilesetDocument(_map.Tileset);
            LinkName = linkInfo.Name;

            // wrap all map screens in screendocuments
            // this should be the only time MegaMan.Screen's are touched directly
            foreach (var pair in _map.Screens)
            {
                WrapScreen(pair.Value);
            }
        }
コード例 #3
0
        public StageDocument(ProjectDocument project, StageInfo info, StageLinkInfo linkInfo)
        {
            Project = project;
            History = new History();
            _map = info;
            Tileset = new TilesetDocument(_map.Tileset);
            LinkName = linkInfo.Name;

            // wrap all map screens in screendocuments
            // this should be the only time MegaMan.Screen's are touched directly
            foreach (var pair in _map.Screens)
            {
                WrapScreen(pair.Value);
            }
        }
コード例 #4
0
ファイル: StageDocument.cs プロジェクト: laazer/cs_megaman
        public StageDocument(ProjectDocument project, StageLinkInfo linkInfo)
        {
            Project = project;
            History = new History();
            var stageReader = new StageXmlReader();
            map = stageReader.LoadStageXml(linkInfo.StagePath);
            Tileset = new TilesetDocument(map.Tileset);
            LinkName = linkInfo.Name;

            // wrap all map screens in screendocuments
            // this should be the only time MegaMan.Screen's are touched directly
            foreach (var pair in map.Screens)
            {
                WrapScreen(pair.Value);
            }
        }
コード例 #5
0
        public StageDocument(ProjectDocument project, StageLinkInfo linkInfo)
        {
            Project = project;
            History = new History();
            var stageReader = new StageXmlReader();

            map      = stageReader.LoadStageXml(linkInfo.StagePath);
            Tileset  = new TilesetDocument(map.Tileset);
            LinkName = linkInfo.Name;

            // wrap all map screens in screendocuments
            // this should be the only time MegaMan.Screen's are touched directly
            foreach (var pair in map.Screens)
            {
                WrapScreen(pair.Value);
            }
        }
コード例 #6
0
        public void SaveTileset(TilesetDocument tileset)
        {
            var tilesetWriter = _writerProvider.GetTilesetWriter();
            tilesetWriter.Save(tileset.Tileset);
            SaveBrushes(tileset);

            if (tileset.IsSheetDirty)
            {
                var sheet = SpriteBitmapCache.GetOrLoadImage(tileset.SheetPath.Absolute);

                using (var fileStream = new FileStream(tileset.SheetPath.Absolute, FileMode.OpenOrCreate))
                {
                    BitmapEncoder encoder = new PngBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(sheet));
                    encoder.Save(fileStream);
                }

                tileset.IsSheetDirty = false;
            }
        }
コード例 #7
0
ファイル: StageDocument.cs プロジェクト: laazer/cs_megaman
 public void ChangeTileset(TilesetDocument tileset)
 {
     Tileset = tileset;
     map.ChangeTileset(tileset.Tileset);
     Dirty = true;
 }
コード例 #8
0
        private void AddStageToProject(TilesetDocument tileset)
        {
            var stage = _project.AddStage(Name);
            stage.ChangeTileset(tileset);
            _dataService.SaveProject(_project);

            var args = new StageChangedEventArgs(stage);
            ViewModelMediator.Current.GetEvent<StageChangedEventArgs>().Raise(this, args);
        }
コード例 #9
0
 public void ChangeTileset(TilesetDocument tileset)
 {
     Tileset = tileset;
     _map.ChangeTileset(tileset.Tileset);
     Dirty = true;
 }
コード例 #10
0
        protected override void SetTileset(TilesetDocument tileset)
        {
            base.SetTileset(tileset);

            if (tileset == null)
            {
                _observedBrushes = new ObservableCollection<MultiTileBrush>();
            }
            else
            {
                _observedBrushes = new ObservableCollection<MultiTileBrush>(_tileset.Brushes);
            }

            OnPropertyChanged("Brushes");
        }
コード例 #11
0
        private void SetTileset(TilesetDocument tileset)
        {
            _tileset = tileset;

            if (tileset == null)
            {
                _observedBrushes = new ObservableCollection<MultiTileBrush>();
            }
            else
            {
                _observedBrushes = new ObservableCollection<MultiTileBrush>(_tileset.Brushes);
            }

            OnPropertyChanged("Brushes");
        }
コード例 #12
0
 protected override void SetTileset(TilesetDocument tileset)
 {
     base.SetTileset(tileset);
     _importer = new TilesetImporter(tileset);
     RefreshSheet();
 }
コード例 #13
0
        protected virtual void SetTileset(TilesetDocument tileset)
        {
            if (_tileset != null)
                _tileset.TilesetModified -= Update;

            _tileset = tileset;

            if (_tileset != null)
            {
                _observedTiles = new ObservableCollection<Tile>(_tileset.Tiles);

                if (_tileset.Tiles.Any())
                    ChangeTile(_tileset.Tiles.First());
                else
                    ChangeTile(null);

                _tileset.TilesetModified += Update;
                ((App)App.Current).AnimateTileset(_tileset.Tileset);
            }
            else
            {
                _observedTiles = new ObservableCollection<Tile>();
                ChangeTile(null);
            }

            OnPropertyChanged("Tiles");
            OnPropertyChanged("SheetPath");
        }
コード例 #14
0
 private string GetBrushFilePath(TilesetDocument tileset)
 {
     string dir = Path.GetDirectoryName(tileset.Tileset.FilePath.Absolute);
     string file = Path.GetFileNameWithoutExtension(tileset.Tileset.FilePath.Absolute);
     string path = Path.Combine(dir, file + "_brushes.xml");
     return path;
 }
コード例 #15
0
        private void SaveBrushes(TilesetDocument tileset)
        {
            string path = GetBrushFilePath(tileset);

            using (var stream = new StreamWriter(path, false))
            {
                foreach (var brush in tileset.Brushes)
                {
                    stream.Write(brush.Width);
                    stream.Write(' ');
                    stream.Write(brush.Height);
                    foreach (var cell in brush.Cells.SelectMany(a => a))
                    {
                        stream.Write(' ');
                        if (cell.tile == null) stream.Write(-1);
                        else stream.Write(cell.tile.Id);
                    }
                    stream.WriteLine();
                }
            }
        }
コード例 #16
0
        private void LoadBrushes(TilesetDocument tileset)
        {
            var path = GetBrushFilePath(tileset);

            if (!File.Exists(path)) return;

            using (var stream = new StreamReader(path))
            {
                while (!stream.EndOfStream)
                {
                    string line = stream.ReadLine();
                    if (line == null) break;

                    string[] info = line.Split(' ');

                    var brush = new MultiTileBrush(int.Parse(info[0]), int.Parse(info[1]));

                    int x = 0; int y = 0;
                    for (int i = 2; i < info.Length; i++)
                    {
                        int id = int.Parse(info[i]);
                        if (id >= 0) brush.AddTile(tileset.Tileset[id], x, y);

                        y++;
                        if (y >= brush.Height)
                        {
                            y = 0;
                            x++;
                        }
                    }

                    tileset.AddBrush(brush);
                }
            }
        }