Refactoring

move slotchange to core
This commit is contained in:
Kurt 2018-01-29 17:52:21 -08:00
parent d7eae51c1f
commit e472bfe278
8 changed files with 41 additions and 26 deletions

View file

@ -1,8 +1,6 @@
using PKHeX.Core;
namespace PKHeX.WinForms
namespace PKHeX.Core
{
public class SlotChange
public class SlotChange : StorageSlotOffset
{
/// <summary> Parent of the object that initiated the slot change. </summary>
public object Parent { get; set; }
@ -10,7 +8,6 @@ namespace PKHeX.WinForms
/// <summary> Original Data of the slot. </summary>
public byte[] OriginalData { get; set; }
public int Offset { get; set; } = -1;
public int Slot { get; set; } = -1;
public int Box { get; set; } = -1;
public PKM PKM { get; set; }
@ -18,4 +15,4 @@ namespace PKHeX.WinForms
public bool IsParty => 30 <= Slot && Slot < 36;
public bool IsValid => Slot > -1 && (Box > -1 || IsParty);
}
}
}

View file

@ -1,6 +1,4 @@
using PKHeX.Core;
namespace PKHeX.WinForms
namespace PKHeX.Core
{
public class SlotChangeInfo
{
@ -26,7 +24,7 @@ namespace PKHeX.WinForms
public void Reset()
{
LeftMouseIsDown = RightMouseIsDown = DragDropInProgress = false;
Source = new SlotChange {OriginalData = BlankData};
Source = new SlotChange { OriginalData = BlankData };
Destination = new SlotChange();
Cursor = CurrentPath = null;
}

View file

@ -0,0 +1,8 @@
namespace PKHeX.Core
{
public class StorageSlotOffset
{
public int Offset { get; set; } = -1;
public StorageSlotType Type { get; set; } = StorageSlotType.Misc;
}
}

View file

@ -0,0 +1,13 @@
namespace PKHeX.Core
{
public enum StorageSlotType
{
Box,
Party,
BattleBox,
Daycare,
GTS,
Fused,
Misc,
}
}

View file

@ -94,8 +94,8 @@ namespace PKHeX.WinForms.Controls
pb.BackColor = Color.Transparent;
pb.Visible = true;
if (M != null && M.colorizedbox == box && M.colorizedslot == slot)
pb.BackgroundImage = M.colorizedcolor;
if (M != null && M.ColorizedBox == box && M.ColorizedSlot == slot)
pb.BackgroundImage = M.ColorizedColor;
}
public void ResetBoxNames(int box = -1)
@ -135,7 +135,7 @@ namespace PKHeX.WinForms.Controls
int boxbgval = SAV.GetBoxWallpaper(box);
PAN_Box.BackgroundImage = SAV.WallpaperImage(boxbgval);
int slot = M?.colorizedbox == box ? M.colorizedslot : -1;
int slot = M?.ColorizedBox == box ? M.ColorizedSlot : -1;
for (int i = 0; i < BoxSlotCount; i++)
{
@ -144,7 +144,7 @@ namespace PKHeX.WinForms.Controls
GetSlotFiller(boxoffset + SAV.SIZE_STORED * i, pb, box, i);
else
pb.Visible = false;
pb.BackgroundImage = slot == i ? M?.colorizedcolor : null;
pb.BackgroundImage = slot == i ? M?.ColorizedColor : null;
}
}
public bool SaveBoxBinary()

View file

@ -151,8 +151,8 @@ namespace PKHeX.WinForms.Controls
ResetNonBoxSlots();
// Recoloring of a storage box slot (to not show for other storage boxes)
if (M?.colorizedslot >= (int)SlotIndex.Party)
SlotPictureBoxes[M.colorizedslot].BackgroundImage = M.colorizedcolor;
if (M?.ColorizedSlot >= (int)SlotIndex.Party)
SlotPictureBoxes[M.ColorizedSlot].BackgroundImage = M.ColorizedColor;
}
private void ResetNonBoxSlots()
{

View file

@ -20,13 +20,14 @@ namespace PKHeX.WinForms.Controls
public readonly SAVEditor SE;
private Image OriginalBackground;
private Image CurrentBackground;
public Image colorizedcolor;
public Image ColorizedColor { get; private set; }
public int ColorizedBox { get; private set; } = -1;
public int ColorizedSlot { get; private set; } = -1;
private SaveFile SAV => SE.SAV;
public SlotChangeInfo DragInfo;
public readonly List<BoxEditor> Boxes = new List<BoxEditor>();
public int colorizedbox = -1;
public int colorizedslot = -1;
public event DragEventHandler RequestExternalDragDrop;
public SlotChangeManager(SAVEditor se)
@ -34,7 +35,7 @@ namespace PKHeX.WinForms.Controls
SE = se;
Reset();
}
public void Reset() { DragInfo = new SlotChangeInfo(SAV); colorizedbox = colorizedslot = -1; }
public void Reset() { DragInfo = new SlotChangeInfo(SAV); ColorizedBox = ColorizedSlot = -1; }
public bool DragActive => DragInfo.DragDropInProgress || !DragInfo.LeftMouseIsDown;
public void SetCursor(Cursor z, object sender)
{
@ -321,9 +322,9 @@ namespace PKHeX.WinForms.Controls
for (int i = 0; i < slots.Count; i++)
slots[i].BackgroundImage = slot == i ? img : null;
}
colorizedbox = box;
colorizedslot = slot;
colorizedcolor = img;
ColorizedBox = box;
ColorizedSlot = slot;
ColorizedColor = img;
}
// PKM Get Set
@ -424,7 +425,7 @@ namespace PKHeX.WinForms.Controls
SE?.Dispose();
OriginalBackground?.Dispose();
CurrentBackground?.Dispose();
colorizedcolor?.Dispose();
ColorizedColor?.Dispose();
}
}
}

View file

@ -190,7 +190,6 @@
<Compile Include="Controls\SAV Editor\SAVEditor.Designer.cs">
<DependentUpon>SAVEditor.cs</DependentUpon>
</Compile>
<Compile Include="Controls\SAV Editor\SlotChangeInfo.cs" />
<Compile Include="Controls\SAV Editor\SlotList.cs">
<SubType>UserControl</SubType>
</Compile>
@ -224,7 +223,6 @@
<Compile Include="Controls\PKM Editor\EditPK7.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\SAV Editor\SlotChange.cs" />
<Compile Include="Controls\PKM Editor\PKMEditor.cs">
<SubType>UserControl</SubType>
</Compile>