2014-06-28 21:22:05 +00:00
using System ;
2015-03-11 04:18:35 +00:00
using System.Drawing ;
2015-03-11 01:44:51 +00:00
using System.IO ;
2015-03-11 04:18:35 +00:00
using System.Linq ;
2014-06-28 21:22:05 +00:00
using System.Windows.Forms ;
namespace PKHeX
{
public partial class SAV_Wondercard : Form
{
2016-06-20 04:22:43 +00:00
public SAV_Wondercard ( MysteryGift g = null )
2014-06-28 21:22:05 +00:00
{
InitializeComponent ( ) ;
2015-09-21 03:34:09 +00:00
Util . TranslateInterface ( this , Main . curlanguage ) ;
2016-06-20 04:22:43 +00:00
mga = Main . SAV . GiftAlbum ;
2015-12-18 05:15:40 +00:00
pba = new [ ]
{
PB_Card01 , PB_Card02 , PB_Card03 , PB_Card04 , PB_Card05 , PB_Card06 ,
PB_Card07 , PB_Card08 , PB_Card09 , PB_Card10 , PB_Card11 , PB_Card12 ,
PB_Card13 , PB_Card14 , PB_Card15 , PB_Card16 , PB_Card17 , PB_Card18 ,
PB_Card19 , PB_Card20 , PB_Card21 , PB_Card22 , PB_Card23 , PB_Card24 ,
} ;
2015-12-19 06:04:01 +00:00
foreach ( PictureBox pb in pba )
{
pb . AllowDrop = true ;
// The PictureBoxes have their own drag&drop event handlers.
}
2016-06-20 04:22:43 +00:00
// Hide slots not present on game
for ( int i = mga . Gifts . Length ; i < pba . Length ; i + + )
pba [ i ] . Visible = false ;
if ( mga . Gifts . Length < 7 )
L_r2 . Visible = false ;
if ( mga . Gifts . Length < 13 )
L_r3 . Visible = false ;
if ( mga . Gifts . Length < 19 )
L_r4 . Visible = false ;
2016-07-06 02:12:18 +00:00
if ( SAV . Generation = = 4 ) // pgt & pcd, split up
{
PB_Card09 . Location = PB_Card19 . Location ;
PB_Card10 . Location = PB_Card20 . Location ;
PB_Card11 . Location = PB_Card21 . Location ;
L_r4 . Visible = true ;
L_r1 . Text = "PGT 1-6" ;
L_r2 . Text = "PGT 7-8" ;
L_r4 . Text = "PCD 1-3" ;
}
2016-06-20 04:22:43 +00:00
setGiftBoxes ( ) ;
getReceivedFlags ( ) ;
2015-12-19 06:04:01 +00:00
2014-06-28 21:22:05 +00:00
if ( LB_Received . Items . Count > 0 )
2014-12-10 23:24:34 +00:00
LB_Received . SelectedIndex = 0 ;
2015-03-11 01:44:51 +00:00
DragEnter + = tabMain_DragEnter ;
DragDrop + = tabMain_DragDrop ;
2015-04-01 00:58:23 +00:00
2016-06-20 04:22:43 +00:00
if ( g = = null )
clickView ( PB_Card01 , null ) ;
else
viewGiftData ( g ) ;
2014-06-28 21:22:05 +00:00
}
2016-06-20 04:22:43 +00:00
private readonly SaveFile SAV = Main . SAV . Clone ( ) ;
private MysteryGiftAlbum mga ;
private MysteryGift mg ;
2016-01-17 21:27:24 +00:00
private readonly PictureBox [ ] pba ;
2014-06-28 21:22:05 +00:00
// Repopulation Functions
2015-12-19 04:48:47 +00:00
private void setBackground ( int index , Image bg )
{
2016-06-20 04:22:43 +00:00
for ( int i = 0 ; i < mga . Gifts . Length ; i + + )
2015-12-19 04:48:47 +00:00
pba [ i ] . BackgroundImage = index = = i ? bg : null ;
}
2016-06-20 04:22:43 +00:00
private void setGiftBoxes ( )
2014-06-28 21:22:05 +00:00
{
2016-06-20 04:22:43 +00:00
for ( int i = 0 ; i < mga . Gifts . Length ; i + + )
2014-06-28 21:22:05 +00:00
{
2016-06-20 04:22:43 +00:00
MysteryGift m = mga . Gifts [ i ] ;
pba [ i ] . Image = m . Empty ? null : getSprite ( m ) ;
2014-06-28 21:22:05 +00:00
}
}
2016-06-20 04:22:43 +00:00
private void viewGiftData ( MysteryGift g )
2014-06-28 21:22:05 +00:00
{
2014-12-11 06:50:40 +00:00
try
2014-06-28 21:22:05 +00:00
{
2016-07-24 22:44:44 +00:00
// only check if the form is visible (not opening)
if ( Visible & & g . GiftUsed & & DialogResult . Yes = =
2015-09-13 04:32:30 +00:00
Util . Prompt ( MessageBoxButtons . YesNo ,
2015-12-18 05:15:40 +00:00
"Wonder Card is marked as USED and will not be able to be picked up in-game." ,
2015-09-13 04:32:30 +00:00
"Do you want to remove the USED flag so that it is UNUSED?" ) )
2016-06-20 04:22:43 +00:00
g . GiftUsed = false ;
2016-01-24 18:19:30 +00:00
2016-06-20 04:22:43 +00:00
RTB . Text = getDescription ( g ) ;
PB_Preview . Image = getSprite ( g ) ;
mg = g ;
2014-06-28 21:22:05 +00:00
}
2015-01-11 07:31:51 +00:00
catch ( Exception e )
{
2015-12-18 05:15:40 +00:00
Util . Error ( "Loading of data failed... is this really a Wonder Card?" , e . ToString ( ) ) ;
2015-01-11 07:31:51 +00:00
RTB . Clear ( ) ;
2014-06-28 21:22:05 +00:00
}
}
2016-06-20 04:22:43 +00:00
private void getReceivedFlags ( )
2014-06-28 21:22:05 +00:00
{
LB_Received . Items . Clear ( ) ;
2016-06-20 04:22:43 +00:00
for ( int i = 1 ; i < mga . Flags . Length ; i + + )
if ( mga . Flags [ i ] )
2014-06-28 21:22:05 +00:00
LB_Received . Items . Add ( i . ToString ( "0000" ) ) ;
2016-04-22 02:16:55 +00:00
2015-12-19 06:04:01 +00:00
if ( LB_Received . Items . Count > 0 )
LB_Received . SelectedIndex = 0 ;
2014-06-28 21:22:05 +00:00
}
2015-12-19 06:04:01 +00:00
private void setCardID ( int cardID )
{
if ( cardID < = 0 | | cardID > = 0x100 * 8 ) return ;
2014-06-28 21:22:05 +00:00
2015-12-19 06:04:01 +00:00
string card = cardID . ToString ( "0000" ) ;
if ( ! LB_Received . Items . Contains ( card ) )
LB_Received . Items . Add ( card ) ;
LB_Received . SelectedIndex = LB_Received . Items . IndexOf ( card ) ;
}
// Wonder Card IO (.wc6<->window)
2016-06-20 04:22:43 +00:00
private string getFilter ( )
{
switch ( SAV . Generation )
{
case 4 :
return "Gen4 Mystery Gift|*.pgt;*.pcd|All Files|*.*" ;
case 5 :
return "Gen5 Mystery Gift|*.pgf|All Files|*.*" ;
case 6 :
return "Gen6 Mystery Gift|*.wc6;*.wc6full|All Files|*.*" ;
default :
return "" ;
}
}
2014-06-28 21:22:05 +00:00
private void B_Import_Click ( object sender , EventArgs e )
{
2016-06-20 04:22:43 +00:00
OpenFileDialog import = new OpenFileDialog { Filter = getFilter ( ) } ;
if ( import . ShowDialog ( ) ! = DialogResult . OK ) return ;
2015-03-12 04:44:12 +00:00
2016-06-20 04:22:43 +00:00
string path = import . FileName ;
MysteryGift g = MysteryGift . getMysteryGift ( File . ReadAllBytes ( path ) , Path . GetExtension ( path ) ) ;
if ( g = = null )
2014-06-28 21:22:05 +00:00
{
2016-06-20 04:22:43 +00:00
Util . Error ( "File is not a Mystery Gift:" , path ) ;
2015-03-12 04:44:12 +00:00
return ;
2014-06-28 21:22:05 +00:00
}
2016-06-20 04:22:43 +00:00
viewGiftData ( g ) ;
2014-06-28 21:22:05 +00:00
}
private void B_Output_Click ( object sender , EventArgs e )
{
2016-06-20 04:22:43 +00:00
SaveFileDialog outputwc6 = new SaveFileDialog
{
Filter = getFilter ( ) ,
FileName = Util . CleanFileName ( $"{mg.CardID} - {mg.CardTitle}{mg.Extension}" )
} ;
2015-03-12 04:44:12 +00:00
if ( outputwc6 . ShowDialog ( ) ! = DialogResult . OK ) return ;
2014-06-28 21:22:05 +00:00
2015-03-12 04:44:12 +00:00
string path = outputwc6 . FileName ;
2014-06-28 21:22:05 +00:00
2016-02-01 07:15:54 +00:00
if ( File . Exists ( path ) ) // File already exists, save a .bak
File . WriteAllBytes ( path + ".bak" , File . ReadAllBytes ( path ) ) ;
2015-03-12 04:44:12 +00:00
2016-06-20 04:22:43 +00:00
File . WriteAllBytes ( path , mg . Data ) ;
2014-06-28 21:22:05 +00:00
}
2015-12-19 06:04:01 +00:00
// Wonder Card RW (window<->sav)
private void clickView ( object sender , EventArgs e )
2014-06-28 21:22:05 +00:00
{
2016-02-01 07:15:54 +00:00
sender = ( ( sender as ToolStripItem ) ? . Owner as ContextMenuStrip ) ? . SourceControl ? ? sender as PictureBox ;
int index = Array . IndexOf ( pba , sender ) ;
2015-12-20 00:25:32 +00:00
2015-12-19 04:48:47 +00:00
setBackground ( index , Properties . Resources . slotView ) ;
2016-06-20 04:22:43 +00:00
viewGiftData ( mga . Gifts [ index ] ) ;
2014-06-28 21:22:05 +00:00
}
2015-12-19 06:04:01 +00:00
private void clickSet ( object sender , EventArgs e )
2014-06-28 21:22:05 +00:00
{
2016-06-20 04:22:43 +00:00
if ( ! checkSpecialWonderCard ( mg ) )
2016-03-31 01:28:28 +00:00
return ;
2016-02-01 07:15:54 +00:00
sender = ( ( sender as ToolStripItem ) ? . Owner as ContextMenuStrip ) ? . SourceControl ? ? sender as PictureBox ;
int index = Array . IndexOf ( pba , sender ) ;
2015-12-20 00:25:32 +00:00
// Hijack to the latest unfilled slot if index creates interstitial empty slots.
int lastUnfilled = Array . FindIndex ( pba , p = > p . Image = = null ) ;
2016-03-31 01:28:28 +00:00
if ( lastUnfilled > - 1 & & lastUnfilled < index )
2015-12-20 00:25:32 +00:00
index = lastUnfilled ;
2016-06-20 04:22:43 +00:00
if ( mg . Data . Length ! = mga . Gifts [ index ] . Data . Length )
{
Util . Alert ( "Can't set slot here." , $"{mg.GetType()} != {mga.Gifts[index].GetType()}" ) ;
return ;
}
2015-12-19 04:48:47 +00:00
setBackground ( index , Properties . Resources . slotSet ) ;
2016-06-20 04:22:43 +00:00
mga . Gifts [ index ] = mg ;
setGiftBoxes ( ) ;
setCardID ( mg . CardID ) ;
2014-06-28 21:22:05 +00:00
}
2015-12-19 06:04:01 +00:00
private void clickDelete ( object sender , EventArgs e )
2014-06-28 21:22:05 +00:00
{
2016-02-01 07:15:54 +00:00
sender = ( ( sender as ToolStripItem ) ? . Owner as ContextMenuStrip ) ? . SourceControl ? ? sender as PictureBox ;
int index = Array . IndexOf ( pba , sender ) ;
2015-12-19 06:04:01 +00:00
2015-12-20 00:25:32 +00:00
setBackground ( index , Properties . Resources . slotDel ) ;
2016-06-20 04:22:43 +00:00
mga . Gifts [ index ] . Data = new byte [ mga . Gifts [ index ] . Data . Length ] ;
setGiftBoxes ( ) ;
2014-06-28 21:22:05 +00:00
}
// Close Window
private void B_Cancel_Click ( object sender , EventArgs e )
{
Close ( ) ;
}
private void B_Save_Click ( object sender , EventArgs e )
{
// Make sure all of the Received Flags are flipped!
2016-06-20 04:22:43 +00:00
bool [ ] flags = new bool [ mga . Flags . Length ] ;
2016-04-22 02:16:55 +00:00
foreach ( var o in LB_Received . Items )
flags [ Util . ToUInt32 ( o . ToString ( ) ) ] = true ;
2014-06-28 21:22:05 +00:00
2016-06-20 04:22:43 +00:00
mga . Flags = flags ;
SAV . GiftAlbum = mga ;
2016-04-22 02:16:55 +00:00
Main . SAV . Data = SAV . Data ;
2015-10-24 23:33:44 +00:00
Main . SAV . Edited = true ;
2014-06-28 21:22:05 +00:00
Close ( ) ;
}
2014-12-11 06:50:40 +00:00
// Delete WC Flag
2015-12-19 06:04:01 +00:00
private void clearRecievedFlag ( object sender , EventArgs e )
2014-06-28 21:22:05 +00:00
{
2016-02-01 07:15:54 +00:00
if ( LB_Received . SelectedIndex < 0 ) return ;
2015-03-12 04:44:12 +00:00
if ( LB_Received . Items . Count > 0 )
LB_Received . Items . Remove ( LB_Received . Items [ LB_Received . SelectedIndex ] ) ;
2015-12-19 06:04:01 +00:00
if ( LB_Received . Items . Count > 0 )
LB_Received . SelectedIndex = 0 ;
2014-06-28 21:22:05 +00:00
}
2014-12-10 23:24:34 +00:00
2015-12-19 06:04:01 +00:00
// Drag & Drop Wonder Cards
2014-12-10 23:24:34 +00:00
private void tabMain_DragEnter ( object sender , DragEventArgs e )
{
if ( e . Data . GetDataPresent ( DataFormats . FileDrop ) ) e . Effect = DragDropEffects . Copy ;
}
private void tabMain_DragDrop ( object sender , DragEventArgs e )
{
string [ ] files = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
2015-01-11 07:31:51 +00:00
2015-01-31 23:59:23 +00:00
// Check for multiple wondercards
2016-03-19 22:50:01 +00:00
if ( Directory . Exists ( files [ 0 ] ) )
files = Directory . GetFiles ( files [ 0 ] , "*" , SearchOption . AllDirectories ) ;
if ( files . Length = = 1 & & ! Directory . Exists ( files [ 0 ] ) )
2014-12-10 23:24:34 +00:00
{
2015-01-31 23:59:23 +00:00
string path = files [ 0 ] ; // open first D&D
2016-03-19 22:50:01 +00:00
long len = new FileInfo ( path ) . Length ;
2016-06-20 04:22:43 +00:00
if ( len > 0x1000 ) // arbitrary
2015-01-31 23:59:23 +00:00
{
2016-06-20 04:22:43 +00:00
Util . Alert ( "File is not a Mystery Gift." , path ) ;
2015-01-31 23:59:23 +00:00
return ;
}
2016-06-20 04:22:43 +00:00
MysteryGift g = MysteryGift . getMysteryGift ( File . ReadAllBytes ( path ) , Path . GetExtension ( path ) ) ;
if ( g = = null )
2016-03-31 01:28:28 +00:00
{
2016-06-20 04:22:43 +00:00
Util . Error ( "File is not a Mystery Gift:" , path ) ;
return ;
2016-03-31 01:28:28 +00:00
}
2016-06-20 04:22:43 +00:00
viewGiftData ( g ) ;
return ;
2016-03-19 22:50:01 +00:00
}
2016-06-20 04:22:43 +00:00
setGiftBoxes ( ) ;
2014-12-10 23:24:34 +00:00
}
2015-03-11 04:18:35 +00:00
2016-06-20 04:22:43 +00:00
private bool checkSpecialWonderCard ( MysteryGift g )
2016-03-31 01:28:28 +00:00
{
2016-06-20 04:22:43 +00:00
if ( SAV . Generation ! = 6 )
return true ;
if ( g is WC6 )
2016-03-31 01:28:28 +00:00
{
2016-06-20 04:22:43 +00:00
if ( g . CardID = = 2048 & & g . Item = = 726 ) // Eon Ticket (OR/AS)
{
if ( ! Main . SAV . ORAS | | ( ( SAV6 ) SAV ) . EonTicket < 0 )
goto reject ;
BitConverter . GetBytes ( WC6 . EonTicketConst ) . CopyTo ( SAV . Data , ( ( SAV6 ) SAV ) . EonTicket ) ;
}
2016-03-31 01:28:28 +00:00
}
return true ;
2016-06-20 04:22:43 +00:00
reject : Util . Alert ( "Unable to insert the Mystery Gift." , "Does this Mystery Gift really belong to this game?" ) ;
2016-03-31 01:28:28 +00:00
return false ;
}
2016-04-22 02:16:55 +00:00
2015-03-11 04:18:35 +00:00
private void L_QR_Click ( object sender , EventArgs e )
{
if ( ModifierKeys = = Keys . Alt )
{
2016-06-20 04:22:43 +00:00
byte [ ] data = QR . getQRData ( ) ;
2016-04-22 02:16:55 +00:00
if ( data = = null ) return ;
2016-07-24 22:44:44 +00:00
string [ ] types = mga . Gifts . Select ( g = > g . GetType ( ) . Name ) . Distinct ( ) . ToArray ( ) ;
MysteryGift gift = MysteryGift . getMysteryGift ( data ) ;
string giftType = gift . GetType ( ) . Name ;
if ( mga . Gifts . All ( card = > card . Data . Length ! = data . Length ) )
Util . Alert ( "Decoded data not valid for loaded save file." , $"QR Data Size: 0x{data.Length.ToString(" X ")}" ) ;
else if ( types . All ( type = > type ! = giftType ) )
Util . Alert ( "Gift type is not compatible with the save file." , $"QR Gift Type: {gift.GetType().Name}" + Environment . NewLine + $"Expected Types: {string.Join(" , ", types)}" ) ;
else
try { viewGiftData ( gift ) ; }
catch { Util . Alert ( "Error loading Mystery Gift data." ) ; }
2015-03-11 04:18:35 +00:00
}
else
{
2016-06-20 04:22:43 +00:00
if ( mg . Data . SequenceEqual ( new byte [ mg . Data . Length ] ) )
2015-09-21 03:34:09 +00:00
{ Util . Alert ( "No wondercard data found in loaded slot!" ) ; return ; }
2016-07-24 22:44:44 +00:00
if ( SAV . Generation = = 6 & & mg . Item = = 726 & & mg . IsItem )
2015-12-19 06:04:01 +00:00
{ Util . Alert ( "Eon Ticket Wonder Cards will not function properly" , "Inject to the save file instead." ) ; return ; }
2016-06-20 04:22:43 +00:00
2015-03-11 04:18:35 +00:00
const string server = "http://lunarcookies.github.io/wc.html#" ;
2016-06-20 04:22:43 +00:00
Image qr = QR . getQRImage ( mg . Data , server ) ;
2015-03-14 02:59:51 +00:00
if ( qr = = null ) return ;
2015-03-11 04:18:35 +00:00
2016-07-24 22:44:44 +00:00
string desc = $"({mg.GetType().Name}) {getDescription(mg)}" ;
2015-03-11 04:18:35 +00:00
2015-12-19 06:04:01 +00:00
new QR ( qr , PB_Preview . Image , desc , "" , "" , "PKHeX Wonder Card @ ProjectPokemon.org" ) . ShowDialog ( ) ;
2015-03-11 04:18:35 +00:00
}
}
2015-12-18 05:15:40 +00:00
private void pbBoxSlot_MouseDown ( object sender , MouseEventArgs e )
{
2016-06-20 04:22:43 +00:00
switch ( ModifierKeys )
2015-12-18 05:15:40 +00:00
{
2016-06-20 04:22:43 +00:00
case Keys . Control : clickView ( sender , e ) ; return ;
case Keys . Shift : clickSet ( sender , e ) ; return ;
case Keys . Alt : clickDelete ( sender , e ) ; return ;
2015-12-18 05:15:40 +00:00
}
2016-06-20 04:22:43 +00:00
PictureBox pb = sender as PictureBox ;
if ( pb ? . Image = = null )
2015-12-19 06:04:01 +00:00
return ;
if ( e . Button ! = MouseButtons . Left | | e . Clicks ! = 1 ) return ;
2016-02-01 07:15:54 +00:00
int index = Array . IndexOf ( pba , sender ) ;
2015-12-19 06:17:01 +00:00
wc_slot = index ;
2015-12-19 06:04:01 +00:00
// Create Temp File to Drag
Cursor . Current = Cursors . Hand ;
// Prepare Data
2016-06-20 04:22:43 +00:00
MysteryGift card = mga . Gifts [ index ] ;
2016-02-01 07:15:54 +00:00
string filename = Util . CleanFileName ( $"{card.CardID.ToString(" 0000 ")} - {card.CardTitle}.wc6" ) ;
2015-12-19 06:04:01 +00:00
// Make File
string newfile = Path . Combine ( Path . GetTempPath ( ) , Util . CleanFileName ( filename ) ) ;
try
{
2016-04-22 02:16:55 +00:00
File . WriteAllBytes ( newfile , card . Data ) ;
2015-12-19 06:04:01 +00:00
DoDragDrop ( new DataObject ( DataFormats . FileDrop , new [ ] { newfile } ) , DragDropEffects . Move ) ;
}
catch ( ArgumentException x )
{ Util . Error ( "Drag & Drop Error:" , x . ToString ( ) ) ; }
File . Delete ( newfile ) ;
2015-12-19 06:17:01 +00:00
wc_slot = - 1 ;
2015-12-18 05:15:40 +00:00
}
2015-12-19 06:04:01 +00:00
private void pbBoxSlot_DragDrop ( object sender , DragEventArgs e )
2015-12-18 05:15:40 +00:00
{
2016-02-01 07:15:54 +00:00
int index = Array . IndexOf ( pba , sender ) ;
2015-12-19 06:04:01 +00:00
// Hijack to the latest unfilled slot if index creates interstitial empty slots.
int lastUnfilled = Array . FindIndex ( pba , p = > p . Image = = null ) ;
if ( lastUnfilled < index )
index = lastUnfilled ;
2016-06-20 04:22:43 +00:00
if ( wc_slot = = - 1 ) // dropped
2015-12-19 06:17:01 +00:00
{
string [ ] files = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
2015-12-19 06:04:01 +00:00
2016-06-20 04:22:43 +00:00
if ( files . Length < 1 )
2015-12-19 06:17:01 +00:00
return ;
2016-06-20 04:22:43 +00:00
if ( PCD . Size < ( int ) new FileInfo ( files [ 0 ] ) . Length )
{ Util . Alert ( "Data size invalid." , files [ 0 ] ) ; return ; }
2016-04-22 02:16:55 +00:00
2016-06-20 04:22:43 +00:00
byte [ ] data = File . ReadAllBytes ( files [ 0 ] ) ;
chk :
if ( data . Length ! = mga . Gifts [ index ] . Data . Length )
{
if ( index < 8 )
{
index = 8 ;
goto chk ;
}
{ Util . Alert ( "Can't set slot here." , $"{data.Length} != {mga.Gifts[index].Data.Length}, {mga.Gifts[index].GetType()}" , files [ 0 ] ) ; return ; }
}
mga . Gifts [ index ] . Data = data ;
setCardID ( mga . Gifts [ index ] . CardID ) ;
viewGiftData ( mga . Gifts [ index ] ) ;
2015-12-19 06:17:01 +00:00
}
else // Swap Data
{
// Check to see if they copied beyond blank slots.
if ( index > Math . Max ( wc_slot , lastUnfilled - 1 ) )
index = Math . Max ( wc_slot , lastUnfilled - 1 ) ;
2016-06-20 04:22:43 +00:00
MysteryGift s1 = mga . Gifts [ index ] ;
MysteryGift s2 = mga . Gifts [ wc_slot ] ;
if ( s1 . Data . Length ! = s2 . Data . Length )
{ Util . Alert ( "Can't swap these two slots." ) ; return ; }
mga . Gifts [ wc_slot ] = s1 ;
mga . Gifts [ index ] = s2 ;
2015-12-19 06:17:01 +00:00
}
2015-12-19 06:04:01 +00:00
setBackground ( index , Properties . Resources . slotView ) ;
2016-06-20 04:22:43 +00:00
setGiftBoxes ( ) ;
2015-12-18 05:15:40 +00:00
}
2015-12-19 06:04:01 +00:00
private void pbBoxSlot_DragEnter ( object sender , DragEventArgs e )
2015-12-18 05:15:40 +00:00
{
2015-12-19 06:04:01 +00:00
if ( e . AllowedEffect = = ( DragDropEffects . Copy | DragDropEffects . Link ) ) // external file
e . Effect = DragDropEffects . Copy ;
else if ( e . Data ! = null ) // within
e . Effect = DragDropEffects . Move ;
2015-12-18 05:15:40 +00:00
}
2015-12-19 06:17:01 +00:00
private int wc_slot = - 1 ;
2016-04-22 02:16:55 +00:00
2016-06-20 04:22:43 +00:00
private static Image getSprite ( MysteryGift gift )
2016-04-22 02:16:55 +00:00
{
2016-06-20 04:22:43 +00:00
Image img ;
if ( gift . IsPokémon )
img = PKX . getSprite ( gift . convertToPKM ( Main . SAV ) ) ;
else if ( gift . IsItem )
img = ( Image ) ( Properties . Resources . ResourceManager . GetObject ( "item_" + gift . Item ) ? ? Properties . Resources . unknown ) ;
else
img = Properties . Resources . unknown ;
if ( gift . GiftUsed )
img = Util . LayerImage ( new Bitmap ( img . Width , img . Height ) , img , 0 , 0 , 0.3 ) ;
return img ;
2016-04-22 02:16:55 +00:00
}
2016-06-20 04:22:43 +00:00
private static string getDescription ( MysteryGift gift )
2016-04-22 02:16:55 +00:00
{
2016-06-20 04:22:43 +00:00
if ( gift . Empty )
return "Empty Slot. No data!" ;
2016-04-22 02:16:55 +00:00
2016-06-20 04:22:43 +00:00
string s = gift . getCardHeader ( ) ;
if ( gift . IsItem )
{
s + = "Item: " + Main . itemlist [ gift . Item ] + Environment . NewLine + "Quantity: " + gift . Quantity ;
return s ;
}
if ( gift . IsPokémon )
{
PKM pk = gift . convertToPKM ( Main . SAV ) ;
2016-04-22 02:16:55 +00:00
2016-06-20 04:22:43 +00:00
try
2016-04-22 02:16:55 +00:00
{
2016-06-20 04:22:43 +00:00
s + = $"{Main.specieslist[pk.Species]} @ {Main.itemlist[pk.HeldItem]} --- " ;
s + = ( pk . IsEgg ? Main . eggname : $"{pk.OT_Name} - {pk.TID.ToString(" 00000 ")}/{pk.SID.ToString(" 00000 ")}" ) + Environment . NewLine ;
s + = $"{Main.movelist[pk.Move1]} / {Main.movelist[pk.Move2]} / {Main.movelist[pk.Move3]} / {Main.movelist[pk.Move4]}" + Environment . NewLine ;
2016-04-22 02:16:55 +00:00
}
2016-06-20 04:22:43 +00:00
catch { s + = "Unable to create gift description." ; }
return s ;
2016-04-22 02:16:55 +00:00
}
2016-06-20 04:22:43 +00:00
s + = "Unknown Wonder Card Type!" ;
return s ;
2016-04-22 02:16:55 +00:00
}
}
2014-12-15 00:50:15 +00:00
}