Ejemplo n.º 1
0
        private void PB_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || e.Clicks != 1 || inChildForm)
            {
                return;
            }


            byte[] dragdata = pk1_wrapper.GetBytes();


            string filename = RBY_Encoding.GetString(pk1.Nickname, JP_Mode) + " - " +
                              RBY_Encoding.GetString(pk1.OT_Name, JP_Mode) + (JP_Mode ? ".jpk1" : ".pk1");

            string newfile = Path.Combine(Path.GetTempPath(), Util.CleanFileName(filename));

            try
            {
                File.WriteAllBytes(newfile, dragdata);
                DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move);
            }
            catch (ArgumentException x)
            { Util.Error("Drag & Drop Error:", x.ToString()); }
            File.Delete(newfile);
        }
Ejemplo n.º 2
0
        public void openFile(string path)
        {
            string   ext = Path.GetExtension(path);
            FileInfo fi  = new FileInfo(path);

            if (fi.Length > 0x802C)
            {
                Util.Error("Input file is too large.", path);
            }
            else
            {
                byte[] input; try { input = File.ReadAllBytes(path); }
                catch { Util.Error("File is in use by another program!", path); return; }

                try { openFile(input, path, ext); }
                catch
                {
                    try
                    {
                        PokemonList empty = new PokemonList((byte[])PokemonList.EMPTY_LIST.Clone())
                        {
                            [0] = { OT_Name = RBY_Encoding.GetBytes(JP_Mode ? "サイドン" : "Rhydon", JP_Mode) },
                            [0] = { Nickname = RBY_Encoding.GetBytes(JP_Mode ? "サイドン" : "RHYDON", JP_Mode) },
                            [0] = { TID = 12345 },
                            [0] = { Species = 1 },
                            [0] = { Level = 1 }
                        };

                        openFile(empty.GetBytes(), path, ext);
                    }
                    catch { openFile(input, path, ext); }
                }
            }
        }
Ejemplo n.º 3
0
        private void InitializeFields()
        {
            pk1         = JP_Mode ? new JPK1() : new PK1();
            pk1.Species = (byte)PK1.SpeciesType.Rhydon;
            pk1.Move_1  = (byte)PK1.MoveType.Pound;

            PopulateFields(pk1);
            {
                if (JP_Mode)
                {
                    TB_OT.Text       = "サイドン";
                    TB_Nickname.Text = "サイドン";
                }
                else
                {
                    TB_OT.Text       = "Rhydon";
                    TB_Nickname.Text = "RHYDON";
                }
                TB_TID.Text           = 12345.ToString();
                pk1.OT_Name           = RBY_Encoding.GetBytes(TB_OT.Text, JP_Mode);
                pk1.Nickname          = RBY_Encoding.GetBytes(TB_Nickname.Text, JP_Mode);
                pk1.TID               = 12345;
                CB_PPu1.SelectedIndex = CB_PPu2.SelectedIndex = CB_PPu3.SelectedIndex = CB_PPu4.SelectedIndex = 0;
            }
            SetStatusEditing();
        }
Ejemplo n.º 4
0
        private void set(int index, PK1 to_set)
        {
            if (index >= pokemonlist.Count)
            {
                index = pokemonlist.Count++;
            }
            else
            {
                string currentpk = RBY_Encoding.GetString(pokemonlist[index].Nickname, pokemonlist[index] is JPK1) + " (" + pokemonlist[index].EXP.ToString() + " EXP)";
                string newpk     = RBY_Encoding.GetString(to_set.Nickname, to_set is JPK1) + " (" + to_set.EXP.ToString() + " EXP)";
                if (Util.Prompt(
                        MessageBoxButtons.YesNo, "Replace?" + Environment.NewLine + Environment.NewLine +
                        "Actual: " + currentpk + Environment.NewLine +
                        "New: " + newpk) != DialogResult.Yes)
                {
                    return;
                }
            }
            pokemonlist[index] = to_set;
            update(index);

            MainForm mf = FindForm() as MainForm;

            mf.SetStatusSet(index);
        }
