mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
More refactoring
More extension methods for other types of images
This commit is contained in:
parent
db5e084ef9
commit
f4797e06a0
12 changed files with 64 additions and 50 deletions
|
@ -3622,7 +3622,7 @@ namespace PKHeX.WinForms
|
|||
{
|
||||
int boxoffset = SAV.getBoxOffset(CB_BoxSelect.SelectedIndex);
|
||||
int boxbgval = SAV.getBoxWallpaper(CB_BoxSelect.SelectedIndex);
|
||||
PAN_Box.BackgroundImage = SAV.getWallpaper(boxbgval);
|
||||
PAN_Box.BackgroundImage = SAV.WallpaperImage(boxbgval);
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
if (i < SAV.BoxSlotCount)
|
||||
|
|
|
@ -53,8 +53,8 @@ namespace PKHeX.WinForms
|
|||
row.Cells[r++].Value = s > 721 || Legal.PastGenAlolanNatives.Contains(s);
|
||||
row.Cells[r].Style.BackColor = mapColor((int)((p.BST - 175) / 3f));
|
||||
row.Cells[r++].Value = p.BST.ToString("000");
|
||||
row.Cells[r++].Value = (Image)Resources.ResourceManager.GetObject("type_icon_" + p.Types[0].ToString("00"));
|
||||
row.Cells[r++].Value = p.Types[0] == p.Types[1] ? Resources.slotTrans : (Image)Resources.ResourceManager.GetObject("type_icon_" + p.Types[1].ToString("00"));
|
||||
row.Cells[r++].Value = PKMUtil.getTypeSprite(p.Types[0]);
|
||||
row.Cells[r++].Value = p.Types[0] == p.Types[1] ? Resources.slotTrans : PKMUtil.getTypeSprite(p.Types[1]);
|
||||
row.Cells[r].Style.BackColor = mapColor(p.HP);
|
||||
row.Cells[r++].Value = p.HP.ToString("000");
|
||||
row.Cells[r].Style.BackColor = mapColor(p.ATK);
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace PKHeX.WinForms
|
|||
private void addRibbonSprite(RibbonInfo rib)
|
||||
{
|
||||
PictureBox pb = new PictureBox { AutoSize = false, Size = new Size(40,40), BackgroundImageLayout = ImageLayout.Center, Visible = false, Name = PrefixPB + rib.Name };
|
||||
var img = Core.Properties.Resources.ResourceManager.GetObject(rib.Name.Replace("CountG3", "G3").ToLower());
|
||||
var img = PKMUtil.getRibbonSprite(rib.Name);
|
||||
if (img != null)
|
||||
pb.BackgroundImage = (Bitmap)img;
|
||||
if (img == null)
|
||||
|
|
|
@ -311,7 +311,7 @@ namespace PKHeX.WinForms
|
|||
}
|
||||
var data = Results.Skip(start * RES_MIN).Take(RES_MAX).ToArray();
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
PKXBOXES[i].Image = SAV_Wondercard.getSprite(data[i]);
|
||||
PKXBOXES[i].Image = data[i].Sprite();
|
||||
for (int i = data.Length; i < RES_MAX; i++)
|
||||
PKXBOXES[i].Image = null;
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace PKHeX.WinForms
|
|||
if (!editing)
|
||||
SAV.setBoxWallpaper(LB_BoxSelect.SelectedIndex, CB_BG.SelectedIndex);
|
||||
|
||||
PAN_BG.BackgroundImage = SAV.getWallpaper(CB_BG.SelectedIndex);
|
||||
PAN_BG.BackgroundImage = SAV.WallpaperImage(CB_BG.SelectedIndex);
|
||||
}
|
||||
|
||||
private bool MoveItem(int direction)
|
||||
|
|
|
@ -422,8 +422,8 @@ namespace PKHeX.WinForms
|
|||
MT_Seconds.Text = SAV.PlayedSeconds.ToString();
|
||||
|
||||
// Load PSS Sprite
|
||||
CB_MultiplayerSprite.SelectedValue = SAV.Sprite;
|
||||
PB_Sprite.Image = (Image)Core.Properties.Resources.ResourceManager.GetObject("tr_" + SAV.Sprite.ToString("00"));
|
||||
CB_MultiplayerSprite.SelectedValue = SAV.MultiplayerSpriteID;
|
||||
PB_Sprite.Image = SAV.Sprite();
|
||||
|
||||
if (SAV.XY)
|
||||
{
|
||||
|
@ -519,7 +519,7 @@ namespace PKHeX.WinForms
|
|||
SAV.PlayedSeconds = ushort.Parse(MT_Seconds.Text)%60;
|
||||
|
||||
// Sprite
|
||||
SAV.Sprite = Convert.ToByte(CB_MultiplayerSprite.SelectedValue);
|
||||
SAV.MultiplayerSpriteID = Convert.ToByte(CB_MultiplayerSprite.SelectedValue);
|
||||
|
||||
// Appearance
|
||||
if (SAV.XY)
|
||||
|
@ -657,7 +657,8 @@ namespace PKHeX.WinForms
|
|||
|
||||
private void CB_Multi_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
PB_Sprite.Image = (Image)Core.Properties.Resources.ResourceManager.GetObject(Main.SAV.ORAS || Main.SAV.ORASDEMO ? "tr_" + WinFormsUtil.getIndex(CB_MultiplayerSprite).ToString("00") : "tr_00");
|
||||
SAV.MultiplayerSpriteID = WinFormsUtil.getIndex(CB_MultiplayerSprite);
|
||||
PB_Sprite.Image = SAV.Sprite();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -90,7 +90,7 @@ namespace PKHeX.WinForms
|
|||
{
|
||||
int boxoffset = SAV.getBoxOffset(CB_BoxSelect.SelectedIndex);
|
||||
int boxbgval = SAV.getBoxWallpaper(CB_BoxSelect.SelectedIndex);
|
||||
PAN_Box.BackgroundImage = SAV.getWallpaper(boxbgval);
|
||||
PAN_Box.BackgroundImage = SAV.WallpaperImage(boxbgval);
|
||||
|
||||
for (int i = 0; i < SAV.BoxSlotCount; i++)
|
||||
getSlotFiller(boxoffset + SAV.SIZE_STORED*i, SlotPictureBoxes[i]);
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace PKHeX.WinForms
|
|||
for (int i = 0; i < mga.Gifts.Length; i++)
|
||||
{
|
||||
MysteryGift m = mga.Gifts[i];
|
||||
pba[i].Image = m.Empty ? null : getSprite(m);
|
||||
pba[i].Image = m.Sprite();
|
||||
}
|
||||
}
|
||||
private void viewGiftData(MysteryGift g)
|
||||
|
@ -85,7 +85,7 @@ namespace PKHeX.WinForms
|
|||
g.GiftUsed = false;
|
||||
|
||||
RTB.Text = getDescription(g);
|
||||
PB_Preview.Image = getSprite(g);
|
||||
PB_Preview.Image = g.Sprite();
|
||||
mg = g;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -468,21 +468,6 @@ namespace PKHeX.WinForms
|
|||
e.Effect = DragDropEffects.Move;
|
||||
}
|
||||
private int wc_slot = -1;
|
||||
|
||||
internal static Image getSprite(MysteryGift gift)
|
||||
{
|
||||
Image img;
|
||||
if (gift.IsPokémon)
|
||||
img = PKMUtil.getSprite(gift.convertToPKM(Main.SAV));
|
||||
else if (gift.IsItem)
|
||||
img = (Image)(Core.Properties.Resources.ResourceManager.GetObject("item_" + gift.Item) ?? Core.Properties.Resources.unknown);
|
||||
else
|
||||
img = Core.Properties.Resources.unknown;
|
||||
|
||||
if (gift.GiftUsed)
|
||||
img = ImageUtil.LayerImage(new Bitmap(img.Width, img.Height), img, 0, 0, 0.3);
|
||||
return img;
|
||||
}
|
||||
private static string getDescription(MysteryGift gift)
|
||||
{
|
||||
if (gift.Empty)
|
||||
|
|
|
@ -11,14 +11,10 @@ namespace PKHeX.WinForms
|
|||
string str = PKX.getBallString(ball);
|
||||
return (Image)Resources.ResourceManager.GetObject(str) ?? Resources._ball4; // Poké Ball (default)
|
||||
}
|
||||
public static Image Sprite(this PKM pkm)
|
||||
{
|
||||
return getSprite(pkm);
|
||||
}
|
||||
public static Image getSprite(int species, int form, int gender, int item, bool isegg, bool shiny, int generation = -1)
|
||||
{
|
||||
if (species == 0)
|
||||
return (Image)Resources.ResourceManager.GetObject("_0");
|
||||
return Resources._0;
|
||||
|
||||
string file = PKX.getSpriteString(species, form, gender, generation);
|
||||
|
||||
|
@ -26,22 +22,15 @@ namespace PKHeX.WinForms
|
|||
Image baseImage = (Image)Resources.ResourceManager.GetObject(file);
|
||||
if (baseImage == null)
|
||||
{
|
||||
if (species < 803)
|
||||
{
|
||||
baseImage = ImageUtil.LayerImage(
|
||||
(Image)Resources.ResourceManager.GetObject("_" + species),
|
||||
Resources.unknown,
|
||||
0, 0, .5);
|
||||
}
|
||||
else
|
||||
baseImage = Resources.unknown;
|
||||
baseImage = (Image) Resources.ResourceManager.GetObject("_" + species);
|
||||
baseImage = baseImage != null ? ImageUtil.LayerImage(baseImage, Resources.unknown, 0, 0, .5) : Resources.unknown;
|
||||
}
|
||||
if (isegg)
|
||||
{
|
||||
// Start with a partially transparent species by layering the species with partial opacity onto a blank image.
|
||||
baseImage = ImageUtil.LayerImage((Image)Resources.ResourceManager.GetObject("_0"), baseImage, 0, 0, 0.33);
|
||||
baseImage = ImageUtil.LayerImage(Resources._0, baseImage, 0, 0, 0.33);
|
||||
// Add the egg layer over-top with full opacity.
|
||||
baseImage = ImageUtil.LayerImage(baseImage, (Image)Resources.ResourceManager.GetObject("egg"), 0, 0, 1);
|
||||
baseImage = ImageUtil.LayerImage(baseImage, Resources.egg, 0, 0, 1);
|
||||
}
|
||||
if (shiny)
|
||||
{
|
||||
|
@ -59,15 +48,53 @@ namespace PKHeX.WinForms
|
|||
}
|
||||
return baseImage;
|
||||
}
|
||||
public static Image getSprite(PKM pkm)
|
||||
public static Image getRibbonSprite(string name)
|
||||
{
|
||||
return Resources.ResourceManager.GetObject(name.Replace("CountG3", "G3").ToLower()) as Image;
|
||||
}
|
||||
public static Image getTypeSprite(int type)
|
||||
{
|
||||
return Resources.ResourceManager.GetObject("type_icon_" + type.ToString("00")) as Image;
|
||||
}
|
||||
|
||||
private static Image getSprite(MysteryGift gift)
|
||||
{
|
||||
if (gift.Empty)
|
||||
return null;
|
||||
|
||||
Image img;
|
||||
if (gift.IsPokémon)
|
||||
img = getSprite(gift.convertToPKM(Main.SAV));
|
||||
else if (gift.IsItem)
|
||||
img = (Image)(Resources.ResourceManager.GetObject("item_" + gift.Item) ?? Resources.unknown);
|
||||
else
|
||||
img = Resources.unknown;
|
||||
|
||||
if (gift.GiftUsed)
|
||||
img = ImageUtil.LayerImage(new Bitmap(img.Width, img.Height), img, 0, 0, 0.3);
|
||||
return img;
|
||||
}
|
||||
private static Image getSprite(PKM pkm)
|
||||
{
|
||||
return getSprite(pkm.Species, pkm.AltForm, pkm.Gender, pkm.SpriteItem, pkm.IsEgg, pkm.IsShiny, pkm.Format);
|
||||
}
|
||||
|
||||
public static Image getWallpaper(this SaveFile SAV, int box)
|
||||
private static Image getSprite(SaveFile SAV)
|
||||
{
|
||||
string file = "tr_00";
|
||||
if (SAV.Generation == 6 && (SAV.ORAS || SAV.ORASDEMO))
|
||||
file = "tr_" + SAV.MultiplayerSpriteID.ToString("00");
|
||||
return Resources.ResourceManager.GetObject(file) as Image;
|
||||
}
|
||||
private static Image getWallpaper(SaveFile SAV, int box)
|
||||
{
|
||||
string s = BoxWallpaper.getWallpaper(SAV, box);
|
||||
return (Bitmap)(Resources.ResourceManager.GetObject(s) ?? Resources.box_wp16xy);
|
||||
}
|
||||
|
||||
// Extension Methods
|
||||
public static Image Sprite(this MysteryGift gift) => getSprite(gift);
|
||||
public static Image Sprite(this PKM pkm) => getSprite(pkm);
|
||||
public static Image Sprite(this SaveFile SAV) => getSprite(SAV);
|
||||
public static Image WallpaperImage(this SaveFile SAV, int box) => getWallpaper(SAV, box);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -516,9 +516,9 @@ namespace PKHeX.Core
|
|||
|
||||
string file = "_" + species;
|
||||
if (form > 0) // Alt Form Handling
|
||||
file = file + "_" + form;
|
||||
file += "_" + form;
|
||||
else if (gender == 1 && new[] { 592, 593, 521, 668 }.Contains(species)) // Frillish & Jellicent, Unfezant & Pyroar
|
||||
file = file + "_" + gender;
|
||||
file += "_" + gender;
|
||||
|
||||
if (species == 25 && form > 0 && generation >= 7) // Pikachu
|
||||
file += "c"; // Cap
|
||||
|
|
|
@ -347,7 +347,7 @@ namespace PKHeX.Core
|
|||
get { return Data[TrainerCard + 5]; }
|
||||
set { Data[TrainerCard + 5] = (byte)value; }
|
||||
}
|
||||
public int Sprite
|
||||
public override int MultiplayerSpriteID
|
||||
{
|
||||
get { return Data[TrainerCard + 7]; }
|
||||
set { Data[TrainerCard + 7] = (byte)value; }
|
||||
|
|
|
@ -328,6 +328,7 @@ namespace PKHeX.Core
|
|||
public virtual uint Money { get; set; }
|
||||
public abstract int BoxCount { get; }
|
||||
public virtual int PartyCount { get; protected set; }
|
||||
public virtual int MultiplayerSpriteID { get { return 0; } set { } }
|
||||
|
||||
// Varied Methods
|
||||
protected abstract void setChecksums();
|
||||
|
|
Loading…
Reference in a new issue