Exemplo n.º 1
0
        public void EditShinyRate()
        {
            var path = Path.Combine(ROM.PathExeFS, "main");
            var data = FileMitm.ReadAllBytes(path);
            var nso  = new NSO(data);

            var shiny = new ShinyRateGG(nso.DecompressedText);

            if (!shiny.IsEditable)
            {
                WinFormsUtil.Alert("Not able to find shiny rate logic in ExeFS.");
                return;
            }

            using var editor = new ShinyRate(shiny);
            editor.ShowDialog();
            if (!editor.Modified)
            {
                return;
            }

            nso.DecompressedText = shiny.Data;
            FileMitm.WriteAllBytes(path, nso.Write());
        }
Exemplo n.º 2
0
 public int GetSlot(PictureBox sender) => slots.IndexOf(WinFormsUtil.GetUnderlyingControl <PictureBox>(sender));
Exemplo n.º 3
0
 private void SaveSpeciesLevelEXP(PKM pk)
 {
     pk.Species    = WinFormsUtil.GetIndex(CB_Species);
     pk.EXP        = Util.ToUInt32(TB_EXP.Text);
     pk.Stat_Level = Util.ToInt32(TB_Level.Text);
 }
Exemplo n.º 4
0
        private PKM PreparePK6()
        {
            PK6 pk6 = pkm as PK6;

            if (pk6 == null)
            {
                return(null);
            }

            // Repopulate PK6 with Edited Stuff
            CheckTransferPIDValid();

            pk6.EncryptionConstant = Util.GetHexValue(TB_EC.Text);
            pk6.Checksum           = 0; // 0 CHK for now

            // Block A
            pk6.Species  = WinFormsUtil.GetIndex(CB_Species);
            pk6.HeldItem = WinFormsUtil.GetIndex(CB_HeldItem);
            pk6.TID      = Util.ToInt32(TB_TID.Text);
            pk6.SID      = Util.ToInt32(TB_SID.Text);
            pk6.EXP      = Util.ToUInt32(TB_EXP.Text);

            if (CB_Ability.Text.Length >= 4)
            {
                pk6.Ability       = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
                pk6.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text);   // Number
            }

            // pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag)
            pk6.PID              = Util.GetHexValue(TB_PID.Text);
            pk6.Nature           = (byte)WinFormsUtil.GetIndex(CB_Nature);
            pk6.FatefulEncounter = CHK_Fateful.Checked;
            pk6.Gender           = PKX.GetGender(Label_Gender.Text);
            pk6.AltForm          = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F;
            pk6.EV_HP            = Util.ToInt32(TB_HPEV.Text); // EVs
            pk6.EV_ATK           = Util.ToInt32(TB_ATKEV.Text);
            pk6.EV_DEF           = Util.ToInt32(TB_DEFEV.Text);
            pk6.EV_SPE           = Util.ToInt32(TB_SPEEV.Text);
            pk6.EV_SPA           = Util.ToInt32(TB_SPAEV.Text);
            pk6.EV_SPD           = Util.ToInt32(TB_SPDEV.Text);

            pk6.CNT_Cool   = Contest.Cool;
            pk6.CNT_Beauty = Contest.Beauty;
            pk6.CNT_Cute   = Contest.Cute;
            pk6.CNT_Smart  = Contest.Smart;
            pk6.CNT_Tough  = Contest.Tough;
            pk6.CNT_Sheen  = Contest.Sheen;

            pk6.PKRS_Days   = CB_PKRSDays.SelectedIndex;
            pk6.PKRS_Strain = CB_PKRSStrain.SelectedIndex;
            // Already in buff (then transferred to new pkx)
            // 0x2C, 0x2D, 0x2E, 0x2F
            // 0x30, 0x31, 0x32, 0x33
            // 0x34, 0x35, 0x36, 0x37
            // 0x38, 0x39

            // Unused
            // 0x3A, 0x3B
            // 0x3C, 0x3D, 0x3E, 0x3F

            // Block B
            // Convert Nickname field back to bytes
            pk6.Nickname     = TB_Nickname.Text;
            pk6.Move1        = WinFormsUtil.GetIndex(CB_Move1);
            pk6.Move2        = WinFormsUtil.GetIndex(CB_Move2);
            pk6.Move3        = WinFormsUtil.GetIndex(CB_Move3);
            pk6.Move4        = WinFormsUtil.GetIndex(CB_Move4);
            pk6.Move1_PP     = WinFormsUtil.GetIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
            pk6.Move2_PP     = WinFormsUtil.GetIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
            pk6.Move3_PP     = WinFormsUtil.GetIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
            pk6.Move4_PP     = WinFormsUtil.GetIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
            pk6.Move1_PPUps  = WinFormsUtil.GetIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
            pk6.Move2_PPUps  = WinFormsUtil.GetIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
            pk6.Move3_PPUps  = WinFormsUtil.GetIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
            pk6.Move4_PPUps  = WinFormsUtil.GetIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;
            pk6.RelearnMove1 = WinFormsUtil.GetIndex(CB_RelearnMove1);
            pk6.RelearnMove2 = WinFormsUtil.GetIndex(CB_RelearnMove2);
            pk6.RelearnMove3 = WinFormsUtil.GetIndex(CB_RelearnMove3);
            pk6.RelearnMove4 = WinFormsUtil.GetIndex(CB_RelearnMove4);
            // 0x72 - Ribbon editor sets this flag (Secret Super Training)
            // 0x73
            pk6.IV_HP       = Util.ToInt32(TB_HPIV.Text);
            pk6.IV_ATK      = Util.ToInt32(TB_ATKIV.Text);
            pk6.IV_DEF      = Util.ToInt32(TB_DEFIV.Text);
            pk6.IV_SPE      = Util.ToInt32(TB_SPEIV.Text);
            pk6.IV_SPA      = Util.ToInt32(TB_SPAIV.Text);
            pk6.IV_SPD      = Util.ToInt32(TB_SPDIV.Text);
            pk6.IsEgg       = CHK_IsEgg.Checked;
            pk6.IsNicknamed = CHK_Nicknamed.Checked;

            // Block C
            pk6.HT_Name = TB_OTt2.Text;

            // 0x90-0xAF
            pk6.HT_Gender = PKX.GetGender(Label_CTGender.Text) & 1;
            // Plus more, set by MemoryAmie (already in buff)

            // Block D
            pk6.OT_Name           = TB_OT.Text;
            pk6.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);

            DateTime?egg_date     = null;
            int      egg_location = 0;

            if (CHK_AsEgg.Checked)      // If encountered as an egg, load the Egg Met data from fields.
            {
                egg_date     = CAL_EggDate.Value;
                egg_location = WinFormsUtil.GetIndex(CB_EggLocation);
            }
            // Egg Met Data
            pk6.EggMetDate   = egg_date;
            pk6.Egg_Location = egg_location;
            // Met Data
            pk6.MetDate      = CAL_MetDate.Value;
            pk6.Met_Location = WinFormsUtil.GetIndex(CB_MetLocation);

            if (pk6.IsEgg && pk6.Met_Location == 0)    // If still an egg, it has no hatch location/date. Zero it!
            {
                pk6.MetDate = null;
            }

            // 0xD7 Unknown

            pk6.Ball          = WinFormsUtil.GetIndex(CB_Ball);
            pk6.Met_Level     = Util.ToInt32(TB_MetLevel.Text);
            pk6.OT_Gender     = PKX.GetGender(Label_OTGender.Text);
            pk6.EncounterType = WinFormsUtil.GetIndex(CB_EncounterType);
            pk6.Version       = WinFormsUtil.GetIndex(CB_GameOrigin);
            pk6.Country       = WinFormsUtil.GetIndex(CB_Country);
            pk6.Region        = WinFormsUtil.GetIndex(CB_SubRegion);
            pk6.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg);
            pk6.Language      = WinFormsUtil.GetIndex(CB_Language);
            // 0xE4-0xE7

            // Toss in Party Stats
            Array.Resize(ref pk6.Data, pk6.SIZE_PARTY);
            pk6.Stat_Level     = Util.ToInt32(TB_Level.Text);
            pk6.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text);
            pk6.Stat_HPMax     = Util.ToInt32(Stat_HP.Text);
            pk6.Stat_ATK       = Util.ToInt32(Stat_ATK.Text);
            pk6.Stat_DEF       = Util.ToInt32(Stat_DEF.Text);
            pk6.Stat_SPE       = Util.ToInt32(Stat_SPE.Text);
            pk6.Stat_SPA       = Util.ToInt32(Stat_SPA.Text);
            pk6.Stat_SPD       = Util.ToInt32(Stat_SPD.Text);

            // Unneeded Party Stats (Status, Flags, Unused)
            pk6.Data[0xE8]              = pk6.Data[0xE9] = pk6.Data[0xEA] = pk6.Data[0xEB] =
                pk6.Data[0xED]          = pk6.Data[0xEE] = pk6.Data[0xEF] =
                    pk6.Data[0xFE]      = pk6.Data[0xFF] = pk6.Data[0x100] =
                        pk6.Data[0x101] = pk6.Data[0x102] = pk6.Data[0x103] = 0;

            // Hax Illegality
            if (HaX)
            {
                pk6.Ability    = (byte)WinFormsUtil.GetIndex(DEV_Ability);
                pk6.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
            }

            // Fix Moves if a slot is empty
            pk6.FixMoves();
            pk6.FixRelearn();

            // Fix Handler (Memories & OT) -- no foreign memories for Pokemon without a foreign trainer (none for eggs)
            if (ModifyPKM)
            {
                pk6.FixMemories();
            }

            // PKX is now filled
            pk6.RefreshChecksum();
            return(pk6);
        }
