private void _graphicsService_GraphicsUpdated()
 {
     _graphicsAccessor.SetTopTable(_graphicsService.GetTileSection(_world.AnimationTileTableIndex));
     _graphicsAccessor.SetBottomTable(_graphicsService.GetTileSection(_world.TileTableIndex));
     TileSelector.Update();
     Update();
 }
Exemple #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;
        }
Exemple #3
0
        private void _graphicsService_GraphicsUpdated()
        {
            if (_currentLevel != null)
            {
                _graphicsAccessor.SetBottomTable(_graphicsService.GetTileSection(_currentLevel.AnimationTileTableIndex));
                _graphicsAccessor.SetTopTable(_graphicsService.GetTileSection(_currentLevel.StaticTileTableIndex));
            }
            else if (_currentWorld != null)
            {
                Tile[] staticTiles   = _graphicsService.GetTileSection(_currentWorld.TileTableIndex);
                Tile[] animatedTiles = _graphicsService.GetTileSection(_currentWorld.AnimationTileTableIndex);

                _graphicsAccessor.SetBottomTable(staticTiles);
                _graphicsAccessor.SetTopTable(animatedTiles);
            }

            _graphicsAccessor.SetGlobalTiles(_graphicsService.GetGlobalTiles(), _graphicsService.GetExtraTiles());
            UpdateTileBlock();
            UpdateGraphics();
            BlockSelector.Update();
        }
        public WorldPanel(GraphicsService graphicsService, PalettesService palettesService, TextService textService, TileService tileService, WorldService worldService, LevelService levelService, GameObjectService gameObjectService, WorldInfo worldInfo)
        {
            InitializeComponent();

            _worldInfo         = worldInfo;
            _textService       = textService;
            _graphicsService   = graphicsService;
            _tileService       = tileService;
            _palettesService   = palettesService;
            _worldService      = worldService;
            _gameObjectService = gameObjectService;

            _historyService     = new HistoryService();
            _interactions       = _tileService.GetMapTileInteractions();
            _world              = _worldService.LoadWorld(_worldInfo);
            _compressionService = new CompressionService();
            Tile[] bottomTableSet = _graphicsService.GetTileSection(_world.TileTableIndex);
            Tile[] topTableSet    = _graphicsService.GetTileSection(_world.AnimationTileTableIndex);
            _graphicsAccessor  = new GraphicsAccessor(topTableSet, bottomTableSet, _graphicsService.GetGlobalTiles(), _graphicsService.GetExtraTiles());
            _worldDataAccessor = new WorldDataAccessor(_world);

            _bitmap        = new WriteableBitmap(WorldRenderer.BITMAP_WIDTH, WorldRenderer.BITMAP_HEIGHT, 96, 96, PixelFormats.Bgra32, null);
            _worldRenderer = new WorldRenderer(_graphicsAccessor, _worldDataAccessor, _palettesService, _tileService.GetMapTileInteractions());
            _worldRenderer.Initializing();

            _tileSet = _tileService.GetTileSet(_world.TileSetIndex);

            Palette palette = _palettesService.GetPalette(_world.PaletteId);

            _worldRenderer.Update(tileSet: _tileSet, palette: palette);

            WorldRenderSource.Source = _bitmap;
            WorldRenderSource.Width  = _bitmap.PixelWidth;
            WorldRenderSource.Height = _bitmap.PixelHeight;
            CanvasContainer.Width    = RenderContainer.Width = _world.ScreenLength * 16 * 16;

            SelectedEditMode.SelectedIndex = 0;
            SelectedDrawMode.SelectedIndex = 0;

            TileSelector.Initialize(_graphicsAccessor, _tileService, _tileSet, palette);
            ObjectSelector.Initialize(_gameObjectService, _palettesService, _graphicsAccessor, palette);
            PointerEditor.Initialize(levelService, _worldInfo);

            _world.ObjectData.ForEach(o => o.GameObject = gameObjectService.GetObject(o.GameObjectId));


            UpdateTextTables();

            _graphicsService.GraphicsUpdated      += _graphicsService_GraphicsUpdated;
            _graphicsService.ExtraGraphicsUpdated += _graphicsService_GraphicsUpdated;
            _palettesService.PalettesChanged      += _palettesService_PalettesChanged;
            _tileService.TileSetUpdated           += _tileService_TileSetUpdated;
            _worldService.WorldUpdated            += _worldService_WorldUpdated;
            gameObjectService.GameObjectUpdated   += GameObjectService_GameObjectsUpdated;


            _world.ObjectData.ForEach(o =>
            {
                o.CalcBoundBox();
                o.CalcVisualBox(true);
            });

            _initializing = false;
            _worldRenderer.Ready();
            Update();
        }