Improve slot lock detection

Uses sm lock indication (same placement), now only appears for teams
that are locked
slots that are not locked but assigned to a team are now indicated as
such, no prevention / moving to adjust team values is done.
#661
This commit is contained in:
Kurt 2016-12-26 16:41:12 -08:00
parent 93cc7472da
commit 750044ea31
9 changed files with 78 additions and 24 deletions

View file

@ -3768,8 +3768,11 @@ namespace PKHeX
var sprite = pk.Species != 0 ? pk.Sprite : null;
int slot = getSlot(pb);
bool locked = slot < 30 && SAV.getIsSlotLocked(CB_BoxSelect.SelectedIndex, slot);
bool team = slot < 30 && SAV.getIsTeamSet(CB_BoxSelect.SelectedIndex, slot);
if (locked)
sprite = Util.LayerImage(sprite, Properties.Resources.locked, 5, 0, 1);
sprite = Util.LayerImage(sprite, Properties.Resources.locked, 26, 0, 1);
else if (team)
sprite = Util.LayerImage(sprite, Properties.Resources.team, 21, 0, 1);
pb.Image = sprite;
if (pb.BackColor == Color.Red)
pb.BackColor = Color.Transparent;
@ -3798,8 +3801,11 @@ namespace PKHeX
var sprite = p.Species != 0 ? p.Sprite : null;
int slot = getSlot(pb);
bool locked = slot < 30 && SAV.getIsSlotLocked(CB_BoxSelect.SelectedIndex, slot);
bool team = slot < 30 && SAV.getIsTeamSet(CB_BoxSelect.SelectedIndex, slot);
if (locked)
sprite = Util.LayerImage(sprite, Properties.Resources.locked, 5, 0, 1);
sprite = Util.LayerImage(sprite, Properties.Resources.locked, 26, 0, 1);
else if (team)
sprite = Util.LayerImage(sprite, Properties.Resources.team, 21, 0, 1);
pb.Image = sprite;
pb.BackColor = Color.Transparent;
pb.Visible = true;

View file

