Merge pull request #2 from kwsch/master

Merge latest changes to fork
This commit is contained in:
Evan Dixon 2016-07-31 16:24:45 -05:00 committed by GitHub
commit 86134f4cd5
19 changed files with 119 additions and 69 deletions

View file

@ -86,7 +86,7 @@ namespace PKHeX
// Box to Tabs D&D
dragout.AllowDrop = true;
FLP_SAVtools.Scroll += Util.FlowLayoutPanelScroll;
FLP_SAVtools.Scroll += Util.PanelScroll;
// Load WC6 folder to legality
refreshWC6DB();
@ -707,14 +707,14 @@ namespace PKHeX
else
sav = new SAV3(sav.Data, GameVersion.FRLG);
}
var drJP = Util.Prompt(MessageBoxButtons.YesNoCancel, $"Generation {sav.Generation} Save File detected. Select Origins:", "Yes: International" + Environment.NewLine + "No: Japanese");
var drJP = Util.Prompt(MessageBoxButtons.YesNoCancel, $"Generation 3 ({sav.Version}) Save File detected. Select Origins:", "Yes: International" + Environment.NewLine + "No: Japanese");
if (drJP == DialogResult.Cancel)
return;
sav.Japanese = drJP == DialogResult.No;
if (sav.Version == GameVersion.FRLG)
{
var drFRLG = Util.Prompt(MessageBoxButtons.YesNoCancel, "FRLG Detected. Select version...", "Yes: FireRed" + Environment.NewLine + "No: LeafGreen");
var drFRLG = Util.Prompt(MessageBoxButtons.YesNoCancel, $"{sav.Version} detected. Select version...", "Yes: FireRed" + Environment.NewLine + "No: LeafGreen");
if (drFRLG == DialogResult.Cancel)
return;
@ -1070,15 +1070,15 @@ namespace PKHeX
items = g3items;
ItemDataSource = Util.getCBList(items, (HaX ? Enumerable.Range(0, SAV.MaxItemID) : SAV.HeldItems.Select(i => (int)i)).ToArray());
CB_HeldItem.DataSource = new BindingSource(ItemDataSource.Where(i => i.Value <= SAV.MaxItemID), null);
CB_HeldItem.DataSource = new BindingSource(ItemDataSource.Where(i => i.Value <= SAV.MaxItemID).ToList(), null);
CB_Ball.DataSource = new BindingSource(BallDataSource.Where(b => b.Value <= SAV.MaxBallID), null);
CB_Species.DataSource = new BindingSource(SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID), null);
DEV_Ability.DataSource = new BindingSource(AbilityDataSource.Where(a => a.Value <= SAV.MaxAbilityID), null);
CB_GameOrigin.DataSource = new BindingSource(VersionDataSource.Where(g => g.Value <= SAV.MaxGameID || SAV.Generation >= 3 && g.Value == 15), null);
CB_Ball.DataSource = new BindingSource(BallDataSource.Where(b => b.Value <= SAV.MaxBallID).ToList(), null);
CB_Species.DataSource = new BindingSource(SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID).ToList(), null);
DEV_Ability.DataSource = new BindingSource(AbilityDataSource.Where(a => a.Value <= SAV.MaxAbilityID).ToList(), null);
CB_GameOrigin.DataSource = new BindingSource(VersionDataSource.Where(g => g.Value <= SAV.MaxGameID || SAV.Generation >= 3 && g.Value == 15).ToList(), null);
// Set the Move ComboBoxes too..
var moves = MoveDataSource.Where(m => m.Value <= SAV.MaxMoveID).ToArray();
var moves = MoveDataSource.Where(m => m.Value <= SAV.MaxMoveID).ToList();
foreach (ComboBox cb in new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4, CB_RelearnMove1, CB_RelearnMove2, CB_RelearnMove3, CB_RelearnMove4 })
{
cb.DisplayMember = "Text"; cb.ValueMember = "Value";
@ -1283,7 +1283,7 @@ namespace PKHeX
{
pkm.Species = Util.getIndex(CB_Species);
pkm.Version = Util.getIndex(CB_GameOrigin);
pkm.Nature = CB_Nature.SelectedIndex;
pkm.Nature = Util.getIndex(CB_Nature);
pkm.AltForm = CB_Form.SelectedIndex;
pkm.setPIDGender(newGender);
@ -1450,7 +1450,8 @@ namespace PKHeX
TB_EXP.Text = PKX.getEXP(Level, Util.getIndex(CB_Species)).ToString();
}
changingFields = false;
pkm.EXP = Util.ToUInt32(TB_EXP.Text);
if (fieldsLoaded)
pkm.EXP = Util.ToUInt32(TB_EXP.Text);
updateStats();
updateLegality();
}
@ -1591,22 +1592,24 @@ namespace PKHeX
}
private void updateRandomPID(object sender, EventArgs e)
{
int origin = Util.getIndex(CB_GameOrigin);
uint PID = PKX.getRandomPID(Util.getIndex(CB_Species), PKX.getGender(Label_Gender.Text), origin, Util.getIndex(CB_Nature), CB_Form.SelectedIndex);
TB_PID.Text = PID.ToString("X8");
if (fieldsLoaded)
{
pkm.Version = Util.getIndex(CB_GameOrigin);
pkm.PID = Util.getHEXval(TB_PID.Text);
pkm.Species = Util.getIndex(CB_Species);
pkm.Nature = Util.getIndex(CB_Nature);
pkm.AltForm = CB_Form.SelectedIndex;
}
if (sender == Label_Gender)
pkm.setPIDGender(pkm.Gender);
else if (sender == CB_Nature && pkm.Nature != Util.getIndex(CB_Nature))
pkm.setPIDNature(Util.getIndex(CB_Nature));
else if (sender == BTN_RerollPID)
pkm.setPIDGender(pkm.Gender);
TB_PID.Text = pkm.PID.ToString("X8");
getQuickFiller(dragout);
if (origin >= 24)
return;
// Before Gen6, EC and PID are related
// Ensure we don't have an illegal newshiny PID.
uint SID = Util.ToUInt32(TB_TID.Text);
uint TID = Util.ToUInt32(TB_TID.Text);
uint XOR = TID ^ SID ^ PID >> 16 ^ PID & 0xFFFF;
if (XOR >> 3 == 1) // Illegal
updateRandomPID(sender, e); // Get a new PID
TB_EC.Text = PID.ToString("X8");
if (pkm.Format >= 6)
TB_EC.Text = pkm.EncryptionConstant.ToString("X8");
}
private void updateRandomEC(object sender, EventArgs e)
{
@ -1973,9 +1976,6 @@ namespace PKHeX
incr != decr
? $"+{labarray[incr].Text} / -{labarray[decr].Text}".Replace(":", "")
: "-/-");
if (fieldsLoaded && SAV.Generation <= 4)
updateRandomPID(sender, e);
}
private void updateNickname(object sender, EventArgs e)
{
@ -2118,10 +2118,14 @@ namespace PKHeX
getQuickFiller(dragout);
updateIVs(null, null); // If the EC is changed, EC%6 (Characteristic) might be changed.
TB_PID.Select(60, 0); // position cursor at end of field
if (SAV.Generation == 4 && fieldsInitialized)
if (SAV.Generation <= 4 && fieldsLoaded)
{
fieldsLoaded = false;
pkm.PID = Util.getHEXval(TB_PID.Text);
CB_Nature.SelectedValue = pkm.Nature;
Label_Gender.Text = gendersymbols[pkm.Gender];
Label_Gender.ForeColor = pkm.Gender == 2 ? Label_Species.ForeColor : (pkm.Gender == 1 ? Color.Red : Color.Blue);
fieldsLoaded = true;
}
}
private void validateComboBox(object sender)
@ -2152,8 +2156,8 @@ namespace PKHeX
validateComboBox(sender, e);
if (sender == CB_Ability)
TB_AbilityNumber.Text = (1 << CB_Ability.SelectedIndex).ToString();
if (fieldsInitialized && sender == CB_Nature && SAV.Generation == 4)
BTN_RerollPID.PerformClick();
if (fieldsLoaded && sender == CB_Nature && SAV.Generation <= 4)
updateRandomPID(sender, e);
updateNatureModification(sender, null);
updateIVs(null, null); // updating Nature will trigger stats to update as well
}
@ -3247,8 +3251,11 @@ namespace PKHeX
if (Directory.Exists(pathCache))
return Directory.GetFiles(pathCache).Where(f => SaveUtil.SizeValidSAV6((int)new FileInfo(f).Length)) // filter
.OrderByDescending(f => new FileInfo(f).LastWriteTime).FirstOrDefault();
if (File.Exists(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main")))) // if cgse exists
return Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main"));
try
{
if (File.Exists(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main")))) // if cgse exists
return Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root", "main"));
} catch { }
return null;
}
@ -3337,6 +3344,7 @@ namespace PKHeX
}
else
{
PKM pkz = SAV.getStoredSlot(pkm_from_offset);
if (ModifierKeys == Keys.Alt && slot > -1) // overwrite delete old slot
{
// Clear from slot
@ -3355,8 +3363,7 @@ namespace PKHeX
SAV.setStoredSlot(pk, pkm_from_offset);
}
// Copy from temp slot to new.
SAV.setStoredSlot(pkm_from, offset);
PKM pkz = SAV.getPKM(SAV.decryptPKM(pkm_from));
SAV.setStoredSlot(pkz, offset);
getQuickFiller(SlotPictureBoxes[slot], pkz);
pkm_from_offset = 0; // Clear offset value

View file

@ -18,7 +18,7 @@ namespace PKHeX
{
Data = Data.Skip(SizeFull - Size).ToArray();
DateTime now = DateTime.Now;
Year = (uint)(now.Year - 2000);
Year = (uint)now.Year;
Month = (uint)now.Month;
Day = (uint)now.Day;
}

View file

@ -329,16 +329,17 @@ namespace PKHeX
public void setShinyPID()
{
while (!IsShiny)
PID = PKX.getRandomPID(Species, Gender, Version, Nature, AltForm);
do PID = PKX.getRandomPID(Species, Gender, Version, Nature, AltForm, PID); while (!IsShiny);
EncryptionConstant = PID;
}
public void setPIDGender(int gender)
{
PID = PKX.getRandomPID(Species, gender, Version, Nature, AltForm);
while (IsShiny)
PID = PKX.getRandomPID(Species, gender, Version, Nature, AltForm);
do PID = PKX.getRandomPID(Species, gender, Version, Nature, AltForm, PID); while (IsShiny);
EncryptionConstant = PID;
}
public void setPIDNature(int nature)
{
do PID = PKX.getRandomPID(Species, Gender, Version, nature, AltForm, PID); while (IsShiny);
EncryptionConstant = PID;
}
}

View file

@ -419,8 +419,9 @@ namespace PKHeX
return chk;
}
internal static uint getRandomPID(int species, int cg, int origin, int nature, int form)
internal static uint getRandomPID(int species, int cg, int origin, int nature, int form, uint OLDPID)
{
uint bits = OLDPID & 0x00010001;
int gt = Personal[species].Gender;
if (origin >= 24)
return Util.rnd32();
@ -441,6 +442,8 @@ namespace PKHeX
if (pidLetter != form)
continue;
}
else if (bits != (pid & 0x00010001)) // keep ability bits
continue;
// Gen 3/4/5: Gender derived from PID
uint gv = pid & 0xFF;

Binary file not shown.

Binary file not shown.

View file

@ -726,7 +726,7 @@ http://projectpokemon.org/forums/showthread.php?36986
- Hotfix: Fixed Gen 5 save file detection. Thanks xtreme1!
- Hotfix: Fixed Bad Eggs from causing past gen dumping to abort. Thanks xtreme1!
07/28/16 - New Update:
07/28/16 - New Update: (9500)
- Fixed: Base save file when no save is loaded now has more realistic data (Console Region and Country fixed).
- Fixed: Loading a X/Y save file will no longer have OR/AS exclusive items/moves/forms available as choices.
- Fixed: Certain edge case Wonder Cards now are recognized correctly.
@ -750,4 +750,16 @@ http://projectpokemon.org/forums/showthread.php?36986
- - "!": Requires the value to NOT match the specified value. If not, the PKM is skipped.
- - ".": Sets the attribute to the specified value if all filters are satisfied.
- Changed: Database can now search pk3/pk4/pk5/pk6 files.
- - An advance search option has been added, uses the same filter style as the Batch Editor.
- - An advance search option has been added, uses the same filter style as the Batch Editor.
07/30/16 - New Update:
- Added: Batch editor "Shinify" command to make a Pokemon shiny ($shiny). Thanks exegg!
- Changed: Ribbon editor is now wider (5 ribbons per row). Thanks \!
- Fixed: Gen 3/4 save issues. Thanks BeyondTheHorizon, poutros!
- Fixed: Event Flag editor saving no longer throws a cast exception. Thanks Armodillomatt12!
- Fixed: Importing PGT/PCD to future generations no longer errors out. Thanks SubMana!
- Fixed: Mystery Gift window import/export button text displayed. Thanks poutros!
- Fixed: Misc Pokémon Link legality cases fixed. Thanks poutros!
- Fixed: Misc linux issues with latest refactoring. Thanks Zekario!
- Fixed: Trainer Editor window ~ Unicode character display. Thanks \!
- Fixed: Minor main window editing bugs for EXP/Nature/Gender.

View file

@ -65,6 +65,18 @@ namespace PKHeX
if (Instructions.Any(z => string.IsNullOrWhiteSpace(z.PropertyValue)))
{ Util.Error("Empty Property Value detected."); return; }
string destPath = "";
if (RB_Path.Checked)
{
Util.Alert("Please select the folder where the files will be saved to.", "This can be the same folder as the source of PKM files.");
var fbd = new FolderBrowserDialog();
var dr = fbd.ShowDialog();
if (dr != DialogResult.OK)
return;
destPath = fbd.SelectedPath;
}
FLP_RB.Enabled = RTB_Instructions.Enabled = B_Go.Enabled = false;
b = new BackgroundWorker {WorkerReportsProgress = true};
@ -80,7 +92,7 @@ namespace PKHeX
{
var files = Directory.GetFiles(TB_Folder.Text, "*", SearchOption.AllDirectories);
setupProgressBar(files.Length);
processFolder(files, Filters, Instructions);
processFolder(files, Filters, Instructions, destPath);
}
};
b.ProgressChanged += (sender, e) =>
@ -161,7 +173,7 @@ namespace PKHeX
Main.SAV.BoxData = data;
}
private void processFolder(string[] files, List<StringInstruction> Filters, List<StringInstruction> Instructions)
private void processFolder(string[] files, List<StringInstruction> Filters, List<StringInstruction> Instructions, string destPath)
{
len = err = ctr = 0;
for (int i = 0; i < files.Length; i++)
@ -183,7 +195,7 @@ namespace PKHeX
if (r == ModifyResult.Modified)
{
ctr++;
File.WriteAllBytes(file, pkm.DecryptedBoxData);
File.WriteAllBytes(Path.Combine(destPath, Path.GetFileName(file)), pkm.DecryptedBoxData);
}
b.ReportProgress(i);
@ -251,6 +263,8 @@ namespace PKHeX
ReflectUtil.SetValue(PKM, cmd.PropertyName, Util.rnd32().ToString());
else if (cmd.PropertyValue == CONST_SHINY && cmd.PropertyName == "PID")
PKM.setShinyPID();
else if (cmd.PropertyValue == "0" && cmd.PropertyName == "Species")
PKM.Data = new byte[PKM.Data.Length];
else
ReflectUtil.SetValue(PKM, cmd.PropertyName, cmd.PropertyValue);

View file

@ -16,6 +16,8 @@ namespace PKHeX
// Updating a Control display with autosized elements on every row addition is cpu intensive. Disable layout updates while populating.
TLP_Ribbons.SuspendLayout();
FLP_Ribbons.Scroll += Util.PanelScroll;
TLP_Ribbons.Scroll += Util.PanelScroll;
populateRibbons();
Util.TranslateInterface(this, Main.curlanguage);
TLP_Ribbons.ResumeLayout();

View file

@ -16,6 +16,8 @@ namespace PKHeX
// Updating a Control display with autosized elements on every row addition is cpu intensive. Disable layout updates while populating.
TLP_SuperTrain.SuspendLayout();
TLP_DistSuperTrain.SuspendLayout();
TLP_SuperTrain.Scroll += Util.PanelScroll;
TLP_DistSuperTrain.Scroll += Util.PanelScroll;
populateRegimens("SuperTrain", TLP_SuperTrain, reglist);
populateRegimens("DistSuperTrain", TLP_DistSuperTrain, distlist);
Util.TranslateInterface(this, Main.curlanguage);

View file

@ -67,15 +67,16 @@ namespace PKHeX
CB_Species.DisplayMember = "Text";
CB_Species.ValueMember = "Value";
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Skip(1), null);
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Skip(1).Where(s => s.Value <= SAV.MaxSpeciesID).ToList(), null);
CB_Move1.DisplayMember = CB_Move2.DisplayMember = CB_Move3.DisplayMember = CB_Move4.DisplayMember = "Text";
CB_Move1.ValueMember = CB_Move2.ValueMember = CB_Move3.ValueMember = CB_Move4.ValueMember = "Value";
CB_Move1.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move2.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move3.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move4.DataSource = new BindingSource(Main.MoveDataSource, null);
var MoveList = Main.MoveDataSource.Where(m => m.Value <= SAV.MaxMoveID).ToList();
CB_Move1.DataSource = new BindingSource(MoveList, null);
CB_Move2.DataSource = new BindingSource(MoveList, null);
CB_Move3.DataSource = new BindingSource(MoveList, null);
CB_Move4.DataSource = new BindingSource(MoveList, null);
CB_HeldItem.DisplayMember = "Text";
CB_HeldItem.ValueMember = "Value";