Exemplo n.º 5
0
        private void Reset(object sender, EventArgs e)
        {
            var sav = WinFormsUtil.FindFirstControlOfType <IMainEditor>(this).RequestSaveFile;

            NUD_CatchRate.Value = GetSuggestedPKMCatchRate(pk1, sav);
        }
Exemplo n.º 6
0
        public SpotfireApiClient SpotfireApiClient => SpotfireSession.SpotfireApiClient; // API link to Spotfire session to interact with


        public SpotfireToolbar()
        {
            InitializeComponent();
            WinFormsUtil.LogControlChildren(this);
        }
Exemplo n.º 7
0
 private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     WinFormsUtil.Alert(e.Exception.Message);
 }
Exemplo n.º 8
0
    public SAV_PokedexResearchEditorLA(SAV8LA sav, int species, int dexIdx, IReadOnlyList <string> tasks, IReadOnlyList <string> timeTasks)
    {
        InitializeComponent();
        WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
        SAV = (SAV8LA)(Origin = sav).Clone();
        Dex = SAV.Blocks.PokedexSave;

        Species = species;

        L_Species.Text = GameInfo.Strings.Species[species];

        #region Declare Arrays
        Label[] taskLabels =
        {
            L_Catch,
            L_CatchAlpha,
            L_CatchLarge,
            L_CatchSmall,
            L_CatchHeavy,
            L_CatchLight,
            L_CatchAtTime,
            L_CatchSleeping,
            L_CatchInAir,
            L_CatchNotSpotted,

            L_UseMove0,
            L_UseMove1,
            L_UseMove2,
            L_UseMove3,
            L_DefeatWithMove0,
            L_DefeatWithMove1,
            L_DefeatWithMove2,
            L_Defeat,
            L_StrongStyle,
            L_AgileStyle,

            L_Evolve,
            L_GiveFood,
            L_Stun,
            L_Scare,
            L_Lure,

            L_LeapTrees,
            L_LeapLeaves,
            L_LeapSnow,
            L_LeapOre,
            L_LeapTussocks,
        };

        TaskNUPs = new[]
        {
            NUP_Catch,
            NUP_CatchAlpha,
            NUP_CatchLarge,
            NUP_CatchSmall,
            NUP_CatchHeavy,
            NUP_CatchLight,
            NUP_CatchAtTime,
            NUP_CatchSleeping,
            NUP_CatchInAir,
            NUP_CatchNotSpotted,

            NUP_UseMove0,
            NUP_UseMove1,
            NUP_UseMove2,
            NUP_UseMove3,
            NUP_DefeatWithMove0,
            NUP_DefeatWithMove1,
            NUP_DefeatWithMove2,
            NUP_Defeat,
            NUP_StrongStyle,
            NUP_AgileStyle,

            NUP_Evolve,
            NUP_GiveFood,
            NUP_Stun,
            NUP_Scare,
            NUP_Lure,

            NUP_LeapTrees,
            NUP_LeapLeaves,
            NUP_LeapSnow,
            NUP_LeapOre,
            NUP_LeapTussocks,
        };

        TaskTypes = new[]
        {
            Catch,
            CatchAlpha,
            CatchLarge,
            CatchSmall,
            CatchHeavy,
            CatchLight,
            CatchAtTime,
            CatchSleeping,
            CatchInAir,
            CatchNotSpotted,

            UseMove,
            UseMove,
            UseMove,
            UseMove,
            DefeatWithMoveType,
            DefeatWithMoveType,
            DefeatWithMoveType,
            Defeat,
            UseStrongStyleMove,
            UseAgileStyleMove,

            Evolve,
            GiveFood,
            StunWithItems,
            ScareWithScatterBang,
            LureWithPokeshiDoll,

            LeapFromTrees,
            LeapFromLeaves,
            LeapFromSnow,
            LeapFromOre,
            LeapFromTussocks,
        };

        TaskIndexes = new[]
        {
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,

            0,
            1,
            2,
            3,
            0,
            1,
            2,
            -1,
            -1,
            -1,

            -1,
            -1,
            -1,
            -1,
            -1,

            -1,
            -1,
            -1,
            -1,
            -1,
        };

        TaskParameters = new int[TaskIndexes.Length];
        InitializeTaskParameters(dexIdx);
        #endregion

        // Initialize labels/values
        for (int i = 0; i < taskLabels.Length; i++)
        {
            taskLabels[i].Text = PokedexResearchTask8aExtensions.GetGenericTaskLabelString(TaskTypes[i], TaskIndexes[i], TaskParameters[i], tasks, timeTasks);

            Dex.GetResearchTaskProgressByForce(Species, TaskTypes[i], TaskIndexes[i], out var curValue);
            TaskNUPs[i].Value = curValue;
        }

        // Detect empty
        WasEmpty = IsEmpty();
    }
