mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Misc updates
condense repeated logic extract properties extract reusable methods
This commit is contained in:
parent
f57e7bf686
commit
493bef75eb
7 changed files with 152 additions and 132 deletions
|
@ -66,6 +66,12 @@ namespace PKHeX.Core
|
|||
|
||||
public static IReadOnlyList<ComboItem> LanguageDataSource(int gen) => GameStrings.LanguageDataSource(gen);
|
||||
|
||||
public static IReadOnlyList<ComboItem> GetAbilityList(int[] abils, int format)
|
||||
{
|
||||
if (format == 3 && abils[1] == abils[0])
|
||||
abils = new[] { abils[0] };
|
||||
return Strings.GetAbilityDataSource(abils);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the location names array for a specified generation.
|
||||
|
|
|
@ -143,7 +143,6 @@ namespace PKHeX.Core
|
|||
OFS_PouchBalls = BlockOfs[1] + 0x0600;
|
||||
OFS_PouchTMHM = BlockOfs[1] + 0x0640;
|
||||
OFS_PouchBerry = BlockOfs[1] + 0x0740;
|
||||
Personal = PersonalTable.RS;
|
||||
SeenFlagOffsets = new[] {PokeDex + 0x44, BlockOfs[1] + 0x938, BlockOfs[4] + 0xC0C};
|
||||
EventFlag = BlockOfs[2] + 0x2A0;
|
||||
EventConst = EventFlag + EventFlagMax / 8;
|
||||
|
@ -157,7 +156,6 @@ namespace PKHeX.Core
|
|||
OFS_PouchBalls = BlockOfs[1] + 0x0650;
|
||||
OFS_PouchTMHM = BlockOfs[1] + 0x0690;
|
||||
OFS_PouchBerry = BlockOfs[1] + 0x0790;
|
||||
Personal = PersonalTable.E;
|
||||
SeenFlagOffsets = new[] {PokeDex + 0x44, BlockOfs[1] + 0x988, BlockOfs[4] + 0xCA4};
|
||||
EventFlag = BlockOfs[2] + 0x2F0;
|
||||
EventConst = EventFlag + EventFlagMax / 8;
|
||||
|
@ -171,13 +169,13 @@ namespace PKHeX.Core
|
|||
OFS_PouchBalls = BlockOfs[1] + 0x0430;
|
||||
OFS_PouchTMHM = BlockOfs[1] + 0x0464;
|
||||
OFS_PouchBerry = BlockOfs[1] + 0x054C;
|
||||
Personal = PersonalTable.FR;
|
||||
SeenFlagOffsets = new[] {PokeDex + 0x44, BlockOfs[1] + 0x5F8, BlockOfs[4] + 0xB98};
|
||||
EventFlag = BlockOfs[2] + 0x000;
|
||||
EventConst = EventFlag + EventFlagMax / 8;
|
||||
Daycare = BlockOfs[4] + 0x100;
|
||||
break;
|
||||
}
|
||||
Personal = SaveUtil.GetG3Personal(Version);
|
||||
LoadEReaderBerryData();
|
||||
LegalItems = Legal.Pouch_Items_RS;
|
||||
LegalBalls = Legal.Pouch_Ball_RS;
|
||||
|
|
|
@ -1223,5 +1223,55 @@ namespace PKHeX.Core
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Force loads the provided <see cref="sav"/> to the requested <see cref="ver"/>.
|
||||
/// </summary>
|
||||
/// <param name="sav">SaveFile data to force</param>
|
||||
/// <param name="ver">Version to retrieve for</param>
|
||||
/// <returns>New <see cref="SaveFile"/> object.</returns>
|
||||
public static SaveFile GetG3SaveOverride(SaveFile sav, GameVersion ver)
|
||||
{
|
||||
switch (ver) // Reset save file info
|
||||
{
|
||||
case GameVersion.R:
|
||||
case GameVersion.S:
|
||||
case GameVersion.RS:
|
||||
return new SAV3(sav.BAK, GameVersion.RS);
|
||||
case GameVersion.E:
|
||||
return new SAV3(sav.BAK, GameVersion.E);
|
||||
case GameVersion.FRLG:
|
||||
case GameVersion.FR:
|
||||
case GameVersion.LG:
|
||||
return new SAV3(sav.BAK, GameVersion.FRLG);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PersonalTable"/> for a Gen3 save file.
|
||||
/// </summary>
|
||||
/// <param name="ver">Version to retrieve for</param>
|
||||
/// <returns>Reference to the <see cref="PersonalTable"/>.</returns>
|
||||
public static PersonalTable GetG3Personal(GameVersion ver)
|
||||
{
|
||||
switch (ver)
|
||||
{
|
||||
case GameVersion.FRLG:
|
||||
case GameVersion.FR:
|
||||
return PersonalTable.FR;
|
||||
case GameVersion.LG:
|
||||
return PersonalTable.LG;
|
||||
case GameVersion.E:
|
||||
return PersonalTable.E;
|
||||
case GameVersion.R:
|
||||
case GameVersion.S:
|
||||
case GameVersion.RS:
|
||||
return PersonalTable.RS;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace PKHeX.WinForms.Controls
|
|||
TB_OT.Font = (Font)TB_Nickname.Font.Clone();
|
||||
TB_OTt2.Font = (Font)TB_Nickname.Font.Clone();
|
||||
|
||||
DrawForeColor = ForeColor;
|
||||
if (TextBrush == null) TextBrush = new SolidBrush(CB_Move1.ForeColor);
|
||||
if (BackBrush == null) BackBrush = new SolidBrush(CB_Move1.BackColor);
|
||||
|
||||
|
@ -298,12 +299,12 @@ namespace PKHeX.WinForms.Controls
|
|||
gendersymbols = symbols;
|
||||
if (!Unicode)
|
||||
{
|
||||
BTN_Shinytize.Text = "*";
|
||||
BTN_Shinytize.Text = ShinytizeDefault;
|
||||
TB_Nickname.Font = TB_OT.Font = TB_OTt2.Font = GB_OT.Font;
|
||||
}
|
||||
else
|
||||
{
|
||||
BTN_Shinytize.Text = "☆";
|
||||
BTN_Shinytize.Text = ShinytizeUnicode;
|
||||
TB_Nickname.Font = TB_OT.Font = TB_OTt2.Font = FontUtil.GetPKXFont(11);
|
||||
}
|
||||
// Switch active gender labels to new if they are active.
|
||||
|
@ -329,6 +330,9 @@ namespace PKHeX.WinForms.Controls
|
|||
private Brush LegalMove { get; set; } = Brushes.PaleGreen;
|
||||
private Brush TextBrush { get; set; }
|
||||
private Brush BackBrush { get; set; }
|
||||
private string ShinytizeDefault { get; set; } = "*";
|
||||
private string ShinytizeUnicode { get; set; } = "☆";
|
||||
private Color DrawForeColor { get; set; }
|
||||
|
||||
private Color GetGenderColor(int gender)
|
||||
{
|
||||
|
@ -336,8 +340,18 @@ namespace PKHeX.WinForms.Controls
|
|||
{
|
||||
case 0: return Color.Blue;
|
||||
case 1: return Color.Red;
|
||||
default: return DrawForeColor;
|
||||
}
|
||||
}
|
||||
|
||||
private bool GetMarkingColor(int markval, out Color c)
|
||||
{
|
||||
switch (markval)
|
||||
{
|
||||
case 1: c = MarkBlue; return true;
|
||||
case 2: c = MarkPink; return true;
|
||||
default: c = MarkDefault; return false; // recolor not required
|
||||
}
|
||||
return CB_Species.ForeColor;
|
||||
}
|
||||
|
||||
private void SetDetailsOT(ITrainerInfo SAV)
|
||||
|
@ -391,8 +405,8 @@ namespace PKHeX.WinForms.Controls
|
|||
if (!hasForms)
|
||||
return;
|
||||
|
||||
var ds = PKX.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, gendersymbols, pkm.Format).ToList();
|
||||
if (ds.Count == 1 && string.IsNullOrEmpty(ds[0])) // empty (Alolan Totems)
|
||||
var ds = PKX.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, gendersymbols, pkm.Format);
|
||||
if (ds.Length == 1 && string.IsNullOrEmpty(ds[0])) // empty (Alolan Totems)
|
||||
CB_Form.Enabled = CB_Form.Visible = Label_Form.Visible = false;
|
||||
else
|
||||
CB_Form.DataSource = ds;
|
||||
|
@ -462,22 +476,6 @@ namespace PKHeX.WinForms.Controls
|
|||
}
|
||||
}
|
||||
|
||||
private bool GetMarkingColor(int markval, out Color c)
|
||||
{
|
||||
switch (markval)
|
||||
{
|
||||
case 1:
|
||||
c = MarkBlue;
|
||||
return true;
|
||||
case 2:
|
||||
c = MarkPink;
|
||||
return true;
|
||||
default:
|
||||
c = MarkDefault;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateGender()
|
||||
{
|
||||
int Gender = pkm.GetSaneGender();
|
||||
|
@ -489,7 +487,7 @@ namespace PKHeX.WinForms.Controls
|
|||
{
|
||||
int index = CB.SelectedIndex;
|
||||
// fix for Korean / Chinese being swapped
|
||||
string cl = GameInfo.CurrentLanguage + "";
|
||||
string cl = GameInfo.CurrentLanguage;
|
||||
cl = cl == "zh" ? "ko" : cl == "ko" ? "zh" : cl;
|
||||
|
||||
CB.DataSource = Util.GetCBList(type, cl);
|
||||
|
@ -706,7 +704,7 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
if (!silent)
|
||||
{
|
||||
var movestrings = m.Select(v => v >= GameInfo.Strings.movelist.Length ? MsgProgramError : GameInfo.Strings.movelist[v]);
|
||||
var movestrings = m.Select(v => v >= GameInfo.Strings.Move.Count ? MsgProgramError : GameInfo.Strings.Move[v]);
|
||||
string r = string.Join(Environment.NewLine, movestrings);
|
||||
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgPKMSuggestionMoves, r))
|
||||
return false;
|
||||
|
@ -730,7 +728,7 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
if (!silent)
|
||||
{
|
||||
var movestrings = m.Select(v => v >= GameInfo.Strings.movelist.Length ? MsgProgramError : GameInfo.Strings.movelist[v]);
|
||||
var movestrings = m.Select(v => v >= GameInfo.Strings.Move.Count ? MsgProgramError : GameInfo.Strings.Move[v]);
|
||||
string r = string.Join(Environment.NewLine, movestrings);
|
||||
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgPKMSuggestionRelearn, r))
|
||||
return false;
|
||||
|
@ -810,8 +808,8 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
private void UpdateEXPLevel(object sender, EventArgs e)
|
||||
{
|
||||
if (ChangingFields || !FieldsInitialized) return;
|
||||
|
||||
if (ChangingFields || !FieldsInitialized)
|
||||
return;
|
||||
ChangingFields = true;
|
||||
if (sender == TB_EXP)
|
||||
{
|
||||
|
@ -998,7 +996,8 @@ namespace PKHeX.WinForms.Controls
|
|||
// Set the days back if they're legal, else set it to 1. (0 always passes).
|
||||
CB_PKRSDays.SelectedIndex = currentDuration < CB_PKRSDays.Items.Count ? currentDuration : 1;
|
||||
|
||||
if (CB_PKRSStrain.SelectedIndex != 0) return;
|
||||
if (CB_PKRSStrain.SelectedIndex != 0)
|
||||
return;
|
||||
|
||||
// Never Infected
|
||||
CB_PKRSDays.SelectedIndex = 0;
|
||||
|
@ -1008,7 +1007,8 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
private void UpdatePKRSdays(object sender, EventArgs e)
|
||||
{
|
||||
if (CB_PKRSDays.SelectedIndex != 0) return;
|
||||
if (CB_PKRSDays.SelectedIndex != 0)
|
||||
return;
|
||||
|
||||
// If no days are selected
|
||||
if (CB_PKRSStrain.SelectedIndex == 0)
|
||||
|
@ -1018,7 +1018,8 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
private void UpdatePKRSCured(object sender, EventArgs e)
|
||||
{
|
||||
if (!FieldsInitialized) return;
|
||||
if (!FieldsInitialized)
|
||||
return;
|
||||
// Cured PokeRus is toggled
|
||||
if (CHK_Cured.Checked)
|
||||
{
|
||||
|
@ -1054,9 +1055,12 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
private void UpdatePKRSInfected(object sender, EventArgs e)
|
||||
{
|
||||
if (!FieldsInitialized) return;
|
||||
if (CHK_Cured.Checked && !CHK_Infected.Checked) { CHK_Cured.Checked = false; return; }
|
||||
if (CHK_Cured.Checked) return;
|
||||
if (!FieldsInitialized)
|
||||
return;
|
||||
if (CHK_Cured.Checked && !CHK_Infected.Checked)
|
||||
{ CHK_Cured.Checked = false; return; }
|
||||
if (CHK_Cured.Checked)
|
||||
return;
|
||||
Label_PKRS.Visible = CB_PKRSStrain.Visible = CHK_Infected.Checked;
|
||||
if (!CHK_Infected.Checked) { CB_PKRSStrain.SelectedIndex = 0; CB_PKRSDays.SelectedIndex = 0; Label_PKRSdays.Visible = CB_PKRSDays.Visible = false; }
|
||||
else if (CB_PKRSStrain.SelectedIndex == 0)
|
||||
|
@ -1233,7 +1237,7 @@ namespace PKHeX.WinForms.Controls
|
|||
// Fetch Current Species and set it as Nickname Text
|
||||
int species = WinFormsUtil.GetIndex(CB_Species);
|
||||
if (species < 1 || species > pkm.MaxSpeciesID)
|
||||
{ TB_Nickname.Text = ""; return; }
|
||||
{ TB_Nickname.Text = string.Empty; return; }
|
||||
|
||||
if (CHK_IsEgg.Checked)
|
||||
species = 0; // get the egg name.
|
||||
|
@ -1291,7 +1295,7 @@ namespace PKHeX.WinForms.Controls
|
|||
if (string.IsNullOrWhiteSpace(TB_OTt2.Text))
|
||||
{
|
||||
ClickGT(GB_OT, null); // Switch CT over to OT.
|
||||
Label_CTGender.Text = "";
|
||||
Label_CTGender.Text = string.Empty;
|
||||
TB_Friendship.Text = pkm.CurrentFriendship.ToString();
|
||||
}
|
||||
else if (string.IsNullOrWhiteSpace(Label_CTGender.Text))
|
||||
|
@ -1550,7 +1554,8 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
private void ValidateMovePaint(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
if (e.Index < 0) return;
|
||||
if (e.Index < 0)
|
||||
return;
|
||||
|
||||
var i = (ComboItem)((ComboBox)sender).Items[e.Index];
|
||||
bool valid = AllowedMoves.Contains(i.Value) && !HaX;
|
||||
|
@ -1587,15 +1592,8 @@ namespace PKHeX.WinForms.Controls
|
|||
}
|
||||
|
||||
// Secondary Windows for Ribbons/Amie/Memories
|
||||
private void OpenRibbons(object sender, EventArgs e)
|
||||
{
|
||||
new RibbonEditor(pkm).ShowDialog();
|
||||
}
|
||||
|
||||
private void OpenMedals(object sender, EventArgs e)
|
||||
{
|
||||
new SuperTrainingEditor(pkm).ShowDialog();
|
||||
}
|
||||
private void OpenRibbons(object sender, EventArgs e) => new RibbonEditor(pkm).ShowDialog();
|
||||
private void OpenMedals(object sender, EventArgs e) => new SuperTrainingEditor(pkm).ShowDialog();
|
||||
|
||||
private void OpenHistory(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -1852,9 +1850,7 @@ namespace PKHeX.WinForms.Controls
|
|||
private static IReadOnlyList<ComboItem> GetAbilityList(PKM pkm)
|
||||
{
|
||||
var abils = pkm.PersonalInfo.Abilities;
|
||||
if (pkm.Format == 3 && abils[1] == abils[0])
|
||||
abils = new[] { abils[0] };
|
||||
return GameInfo.Strings.GetAbilityDataSource(abils);
|
||||
return GameInfo.GetAbilityList(abils, pkm.Format);
|
||||
}
|
||||
|
||||
private static PKM GetCompatiblePKM(SaveFile sav, PKM current)
|
||||
|
|
|
@ -154,6 +154,7 @@
|
|||
//
|
||||
// Tab_Box
|
||||
//
|
||||
this.Tab_Box.AllowDrop = true;
|
||||
this.Tab_Box.Controls.Add(this.Box);
|
||||
this.Tab_Box.Location = new System.Drawing.Point(4, 22);
|
||||
this.Tab_Box.Name = "Tab_Box";
|
||||
|
@ -178,6 +179,7 @@
|
|||
//
|
||||
// Tab_PartyBattle
|
||||
//
|
||||
this.Tab_PartyBattle.AllowDrop = true;
|
||||
this.Tab_PartyBattle.Controls.Add(this.PAN_BattleBox);
|
||||
this.Tab_PartyBattle.Controls.Add(this.L_ReadOnlyPBB);
|
||||
this.Tab_PartyBattle.Controls.Add(this.L_BattleBox);
|
||||
|
|
|
@ -82,13 +82,19 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
dcpkx1, dcpkx2
|
||||
};
|
||||
GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
|
||||
SAV = z.Result;
|
||||
Box.Setup(M = new SlotChangeManager(this));
|
||||
SL_Extra.M = M;
|
||||
foreach (TabPage tab in tabBoxMulti.TabPages)
|
||||
tab.AllowDrop = true;
|
||||
|
||||
M.OtherSlots.Add(this);
|
||||
SL_Extra.ViewIndex = -2;
|
||||
M.OtherSlots.Add(SL_Extra);
|
||||
Tab_Box.ContextMenuStrip = SortMenu = new BoxMenuStrip(this);
|
||||
InitializeEvents();
|
||||
}
|
||||
|
||||
private void InitializeEvents()
|
||||
{
|
||||
foreach (PictureBox pb in Box.SlotPictureBoxes)
|
||||
pb.ContextMenuStrip = menu.mnuVSD;
|
||||
foreach (PictureBox pb in SlotPictureBoxes)
|
||||
|
@ -97,6 +103,7 @@ namespace PKHeX.WinForms.Controls
|
|||
pb.ContextMenuStrip = menu.mnuVSD;
|
||||
}
|
||||
|
||||
GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
|
||||
Tab_Box.MouseWheel += (s, e) =>
|
||||
{
|
||||
if (menu.mnuVSD.Visible)
|
||||
|
@ -109,12 +116,7 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
GB_Daycare.Click += SwitchDaycare;
|
||||
FLP_SAVtools.Scroll += WinFormsUtil.PanelScroll;
|
||||
Tab_Box.ContextMenuStrip = SortMenu = new BoxMenuStrip(this);
|
||||
SortMenu.Opening += (s, x) => x.Cancel = !tabBoxMulti.GetTabRect(tabBoxMulti.SelectedIndex).Contains(PointToClient(MousePosition));
|
||||
|
||||
M.OtherSlots.Add(this);
|
||||
SL_Extra.ViewIndex = -2;
|
||||
M.OtherSlots.Add(SL_Extra);
|
||||
}
|
||||
|
||||
private void InitializeDragDrop(Control pb)
|
||||
|
@ -391,7 +393,6 @@ namespace PKHeX.WinForms.Controls
|
|||
pb.BackColor = Color.Transparent;
|
||||
}
|
||||
|
||||
#region Box Manipulation
|
||||
private void ClickBoxSort(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (tabBoxMulti.SelectedTab != Tab_Box)
|
||||
|
@ -420,7 +421,6 @@ namespace PKHeX.WinForms.Controls
|
|||
SystemSounds.Asterisk.Play();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private void ClickBoxDouble(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (tabBoxMulti.SelectedTab == Tab_SAV)
|
||||
|
@ -686,21 +686,10 @@ namespace PKHeX.WinForms.Controls
|
|||
return false;
|
||||
|
||||
clearAll = dr == DialogResult.Yes;
|
||||
noSetb = GetPKMSetOverride();
|
||||
noSetb = GetPKMSetOverride(ModifyPKM);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool? GetPKMSetOverride()
|
||||
{
|
||||
var yn = ModifyPKM ? MsgYes : MsgNo;
|
||||
DialogResult noSet = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel,
|
||||
MsgSaveBoxImportModifyIntro,
|
||||
MsgSaveBoxImportModifyYes + Environment.NewLine +
|
||||
MsgSaveBoxImportModifyNo + Environment.NewLine +
|
||||
string.Format(MsgSaveBoxImportModifyCurrent, yn));
|
||||
return noSet == DialogResult.Yes || noSet == DialogResult.No ? (bool?)false : null;
|
||||
}
|
||||
|
||||
private static bool IsFolderPath(out string path)
|
||||
{
|
||||
FolderBrowserDialog fbd = new FolderBrowserDialog();
|
||||
|
@ -730,8 +719,6 @@ namespace PKHeX.WinForms.Controls
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool IsPCBoxBin(int length) => PKX.IsPKM(length / SAV.SlotCount) || PKX.IsPKM(length / SAV.BoxSlotCount);
|
||||
|
||||
public bool OpenPCBoxBin(byte[] input, out string c)
|
||||
{
|
||||
if (SAV.PCBinary.Length == input.Length)
|
||||
|
@ -778,7 +765,7 @@ namespace PKHeX.WinForms.Controls
|
|||
return false;
|
||||
}
|
||||
|
||||
bool? noSetb = GetPKMSetOverride();
|
||||
bool? noSetb = GetPKMSetOverride(ModifyPKM);
|
||||
PKM[] data = b.BattlePKMs;
|
||||
int offset = SAV.GetBoxOffset(Box.CurrentBox);
|
||||
int slotSkipped = 0;
|
||||
|
@ -1053,43 +1040,28 @@ namespace PKHeX.WinForms.Controls
|
|||
}
|
||||
}
|
||||
|
||||
public void ClickShowdownExportParty(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var str = ShowdownSet.GetShowdownSets(SAV.PartyData, Environment.NewLine + Environment.NewLine);
|
||||
if (string.IsNullOrWhiteSpace(str)) return;
|
||||
Clipboard.SetText(str);
|
||||
}
|
||||
catch { }
|
||||
WinFormsUtil.Alert(MsgSimulatorExportParty);
|
||||
}
|
||||
|
||||
public void ClickShowdownExportBattleBox(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var str = ShowdownSet.GetShowdownSets(SAV.BattleBoxData, Environment.NewLine + Environment.NewLine);
|
||||
if (string.IsNullOrWhiteSpace(str)) return;
|
||||
Clipboard.SetText(str);
|
||||
}
|
||||
catch { }
|
||||
WinFormsUtil.Alert(MsgSimulatorExportBattleBox);
|
||||
}
|
||||
public void ClickShowdownExportParty(object sender, EventArgs e) => ExportShowdownText(SAV, MsgSimulatorExportParty, sav => sav.PartyData);
|
||||
public void ClickShowdownExportBattleBox(object sender, EventArgs e) => ExportShowdownText(SAV, MsgSimulatorExportBattleBox, sav => sav.BattleBoxData);
|
||||
|
||||
public void ClickShowdownExportCurrentBox(object sender, EventArgs e)
|
||||
{
|
||||
if (!SAV.HasBox)
|
||||
return;
|
||||
ExportShowdownText(SAV, MsgSimulatorExportList,
|
||||
sav => (ModifierKeys & Keys.Control) != 0 ? sav.BoxData : sav.GetBoxData(CurrentBox));
|
||||
}
|
||||
|
||||
private static void ExportShowdownText(SaveFile SAV, string success, Func<SaveFile, IEnumerable<PKM>> func)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = (ModifierKeys & Keys.Control) != 0 ? SAV.BoxData : SAV.GetBoxData(CurrentBox);
|
||||
var str = ShowdownSet.GetShowdownSets(data, Environment.NewLine + Environment.NewLine);
|
||||
var pkms = func(SAV);
|
||||
var str = ShowdownSet.GetShowdownSets(pkms, Environment.NewLine + Environment.NewLine);
|
||||
if (string.IsNullOrWhiteSpace(str)) return;
|
||||
Clipboard.SetText(str);
|
||||
}
|
||||
catch { }
|
||||
WinFormsUtil.Alert(MsgSimulatorExportList);
|
||||
WinFormsUtil.Alert(success);
|
||||
}
|
||||
|
||||
private void B_OpenUGSEditor_Click(object sender, EventArgs e)
|
||||
|
@ -1116,8 +1088,24 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
private void GenerateLivingDex()
|
||||
{
|
||||
var bd = SAV.BoxData;
|
||||
SAV.BoxData = GetLivingDex(SAV);
|
||||
ReloadSlots();
|
||||
}
|
||||
|
||||
private static bool? GetPKMSetOverride(bool currentSetting)
|
||||
{
|
||||
var yn = currentSetting ? MsgYes : MsgNo;
|
||||
DialogResult noSet = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel,
|
||||
MsgSaveBoxImportModifyIntro,
|
||||
MsgSaveBoxImportModifyYes + Environment.NewLine +
|
||||
MsgSaveBoxImportModifyNo + Environment.NewLine +
|
||||
string.Format(MsgSaveBoxImportModifyCurrent, yn));
|
||||
return noSet == DialogResult.Yes || noSet == DialogResult.No ? (bool?)false : null;
|
||||
}
|
||||
|
||||
private static IList<PKM> GetLivingDex(SaveFile SAV)
|
||||
{
|
||||
var bd = SAV.BoxData;
|
||||
var tr = SAV;
|
||||
for (int i = 1; i <= 807; i++)
|
||||
{
|
||||
|
@ -1130,8 +1118,7 @@ namespace PKHeX.WinForms.Controls
|
|||
if (f != null)
|
||||
bd[i] = PKMConverter.ConvertToType(f, SAV.PKMType, out _);
|
||||
}
|
||||
SAV.BoxData = bd;
|
||||
ReloadSlots();
|
||||
return bd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -804,26 +804,14 @@ namespace PKHeX.WinForms
|
|||
if (sav.Generation == 3 && (sav.IndeterminateGame || ModifierKeys == Keys.Control))
|
||||
{
|
||||
WinFormsUtil.Alert(string.Format(MsgFileLoadVersionDetect, sav.Generation), MsgFileLoadVersionSelect);
|
||||
var g = new[] {GameVersion.R, GameVersion.S, GameVersion.E, GameVersion.FR, GameVersion.LG};
|
||||
var games = g.Select(z => GameInfo.VersionDataSource.First(v => v.Value == (int) z));
|
||||
var g = new[] { GameVersion.R, GameVersion.S, GameVersion.E, GameVersion.FR, GameVersion.LG };
|
||||
var games = g.Select(z => GameInfo.VersionDataSource.First(v => v.Value == (int)z));
|
||||
var dialog = new SAV_GameSelect(games);
|
||||
dialog.ShowDialog();
|
||||
|
||||
switch (dialog.Result) // Reset save file info
|
||||
{
|
||||
case GameVersion.R:
|
||||
case GameVersion.S:
|
||||
sav = new SAV3(sav.BAK, GameVersion.RS);
|
||||
break;
|
||||
case GameVersion.E:
|
||||
sav = new SAV3(sav.BAK, GameVersion.E);
|
||||
break;
|
||||
case GameVersion.FR:
|
||||
case GameVersion.LG:
|
||||
sav = new SAV3(sav.BAK, GameVersion.FRLG);
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
sav = SaveUtil.GetG3SaveOverride(sav, dialog.Result);
|
||||
if (sav == null)
|
||||
return false;
|
||||
if (sav.Version == GameVersion.FRLG)
|
||||
sav.Personal = dialog.Result == GameVersion.FR ? PersonalTable.FR : PersonalTable.LG;
|
||||
}
|
||||
|
@ -838,17 +826,10 @@ namespace PKHeX.WinForms
|
|||
var dialog = new SAV_GameSelect(games);
|
||||
dialog.ShowDialog();
|
||||
|
||||
switch (dialog.Result)
|
||||
{
|
||||
case GameVersion.FR:
|
||||
sav.Personal = PersonalTable.FR;
|
||||
break;
|
||||
case GameVersion.LG:
|
||||
sav.Personal = PersonalTable.LG;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
var pt = SaveUtil.GetG3Personal(dialog.Result);
|
||||
if (pt == null)
|
||||
return false;
|
||||
sav.Personal = pt;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue