Ejemplo n.º 1
0
        public UserPreferences(UserPreferences original)
        {
            Video = new VideoPreferences()
            {
                DoubleBuffering = original.Video.DoubleBuffering,
                ShowPopups = original.Video.ShowPopups,
                ShowSplashScreen = original.Video.ShowSplashScreen,
                ShowBubbleMainScreen = original.Video.ShowBubbleMainScreen
            };

            AnimationStudio = new AnimationStudioPreferences()
            {
                BackgroundColor = original.AnimationStudio.BackgroundColor,
                RulerSize = original.AnimationStudio.RulerSize,
                ShowSplashScreen = original.AnimationStudio.ShowSplashScreen,
                UseXna = original.AnimationStudio.UseXna
            };

            Audio = new AudioPreferences()
            {
                LoopSongs = original.Audio.LoopSongs,
                PlaySound = original.Audio.PlaySound,
                SoundPath = original.Audio.SoundPath
            };

            Map = new MapPreferences()
            {
                GridColor = original.Map.GridColor,
                GridThickness = original.Map.GridThickness,
                TileSize = original.Map.TileSize
            };

            TileSet = new TileSetPreferences()
            {
                BackgroundColor = original.TileSet.BackgroundColor,
                TilesPerRow = original.TileSet.TilesPerRow
            };

            Memory = new MemoryPreferences()
            {
                HistoryCount = original.Memory.HistoryCount,
                Hotkeys = original.Memory.Hotkeys,
                PreloadMaps = original.Memory.PreloadMaps,
                QuickMaps = original.Memory.QuickMaps
            };

            Tabs = new TabsPreferences()
            {
                FirstColorGradiant = original.Tabs.FirstColorGradiant,
                SecondColorGradiant = original.Tabs.SecondColorGradiant
            };
        }
Ejemplo n.º 2
0
        public static UserPreferences LoadFromFile(String path)
        {
            if (!File.Exists(path))
            {
                UserPreferences prefs = new UserPreferences();
                prefs.SaveToFile(DefaultFileName);

                return prefs;
            }
            else
            {
                UserPreferences objectToSerialize;

                try
                {
                    Stream stream = File.Open(path, FileMode.Open);
                    BinaryFormatter bFormatter = new BinaryFormatter();
                    objectToSerialize = (UserPreferences)bFormatter.Deserialize(stream);
                    stream.Close();
                }
                catch (Exception)
                {
                    objectToSerialize = new UserPreferences();
                }

                return objectToSerialize;
            }
        }
Ejemplo n.º 3
0
        private void valeursParDéfautToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Voulez-vous vraiment restaurer les valeurs par défaut?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
            {
                Prefs = new UserPreferences();
                GlobalPreferences.Prefs = new UserPreferences();

                ShowPopup("Préférences", "Les valeurs par défaut ont été affectées aux préférences utilisateur.");
            }
        }
Ejemplo n.º 4
0
        private void préférencesUtilisateurToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PreferencesDialog dlg = new PreferencesDialog(GlobalPreferences.Prefs, this);
            UserPreferences oldPrefs = new UserPreferences( GlobalPreferences.Prefs );

            switch (dlg.ShowDialog())
            {
                case System.Windows.Forms.DialogResult.OK:
                    {
                        Prefs = dlg.GeneratePreferences();
                        GlobalPreferences.Prefs = Prefs;
                        Prefs.SaveToFile(UserPreferences.DefaultFileName);
                        ShowPopup("Sauvegarde des préférences", "Les préférences ont été sauvegardées avec succèes.");
                    }
                    break;

                case System.Windows.Forms.DialogResult.Retry:
                    {
                        Prefs = dlg.GeneratePreferences();
                        Prefs.SaveToFile(UserPreferences.DefaultFileName);

                        Application.Restart();
                    }
                    break;
                case System.Windows.Forms.DialogResult.Ignore:
                    {
                        GlobalPreferences.Prefs = oldPrefs;
                        History.Clear();
                        ShowPopup("Historique", "L'historique a été nettoyé avec succèes.");
                    }
                    break;

                case System.Windows.Forms.DialogResult.Yes:
                    {
                        GlobalPreferences.Prefs = oldPrefs;
                        importerToolStripMenuItem_Click(sender, e);
                    }
                    break;

                case System.Windows.Forms.DialogResult.No:
                    {
                        GlobalPreferences.Prefs = oldPrefs;
                        exporterToolStripMenuItem_Click(sender, e);
                    }
                    break;

                default:
                    GlobalPreferences.Prefs = oldPrefs;
                    break;
            }

            Refresh();
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
        private void importerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Préférences Pixel Lion (*.plpref)|*.plpref";

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    Prefs = UserPreferences.LoadFromFile(dlg.FileName);
                    GlobalPreferences.Prefs = Prefs;
                    ShowPopup("Importation", "Les préférences ont été importées avec succèes.");
                }
                catch (Exception)
                {
                    ShowPopup("Importation des préférences", "Impossible d'importer les préférences. Fichier invalide.", PopupReason.Error);
                }
            }
        }