Exemplo n.º 9
0
 private int GetSlot(PictureBox sender) => SlotPictureBoxes.IndexOf(WinFormsUtil.GetUnderlyingControl(sender) as PictureBox);
Exemplo n.º 10
0
        public int InitialSplitterPos = -1;         // splitter position to set when first painting

        public QbControl()
        {
            InitializeComponent();
            WinFormsUtil.LogControlChildren(this);
        }
Exemplo n.º 11
0
        private static void ClickSet(object sender, EventArgs e)
        {
            SlotChangeManager m = GetSenderInfo(ref sender, out SlotChange info);

            if (m == null)
            {
                return;
            }

            var editor = m.SE.PKME_Tabs;
            var sav    = m.SE.SAV;

            if (info.IsParty && editor.IsEmptyOrEgg && sav.IsPartyAllEggs(info.Slot - 30) && !m.SE.HaX)
            {
                WinFormsUtil.Alert("Can't have empty/egg party."); return;
            }
            if (m.SE.SAV.IsSlotLocked(info.Box, info.Slot))
            {
                WinFormsUtil.Alert("Can't set to locked slot."); return;
            }

            if (!editor.VerifiedPKM())
            {
                return;
            }

            PKM pk = editor.PreparePKM();

            string[] errata = sav.IsPKMCompatible(pk);
            if (errata.Length > 0 && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, string.Join(Environment.NewLine, errata), "Continue?"))
            {
                return;
            }

            if (info.Slot >= 30)
            {
                info.Box = -1;
            }
            if (info.Slot >= 30 && info.Slot < 36) // Party
            {
                // If info.Slot isn't overwriting existing PKM, make it write to the lowest empty PKM info.Slot
                if (sav.PartyCount < info.Slot + 1 - 30)
                {
                    info.Slot   = sav.PartyCount + 30;
                    info.Offset = m.SE.GetPKMOffset(info.Slot);
                }
                m.SetPKM(pk, info, true, Resources.slotSet);
            }
            else if (info.Slot < 30 || m.SE.HaX)
            {
                if (info.Slot < 30)
                {
                    m.SE.UndoStack.Push(new SlotChange
                    {
                        Box    = info.Box,
                        Slot   = info.Slot,
                        Offset = info.Offset,
                        PKM    = sav.GetStoredSlot(info.Offset)
                    });
                    m.SE.Menu_Undo.Enabled = true;
                }

                m.SetPKM(pk, info, true, Resources.slotSet);
            }

            editor.LastData = pk.Data;
            m.SE.RedoStack.Clear(); m.SE.Menu_Redo.Enabled = false;
        }
