public void ConvertPalettes() { ProjectService projectService = new ProjectService(new ErrorService()); Project project = projectService.LoadProject(@"C:\Projects\Mario Adventure 3\Mushroom Mayhem\Mushroom Mayhem.json"); LevelService levelService = new LevelService(new ErrorService(), project); WorldService worldService = new WorldService(new ErrorService(), project); PalettesService palettesService = new PalettesService(new ErrorService(), project); var palettes = palettesService.GetPalettes(); foreach (IInfo info in levelService.AllWorldsLevels()) { if (info.InfoType == InfoType.Level) { LevelInfo levelInfo = info as LevelInfo; Level level = levelService.LoadLevel(levelInfo); Palette palette = palettes.Where(p => p.Id == level.PaletteId).FirstOrDefault(); if (!palette.Renamed) { palette.Name = level.Name; palette.Renamed = true; palettesService.CommitPalette(palette); } } if (info.InfoType == InfoType.World) { WorldInfo worldInfo = info as WorldInfo; World world = worldService.LoadWorld(worldInfo); Palette palette = palettes.Where(p => p.Id == world.PaletteId).FirstOrDefault(); if (!palette.Renamed) { palette.Name = world.Name; palette.Renamed = true; palettesService.CommitPalette(palette); } } } projectService.SaveProject(); }
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); } }