Ejemplo n.º 5
0
        public void PopulateFields(PK1 pk, bool focus = true)
        {
            pk1 = pk ?? new PK1();

            if (focus)
            {
                Tab_Main.Focus();
            }

            pk1.Current_Level = (byte)Tables.getLevel(pk1.Species, pk1.EXP);
            if (pk1.Level == 100)
            {
                pk1.EXP = Tables.getEXP(pk1.Current_Level, pk1.Species);
            }
            pk1.Level = pk1.Current_Level;

            changingFields           = true;
            CB_Species.SelectedValue = (int)pk1.Species;

            TB_TID.Text      = pk1.TID.ToString("00000");
            TB_OT.Text       = RBY_Encoding.GetString(pk1.OT_Name, JP_Mode);
            TB_Nickname.Text = RBY_Encoding.GetString(pk1.Nickname, JP_Mode);

            TB_HPDV.Text  = pk1.DV_HP.ToString();
            TB_ATKDV.Text = pk1.DV_ATK.ToString();
            TB_DEFDV.Text = pk1.DV_DEF.ToString();
            TB_SPDDV.Text = pk1.DV_SPD.ToString();
            TB_SPCDV.Text = pk1.DV_SPC.ToString();

            TB_HPSTATEXP.Text  = pk1.STATEXP_HP.ToString();
            TB_ATKSTATEXP.Text = pk1.STATEXP_ATK.ToString();
            TB_DEFSTATEXP.Text = pk1.STATEXP_DEF.ToString();
            TB_SPCSTATEXP.Text = pk1.STATEXP_SPC.ToString();
            TB_SPDSTATEXP.Text = pk1.STATEXP_SPD.ToString();

            TB_EXP.Text   = pk1.EXP.ToString();
            TB_Level.Text = pk1.Current_Level.ToString();

            CB_Move1.SelectedValue = (int)pk1.Move_1;
            CB_Move2.SelectedValue = (int)pk1.Move_2;
            CB_Move3.SelectedValue = (int)pk1.Move_3;
            CB_Move4.SelectedValue = (int)pk1.Move_4;

            CB_PPu1.SelectedIndex = pk1.PPUP_1;
            CB_PPu2.SelectedIndex = pk1.PPUP_2;
            CB_PPu3.SelectedIndex = pk1.PPUP_3;
            CB_PPu4.SelectedIndex = pk1.PPUP_4;
            TB_PP1.Text           = pk1.PP_1.ToString();
            TB_PP2.Text           = pk1.PP_2.ToString();
            TB_PP3.Text           = pk1.PP_3.ToString();
            TB_PP4.Text           = pk1.PP_4.ToString();
            changingFields        = false;
            updateStats();

            SetStatusViewing();
        }
Ejemplo n.º 6
0
        private void HandleMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || e.Clicks != 1)
            {
                return;
            }

            Control c = sender as Control;

            if (!(c.FindForm() is MainForm))
            {
                return;
            }
            MainForm mf = c.FindForm() as MainForm;

            if (mf.getInChildForm())
            {
                return;
            }
            if (!(c.Parent is PokemonListPanel))
            {
                return;
            }
            PokemonListPanel parent = c.Parent as PokemonListPanel;
            int index = getSlot(sender);

            if (index >= parent.pokemonlist.Count)
            {
                return;
            }
            Cursor.Current = Cursors.Hand;

            byte[] dragdata = new PokemonList(parent.pokemonlist[index]).GetBytes();


            string filename = RBY_Encoding.GetString(parent.pokemonlist[index].Nickname, parent.pokemonlist[index] is JPK1) + " - " +
                              RBY_Encoding.GetString(parent.pokemonlist[index].OT_Name, parent.pokemonlist[index] is JPK1) + (parent.pokemonlist[index] is JPK1 ? ".jpk1" : ".pk1");

            string newfile = Path.Combine(Path.GetTempPath(), Util.CleanFileName(filename));

            try
            {
                File.WriteAllBytes(newfile, dragdata);
                sender_parent = parent;
                sender_slot   = index;
                DoDragDrop(new DataObject(DataFormats.FileDrop, new [] { newfile }), DragDropEffects.Move);
            }
            catch (ArgumentException x)
            { Util.Error("Drag & Drop Error:", x.ToString()); }
            File.Delete(newfile);
            sender_slot   = 0;
            sender_parent = null;
        }
Ejemplo n.º 7
0
 private void update(int i)
 {
     if (i < pokemonlist.Count)
     {
         PartySprites[i].Image = Util.GetPartySprite(pokemonlist[i]);
         Pokemon[i].Text       = RBY_Encoding.GetString(pokemonlist[i].Nickname, pokemonlist[i] is JPK1);
     }
     else
     {
         Pokemon[i].Text       = "(None)";
         PartySprites[i].Image = new Bitmap(16, 16);
     }
 }
Ejemplo n.º 8
0
        private void updateRivalName(object sender, EventArgs e)
        {
            if (changingFields || !initializedFields)
            {
                return;
            }
            changingFields = true;

            if (!RBY_Encoding.Validate(TB_Rival.Text, JP_Mode))
            {
                TB_Rival.Text = RBY_Encoding.FixString(TB_Rival.Text, JP_Mode);
            }

            sav.Rival_Name = TB_Rival.Text;
            changingFields = false;
        }
Ejemplo n.º 9
0
        private void updateOT(object sender, EventArgs e)
        {
            if (changingFields || !initializedFields)
            {
                return;
            }
            changingFields = true;

            if (!RBY_Encoding.Validate(TB_OT.Text, JP_Mode))
            {
                TB_OT.Text = RBY_Encoding.FixString(TB_OT.Text, JP_Mode);
            }

            pk1.OT_Name    = RBY_Encoding.GetBytes(TB_OT.Text, JP_Mode);
            changingFields = false;
        }
Ejemplo n.º 10
0
        private void updateNickname(object sender, EventArgs e)
        {
            if (changingFields || !initializedFields)
            {
                return;
            }
            changingFields = true;

            if (!RBY_Encoding.Validate(TB_Nickname.Text, JP_Mode))
            {
                TB_Nickname.Text = RBY_Encoding.FixString(TB_Nickname.Text, JP_Mode);
            }

            pk1.Nickname   = RBY_Encoding.GetBytes(TB_Nickname.Text, JP_Mode);
            changingFields = false;

            SetStatusEditing();
        }