Exemplo n.º 12
0
 private void B_OK_Click(object sender, EventArgs e)
 {
     Result = (GameVersion)WinFormsUtil.GetIndex(CB_Game);
     Close();
 }
Exemplo n.º 13
0
        private PKM PreparePK3()
        {
            PK3 pk3 = pkm as PK3;

            if (pk3 == null)
            {
                return(null);
            }

            pk3.Species       = WinFormsUtil.GetIndex(CB_Species);
            pk3.HeldItem      = WinFormsUtil.GetIndex(CB_HeldItem);
            pk3.TID           = Util.ToInt32(TB_TID.Text);
            pk3.SID           = Util.ToInt32(TB_SID.Text);
            pk3.EXP           = Util.ToUInt32(TB_EXP.Text);
            pk3.PID           = Util.GetHexValue(TB_PID.Text);
            pk3.AbilityNumber = 1 << CB_Ability.SelectedIndex; // to match gen6+

            pk3.FatefulEncounter = CHK_Fateful.Checked;
            pk3.Gender           = PKX.GetGender(Label_Gender.Text);
            pk3.EV_HP            = Util.ToInt32(TB_HPEV.Text);
            pk3.EV_ATK           = Util.ToInt32(TB_ATKEV.Text);
            pk3.EV_DEF           = Util.ToInt32(TB_DEFEV.Text);
            pk3.EV_SPE           = Util.ToInt32(TB_SPEEV.Text);
            pk3.EV_SPA           = Util.ToInt32(TB_SPAEV.Text);
            pk3.EV_SPD           = Util.ToInt32(TB_SPDEV.Text);

            pk3.CNT_Cool   = Contest.Cool;
            pk3.CNT_Beauty = Contest.Beauty;
            pk3.CNT_Cute   = Contest.Cute;
            pk3.CNT_Smart  = Contest.Smart;
            pk3.CNT_Tough  = Contest.Tough;
            pk3.CNT_Sheen  = Contest.Sheen;

            pk3.PKRS_Days   = CB_PKRSDays.SelectedIndex;
            pk3.PKRS_Strain = CB_PKRSStrain.SelectedIndex;
            pk3.Nickname    = TB_Nickname.Text;
            pk3.Move1       = WinFormsUtil.GetIndex(CB_Move1);
            pk3.Move2       = WinFormsUtil.GetIndex(CB_Move2);
            pk3.Move3       = WinFormsUtil.GetIndex(CB_Move3);
            pk3.Move4       = WinFormsUtil.GetIndex(CB_Move4);
            pk3.Move1_PP    = WinFormsUtil.GetIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
            pk3.Move2_PP    = WinFormsUtil.GetIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
            pk3.Move3_PP    = WinFormsUtil.GetIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
            pk3.Move4_PP    = WinFormsUtil.GetIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
            pk3.Move1_PPUps = WinFormsUtil.GetIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
            pk3.Move2_PPUps = WinFormsUtil.GetIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
            pk3.Move3_PPUps = WinFormsUtil.GetIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
            pk3.Move4_PPUps = WinFormsUtil.GetIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;

            pk3.IV_HP       = Util.ToInt32(TB_HPIV.Text);
            pk3.IV_ATK      = Util.ToInt32(TB_ATKIV.Text);
            pk3.IV_DEF      = Util.ToInt32(TB_DEFIV.Text);
            pk3.IV_SPE      = Util.ToInt32(TB_SPEIV.Text);
            pk3.IV_SPA      = Util.ToInt32(TB_SPAIV.Text);
            pk3.IV_SPD      = Util.ToInt32(TB_SPDIV.Text);
            pk3.IsEgg       = CHK_IsEgg.Checked;
            pk3.IsNicknamed = CHK_Nicknamed.Checked;

            pk3.OT_Name           = TB_OT.Text;
            pk3.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);

            pk3.Ball      = WinFormsUtil.GetIndex(CB_Ball);
            pk3.Met_Level = Util.ToInt32(TB_MetLevel.Text);
            pk3.OT_Gender = PKX.GetGender(Label_OTGender.Text);
            pk3.Version   = WinFormsUtil.GetIndex(CB_GameOrigin);
            pk3.Language  = WinFormsUtil.GetIndex(CB_Language);

            pk3.Met_Location = WinFormsUtil.GetIndex(CB_MetLocation);

            // Toss in Party Stats
            Array.Resize(ref pk3.Data, pk3.SIZE_PARTY);
            pk3.Stat_Level     = Util.ToInt32(TB_Level.Text);
            pk3.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text);
            pk3.Stat_HPMax     = Util.ToInt32(Stat_HP.Text);
            pk3.Stat_ATK       = Util.ToInt32(Stat_ATK.Text);
            pk3.Stat_DEF       = Util.ToInt32(Stat_DEF.Text);
            pk3.Stat_SPE       = Util.ToInt32(Stat_SPE.Text);
            pk3.Stat_SPA       = Util.ToInt32(Stat_SPA.Text);
            pk3.Stat_SPD       = Util.ToInt32(Stat_SPD.Text);

            if (HaX)
            {
                pk3.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
            }

            // Fix Moves if a slot is empty
            pk3.FixMoves();

            pk3.RefreshChecksum();
            return(pk3);
        }
Exemplo n.º 14
0
 private void UpdateCountry(object sender, EventArgs e)
 {
     int index;
     if (sender is ComboBox c && (index = WinFormsUtil.GetIndex(c)) > 0)
         Main.SetCountrySubRegion(CB_Region, $"sr_{index:000}");
 }
Exemplo n.º 15
0
    private void Save()
    {
        SAV.Game = (byte)(CB_Game.SelectedIndex + 0x18);
        SAV.Gender = (byte)CB_Gender.SelectedIndex;

        SAV.TID = (ushort)Util.ToUInt32(MT_TID.Text);
        SAV.SID = (ushort)Util.ToUInt32(MT_SID.Text);
        SAV.Money = Util.ToUInt32(MT_Money.Text);
        SAV.Region = (byte)WinFormsUtil.GetIndex(CB_Region);
        SAV.Country = (byte)WinFormsUtil.GetIndex(CB_Country);
        SAV.ConsoleRegion = (byte)WinFormsUtil.GetIndex(CB_3DSReg);
        SAV.Language = WinFormsUtil.GetIndex(CB_Language);

        SAV.OT = TB_OTName.Text;

        var status = SAV.Status;
        status.Saying1 = TB_Saying1.Text;
        status.Saying2 = TB_Saying2.Text;
        status.Saying3 = TB_Saying3.Text;
        status.Saying4 = TB_Saying4.Text;
        status.Saying5 = TB_Saying5.Text;

        // Copy Maison Data in
        if (SAV is ISaveBlock6Main xyao)
        {
            for (int i = 0; i < MaisonBlock.MaisonStatCount; i++)
                xyao.Maison.SetMaisonStat(i, ushort.Parse(MaisonRecords[i].Text));
        }

        // Copy Position
        var sit = SAV.Situation;
        if (GB_Map.Enabled && MapUpdated)
        {
            sit.M = (int)NUD_M.Value;
            sit.X = (float)NUD_X.Value;
            sit.Z = (float)NUD_Z.Value;
            sit.Y = (float)NUD_Y.Value;
        }

        SAV.BP = ushort.Parse(TB_BP.Text);
        // Set Current PokéMiles
        SAV.SetRecord(63, Util.ToInt32(TB_PM.Text));
        // Set Max Obtained Pokémiles
        SAV.SetRecord(64, Util.ToInt32(TB_PM.Text));
        sit.Style = byte.Parse(TB_Style.Text);

        // Copy Badges
        int badgeval = 0;
        for (int i = 0; i < 8; i++)
            badgeval |= (cba[i].Checked ? 1 : 0) << i;
        SAV.Badges = badgeval;

        // Save PlayTime
        SAV.PlayedHours = ushort.Parse(MT_Hours.Text);
        SAV.PlayedMinutes = ushort.Parse(MT_Minutes.Text)%60;
        SAV.PlayedSeconds = ushort.Parse(MT_Seconds.Text)%60;

        // Sprite
        if (SAV is IMultiplayerSprite ms)
            ms.MultiplayerSpriteID = Convert.ToByte(CB_MultiplayerSprite.SelectedValue);

        // Appearance
        if (SAV is SAV6XY xy)
        {
            var xystat = (MyStatus6XY)xy.Status;
            xystat.Fashion = (TrainerFashion6)PG_CurrentAppearance.SelectedObject;
            xystat.OT_Nick = TB_TRNick.Text;
        }

        // Vivillon
        SAV.Vivillon = CB_Vivillon.SelectedIndex;

        SAV.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(CAL_AdventureStartDate.Value, CAL_AdventureStartTime.Value);
        SAV.SecondsToFame = (uint)DateUtil.GetSecondsFrom2000(CAL_HoFDate.Value, CAL_HoFTime.Value);

        if (SAV.Played.LastSavedDate.HasValue)
            SAV.Played.LastSavedDate = new DateTime(CAL_LastSavedDate.Value.Year, CAL_LastSavedDate.Value.Month, CAL_LastSavedDate.Value.Day, CAL_LastSavedTime.Value.Hour, CAL_LastSavedTime.Value.Minute, 0);

        status.IsMegaEvolutionUnlocked = CHK_MegaUnlocked.Checked;
        status.IsMegaRayquazaUnlocked = CHK_MegaRayquazaUnlocked.Checked;
    }
