Ejemplo n.º 1
0
        public void Initialize(GraphicsAccessor graphicsAccessor, TileService tileService, TileSet tileSet, Palette palette, TileSetRenderer tileSetRenderer = null)
        {
            _graphicsAccessor    = graphicsAccessor;
            _tileSet             = tileSet;
            _terrain             = tileService.GetTerrain();
            _mapTileInteractions = tileService.GetMapTileInteractions();
            _tileSetRenderer     = tileSetRenderer ?? new TileSetRenderer(graphicsAccessor, _terrain, _mapTileInteractions);

            Dpi dpi = this.GetDpi();

            _bitmap = new WriteableBitmap(256, 256, dpi.X, dpi.Y, PixelFormats.Bgra32, null);

            TileRenderSource.Source = _bitmap;

            Update(tileSet, palette);
            SelectedBlockValue = 0;
        }
Ejemplo n.º 2
0
        public TileBlockEditor(ProjectService projectService, WorldService worldService, LevelService levelService, GraphicsService graphicsService, PalettesService palettesService, TileService tileService, TextService textService)
        {
            _ignoreChanges = true;
            InitializeComponent();

            _projectService  = projectService;
            _palettesService = palettesService;
            _graphicsService = graphicsService;
            _worldService    = worldService;
            _levelService    = levelService;
            _tileService     = tileService;
            _textService     = textService;

            List <KeyValuePair <string, string> > tileSetText = _textService.GetTable("tile_sets");

            tileSetText.Insert(0, new KeyValuePair <string, string>("0", "Map"));

            TerrainList.ItemsSource        = _localTileTerrain = _tileService.GetTerrainCopy();
            LevelList.ItemsSource          = _levelService.AllWorldsLevels();
            MapInteractionList.ItemsSource = _localMapTileInteraction = _tileService.GetMapTileInteractionCopy();

            _graphicsAccessor = new GraphicsAccessor(_graphicsService.GetTileSection(0), _graphicsService.GetTileSection(0), _graphicsService.GetGlobalTiles(), _graphicsService.GetExtraTiles());

            _graphicsSetRenderer = new GraphicsSetRender(_graphicsAccessor);
            _tileSetRenderer     = new TileSetRenderer(_graphicsAccessor, _localTileTerrain, _localMapTileInteraction);

            Dpi dpi = this.GetDpi();

            _graphicsSetBitmap = new WriteableBitmap(128, 128, dpi.X, dpi.Y, PixelFormats.Bgra32, null);
            _tileBlockBitmap   = new WriteableBitmap(16, 16, dpi.X, dpi.Y, PixelFormats.Bgra32, null);

            GraphicsSetImage.Source = _graphicsSetBitmap;

            TileBlockImage.Source = _tileBlockBitmap;

            BlockSelector.Initialize(_graphicsAccessor, _tileService, _tileService.GetTileSet(0), _graphicsService.GetPalette(0), _tileSetRenderer);
            BlockSelector.TileBlockSelected += BlockSelector_TileBlockSelected;

            LevelList.SelectedIndex          = 1;
            BlockSelector.SelectedBlockValue = 0;
            _ignoreChanges = false;

            _graphicsService.GraphicsUpdated      += _graphicsService_GraphicsUpdated;
            _graphicsService.ExtraGraphicsUpdated += _graphicsService_GraphicsUpdated;
        }
Ejemplo n.º 3
0
        public PaletteEditor(ProjectService projectService, PalettesService palettesService)
        {
            InitializeComponent();

            _projectService  = projectService;
            _palettesService = palettesService;

            Dpi dpi = this.GetDpi();

            _bitmapSection = new WriteableBitmap(256, 32, dpi.X, dpi.Y, PixelFormats.Bgra32, null);
            _bitmapFull    = new WriteableBitmap(256, 64, dpi.X, dpi.Y, PixelFormats.Bgra32, null);

            ImageSection.Source = _bitmapSection;
            ImageFull.Source    = _bitmapFull;

            _rendererSection = new PaletteRenderer(_palettesService, PaletteType.Section);
            _rendererFull    = new PaletteRenderer(_palettesService, PaletteType.Full);

            PaletteList.ItemsSource   = _palettesService.GetPalettes();
            PaletteList.SelectedIndex = 0;

            UpdateFull();

            _palettesService.PalettesChanged += _palettesService_PalettesChanged;
            _rgbPalette = _palettesService.RgbPalette;
            _rgbEditors = new List <PaletteRgbEditor>();

            for (int i = 0; i < 0x40; i++)
            {
                PaletteRgbEditor rgbEditor = new PaletteRgbEditor();
                rgbEditor.RgbColor     = _rgbPalette[i];
                rgbEditor.PaletteIndex = i;

                _rgbEditors.Add(rgbEditor);
                PaletteRgbList.Children.Add(rgbEditor);
            }
        }