public TsMapCanvas(SetupForm f) { InitializeComponent(); //_appSettings = f.AppSettings; //JsonHelper.SaveSettings(_appSettings); _mapper = this.CreateMapper(); _palette = SettingsManager.Current.Settings.Palette.ToBrushPalette(); _mapper.Parse(); CityStripComboBox.Items.AddRange(_mapper.Cities.Where(x => !x.Hidden).ToArray()); if (!_mapper.IsEts2) { _startPoint = new PointF(-105000, 15000); } else { _startPoint = new PointF(-1000, -4000); } _renderer = this.CreateRenderer(_mapper); // Panning around MapPanel.MouseDown += (s, e) => { _dragging = true; _lastPoint = new PointF(e.X, e.Y); }; MapPanel.MouseUp += (s, e) => _dragging = false; MapPanel.MouseMove += (s, e) => { if (_dragging) { MapPanel.Invalidate(); _startPoint.X -= (e.X - _lastPoint.X) / _scale; _startPoint.Y -= (e.Y - _lastPoint.Y) / _scale; } _lastPoint = new PointF(e.X, e.Y); }; MapPanel.MouseWheel += (s, e) => { _scale += (e.Delta > 0 ? 1 : -1) * 0.05f * _scale; _scale = Math.Max(_scale, 0.0005f); MapPanel.Invalidate(); }; MapPanel.Resize += TsMapCanvas_Resize; Closed += (s, e) => { f.Close(); _tileMapGeneratorForm?.Close(); }; }
public TsMapCanvas(Form f, string path, List <Mod> mods) { InitializeComponent(); _mapper = new TsMapper(path, mods); _palette = new SimpleMapPalette(); if (path.Contains("American Truck Simulator")) { _pos = new PointF(-103000, -54444); _mapper.IsEts2 = false; } else { _pos = new PointF(850, -920); _mapper.IsEts2 = true; } _mapper.Parse(); _renderer = new TsMapRenderer(_mapper); Timer t = new Timer { Interval = 1000 / 30 }; t.Tick += (s, a) => MapPanel.Invalidate(); t.Start(); // Panning around MapPanel.MouseDown += (s, e) => _dragPoint = e.Location; MapPanel.MouseUp += (s, e) => _dragPoint = null; MapPanel.MouseMove += (s, e) => { if (_dragPoint == null) { return; } var spd = _mapScale / Math.Max(MapPanel.Width, MapPanel.Height); _pos.X = _pos.X - (e.X - _dragPoint.Value.X) * spd; _pos.Y = _pos.Y - (e.Y - _dragPoint.Value.Y) * spd; _dragPoint = e.Location; }; MapPanel.MouseWheel += TsMapCanvas_MouseWheel; MapPanel.Resize += TsMapCanvas_Resize; Closed += (s, e) => { f.Close(); _imageExportForm?.Close(); }; }
private void paletteToolStripMenuItem_Click(object sender, EventArgs e) { _paletteEditorForm = new PaletteEditorForm(); _paletteEditorForm.Show(); _paletteEditorForm.BringToFront(); _paletteEditorForm.UpdatePalette += (palette) => { _palette = palette; }; }
public static void Export(MetaMap map, MapPalette palette, string outputFilePath, int scale = 1) { using var image = new FastImage(map.Width, map.Height, scale); for (var tileY = 0; tileY < map.Height; tileY++) { for (var tileX = 0; tileX < map.Width; tileX++) { var tileColor = palette.PickColor(map[tileX, tileY]); image.SetPixel(tileX, tileY, tileColor); } } image.Save(outputFilePath); }
private MapColorPalette GetMapColorPalette(MapPalette palette) { switch (palette) { case MapPalette.BrightPastel: return(MapColorPalette.Dundas); case MapPalette.Light: return(MapColorPalette.Light); case MapPalette.SemiTransparent: return(MapColorPalette.SemiTransparent); case MapPalette.Pacific: return(MapColorPalette.Pacific); default: return(MapColorPalette.Random); } }
public PaletteEditorForm(MapPalette palette) { InitializeComponent(); }
public TsMapCanvas(SetupForm f, string path, List <Mod> mods) { InitializeComponent(); _appSettings = f.AppSettings; JsonHelper.SaveSettings(_appSettings); _mapper = new TsMapper(path, mods); _palette = new SimpleMapPalette(); _mapper.Parse(); CityStripComboBox.Items.AddRange(_mapper.Cities.Where(x => !x.Hidden).ToArray()); if (!_mapper.IsEts2) { _startPoint = new PointF(-105000, 15000); } else { _startPoint = new PointF(-1000, -4000); } _renderer = new TsMapRenderer(_mapper); Timer t = new Timer { Interval = 1000 / 30 }; t.Tick += (s, a) => MapPanel.Invalidate(); t.Start(); // Panning around MapPanel.MouseDown += (s, e) => { _dragging = true; _lastPoint = new PointF(e.X, e.Y); }; MapPanel.MouseUp += (s, e) => _dragging = false; MapPanel.MouseMove += (s, e) => { if (_dragging) { _startPoint.X -= (e.X - _lastPoint.X) / _scale; _startPoint.Y -= (e.Y - _lastPoint.Y) / _scale; } _lastPoint = new PointF(e.X, e.Y); }; MapPanel.MouseWheel += (s, e) => { _scale += (e.Delta > 0 ? 1 : -1) * 0.05f * _scale; _scale = Math.Max(_scale, 0.0005f); }; MapPanel.Resize += TsMapCanvas_Resize; Closed += (s, e) => { f.Close(); _tileMapGeneratorForm?.Close(); }; }