Exemplo n.º 16
0
    private void SetEntry(int index, int formIndex)
    {
        if (!CanSave || Editing || index < 0 || formIndex < 0)
        {
            return;
        }

        var empty = IsEntryEmpty(index, formIndex);

        if (!CHK_Seen.Checked && empty)
        {
            return;
        }

        var species = DexToSpecies[index + 1];
        var form    = DisplayedForms[formIndex].Value;

        if (!empty)
        {
            Dex.SetPokeHasBeenUpdated(species);
        }

        // Flags
        var seenWild   = 0;
        var obtain     = 0;
        var caughtWild = 0;

        for (var i = 0; i < CHK_SeenWild.Length; i++)
        {
            seenWild   |= CHK_SeenWild[i].Checked ? (1 << i) : 0;
            obtain     |= CHK_Obtained[i].Checked ? (1 << i) : 0;
            caughtWild |= CHK_CaughtWild[i].Checked ? (1 << i) : 0;
        }

        Dex.SetPokeSeenInWildFlags(species, form, (byte)seenWild);
        Dex.SetPokeObtainFlags(species, form, (byte)obtain);
        Dex.SetPokeCaughtInWildFlags(species, form, (byte)caughtWild);
        Dex.SetSolitudeComplete(species, CHK_Solitude.Checked);

        // Display
        var dispForm = form;

        if (CB_DisplayForm.Enabled)
        {
            dispForm = WinFormsUtil.GetIndex(CB_DisplayForm);
        }

        Dex.SetSelectedGenderForm(species, dispForm, CHK_G.Checked, CHK_S.Checked, CHK_A.Checked);

        // Set research
        for (var i = 0; i < PokedexConstants8a.ResearchTasks[index].Length; i++)
        {
            if (TaskControls[i].CanSetCurrentValue)
            {
                Dex.SetResearchTaskProgressByForce(species, TaskControls[i].Task, TaskControls[i].CurrentValue);
            }
        }

        // Statistics
        Dex.GetSizeStatistics(species, form, out _, out var oldMinHeight, out var oldMaxHeight, out var oldMinWeight, out var oldMaxWeight);

        if (!float.TryParse(TB_MinHeight.Text, out var minHeight))
        {
            minHeight = oldMinHeight;
        }

        if (!float.TryParse(TB_MaxHeight.Text, out var maxHeight))
        {
            maxHeight = oldMaxHeight;
        }

        if (!float.TryParse(TB_MinWeight.Text, out var minWeight))
        {
            minWeight = oldMinWeight;
        }

        if (!float.TryParse(TB_MaxWeight.Text, out var maxWeight))
        {
            maxWeight = oldMaxWeight;
        }

        Dex.SetSizeStatistics(species, form, CHK_MinAndMax.Checked, minHeight, maxHeight, minWeight, maxWeight);
    }
Exemplo n.º 17
0
 private void B_CopyText_Click(object sender, EventArgs e)
 {
     WinFormsUtil.SetClipboardText(RTB.Text);
 }
Exemplo n.º 18
0
        public event EventHandler ColumnChanged;         // event to fire when column changes

/// <summary>
/// Constructor
/// </summary>

        public CalcFieldColumnControl()
        {
            InitializeComponent();
            WinFormsUtil.LogControlChildren(this);
        }
Exemplo n.º 19
0
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     WinFormsUtil.Alert(e.ExceptionObject.ToString());
 }
Exemplo n.º 20
0
        public event EventHandler ValueChangedCallback;         // event to fire back to caller when edit value changes here

        public ScaleAxisPanel()
        {
            InitializeComponent();
            WinFormsUtil.LogControlChildren(this);
        }
Exemplo n.º 21
0
 private static ISlotViewer <T> GetViewParent <T>(T pb) where T : Control
 => WinFormsUtil.FindFirstControlOfType <ISlotViewer <T> >(pb);
