private void UpdateMemoryDisplay(object sender) { if (sender == CB_CTMemory) { int memory = WinFormsUtil.GetIndex((ComboBox)sender); var memIndex = Memories.GetMemoryArgType(memory, pkm.GenNumber); var argvals = MemStrings.GetArgumentStrings(memIndex); CB_CTVar.InitializeBinding(); CB_CTVar.DataSource = new BindingSource(argvals, null); LCTV.Text = TextArgs.GetMemoryCategory(memIndex, pkm.GenNumber); LCTV.Visible = CB_CTVar.Visible = CB_CTVar.Enabled = argvals.Count > 1; } else { int memory = WinFormsUtil.GetIndex((ComboBox)sender); var memIndex = Memories.GetMemoryArgType(memory, pkm.Format); var argvals = MemStrings.GetArgumentStrings(memIndex); CB_OTVar.InitializeBinding(); CB_OTVar.DataSource = new BindingSource(argvals, null); LOTV.Text = TextArgs.GetMemoryCategory(memIndex, pkm.Format); LOTV.Visible = CB_OTVar.Visible = CB_OTVar.Enabled = argvals.Count > 1; } }
private void B_Save_Click(object sender, EventArgs e) { // Copy Bags byte[] bagarray = new byte[12]; int emptyslots = 0; for (int i = 0; i < 12; i++) { string bag = dataGridView1.Rows[i].Cells[1].Value.ToString(); if (Array.IndexOf(trba, bag) == 0) { emptyslots++; continue; } bagarray[i - emptyslots] = (byte)Array.IndexOf(trba, bag); } try { BitConverter.GetBytes(float.Parse(TB_Time1.Text)).CopyTo(SAV.Data, offsetTime + (4 * 30)); } catch { } try { BitConverter.GetBytes(float.Parse(TB_Time2.Text)).CopyTo(SAV.Data, offsetTime + (4 * 31)); } catch { } BitConverter.GetBytes((ushort)WinFormsUtil.GetIndex(CB_S2)).CopyTo(SAV.Data, offsetSpec + (4 * 30)); bagarray.CopyTo(SAV.Data, SAV.SuperTrain + 0x308); Origin.SetData(SAV.Data, 0); Close(); }
private void B_Close_Click(object sender, EventArgs e) { int ofs = SAV.HoF; SAV.Data[ofs] &= 0xFE; SAV.Data[ofs] |= (byte)(CHK_Flag.Checked ? 1 : 0); BitConverter.GetBytes((ushort)NUD_Count.Value).CopyTo(SAV.Data, ofs + 2); for (int i = 0; i < entries.Length; i++) { int o = ofs + 4 + i * 2; var cb = entries[i]; var val = WinFormsUtil.GetIndex(cb); BitConverter.GetBytes((ushort)val).CopyTo(SAV.Data, o); } if (SAV.USUM) { SAV.StarterEncryptionConstant = Util.GetHexValue(TB_EC.Text); } Origin.SetData(SAV.Data, 0); Close(); }
private void UpdateMemoryDisplay(object sender) { int memory = WinFormsUtil.GetIndex((ComboBox)sender); var memIndex = Memories.GetMemoryArgType(memory); var argvals = GameInfo.Strings.Memories.GetArgumentStrings(memIndex); if (sender == CB_CTMemory) { CB_CTVar.DisplayMember = nameof(ComboItem.Text); CB_CTVar.ValueMember = nameof(ComboItem.Value); CB_CTVar.DataSource = argvals; LCTV.Text = vartypes[(int)memIndex]; LCTV.Visible = CB_CTVar.Visible = CB_CTVar.Enabled = argvals.Count > 1; } else { CB_OTVar.DisplayMember = nameof(ComboItem.Text); CB_OTVar.ValueMember = nameof(ComboItem.Value); CB_OTVar.DataSource = argvals; LOTV.Text = vartypes[(int)memIndex]; LOTV.Visible = CB_OTVar.Visible = CB_OTVar.Enabled = argvals.Count > 1; } }
private void UpdateSlotValue(object sender, EventArgs e) { if (CurrentSlot == null) { return; } if (sender == CB_Species) { CurrentSlot.Species = WinFormsUtil.GetIndex(CB_Species); LB_Slots.Items[currentIndex] = GameInfo.Strings.Species[CurrentSlot.Species]; SetForms(CurrentSlot); SetGenders(CurrentSlot); } else if (sender == CB_Move) { CurrentSlot.Move = WinFormsUtil.GetIndex(CB_Move); } else if (sender == CB_Gender) { CurrentSlot.Gender = WinFormsUtil.GetIndex(CB_Gender); } else if (sender == CB_Form) { CurrentSlot.Form = CB_Form.SelectedIndex; } else if (sender == CHK_Invisible) { CurrentSlot.Invisible = CHK_Invisible.Checked; } else if (sender == NUD_Animation) { CurrentSlot.Animation = (int)NUD_Animation.Value; } SetSprite(CurrentSlot); }
private void UpdateGender(object sender, EventArgs e) { // Get Gender Threshold int species = WinFormsUtil.GetIndex(CB_Species); var pi = SAV.Personal[species]; if (pi.IsDualGender) { var fg = PKX.GetGenderFromString(Label_Gender.Text); fg = (fg ^ 1) & 1; Label_Gender.Text = Main.GenderSymbols[fg]; } else { var fg = pi.FixedGender; Label_Gender.Text = Main.GenderSymbols[fg]; return; } var g = PKX.GetGenderFromString(CB_Form.Text); if (g == 0 && Label_Gender.Text != gendersymbols[0]) { CB_Form.SelectedIndex = 1; } else if (g == 1 && Label_Gender.Text != gendersymbols[1]) { CB_Form.SelectedIndex = 0; } if (species == (int)Species.Pyroar) { CB_Form.SelectedIndex = PKX.GetGenderFromString(Label_Gender.Text); } Write_Entry(this, EventArgs.Empty); }
private void B_ApplyTrash_Click(object sender, EventArgs e) { string species = SpeciesName.GetSpeciesNameGeneration(WinFormsUtil.GetIndex(CB_Species), WinFormsUtil.GetIndex(CB_Language), (int) NUD_Generation.Value); if (string.IsNullOrEmpty(species)) // no result species = CB_Species.Text; byte[] current = SetString(TB_Text.Text); byte[] data = SetString(species); if (data.Length <= current.Length) { WinFormsUtil.Alert("Trash byte layer is hidden by current text.", $"Current Bytes: {current.Length}" + Environment.NewLine + $"Layer Bytes: {data.Length}"); return; } if (data.Length > Bytes.Count) { WinFormsUtil.Alert("Trash byte layer is too long to apply."); return; } for (int i = current.Length; i < data.Length; i++) Bytes[i].Value = data[i]; }
private void UpdateNickname(object sender, EventArgs e) { if (!CHK_Nicknamed.Checked) { // Fetch Current Species and set it as Nickname Text int species = WinFormsUtil.GetIndex(CB_Species); if (species == 0 || species > 721) { TB_Nickname.Text = ""; } else { try { // get language TB_Nickname.Text = PKX.GetSpeciesNameGeneration(species, SAV.Language, 6); } catch { } } } TB_Nickname.ReadOnly = !CHK_Nicknamed.Checked; Write_Entry(null, null); }
private void SaveTrainerInfo() { SAV.Game = (byte)(CB_Game.SelectedIndex + 30); SAV.Gender = (byte)CB_Gender.SelectedIndex; SAV.Money = Util.ToUInt32(MT_Money.Text); SAV.SubRegion = WinFormsUtil.GetIndex(CB_Region); SAV.Country = WinFormsUtil.GetIndex(CB_Country); SAV.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg); SAV.Language = WinFormsUtil.GetIndex(CB_Language); SAV.OT = TB_OTName.Text; // Copy Position if (GB_Map.Enabled && MapUpdated) { SAV.Situation.M = (int)NUD_M.Value; SAV.Situation.X = (float)NUD_X.Value; SAV.Situation.Z = (float)NUD_Z.Value; SAV.Situation.Y = (float)NUD_Y.Value; SAV.Situation.R = (float)NUD_R.Value; SAV.Situation.UpdateOverworldCoordinates(); } // 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; SAV.SecondsToStart = (uint)Util.GetSecondsFrom2000(CAL_AdventureStartDate.Value, CAL_AdventureStartTime.Value); SAV.SecondsToFame = (uint)Util.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); } }
private SearchSettings GetSearchSettings() { var settings = new SearchSettings { Format = SAV.Generation, // 0->(n-1) => 1->n Generation = SAV.Generation, Species = WinFormsUtil.GetIndex(CB_Species), BatchInstructions = RTB_Instructions.Lines, }; settings.AddMove(WinFormsUtil.GetIndex(CB_Move1)); settings.AddMove(WinFormsUtil.GetIndex(CB_Move2)); settings.AddMove(WinFormsUtil.GetIndex(CB_Move3)); settings.AddMove(WinFormsUtil.GetIndex(CB_Move4)); if (CHK_IsEgg.CheckState != CheckState.Indeterminate) { settings.SearchEgg = CHK_IsEgg.CheckState == CheckState.Checked; } return(settings); }
private void SaveFields() { // Save Region & Country Data if (pkm is IGeoTrack g) { g.Geo1_Region = WinFormsUtil.GetIndex(CB_Region0); g.Geo2_Region = WinFormsUtil.GetIndex(CB_Region1); g.Geo3_Region = WinFormsUtil.GetIndex(CB_Region2); g.Geo4_Region = WinFormsUtil.GetIndex(CB_Region3); g.Geo5_Region = WinFormsUtil.GetIndex(CB_Region4); g.Geo1_Country = WinFormsUtil.GetIndex(CB_Country0); g.Geo2_Country = WinFormsUtil.GetIndex(CB_Country1); g.Geo3_Country = WinFormsUtil.GetIndex(CB_Country2); g.Geo4_Country = WinFormsUtil.GetIndex(CB_Country3); g.Geo5_Country = WinFormsUtil.GetIndex(CB_Country4); } // Save 0-255 stats pkm.HT_Friendship = Util.ToInt32(M_CT_Friendship.Text); pkm.HT_Affection = Util.ToInt32(M_CT_Affection.Text); pkm.OT_Friendship = Util.ToInt32(M_OT_Friendship.Text); pkm.OT_Affection = Util.ToInt32(M_OT_Affection.Text); pkm.Fullness = (byte)Util.ToInt32(M_Fullness.Text); pkm.Enjoyment = (byte)Util.ToInt32(M_Enjoyment.Text); // Save Memories pkm.HT_Memory = WinFormsUtil.GetIndex(CB_CTMemory); pkm.HT_TextVar = CB_CTVar.Enabled ? WinFormsUtil.GetIndex(CB_CTVar) : 0; pkm.HT_Intensity = CB_CTFeel.Enabled ? CB_CTQual.SelectedIndex + 1 : 0; pkm.HT_Feeling = CB_CTFeel.Enabled ? CB_CTFeel.SelectedIndex : 0; pkm.OT_Memory = WinFormsUtil.GetIndex(CB_OTMemory); pkm.OT_TextVar = CB_OTVar.Enabled ? WinFormsUtil.GetIndex(CB_OTVar) : 0; pkm.OT_Intensity = CB_OTFeel.Enabled ? CB_OTQual.SelectedIndex + 1 : 0; pkm.OT_Feeling = CB_OTFeel.Enabled ? CB_OTFeel.SelectedIndex : 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 = WinFormsUtil.GetIndex(CB_Region); SAV.Country = WinFormsUtil.GetIndex(CB_Country); SAV.ConsoleRegion = 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 SAV.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; }
// View Updates private void B_Search_Click(object sender, EventArgs e) { // Populate Search Query Result IEnumerable <MysteryGift> res = RawDB; int format = MAXFORMAT + 1 - CB_Format.SelectedIndex; switch (CB_FormatComparator.SelectedIndex) { case 0: /* Do nothing */ break; case 1: res = res.Where(mg => mg.Format >= format); break; case 2: res = res.Where(mg => mg.Format == format); break; case 3: res = res.Where(mg => mg.Format <= format); break; } // Primary Searchables int species = WinFormsUtil.GetIndex(CB_Species); int item = WinFormsUtil.GetIndex(CB_HeldItem); if (species != -1) { res = res.Where(pk => pk.Species == species); } if (item != -1) { res = res.Where(pk => pk.HeldItem == item); } // Secondary Searchables int move1 = WinFormsUtil.GetIndex(CB_Move1); int move2 = WinFormsUtil.GetIndex(CB_Move2); int move3 = WinFormsUtil.GetIndex(CB_Move3); int move4 = WinFormsUtil.GetIndex(CB_Move4); if (move1 != -1) { res = res.Where(pk => pk.Moves.Contains(move1)); } if (move2 != -1) { res = res.Where(pk => pk.Moves.Contains(move2)); } if (move3 != -1) { res = res.Where(pk => pk.Moves.Contains(move3)); } if (move4 != -1) { res = res.Where(pk => pk.Moves.Contains(move4)); } if (CHK_Shiny.CheckState == CheckState.Checked) { res = res.Where(pk => pk.IsShiny); } if (CHK_Shiny.CheckState == CheckState.Unchecked) { res = res.Where(pk => !pk.IsShiny); } if (CHK_IsEgg.CheckState == CheckState.Checked) { res = res.Where(pk => pk.IsEgg); } if (CHK_IsEgg.CheckState == CheckState.Unchecked) { res = res.Where(pk => !pk.IsEgg); } slotSelected = -1; // reset the slot last viewed if (RTB_Instructions.Lines.Any(line => line.Length > 0)) { var raw = RTB_Instructions.Lines .Where(line => !string.IsNullOrWhiteSpace(line)) .Where(line => new[] { '!', '=' }.Contains(line[0])); var filters = (from line in raw let eval = line[0] == '=' let split = line.Substring(1).Split('=') where split.Length == 2 && !string.IsNullOrWhiteSpace(split[0]) select new BatchEditor.StringInstruction { PropertyName = split[0], PropertyValue = split[1], Evaluator = eval }).ToArray(); if (filters.Any(z => string.IsNullOrWhiteSpace(z.PropertyValue))) { WinFormsUtil.Error(MsgBEFilterEmpty); return; } res = res.Where(gift => // Compare across all filters { foreach (var cmd in filters) { if (!gift.GetType().HasPropertyAll(cmd.PropertyName)) { return(false); } try { if (gift.GetType().IsValueEqual(gift, cmd.PropertyName, cmd.PropertyValue) == cmd.Evaluator) { continue; } } catch { Debug.WriteLine($"Unable to compare {cmd.PropertyName} to {cmd.PropertyValue}."); } return(false); } return(true); }); } var results = res.ToArray(); if (results.Length == 0) { WinFormsUtil.Alert(MsgDBSearchNone); } SetResults(new List <MysteryGift>(results)); // updates Count Label as well. System.Media.SystemSounds.Asterisk.Play(); }
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); // 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); }
private void Save() { SAV.Game = (byte)(CB_Game.SelectedIndex + 30); 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.SubRegion = WinFormsUtil.GetIndex(CB_Region); SAV.Country = WinFormsUtil.GetIndex(CB_Country); SAV.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg); SAV.Language = WinFormsUtil.GetIndex(CB_Language); SAV.AlolaTime = (ulong)WinFormsUtil.GetIndex(CB_AlolaTime); SAV.OT = TB_OTName.Text; // Copy Position if (GB_Map.Enabled && MapUpdated) { SAV.M = (int)NUD_M.Value; SAV.X = (float)NUD_X.Value; SAV.Z = (float)NUD_Z.Value; SAV.Y = (float)NUD_Y.Value; SAV.R = (float)NUD_R.Value; } // 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; int seconds = (int)(CAL_AdventureStartDate.Value - new DateTime(2000, 1, 1)).TotalSeconds; seconds -= seconds % 86400; seconds += (int)(CAL_AdventureStartTime.Value - new DateTime(2000, 1, 1)).TotalSeconds; SAV.SecondsToStart = seconds; int fame = (int)(CAL_HoFDate.Value - new DateTime(2000, 1, 1)).TotalSeconds; fame -= fame % 86400; fame += (int)(CAL_HoFTime.Value - new DateTime(2000, 1, 1)).TotalSeconds; SAV.SecondsToFame = fame; if (SAV.LastSavedDate.HasValue) { SAV.LastSavedDate = new DateTime(CAL_LastSavedDate.Value.Year, CAL_LastSavedDate.Value.Month, CAL_LastSavedDate.Value.Day, CAL_LastSavedTime.Value.Hour, CAL_LastSavedTime.Value.Minute, 0); } SAV.BP = (uint)NUD_BP.Value; SAV.FestaCoins = (uint)NUD_FC.Value; // Poké Finder SAV.PokeFinderSnapCount = (uint)NUD_SnapCount.Value; SAV.PokeFinderThumbsTotalValue = (uint)NUD_ThumbsTotal.Value; SAV.PokeFinderThumbsHighValue = (uint)NUD_ThumbsRecord.Value; SAV.PokeFinderCameraVersion = (ushort)CB_CameraVersion.SelectedIndex; SAV.PokeFinderGyroFlag = CHK_Gyro.Checked; // Battle Tree SAV.SetTreeStreak((int)NUD_RCStreak0.Value, 0, super: false, max: false); SAV.SetTreeStreak((int)NUD_RCStreak1.Value, 1, super: false, max: false); SAV.SetTreeStreak((int)NUD_RCStreak2.Value, 2, super: false, max: false); SAV.SetTreeStreak((int)NUD_RMStreak0.Value, 0, super: false, max: true); SAV.SetTreeStreak((int)NUD_RMStreak1.Value, 1, super: false, max: true); SAV.SetTreeStreak((int)NUD_RMStreak2.Value, 2, super: false, max: true); SAV.SetTreeStreak((int)NUD_SCStreak0.Value, 0, super: true, max: false); SAV.SetTreeStreak((int)NUD_SCStreak1.Value, 1, super: true, max: false); SAV.SetTreeStreak((int)NUD_SCStreak2.Value, 2, super: true, max: false); SAV.SetTreeStreak((int)NUD_SMStreak0.Value, 0, super: true, max: true); SAV.SetTreeStreak((int)NUD_SMStreak1.Value, 1, super: true, max: true); SAV.SetTreeStreak((int)NUD_SMStreak2.Value, 2, super: true, max: true); // Skin changed && (gender matches || override) int gender = CB_Gender.SelectedIndex & 1; int skin = CB_SkinColor.SelectedIndex & 1; string gStr = CB_Gender.Items[gender].ToString(); string sStr = CB_Gender.Items[skin].ToString(); if (SAV.DressUpSkinColor != CB_SkinColor.SelectedIndex && (SAV.Gender == skin || DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, $"Gender-Skin mismatch:\nGender: {gStr}, Skin: {sStr}", "Save selected Skin Color?"))) { SAV.DressUpSkinColor = CB_SkinColor.SelectedIndex; } SAV.FestivalPlazaName = TB_PlazaName.Text; // Vivillon if (CB_Vivillon.SelectedIndex >= 0) { SAV.Vivillon = CB_Vivillon.SelectedIndex; } SAV.DaysFromRefreshed = (byte)NUD_DaysFromRefreshed.Value; SAV.BallThrowType = CB_BallThrowType.SelectedIndex; SAV.BallThrowTypeUnlocked = (byte)GetBits(LB_BallThrowTypeUnlocked); SAV.BallThrowTypeLearned = (byte)GetBits(LB_BallThrowTypeLearned); SAV.Stamps = GetBits(LB_Stamps); byte btsu = 0; if (CHK_UnlockSuperSingles.Checked) { btsu |= 1; } if (CHK_UnlockSuperDoubles.Checked) { btsu |= 1 << 1; } if (CHK_UnlockSuperMulti.Checked) { btsu |= 1 << 2; } SAV.BattleTreeSuperUnlocked = btsu; SAV.MegaUnlocked = CHK_UnlockMega.Checked; }
private void Write_Entry(object sender, EventArgs e) { if (!editing) { return; //Don't do writing until loaded } Validate_TextBoxes(); int index = LB_DataEntry.SelectedIndex; int partymember = Convert.ToInt32(NUP_PartyIndex.Value) - 1; int offset = (index * 0x1B4) + (partymember * 0x48); BitConverter.GetBytes(Convert.ToUInt16(CB_Species.SelectedValue)).CopyTo(data, offset + 0x00); BitConverter.GetBytes(Convert.ToUInt16(CB_HeldItem.SelectedValue)).CopyTo(data, offset + 0x02); BitConverter.GetBytes(Convert.ToUInt16(CB_Move1.SelectedValue)).CopyTo(data, offset + 0x04); BitConverter.GetBytes(Convert.ToUInt16(CB_Move2.SelectedValue)).CopyTo(data, offset + 0x06); BitConverter.GetBytes(Convert.ToUInt16(CB_Move3.SelectedValue)).CopyTo(data, offset + 0x08); BitConverter.GetBytes(Convert.ToUInt16(CB_Move4.SelectedValue)).CopyTo(data, offset + 0x0A); BitConverter.GetBytes(Util.GetHexValue(TB_EC.Text)).CopyTo(data, offset + 0x0C); BitConverter.GetBytes(Convert.ToUInt16(TB_TID.Text)).CopyTo(data, offset + 0x10); BitConverter.GetBytes(Convert.ToUInt16(TB_SID.Text)).CopyTo(data, offset + 0x12); uint rawslgf = BitConverter.ToUInt32(data, offset + 0x14); uint slgf = 0; slgf |= (uint)(CB_Form.SelectedIndex & 0x1F); slgf |= (uint)((PKX.GetGenderFromString(Label_Gender.Text) & 0x3) << 5); slgf |= (uint)((Convert.ToUInt16(TB_Level.Text) & 0x7F) << 7); if (CHK_Shiny.Checked) { slgf |= 1 << 14; } slgf |= rawslgf & 0x8000; Array.Copy(BitConverter.GetBytes(slgf), 0, data, offset + 0x14, 2); uint nick = 0; if (CHK_Nicknamed.Checked) { nick = 1; } Array.Copy(BitConverter.GetBytes(nick), 0, data, offset + 0x16, 2); //Mimic in-game behavior of not clearing strings. It's awful, but accuracy > good. string pk = TB_Nickname.Text; if (pk.Length != 12) { pk = pk.PadRight(pk.Length + 1, '\0'); } string ot = TB_OT.Text; if (ot.Length != 12) { ot = ot.PadRight(pk.Length + 1, '\0'); } Encoding.Unicode.GetBytes(pk).CopyTo(data, offset + 0x18); Encoding.Unicode.GetBytes(ot).CopyTo(data, offset + 0x30); offset = index * 0x1B4; uint vnd = 0; uint date = 0; vnd |= Convert.ToUInt32(TB_VN.Text) & 0xFF; date |= (uint)((CAL_MetDate.Value.Year - 2000) & 0xFF); date |= (uint)((CAL_MetDate.Value.Month & 0xF) << 8); date |= (uint)((CAL_MetDate.Value.Day & 0x1F) << 12); vnd |= (date & 0x1FFFF) << 14; //Fix for top bit uint rawvnd = BitConverter.ToUInt32(data, offset + 0x1B0); vnd |= rawvnd & 0x80000000; Array.Copy(BitConverter.GetBytes(vnd), 0, data, offset + 0x1B0, 4); var species = WinFormsUtil.GetIndex(CB_Species); var form = CB_Form.SelectedIndex & 0x1F; var gender = PKX.GetGenderFromString(Label_Gender.Text); var item = WinFormsUtil.GetIndex(CB_HeldItem); bpkx.Image = SpriteUtil.GetSprite(species, form, gender, 0, item, false, CHK_Shiny.Checked); DisplayEntry(this, EventArgs.Empty); // refresh text view }
private void ChangeMemory(object sender, EventArgs e) { ComboBox m = (ComboBox)sender; if (m == CB_CTMemory || m == CB_OTMemory) { int memory = WinFormsUtil.GetIndex(m); switch (memory) // Memory Case Switchtable { case 0: GetMemoryArguments("NONE", m); break; case 1: GetMemoryArguments("GENLOC", m); break; case 2: GetMemoryArguments("GENLOC", m); break; case 3: GetMemoryArguments("GENLOC", m); break; case 4: GetMemoryArguments("GENLOC", m); break; case 5: GetMemoryArguments("ITEM", m); break; case 6: GetMemoryArguments("LOCATION", m); break; case 7: GetMemoryArguments("PKM", m); break; case 8: GetMemoryArguments("NONE", m); break; case 9: GetMemoryArguments("PKM", m); break; case 10: GetMemoryArguments("NONE", m); break; case 11: GetMemoryArguments("NONE", m); break; case 12: GetMemoryArguments("MOVE", m); break; case 13: GetMemoryArguments("PKM", m); break; case 14: GetMemoryArguments("PKM", m); break; case 15: GetMemoryArguments("ITEM", m); break; case 16: GetMemoryArguments("MOVE", m); break; case 17: GetMemoryArguments("PKM", m); break; case 18: GetMemoryArguments("PKM", m); break; case 19: GetMemoryArguments("GENLOC", m); break; case 20: GetMemoryArguments("NONE", m); break; case 21: GetMemoryArguments("PKM", m); break; case 22: GetMemoryArguments("NONE", m); break; case 23: GetMemoryArguments("NONE", m); break; case 24: GetMemoryArguments("GENLOC", m); break; case 25: GetMemoryArguments("PKM", m); break; case 26: GetMemoryArguments("ITEM", m); break; case 27: GetMemoryArguments("NONE", m); break; case 28: GetMemoryArguments("NONE", m); break; case 29: GetMemoryArguments("PKM", m); break; case 30: GetMemoryArguments("NONE", m); break; case 31: GetMemoryArguments("GENLOC", m); break; case 32: GetMemoryArguments("GENLOC", m); break; case 33: GetMemoryArguments("GENLOC", m); break; case 34: GetMemoryArguments("ITEM", m); break; case 35: GetMemoryArguments("GENLOC", m); break; case 36: GetMemoryArguments("GENLOC", m); break; case 37: GetMemoryArguments("GENLOC", m); break; case 38: GetMemoryArguments("GENLOC", m); break; case 39: GetMemoryArguments("GENLOC", m); break; case 40: GetMemoryArguments("ITEM", m); break; case 41: GetMemoryArguments("NONE", m); break; case 42: GetMemoryArguments("GENLOC", m); break; case 43: GetMemoryArguments("NONE", m); break; case 44: GetMemoryArguments("PKM", m); break; case 45: GetMemoryArguments("PKM", m); break; case 46: GetMemoryArguments("NONE", m); break; case 47: GetMemoryArguments("NONE", m); break; case 48: GetMemoryArguments("MOVE", m); break; case 49: GetMemoryArguments("MOVE", m); break; case 50: GetMemoryArguments("PKM", m); break; case 51: GetMemoryArguments("ITEM", m); break; case 52: GetMemoryArguments("GENLOC", m); break; case 53: GetMemoryArguments("NONE", m); break; case 54: GetMemoryArguments("NONE", m); break; case 55: GetMemoryArguments("NONE", m); break; case 56: GetMemoryArguments("NONE", m); break; case 57: GetMemoryArguments("NONE", m); break; case 58: GetMemoryArguments("NONE", m); break; case 59: GetMemoryArguments("GENLOC", m); break; case 60: GetMemoryArguments("PKM", m); break; case 61: GetMemoryArguments("NONE", m); break; case 62: GetMemoryArguments("NONE", m); break; case 63: GetMemoryArguments("NONE", m); break; case 64: GetMemoryArguments("NONE", m); break; default: GetMemoryArguments("NONE", m); break; } } if (!init) { return; } RTB_OT.Text = GetMemoryString(CB_OTMemory, CB_OTVar, CB_OTQual, CB_OTFeel, pkm.OT_Name); RTB_CT.Text = GetMemoryString(CB_CTMemory, CB_CTVar, CB_CTQual, CB_CTFeel, pkm.HT_Name); }
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.SubRegion = WinFormsUtil.GetIndex(CB_Region); SAV.Country = WinFormsUtil.GetIndex(CB_Country); SAV.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg); SAV.Language = WinFormsUtil.GetIndex(CB_Language); SAV.OT = TB_OTName.Text; SAV.Saying1 = TB_Saying1.Text; SAV.Saying2 = TB_Saying2.Text; SAV.Saying3 = TB_Saying3.Text; SAV.Saying4 = TB_Saying4.Text; SAV.Saying5 = TB_Saying5.Text; // Copy Maison Data in if (SAV.MaisonStats > -1) { for (int i = 0; i < MaisonRecords.Length; i++) { SAV.SetMaisonStat(i, ushort.Parse(MaisonRecords[i].Text)); } } // Copy Position if (GB_Map.Enabled && MapUpdated) { SAV.M = (int)NUD_M.Value; SAV.X = (float)NUD_X.Value; SAV.Z = (float)NUD_Z.Value; SAV.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)); SAV.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 SAV.MultiplayerSpriteID = Convert.ToByte(CB_MultiplayerSprite.SelectedValue); // Appearance if (SAV.XY) { // Save Clothing Data var obj = (TrainerFashion6)propertyGrid1.SelectedObject; obj.Write(SAV.Data, SAV.TrainerCard + 0x30); SAV.OT_Nick = TB_TRNick.Text; } // Vivillon SAV.Vivillon = CB_Vivillon.SelectedIndex; uint seconds = (uint)(CAL_AdventureStartDate.Value - new DateTime(2000, 1, 1)).TotalSeconds; seconds -= seconds % 86400; seconds += (uint)(CAL_AdventureStartTime.Value - new DateTime(2000, 1, 1)).TotalSeconds; SAV.SecondsToStart = seconds; uint fame = (uint)(CAL_HoFDate.Value - new DateTime(2000, 1, 1)).TotalSeconds; fame -= fame % 86400; fame += (uint)(CAL_HoFTime.Value - new DateTime(2000, 1, 1)).TotalSeconds; SAV.SecondsToFame = fame; if (SAV.LastSavedDate.HasValue) { SAV.LastSavedDate = new DateTime(CAL_LastSavedDate.Value.Year, CAL_LastSavedDate.Value.Month, CAL_LastSavedDate.Value.Day, CAL_LastSavedTime.Value.Hour, CAL_LastSavedTime.Value.Minute, 0); } SAV.IsMegaEvolutionUnlocked = CHK_MegaUnlocked.Checked; SAV.IsMegaRayquazaUnlocked = CHK_MegaRayquazaUnlocked.Checked; }
public void Form1_Load(object sender, EventArgs e) { string pokegenfolder = "Gen Files\\"; PictureBox[] pba = { C_SAV.Box.bpkx1, C_SAV.Box.bpkx2, C_SAV.Box.bpkx3, C_SAV.Box.bpkx4, C_SAV.Box.bpkx5, C_SAV.Box.bpkx6, C_SAV.Box.bpkx7, C_SAV.Box.bpkx8, C_SAV.Box.bpkx9, C_SAV.Box.bpkx10, C_SAV.Box.bpkx11, C_SAV.Box.bpkx12, C_SAV.Box.bpkx13, C_SAV.Box.bpkx14, C_SAV.Box.bpkx15, C_SAV.Box.bpkx16, C_SAV.Box.bpkx17, C_SAV.Box.bpkx18, C_SAV.Box.bpkx19, C_SAV.Box.bpkx20, C_SAV.Box.bpkx21, C_SAV.Box.bpkx22, C_SAV.Box.bpkx23, C_SAV.Box.bpkx24, C_SAV.Box.bpkx25, C_SAV.Box.bpkx26, C_SAV.Box.bpkx27, C_SAV.Box.bpkx28, C_SAV.Box.bpkx29, C_SAV.Box.bpkx30 }; Image standardImage = pba[0].Image; int minB = 1; int maxB = 31; if (!singleFiles) { } if (savExtraction) { openQuick(cyberSavPath); minB = int.Parse(minBox); maxB = int.Parse(maxBox); C_SAV.Box.CB_BoxSelect.SelectedIndex = minB - 1; } Dictionary <string, string> metDict = new Dictionary <string, string>(); DirectoryInfo d = new DirectoryInfo(pokegenfolder + "gold"); foreach (FileInfo f in d.GetFiles()) { if (f.Name.Contains("Ho-Oh")) { if (!metDict.ContainsKey("ho-oh")) { metDict.Add("ho-oh", f.FullName); } } else { string filename = f.Name.Substring(f.Name.IndexOf("-") + 1); filename = filename.Substring(0, filename.IndexOf("-")).Trim(); if (!metDict.ContainsKey(filename.ToLower())) { metDict.Add(filename.ToLower(), f.FullName); } } } int count = 0; foreach (Pokemon p in pkms) { ComboItem i = new ComboItem(); i.Text = null; string poke = p.name; poke = poke.Replace("'", "’"); poke = poke.Replace("-Mega", ""); if (savExtraction) { if (count == 30) { if (C_SAV.Box.CB_BoxSelect.SelectedIndex == maxB - 1) { MessageBox.Show("Stopped at " + poke + ", since the boxes are fully stretched!"); break; } count = 0; C_SAV.Box.CB_BoxSelect.SelectedIndex++; } if (!ContextMenuSAV.ClickViewChange(pba[count], null)) { } else { bool stop = false; while (ContextMenuSAV.ClickViewChange(pba[count], null)) { count++; if (count == 30) { if (C_SAV.Box.CB_BoxSelect.SelectedIndex == maxB - 1) { MessageBox.Show("Stopped at " + poke + ", since the boxes are fully stretched!"); stop = true; break; } count = 0; C_SAV.Box.CB_BoxSelect.SelectedIndex++; } } if (stop) { break; } } } string item = p.item; if (item.Equals("BlackGlasses")) { item = "Black Glasses"; } if (item.Equals("NeverMeltIce")) { item = "Never-Melt Ice"; } if (item.Equals("BrightPowder")) { item = "Bright Powder"; } item = item.Replace("'", "’"); string ability = p.ability; if (ability.Equals("Lightningrod")) { ability = "Lightning Rod"; } string nature = p.nature; string hptype = null; string move1 = (p.moves.Count > 0) ? p.moves[0] : "(None)"; if (move1.Contains("Hidden Power")) { hptype = move1.Substring(13); move1 = "Hidden Power"; } string move2 = (p.moves.Count > 1) ? p.moves[1] : "(None)"; if (move2.Contains("Hidden Power")) { hptype = move2.Substring(13); move2 = "Hidden Power"; } string move3 = (p.moves.Count > 2) ? p.moves[2] : "(None)"; if (move3.Contains("Hidden Power")) { hptype = move3.Substring(13); move3 = "Hidden Power"; } string move4 = (p.moves.Count > 3) ? p.moves[3] : "(None)"; if (move4.Contains("Hidden Power")) { hptype = move4.Substring(13); move4 = "Hidden Power"; } //fixing double moves if ((move1 != "(None)" && (move1.Equals(move2) || move1.Equals(move3) || move1.Equals(move4))) || (move2 != "(None)" && (move2.Equals(move3) || move2.Equals(move4))) || (move3 != "(None)" && move3.Equals(move4))) { continue; } //fixing King's Shield (King’s Shield) move1 = move1.Replace("'", "’"); move2 = move2.Replace("'", "’"); move3 = move3.Replace("'", "’"); move4 = move4.Replace("'", "’"); string pokemonlower = poke.ToLower(); bool special = false; //fixing Mewtwo + Unnerve and all other Event Mons if (poke.Equals("Mewtwo") && ability.Equals("Unnerve")) { special = true; mainMenuOpen(metDict["mewtwo (unnerve)"]); } else if (poke.Equals("Jirachi") && (move1.Contains("Heart Stamp") || move2.Contains("Heart Stamp") || move3.Contains("Heart Stamp") || move4.Contains("Heart Stamp"))) { special = true; mainMenuOpen(metDict["jirachi (heart stamp)"]); } else if (poke.Equals("Jirachi") && (move1.Contains("Play Rough") || move2.Contains("Play Rough") || move3.Contains("Play Rough") || move4.Contains("Play Rough"))) { special = true; mainMenuOpen(metDict["jirachi (heart stamp)"]); } else if (poke.Equals("Zapdos") && ability.Equals("Static")) { special = true; mainMenuOpen(metDict["zapdos (static)"]); } else if (poke.Equals("Thundurus") && ability.Equals("Defiant")) { special = true; mainMenuOpen(metDict["thundurus (defiant)"]); } else if (poke.Equals("Entei") && (move1.Contains("Extreme Speed") || move2.Contains("Extreme Speed") || move3.Contains("Extreme Speed") || move4.Contains("Extreme Speed"))) { special = true; mainMenuOpen(metDict["entei (espeed)"]); } else if (poke.Equals("Tauros") && (move1.Contains("Rock Climb") || move2.Contains("Rock Climb") || move3.Contains("Rock Climb") || move4.Contains("Rock Climb"))) { special = true; mainMenuOpen(metDict["tauros (rock climb)"]); } else if (poke.Equals("Tauros") && (move1.Contains("Body Slam") || move2.Contains("Body Slam") || move3.Contains("Body Slam") || move4.Contains("Body Slam"))) { special = true; mainMenuOpen(metDict["tauros (body slam)"]); } else if (poke.Equals("Celebi") && (move1.Contains("Nasty Plot") || move2.Contains("Nasty Plot") || move3.Contains("Nasty Plot") || move4.Contains("Nasty Plot"))) { special = true; mainMenuOpen(metDict["celebi (nasty plot)"]); } else if (poke.Equals("Heatran") && (move1.Contains("Eruption") || move2.Contains("Eruption") || move3.Contains("Eruption") || move4.Contains("Eruption"))) { special = true; mainMenuOpen(metDict["heatran (eruption)"]); } else if (poke.Equals("Jirachi") && (move1.Contains("Follow Me") || move2.Contains("Follow Me") || move3.Contains("Follow Me") || move4.Contains("Follow Me"))) { special = true; mainMenuOpen(metDict["jirachi (follow me)"]); } else if (poke.Equals("Raikou") && (move1.Contains("Aura Sphere") || move2.Contains("Aura Sphere") || move3.Contains("Aura Sphere") || move4.Contains("Aura Sphere"))) { special = true; mainMenuOpen(metDict["raikou (aura sphere)"]); } else if (poke.Contains("Dusk") && (move1.Contains("Helping Hand") || move2.Contains("Helping Hand") || move3.Contains("Helping Hand") || move4.Contains("Helping Hand"))) { special = true; mainMenuOpen(metDict["duskull (helping hand)"]); } else if (poke.Equals("Lunatone") && (move1.Contains("Baton Pass") || move2.Contains("Baton Pass") || move3.Contains("Baton Pass") || move4.Contains("Baton Pass"))) { special = true; mainMenuOpen(metDict["lunatone (baton pass)"]); } else if (poke.Contains("Toge") && (move1.Contains("Helping Hand") || move2.Contains("Helping Hand") || move3.Contains("Helping Hand") || move4.Contains("Helping Hand"))) { special = true; mainMenuOpen(metDict["togepi (helping hand)"]); } else if (poke.Equals("Rapidash") && (move1.Contains("Baton Pass") || move2.Contains("Baton Pass") || move3.Contains("Baton Pass") || move4.Contains("Baton Pass"))) { special = true; mainMenuOpen(metDict["rapidash (baton pass)"]); } else if (poke.Equals("Salamence") && (move1.Contains("Refresh") || move2.Contains("Refresh") || move3.Contains("Refresh") || move4.Contains("Refresh"))) { special = true; mainMenuOpen(metDict["salamence (refresh)"]); } else if (poke.Equals("Moltres") && (move1.Contains("Morning Sun") || move2.Contains("Morning Sun") || move3.Contains("Morning Sun") || move4.Contains("Morning Sun"))) { special = true; mainMenuOpen(metDict["moltres (morning sun)"]); } else if (poke.Equals("Moltres") && ability.Contains("Flame Body")) { special = true; mainMenuOpen(metDict["moltres (flame body)"]); } else if (poke.Equals("Blastoise") && (move1.Contains("Celebate") || move2.Contains("Celebate") || move3.Contains("Celebate") || move4.Contains("Celebate"))) { special = true; mainMenuOpen(metDict["blastoise (celebrate)"]); } else if (poke.Equals("Gengar") && (move1.Contains("Sludge Wave") || move2.Contains("Sludge Wave") || move3.Contains("Sludge Wave") || move4.Contains("Sludge Wave"))) { special = true; mainMenuOpen(metDict["gengar"]); } else if (poke.Equals("Lycanroc") && ability.Contains("Tough Claws")) { special = true; mainMenuOpen(metDict["lycanroc (dusk)"]); } else if (poke.Equals("Rockruff") && ability.Contains("Own Tempo")) { special = true; mainMenuOpen(metDict["rockruff (dusk)"]); } else if (poke.Equals("Zygarde-10%")) { special = true; mainMenuOpen(metDict["zygarde (10%)"]); } else if (poke.Equals("Type: Null")) { special = true; mainMenuOpen(metDict["type null"]); } else if (poke.Equals("Gengar")) { } else if (poke.Contains("Totem")) { special = true; mainMenuOpen(pokegenfolder + "totem.pk7"); } else { foreach (KeyValuePair <string, string> met in metDict) { if (pokemonlower.Contains(met.Key)) { special = true; mainMenuOpen(met.Value); break; } } } if (!special) { if (move1.Equals("Soft-Boiled") || move2.Equals("Soft-Boiled") || move3.Equals("Soft-Boiled") || move4.Equals("Soft-Boiled")) { mainMenuOpen(pokegenfolder + "softboiled.ek6"); } else if (((move1.Equals("Wish") || move2.Equals("Wish") || move3.Equals("Wish") || move4.Equals("Wish"))) && (poke.Contains("Chansey") || poke.Contains("Blissey") || poke.Contains("Hypno") || poke.Contains("Lickilicky"))) { mainMenuOpen(pokegenfolder + "softboiled.ek6"); } else if ((move1.Equals("Double-Edge") || move2.Equals("Double-Edge") || move3.Equals("Double-Edge") || move4.Equals("Double-Edge")) && (poke.Contains("Doduo") || poke.Contains("Dodrio") || poke.Contains("Glalie") || poke.Contains("Tauros"))) { mainMenuOpen(pokegenfolder + "softboiled.ek6"); } else if ((move1.Equals("Counter") || move2.Equals("Counter") || move3.Equals("Counter") || move4.Equals("Counter")) && (poke.Contains("Geodude") || poke.Contains("Golem"))) { mainMenuOpen(pokegenfolder + "softboiled.ek6"); } else if ((move1.Equals("Body Slam") || move2.Equals("Body Slam") || move3.Equals("Body Slam") || move4.Equals("Body Slam")) && (poke.Contains("Dunsparce"))) { mainMenuOpen(pokegenfolder + "softboiled.ek6"); } else if (!gen7 && (move1.Equals("Defog") || move2.Equals("Defog") || move3.Equals("Defog") || move4.Equals("Defog")) && !poke.Contains("Mandibuzz") && !poke.Contains("Vullaby") && !poke.Contains("Braviary") && !poke.Contains("Golbat") && !poke.Contains("Crobat") && !poke.Contains("Archeops") && !poke.Contains("Archen") && !poke.Contains("Swanna") && !poke.Contains("Ducklett") && !poke.Contains("Zubat") && !poke.Contains("Pidgey") && !poke.Contains("Scizor") && !poke.Contains("Dartrix") && !poke.Contains("Decidueye") && !poke.Contains("Fomantis") && !poke.Contains("Lurantis") && !poke.Contains("Rowlet")) { mainMenuOpen(pokegenfolder + "defog.ek6"); } else if ((move1.Equals("Tailwind") || move2.Equals("Tailwind") || move3.Equals("Tailwind") || move4.Equals("Tailwind")) && poke.Contains("Lumineon")) { mainMenuOpen(pokegenfolder + "defog.ek6"); } else if ((move1.Equals("Bullet Seed") || move2.Equals("Bullet Seed") || move3.Equals("Bullet Seed") || move4.Equals("Bullet Seed")) && (poke.Contains("Cacturne") || poke.Contains("Ludicolo") || poke.Contains("Torterra"))) { mainMenuOpen(pokegenfolder + "defog.ek6"); } else if ((move1.Equals("Sucker Punch") || move2.Equals("Sucker Punch") || move3.Equals("Sucker Punch") || move4.Equals("Sucker Punch")) && (poke.Contains("Geodude") || poke.Contains("Golem") || poke.Contains("Hitmonlee") || poke.Contains("Hitmontop") || poke.Contains("Shiftry") || poke.Contains("Victreebel"))) { mainMenuOpen(pokegenfolder + "defog.ek6"); } else if ((move1.Equals("Vacuum Wave") || move2.Equals("Vacuum Wave") || move3.Equals("Vacuum Wave") || move4.Equals("Vacuum Wave")) && (poke.Contains("Infernape") || poke.Contains("Poliwrath"))) { mainMenuOpen(pokegenfolder + "defog.ek6"); } else if ((move1.Equals("Whirlpool") || move2.Equals("Whirlpool") || move3.Equals("Whirlpool") || move4.Equals("Whirlpool")) && (poke.Contains("Seel"))) { mainMenuOpen(pokegenfolder + "defog.ek6"); } else if ((move1.Equals("Sucker Punch") || move2.Equals("Sucker Punch") || move3.Equals("Sucker Punch") || move4.Equals("Sucker Punch")) && (poke.Contains("Lanturn"))) { mainMenuOpen(pokegenfolder + "defog.ek6"); } else if ((move1.Equals("Work Up") || move2.Equals("Work Up") || move3.Equals("Work Up") || move4.Equals("Work Up")) && (poke.Contains("Togepi") || poke.Contains("Exploud"))) { mainMenuOpen(pokegenfolder + "workup.ek6"); } else if ((move1.Equals("Refresh") || move2.Equals("Refresh") || move3.Equals("Refresh") || move4.Equals("Refresh")) && (poke.Contains("Pidgeot") || poke.Contains("Salamence"))) { mainMenuOpen(pokegenfolder + "refresh.ek6"); } else { if (gen7) { // Gen 7 mainMenuOpen(pokegenfolder + "sunmoon.pk7"); } else { // Gen 6 mainMenuOpen(pokegenfolder + "oras.ekx.ek6"); } } } if (p.level != null && int.Parse(PKME_Tabs.TB_MetLevel.Text) > int.Parse(p.level)) { PKME_Tabs.TB_MetLevel.Text = p.level; } if (PKME_Tabs.CB_Form.Items.Count != 0) { PKME_Tabs.CB_Form.SelectedIndex = 0; } string[] evs = p.evs.Split('/'); foreach (ComboItem items in PKME_Tabs.CB_Species.Items) { if (poke.Contains(items.Text)) { if (i.Text != null) { if (i.Text.Length < items.Text.Length) { i = items; } } else { i = items; } } } PKME_Tabs.CB_Species.SelectedItem = i; PKME_Tabs.TB_Nickname.Text = i.Text; if (p.level != null) { PKME_Tabs.TB_Level.Text = p.level; } else { PKME_Tabs.TB_Level.Text = "100"; } if (poke.Contains("-")) { string extension = ((poke.Split('-'))[1]).Trim(); if (poke.Contains("-Totem")) { extension = "Large"; } bool b = false; while (PKME_Tabs.CB_Form.SelectedIndex < PKME_Tabs.CB_Form.Items.Count - 1) { PKME_Tabs.CB_Form.SelectedIndex++; string text = PKME_Tabs.CB_Form.SelectedItem.ToString().Substring(PKME_Tabs.CB_Form.SelectedItem.ToString().IndexOf("=") + 1); if (text.Contains(",")) { text = text.Substring(0, text.IndexOf(",")); } text = text.Trim(); if (text.Contains(extension)) { b = true; break; } } if (!b) { PKME_Tabs.CB_Form.SelectedIndex = 0; } } i.Text = null; foreach (ComboItem items in PKME_Tabs.CB_HeldItem.Items) { if (item.Contains(items.Text)) { if (i.Text != null) { if (i.Text.Length < items.Text.Length) { i = items; } } else { i = items; } } } PKME_Tabs.CB_HeldItem.SelectedItem = i; i.Text = null; foreach (ComboItem items in PKME_Tabs.CB_Ability.Items) { if (items.Text.Contains(ability)) { if (i.Text != null) { if (i.Text.Length < items.Text.Length) { i = items; } } else { i = items; } } } if (i.Text == null) { if (!ability.Equals("")) { while (true) { bool b = false; foreach (ComboItem items in PKME_Tabs.CB_Ability.Items) { if (items.Text.Contains(ability)) { PKME_Tabs.CB_Ability.SelectedItem = items; b = true; break; } } if (b) { break; } else { int species = WinFormsUtil.GetIndex(PKME_Tabs.CB_Species); int[] mspec = // XY { 003, 009, 065, 094, 115, 127, 130, 142, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359, 380, 381, 445, 448, 460, // ORAS 015, 018, 080, 208, 254, 260, 302, 319, 323, 334, 362, 373, 376, 384, 428, 475, 531, 719, }; if (Array.IndexOf(mspec, species) > -1 || ((species == 6) || (species == 150))) { break; } PKME_Tabs.CB_Form.SelectedIndex++; } } } } else { if (poke.Equals("Registeel")) { PKME_Tabs.CB_Ability.SelectedIndex = 0; } else if (poke.Contains("Kyurem")) { PKME_Tabs.CB_Ability.SelectedIndex = 1; } else { PKME_Tabs.CB_Ability.SelectedItem = i; } } if (nature != null) { i.Text = null; foreach (ComboItem items in PKME_Tabs.CB_Nature.Items) { if (items.Text.Contains(nature)) { if (i.Text != null) { if (i.Text.Length < items.Text.Length) { i = items; } } else { i = items; } } } PKME_Tabs.CB_Nature.SelectedItem = i; } i.Text = null; foreach (ComboItem items in PKME_Tabs.CB_Move1.Items) { if (items.Text.Equals(move1)) { if (i.Text != null) { if (i.Text.Length < items.Text.Length) { i = items; } } else { i = items; } } } PKME_Tabs.CB_Move1.SelectedItem = i; i.Text = null; foreach (ComboItem items in PKME_Tabs.CB_Move2.Items) { if (items.Text.Equals(move2)) { if (i.Text != null) { if (i.Text.Length < items.Text.Length) { i = items; } } else { i = items; } } } PKME_Tabs.CB_Move2.SelectedItem = i; i.Text = null; foreach (ComboItem items in PKME_Tabs.CB_Move3.Items) { if (items.Text.Equals(move3)) { if (i.Text != null) { if (i.Text.Length < items.Text.Length) { i = items; } } else { i = items; } } } PKME_Tabs.CB_Move3.SelectedItem = i; i.Text = null; foreach (ComboItem items in PKME_Tabs.CB_Move4.Items) { if (items.Text.Equals(move4)) { if (i.Text != null) { if (i.Text.Length < items.Text.Length) { i = items; } } else { i = items; } } } PKME_Tabs.CB_Move4.SelectedItem = i; // Make PP Max PKME_Tabs.CB_PPu1.SelectedIndex = 3; PKME_Tabs.CB_PPu2.SelectedIndex = 3; PKME_Tabs.CB_PPu3.SelectedIndex = 3; PKME_Tabs.CB_PPu4.SelectedIndex = 3; // IVs PKME_Tabs.TB_HPIV.Text = "31"; PKME_Tabs.TB_ATKIV.Text = "31"; PKME_Tabs.TB_DEFIV.Text = "31"; PKME_Tabs.TB_SPAIV.Text = "31"; PKME_Tabs.TB_SPDIV.Text = "31"; PKME_Tabs.TB_SPEIV.Text = "31"; if (hptype != null) { if (hptype.Contains("Fighting")) { PKME_Tabs.TB_DEFIV.Text = "30"; PKME_Tabs.TB_SPAIV.Text = "30"; PKME_Tabs.TB_SPDIV.Text = "30"; PKME_Tabs.TB_SPEIV.Text = "30"; } else if (hptype.Contains("Flying")) { PKME_Tabs.TB_SPAIV.Text = "30"; PKME_Tabs.TB_SPDIV.Text = "30"; PKME_Tabs.TB_HPIV.Text = "30"; PKME_Tabs.TB_ATKIV.Text = "30"; PKME_Tabs.TB_DEFIV.Text = "30"; } else if (hptype.Contains("Poison")) { PKME_Tabs.TB_DEFIV.Text = "30"; PKME_Tabs.TB_SPDIV.Text = "30"; PKME_Tabs.TB_SPAIV.Text = "30"; } else if (hptype.Contains("Ground")) { PKME_Tabs.TB_SPDIV.Text = "30"; PKME_Tabs.TB_SPAIV.Text = "30"; } else if (hptype.Contains("Rock")) { PKME_Tabs.TB_SPDIV.Text = "30"; PKME_Tabs.TB_SPEIV.Text = "30"; PKME_Tabs.TB_DEFIV.Text = "30"; } else if (hptype.Contains("Bug")) { PKME_Tabs.TB_SPDIV.Text = "30"; PKME_Tabs.TB_ATKIV.Text = "30"; PKME_Tabs.TB_DEFIV.Text = "30"; } else if (hptype.Contains("Ghost")) { PKME_Tabs.TB_DEFIV.Text = "30"; PKME_Tabs.TB_SPDIV.Text = "30"; } else if (hptype.Contains("Steel")) { PKME_Tabs.TB_SPDIV.Text = "30"; } else if (hptype.Contains("Fire")) { PKME_Tabs.TB_SPAIV.Text = "30"; PKME_Tabs.TB_SPEIV.Text = "30"; PKME_Tabs.TB_ATKIV.Text = "30"; } else if (hptype.Contains("Water")) { PKME_Tabs.TB_SPAIV.Text = "30"; PKME_Tabs.TB_ATKIV.Text = "30"; PKME_Tabs.TB_DEFIV.Text = "30"; } else if (hptype.Contains("Grass")) { PKME_Tabs.TB_SPAIV.Text = "30"; PKME_Tabs.TB_HPIV.Text = "30"; } else if (hptype.Contains("Electric")) { PKME_Tabs.TB_SPAIV.Text = "30"; } else if (hptype.Contains("Psychic")) { PKME_Tabs.TB_SPEIV.Text = "30"; PKME_Tabs.TB_ATKIV.Text = "30"; } else if (hptype.Contains("Ice")) { PKME_Tabs.TB_DEFIV.Text = "30"; PKME_Tabs.TB_ATKIV.Text = "30"; } else if (hptype.Contains("Dragon")) { PKME_Tabs.TB_DEFIV.Text = "30"; } } if (int.Parse(PKME_Tabs.TB_Level.Text) == 100) { PKME_Tabs.pkm.HT_HP = (PKME_Tabs.TB_HPIV.Text != "31"); PKME_Tabs.UpdateIVs(PKME_Tabs.TB_HPIV, e); PKME_Tabs.pkm.HT_ATK = (PKME_Tabs.TB_ATKIV.Text != "31"); PKME_Tabs.UpdateIVs(PKME_Tabs.TB_ATKIV, e); PKME_Tabs.pkm.HT_DEF = (PKME_Tabs.TB_DEFIV.Text != "31"); PKME_Tabs.UpdateIVs(PKME_Tabs.TB_DEFIV, e); PKME_Tabs.pkm.HT_SPA = (PKME_Tabs.TB_SPAIV.Text != "31"); PKME_Tabs.UpdateIVs(PKME_Tabs.TB_SPAIV, e); PKME_Tabs.pkm.HT_SPD = (PKME_Tabs.TB_SPDIV.Text != "31"); PKME_Tabs.UpdateIVs(PKME_Tabs.TB_SPDIV, e); PKME_Tabs.pkm.HT_SPE = (PKME_Tabs.TB_SPEIV.Text != "31"); PKME_Tabs.UpdateIVs(PKME_Tabs.TB_SPEIV, e); if (p.ivs != null) { string[] ivs = p.ivs.Split('/'); foreach (string iv in ivs) { if (iv.Contains("HP")) { PKME_Tabs.pkm.HT_HP = false; PKME_Tabs.UpdateIVs(PKME_Tabs.TB_HPIV, e); PKME_Tabs.TB_HPIV.Text = iv.Substring(0, iv.IndexOf("HP")).Trim(); } else if (iv.Contains("Atk")) { PKME_Tabs.pkm.HT_ATK = false; PKME_Tabs.UpdateIVs(PKME_Tabs.TB_ATKIV, e); PKME_Tabs.TB_ATKIV.Text = iv.Substring(0, iv.IndexOf("Atk")).Trim(); } else if (iv.Contains("Def")) { PKME_Tabs.pkm.HT_DEF = false; PKME_Tabs.UpdateIVs(PKME_Tabs.TB_DEFIV, e); PKME_Tabs.TB_DEFIV.Text = iv.Substring(0, iv.IndexOf("Def")).Trim(); } else if (iv.Contains("SpA")) { PKME_Tabs.pkm.HT_SPA = false; PKME_Tabs.UpdateIVs(PKME_Tabs.TB_SPAIV, e); PKME_Tabs.TB_SPAIV.Text = iv.Substring(0, iv.IndexOf("SpA")).Trim(); } else if (iv.Contains("SpD")) { PKME_Tabs.pkm.HT_SPD = false; PKME_Tabs.UpdateIVs(PKME_Tabs.TB_SPDIV, e); PKME_Tabs.TB_SPDIV.Text = iv.Substring(0, iv.IndexOf("SpD")).Trim(); } else if (iv.Contains("Spe")) { PKME_Tabs.pkm.HT_SPE = false; PKME_Tabs.UpdateIVs(PKME_Tabs.TB_SPEIV, e); PKME_Tabs.TB_SPEIV.Text = iv.Substring(0, iv.IndexOf("Spe")).Trim(); } } } } else { if (p.ivs != null) { string[] ivs = p.ivs.Split('/'); foreach (string iv in ivs) { if (iv.Contains("HP")) { PKME_Tabs.TB_HPIV.Text = iv.Substring(0, iv.IndexOf("HP")).Trim(); } else if (iv.Contains("Atk")) { PKME_Tabs.TB_ATKIV.Text = iv.Substring(0, iv.IndexOf("Atk")).Trim(); } else if (iv.Contains("Def")) { PKME_Tabs.TB_DEFIV.Text = iv.Substring(0, iv.IndexOf("Def")).Trim(); } else if (iv.Contains("SpA")) { PKME_Tabs.TB_SPAIV.Text = iv.Substring(0, iv.IndexOf("SpA")).Trim(); } else if (iv.Contains("SpD")) { PKME_Tabs.TB_SPDIV.Text = iv.Substring(0, iv.IndexOf("SpD")).Trim(); } else if (iv.Contains("Spe")) { PKME_Tabs.TB_SPEIV.Text = iv.Substring(0, iv.IndexOf("Spe")).Trim(); } } } } // EVs PKME_Tabs.TB_HPEV.Text = "0"; PKME_Tabs.TB_ATKEV.Text = "0"; PKME_Tabs.TB_DEFEV.Text = "0"; PKME_Tabs.TB_SPAEV.Text = "0"; PKME_Tabs.TB_SPDEV.Text = "0"; PKME_Tabs.TB_SPEEV.Text = "0"; foreach (string ev in evs) { if (ev.Contains("HP")) { PKME_Tabs.TB_HPEV.Text = ev.Substring(0, ev.IndexOf("HP")).Trim(); } else if (ev.Contains("Atk")) { PKME_Tabs.TB_ATKEV.Text = ev.Substring(0, ev.IndexOf("Atk")).Trim(); } else if (ev.Contains("Def")) { PKME_Tabs.TB_DEFEV.Text = ev.Substring(0, ev.IndexOf("Def")).Trim(); } else if (ev.Contains("SpA")) { PKME_Tabs.TB_SPAEV.Text = ev.Substring(0, ev.IndexOf("SpA")).Trim(); } else if (ev.Contains("SpD")) { PKME_Tabs.TB_SPDEV.Text = ev.Substring(0, ev.IndexOf("SpD")).Trim(); } else if (ev.Contains("Spe")) { PKME_Tabs.TB_SPEEV.Text = ev.Substring(0, ev.IndexOf("Spe")).Trim(); } } if (p.gender != null) { if (p.gender == "m") { PKME_Tabs.Label_Gender.Text = PKME_Tabs.gendersymbols[0]; } else { PKME_Tabs.Label_Gender.Text = PKME_Tabs.gendersymbols[1]; } } if (p.happiness != null) { PKME_Tabs.TB_Friendship.Text = p.happiness; } else { PKME_Tabs.TB_Friendship.Text = "255"; } if (p.nickname != null) { PKME_Tabs.CHK_Nicknamed.Checked = true; PKME_Tabs.TB_Nickname.Text = p.nickname; } PKME_Tabs.ClickMoves(PKME_Tabs.GB_RelearnMoves, null); if ((!poke.Contains("Genesect") && !(move1.Contains("Extreme Speed") || move2.Contains("Extreme Speed") || move3.Contains("Extreme Speed") || move4.Contains("Extreme Speed"))) && (!poke.Contains("Entei") && !(move1.Contains("Extreme Speed") || move2.Contains("Extreme Speed") || move3.Contains("Extreme Speed") || move4.Contains("Extreme Speed"))) && (!poke.Contains("Raikou") && !(move1.Contains("Aura Sphere") || move2.Contains("Aura Sphere") || move3.Contains("Aura Sphere") || move4.Contains("Aura Sphere")))) { PKME_Tabs.UpdateRandomPID(PKME_Tabs.BTN_RerollPID, null); } if (p.shiny) { PKME_Tabs.UpdateShinyPID(null, null); } if (singleFiles) { mainMenuSave(p); } else if ((!singleFiles && !savExtraction) || savExtraction) { ContextMenuSAV.ClickSet(pba[count], null); ContextMenuSAV.ClickView(pba[count], null); ContextMenuSAV.ClickSet(pba[count], null); } count++; } if (!singleFiles && !savExtraction) { if (!extractPath.Trim().EndsWith("\\") && !extractPath.Trim().EndsWith("/")) { extractPath = extractPath + "\\"; } File.WriteAllBytes(extractPath + "boxdata.bin", C_SAV.SAV.GetBoxBinary(C_SAV.Box.CB_BoxSelect.SelectedIndex)); } else if (savExtraction) { clickExportSAVCustomized(cyberSavPath); } this.Close(); }
private void B_OK_Click(object sender, EventArgs e) { Result = (GameVersion)WinFormsUtil.GetIndex(CB_Game); Close(); }
public SettingsEditor(object obj, params string[] blacklist) { InitializeComponent(); SettingsObject = obj ?? Settings.Default; LoadSettings(blacklist); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); // reorder checkboxes var checkboxes = FLP_Settings.Controls.OfType <CheckBox>().OrderBy(z => z.Text).ToList(); var ctr = 0; foreach (var c in checkboxes) { FLP_Settings.Controls.SetChildIndex(c, ctr++); } if (obj is Settings s) { var noSelectVersions = new[] { GameVersion.GO }; CB_Blank.InitializeBinding(); CB_Blank.DataSource = GameInfo.VersionDataSource.Where(z => !noSelectVersions.Contains((GameVersion)z.Value)).ToList(); CB_Blank.SelectedValue = (int)s.DefaultSaveVersion; CB_Blank.SelectedValueChanged += (_, __) => s.DefaultSaveVersion = (GameVersion)WinFormsUtil.GetIndex(CB_Blank); } else { FLP_Blank.Visible = false; } PG_Color.SelectedObject = Main.Draw; this.CenterToForm(FindForm()); }
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.SubRegion = WinFormsUtil.GetIndex(CB_Region); SAV.Country = WinFormsUtil.GetIndex(CB_Country); SAV.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg); SAV.Language = WinFormsUtil.GetIndex(CB_Language); SAV.OT = TB_OTName.Text; SAV.Saying1 = TB_Saying1.Text; SAV.Saying2 = TB_Saying2.Text; SAV.Saying3 = TB_Saying3.Text; SAV.Saying4 = TB_Saying4.Text; SAV.Saying5 = TB_Saying5.Text; // Copy Maison Data in if (SAV.MaisonStats > -1) { for (int i = 0; i < MaisonRecords.Length; i++) { SAV.SetMaisonStat(i, ushort.Parse(MaisonRecords[i].Text)); } } // Copy Position if (GB_Map.Enabled && MapUpdated) { SAV.M = (int)NUD_M.Value; SAV.X = (float)NUD_X.Value; SAV.Z = (float)NUD_Z.Value; SAV.Y = (float)NUD_Y.Value; } SAV.BP = ushort.Parse(TB_BP.Text); // Set Current PokéMiles SAV.SetPSSStat(0xFC / 4, Util.ToUInt32(TB_PM.Text)); // Set Max Obtained Pokémiles SAV.SetPSSStat(0x100 / 4, Util.ToUInt32(TB_PM.Text)); SAV.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 SAV.MultiplayerSpriteID = Convert.ToByte(CB_MultiplayerSprite.SelectedValue); // Appearance if (SAV.XY) { SAV.Data[SAV.TrainerCard + 0x30] = byte.Parse(MT_14030.Text); SAV.Data[SAV.TrainerCard + 0x31] = (byte)(byte.Parse(MT_HairColor.Text) | (byte.Parse(MT_Hat.Text) << 3)); SAV.Data[SAV.TrainerCard + 0x32] = byte.Parse(MT_14032.Text); SAV.Data[SAV.TrainerCard + 0x33] = byte.Parse(MT_14033.Text); SAV.Data[SAV.TrainerCard + 0x34] = byte.Parse(MT_14034.Text); SAV.Data[SAV.TrainerCard + 0x35] = byte.Parse(MT_14035.Text); SAV.Data[SAV.TrainerCard + 0x36] = byte.Parse(MT_14036.Text); SAV.Data[SAV.TrainerCard + 0x37] = byte.Parse(MT_14037.Text); SAV.Data[SAV.TrainerCard + 0x38] = byte.Parse(MT_14038.Text); SAV.Data[SAV.TrainerCard + 0x39] = byte.Parse(MT_14039.Text); SAV.Data[SAV.TrainerCard + 0x3A] = byte.Parse(MT_1403A.Text); SAV.Data[SAV.TrainerCard + 0x3B] = byte.Parse(MT_1403B.Text); SAV.Data[SAV.TrainerCard + 0x3C] = byte.Parse(MT_1403C.Text); SAV.Data[SAV.TrainerCard + 0x3D] = byte.Parse(MT_1403D.Text); SAV.Data[SAV.TrainerCard + 0x3E] = byte.Parse(MT_1403E.Text); SAV.Data[SAV.TrainerCard + 0x3F] = byte.Parse(MT_1403F.Text); SAV.OT_Nick = TB_TRNick.Text; } // Vivillon SAV.Vivillon = CB_Vivillon.SelectedIndex; int seconds = (int)(CAL_AdventureStartDate.Value - new DateTime(2000, 1, 1)).TotalSeconds; seconds -= seconds % 86400; seconds += (int)(CAL_AdventureStartTime.Value - new DateTime(2000, 1, 1)).TotalSeconds; SAV.SecondsToStart = seconds; int fame = (int)(CAL_HoFDate.Value - new DateTime(2000, 1, 1)).TotalSeconds; fame -= fame % 86400; fame += (int)(CAL_HoFTime.Value - new DateTime(2000, 1, 1)).TotalSeconds; SAV.SecondsToFame = fame; if (SAV.LastSavedDate.HasValue) { SAV.LastSavedDate = new DateTime(CAL_LastSavedDate.Value.Year, CAL_LastSavedDate.Value.Month, CAL_LastSavedDate.Value.Day, CAL_LastSavedTime.Value.Hour, CAL_LastSavedTime.Value.Minute, 0); } SAV.IsMegaEvolutionUnlocked = CHK_MegaUnlocked.Checked; }
// View Updates private void B_Search_Click(object sender, EventArgs e) { // Populate Search Query Result IEnumerable <MysteryGift> res = RawDB; int format = MAXFORMAT + 1 - CB_Format.SelectedIndex; switch (CB_FormatComparator.SelectedIndex) { case 0: /* Do nothing */ break; case 1: res = res.Where(mg => mg.Format >= format); break; case 2: res = res.Where(mg => mg.Format == format); break; case 3: res = res.Where(mg => mg.Format <= format); break; } // Primary Searchables int species = WinFormsUtil.GetIndex(CB_Species); int item = WinFormsUtil.GetIndex(CB_HeldItem); if (species != -1) { res = res.Where(pk => pk.Species == species); } if (item != -1) { res = res.Where(pk => pk.HeldItem == item); } // Secondary Searchables int move1 = WinFormsUtil.GetIndex(CB_Move1); int move2 = WinFormsUtil.GetIndex(CB_Move2); int move3 = WinFormsUtil.GetIndex(CB_Move3); int move4 = WinFormsUtil.GetIndex(CB_Move4); if (move1 != -1) { res = res.Where(mg => mg.HasMove(move1)); } if (move2 != -1) { res = res.Where(mg => mg.HasMove(move2)); } if (move3 != -1) { res = res.Where(mg => mg.HasMove(move3)); } if (move4 != -1) { res = res.Where(mg => mg.HasMove(move4)); } if (CHK_Shiny.CheckState == CheckState.Checked) { res = res.Where(pk => pk.IsShiny); } if (CHK_Shiny.CheckState == CheckState.Unchecked) { res = res.Where(pk => !pk.IsShiny); } if (CHK_IsEgg.CheckState == CheckState.Checked) { res = res.Where(pk => pk.IsEgg); } if (CHK_IsEgg.CheckState == CheckState.Unchecked) { res = res.Where(pk => !pk.IsEgg); } slotSelected = -1; // reset the slot last viewed if (RTB_Instructions.Lines.Any(line => line.Length > 0)) { var filters = StringInstruction.GetFilters(RTB_Instructions.Lines).ToArray(); BatchEditing.ScreenStrings(filters); res = res.Where(pkm => BatchEditing.IsFilterMatch(filters, pkm)); // Compare across all filters } var results = res.ToArray(); if (results.Length == 0) { WinFormsUtil.Alert(MsgDBSearchNone); } SetResults(new List <MysteryGift>(results)); // updates Count Label as well. System.Media.SystemSounds.Asterisk.Play(); }
// View Updates private IEnumerable <PKM> SearchDatabase() { // Populate Search Query Result IEnumerable <PKM> res = RawDB; // Filter for Selected Source if (!Menu_SearchBoxes.Checked) { res = res.Where(pk => pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal)); } if (!Menu_SearchDatabase.Checked) { res = res.Where(pk => !pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal)); #if LOADALL res = res.Where(pk => !pk.Identifier.StartsWith(EXTERNAL_SAV, StringComparison.Ordinal)); #endif } int format = MAXFORMAT + 1 - CB_Format.SelectedIndex; switch (CB_FormatComparator.SelectedIndex) { case 0: /* Do nothing */ break; case 1: res = res.Where(pk => pk.Format >= format); break; case 2: res = res.Where(pk => pk.Format == format); break; case 3: res = res.Where(pk => pk.Format <= format); break; } if (CB_FormatComparator.SelectedIndex != 0) { if (format <= 2) // 1-2 { res = res.Where(pk => pk.Format <= 2); } if (format >= 3 && format <= 6) // 3-6 { res = res.Where(pk => pk.Format >= 3); } if (format >= 7) // 1,3-6,7 { res = res.Where(pk => pk.Format != 2); } } switch (CB_Generation.SelectedIndex) { case 0: /* Do nothing */ break; case 1: res = res.Where(pk => pk.Gen7); break; case 2: res = res.Where(pk => pk.Gen6); break; case 3: res = res.Where(pk => pk.Gen5); break; case 4: res = res.Where(pk => pk.Gen4); break; case 5: res = res.Where(pk => pk.Gen3); break; } // Primary Searchables int species = WinFormsUtil.GetIndex(CB_Species); int ability = WinFormsUtil.GetIndex(CB_Ability); int nature = WinFormsUtil.GetIndex(CB_Nature); int item = WinFormsUtil.GetIndex(CB_HeldItem); if (species != -1) { res = res.Where(pk => pk.Species == species); } if (ability != -1) { res = res.Where(pk => pk.Ability == ability); } if (nature != -1) { res = res.Where(pk => pk.Nature == nature); } if (item != -1) { res = res.Where(pk => pk.HeldItem == item); } // Secondary Searchables int move1 = WinFormsUtil.GetIndex(CB_Move1); int move2 = WinFormsUtil.GetIndex(CB_Move2); int move3 = WinFormsUtil.GetIndex(CB_Move3); int move4 = WinFormsUtil.GetIndex(CB_Move4); if (move1 != -1) { res = res.Where(pk => pk.Moves.Contains(move1)); } if (move2 != -1) { res = res.Where(pk => pk.Moves.Contains(move2)); } if (move3 != -1) { res = res.Where(pk => pk.Moves.Contains(move3)); } if (move4 != -1) { res = res.Where(pk => pk.Moves.Contains(move4)); } int vers = WinFormsUtil.GetIndex(CB_GameOrigin); if (vers != -1) { res = res.Where(pk => pk.Version == vers); } int hptype = WinFormsUtil.GetIndex(CB_HPType); if (hptype != -1) { res = res.Where(pk => pk.HPType == hptype); } if (CHK_Shiny.CheckState == CheckState.Checked) { res = res.Where(pk => pk.IsShiny); } if (CHK_Shiny.CheckState == CheckState.Unchecked) { res = res.Where(pk => !pk.IsShiny); } if (CHK_IsEgg.CheckState == CheckState.Checked) { res = res.Where(pk => pk.IsEgg); } if (CHK_IsEgg.CheckState == CheckState.Unchecked) { res = res.Where(pk => !pk.IsEgg); } if (CHK_IsEgg.CheckState == CheckState.Checked && MT_ESV.Text != "") { res = res.Where(pk => pk.PSV == Convert.ToInt16(MT_ESV.Text)); } // Tertiary Searchables res = FilterByLVL(res, CB_Level.SelectedIndex, TB_Level.Text); res = FilterByIVs(res, CB_IV.SelectedIndex); res = FilterByEVs(res, CB_EVTrain.SelectedIndex); slotSelected = -1; // reset the slot last viewed if (Menu_SearchLegal.Checked && !Menu_SearchIllegal.Checked) { res = res.Where(pk => new LegalityAnalysis(pk).ParsedValid); } if (!Menu_SearchLegal.Checked && Menu_SearchIllegal.Checked) { res = res.Where(pk => new LegalityAnalysis(pk).ParsedInvalid); } if (RTB_Instructions.Lines.Any(line => line.Length > 0)) { var filters = BatchEditor.StringInstruction.GetFilters(RTB_Instructions.Lines).ToArray(); BatchEditor.ScreenStrings(filters); res = res.Where(pkm => // Compare across all filters { foreach (var cmd in filters) { if (cmd.PropertyName == nameof(PKM.Identifier) + "Contains") { return(pkm.Identifier.Contains(cmd.PropertyValue)); } if (!pkm.GetType().HasPropertyAll(cmd.PropertyName)) { return(false); } try { if (pkm.GetType().IsValueEqual(pkm, cmd.PropertyName, cmd.PropertyValue) == cmd.Evaluator) { continue; } } catch { Debug.WriteLine($"Unable to compare {cmd.PropertyName} to {cmd.PropertyValue}."); } return(false); } return(true); }); } if (Menu_SearchClones.Checked) { res = res.GroupBy(Hash).Where(group => group.Count() > 1).SelectMany(z => z); } return(res); }
// View Updates private IEnumerable <PKM> SearchDatabase() { // Populate Search Query Result IEnumerable <PKM> res = RawDB; // Filter for Selected Source if (!Menu_SearchBoxes.Checked) { res = res.Where(pk => pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal)); } if (!Menu_SearchDatabase.Checked) { res = res.Where(pk => !pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal)); #if LOADALL res = res.Where(pk => !pk.Identifier.StartsWith(EXTERNAL_SAV, StringComparison.Ordinal)); #endif } int format = MAXFORMAT + 1 - CB_Format.SelectedIndex; switch (CB_FormatComparator.SelectedIndex) { case 0: /* Do nothing */ break; case 1: res = res.Where(pk => pk.Format >= format); break; case 2: res = res.Where(pk => pk.Format == format); break; case 3: res = res.Where(pk => pk.Format <= format); break; } if (CB_FormatComparator.SelectedIndex != 0) { if (format <= 2) // 1-2 { res = res.Where(pk => pk.Format <= 2); } if (format >= 3 && format <= 6) // 3-6 { res = res.Where(pk => pk.Format >= 3); } } switch (CB_Generation.SelectedIndex) { case 0: /* Do nothing */ break; case 1: res = res.Where(pk => pk.Gen7); break; case 2: res = res.Where(pk => pk.Gen6); break; case 3: res = res.Where(pk => pk.Gen5); break; case 4: res = res.Where(pk => pk.Gen4); break; case 5: res = res.Where(pk => pk.Gen3); break; } // Primary Searchables int species = WinFormsUtil.GetIndex(CB_Species); int ability = WinFormsUtil.GetIndex(CB_Ability); int nature = WinFormsUtil.GetIndex(CB_Nature); int item = WinFormsUtil.GetIndex(CB_HeldItem); if (species != -1) { res = res.Where(pk => pk.Species == species); } if (ability != -1) { res = res.Where(pk => pk.Ability == ability); } if (nature != -1) { res = res.Where(pk => pk.Nature == nature); } if (item != -1) { res = res.Where(pk => pk.HeldItem == item); } // Secondary Searchables int move1 = WinFormsUtil.GetIndex(CB_Move1); int move2 = WinFormsUtil.GetIndex(CB_Move2); int move3 = WinFormsUtil.GetIndex(CB_Move3); int move4 = WinFormsUtil.GetIndex(CB_Move4); var moves = new[] { move1, move2, move3, move4 }.Where(z => z > 0).ToList(); int count = moves.Count; if (count > 0) { res = res.Where(pk => pk.Moves.Intersect(moves).Count() == count); } int vers = WinFormsUtil.GetIndex(CB_GameOrigin); if (vers != -1) { res = res.Where(pk => pk.Version == vers); } int hptype = WinFormsUtil.GetIndex(CB_HPType); if (hptype != -1) { res = res.Where(pk => pk.HPType == hptype); } if (CHK_Shiny.CheckState == CheckState.Checked) { res = res.Where(pk => pk.IsShiny); } if (CHK_Shiny.CheckState == CheckState.Unchecked) { res = res.Where(pk => !pk.IsShiny); } if (CHK_IsEgg.CheckState == CheckState.Checked) { res = res.Where(pk => pk.IsEgg); } if (CHK_IsEgg.CheckState == CheckState.Unchecked) { res = res.Where(pk => !pk.IsEgg); } if (CHK_IsEgg.CheckState == CheckState.Checked && int.TryParse(MT_ESV.Text, out int esv)) { res = res.Where(pk => pk.PSV == esv); } // Tertiary Searchables res = FilterByLVL(res, CB_Level.SelectedIndex, TB_Level.Text); res = FilterByIVs(res, CB_IV.SelectedIndex); res = FilterByEVs(res, CB_EVTrain.SelectedIndex); slotSelected = -1; // reset the slot last viewed if (Menu_SearchLegal.Checked && !Menu_SearchIllegal.Checked) { res = res.Where(pk => new LegalityAnalysis(pk).Valid); } if (!Menu_SearchLegal.Checked && Menu_SearchIllegal.Checked) { res = res.Where(pk => !new LegalityAnalysis(pk).Valid); } if (RTB_Instructions.Lines.Any(line => line.Length > 0)) { var filters = StringInstruction.GetFilters(RTB_Instructions.Lines).ToArray(); BatchEditing.ScreenStrings(filters); res = res.Where(pkm => BatchEditing.IsFiltered(filters, pkm)); // Compare across all filters } if (Menu_SearchClones.Checked) { res = res.GroupBy(Hash).Where(group => group.Count() > 1).SelectMany(z => z); } return(res); }
public SettingsEditor(object obj) { InitializeComponent(); LoadSettings(obj); if (obj is PKHeXSettings s) { var noSelectVersions = new[] { GameVersion.GO }; CB_Blank.InitializeBinding(); CB_Blank.DataSource = GameInfo.VersionDataSource.Where(z => !noSelectVersions.Contains((GameVersion)z.Value)).ToList(); CB_Blank.SelectedValue = (int)s.Startup.DefaultSaveVersion; CB_Blank.SelectedValueChanged += (_, __) => s.Startup.DefaultSaveVersion = (GameVersion)WinFormsUtil.GetIndex(CB_Blank); CB_Blank.SelectedIndexChanged += (_, __) => BlankChanged = true; B_Reset.Click += (x, e) => DeleteSettings(); } else { FLP_Blank.Visible = false; B_Reset.Visible = false; } this.CenterToForm(FindForm()); }
private SearchSettings GetSearchSettings() { var settings = new SearchSettings { Format = MAXFORMAT - CB_Format.SelectedIndex + 1, // 0->(n-1) => 1->n SearchFormat = (SearchComparison)CB_FormatComparator.SelectedIndex, Generation = CB_Generation.SelectedIndex, Version = WinFormsUtil.GetIndex(CB_GameOrigin), HiddenPowerType = WinFormsUtil.GetIndex(CB_HPType), Species = WinFormsUtil.GetIndex(CB_Species), Ability = WinFormsUtil.GetIndex(CB_Ability), Nature = WinFormsUtil.GetIndex(CB_Nature), Item = WinFormsUtil.GetIndex(CB_HeldItem), BatchInstructions = RTB_Instructions.Lines, Level = int.TryParse(TB_Level.Text, out var lvl) ? (int?)lvl : null, SearchLevel = (SearchComparison)CB_Level.SelectedIndex, EVType = CB_EVTrain.SelectedIndex, IVType = CB_IV.SelectedIndex, }; settings.AddMove(WinFormsUtil.GetIndex(CB_Move1)); settings.AddMove(WinFormsUtil.GetIndex(CB_Move2)); settings.AddMove(WinFormsUtil.GetIndex(CB_Move3)); settings.AddMove(WinFormsUtil.GetIndex(CB_Move4)); if (CHK_Shiny.CheckState != CheckState.Indeterminate) { settings.SearchShiny = CHK_Shiny.CheckState == CheckState.Checked; } if (CHK_IsEgg.CheckState != CheckState.Indeterminate) { settings.SearchEgg = CHK_IsEgg.CheckState == CheckState.Checked; if (int.TryParse(MT_ESV.Text, out int esv)) { settings.ESV = esv; } } if (Menu_SearchLegal.Checked != Menu_SearchIllegal.Checked) { settings.SearchLegal = Menu_SearchLegal.Checked; } if (Menu_SearchClones.Checked) { switch (ModifierKeys) { case Keys.Control: settings.SearchClones = CloneDetectionMethod.HashPID; break; default: settings.SearchClones = CloneDetectionMethod.HashDetails; break; } } return(settings); }
private void UpdateShiny(object sender, EventArgs e) { if (!editing) { return; //Don't do writing until loaded } bpkx.Image = PKMUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked); Write_Entry(null, null); }