@ -3779,6 +3779,9 @@
<ItemGroup>
<None Include="Resources\img\ribbons\ribbonbattletreemaster.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\img\misc\team.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -12302,16 +12302,15 @@ namespace PKHeX.Properties {
/// <summary>
/// Looks up a localized string similar to PKHeX - By Kaphotics
///http://projectpokemon.org/
///http://projectpokemon.org/forums/showthread.php?36986
///http://projectpokemon.org/pkhex
///
///11/18/16 - New Update:
/// - Added: Sun/Moon Support
/// - - Initial legality checking. Postgame encounters (Scan/Poke Pelago/etc) unsupported at this time.
/// - - QR Exporting for use with custom firmware patched code.
/// - - Trainer Editor and limited Pokedex editor
/// - Added: KChart, a personal info (base stats) viewer. Hold Shift when opening the PKM Database from the Tools drop-down.
/// - Added: Legal mo [rest of string was truncated]&quot;;.
///16/12/21 - New Update:
/// - Legality: Fine tuned problematic cases (Island Scan, SOS slots, Ash Greninja, result descriptions).
/// - Added: Battle Box slot indication and edit prevention for Generation 7 save files.
/// - Added: Party Drag&amp;Drop
/// - Added: Zygarde Core stored count; also improved subform &quot;Collect All&quot; button method.
/// - Added: Pokédex forme editing (Gen7).
/// - Added: Advanced randomization for Batch Editor. Syntax: $x,y to have a random va [rest of string was truncated]&quot;;.
/// </summary>
internal static string changelog {
get {
@ -12611,7 +12610,8 @@ namespace PKHeX.Properties {
/// Looks up a localized string similar to 3100 Is Alolan Champion + Magearna Event Active
///3487 Received Magearna Gift
///1216 Received Gift Cosmog
///0499 Received Gift Type:Null.
///0499 Received Gift Type:Null
///0160 Moone[0] / Sunne Portal [1].
/// </summary>
internal static string flags_sm {
get {
@ -17952,7 +17952,7 @@ namespace PKHeX.Properties {
}
/// <summary>
/// Looks up a localized string similar to 20161118.
/// Looks up a localized string similar to 20161221.
/// </summary>
internal static string ProgramVersion {
get {
@ -20873,6 +20873,16 @@ namespace PKHeX.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap team {
get {
object obj = ResourceManager.GetObject("team", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to -
///Duftnote
@ -33492,10 +33502,10 @@ namespace PKHeX.Properties {
///ライチュウ
///サンド
///サンドパン
///ニドラン
///ニドラン
///ニドリーナ
///ニドクイン
///ニドラン
///ニドラン
///ニドリーノ
///ニドキング
///ピッピ
@ -33542,7 +33552,7 @@ namespace PKHeX.Properties {
///ゴローニャ
///ポニータ
///ギャロップ
///ヤドン [rest of string was truncated]&quot;;.
///ヤ [rest of string was truncated]&quot;;.
/// </summary>
internal static string text_species_ja {
get {

View file

@ -7369,4 +7369,7 @@
<data name="ribbonbattletreemaster" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\img\ribbons\ribbonbattletreemaster.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="team" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\img\misc\team.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

View file

@ -30,17 +30,29 @@ namespace PKHeX
{
PokeDex = -1; // Disabled
LockedSlots = new int[0];
TeamSlots = new int[0];
}
else // Valid slot locking info present
{
int lockedCount = 0;
for (int i = 0; i < LockedSlots.Length; i++)
int lockedCount = 0, teamCount = 0;
for (int i = 0; i < TeamCount; i++)
{
short val = BitConverter.ToInt16(Data, BattleBoxFlags + i*2);
if (val >= 0)
LockedSlots[lockedCount++] = (BoxSlotCount*(val >> 8) + (val & 0xFF)) & 0xFFFF;
bool locked = Data[PCBackgrounds - TeamCount - i] == 1;
for (int j = 0; j < 6; j++)
{
short val = BitConverter.ToInt16(Data, BattleBoxFlags + (i*6 + j) * 2);
if (val < 0)
continue;
var slotVal = (BoxSlotCount*(val >> 8) + (val & 0xFF)) & 0xFFFF;
if (locked)
LockedSlots[lockedCount++] = slotVal;
else TeamSlots[teamCount++] = slotVal;
}
}
Array.Resize(ref LockedSlots, lockedCount);
Array.Resize(ref TeamSlots, teamCount);
}
}
@ -237,7 +249,10 @@ namespace PKHeX
PCFlags = PCLayout + 0x5E0;
FashionLength = 0x1A08;
LockedSlots = new int[36];
TeamCount = 6;
LockedSlots = new int[6*TeamCount];
TeamSlots = new int[6*TeamCount];
}
else // Empty input
{
@ -260,6 +275,7 @@ namespace PKHeX
private int PokeFinderSave { get; set; } = int.MinValue;
private int BattleTree { get; set; } = int.MinValue;
private int BattleBoxFlags { get; set; } = int.MinValue;
private int TeamCount { get; set; } = int.MinValue;
// Accessible as SAV7
public int TrainerCard { get; private set; } = 0x14000;
@ -915,6 +931,14 @@ namespace PKHeX
int slotIndex = slot + BoxSlotCount*box;
return LockedSlots.Any(s => s == slotIndex);
}
public override bool getIsTeamSet(int box, int slot)
{
if (slot >= 30 || box >= BoxCount)
return false;
int slotIndex = slot + BoxSlotCount * box;
return TeamSlots.Any(s => s == slotIndex);
}
public override int DaycareSeedSize => 32; // 128 bits
public override int getDaycareSlotOffset(int loc, int slot)

View file

@ -355,6 +355,7 @@ namespace PKHeX
public virtual byte[] BoxFlags { get { return null; } set { } }
public virtual int CurrentBox { get { return 0; } set { } }
protected int[] LockedSlots = new int[0];
protected int[] TeamSlots = new int[0];
protected virtual int getBoxWallpaperOffset(int box) { return -1; }
public int getBoxWallpaper(int box)
@ -459,6 +460,7 @@ namespace PKHeX
{
return LockedSlots.Any(slot => BoxStart*BoxSlotCount <= slot && slot < (BoxEnd + 1)*BoxSlotCount);
}
public virtual bool getIsTeamSet(int box, int slot) { return false; }
public void sortBoxes(int BoxStart = 0, int BoxEnd = -1)
{

View file

@ -115,8 +115,11 @@ namespace PKHeX
var sprite = p.Species != 0 ? p.Sprite : null;
int slot = getSlot(pb);
bool locked = slot < 30 && SAV.getIsSlotLocked(CB_BoxSelect.SelectedIndex, slot);
bool team = slot < 30 && SAV.getIsTeamSet(CB_BoxSelect.SelectedIndex, slot);
if (locked)
sprite = Util.LayerImage(sprite, Properties.Resources.locked, 5, 0, 1);
sprite = Util.LayerImage(sprite, Properties.Resources.locked, 26, 0, 1);
else if (team)
sprite = Util.LayerImage(sprite, Properties.Resources.team, 21, 0, 1);
pb.Image = sprite;
pb.BackColor = Color.Transparent;
}
@ -125,8 +128,11 @@ namespace PKHeX
var sprite = pk.Species != 0 ? pk.Sprite : null;
int slot = getSlot(pb);
bool locked = slot < 30 && SAV.getIsSlotLocked(CB_BoxSelect.SelectedIndex, slot);
bool team = slot < 30 && SAV.getIsTeamSet(CB_BoxSelect.SelectedIndex, slot);
if (locked)
sprite = Util.LayerImage(sprite, Properties.Resources.locked, 5, 0, 1);
sprite = Util.LayerImage(sprite, Properties.Resources.locked, 26, 0, 1);
else if (team)
sprite = Util.LayerImage(sprite, Properties.Resources.team, 21, 0, 1);
pb.Image = sprite;
if (pb.BackColor == Color.Red)
pb.BackColor = Color.Transparent;