Exemplo n.º 22
0
        private Bitmap overlayEntities(Bitmap img)
        {
            const float opacity = 0.66f;

            // Overlay every... overworld entity
            foreach (var e in OWSE.CurrentZone.Entities.Furniture)
            {
                int x = e.X;
                int y = e.Y;
                for (int sx = 0; sx < e.WX; sx++)     // Stretch X
                {
                    for (int sy = 0; sy < e.WY; sy++) // Stretch Y
                    {
                        try { WinFormsUtil.LayerImage(img, Properties.Resources.F, (x + sx) * mapScale, (y + sy) * mapScale, opacity); }
                        catch { }
                    }
                }
            }
            foreach (var e in OWSE.CurrentZone.Entities.NPCs)
            {
                int x = e.X;
                int y = e.Y;
                try { WinFormsUtil.LayerImage(img, Properties.Resources.N, x * mapScale, y * mapScale, opacity); }
                catch { }
            }
            foreach (var e in OWSE.CurrentZone.Entities.Warps)
            {
                int x = (int)e.pX;                        // shifted warps look weird
                int y = (int)e.pY;                        // shifted warps look weird
                for (int sx = 0; sx < e.Width; sx++)      // Stretch X
                {
                    for (int sy = 0; sy < e.Height; sy++) // Stretch Y
                    {
                        try { WinFormsUtil.LayerImage(img, Properties.Resources.W, (x + sx) * mapScale, (y + sy) * mapScale, opacity); }
                        catch { }
                    }
                }
            }
            foreach (var e in OWSE.CurrentZone.Entities.Triggers1)
            {
                int x = e.X;
                int y = e.Y;
                for (int sx = 0; sx < e.Width; sx++)      // Stretch X
                {
                    for (int sy = 0; sy < e.Height; sy++) // Stretch Y
                    {
                        try { WinFormsUtil.LayerImage(img, Properties.Resources.T1, (x + sx) * mapScale, (y + sy) * mapScale, opacity); }
                        catch { }
                    }
                }
            }
            foreach (var e in OWSE.CurrentZone.Entities.Triggers2)
            {
                int x = e.X;
                int y = e.Y;
                for (int sx = 0; sx < e.Width; sx++)      // Stretch X
                {
                    for (int sy = 0; sy < e.Height; sy++) // Stretch Y
                    {
                        try { WinFormsUtil.LayerImage(img, Properties.Resources.T2, (x + sx) * mapScale, (y + sy) * mapScale, opacity); }
                        catch { }
                    }
                }
            }

            // Overlay Map Data
            // Flyto
            {
                int x = (int)OWSE.CurrentZone.ZD.pX2;
                int y = (int)OWSE.CurrentZone.ZD.pY2;
                for (int sx = 0; sx < 1; sx++)     // Stretch X
                {
                    for (int sy = 0; sy < 1; sy++) // Stretch Y
                    {
                        try { WinFormsUtil.LayerImage(img, Properties.Resources.FLY, (x + sx) * mapScale, (y + sy) * mapScale, opacity / 2); }
                        catch { }
                    }
                }
            }
            // Unknown
            //{
            //    using(var g = Graphics.FromImage(img))
            //        foreach (var l in OWSE.mm.LoadLines)
            //            try { g.DrawLine(new Pen(Color.Red, 4), l.p2 * mapScale, l.p1 * mapScale, l.p4 * mapScale, l.p3 * mapScale); }
            //            catch {}
            //}

            return(img);
        }
Exemplo n.º 23
0
        private string FormatKey(Keys key)
        {
            Keys body      = key & Keys.KeyCode;
            Keys modifiers = key & Keys.Modifiers;

            //modifierは常に表示する
            StringBuilder b = new StringBuilder();

            if ((modifiers & Keys.Control) != Keys.None)
            {
                b.Append("Ctrl");
            }
            if ((modifiers & Keys.Shift) != Keys.None)
            {
                if (b.Length > 0)
                {
                    b.Append('+');
                }
                b.Append("Shift");
            }
            if ((modifiers & Keys.Alt) != Keys.None)
            {
                if (b.Length > 0)
                {
                    b.Append('+');
                }
                b.Append("Alt");
            }
            if (b.Length > 0)
            {
                b.Append('+');
            }

            //この条件付けやや恣意的

            if (IsCharKey(body))
            {
                if (modifiers != Keys.None && modifiers != Keys.Shift)
                {
                    if (modifiers == Keys.Alt && (Keys.D0 <= body && body <= Keys.D9))
                    {
                        _key = Keys.None;
                    }
                    else
                    {
                        b.Append(WinFormsUtil.KeyString(body));
                        _key = key;
                    }
                }
                else
                {
                    _key = Keys.None;
                }
            }
            else if (IsTerminalKey(body))
            {
                if (modifiers != Keys.None)
                {
                    //カスタマイズ不能で固定されたショートカットキーは登録できない
                    if (modifiers == Keys.Control && IsScrollKey(body))
                    {
                        _key = Keys.None;
                    }
                    else
                    {
                        b.Append(WinFormsUtil.KeyString(body));
                        _key = key;
                    }
                }
                else
                {
                    _key = Keys.None;
                }
            }
            else if (IsFunctionKey(body))
            {
                b.Append(WinFormsUtil.KeyString(body));
                _key = key;
            }
            else if (!IsModifierKey(body))
            {
                _key = Keys.None;
            }

            return(b.ToString());
        }
Exemplo n.º 24
0
 private void ParseKeys()
 {
     _intelliSenseKeyCache = WinFormsUtil.ParseKey(_intelliSenseKey.Value);
     _commandPopupKeyCache = WinFormsUtil.ParseKey(_commandPopupKey.Value);
     _parseKeyRequired     = false;
 }
Exemplo n.º 25
0
 public FilterStructureControl()
 {
     InitializeComponent();
     WinFormsUtil.LogControlChildren(this);
 }
Exemplo n.º 26
0
        public event EventHandler EditValueChanged;         // event to fire when edit value changes

        public ShapeBySelectorControl()
        {
            InitializeComponent();
            WinFormsUtil.LogControlChildren(this);
        }
Exemplo n.º 27
0
 private void SaveGeolocation(IRegionOrigin pk)
 {
     pk.Country       = (byte)WinFormsUtil.GetIndex(CB_Country);
     pk.Region        = (byte)WinFormsUtil.GetIndex(CB_SubRegion);
     pk.ConsoleRegion = (byte)WinFormsUtil.GetIndex(CB_3DSReg);
 }
