Skip to content

Commit

Permalink
Merge remote-tracking branch 'PKHeX_original/master' into mycommits
Browse files Browse the repository at this point in the history
  • Loading branch information
JortonMV committed Feb 17, 2017
2 parents e22901f + 139d081 commit bd82af8
Show file tree
Hide file tree
Showing 25 changed files with 288 additions and 178 deletions.
1 change: 1 addition & 0 deletions PKHeX.WinForms/MainWindow/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 34 additions & 11 deletions PKHeX.WinForms/MainWindow/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,9 @@ private void openQuick(string path, bool force = false)
string ext = Path.GetExtension(path);
FileInfo fi = new FileInfo(path);
if (fi.Length > 0x10009C && fi.Length != 0x380000)
WinFormsUtil.Error("Input file is too large.", path);
WinFormsUtil.Error("Input file is too large." + Environment.NewLine + $"Size: {fi.Length} bytes", path);
else if (fi.Length < 32)
WinFormsUtil.Error("Input file is too small." + Environment.NewLine + $"Size: {fi.Length} bytes", path);
else
{
byte[] input; try { input = File.ReadAllBytes(path); }
Expand Down Expand Up @@ -1940,8 +1942,12 @@ private void clickMetLocation(object sender, EventArgs e)
return;

pkm = preparePKM();
updateLegality();
if (Legality.Valid)
return;

var encounter = Legality.getSuggestedMetInfo();
if (encounter == null || encounter.Location < 0)
if (encounter == null || (pkm.Format >= 3 && encounter.Location < 0))
{
WinFormsUtil.Alert("Unable to provide a suggestion.");
return;
Expand All @@ -1950,21 +1956,37 @@ private void clickMetLocation(object sender, EventArgs e)
int level = encounter.Level;
int location = encounter.Location;
int minlvl = Legal.getLowestLevel(pkm, encounter.Species);

if (pkm.Met_Level == level && pkm.Met_Location == location && pkm.CurrentLevel >= minlvl)
if (minlvl == 0)
minlvl = level;

if (pkm.CurrentLevel >= minlvl && pkm.Met_Level == level && pkm.Met_Location == location)
return;
if (minlvl < level)
minlvl = level;

var met_list = GameInfo.getLocationList((GameVersion)pkm.Version, SAV.Generation, egg: false);
var locstr = met_list.FirstOrDefault(loc => loc.Value == location)?.Text;
string suggestion = $"Suggested:\nMet Location: {locstr}\nMet Level: {level}";
var suggestion = new List<string> {"Suggested:"};
if (pkm.Format >= 3)
{
var met_list = GameInfo.getLocationList((GameVersion)pkm.Version, SAV.Generation, egg: false);
var locstr = met_list.FirstOrDefault(loc => loc.Value == location)?.Text;
suggestion.Add($"Met Location: {locstr}");
suggestion.Add($"Met Level: {level}");
}
if (pkm.CurrentLevel < minlvl)
suggestion += $"\nCurrent Level {minlvl}";
suggestion.Add($"Current Level: {minlvl}");

if (suggestion.Count == 1) // no suggestion
return;

if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, suggestion) != DialogResult.Yes)
string suggest = string.Join(Environment.NewLine, suggestion);
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, suggest) != DialogResult.Yes)
return;

TB_MetLevel.Text = level.ToString();
CB_MetLocation.SelectedValue = location;
if (pkm.Format >= 3)
{
TB_MetLevel.Text = level.ToString();
CB_MetLocation.SelectedValue = location;
}

if (pkm.CurrentLevel < minlvl)
TB_Level.Text = minlvl.ToString();
Expand Down Expand Up @@ -3825,6 +3847,7 @@ private void loadBoxesFromDB(string path)
bool? noSetb = getPKMSetOverride();

SAV.loadBoxes(path, out result, CB_BoxSelect.SelectedIndex, clearAll, noSetb);
setPKXBoxes();
WinFormsUtil.Alert(result);
}
private void B_SaveBoxBin_Click(object sender, EventArgs e)
Expand Down
89 changes: 58 additions & 31 deletions PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ private void getTextBoxes()
NUD_SMStreak2.Value = Math.Min(NUD_SMStreak2.Maximum, SAV.getTreeStreak(2, super: true, max: true));

CB_SkinColor.SelectedIndex = SAV.DressUpSkinColor;
TB_PlazaName.Text = SAV.FestivalPlazaName;
}
private void save()
{
Expand Down Expand Up @@ -262,6 +263,8 @@ private void save()
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;
}

private void clickOT(object sender, MouseEventArgs e)
Expand Down
Loading

0 comments on commit bd82af8

Please sign in to comment.