View file

@ -23,7 +23,7 @@ namespace PKHeX
// Fill List
CB_Species.DisplayMember = "Text";
CB_Species.ValueMember = "Value";
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Skip(1), null);
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Skip(1).ToList(), null);
for (int i = 1; i < SAV.MaxSpeciesID + 1; i++)
LB_Species.Items.Add(i.ToString("000") + " - " + Main.specieslist[i]);

View file

@ -23,7 +23,7 @@ namespace PKHeX
// Fill List
CB_Species.DisplayMember = "Text";
CB_Species.ValueMember = "Value";
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Skip(1), null);
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Skip(1).ToList(), null);
for (int i = 1; i < SAV.MaxSpeciesID + 1; i++)
LB_Species.Items.Add(i.ToString("000") + " - " + Main.specieslist[i]);

View file

@ -35,19 +35,20 @@ namespace PKHeX
CB_Ball.DisplayMember = CB_HeldItem.DisplayMember = CB_Species.DisplayMember = CB_Nature.DisplayMember = "Text";
CB_Ball.ValueMember = CB_HeldItem.ValueMember = CB_Species.ValueMember = CB_Nature.ValueMember = "Value";
CB_Ball.DataSource = new BindingSource(Main.BallDataSource.Where(b => b.Value <= SAV.MaxBallID), null);
CB_HeldItem.DataSource = new BindingSource(Main.ItemDataSource, null);
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID), null);
CB_Ball.DataSource = new BindingSource(Main.BallDataSource.Where(b => b.Value <= SAV.MaxBallID).ToList(), null);
CB_HeldItem.DataSource = new BindingSource(Main.ItemDataSource.Where(i => i.Value < SAV.MaxItemID).ToList(), null);
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID).ToList(), null);
CB_Nature.DataSource = new BindingSource(Main.NatureDataSource, null);
CB_Move1.DisplayMember = CB_Move2.DisplayMember = CB_Move3.DisplayMember = CB_Move4.DisplayMember = "Text";
CB_Move1.ValueMember = CB_Move2.ValueMember = CB_Move3.ValueMember = CB_Move4.ValueMember = "Value";
CB_Move1.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move2.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move3.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move4.DataSource = new BindingSource(Main.MoveDataSource, null);
var MoveList = Main.MoveDataSource.Where(m => m.Value <= SAV.MaxMoveID).ToList();
CB_Move1.DataSource = new BindingSource(MoveList, null);
CB_Move2.DataSource = new BindingSource(MoveList, null);
CB_Move3.DataSource = new BindingSource(MoveList, null);
CB_Move4.DataSource = new BindingSource(MoveList, null);
}
// Repopulation Functions

