Exemplo n.º 1
0
        private void BTN_Add_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Multiselect = true;
            dlg.Filter = "Fichiers png (*.png)|*.png";
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                WaitingForm form = new WaitingForm();
                form.Show();
                Application.DoEvents();

                for (int i = 0; i < dlg.FileNames.Count(); i++)
                {
                    using (XNAUtils utils = new XNAUtils())
                    {
                        byte[] data = File.ReadAllBytes(dlg.FileNames[i]);
                        Image image = byteArrayToImage(data);
                        Battler battler = new Battler(dlg.SafeFileNames[i], utils.ConvertToTexture(image));
                        LIST_Battlers.Items.Add(battler);
                    }
                }

                form.Close();
            }
        }
Exemplo n.º 2
0
 public pIcon(SerializationInfo info, StreamingContext context)
 {
     using (XNAUtils utils = new XNAUtils())
     {
         ContentImage = utils.ConvertToTexture(info.GetValue("ContentImage", typeof(System.Drawing.Image)) as System.Drawing.Image);
         Name = info.GetValue("Name", typeof(String)) as String;
     }
 }
Exemplo n.º 3
0
 public Battler(SerializationInfo info, StreamingContext context)
 {
     using (XNAUtils utils = new XNAUtils())
     {
         Name = info.GetString("Name");
         Img = utils.ConvertToTexture(info.GetValue("Img", typeof(System.Drawing.Image)) as System.Drawing.Image);
     }
 }
Exemplo n.º 4
0
 public Landscape(SerializationInfo info, StreamingContext context)
 {
     using (XNAUtils utils = new XNAUtils())
     {
         BackImage = utils.ConvertToTexture((System.Drawing.Image)info.GetValue("BackImage", typeof(System.Drawing.Image)));
         Repeat = (Boolean)info.GetValue("Repeat", typeof(Boolean));
         Opacity = (Int32)info.GetValue("Opacity", typeof(Int32));
     }
 }
Exemplo n.º 5
0
 public Sprite(SerializationInfo info, StreamingContext context)
 {
     using (XNAUtils utils = new XNAUtils())
     {
         SpriteImage = utils.ConvertToTexture((System.Drawing.Image)info.GetValue("Image", typeof(System.Drawing.Image)));
         Name = (String)info.GetValue("Name", typeof(String));
         TileCount = (Point)info.GetValue("TileCount", typeof(Point));
         tempTileX = 0;
         tempTileY = 0;
     }
 }
Exemplo n.º 6
0
        private void BTN_Save_Click(object sender, EventArgs e)
        {
            using (XNAUtils utils = new XNAUtils())
            {
                HasSaved = true;
                fog.BackImage = utils.ConvertToTexture(PN_Preview.BackgroundImage);
                fog.Opacity = TRACK_Opacity.Value;
                fog.Repeat = true;
            }

            Close();
        }
Exemplo n.º 7
0
        private void BTN_AddItemObject_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Multiselect = true;
            dlg.Filter = "Images|*.jpg;*.jpeg;*.png;*.bmp";

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                using (XNAUtils utils = new XNAUtils())
                foreach (String item in dlg.FileNames)
                {
                    LIST_Icons.Items.Add(new pIcon(utils.ConvertToTexture(Image.FromFile(item)), item.Substring(item.LastIndexOf("\\"))));
                }
            }
        }
Exemplo n.º 8
0
        private void LIST_Animations_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Saving) return;

            if (LIST_Animations.SelectedItem != null)
            {
                String animationname = LIST_Animations.SelectedItem.ToString();

                DrawLoadingNotice("Initialisation de l'animation", animationname);
                Thread.Sleep(20);

                Animation animation = (LIST_Animations.SelectedItem as Animation).Clone() as Animation;

                if (animation.GetPattern() != null && animation.GetPattern().GetImage() != null)
                {
                    // Set pattern in pattern panel
                    DrawLoadingNotice("Chargement du motif", animationname);
                    SetPatternImage(animation, animation.GetPattern().GetImage());

                    // Dispose old textures
                    DrawLoadingNotice("Libération de la mémoire", animationname);
                    foreach (Texture2D texture in textures) texture.Dispose();

                    // Clear texture table
                    textures.Clear();

                    // Convert images into Texture2D for them to be used with XNA
                    DrawLoadingNotice("Adaptation du motif", animationname);

                    foreach (Control c in PN_Pattern.Controls)
                    using (XNAUtils utils = new XNAUtils())
                    {
                        textures.Add(utils.ConvertToTexture(c.BackgroundImage));
                    }
                }
                else
                {
                    // Dispose old textures
                    DrawLoadingNotice("Libération de la mémoire", animationname);
                    foreach (Texture2D texture in textures) texture.Dispose();

                    // Clear texture table
                    textures.Clear();

                    PN_Pattern.Controls.Clear();
                }

                // Set informations
                DrawLoadingNotice("Affichage des informations", animationname);
                LBL_AnimationName.Text = animation.ToString();

                // Update indexes
                DrawLoadingNotice("Mise à jour des index", animationname);
                CurrentAnimation = animation;
                CurrentIndex = LIST_Animations.SelectedIndex;

                // Update timeline
                DrawLoadingNotice("Chargement de la ligne de temps", animationname);
                animationTimeLine1.LoadAnimation(animation);
                DrawFrame(CurrentAnimation.FrameAt(0));

                GROUP_Animation.Visible = true;
            }
            else
            {
                CurrentAnimation = null;
                CurrentIndex = LIST_Animations.SelectedIndex;

                GROUP_Animation.Visible = false;
            }
        }
Exemplo n.º 9
0
        private void PB_Tileset_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "PNG (*.png)|*.png";

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                using (XNAUtils utils = new XNAUtils())
                {
                    PB_Tileset.Image = Image.FromFile(dlg.FileName);
                    PB_Tileset.Size = PB_Tileset.Image.Size;

                    map.TileSet = utils.ConvertToTexture(PB_Tileset.Image);
                }
            }
        }
Exemplo n.º 10
0
        private void BTN_SaveElement_Click(object sender, EventArgs e)
        {
            using (XNAUtils utils = new XNAUtils())
            {
                if (linkLBL_ELEM_Name.Text == LIST_Elements.SelectedItem.ToString() || !ContainsSameName(LIST_Elements, linkLBL_ELEM_Name.Text))
                {
                    pIcon icon = new pIcon(utils.ConvertToTexture(PN_IconElement.BackgroundImage), linkLBL_ELEM_Name.Text);
                    Elemental elem = new Elemental(linkLBL_ELEM_Name.Text, icon);

                    elem.Immunities = new List<Elemental>();
                    elem.Resistances = new List<Elemental>();
                    elem.Weaknesses = new List<Elemental>();

                    elem.Immunities = ES_Immunites.UpdateList();
                    elem.Resistances = ES_Resistances.UpdateList();
                    elem.Weaknesses = ES_Faiblesses.UpdateList();

                    elem.SetDescription(TB_Description.Text);

                    LIST_Elements.Items[LIST_Elements.SelectedIndex] = elem;
                }

                else
                    GenerateSaveWarningBox("élément", linkLBL_ELEM_Name.Text);

                ES_Faiblesses.Init(LIST_Elements, linkLBL_ELEM_Name.Text);
                ES_Resistances.Init(LIST_Elements, linkLBL_ELEM_Name.Text);
                ES_Immunites.Init(LIST_Elements, linkLBL_ELEM_Name.Text);
            }
        }
Exemplo n.º 11
0
        private void BTN_SaveAttack_Click(object sender, EventArgs e)
        {
            using (XNAUtils utils = new XNAUtils())
            {
                if (LBL_ATK_Name.Text == LIST_SpecialAttacks.SelectedItem.ToString() || !ContainsSameName(LIST_SpecialAttacks, LBL_ATK_Name.Text))
                {
                    SpecialAttack atk = new SpecialAttack();
                    pIcon icon = new pIcon(utils.ConvertToTexture(PN_Attaque.BackgroundImage), LBL_ATK_Name.Text);
                    atk.AtkIcon = icon;
                    atk.AtkType = (AttackType)DDL_ATK_Type.SelectedItem;
                    atk.DamageRatio = (float)NUM_ATK_Ratio.Value;
                    atk.Name = LBL_ATK_Name.Text;
                    atk.Radius = (int)NUM_ATK_Radius.Value;
                    atk.AnimTarget = (Animation)DDL_ATK_AnimationTarget.SelectedItem;
                    atk.AnimSelf = (Animation)DDL_ATK_AnimationSelf.SelectedItem;
                    atk.Target = (TargetType)DDL_Cible.SelectedItem;

                    LIST_SpecialAttacks.Items[LIST_SpecialAttacks.SelectedIndex] = atk;
                }
                else
                    GenerateSaveWarningBox("attaque spéciale", LBL_ATK_Name.Text);
            }
        }
Exemplo n.º 12
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();
            }
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
0
        private void OpenTileSet()
        {
            OpenFileDialog dlg = new OpenFileDialog();

            using (XNAUtils utils = new XNAUtils())
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    PN_Tileset.BackgroundImage = System.Drawing.Bitmap.FromFile(dlg.FileName);
                    CurrentMap.TileSet = utils.ConvertToTexture(PN_Tileset.BackgroundImage);
                    TileSetImage = CurrentMap.TileSet;

                    PN_Tileset.Size = new System.Drawing.Size(256, PN_Tileset.BackgroundImage.Height + 2);
                }
                catch (Exception)
                {
                    ShowPopup("Tuiles", "Impossible d'ouvrir l'image. Le fichier n'est pas une image valide.", PopupReason.Warning);
                }
            }
        }
Exemplo n.º 15
0
        private void limitesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DrawLimits dlg = new DrawLimits(CurrentMap);
            dlg.ShowDialog();

            if (dlg.HasSaved) using (XNAUtils utils = new XNAUtils()) CurrentMap.Limits = utils.ConvertToTexture(dlg.GetLimits());
        }