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.Core
namespace PKHeX.WinForms
{ {
public class SlotChange public class SlotChange : StorageSlotOffset
{ {
/// <summary> Parent of the object that initiated the slot change. </summary> /// <summary> Parent of the object that initiated the slot change. </summary>
public object Parent { get; set; } public object Parent { get; set; }
@ -10,7 +8,6 @@ namespace PKHeX.WinForms
/// <summary> Original Data of the slot. </summary> /// <summary> Original Data of the slot. </summary>
public byte[] OriginalData { get; set; } public byte[] OriginalData { get; set; }
public int Offset { get; set; } = -1;
public int Slot { get; set; } = -1; public int Slot { get; set; } = -1;
public int Box { get; set; } = -1; public int Box { get; set; } = -1;
public PKM PKM { get; set; } public PKM PKM { get; set; }

View file

@ -1,6 +1,4 @@
using PKHeX.Core; namespace PKHeX.Core
namespace PKHeX.WinForms
{ {
public class SlotChangeInfo public class SlotChangeInfo
{ {
@ -26,7 +24,7 @@ namespace PKHeX.WinForms
public void Reset() public void Reset()
{ {
LeftMouseIsDown = RightMouseIsDown = DragDropInProgress = false; LeftMouseIsDown = RightMouseIsDown = DragDropInProgress = false;
Source = new SlotChange {OriginalData = BlankData}; Source = new SlotChange { OriginalData = BlankData };
Destination = new SlotChange(); Destination = new SlotChange();
Cursor = CurrentPath = null; 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.BackColor = Color.Transparent;
pb.Visible = true; pb.Visible = true;
if (M != null && M.colorizedbox == box && M.colorizedslot == slot) if (M != null && M.ColorizedBox == box && M.ColorizedSlot == slot)
pb.BackgroundImage = M.colorizedcolor; pb.BackgroundImage = M.ColorizedColor;
} }
public void ResetBoxNames(int box = -1) public void ResetBoxNames(int box = -1)
@ -135,7 +135,7 @@ namespace PKHeX.WinForms.Controls
int boxbgval = SAV.GetBoxWallpaper(box); int boxbgval = SAV.GetBoxWallpaper(box);
PAN_Box.BackgroundImage = SAV.WallpaperImage(boxbgval); 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++) for (int i = 0; i < BoxSlotCount; i++)
{ {
@ -144,7 +144,7 @@ namespace PKHeX.WinForms.Controls
GetSlotFiller(boxoffset + SAV.SIZE_STORED * i, pb, box, i); GetSlotFiller(boxoffset + SAV.SIZE_STORED * i, pb, box, i);
else else
pb.Visible = false; pb.Visible = false;
pb.BackgroundImage = slot == i ? M?.colorizedcolor : null; pb.BackgroundImage = slot == i ? M?.ColorizedColor : null;
} }
} }
public bool SaveBoxBinary() public bool SaveBoxBinary()

View file

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

View file

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

View file

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