// Validates user inputs, creates a tilemap and open editor windows (map & tileset) private void BtnOK_Click(object sender, RoutedEventArgs e) { if (txtWidth.Text != "" && txtHeight.Text != "" && txtTileWidth.Text != "" && txtTileHeight.Text != "" && txtTilemapPath.Text != "" && txtTilemapName.Text != "" && txtElementWidth.Text != "" && txtElementHeight.Text != "" && txtMargin.Text != "" && txtSpacing.Text != "" && txtTilesetFile.Text != "") { Tilemap theTilemap = new Tilemap ( int.Parse(txtWidth.Text), int.Parse(txtHeight.Text), int.Parse(txtTileWidth.Text), int.Parse(txtTileHeight.Text), txtTilemapPath.Text, txtTilemapName.Text, int.Parse(txtElementWidth.Text), int.Parse(txtElementHeight.Text), int.Parse(txtMargin.Text), int.Parse(txtSpacing.Text), txtTilesetFile.Text ); if (theTilemap.initDoc()) { MapWindow mapWindow = theTilemap.goToEditor(); mapWindow.Show(); TilemapWindow tilemapWindow = new TilemapWindow(mapWindow, theTilemap.getTileset()); tilemapWindow.Show(); ToolsWindow tools = new ToolsWindow(mapWindow, theTilemap); tools.Show(); this.Close(); } } else { System.Windows.MessageBox.Show("Merci de renseigner tous les champs"); } }
// Load an existing tilemap private void BtnLoadMap_Click(object sender, RoutedEventArgs e) { // Choose the tilemap file FileDialog fileDialog = new OpenFileDialog(); fileDialog.ShowDialog(); Tilemap theTilemap = new Tilemap(); if (theTilemap.initFromXML(fileDialog.FileName)) { MapWindow Map = theTilemap.goToEditor(); Map.Show(); TilemapWindow tilemap = new TilemapWindow(Map, theTilemap.getTileset()); tilemap.Show(); ToolsWindow tools = new ToolsWindow(Map, theTilemap); tools.Show(); this.Close(); } }