Exemplo n.º 28
0
 private void SaveGeolocation(PKM pk)
 {
     pk.Country       = WinFormsUtil.GetIndex(CB_Country);
     pk.Region        = WinFormsUtil.GetIndex(CB_SubRegion);
     pk.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg);
 }
        private void ClickSet(object sender, EventArgs e)
        {
            var m = GetSenderInfo(ref sender, out SlotChange info);

            if (m == null)
            {
                return;
            }

            var editor = m.SE.PKME_Tabs;
            var sav    = m.SE.SAV;

            if (info.IsParty && editor.IsEmptyOrEgg && sav.IsPartyAllEggs(info.Slot) && !m.SE.HaX)
            {
                WinFormsUtil.Alert(MsgSaveSlotEmpty); return;
            }
            if (m.SE.SAV.IsSlotLocked(info.Box, info.Slot))
            {
                WinFormsUtil.Alert(MsgSaveSlotLocked); return;
            }

            if (!editor.EditsComplete)
            {
                return;
            }

            PKM pk = editor.PreparePKM();

            var errata = sav.IsPKMCompatible(pk);

            if (errata.Count > 0 && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, string.Join(Environment.NewLine, errata), MsgContinue))
            {
                return;
            }

            m.HoverCancel();

            if (info.Type == StorageSlotType.Party) // Party
            {
                // If info.Slot isn't overwriting existing PKM, make it write to the lowest empty PKM info.Slot
                if (sav.PartyCount < info.Slot + 1)
                {
                    var pb   = (PictureBox)WinFormsUtil.GetUnderlyingControl(sender);
                    var view = WinFormsUtil.FindFirstControlOfType <ISlotViewer <PictureBox> >(pb);
                    info = view.GetSlotData(view.SlotPictureBoxes[sav.PartyCount]);
                }
                m.SetPKM(pk, info, true, Resources.slotSet);
            }
            else if (info.Type == StorageSlotType.Box || m.SE.HaX)
            {
                if (info.Type == StorageSlotType.Box)
                {
                    m.SE.UndoStack.Push(new SlotChange(info, sav));
                    m.SE.Menu_Undo.Enabled = true;
                }

                m.SetPKM(pk, info, true, Resources.slotSet);
            }
            else
            {
                return;
            }

            editor.LastData = pk.Data;
            m.SE.RedoStack.Clear(); m.SE.Menu_Redo.Enabled = false;
        }
Exemplo n.º 30
0
    public SAV_PokedexLA(SAV8LA sav)
    {
        InitializeComponent();
        WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
        SAV = (SAV8LA)(Origin = sav).Clone();
        Dex = SAV.Blocks.PokedexSave;
        var speciesNames = GameInfo.Strings.Species;

        CHK_SeenWild   = new[] { CHK_S0, CHK_S1, CHK_S2, CHK_S3, CHK_S4, CHK_S5, CHK_S6, CHK_S7 };
        CHK_Obtained   = new[] { CHK_O0, CHK_O1, CHK_O2, CHK_O3, CHK_O4, CHK_O5, CHK_O6, CHK_O7 };
        CHK_CaughtWild = new[] { CHK_C0, CHK_C1, CHK_C2, CHK_C3, CHK_C4, CHK_C5, CHK_C6, CHK_C7 };

        TaskControls = new []
        {
            PRT_1,
            PRT_2,
            PRT_3,
            PRT_4,
            PRT_5,
            PRT_6,
            PRT_7,
            PRT_8,
            PRT_9,
            PRT_10,
        };

        foreach (var tc in TaskControls)
        {
            tc.Visible = false;
            tc.SetStrings(TaskDescriptions, SpeciesQuests, TimeTaskDescriptions);
        }

        SpeciesToDex = new int[SAV.Personal.MaxSpeciesID + 1];

        var maxDex = 0;

        for (var s = 1; s <= SAV.Personal.MaxSpeciesID; s++)
        {
            var hisuiDex = PokedexSave8a.GetDexIndex(PokedexType8a.Hisui, s);
            if (hisuiDex == 0)
            {
                continue;
            }

            SpeciesToDex[s] = hisuiDex;
            if (hisuiDex > maxDex)
            {
                maxDex = hisuiDex;
            }
        }

        DexToSpecies = new int[maxDex + 1];
        for (var s = 1; s <= SAV.Personal.MaxSpeciesID; s++)
        {
            if (SpeciesToDex[s] != 0)
            {
                DexToSpecies[SpeciesToDex[s]] = s;
            }
        }

        Editing = true;
        // Clear Listbox and ComboBox
        LB_Species.Items.Clear();
        CB_Species.Items.Clear();

        // Fill List
        CB_Species.InitializeBinding();
        var species = GameInfo.FilteredSources.Species.Where(z => PokedexSave8a.GetDexIndex(PokedexType8a.Hisui, z.Value) != 0).ToArray();

        CB_Species.DataSource = new BindingSource(species, null);

        CB_DisplayForm.InitializeBinding();
        DisplayedForms = new List <ComboItem> {
            new(GameInfo.Strings.types[0], 0)
        };
        CB_DisplayForm.DataSource = new BindingSource(DisplayedForms, null);

        for (var d = 1; d < DexToSpecies.Length; d++)
        {
            LB_Species.Items.Add($"{d:000} - {speciesNames[DexToSpecies[d]]}");
        }

        Editing = false;
        LB_Species.SelectedIndex = 0;
        CB_Species.KeyDown      += WinFormsUtil.RemoveDropCB;
        CanSave = true;
    }