public GraphicsWindow(GraphicsService graphicsService, TileService tileService, PalettesService palettesService) { InitializeComponent(); _graphicsService = graphicsService; _tileService = tileService; _paletteService = palettesService; _graphicsAccessor = new GraphicsAccessor(_graphicsService.GetTilesAtAddress(0)); _graphicsRenderer = new GraphicsSetRender(_graphicsAccessor); _blockRenderer = new BlockRenderer(); Dpi dpi = this.GetDpi(); _graphicsBitmap = new WriteableBitmap(128, 128, dpi.X, dpi.Y, PixelFormats.Bgra32, null); _editorBitmap = new WriteableBitmap(16, 16, dpi.X, dpi.Y, PixelFormats.Bgra32, null); PatternTable.Source = _graphicsBitmap; EditorImage.Source = _editorBitmap; LoadPalettes(); GraphicsType.SelectedIndex = LayoutOrder.SelectedIndex = 0; _paletteService.PalettesChanged += _paletteService_PalettesChanged; }
public GameObjectEditor(ProjectService projectService, PalettesService palettesService, GraphicsService graphicsService, GameObjectService gameObjectService) { InitializeComponent(); _projectService = projectService; _gameObjectService = gameObjectService; _graphicsService = graphicsService; _palettesService = palettesService; _graphicsAccessor = new GraphicsAccessor(graphicsService.GetGlobalTiles(), graphicsService.GetExtraTiles()); viewObjects.Add(viewObject); Dpi dpi = this.GetDpi(); _bitmap = new WriteableBitmap(256, 256, dpi.X, dpi.Y, PixelFormats.Bgra32, null); _renderer = new GameObjectRenderer(_gameObjectService, _palettesService, _graphicsAccessor); _renderer.RenderGrid = true; GameObjectRenderer.Source = _bitmap; List <Palette> palettes = _palettesService.GetPalettes(); ObjectSelector.Initialize(_gameObjectService, _palettesService, _graphicsAccessor, palettes[0]); PaletteSelector.ItemsSource = palettes; PaletteSelector.SelectedIndex = 0; _graphicsService.GraphicsUpdated += _graphicsService_GraphicsUpdated; _graphicsService.ExtraGraphicsUpdated += _graphicsService_GraphicsUpdated; }
public LevelRenderer(GraphicsAccessor graphicsAccessor, LevelDataAccessor levelDataAccessor, PalettesService paletteService, GameObjectService gameObjectService, List <TileTerrain> terrain) : base(graphicsAccessor) { _levelDataAccessor = levelDataAccessor; _gameObjectService = gameObjectService; _paletteService = paletteService; _terrain = terrain; _buffer = new byte[BITMAP_WIDTH * BITMAP_HEIGHT * 4]; }
public TileSetRenderer(GraphicsAccessor graphicsAccessor, List <TileTerrain> terrain, List <MapTileInteraction> mapTileInteractions) : base(graphicsAccessor) { _buffer = new byte[256 * 256 * BYTES_PER_BLOCK]; BYTE_STRIDE = 16 * 16 * 4; _graphicsAccessor = graphicsAccessor; _terrain = terrain; _mapTileInteractions = mapTileInteractions; }
public GraphicsSetRender(GraphicsAccessor graphicsAccessor) : base(graphicsAccessor) { _buffer = new byte[BYTES_PER_PIXEL * PIXELS_PER_TILE * TILES_PER_COLUMN * TILES_PER_ROW]; _graphicsAccessor = graphicsAccessor; _tileMap = new Tile[16, 16]; BYTE_STRIDE = 128 * 4; }
public WorldRenderer(GraphicsAccessor graphicsAccessor, WorldDataAccessor worldDataAccessor, PalettesService paletteService, List <MapTileInteraction> terrain) : base(graphicsAccessor) { _worldDataAccessor = worldDataAccessor; _paletteService = paletteService; _terrain = terrain; _buffer = new byte[BITMAP_WIDTH * BITMAP_HEIGHT * 4]; BYTE_STRIDE = BYTES_PER_PIXEL * PIXELS_PER_BLOCK_ROW * BLOCKS_PER_SCREEN * 4; }
public void Initialize(GameObjectService gameObjectService, PalettesService palettesService, GraphicsAccessor graphicsAccessor, Palette palette) { _gameObjectService = gameObjectService; _graphicsAccessor = graphicsAccessor; _palette = palette; _palettesService = palettesService; _objectTypes = new List <GameObjectType>(); _renderer = new GameObjectRenderer(gameObjectService, _palettesService, graphicsAccessor); Dpi dpi = this.GetDpi(); _bitmap = new WriteableBitmap(256, 256, dpi.X, dpi.Y, PixelFormats.Bgra32, null); _selectedGroup = new Dictionary <GameObjectType, string>(); switch (ObjectGroup) { case GameObjectGroup.Level: _objectTypes.Add(GameObjectType.Global); _objectTypes.Add(GameObjectType.TypeA); _objectTypes.Add(GameObjectType.TypeB); break; case GameObjectGroup.World: _objectTypes.Add(GameObjectType.World); break; case GameObjectGroup.All: _objectTypes.Add(GameObjectType.Global); _objectTypes.Add(GameObjectType.TypeA); _objectTypes.Add(GameObjectType.TypeB); _objectTypes.Add(GameObjectType.World); break; } foreach (var objectType in _objectTypes) { _selectedGroup[objectType] = null; } _selectedObject = null; GameObjectImage.Source = _bitmap; GameObjectTypes.ItemsSource = _objectTypes; _renderer.Update(palette); CanvasArea.Background = new SolidColorBrush(palette.RgbColors[0][0].ToMediaColor()); GameObjectTypes.SelectedIndex = 0; _gameObjectService.GameObjectUpdated += GameObjectsUpdated; }
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; }
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; }
public Renderer(GraphicsAccessor graphicsAccessor) { _graphicsAccessor = graphicsAccessor; }
public GraphicsRenderer(GraphicsAccessor graphicsAccessor) : base(graphicsAccessor) { _buffer = new byte[256 * 256 * BYTES_PER_BLOCK]; }
public GameObjectRenderer(GameObjectService gameObjectService, PalettesService palettesService, GraphicsAccessor graphicsAccessor) : base(graphicsAccessor) { BYTE_STRIDE = 256 * 4; _buffer = new byte[256 * 256 * 4]; _gameObjectService = gameObjectService; _palettesService = palettesService; }
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(); }