private void CreateNewMap() { Texture2D CurrentTileFile = CurrentMap.TileSet; NewMap dlg = new NewMap(); dlg.StartPosition = FormStartPosition.CenterParent; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) using (XNAUtils utils = new XNAUtils()) { if (File.Exists(Project.Dir + "\\" + dlg.GetName() + ".plm")) { ShowPopup("Création d'une carte", "Une carte portant le même nom existe déjà. Vous devez choisir une carte avec un nom différent de " + dlg.Name, PopupReason.Error); return; } // Pour éviter le bug des de la map out of bounds du Panel lors des scrolls à l'extrême bas-droit PN_Map.Focus(); MapSize = new SizeI(dlg.GetSize()); CurrentMap = new Map(MapSize, Prefs.Map.TileSize.Width); CurrentMap.Name = dlg.GetName(); CurrentMap.WasInit = true; CurrentMap.TileSet = utils.ConvertToTexture(dlg.GetImage()); CurrentMap.FilePath = Project.Dir + "\\" + dlg.GetName() + ".plm"; CurrentMap.Save(); tabControlPanel1.AddTab(CurrentMap); PN_Map.Dock = DockStyle.None; PN_Map.Location = new System.Drawing.Point(0, 0); PN_Map.Size = new System.Drawing.Size(CurrentMap.MapSize.Width * Prefs.Map.TileSize.Width + 1, CurrentMap.MapSize.Height * Prefs.Map.TileSize.Width + 1); PN_Map.BackgroundImage = null; PN_Map.Refresh(); PN_Tileset.Size = new System.Drawing.Size(CurrentMap.TileSet.Width, CurrentMap.TileSet.Height); LastOpenedMapFile = CurrentMap.FilePath; Text = "Pixel Lion - " + CurrentMap.Name; EnableMapEditing(); // Enable History History.Clear(); History.PushHistory(new MapState(CurrentMap.CloneTiles())); // Reload Quick Maps RefreshDevice(); DrawMap(); } }
private void Open(String filepath) { CurrentMap = Map.LoadFromFile(filepath); tabControlPanel1.AddTab(CurrentMap); Clear(BackColor.ToXnaColor()); Present(); using (XNAUtils utils = new XNAUtils()) PN_Tileset.BackgroundImage = utils.ConvertToImage(CurrentMap.TileSet); if (PN_Tileset.BackgroundImage != null) PN_Tileset.Size = new System.Drawing.Size(256, PN_Tileset.BackgroundImage.Height + 2); MapSize = CurrentMap.MapSize; PN_Map.Dock = DockStyle.None; PN_Map.Location = new System.Drawing.Point(0, 0); PN_Map.Size = new System.Drawing.Size(CurrentMap.MapSize.Width * Prefs.Map.TileSize.Width + 1, CurrentMap.MapSize.Height * Prefs.Map.TileSize.Width + 1); PN_Map.BackgroundImage = null; TileSetImage = CurrentMap.TileSet; LastOpenedMapFile = filepath; Text = "Pixel Lion - " + CurrentMap.Name; // Enable History History.Clear(); History.PushHistory(new MapState(CurrentMap.CloneTiles())); ShowPopup("Carte ouverte", "Ouverture de la carte " + CurrentMap.Name + " réussie à partir du fichier " + LastOpenedMapFile); RefreshDevice(); DrawMap(); }
private void tabControlPanel1_TabChanged(object sender, EventArgs e) { // Pour éviter les anormalités de positions de carte PN_Map.Focus(); Clear(BackColor.ToXnaColor()); Present(); CurrentMap = tabControlPanel1.GetCurrentTabItem() as Map; PN_Tileset.BackgroundImage = utils.ConvertToImage(CurrentMap.TileSet); TileSetImage = CurrentMap.TileSet; if (PN_Tileset.BackgroundImage != null) PN_Tileset.Size = new System.Drawing.Size(256, PN_Tileset.BackgroundImage.Height + 2); MapSize = CurrentMap.MapSize; PN_Map.Dock = DockStyle.None; PN_Map.Location = new System.Drawing.Point(0, 0); PN_Map.Size = new System.Drawing.Size(CurrentMap.MapSize.Width * Prefs.Map.TileSize.Width + 1, CurrentMap.MapSize.Height * Prefs.Map.TileSize.Width + 1); PN_Map.BackgroundImage = null; LastOpenedMapFile = CurrentMap.FilePath; Text = "Pixel Lion - " + CurrentMap.Name; // Enable History History.Clear(); History.PushHistory(new MapState(CurrentMap.CloneTiles())); RefreshDevice(); DrawMap(); }
private void Open() { MapNavigator dlg = new MapNavigator(Project.Dir, MapBatch); dlg.ShowDialog(); using (XNAUtils utils = new XNAUtils()) if (dlg.OpenedFile) { // Pour éviter les anormalités de positions de carte PN_Map.Focus(); Clear(BackColor.ToXnaColor()); Present(); StartWaiting(); Application.DoEvents(); CurrentMap = dlg.SelectedMap; tabControlPanel1.AddTab(CurrentMap); PN_Tileset.BackgroundImage = utils.ConvertToImage(CurrentMap.TileSet); TileSetImage = CurrentMap.TileSet; if (PN_Tileset.BackgroundImage != null) PN_Tileset.Size = new System.Drawing.Size(256, PN_Tileset.BackgroundImage.Height + 2); MapSize = CurrentMap.MapSize; PN_Map.Dock = DockStyle.None; PN_Map.Location = new System.Drawing.Point(0, 0); PN_Map.Size = new System.Drawing.Size(CurrentMap.MapSize.Width * Prefs.Map.TileSize.Width + 1, CurrentMap.MapSize.Height * Prefs.Map.TileSize.Width + 1); PN_Map.BackgroundImage = null; LastOpenedMapFile = dlg.DirPath; Text = "Pixel Lion - " + CurrentMap.Name; // Enable History History.Clear(); History.PushHistory(new MapState(CurrentMap.CloneTiles())); // Enable History History.Clear(); History.PushHistory(new MapState(CurrentMap.CloneTiles())); EnableMapEditing(); StopWaiting(); RefreshDevice(); DrawMap(); } else RefreshDevice(); }