Disable Map Editing on failure to show map

Lumiose City's odd coordinate format can't be properly kept by the
NumericUpDowns; disabled in the case where coordinates are irregular
(%.5!=0).
This commit is contained in:
Kaphotics
2016-01-20 21:08:33 -08:00
parent a8a89c3bb2
commit 17b2e4ea30

View File

@@ -36,10 +36,10 @@ public SAV_Trainer()
GB_Appear.Visible = false;
}
editing = true;
GB_Map.Enabled = Main.ramsav == null;
getComboBoxes();
getTextBoxes();
getBadges();
GB_Map.Enabled = Main.ramsav == null;
statdata = new[] {
"0x000", "0x000", // Steps taken?
@@ -392,9 +392,16 @@ private void getTextBoxes()
MaisonRecords[i].Text = SAV.getMaisonStat(i).ToString();
NUD_M.Value = SAV.M;
NUD_X.Value = (decimal)SAV.X;
NUD_Z.Value = (decimal)SAV.Z;
NUD_Y.Value = (decimal)SAV.Y;
// Sanity Check Map Coordinates
if (!GB_Map.Enabled || SAV.X%0.5 != 0 || SAV.Z%0.5 != 0 || SAV.Y%0.5 != 0)
GB_Map.Enabled = false;
else try
{
NUD_X.Value = (decimal)SAV.X;
NUD_Z.Value = (decimal)SAV.Z;
NUD_Y.Value = (decimal)SAV.Y;
}
catch { GB_Map.Enabled = false; }
// Load BP and PokeMiles
TB_BP.Text = SAV.BP.ToString();
@@ -468,10 +475,13 @@ private void save()
SAV.setMaisonStat(i, UInt16.Parse(MaisonRecords[i].Text));
// Copy Position
SAV.M = (int)NUD_M.Value;
SAV.X = (float)NUD_X.Value;
SAV.Z = (float)NUD_Z.Value;
SAV.Y = (float)NUD_Y.Value;
if (GB_Map.Enabled)
{
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 = UInt16.Parse(TB_BP.Text);
// Set Current PokéMiles