Пример #1
0
 public ProjectDetails(PLProject projet)
 {
     InitializeComponent();
     CurrentProject = projet;
     String[] files = Directory.GetFiles(projet.Dir);
     int NBMaps = 0;
     for (int i = 0; i < files.Count(); i++)
         if (files[i].EndsWith(".plm"))
             NBMaps++;
     lblProjectName.Text = projet.Name;
     if(NBMaps < 2)
         lblMapNumber.Text = "Contient " + NBMaps + " carte";
     else
         lblMapNumber.Text = "Contient " + NBMaps + " cartes";
     if (File.Exists("LastProjectPath.plcfg"))
     {
         String proj = File.ReadAllText("LastProjectPath.plcfg").Trim();
         if (File.Exists(proj))
         {
             FileInfo info = new FileInfo(proj);
             lblProjectSize.Text = "Taille: " + (info.Length / 1024) + " ko";
         }
         else
             lblProjectSize.Text = "Fichier introuvable";
     }
     lblNbSprites.Text = "Contient " + projet.Ressources.Sprites.Sprites.Count.ToString() + " sprites";
     lblNbSongs.Text = "Contient " + projet.Ressources.Songs.Songs.Count.ToString() + " chansons";
     lblNbSounds.Text = "Contient " + projet.Ressources.Sounds.Sounds.Count.ToString() + " sons";
     lblPath.Text = "Chemin: " + projet.Dir;
 }
Пример #2
0
        private void OpenProject(String path)
        {
            PLProject temp = PLProject.Load(path);

            if (temp == null)
                throw new Exception("Projet invalide");
            else
            {
                Project = temp;

                EnableEditing();
                ShowPopup("Projet chargée", "Le projet " + Project.Name + " a été chargé avec succès à partir du fichier " + Project.Dir);

                FileStream stream = File.Create("LastProjectPath.plcfg");
                StreamWriter writer = new StreamWriter(stream);
                writer.WriteLine(path);
                writer.Close();
                stream.Close();

                WelcomeScreenPopup.SetInformations(Project);
                WelcomeScreenPopup.Visible = true;
            }
        }
Пример #3
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();
        }
Пример #4
0
        private void nouveauProjetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewProject progdlg = new NewProject();

            if (progdlg.ShowDialog() == DialogResult.OK)
            {
                Project = new PLProject();
                Project.PixelMonkeyCore = Properties.Resources.DefaultPMSLCore;

                Project.Name = progdlg.GetName();

                Project.Save(progdlg.GetPath());
                Project.Description = progdlg.GetDescription();

                FileStream stream = File.Create("LastProjectPath.plcfg");
                StreamWriter writer = new StreamWriter(stream);
                writer.WriteLine(progdlg.GetPath());
                writer.Close();
                stream.Close();

                EnableEditing();

                ShowPopup("Projet créé", "Création du projet " + Project.Name + " réussie. Le projet est enregistrer à l'emplacement suivant : " + progdlg.GetPath());
            }
        }