View file

@ -35,11 +35,11 @@ namespace PKHeX
{
CB_Species.DisplayMember = "Text";
CB_Species.ValueMember = "Value";
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID), null);
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID).ToList(), null);
CB_S2.DisplayMember = "Text";
CB_S2.ValueMember = "Value";
CB_S2.DataSource = new BindingSource(Main.SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID), null);
CB_S2.DataSource = new BindingSource(Main.SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID).ToList(), null);
}
listBox1.SelectedIndex = 0;
fillTrainingBags();

View file

@ -18,6 +18,9 @@ namespace PKHeX
Util.TranslateInterface(this, Main.curlanguage);
B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999";
CB_Gender.Items.Clear();
CB_Gender.Items.AddRange(Main.gendersymbols.Take(2).ToArray()); // m/f depending on unicode selection
MaisonRecords = new[]
{
TB_MCSN,TB_MCSS,TB_MBSN,TB_MBSS,

View file

@ -24,9 +24,10 @@ namespace PKHeX
CB_Stats.Items.Add(i.ToString());
TLP_Flags.SuspendLayout();
TLP_Flags.Controls.Clear();
TLP_Const.SuspendLayout();
TLP_Flags.Scroll += Util.PanelScroll;
TLP_Const.Scroll += Util.PanelScroll;
TLP_Flags.Controls.Clear();
TLP_Const.Controls.Clear();
addFlagList(getStringList("flags"));
addConstList(getStringList("const"));

View file

@ -15,6 +15,9 @@ namespace PKHeX
TB_OTName.MaxLength = SAV.OTLength;
B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999";
CB_Gender.Items.Clear();
CB_Gender.Items.AddRange(Main.gendersymbols.Take(2).ToArray()); // m/f depending on unicode selection
TB_OTName.Text = SAV.OT;
CB_Gender.SelectedIndex = SAV.Gender;
MT_TID.Text = SAV.TID.ToString("00000");

View file

@ -139,9 +139,9 @@ namespace PKHeX
return (int)(cb?.SelectedValue ?? 0);
}
public static void FlowLayoutPanelScroll(object sender, ScrollEventArgs e)
public static void PanelScroll(object sender, ScrollEventArgs e)
{
var p = sender as FlowLayoutPanel;
var p = sender as Panel;
switch (e.ScrollOrientation)
{
case ScrollOrientation.HorizontalScroll: