Пример #1
0
        private void fermerLaMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Map map = tabControlPanel1.RemoveCurrentObject() as Map;

            CurrentMap = map == null ? new Map() : map;

            if (map == null)
            {
                CurrentLayer = 0;
                CurrentTileIndex = new Point();
                MapSize = new SizeI();
                LastOpenedMapFile = "";
                PN_Tileset.BackgroundImage = null;
                Text = "Pixel Lion";

                DisableMapEditing();
            }

            RefreshDevice();
            Refresh();
            DrawMap();
        }
Пример #2
0
        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();
            }
        }
Пример #3
0
        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();
        }
Пример #4
0
        // First method called when loading main form
        public MainFormPixelLion()
        {
            // Show Splashscreen
            frmSplash splash = new frmSplash(Properties.Resources.AlternateSplashScreen);
            splash.Show();

            MainFormPixelLion variable = Parent as MainFormPixelLion;

            // Initialize controls
            splash.ChangeStatus("Initialisation de Pixel Lion");
            InitializeComponent();
            DisableMapEditing();

            // Object creations
            splash.ChangeStatus("Initialisation d'XNA");
            PresentationParameters pp = new PresentationParameters()
            {
                BackBufferHeight = PN_Map.Height,
                BackBufferWidth = PN_Map.Width,
                DeviceWindowHandle = PN_Map.Handle,
                IsFullScreen = false
            };

            XNADevices.graphicsdevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, pp);

            splash.ChangeStatus("Création des objets cartes");
            CurrentMap = new Map();
            CurrentTool = DrawingTools.Pen;
            CurrentLayer = 0;
            CurrentTileIndex = new Point();

            MapBatch = new SpriteBatch(XNADevices.graphicsdevice);

            // Loading user preferences
            splash.ChangeStatus("Chargement des préférences");
            GlobalPreferences.Prefs = UserPreferences.LoadFromFile(UserPreferences.DefaultFileName);
            Prefs = GlobalPreferences.Prefs;
            PN_Tileset.BackColor = Prefs.TileSet.BackgroundColor;

            // Variable initialization
            splash.ChangeStatus("Initialisation des variables");
            Rand = new Random();
            MapSize = new SizeI();
            LastOpenedMapFile = "";
            MultiSelectionClicked = false;
            MapIsOpened = false;
            Bubbles = new Bubble[60].Select(x => Bubble.Create(PN_Map.Size, Rand)).ToList();
            CurrentTile = new Rectangle(-Prefs.Map.TileSize.Width, -Prefs.Map.TileSize.Height, 0, 0);
            utils = new XNAUtils();
            XNADevices.EvMarkers = new Texture2D[]
            {
                utils.ConvertToTexture(Properties.Resources.EvMarker1),
                utils.ConvertToTexture(Properties.Resources.EvMarker2),
                utils.ConvertToTexture(Properties.Resources.EvMarker3)
            };

            // Buffering a number of map states for history management
            splash.ChangeStatus("Mise en mémoire tampon de l'historique");
            History = new MapStateHistory(Prefs.Memory.HistoryCount);

            // Creating a map buffer to be drawn on Map Panel
            splash.ChangeStatus("Création d'une image tampon");

            // Project Creation
            splash.ChangeStatus("Création d'un projet");
            Project = new PLProject();

            // This block tries to open the last opened project
            // If not found, will simply continue loading the rest of the form
            try
            {
                splash.ChangeStatus("Vérification du dernier projet ouvert");
                if (File.Exists("LastProjectPath.plcfg"))
                {
                    String proj = File.ReadAllText("LastProjectPath.plcfg").Trim();
                    if (File.Exists(proj))
                    {
                        splash.ChangeStatus("Ouverture du dernier projet");

                        // If a project was found, try opening it
                        try
                        {
                            OpenProject(proj);
                        }
                        catch (Exception)
                        {
                            splash.ChangeStatus("Impossible d'ouvrir le dernier projet");

                            ShowPopup("Projet invalide", "Impossible d'ouvrir le dernier projet ouvert. Celui-ci est peut-être introuvable ou est corrompu.", PopupReason.Error);
                        }
                    }
                    else
                    {
                        ShowPopup("Projet introuvable", "Le dernier projet est introuvable. Il est possible que le fichier aie changé d'emplacement ou qu'il aie été supprimé.", PopupReason.Warning);
                    }
                }
            }
            catch (ArgumentException) { }
            catch (IOException) { }
            catch (InvalidOperationException) { }

            // Locating Welcome Screen
            WelcomeScreenPopup.Location = new System.Drawing.Point(this.Width / 2 - WelcomeScreenPopup.Width / 2, this.Height / 2 - WelcomeScreenPopup.Height / 2);
            WelcomeScreenPopup.Visible = Project.Name != String.Empty;

            // Deletion of temporary files like songs preview
            splash.ChangeStatus("Destruction des fichers temporaires");
            if (Directory.Exists("temps")) Directory.Delete("temp", true);

            // Recreation of a folder meant to contain teporary files
            splash.ChangeStatus("Création des dossiers temporaires");
            Directory.CreateDirectory("temp");
            ShowPopup("Dossier temporaire créé", "Le dossier temporaire contenant les fichiers de sons et autres a été créé avec succès");

            // Check user preferences for if user wants to use double buffering
            if (Prefs.Video.DoubleBuffering)
            {
                try
                {
                    // Turn on double buffering on main Map Panel
                    splash.ChangeStatus("Chargement de l'optimisation graphique");
                    this.SetStyle(
                        ControlStyles.UserPaint |
                        ControlStyles.AllPaintingInWmPaint |
                        ControlStyles.OptimizedDoubleBuffer, true);

                    Thread.Sleep(10);
                    ShowPopup("Optimisation graphique", "La mise en mémoire tampon double (Double Buffering) a été activé avec succès et est bien géré par votre carte vidéo.");
                }
                catch (Exception)
                {
                    ShowPopup("Optimisation graphique", "La mise en mémoire tampon double (Double Buffering) ne peut être activée. Peut-être que votre carte vidéo ne peut prendre en charge cette fonctionnalité.", PopupReason.Warning);
                }
            }

            // Will browse project folder for maps to add in the quick load menu
            splash.ChangeStatus("Chargement des cartes rapides");

            // Initialization of the pEvent tooltip
            peventtip = new HoverTooltip();
            peventtip.Visible = false;
            peventtip.MouseEnter += new EventHandler(peventtip_MouseEnter);
            PN_Map.Controls.Add(peventtip);

            // End of loading
            splash.Close();
        }
Пример #5
0
        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();
        }
Пример #6
0
        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();
        }