mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Block parties without battleable pkms
#1257 not perfect but less restrictive, probably more obvious.
This commit is contained in:
parent
9efd49b0bc
commit
e697a9edc7
3 changed files with 37 additions and 15 deletions
|
@ -330,6 +330,14 @@ namespace PKHeX.Core
|
||||||
public int SlotCount => BoxCount * BoxSlotCount;
|
public int SlotCount => BoxCount * BoxSlotCount;
|
||||||
public virtual int PartyCount { get; protected set; }
|
public virtual int PartyCount { get; protected set; }
|
||||||
public virtual int MultiplayerSpriteID { get => 0; set { } }
|
public virtual int MultiplayerSpriteID { get => 0; set { } }
|
||||||
|
public bool IsPartyAllEggs(params int[] except)
|
||||||
|
{
|
||||||
|
if (!HasParty)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var party = PartyData;
|
||||||
|
return party.Length == party.Where((t, i) => t.IsEgg || except.Contains(i)).Count();
|
||||||
|
}
|
||||||
|
|
||||||
// Varied Methods
|
// Varied Methods
|
||||||
protected abstract void SetChecksums();
|
protected abstract void SetChecksums();
|
||||||
|
|
|
@ -44,10 +44,10 @@ namespace PKHeX.WinForms.Controls
|
||||||
|
|
||||||
var editor = m.SE.PKME_Tabs;
|
var editor = m.SE.PKME_Tabs;
|
||||||
var sav = m.SE.SAV;
|
var sav = m.SE.SAV;
|
||||||
if (info.Slot == 30 && editor.IsEmptyOrEgg)
|
if (info.IsParty && editor.IsEmptyOrEgg && sav.IsPartyAllEggs(info.Slot - 30) && !m.SE.HaX)
|
||||||
{ WinFormsUtil.Alert("Can't have empty/egg first info.Slot."); return; }
|
{ WinFormsUtil.Alert("Can't have empty/egg party."); return; }
|
||||||
if (m.SE.SAV.IsSlotLocked(info.Box, info.Slot))
|
if (m.SE.SAV.IsSlotLocked(info.Box, info.Slot))
|
||||||
{ WinFormsUtil.Alert("Can't set to locked info.Slot."); return; }
|
{ WinFormsUtil.Alert("Can't set to locked slot."); return; }
|
||||||
|
|
||||||
PKM pk = editor.PreparePKM();
|
PKM pk = editor.PreparePKM();
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ namespace PKHeX.WinForms.Controls
|
||||||
{ System.Media.SystemSounds.Asterisk.Play(); return; }
|
{ System.Media.SystemSounds.Asterisk.Play(); return; }
|
||||||
|
|
||||||
var sav = m.SE.SAV;
|
var sav = m.SE.SAV;
|
||||||
if (info.Slot == 30 && sav.PartyCount == 1 && !m.SE.HaX)
|
if (info.IsParty && sav.IsPartyAllEggs(info.Slot - 30) && !m.SE.HaX)
|
||||||
{ WinFormsUtil.Alert("Can't delete first slot."); return; }
|
{ WinFormsUtil.Alert("Can't delete this slot."); return; }
|
||||||
if (sav.IsSlotLocked(info.Box, info.Slot))
|
if (sav.IsSlotLocked(info.Box, info.Slot))
|
||||||
{ WinFormsUtil.Alert("Can't delete locked slot."); return; }
|
{ WinFormsUtil.Alert("Can't delete locked slot."); return; }
|
||||||
|
|
||||||
|
|
|
@ -200,22 +200,31 @@ namespace PKHeX.WinForms.Controls
|
||||||
}
|
}
|
||||||
if (SAV.IsSlotLocked(DragInfo.Destination.Box, DragInfo.Destination.Slot))
|
if (SAV.IsSlotLocked(DragInfo.Destination.Box, DragInfo.Destination.Slot))
|
||||||
{
|
{
|
||||||
DragInfo.Destination.Slot = -1; // Invalidate
|
AlertInvalidate("Unable to set to locked slot.");
|
||||||
WinFormsUtil.Alert("Unable to set to locked slot.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool noEgg = DragInfo.Destination.IsParty && SE.SAV.IsPartyAllEggs(DragInfo.Destination.Slot - 30) && !SE.HaX;
|
||||||
if (DragInfo.Source.Offset < 0) // external source
|
if (DragInfo.Source.Offset < 0) // external source
|
||||||
{
|
{
|
||||||
TryLoadFiles(files, e);
|
if (!TryLoadFiles(files, e, noEgg))
|
||||||
|
AlertInvalidate("Unable to set to this slot.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!TrySetPKMDestination(sender, e, overwrite, clone, noEgg))
|
||||||
|
{
|
||||||
|
AlertInvalidate("Unable to set to this slot.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrySetPKMDestination(sender, e, overwrite, clone);
|
|
||||||
|
|
||||||
if (DragInfo.Source.Parent == null) // internal file
|
if (DragInfo.Source.Parent == null) // internal file
|
||||||
DragInfo.Reset();
|
DragInfo.Reset();
|
||||||
}
|
}
|
||||||
private bool TryLoadFiles(string[] files, DragEventArgs e)
|
private void AlertInvalidate(string msg)
|
||||||
|
{
|
||||||
|
DragInfo.Destination.Slot = -1; // Invalidate
|
||||||
|
WinFormsUtil.Alert(msg);
|
||||||
|
}
|
||||||
|
private bool TryLoadFiles(string[] files, DragEventArgs e, bool noEgg)
|
||||||
{
|
{
|
||||||
if (files.Length <= 0)
|
if (files.Length <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -240,6 +249,9 @@ namespace PKHeX.WinForms.Controls
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (noEgg && (pk.Species == 0 || pk.IsEgg))
|
||||||
|
return false;
|
||||||
|
|
||||||
string[] errata = SAV.IsPKMCompatible(pk);
|
string[] errata = SAV.IsPKMCompatible(pk);
|
||||||
if (errata.Length > 0)
|
if (errata.Length > 0)
|
||||||
{
|
{
|
||||||
|
@ -256,19 +268,21 @@ namespace PKHeX.WinForms.Controls
|
||||||
Console.WriteLine(c);
|
Console.WriteLine(c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool TrySetPKMDestination(object sender, DragEventArgs e, bool overwrite, bool clone)
|
private bool TrySetPKMDestination(object sender, DragEventArgs e, bool overwrite, bool clone, bool noEgg)
|
||||||
{
|
{
|
||||||
PKM pkz = GetPKM(true);
|
PKM pkz = GetPKM(true);
|
||||||
bool result = false;
|
if (noEgg && (pkz.Species == 0 || pkz.IsEgg))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (DragInfo.Source.IsValid)
|
if (DragInfo.Source.IsValid)
|
||||||
result = TrySetPKMSource(sender, overwrite, clone);
|
TrySetPKMSource(sender, overwrite, clone);
|
||||||
|
|
||||||
// Copy from temp to destination slot.
|
// Copy from temp to destination slot.
|
||||||
SetPKM(pkz, false, null);
|
SetPKM(pkz, false, null);
|
||||||
|
|
||||||
e.Effect = clone ? DragDropEffects.Copy : DragDropEffects.Link;
|
e.Effect = clone ? DragDropEffects.Copy : DragDropEffects.Link;
|
||||||
SetCursor(SE.GetDefaultCursor, sender);
|
SetCursor(SE.GetDefaultCursor, sender);
|
||||||
return result;
|
return true;
|
||||||
}
|
}
|
||||||
private bool TrySetPKMSource(object sender, bool overwrite, bool clone)
|
private bool TrySetPKMSource(object sender, bool overwrite, bool clone)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue