From 13e91cc9a13160d3e44f4b90e1b75d4c42740c48 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 20 Aug 2016 15:45:38 -0700 Subject: [PATCH 01/43] Fix super training translation names Update with correct control name --- PKHeX/Resources/text/de/lang_de.txt | 60 ++++++++++++------------- PKHeX/Resources/text/en/lang_en.txt | 60 ++++++++++++------------- PKHeX/Resources/text/es/lang_es.txt | 62 +++++++++++++------------- PKHeX/Resources/text/fr/lang_fr.txt | 60 ++++++++++++------------- PKHeX/Resources/text/it/lang_it.txt | 60 ++++++++++++------------- PKHeX/Resources/text/ja/lang_ja.txt | 60 ++++++++++++------------- PKHeX/Resources/text/ko/lang_ko.txt | 60 ++++++++++++------------- PKHeX/Resources/text/other/lang_pt.txt | 60 ++++++++++++------------- PKHeX/Resources/text/zh/lang_zh.txt | 60 ++++++++++++------------- 9 files changed, 271 insertions(+), 271 deletions(-) diff --git a/PKHeX/Resources/text/de/lang_de.txt b/PKHeX/Resources/text/de/lang_de.txt index 583b19513..407439b28 100644 --- a/PKHeX/Resources/text/de/lang_de.txt +++ b/PKHeX/Resources/text/de/lang_de.txt @@ -289,37 +289,37 @@ B_None = Remove All B_Cancel = Cancel B_Save = Save ------------------Super Training----------------------- -L_SuperTrain1_HP = Rang 1: KP -L_SuperTrain1_ATK = Rang 1: Atk -L_SuperTrain1_DEF = Rang 1: Def -L_SuperTrain1_SPA = Rang 1: SpA -L_SuperTrain1_SPD = Rang 1: SpD -L_SuperTrain1_SPE = Rang 1: Init -L_SuperTrain2_HP = Rang 2: KP -L_SuperTrain2_ATK = Rang 2: Atk -L_SuperTrain2_DEF = Rang 2: Def -L_SuperTrain2_SPA = Rang 2: SpA -L_SuperTrain2_SPD = Rang 2: SpD -L_SuperTrain2_SPE = Rang 2: Init -L_SuperTrain3_HP = Rang 3: HP -L_SuperTrain3_ATK = Rang 3: Atk -L_SuperTrain3_DEF = Rang 3: Def -L_SuperTrain3_SPA = Rang 3: SpA -L_SuperTrain3_SPD = Rang 3: SpD -L_SuperTrain3_SPE = Rang 3: Init +CHK_SuperTrain1_HP = Rang 1: KP +CHK_SuperTrain1_ATK = Rang 1: Atk +CHK_SuperTrain1_DEF = Rang 1: Def +CHK_SuperTrain1_SPA = Rang 1: SpA +CHK_SuperTrain1_SPD = Rang 1: SpD +CHK_SuperTrain1_SPE = Rang 1: Init +CHK_SuperTrain2_HP = Rang 2: KP +CHK_SuperTrain2_ATK = Rang 2: Atk +CHK_SuperTrain2_DEF = Rang 2: Def +CHK_SuperTrain2_SPA = Rang 2: SpA +CHK_SuperTrain2_SPD = Rang 2: SpD +CHK_SuperTrain2_SPE = Rang 2: Init +CHK_SuperTrain3_HP = Rang 3: HP +CHK_SuperTrain3_ATK = Rang 3: Atk +CHK_SuperTrain3_DEF = Rang 3: Def +CHK_SuperTrain3_SPA = Rang 3: SpA +CHK_SuperTrain3_SPD = Rang 3: SpD +CHK_SuperTrain3_SPE = Rang 3: Init CHK_Secret = Geheimtraining verfügbar -L_SuperTrain4_1 = Rang 4: Unheil -L_SuperTrain5_1 = Rang 5: Blattst. -L_SuperTrain5_2 = Rang 5: Feuerst. -L_SuperTrain5_3 = Rang 5: Wasserst. -L_SuperTrain5_4 = Rang 5: Beweg. Tore! -L_SuperTrain6_1 = Rang 6: 2. Halbzeit! -L_SuperTrain6_2 = Rang 6: 1. Haltzeit! -L_SuperTrain6_3 = Rang 6: Weitsch. -L_SuperTrain7_1 = Rang 7: Purmel -L_SuperTrain7_2 = Rang 7: Bit-Ballon-Barriere -L_SuperTrain7_3 = Rang 7: Blitz-K.O.! -L_SuperTrain8_1 = Rang 8: Pokémon X/Y +CHK_SuperTrain4_1 = Rang 4: Unheil +CHK_SuperTrain5_1 = Rang 5: Blattst. +CHK_SuperTrain5_2 = Rang 5: Feuerst. +CHK_SuperTrain5_3 = Rang 5: Wasserst. +CHK_SuperTrain5_4 = Rang 5: Beweg. Tore! +CHK_SuperTrain6_1 = Rang 6: 2. Halbzeit! +CHK_SuperTrain6_2 = Rang 6: 1. Haltzeit! +CHK_SuperTrain6_3 = Rang 6: Weitsch. +CHK_SuperTrain7_1 = Rang 7: Purmel +CHK_SuperTrain7_2 = Rang 7: Bit-Ballon-Barriere +CHK_SuperTrain7_3 = Rang 7: Blitz-K.O.! +CHK_SuperTrain8_1 = Rang 8: Pokémon X/Y --- L_Bag = Last Used Bag: L_Hits = Hits Remaining: diff --git a/PKHeX/Resources/text/en/lang_en.txt b/PKHeX/Resources/text/en/lang_en.txt index 38767962c..67fe2dc47 100644 --- a/PKHeX/Resources/text/en/lang_en.txt +++ b/PKHeX/Resources/text/en/lang_en.txt @@ -291,37 +291,37 @@ B_None = Remove All B_Cancel = Cancel B_Save = Save ------------------Super Training----------------------- -L_SuperTrain1_HP = Rank 1: HP -L_SuperTrain1_ATK = Rank 1: Atk -L_SuperTrain1_DEF = Rank 1: Def -L_SuperTrain1_SPA = Rank 1: SpA -L_SuperTrain1_SPD = Rank 1: SpD -L_SuperTrain1_SPE = Rank 1: Spe -L_SuperTrain2_HP = Rank 2: HP -L_SuperTrain2_ATK = Rank 2: Atk -L_SuperTrain2_DEF = Rank 2: Def -L_SuperTrain2_SPA = Rank 2: SpA -L_SuperTrain2_SPD = Rank 2: SpD -L_SuperTrain2_SPE = Rank 2: Spe -L_SuperTrain3_HP = Rank 3: HP -L_SuperTrain3_ATK = Rank 3: Atk -L_SuperTrain3_DEF = Rank 3: Def -L_SuperTrain3_SPA = Rank 3: SpA -L_SuperTrain3_SPD = Rank 3: SpD -L_SuperTrain3_SPE = Rank 3: Spe +CHK_SuperTrain1_HP = Rank 1: HP +CHK_SuperTrain1_ATK = Rank 1: Atk +CHK_SuperTrain1_DEF = Rank 1: Def +CHK_SuperTrain1_SPA = Rank 1: SpA +CHK_SuperTrain1_SPD = Rank 1: SpD +CHK_SuperTrain1_SPE = Rank 1: Spe +CHK_SuperTrain2_HP = Rank 2: HP +CHK_SuperTrain2_ATK = Rank 2: Atk +CHK_SuperTrain2_DEF = Rank 2: Def +CHK_SuperTrain2_SPA = Rank 2: SpA +CHK_SuperTrain2_SPD = Rank 2: SpD +CHK_SuperTrain2_SPE = Rank 2: Spe +CHK_SuperTrain3_HP = Rank 3: HP +CHK_SuperTrain3_ATK = Rank 3: Atk +CHK_SuperTrain3_DEF = Rank 3: Def +CHK_SuperTrain3_SPA = Rank 3: SpA +CHK_SuperTrain3_SPD = Rank 3: SpD +CHK_SuperTrain3_SPE = Rank 3: Spe CHK_Secret = Secret Training Enabled -L_SuperTrain4_1 = Rank 4: Troubles -L_SuperTrain5_1 = Rank 5: Leaf -L_SuperTrain5_2 = Rank 5: Fire -L_SuperTrain5_3 = Rank 5: Water -L_SuperTrain5_4 = Rank 5: Fleeing -L_SuperTrain6_1 = Rank 6: Second -L_SuperTrain6_2 = Rank 6: Quick -L_SuperTrain6_3 = Rank 6: Long -L_SuperTrain7_1 = Rank 7: Scatter -L_SuperTrain7_2 = Rank 7: Barrage -L_SuperTrain7_3 = Rank 7: Hydreigon -L_SuperTrain8_1 = Rank 8: Best +CHK_SuperTrain4_1 = Rank 4: Troubles +CHK_SuperTrain5_1 = Rank 5: Leaf +CHK_SuperTrain5_2 = Rank 5: Fire +CHK_SuperTrain5_3 = Rank 5: Water +CHK_SuperTrain5_4 = Rank 5: Fleeing +CHK_SuperTrain6_1 = Rank 6: Second +CHK_SuperTrain6_2 = Rank 6: Quick +CHK_SuperTrain6_3 = Rank 6: Long +CHK_SuperTrain7_1 = Rank 7: Scatter +CHK_SuperTrain7_2 = Rank 7: Barrage +CHK_SuperTrain7_3 = Rank 7: Hydreigon +CHK_SuperTrain8_1 = Rank 8: Best --- L_Bag = Last Used Bag: L_Hits = Hits Remaining: diff --git a/PKHeX/Resources/text/es/lang_es.txt b/PKHeX/Resources/text/es/lang_es.txt index cb6ae5d36..916db7d46 100644 --- a/PKHeX/Resources/text/es/lang_es.txt +++ b/PKHeX/Resources/text/es/lang_es.txt @@ -291,38 +291,38 @@ B_None = Quitar todos B_Cancel = Cancelar B_Save = Guardar ------------------Super Training----------------------- -L_SuperTraining = Superentrenamiento Normal -L_SuperTrain1_HP = Nv. 1: PS -L_SuperTrain1_ATK = Nv. 1: Atq -L_SuperTrain1_DEF = Nv. 1: Def -L_SuperTrain1_SPA = Nv. 1: AtE -L_SuperTrain1_SPD = Nv. 1: DfE -L_SuperTrain1_SPE = Nv. 1: Vel -L_SuperTrain2_HP = Nv. 2: PS -L_SuperTrain2_ATK = Nv. 2: Atq -L_SuperTrain2_DEF = Nv. 2: Def -L_SuperTrain2_SPA = Nv. 2: AtE -L_SuperTrain2_SPD = Nv. 2: DfE -L_SuperTrain2_SPE = Nv. 2: Vel -L_SuperTrain3_HP = Nv. 3: PS -L_SuperTrain3_ATK = Nv. 3: Atq -L_SuperTrain3_DEF = Nv. 3: Def -L_SuperTrain3_SPA = Nv. 3: AtE -L_SuperTrain3_SPD = Nv. 3: DfE -L_SuperTrain3_SPE = Nv. 3: Vel +CHK_SuperTraining = Superentrenamiento Normal +CHK_SuperTrain1_HP = Nv. 1: PS +CHK_SuperTrain1_ATK = Nv. 1: Atq +CHK_SuperTrain1_DEF = Nv. 1: Def +CHK_SuperTrain1_SPA = Nv. 1: AtE +CHK_SuperTrain1_SPD = Nv. 1: DfE +CHK_SuperTrain1_SPE = Nv. 1: Vel +CHK_SuperTrain2_HP = Nv. 2: PS +CHK_SuperTrain2_ATK = Nv. 2: Atq +CHK_SuperTrain2_DEF = Nv. 2: Def +CHK_SuperTrain2_SPA = Nv. 2: AtE +CHK_SuperTrain2_SPD = Nv. 2: DfE +CHK_SuperTrain2_SPE = Nv. 2: Vel +CHK_SuperTrain3_HP = Nv. 3: PS +CHK_SuperTrain3_ATK = Nv. 3: Atq +CHK_SuperTrain3_DEF = Nv. 3: Def +CHK_SuperTrain3_SPA = Nv. 3: AtE +CHK_SuperTrain3_SPD = Nv. 3: DfE +CHK_SuperTrain3_SPE = Nv. 3: Vel CHK_Secret = Superentrenamiento -L_SuperTrain4_1 = Nv. 4: Dificultad tras otra -L_SuperTrain5_1 = Nv. 5: Hoja -L_SuperTrain5_2 = Nv. 5: Fuego -L_SuperTrain5_3 = Nv. 5: Agua -L_SuperTrain5_4 = Nv. 5: Evasivas -L_SuperTrain6_1 = Nv. 6: Contraataque -L_SuperTrain6_2 = Nv. 6: Agilidad -L_SuperTrain6_3 = Nv. 6: Ristras -L_SuperTrain7_1 = Nv. 7: Scatterbug -L_SuperTrain7_2 = Nv. 7: Bombardeo -L_SuperTrain7_3 = Nv. 7: Hydreigon -L_SuperTrain8_1 = Nv. 8: X/Y +CHK_SuperTrain4_1 = Nv. 4: Dificultad tras otra +CHK_SuperTrain5_1 = Nv. 5: Hoja +CHK_SuperTrain5_2 = Nv. 5: Fuego +CHK_SuperTrain5_3 = Nv. 5: Agua +CHK_SuperTrain5_4 = Nv. 5: Evasivas +CHK_SuperTrain6_1 = Nv. 6: Contraataque +CHK_SuperTrain6_2 = Nv. 6: Agilidad +CHK_SuperTrain6_3 = Nv. 6: Ristras +CHK_SuperTrain7_1 = Nv. 7: Scatterbug +CHK_SuperTrain7_2 = Nv. 7: Bombardeo +CHK_SuperTrain7_3 = Nv. 7: Hydreigon +CHK_SuperTrain8_1 = Nv. 8: X/Y --- L_Bag = Último saco usado: L_Hits = Golpes restantes: diff --git a/PKHeX/Resources/text/fr/lang_fr.txt b/PKHeX/Resources/text/fr/lang_fr.txt index 3eb8c9291..4c5974a69 100644 --- a/PKHeX/Resources/text/fr/lang_fr.txt +++ b/PKHeX/Resources/text/fr/lang_fr.txt @@ -290,37 +290,37 @@ B_None = Remove All B_Cancel = Cancel B_Save = Save ------------------Super Training----------------------- -L_SuperTrain1_HP = Rang 1: PV -L_SuperTrain1_ATK = Rang 1: Attq. -L_SuperTrain1_DEF = Rang 1: Déf. -L_SuperTrain1_SPA = Rang 1: A. Spé. -L_SuperTrain1_SPD = Rang 1: D. Spé. -L_SuperTrain1_SPE = Rang 1: Vit. -L_SuperTrain2_HP = Rang 2: PV -L_SuperTrain2_ATK = Rang 2: Attq. -L_SuperTrain2_DEF = Rang 2: Déf. -L_SuperTrain2_SPA = Rang 2: A. Spé. -L_SuperTrain2_SPD = Rang 2: D. Spé. -L_SuperTrain2_SPE = Rang 2: Vit. -L_SuperTrain3_HP = Rang 3: PV -L_SuperTrain3_ATK = Rang 3: Attq. -L_SuperTrain3_DEF = Rang 3: Déf. -L_SuperTrain3_SPA = Rang 3: A. Spé. -L_SuperTrain3_SPD = Rang 3: D. Spé. -L_SuperTrain3_SPE = Rang 3: Vit. +CHK_SuperTrain1_HP = Rang 1: PV +CHK_SuperTrain1_ATK = Rang 1: Attq. +CHK_SuperTrain1_DEF = Rang 1: Déf. +CHK_SuperTrain1_SPA = Rang 1: A. Spé. +CHK_SuperTrain1_SPD = Rang 1: D. Spé. +CHK_SuperTrain1_SPE = Rang 1: Vit. +CHK_SuperTrain2_HP = Rang 2: PV +CHK_SuperTrain2_ATK = Rang 2: Attq. +CHK_SuperTrain2_DEF = Rang 2: Déf. +CHK_SuperTrain2_SPA = Rang 2: A. Spé. +CHK_SuperTrain2_SPD = Rang 2: D. Spé. +CHK_SuperTrain2_SPE = Rang 2: Vit. +CHK_SuperTrain3_HP = Rang 3: PV +CHK_SuperTrain3_ATK = Rang 3: Attq. +CHK_SuperTrain3_DEF = Rang 3: Déf. +CHK_SuperTrain3_SPA = Rang 3: A. Spé. +CHK_SuperTrain3_SPD = Rang 3: D. Spé. +CHK_SuperTrain3_SPE = Rang 3: Vit. CHK_Secret = Entraînement Secret Activé -L_SuperTrain4_1 = Rang 4: Troubles -L_SuperTrain5_1 = Rang 5: Plante -L_SuperTrain5_2 = Rang 5: Feu -L_SuperTrain5_3 = Rang 5: Eau -L_SuperTrain5_4 = Rang 5: Cibles Fuyantes -L_SuperTrain6_1 = Rang 6: Riposte -L_SuperTrain6_2 = Rang 6: Rapide -L_SuperTrain6_3 = Rang 6: Longue -L_SuperTrain7_1 = Rang 7: Lépidonille -L_SuperTrain7_2 = Rang 7: Ballon Pixel -L_SuperTrain7_3 = Rang 7: Trioxhydre -L_SuperTrain8_1 = Rang 8: X / Y +CHK_SuperTrain4_1 = Rang 4: Troubles +CHK_SuperTrain5_1 = Rang 5: Plante +CHK_SuperTrain5_2 = Rang 5: Feu +CHK_SuperTrain5_3 = Rang 5: Eau +CHK_SuperTrain5_4 = Rang 5: Cibles Fuyantes +CHK_SuperTrain6_1 = Rang 6: Riposte +CHK_SuperTrain6_2 = Rang 6: Rapide +CHK_SuperTrain6_3 = Rang 6: Longue +CHK_SuperTrain7_1 = Rang 7: Lépidonille +CHK_SuperTrain7_2 = Rang 7: Ballon Pixel +CHK_SuperTrain7_3 = Rang 7: Trioxhydre +CHK_SuperTrain8_1 = Rang 8: X / Y --- L_Bag = Last Used Bag: L_Hits = Hits Remaining: diff --git a/PKHeX/Resources/text/it/lang_it.txt b/PKHeX/Resources/text/it/lang_it.txt index 192f8e996..e3c1ccb30 100644 --- a/PKHeX/Resources/text/it/lang_it.txt +++ b/PKHeX/Resources/text/it/lang_it.txt @@ -291,37 +291,37 @@ B_None = Remove All B_Cancel = Cancel B_Save = Save ------------------Super Training----------------------- -L_SuperTrain1_HP = Rank 1: HP -L_SuperTrain1_ATK = Rank 1: Atk -L_SuperTrain1_DEF = Rank 1: Def -L_SuperTrain1_SPA = Rank 1: SpA -L_SuperTrain1_SPD = Rank 1: SpD -L_SuperTrain1_SPE = Rank 1: Spe -L_SuperTrain2_HP = Rank 2: HP -L_SuperTrain2_ATK = Rank 2: Atk -L_SuperTrain2_DEF = Rank 2: Def -L_SuperTrain2_SPA = Rank 2: SpA -L_SuperTrain2_SPD = Rank 2: SpD -L_SuperTrain2_SPE = Rank 2: Spe -L_SuperTrain3_HP = Rank 3: HP -L_SuperTrain3_ATK = Rank 3: Atk -L_SuperTrain3_DEF = Rank 3: Def -L_SuperTrain3_SPA = Rank 3: SpA -L_SuperTrain3_SPD = Rank 3: SpD -L_SuperTrain3_SPE = Rank 3: Spe +CHK_SuperTrain1_HP = Rank 1: HP +CHK_SuperTrain1_ATK = Rank 1: Atk +CHK_SuperTrain1_DEF = Rank 1: Def +CHK_SuperTrain1_SPA = Rank 1: SpA +CHK_SuperTrain1_SPD = Rank 1: SpD +CHK_SuperTrain1_SPE = Rank 1: Spe +CHK_SuperTrain2_HP = Rank 2: HP +CHK_SuperTrain2_ATK = Rank 2: Atk +CHK_SuperTrain2_DEF = Rank 2: Def +CHK_SuperTrain2_SPA = Rank 2: SpA +CHK_SuperTrain2_SPD = Rank 2: SpD +CHK_SuperTrain2_SPE = Rank 2: Spe +CHK_SuperTrain3_HP = Rank 3: HP +CHK_SuperTrain3_ATK = Rank 3: Atk +CHK_SuperTrain3_DEF = Rank 3: Def +CHK_SuperTrain3_SPA = Rank 3: SpA +CHK_SuperTrain3_SPD = Rank 3: SpD +CHK_SuperTrain3_SPE = Rank 3: Spe CHK_Secret = Secret Training Enabled -L_SuperTrain4_1 = Rank 4: Troubles -L_SuperTrain5_1 = Rank 5: Leaf -L_SuperTrain5_2 = Rank 5: Fire -L_SuperTrain5_3 = Rank 5: Water -L_SuperTrain5_4 = Rank 5: Fleeing -L_SuperTrain6_1 = Rank 6: Second -L_SuperTrain6_2 = Rank 6: Quick -L_SuperTrain6_3 = Rank 6: Long -L_SuperTrain7_1 = Rank 7: Scatter -L_SuperTrain7_2 = Rank 7: Barrage -L_SuperTrain7_3 = Rank 7: Hydreigon -L_SuperTrain8_1 = Rank 8: Best +CHK_SuperTrain4_1 = Rank 4: Troubles +CHK_SuperTrain5_1 = Rank 5: Leaf +CHK_SuperTrain5_2 = Rank 5: Fire +CHK_SuperTrain5_3 = Rank 5: Water +CHK_SuperTrain5_4 = Rank 5: Fleeing +CHK_SuperTrain6_1 = Rank 6: Second +CHK_SuperTrain6_2 = Rank 6: Quick +CHK_SuperTrain6_3 = Rank 6: Long +CHK_SuperTrain7_1 = Rank 7: Scatter +CHK_SuperTrain7_2 = Rank 7: Barrage +CHK_SuperTrain7_3 = Rank 7: Hydreigon +CHK_SuperTrain8_1 = Rank 8: Best --- L_Bag = Last Used Bag: L_Hits = Hits Remaining: diff --git a/PKHeX/Resources/text/ja/lang_ja.txt b/PKHeX/Resources/text/ja/lang_ja.txt index 3b4a52354..5aebea89f 100644 --- a/PKHeX/Resources/text/ja/lang_ja.txt +++ b/PKHeX/Resources/text/ja/lang_ja.txt @@ -290,37 +290,37 @@ B_None = Remove All B_Cancel = Cancel B_Save = Save ------------------Super Training----------------------- -L_SuperTrain1_HP = ランク1: HP -L_SuperTrain1_ATK = ランク1: 攻撃 -L_SuperTrain1_DEF = ランク1: 防御 -L_SuperTrain1_SPA = ランク1: 特攻 -L_SuperTrain1_SPD = ランク1: 特防 -L_SuperTrain1_SPE = ランク1: 素早さ -L_SuperTrain2_HP = ランク2: HP -L_SuperTrain2_ATK = ランク2: 攻撃 -L_SuperTrain2_DEF = ランク2: 防御 -L_SuperTrain2_SPA = ランク2: 特攻 -L_SuperTrain2_SPD = ランク2: 特防 -L_SuperTrain2_SPE = ランク2: 素早さ -L_SuperTrain3_HP = ランク3: HP -L_SuperTrain3_ATK = ランク3: 攻撃 -L_SuperTrain3_DEF = ランク3: 防御 -L_SuperTrain3_SPA = ランク3: 特攻 -L_SuperTrain3_SPD = ランク3: 特防 -L_SuperTrain3_SPE = ランク3: 素早さ +CHK_SuperTrain1_HP = ランク1: HP +CHK_SuperTrain1_ATK = ランク1: 攻撃 +CHK_SuperTrain1_DEF = ランク1: 防御 +CHK_SuperTrain1_SPA = ランク1: 特攻 +CHK_SuperTrain1_SPD = ランク1: 特防 +CHK_SuperTrain1_SPE = ランク1: 素早さ +CHK_SuperTrain2_HP = ランク2: HP +CHK_SuperTrain2_ATK = ランク2: 攻撃 +CHK_SuperTrain2_DEF = ランク2: 防御 +CHK_SuperTrain2_SPA = ランク2: 特攻 +CHK_SuperTrain2_SPD = ランク2: 特防 +CHK_SuperTrain2_SPE = ランク2: 素早さ +CHK_SuperTrain3_HP = ランク3: HP +CHK_SuperTrain3_ATK = ランク3: 攻撃 +CHK_SuperTrain3_DEF = ランク3: 防御 +CHK_SuperTrain3_SPA = ランク3: 特攻 +CHK_SuperTrain3_SPD = ランク3: 特防 +CHK_SuperTrain3_SPE = ランク3: 素早さ CHK_Secret = 秘密の訓練 -L_SuperTrain4_1 = ランク4: Troubles -L_SuperTrain5_1 = ランク5: Leaf -L_SuperTrain5_2 = ランク5: Fire -L_SuperTrain5_3 = ランク5: Water -L_SuperTrain5_4 = ランク5: Fleeing -L_SuperTrain6_1 = ランク6: Second -L_SuperTrain6_2 = ランク6: Quick -L_SuperTrain6_3 = ランク6: Long -L_SuperTrain7_1 = ランク7: Scatter -L_SuperTrain7_2 = ランク7: Barrage -L_SuperTrain7_3 = ランク7: Hydreigon -L_SuperTrain8_1 = ランク8: X/Y +CHK_SuperTrain4_1 = ランク4: Troubles +CHK_SuperTrain5_1 = ランク5: Leaf +CHK_SuperTrain5_2 = ランク5: Fire +CHK_SuperTrain5_3 = ランク5: Water +CHK_SuperTrain5_4 = ランク5: Fleeing +CHK_SuperTrain6_1 = ランク6: Second +CHK_SuperTrain6_2 = ランク6: Quick +CHK_SuperTrain6_3 = ランク6: Long +CHK_SuperTrain7_1 = ランク7: Scatter +CHK_SuperTrain7_2 = ランク7: Barrage +CHK_SuperTrain7_3 = ランク7: Hydreigon +CHK_SuperTrain8_1 = ランク8: X/Y --- L_Bag = Last Used Bag: L_Hits = Hits Remaining: diff --git a/PKHeX/Resources/text/ko/lang_ko.txt b/PKHeX/Resources/text/ko/lang_ko.txt index 25078380f..c66077b15 100644 --- a/PKHeX/Resources/text/ko/lang_ko.txt +++ b/PKHeX/Resources/text/ko/lang_ko.txt @@ -291,37 +291,37 @@ B_None = Remove All B_Cancel = Cancel B_Save = Save ------------------Super Training----------------------- -L_SuperTrain1_HP = 랭크 1: HP(체력) -L_SuperTrain1_ATK = 랭크 1: Atk(공격) -L_SuperTrain1_DEF = 랭크 1: Def(방어) -L_SuperTrain1_SPA = 랭크 1: SpA(특공) -L_SuperTrain1_SPD = 랭크 1: SpD(특방) -L_SuperTrain1_SPE = 랭크 1: Spe(스피드) -L_SuperTrain2_HP = 랭크 2: HP(체력) -L_SuperTrain2_ATK = 랭크 2: Atk(공격) -L_SuperTrain2_DEF = 랭크 2: Def(방어) -L_SuperTrain2_SPA = 랭크 2: SpA(특공) -L_SuperTrain2_SPD = 랭크 2: SpD(특방) -L_SuperTrain2_SPE = 랭크 2: Spe(스피드) -L_SuperTrain3_HP = 랭크 3: HP(체력) -L_SuperTrain3_ATK = 랭크 3: Atk(공격) -L_SuperTrain3_DEF = 랭크 3: Def(방어) -L_SuperTrain3_SPA = 랭크 3: SpA(특공) -L_SuperTrain3_SPD = 랭크 3: SpD(특방) -L_SuperTrain3_SPE = 랭크 3: Spe(스피드) +CHK_SuperTrain1_HP = 랭크 1: HP(체력) +CHK_SuperTrain1_ATK = 랭크 1: Atk(공격) +CHK_SuperTrain1_DEF = 랭크 1: Def(방어) +CHK_SuperTrain1_SPA = 랭크 1: SpA(특공) +CHK_SuperTrain1_SPD = 랭크 1: SpD(특방) +CHK_SuperTrain1_SPE = 랭크 1: Spe(스피드) +CHK_SuperTrain2_HP = 랭크 2: HP(체력) +CHK_SuperTrain2_ATK = 랭크 2: Atk(공격) +CHK_SuperTrain2_DEF = 랭크 2: Def(방어) +CHK_SuperTrain2_SPA = 랭크 2: SpA(특공) +CHK_SuperTrain2_SPD = 랭크 2: SpD(특방) +CHK_SuperTrain2_SPE = 랭크 2: Spe(스피드) +CHK_SuperTrain3_HP = 랭크 3: HP(체력) +CHK_SuperTrain3_ATK = 랭크 3: Atk(공격) +CHK_SuperTrain3_DEF = 랭크 3: Def(방어) +CHK_SuperTrain3_SPA = 랭크 3: SpA(특공) +CHK_SuperTrain3_SPD = 랭크 3: SpD(특방) +CHK_SuperTrain3_SPE = 랭크 3: Spe(스피드) CHK_Secret = 비밀 트레이닝 활성화 -L_SuperTrain4_1 = 랭크 4: Troubles -L_SuperTrain5_1 = 랭크 5: 풀 -L_SuperTrain5_2 = 랭크 5: 불 -L_SuperTrain5_3 = 랭크 5: 물 -L_SuperTrain5_4 = 랭크 5: Fleeing -L_SuperTrain6_1 = 랭크 6: Second -L_SuperTrain6_2 = 랭크 6: Quick -L_SuperTrain6_3 = 랭크 6: Long -L_SuperTrain7_1 = 랭크 7: Scatter -L_SuperTrain7_2 = 랭크 7: Barrage -L_SuperTrain7_3 = 랭크 7: Hydreigon -L_SuperTrain8_1 = 랭크 8: 베스트 +CHK_SuperTrain4_1 = 랭크 4: Troubles +CHK_SuperTrain5_1 = 랭크 5: 풀 +CHK_SuperTrain5_2 = 랭크 5: 불 +CHK_SuperTrain5_3 = 랭크 5: 물 +CHK_SuperTrain5_4 = 랭크 5: Fleeing +CHK_SuperTrain6_1 = 랭크 6: Second +CHK_SuperTrain6_2 = 랭크 6: Quick +CHK_SuperTrain6_3 = 랭크 6: Long +CHK_SuperTrain7_1 = 랭크 7: Scatter +CHK_SuperTrain7_2 = 랭크 7: Barrage +CHK_SuperTrain7_3 = 랭크 7: Hydreigon +CHK_SuperTrain8_1 = 랭크 8: 베스트 --- L_Bag = Last Used Bag: L_Hits = Hits Remaining: diff --git a/PKHeX/Resources/text/other/lang_pt.txt b/PKHeX/Resources/text/other/lang_pt.txt index ef08a5fe5..105e8aa93 100644 --- a/PKHeX/Resources/text/other/lang_pt.txt +++ b/PKHeX/Resources/text/other/lang_pt.txt @@ -291,37 +291,37 @@ B_None = Remove All B_Cancel = Cancel B_Save = Save ------------------Super Training----------------------- -L_SuperTrain1_HP = Rank 1: HP -L_SuperTrain1_ATK = Rank 1: Atk -L_SuperTrain1_DEF = Rank 1: Def -L_SuperTrain1_SPA = Rank 1: SpA -L_SuperTrain1_SPD = Rank 1: SpD -L_SuperTrain1_SPE = Rank 1: Spe -L_SuperTrain2_HP = Rank 2: HP -L_SuperTrain2_ATK = Rank 2: Atk -L_SuperTrain2_DEF = Rank 2: Def -L_SuperTrain2_SPA = Rank 2: SpA -L_SuperTrain2_SPD = Rank 2: SpD -L_SuperTrain2_SPE = Rank 2: Spe -L_SuperTrain3_HP = Rank 3: HP -L_SuperTrain3_ATK = Rank 3: Atk -L_SuperTrain3_DEF = Rank 3: Def -L_SuperTrain3_SPA = Rank 3: SpA -L_SuperTrain3_SPD = Rank 3: SpD -L_SuperTrain3_SPE = Rank 3: Spe +CHK_SuperTrain1_HP = Rank 1: HP +CHK_SuperTrain1_ATK = Rank 1: Atk +CHK_SuperTrain1_DEF = Rank 1: Def +CHK_SuperTrain1_SPA = Rank 1: SpA +CHK_SuperTrain1_SPD = Rank 1: SpD +CHK_SuperTrain1_SPE = Rank 1: Spe +CHK_SuperTrain2_HP = Rank 2: HP +CHK_SuperTrain2_ATK = Rank 2: Atk +CHK_SuperTrain2_DEF = Rank 2: Def +CHK_SuperTrain2_SPA = Rank 2: SpA +CHK_SuperTrain2_SPD = Rank 2: SpD +CHK_SuperTrain2_SPE = Rank 2: Spe +CHK_SuperTrain3_HP = Rank 3: HP +CHK_SuperTrain3_ATK = Rank 3: Atk +CHK_SuperTrain3_DEF = Rank 3: Def +CHK_SuperTrain3_SPA = Rank 3: SpA +CHK_SuperTrain3_SPD = Rank 3: SpD +CHK_SuperTrain3_SPE = Rank 3: Spe CHK_Secret = Super Treino Activado -L_SuperTrain4_1 = Rank 4: Problemas -L_SuperTrain5_1 = Rank 5: Erva -L_SuperTrain5_2 = Rank 5: Fogo -L_SuperTrain5_3 = Rank 5: Água -L_SuperTrain5_4 = Rank 5: Fugir -L_SuperTrain6_1 = Rank 6: Segundo -L_SuperTrain6_2 = Rank 6: Rápido -L_SuperTrain6_3 = Rank 6: Longo -L_SuperTrain7_1 = Rank 7: Dispersar -L_SuperTrain7_2 = Rank 7: Barragem -L_SuperTrain7_3 = Rank 7: Hydreigon -L_SuperTrain8_1 = Rank 8: Melhor +CHK_SuperTrain4_1 = Rank 4: Problemas +CHK_SuperTrain5_1 = Rank 5: Erva +CHK_SuperTrain5_2 = Rank 5: Fogo +CHK_SuperTrain5_3 = Rank 5: Água +CHK_SuperTrain5_4 = Rank 5: Fugir +CHK_SuperTrain6_1 = Rank 6: Segundo +CHK_SuperTrain6_2 = Rank 6: Rápido +CHK_SuperTrain6_3 = Rank 6: Longo +CHK_SuperTrain7_1 = Rank 7: Dispersar +CHK_SuperTrain7_2 = Rank 7: Barragem +CHK_SuperTrain7_3 = Rank 7: Hydreigon +CHK_SuperTrain8_1 = Rank 8: Melhor --- L_Bag = Última Mochila Utilizada: L_Hits = Pancadas de Sobra: diff --git a/PKHeX/Resources/text/zh/lang_zh.txt b/PKHeX/Resources/text/zh/lang_zh.txt index f9f41eee0..08fb9c463 100644 --- a/PKHeX/Resources/text/zh/lang_zh.txt +++ b/PKHeX/Resources/text/zh/lang_zh.txt @@ -291,37 +291,37 @@ B_None = 全部清除 B_Cancel = 取消 B_Save = 保存 ------------------Super Training----------------------- -L_SuperTrain1_HP = 等级1: HP -L_SuperTrain1_ATK = 等级1: 攻击 -L_SuperTrain1_DEF = 等级1: 防御 -L_SuperTrain1_SPA = 等级1: 特攻 -L_SuperTrain1_SPD = 等级1: 特防 -L_SuperTrain1_SPE = 等级1: 速度 -L_SuperTrain2_HP = 等级2: HP -L_SuperTrain2_ATK = 等级2: 攻击 -L_SuperTrain2_DEF = 等级2: 防御 -L_SuperTrain2_SPA = 等级2: 特攻 -L_SuperTrain2_SPD = 等级2: 特防 -L_SuperTrain2_SPE = 等级2: 速度 -L_SuperTrain3_HP = 等级3: HP -L_SuperTrain3_ATK = 等级3: 攻击 -L_SuperTrain3_DEF = 等级3: 防御 -L_SuperTrain3_SPA = 等级3: 特攻 -L_SuperTrain3_SPD = 等级3: 特防 -L_SuperTrain3_SPE = 等级3: 速度 +CHK_SuperTrain1_HP = 等级1: HP +CHK_SuperTrain1_ATK = 等级1: 攻击 +CHK_SuperTrain1_DEF = 等级1: 防御 +CHK_SuperTrain1_SPA = 等级1: 特攻 +CHK_SuperTrain1_SPD = 等级1: 特防 +CHK_SuperTrain1_SPE = 等级1: 速度 +CHK_SuperTrain2_HP = 等级2: HP +CHK_SuperTrain2_ATK = 等级2: 攻击 +CHK_SuperTrain2_DEF = 等级2: 防御 +CHK_SuperTrain2_SPA = 等级2: 特攻 +CHK_SuperTrain2_SPD = 等级2: 特防 +CHK_SuperTrain2_SPE = 等级2: 速度 +CHK_SuperTrain3_HP = 等级3: HP +CHK_SuperTrain3_ATK = 等级3: 攻击 +CHK_SuperTrain3_DEF = 等级3: 防御 +CHK_SuperTrain3_SPA = 等级3: 特攻 +CHK_SuperTrain3_SPD = 等级3: 特防 +CHK_SuperTrain3_SPE = 等级3: 速度 CHK_Secret = 秘密训练开启 -L_SuperTrain4_1 = 等级4: 困境 -L_SuperTrain5_1 = 等级5: 草之石 -L_SuperTrain5_2 = 等级5: 火之石 -L_SuperTrain5_3 = 等级5: 水之石 -L_SuperTrain5_4 = 等级5: 逃跑 -L_SuperTrain6_1 = 等级6: 反击战 -L_SuperTrain6_2 = 等级6: 速攻战 -L_SuperTrain6_3 = 等级6: 远距离 -L_SuperTrain7_1 = 等级7: 逆袭粉蛹 -L_SuperTrain7_2 = 等级7: 小气球 -L_SuperTrain7_3 = 等级7: 三头龙 -L_SuperTrain8_1 = 等级8: 最强之战 +CHK_SuperTrain4_1 = 等级4: 困境 +CHK_SuperTrain5_1 = 等级5: 草之石 +CHK_SuperTrain5_2 = 等级5: 火之石 +CHK_SuperTrain5_3 = 等级5: 水之石 +CHK_SuperTrain5_4 = 等级5: 逃跑 +CHK_SuperTrain6_1 = 等级6: 反击战 +CHK_SuperTrain6_2 = 等级6: 速攻战 +CHK_SuperTrain6_3 = 等级6: 远距离 +CHK_SuperTrain7_1 = 等级7: 逆袭粉蛹 +CHK_SuperTrain7_2 = 等级7: 小气球 +CHK_SuperTrain7_3 = 等级7: 三头龙 +CHK_SuperTrain8_1 = 等级8: 最强之战 --- L_Bag = 上一次使用物品: L_Hits = 剩余点数: From 137f341e3774d97767d9a9b7569b44b74490543b Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 21 Aug 2016 00:17:45 -0700 Subject: [PATCH 02/43] Improve dragdrop to use sprites Set cursor to slot sprite and 'pick up' the image, restore if not moved. Drag&Drop GiveFeedback overrident to false to prevent the 'dragdrop' cursor override. Set the tabmain effect to Copy instead of Move so that everything behaves! --- PKHeX/MainWindow/Main.cs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 6e413c97c..f14c9a424 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -54,7 +54,10 @@ namespace PKHeX foreach (PictureBox pb in PAN_Box.Controls) { pb.AllowDrop = true; // The PictureBoxes have their own drag&drop event handlers (pbBoxSlot) + pb.GiveFeedback += (sender, e) => { e.UseDefaultCursors = false; }; } + dragout.GiveFeedback += (sender, e) => { e.UseDefaultCursors = false; }; + GiveFeedback += (sender, e) => { e.UseDefaultCursors = false; }; foreach (TabPage tab in tabMain.TabPages) { tab.AllowDrop = true; @@ -2440,6 +2443,7 @@ namespace PKHeX { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); openQuick(files[0]); + e.Effect = DragDropEffects.Copy; } // Decrypted Export private void dragout_MouseDown(object sender, MouseEventArgs e) @@ -2461,10 +2465,13 @@ namespace PKHeX try { File.WriteAllBytes(newfile, dragdata); + PictureBox pb = (PictureBox)sender; + Cursor.Current = new Cursor(((Bitmap)pb.Image).GetHicon()); DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); } catch (Exception x) { Util.Error("Drag & Drop Error", x.ToString()); } + Cursor.Current = DefaultCursor; File.Delete(newfile); } private void dragout_DragOver(object sender, DragEventArgs e) @@ -2482,7 +2489,9 @@ namespace PKHeX } private void dragoutDrop(object sender, DragEventArgs e) { - openQuick(((string[])e.Data.GetData(DataFormats.FileDrop))[0]); + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); + openQuick(files[0]); + e.Effect = DragDropEffects.Copy; } #endregion @@ -3323,13 +3332,14 @@ namespace PKHeX // and use that file to perform a drag drop operation. // Abort if there is no Pokemon in the given slot. - if (((PictureBox)sender).Image == null) + PictureBox pb = (PictureBox)sender; + if (pb.Image == null) return; // Set flag to prevent re-entering. slotDragDropInProgress = true; - slotSourceSlotNumber = getSlot(sender); + slotSourceSlotNumber = getSlot(pb); int offset = getPKXOffset(slotSourceSlotNumber); // Prepare Data @@ -3347,14 +3357,22 @@ namespace PKHeX try { File.WriteAllBytes(newfile, dragdata); + var img = (Bitmap)pb.Image; + Cursor.Current = new Cursor(img.GetHicon()); + pb.Image = null; // Thread Blocks on DoDragDrop - ((PictureBox)sender).DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); + DragDropEffects result = pb.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); + if (result == DragDropEffects.None || result == DragDropEffects.Copy) // not dropped to another box slot, restore img + pb.Image = img; + if (result == DragDropEffects.Copy) // viewed in tabs, apply 'view' highlight + getSlotColor(slotSourceSlotNumber, Properties.Resources.slotView); } catch (Exception x) { Util.Error("Drag & Drop Error:", x.ToString()); } slotSourceOffset = 0; + Cursor.Current = DefaultCursor; // Browser apps need time to load data since the file isn't moved to a location on the user's local storage. // Tested 10ms -> too quick, 100ms was fine. 500ms should be safe? From 81451a57e53d8273bafb79778f7c78799b15f65f Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 21 Aug 2016 00:23:07 -0700 Subject: [PATCH 03/43] Colorize dragdrop source slot on drag Semi-transparent grey; instead of the sprite disappearing, the slot will indicate "hey something's happening to my contents" --- PKHeX/MainWindow/Main.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index f14c9a424..a0c968548 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -3360,12 +3360,14 @@ namespace PKHeX var img = (Bitmap)pb.Image; Cursor.Current = new Cursor(img.GetHicon()); pb.Image = null; + pb.BackColor = Color.FromArgb(100, 200, 200, 200); // Thread Blocks on DoDragDrop DragDropEffects result = pb.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); if (result == DragDropEffects.None || result == DragDropEffects.Copy) // not dropped to another box slot, restore img pb.Image = img; if (result == DragDropEffects.Copy) // viewed in tabs, apply 'view' highlight getSlotColor(slotSourceSlotNumber, Properties.Resources.slotView); + pb.BackColor = Color.Transparent; } catch (Exception x) { From 1d75da730a524d7ad655e68c9bd06fb6f0ce8d43 Mon Sep 17 00:00:00 2001 From: viacgo Date: Sun, 21 Aug 2016 14:52:10 +0200 Subject: [PATCH 04/43] Fix for fix PPs in PK4 to PK5 conversion. --- PKHeX/PKM/PK4.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PKHeX/PKM/PK4.cs b/PKHeX/PKM/PK4.cs index 60101f790..6b5e97c78 100644 --- a/PKHeX/PKM/PK4.cs +++ b/PKHeX/PKM/PK4.cs @@ -415,10 +415,10 @@ namespace PKHeX }; // Fix PP - pk5.Move1_PP = pk5.getMovePP(pk5.Move1_PP, pk5.Move1_PPUps); - pk5.Move2_PP = pk5.getMovePP(pk5.Move2_PP, pk5.Move2_PPUps); - pk5.Move3_PP = pk5.getMovePP(pk5.Move3_PP, pk5.Move3_PPUps); - pk5.Move4_PP = pk5.getMovePP(pk5.Move4_PP, pk5.Move4_PPUps); + pk5.Move1_PP = pk5.getMovePP(pk5.Move1, pk5.Move1_PPUps); + pk5.Move2_PP = pk5.getMovePP(pk5.Move2, pk5.Move2_PPUps); + pk5.Move3_PP = pk5.getMovePP(pk5.Move3, pk5.Move3_PPUps); + pk5.Move4_PP = pk5.getMovePP(pk5.Move4, pk5.Move4_PPUps); // Disassociate Nature and PID pk5.Nature = (int)(pk5.PID % 25); From a45b19364d27ef2b316cd0df07d45c7543668b48 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 21 Aug 2016 09:07:44 -0700 Subject: [PATCH 05/43] Tweak dragdrop to computer When the dragdrop succeeds to a location outside the program, the effect is Move. When the dragdrop succeeds to another slot, the effect is Link. When the dragdrop succeeds to Tabs, the effect is Copy. When the dragdrop fails, the effect is None. --- PKHeX/MainWindow/Main.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index a0c968548..4071e375d 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -3363,7 +3363,7 @@ namespace PKHeX pb.BackColor = Color.FromArgb(100, 200, 200, 200); // Thread Blocks on DoDragDrop DragDropEffects result = pb.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); - if (result == DragDropEffects.None || result == DragDropEffects.Copy) // not dropped to another box slot, restore img + if (result != DragDropEffects.Link) // not dropped to another box slot, restore img pb.Image = img; if (result == DragDropEffects.Copy) // viewed in tabs, apply 'view' highlight getSlotColor(slotSourceSlotNumber, Properties.Resources.slotView); @@ -3458,6 +3458,7 @@ namespace PKHeX SAV.setStoredSlot(pkz, slotDestinationOffset); getQuickFiller(SlotPictureBoxes[slotDestinationSlotNumber], pkz); + e.Effect = DragDropEffects.Link; slotSourceOffset = 0; // Clear offset value } } From e5737db404a924c57f32677b8cbcc8e472e0c67b Mon Sep 17 00:00:00 2001 From: viacgo Date: Sun, 21 Aug 2016 18:09:22 +0200 Subject: [PATCH 06/43] Fix reorder moves and clear PP values for empty moves. --- PKHeX/PKM/PKM.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 0c39bcbd2..2c338ed30 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -331,29 +331,42 @@ namespace PKHeX public abstract bool getGenderIsValid(); public void RefreshChecksum() { Checksum = CalculateChecksum(); } public void FixMoves() + { + ReorderMoves(); + + if (Move1 == 0) { Move1_PP = 0; Move1_PPUps = 0; } + if (Move2 == 0) { Move2_PP = 0; Move2_PPUps = 0; } + if (Move3 == 0) { Move3_PP = 0; Move3_PPUps = 0; } + if (Move4 == 0) { Move4_PP = 0; Move4_PPUps = 0; } + } + + private void ReorderMoves() { if (Move4 != 0 && Move3 == 0) { Move3 = Move4; Move3_PP = Move4_PP; Move3_PPUps = Move4_PPUps; - Move4 = Move4_PP = Move4_PPUps = 0; + Move4 = 0; } if (Move3 != 0 && Move2 == 0) { Move2 = Move3; Move2_PP = Move3_PP; Move2_PPUps = Move3_PPUps; - Move3 = Move3_PP = Move3_PPUps = 0; + Move3 = 0; + ReorderMoves(); } if (Move2 != 0 && Move1 == 0) { Move1 = Move2; Move1_PP = Move2_PP; Move1_PPUps = Move2_PPUps; - Move2 = Move2_PP = Move2_PPUps = 0; + Move2 = 0; + ReorderMoves(); } } + public int PotentialRating { get From 4df390a9c1188d92ffedc948603a70822189a395 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Mon, 22 Aug 2016 00:29:51 -0700 Subject: [PATCH 07/43] Release 08-22-16 Updated with latest event files. --- PKHeX/Resources/byte/wc6.pkl | Bin 247368 -> 251856 bytes PKHeX/Resources/byte/wc6full.pkl | Bin 192080 -> 196000 bytes PKHeX/Resources/text/changelog.txt | 18 ++++++++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/PKHeX/Resources/byte/wc6.pkl b/PKHeX/Resources/byte/wc6.pkl index e29dc62e28b92d4f3b219a1f1ebcec59e03edd83..8d99c4601f5e70e08352b4e90abc5454bba4c853 100644 GIT binary patch delta 1690 zcmX@n!+&8tzqTDyC_^5D0z(l)CPOk1W&r78Ak1XQWylAL`!b{g>2ih=hK$LH?24?$ z3ym4ICkBd3vnbdxF~ER=0FV{Ul+K{T@Q1-<;zQZ#4lGO@q9PF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{ByTq*wf%F*EX*#{|P$&@B#N}R9P`*kZE|Omd%VMQ5DAOo-zP8 zm|vAEYz6ycvxh}(6t_E@@U#|&!BY%>A1e6)pxEcx_nF*=*Btma=}flRMNHHxi-EU> zDFyZ=b`!QPj;7V8VZLuCY6(P#4goI=PkD9FHxtszi==cQO=P2EcymtE&wv|#qh9vj f_-bOiq`NrFG6aPs_`+N&RnFc`SZujaom=8RXAYyj delta 25 hcmZ4RoBP5Y?(H9LGcAy7cHn7u;9=bEz{9lRJOH0D3daBd diff --git a/PKHeX/Resources/text/changelog.txt b/PKHeX/Resources/text/changelog.txt index 5858adbec..71d162829 100644 --- a/PKHeX/Resources/text/changelog.txt +++ b/PKHeX/Resources/text/changelog.txt @@ -764,7 +764,7 @@ http://projectpokemon.org/forums/showthread.php?36986 - Fixed: Trainer Editor window ~ Unicode character display. Thanks \! - Fixed: Minor main window editing bugs for EXP/Nature/Gender. -08/07/16 - New Update: +08/07/16 - New Update: (38200) - Added: TWLSaveTool folder auto-detection for past generation save files. - Changed: Save file auto-detection now detects the last saved file instead of a predefined order. Saving a NDS game after 3DS game will return the NDS save. - Fixed: Multiple gen3/4 save/pkm/transfer bugs. Thanks BeyondTheHorizon, JHorbach, Destinyy, MichiS97, ashrobb, IamAVeryNicePereson & javier_himura! @@ -774,4 +774,18 @@ http://projectpokemon.org/forums/showthread.php?36986 - Fixed: Mystery Gift files can now be dragged into Box slots directly. - Fixed: Gen6 Trainer Info editor can now edit Vivillon forms again. Thanks Majickhat55! - Added: Cleaner 'delete' command to batch editor (set species to 0 to clear data). - - Added: Specifying output folder when modifying a folder in the Batch Editor. Thanks \! \ No newline at end of file + - Added: Specifying output folder when modifying a folder in the Batch Editor. Thanks \! + +08/22/16 - New Update: + - Changed: Drag&Drop now replaces the cursor with the sprite to better simulate moving a Pokémon. + - Added: FBI homebrew save file detection. Thanks poutros! + - Fixed: Program now indicates the type of blank save file loaded if none is detected on startup. + - Fixed: Vivillon form Showdown Import behavior. Thansk sora10pls! + - Fixed: Vivillon form selection in Trainer Editor re-enabled. Thanks Tsunamical! + - Fixed: Program should now load data much quicker; includes save files, box slots, and pcdata. + - Fixed: Past gen transfer / save file bugs. Thanks vacero, JSS, Ninjistix & Porta_14 + - Fixed: Mystery Gift manipulation now behaves better. Thanks jonaththejonath, sora10pls, Odaxis & rush2802! + - Fixed: Legality indication persists when loading a save file. + - Fixed: Hyperspace Fury legality. Thanks RanEncounter! + - Changed: Batch Editor improvements for PID/EC writing. Thanks JSS & Pokegeo! + - Changed: Updated Spanish and Chinese translation. Thanks ajtudela & easyworld! \ No newline at end of file From 27d55b47fb2b7823cf96f99b4ee1b5aae76982ea Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Mon, 22 Aug 2016 20:37:50 -0700 Subject: [PATCH 08/43] Implement PID-Ability corrections Line 2211: When the fields are loaded, if the user modifies the Ability on a <=Gen5 save file, if the ability is modified, the PID will be randomized to fit the new PID. When the Ability combobox is loaded, the personal entry may have 0 for the ability2 (indicating same as ability1); if so, copy ability1 instead of filtering it out. When the Ability index is loaded, hidden ability is checked first, else it tries to match: invalid, hidden (unflagged=illegal), if abilities same use PIDAbility, else use the actual ability index. --- PKHeX/MainWindow/Main.cs | 18 ++++++++++++++---- PKHeX/MainWindow/MainPK4.cs | 10 +++++++++- PKHeX/MainWindow/MainPK5.cs | 10 +++++++++- PKHeX/PKM/PKM.cs | 11 +++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 4071e375d..b969a6449 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -1228,6 +1228,8 @@ namespace PKHeX formnum = CB_Form.SelectedIndex; int[] abils = SAV.Personal.getAbilities(species, formnum); + if (abils[1] == 0) + abils[1] = abils[0]; string[] abilIdentifier = {" (1)", " (2)", " (H)"}; List ability_list = abils.Where(a => a != 0).Select((t, i) => abilitylist[t] + abilIdentifier[i]).ToList(); if (!ability_list.Any()) @@ -1652,6 +1654,9 @@ namespace PKHeX pkm.setPIDNature(Util.getIndex(CB_Nature)); else if (sender == BTN_RerollPID) pkm.setPIDGender(pkm.Gender); + else if (sender == CB_Ability && CB_Ability.SelectedIndex != pkm.PIDAbility && pkm.PIDAbility > -1) + pkm.PID = PKX.getRandomPID(pkm.Species, pkm.Gender, pkm.Version, pkm.Nature, pkm.Format, (uint)(CB_Ability.SelectedIndex * 0x10001)); + TB_PID.Text = pkm.PID.ToString("X8"); getQuickFiller(dragout); if (pkm.GenNumber < 6 && TB_EC.Visible) @@ -2203,10 +2208,15 @@ namespace PKHeX if (!fieldsInitialized) return; validateComboBox(sender, e); - if (sender == CB_Ability) - TB_AbilityNumber.Text = (1 << CB_Ability.SelectedIndex).ToString(); - if (fieldsLoaded && sender == CB_Nature && SAV.Generation <= 4) - updateRandomPID(sender, e); + if (fieldsLoaded) + { + if (sender == CB_Ability && SAV.Generation >= 6) + TB_AbilityNumber.Text = (1 << CB_Ability.SelectedIndex).ToString(); + if (sender == CB_Ability && SAV.Generation <= 5 && CB_Ability.SelectedIndex < 2) // not hidden + updateRandomPID(sender, e); + if (sender == CB_Nature && SAV.Generation <= 4) + updateRandomPID(sender, e); + } updateNatureModification(sender, null); updateIVs(null, null); // updating Nature will trigger stats to update as well } diff --git a/PKHeX/MainWindow/MainPK4.cs b/PKHeX/MainWindow/MainPK4.cs index 4e27d2d69..fef518fd0 100644 --- a/PKHeX/MainWindow/MainPK4.cs +++ b/PKHeX/MainWindow/MainPK4.cs @@ -134,7 +134,15 @@ namespace PKHeX { int[] abils = SAV.Personal.getAbilities(pk4.Species, pk4.AltForm); int abil = Array.IndexOf(abils, pk4.Ability); - CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; + + if (abil < 0) + CB_Ability.SelectedIndex = 0; + else if (abil == 2) + CB_Ability.SelectedIndex = 2; + else if (abils[0] == abils[1] || abils[1] == 0) + CB_Ability.SelectedIndex = pk4.PIDAbility; + else + CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; } } private PKM preparePK4() diff --git a/PKHeX/MainWindow/MainPK5.cs b/PKHeX/MainWindow/MainPK5.cs index c48dde3d3..286871469 100644 --- a/PKHeX/MainWindow/MainPK5.cs +++ b/PKHeX/MainWindow/MainPK5.cs @@ -145,7 +145,15 @@ namespace PKHeX { int[] abils = SAV.Personal.getAbilities(pk5.Species, pk5.AltForm); int abil = Array.IndexOf(abils, pk5.Ability); - CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; + + if (abil < 0) + CB_Ability.SelectedIndex = 0; + else if (abil == 2) + CB_Ability.SelectedIndex = 2; + else if (abils[0] == abils[1] || abils[1] == 0) + CB_Ability.SelectedIndex = pk5.PIDAbility; + else + CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; } } private PKM preparePK5() diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 2c338ed30..949efd682 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -287,6 +287,17 @@ namespace PKHeX get { return new[] { Move1, Move2, Move3, Move4 }; } set { if (value?.Length != 4) return; Move1 = value[0]; Move2 = value[1]; Move3 = value[2]; Move4 = value[3]; } } + public int PIDAbility + { + get + { + if (GenNumber > 5 || Format > 5) + return -1; + if (GenNumber == 5) + return (int)((PID >> 16) & 1); + return (int)(PID & 1); + } + } public bool[] Markings { From 8d741ec63a7d926f9a1dc9c6862ec6993cf50079 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Tue, 23 Aug 2016 18:09:55 -0700 Subject: [PATCH 09/43] Fix drag-clone not displaying sprite Control-DragDrop clones slot, switch boxes back and forth, pokemon magically appears; fixed. --- PKHeX/MainWindow/Main.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index b969a6449..49ece3e56 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -3464,6 +3464,8 @@ namespace PKHeX SlotPictureBoxes[slotSourceSlotNumber].Image = null; } } + else + getQuickFiller(SlotPictureBoxes[slotSourceSlotNumber], pkz); // Copy from temp to destination slot. SAV.setStoredSlot(pkz, slotDestinationOffset); getQuickFiller(SlotPictureBoxes[slotDestinationSlotNumber], pkz); From 9fead34917ea2f78d2321c1af81800184e00ada4 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Tue, 23 Aug 2016 18:11:35 -0700 Subject: [PATCH 10/43] Expose SecondsToFame for Gen6 Closes #192 --- .../Save Editors/Gen6/SAV_Trainer.Designer.cs | 146 +++++++++++------- .../Subforms/Save Editors/Gen6/SAV_Trainer.cs | 7 + 2 files changed, 101 insertions(+), 52 deletions(-) diff --git a/PKHeX/Subforms/Save Editors/Gen6/SAV_Trainer.Designer.cs b/PKHeX/Subforms/Save Editors/Gen6/SAV_Trainer.Designer.cs index 401b769f7..11747e675 100644 --- a/PKHeX/Subforms/Save Editors/Gen6/SAV_Trainer.Designer.cs +++ b/PKHeX/Subforms/Save Editors/Gen6/SAV_Trainer.Designer.cs @@ -181,6 +181,10 @@ namespace PKHeX this.Tab_Overview = new System.Windows.Forms.TabPage(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.L_Started = new System.Windows.Forms.Label(); + this.CAL_AdventureStartDate = new System.Windows.Forms.DateTimePicker(); + this.CAL_AdventureStartTime = new System.Windows.Forms.DateTimePicker(); + this.CAL_LastSavedTime = new System.Windows.Forms.DateTimePicker(); this.Tab_BadgeMap = new System.Windows.Forms.TabPage(); this.GB_Map = new System.Windows.Forms.GroupBox(); this.NUD_Z = new System.Windows.Forms.NumericUpDown(); @@ -195,10 +199,9 @@ namespace PKHeX this.Tab_Multiplayer = new System.Windows.Forms.TabPage(); this.Tab_Maison = new System.Windows.Forms.TabPage(); this.Tab_Appearance = new System.Windows.Forms.TabPage(); - this.CAL_AdventureStartTime = new System.Windows.Forms.DateTimePicker(); - this.CAL_AdventureStartDate = new System.Windows.Forms.DateTimePicker(); - this.L_Started = new System.Windows.Forms.Label(); - this.CAL_LastSavedTime = new System.Windows.Forms.DateTimePicker(); + this.L_Fame = new System.Windows.Forms.Label(); + this.CAL_HoFDate = new System.Windows.Forms.DateTimePicker(); + this.CAL_HoFTime = new System.Windows.Forms.DateTimePicker(); ((System.ComponentModel.ISupportInitialize)(this.PB_Badge8)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_Badge6)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_Badge4)).BeginInit(); @@ -620,7 +623,7 @@ namespace PKHeX // // L_LastSaved // - this.L_LastSaved.Location = new System.Drawing.Point(4, 107); + this.L_LastSaved.Location = new System.Drawing.Point(3, 110); this.L_LastSaved.Name = "L_LastSaved"; this.L_LastSaved.Size = new System.Drawing.Size(80, 20); this.L_LastSaved.TabIndex = 32; @@ -630,7 +633,7 @@ namespace PKHeX // CAL_LastSavedDate // this.CAL_LastSavedDate.Format = System.Windows.Forms.DateTimePickerFormat.Short; - this.CAL_LastSavedDate.Location = new System.Drawing.Point(90, 107); + this.CAL_LastSavedDate.Location = new System.Drawing.Point(89, 110); this.CAL_LastSavedDate.MaxDate = new System.DateTime(4095, 12, 31, 0, 0, 0, 0); this.CAL_LastSavedDate.Name = "CAL_LastSavedDate"; this.CAL_LastSavedDate.Size = new System.Drawing.Size(99, 20); @@ -640,7 +643,7 @@ namespace PKHeX // L_Seconds // this.L_Seconds.AutoSize = true; - this.L_Seconds.Location = new System.Drawing.Point(136, 20); + this.L_Seconds.Location = new System.Drawing.Point(136, 17); this.L_Seconds.Name = "L_Seconds"; this.L_Seconds.Size = new System.Drawing.Size(29, 13); this.L_Seconds.TabIndex = 30; @@ -649,7 +652,7 @@ namespace PKHeX // L_Minutes // this.L_Minutes.AutoSize = true; - this.L_Minutes.Location = new System.Drawing.Point(84, 20); + this.L_Minutes.Location = new System.Drawing.Point(84, 17); this.L_Minutes.Name = "L_Minutes"; this.L_Minutes.Size = new System.Drawing.Size(27, 13); this.L_Minutes.TabIndex = 29; @@ -657,7 +660,7 @@ namespace PKHeX // // MT_Seconds // - this.MT_Seconds.Location = new System.Drawing.Point(166, 17); + this.MT_Seconds.Location = new System.Drawing.Point(166, 14); this.MT_Seconds.Mask = "00"; this.MT_Seconds.Name = "MT_Seconds"; this.MT_Seconds.Size = new System.Drawing.Size(22, 20); @@ -667,7 +670,7 @@ namespace PKHeX // // MT_Minutes // - this.MT_Minutes.Location = new System.Drawing.Point(111, 17); + this.MT_Minutes.Location = new System.Drawing.Point(111, 14); this.MT_Minutes.Mask = "00"; this.MT_Minutes.Name = "MT_Minutes"; this.MT_Minutes.Size = new System.Drawing.Size(22, 20); @@ -678,7 +681,7 @@ namespace PKHeX // L_Hours // this.L_Hours.AutoSize = true; - this.L_Hours.Location = new System.Drawing.Point(12, 20); + this.L_Hours.Location = new System.Drawing.Point(12, 17); this.L_Hours.Name = "L_Hours"; this.L_Hours.Size = new System.Drawing.Size(26, 13); this.L_Hours.TabIndex = 26; @@ -686,7 +689,7 @@ namespace PKHeX // // MT_Hours // - this.MT_Hours.Location = new System.Drawing.Point(44, 17); + this.MT_Hours.Location = new System.Drawing.Point(44, 14); this.MT_Hours.Mask = "00000"; this.MT_Hours.Name = "MT_Hours"; this.MT_Hours.Size = new System.Drawing.Size(38, 20); @@ -1826,6 +1829,9 @@ namespace PKHeX // // groupBox2 // + this.groupBox2.Controls.Add(this.L_Fame); + this.groupBox2.Controls.Add(this.CAL_HoFDate); + this.groupBox2.Controls.Add(this.CAL_HoFTime); this.groupBox2.Controls.Add(this.L_Started); this.groupBox2.Controls.Add(this.CAL_AdventureStartDate); this.groupBox2.Controls.Add(this.CAL_LastSavedDate); @@ -1845,6 +1851,52 @@ namespace PKHeX this.groupBox2.TabStop = false; this.groupBox2.Text = "Adventure Info"; // + // L_Started + // + this.L_Started.Location = new System.Drawing.Point(3, 35); + this.L_Started.Name = "L_Started"; + this.L_Started.Size = new System.Drawing.Size(80, 20); + this.L_Started.TabIndex = 36; + this.L_Started.Text = "Game Started:"; + this.L_Started.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // CAL_AdventureStartDate + // + this.CAL_AdventureStartDate.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.CAL_AdventureStartDate.Location = new System.Drawing.Point(89, 35); + this.CAL_AdventureStartDate.MaxDate = new System.DateTime(2050, 12, 31, 0, 0, 0, 0); + this.CAL_AdventureStartDate.MinDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); + this.CAL_AdventureStartDate.Name = "CAL_AdventureStartDate"; + this.CAL_AdventureStartDate.Size = new System.Drawing.Size(99, 20); + this.CAL_AdventureStartDate.TabIndex = 35; + this.CAL_AdventureStartDate.Value = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); + // + // CAL_AdventureStartTime + // + this.CAL_AdventureStartTime.CustomFormat = "hh:mm tt"; + this.CAL_AdventureStartTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.CAL_AdventureStartTime.Location = new System.Drawing.Point(115, 54); + this.CAL_AdventureStartTime.MaxDate = new System.DateTime(2050, 12, 31, 0, 0, 0, 0); + this.CAL_AdventureStartTime.MinDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); + this.CAL_AdventureStartTime.Name = "CAL_AdventureStartTime"; + this.CAL_AdventureStartTime.ShowUpDown = true; + this.CAL_AdventureStartTime.Size = new System.Drawing.Size(73, 20); + this.CAL_AdventureStartTime.TabIndex = 34; + this.CAL_AdventureStartTime.Value = new System.DateTime(2001, 1, 1, 0, 0, 0, 0); + // + // CAL_LastSavedTime + // + this.CAL_LastSavedTime.CustomFormat = "hh:mm tt"; + this.CAL_LastSavedTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.CAL_LastSavedTime.Location = new System.Drawing.Point(115, 129); + this.CAL_LastSavedTime.MaxDate = new System.DateTime(2050, 12, 31, 0, 0, 0, 0); + this.CAL_LastSavedTime.MinDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); + this.CAL_LastSavedTime.Name = "CAL_LastSavedTime"; + this.CAL_LastSavedTime.ShowUpDown = true; + this.CAL_LastSavedTime.Size = new System.Drawing.Size(73, 20); + this.CAL_LastSavedTime.TabIndex = 37; + this.CAL_LastSavedTime.Value = new System.DateTime(2001, 1, 1, 0, 0, 0, 0); + // // Tab_BadgeMap // this.Tab_BadgeMap.Controls.Add(this.GB_Map); @@ -2067,51 +2119,38 @@ namespace PKHeX this.Tab_Appearance.Text = "Appearance"; this.Tab_Appearance.UseVisualStyleBackColor = true; // - // CAL_AdventureStartTime + // L_Fame // - this.CAL_AdventureStartTime.CustomFormat = "hh:mm tt"; - this.CAL_AdventureStartTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; - this.CAL_AdventureStartTime.Location = new System.Drawing.Point(116, 70); - this.CAL_AdventureStartTime.MaxDate = new System.DateTime(2050, 12, 31, 0, 0, 0, 0); - this.CAL_AdventureStartTime.MinDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); - this.CAL_AdventureStartTime.Name = "CAL_AdventureStartTime"; - this.CAL_AdventureStartTime.ShowUpDown = true; - this.CAL_AdventureStartTime.Size = new System.Drawing.Size(73, 20); - this.CAL_AdventureStartTime.TabIndex = 34; - this.CAL_AdventureStartTime.Value = new System.DateTime(2001, 1, 1, 0, 0, 0, 0); + this.L_Fame.Location = new System.Drawing.Point(3, 72); + this.L_Fame.Name = "L_Fame"; + this.L_Fame.Size = new System.Drawing.Size(80, 20); + this.L_Fame.TabIndex = 40; + this.L_Fame.Text = "HoF Entered:"; + this.L_Fame.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // CAL_AdventureStartDate + // CAL_HoFDate // - this.CAL_AdventureStartDate.Format = System.Windows.Forms.DateTimePickerFormat.Short; - this.CAL_AdventureStartDate.Location = new System.Drawing.Point(90, 51); - this.CAL_AdventureStartDate.MaxDate = new System.DateTime(2050, 12, 31, 0, 0, 0, 0); - this.CAL_AdventureStartDate.MinDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); - this.CAL_AdventureStartDate.Name = "CAL_AdventureStartDate"; - this.CAL_AdventureStartDate.Size = new System.Drawing.Size(99, 20); - this.CAL_AdventureStartDate.TabIndex = 35; - this.CAL_AdventureStartDate.Value = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); + this.CAL_HoFDate.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.CAL_HoFDate.Location = new System.Drawing.Point(89, 72); + this.CAL_HoFDate.MaxDate = new System.DateTime(2050, 12, 31, 0, 0, 0, 0); + this.CAL_HoFDate.MinDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); + this.CAL_HoFDate.Name = "CAL_HoFDate"; + this.CAL_HoFDate.Size = new System.Drawing.Size(99, 20); + this.CAL_HoFDate.TabIndex = 39; + this.CAL_HoFDate.Value = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); // - // L_Started + // CAL_HoFTime // - this.L_Started.Location = new System.Drawing.Point(4, 51); - this.L_Started.Name = "L_Started"; - this.L_Started.Size = new System.Drawing.Size(80, 20); - this.L_Started.TabIndex = 36; - this.L_Started.Text = "Game Started:"; - this.L_Started.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // CAL_LastSavedTime - // - this.CAL_LastSavedTime.CustomFormat = "hh:mm tt"; - this.CAL_LastSavedTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; - this.CAL_LastSavedTime.Location = new System.Drawing.Point(116, 126); - this.CAL_LastSavedTime.MaxDate = new System.DateTime(2050, 12, 31, 0, 0, 0, 0); - this.CAL_LastSavedTime.MinDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); - this.CAL_LastSavedTime.Name = "CAL_LastSavedTime"; - this.CAL_LastSavedTime.ShowUpDown = true; - this.CAL_LastSavedTime.Size = new System.Drawing.Size(73, 20); - this.CAL_LastSavedTime.TabIndex = 37; - this.CAL_LastSavedTime.Value = new System.DateTime(2001, 1, 1, 0, 0, 0, 0); + this.CAL_HoFTime.CustomFormat = "hh:mm tt"; + this.CAL_HoFTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.CAL_HoFTime.Location = new System.Drawing.Point(115, 91); + this.CAL_HoFTime.MaxDate = new System.DateTime(2050, 12, 31, 0, 0, 0, 0); + this.CAL_HoFTime.MinDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0); + this.CAL_HoFTime.Name = "CAL_HoFTime"; + this.CAL_HoFTime.ShowUpDown = true; + this.CAL_HoFTime.Size = new System.Drawing.Size(73, 20); + this.CAL_HoFTime.TabIndex = 38; + this.CAL_HoFTime.Value = new System.DateTime(2001, 1, 1, 0, 0, 0, 0); // // SAV_Trainer // @@ -2338,5 +2377,8 @@ namespace PKHeX private System.Windows.Forms.DateTimePicker CAL_AdventureStartTime; private System.Windows.Forms.Label L_Started; private System.Windows.Forms.DateTimePicker CAL_LastSavedTime; + private System.Windows.Forms.Label L_Fame; + private System.Windows.Forms.DateTimePicker CAL_HoFDate; + private System.Windows.Forms.DateTimePicker CAL_HoFTime; } } diff --git a/PKHeX/Subforms/Save Editors/Gen6/SAV_Trainer.cs b/PKHeX/Subforms/Save Editors/Gen6/SAV_Trainer.cs index d106096cd..8dc6171e5 100644 --- a/PKHeX/Subforms/Save Editors/Gen6/SAV_Trainer.cs +++ b/PKHeX/Subforms/Save Editors/Gen6/SAV_Trainer.cs @@ -454,6 +454,8 @@ namespace PKHeX CAL_LastSavedTime.Value = new DateTime(2000, 1, 1, SAV.LastSavedHour, SAV.LastSavedMinute, 0); CAL_AdventureStartDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart); CAL_AdventureStartTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart % 86400); + CAL_HoFDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame); + CAL_HoFTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame % 86400); } private void save() { @@ -540,6 +542,11 @@ namespace PKHeX seconds += (int)(CAL_AdventureStartTime.Value - new DateTime(2000, 1, 1)).TotalSeconds; SAV.SecondsToStart = seconds; + int fame = (int)(CAL_HoFDate.Value - new DateTime(2000, 1, 1)).TotalSeconds; + fame -= fame % 86400; + fame += (int)(CAL_HoFTime.Value - new DateTime(2000, 1, 1)).TotalSeconds; + SAV.SecondsToFame = fame; + SAV.LastSavedYear = CAL_LastSavedDate.Value.Year; SAV.LastSavedMonth = CAL_LastSavedDate.Value.Month; SAV.LastSavedDay = CAL_LastSavedDate.Value.Day; From c83701805b2381941d824cea85490a67448de94d Mon Sep 17 00:00:00 2001 From: Evan Dixon Date: Wed, 24 Aug 2016 19:46:24 -0500 Subject: [PATCH 11/43] Changed min and max of NumericUpDown from short to ushort --- PKHeX/Subforms/Save Editors/SAV_EventFlags.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PKHeX/Subforms/Save Editors/SAV_EventFlags.cs b/PKHeX/Subforms/Save Editors/SAV_EventFlags.cs index 006653a9c..4d15c321f 100644 --- a/PKHeX/Subforms/Save Editors/SAV_EventFlags.cs +++ b/PKHeX/Subforms/Save Editors/SAV_EventFlags.cs @@ -171,8 +171,8 @@ namespace PKHeX }; var mtb = new NumericUpDown { - Maximum = short.MaxValue, - Minimum = short.MinValue, + Maximum = ushort.MaxValue, + Minimum = ushort.MinValue, Value = Constants[num[i]], Name = constTag + num[i].ToString("0000"), Margin = Padding.Empty, From c34c4901eaf211784de5c42edc7816eee6400e1d Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Thu, 25 Aug 2016 14:44:02 -0700 Subject: [PATCH 12/43] Fix duplicate property name MysteryGift has "Type" property, PGT has "Type" property; fix to make them named differently. --- PKHeX/MysteryGifts/PGT.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PKHeX/MysteryGifts/PGT.cs b/PKHeX/MysteryGifts/PGT.cs index 911754cf9..25c935e3c 100644 --- a/PKHeX/MysteryGifts/PGT.cs +++ b/PKHeX/MysteryGifts/PGT.cs @@ -116,12 +116,12 @@ namespace PKHeX } } - private GiftType Type { get { return (GiftType)Data[0]; } set {Data[0] = (byte)value; } } - public bool IsHatched => Type == GiftType.Pokémon; - public bool IsEgg => Type == GiftType.PokémonEgg; - public bool IsManaphyEgg => Type == GiftType.ManaphyEgg; - public override bool IsItem { get { return Type == GiftType.Item; } set { if (value) CardType = (int)GiftType.Item; } } - public override bool IsPokémon { get { return Type == GiftType.Pokémon || Type == GiftType.PokémonEgg || Type == GiftType.ManaphyEgg; } set { } } + private GiftType PGTGiftType { get { return (GiftType)Data[0]; } set {Data[0] = (byte)value; } } + public bool IsHatched => PGTGiftType == GiftType.Pokémon; + public bool IsEgg => PGTGiftType == GiftType.PokémonEgg; + public bool IsManaphyEgg => PGTGiftType == GiftType.ManaphyEgg; + public override bool IsItem { get { return PGTGiftType == GiftType.Item; } set { if (value) CardType = (int)GiftType.Item; } } + public override bool IsPokémon { get { return PGTGiftType == GiftType.Pokémon || PGTGiftType == GiftType.PokémonEgg || PGTGiftType == GiftType.ManaphyEgg; } set { } } public override PKM convertToPKM(SaveFile SAV) { From 4ea349df118ee8b99e0414a3abfd5dabb6b0d3c1 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Thu, 25 Aug 2016 18:50:51 -0700 Subject: [PATCH 13/43] Add popup box viewer Allows for dragging between boxes Pop up via shift-click Box tab Click the swap arrows to flip Main/Viewer current box Fixes swallowed exception: DragDrop a slot (filename), start another within 500ms before deletion thread deletes original dragdrop file; since filenames are the same the file for the active dragdrop will no longer exist resulting in an exception. Solved by tracking the current path of a dragdrop operation. Had to refactor the draginfo into its own class to 'cleanly' communicate between forms. --- PKHeX/MainWindow/Main.cs | 199 ++++-- PKHeX/PKHeX.csproj | 16 +- PKHeX/Properties/Resources.Designer.cs | 24 +- PKHeX/Properties/Resources.resx | 6 + PKHeX/Resources/img/box/slotDrag.png | Bin 0 -> 143 bytes PKHeX/Resources/img/box/swapBox.png | Bin 0 -> 176 bytes .../Save Editors/SAV_BoxViewer.Designer.cs | 603 ++++++++++++++++++ PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs | 314 +++++++++ .../Subforms/Save Editors/SAV_BoxViewer.resx | 219 +++++++ 9 files changed, 1310 insertions(+), 71 deletions(-) create mode 100644 PKHeX/Resources/img/box/slotDrag.png create mode 100644 PKHeX/Resources/img/box/swapBox.png create mode 100644 PKHeX/Subforms/Save Editors/SAV_BoxViewer.Designer.cs create mode 100644 PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs create mode 100644 PKHeX/Subforms/Save Editors/SAV_BoxViewer.resx diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 49ece3e56..5f63b6f04 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -17,7 +17,7 @@ namespace PKHeX { #region Initialize Form new Thread(() => new SplashScreen().ShowDialog()).Start(); - slotPkmSource = SAV.BlankPKM.EncryptedPartyData; + DragInfo.slotPkmSource = SAV.BlankPKM.EncryptedPartyData; InitializeComponent(); CB_ExtraBytes.SelectedIndex = 0; SaveFile.SetUpdateDex = Menu_ModifyDex.Checked; @@ -774,6 +774,11 @@ namespace PKHeX } Menu_ExportSAV.Enabled = B_VerifyCHK.Enabled = SAV.Exportable; + // Close subforms that are save dependent + Type[] f = { typeof(SAV_BoxViewer), typeof(f2_Text) }; + foreach (var form in Application.OpenForms.Cast
().Where(form => f.Contains(form.GetType())).ToArray()) + form.Close(); + setBoxNames(); // Display the Box Names if (SAV.HasBox) { @@ -2402,7 +2407,7 @@ namespace PKHeX invalid: { SystemSounds.Exclamation.Play(); return false; } } - private static string[] verifyPKMtoSAV(PKM pk) + public static string[] verifyPKMtoSAV(PKM pk) { // Check if PKM properties are outside of the valid range List errata = new List(); @@ -2454,6 +2459,8 @@ namespace PKHeX string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); openQuick(files[0]); e.Effect = DragDropEffects.Copy; + + Cursor = DefaultCursor; } // Decrypted Export private void dragout_MouseDown(object sender, MouseEventArgs e) @@ -2476,12 +2483,12 @@ namespace PKHeX { File.WriteAllBytes(newfile, dragdata); PictureBox pb = (PictureBox)sender; - Cursor.Current = new Cursor(((Bitmap)pb.Image).GetHicon()); + Cursor = DragInfo.Cursor = new Cursor(((Bitmap)pb.Image).GetHicon()); DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); } catch (Exception x) { Util.Error("Drag & Drop Error", x.ToString()); } - Cursor.Current = DefaultCursor; + Cursor = DragInfo.Cursor = DefaultCursor; File.Delete(newfile); } private void dragout_DragOver(object sender, DragEventArgs e) @@ -2502,6 +2509,8 @@ namespace PKHeX string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); openQuick(files[0]); e.Effect = DragDropEffects.Copy; + + Cursor = DefaultCursor; } #endregion @@ -2617,6 +2626,20 @@ namespace PKHeX setPKXBoxes(); Util.Alert("Current Box sorted!"); } + else if (ModifierKeys == Keys.Shift) + { + var z = Application.OpenForms.Cast().FirstOrDefault(form => form.GetType() == typeof(SAV_BoxViewer)) as SAV_BoxViewer; + if (z != null) + { Util.CenterToForm(z, this); z.BringToFront(); return; } + + new SAV_BoxViewer(this).Show(); + } + } + public int swapBoxesViewer(int viewBox) + { + int mainBox = CB_BoxSelect.SelectedIndex; + CB_BoxSelect.SelectedIndex = viewBox; + return mainBox; } private void clickSlot(object sender, EventArgs e) @@ -2980,8 +3003,8 @@ namespace PKHeX catch { CB_BoxSelect.Items.Clear(); - for (int i = 0; i < SAV.BoxCount; i++) - CB_BoxSelect.Items.Add("BOX " + (i+1)); + for (int i = 1; i <= SAV.BoxCount; i++) + CB_BoxSelect.Items.Add($"BOX {i}"); } if (selectedbox < CB_BoxSelect.Items.Count) CB_BoxSelect.SelectedIndex = selectedbox; // restore selected box @@ -2992,7 +3015,7 @@ namespace PKHeX pk = pk ?? preparePKM(false); // don't perform control loss click if (pb == dragout) mnuLQR.Enabled = pk.Species != 0; // Species - pb.Image = pk.Sprite; + pb.Image = pk.Species != 0 ? pk.Sprite : null; if (pb.BackColor == Color.Red) pb.BackColor = Color.Transparent; } @@ -3312,7 +3335,7 @@ namespace PKHeX // Drag and drop related functions private void pbBoxSlot_MouseClick(object sender, MouseEventArgs e) { - if (slotDragDropInProgress) + if (DragInfo.slotDragDropInProgress) return; clickSlot(sender, e); @@ -3320,23 +3343,23 @@ namespace PKHeX private void pbBoxSlot_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) - slotLeftMouseIsDown = false; + DragInfo.slotLeftMouseIsDown = false; if (e.Button == MouseButtons.Right) - slotRightMouseIsDown = false; + DragInfo.slotRightMouseIsDown = false; } private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) - slotLeftMouseIsDown = true; + DragInfo.slotLeftMouseIsDown = true; if (e.Button == MouseButtons.Right) - slotRightMouseIsDown = true; + DragInfo.slotRightMouseIsDown = true; } private void pbBoxSlot_MouseMove(object sender, MouseEventArgs e) { - if (slotDragDropInProgress) + if (DragInfo.slotDragDropInProgress) return; - if (slotLeftMouseIsDown) + if (DragInfo.slotLeftMouseIsDown) { // The goal is to create a temporary PKX file for the underlying Pokemon // and use that file to perform a drag drop operation. @@ -3347,17 +3370,18 @@ namespace PKHeX return; // Set flag to prevent re-entering. - slotDragDropInProgress = true; + DragInfo.slotDragDropInProgress = true; - slotSourceSlotNumber = getSlot(pb); - int offset = getPKXOffset(slotSourceSlotNumber); + DragInfo.slotSourceSlotNumber = getSlot(pb); + int offset = getPKXOffset(DragInfo.slotSourceSlotNumber); // Prepare Data - slotPkmSource = SAV.getData(offset, SAV.SIZE_STORED); - slotSourceOffset = offset; + DragInfo.slotPkmSource = SAV.getData(offset, SAV.SIZE_STORED); + DragInfo.slotSourceOffset = offset; + DragInfo.slotSourceBoxNumber = CB_BoxSelect.SelectedIndex; // Make a new file name based off the PID - byte[] dragdata = SAV.decryptPKM(slotPkmSource); + byte[] dragdata = SAV.decryptPKM(DragInfo.slotPkmSource); Array.Resize(ref dragdata, SAV.SIZE_STORED); PKM pkx = SAV.getPKM(dragdata); string filename = pkx.FileName; @@ -3368,43 +3392,51 @@ namespace PKHeX { File.WriteAllBytes(newfile, dragdata); var img = (Bitmap)pb.Image; - Cursor.Current = new Cursor(img.GetHicon()); + DragInfo.Cursor = Cursor.Current = new Cursor(img.GetHicon()); pb.Image = null; - pb.BackColor = Color.FromArgb(100, 200, 200, 200); + pb.BackgroundImage = Properties.Resources.slotDrag; // Thread Blocks on DoDragDrop + DragInfo.CurrentPath = newfile; DragDropEffects result = pb.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); if (result != DragDropEffects.Link) // not dropped to another box slot, restore img pb.Image = img; + else // refresh image + getQuickFiller(pb, SAV.getStoredSlot(DragInfo.slotSourceOffset)); + pb.BackgroundImage = null; + + if (DragInfo.slotDestinationBoxNumber == DragInfo.slotSourceBoxNumber) + SlotPictureBoxes[DragInfo.slotDestinationSlotNumber].Image = img; + if (result == DragDropEffects.Copy) // viewed in tabs, apply 'view' highlight - getSlotColor(slotSourceSlotNumber, Properties.Resources.slotView); - pb.BackColor = Color.Transparent; + getSlotColor(DragInfo.slotSourceSlotNumber, Properties.Resources.slotView); } catch (Exception x) { Util.Error("Drag & Drop Error:", x.ToString()); } - slotSourceOffset = 0; - Cursor.Current = DefaultCursor; + DragInfo.Reset(); + Cursor = DefaultCursor; // Browser apps need time to load data since the file isn't moved to a location on the user's local storage. // Tested 10ms -> too quick, 100ms was fine. 500ms should be safe? new Thread(() => { Thread.Sleep(500); - if (File.Exists(newfile)) + if (File.Exists(newfile) && DragInfo.CurrentPath == null) File.Delete(newfile); }).Start(); } } private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) { - int slotDestinationSlotNumber = getSlot(sender); - int slotDestinationOffset = getPKXOffset(slotDestinationSlotNumber); + DragInfo.slotDestinationSlotNumber = getSlot(sender); + DragInfo.slotDestinationOffset = getPKXOffset(DragInfo.slotDestinationSlotNumber); + DragInfo.slotDestinationBoxNumber = CB_BoxSelect.SelectedIndex; // Check for In-Dropped files (PKX,SAV,ETC) string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (Directory.Exists(files[0])) { loadBoxesFromDB(files[0]); return; } - if (slotSourceOffset == 0) + if (DragInfo.slotSourceOffset < 0) // file { if (files.Length <= 0) return; @@ -3430,48 +3462,45 @@ namespace PKHeX { Console.WriteLine(c); Console.WriteLine(concat); return; } } - SAV.setStoredSlot(pk, slotDestinationOffset); - getQuickFiller(SlotPictureBoxes[slotDestinationSlotNumber], pk); - getSlotColor(slotDestinationSlotNumber, Properties.Resources.slotSet); + SAV.setStoredSlot(pk, DragInfo.slotDestinationOffset); + getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pk); + getSlotColor(DragInfo.slotDestinationSlotNumber, Properties.Resources.slotSet); Console.WriteLine(c); } else { - PKM pkz = SAV.getStoredSlot(slotSourceOffset); - if (ModifierKeys == Keys.Alt && slotDestinationSlotNumber > -1) // overwrite delete old slot + PKM pkz = SAV.getStoredSlot(DragInfo.slotSourceOffset); + if (ModifierKeys == Keys.Alt && DragInfo.slotDestinationSlotNumber > -1) // overwrite delete old slot { - // Clear from slot - getQuickFiller(SlotPictureBoxes[slotSourceSlotNumber], SAV.BlankPKM); // picturebox - SAV.setStoredSlot(SAV.BlankPKM, slotSourceOffset); // savefile + // Clear from slot + if (DragInfo.SameBox) + getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], SAV.BlankPKM); // picturebox + + SAV.setStoredSlot(SAV.BlankPKM, DragInfo.slotSourceOffset); } - else if (ModifierKeys != Keys.Control && slotDestinationSlotNumber > -1) + else if (ModifierKeys != Keys.Control && DragInfo.slotDestinationSlotNumber > -1) { - if (((PictureBox)sender).Image != null) - { - // Load data from destination - PKM pk = SAV.getStoredSlot(slotDestinationOffset); + // Load data from destination + PKM pk = ((PictureBox) sender).Image != null + ? SAV.getStoredSlot(DragInfo.slotDestinationOffset) + : SAV.BlankPKM; - // Set destination pokemon image to source picture box - getQuickFiller(SlotPictureBoxes[slotSourceSlotNumber], pk); + // Set destination pokemon image to source picture box + if (DragInfo.SameBox) + getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pk); - // Set destination pokemon data to source slot - SAV.setStoredSlot(pk, slotSourceOffset); - } - else - { - // Set blank to source slot - SAV.setStoredSlot(SAV.BlankPKM, slotSourceOffset); - SlotPictureBoxes[slotSourceSlotNumber].Image = null; - } + // Set destination pokemon data to source slot + SAV.setStoredSlot(pk, DragInfo.slotSourceOffset); } - else - getQuickFiller(SlotPictureBoxes[slotSourceSlotNumber], pkz); + else if (DragInfo.SameBox) + getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pkz); + // Copy from temp to destination slot. - SAV.setStoredSlot(pkz, slotDestinationOffset); - getQuickFiller(SlotPictureBoxes[slotDestinationSlotNumber], pkz); + SAV.setStoredSlot(pkz, DragInfo.slotDestinationOffset); + getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pkz); e.Effect = DragDropEffects.Link; - slotSourceOffset = 0; // Clear offset value + Cursor = DefaultCursor; } } private void pbBoxSlot_DragEnter(object sender, DragEventArgs e) @@ -3480,23 +3509,57 @@ namespace PKHeX e.Effect = DragDropEffects.Copy; else if (e.Data != null) // within e.Effect = DragDropEffects.Move; + + if (DragInfo.slotDragDropInProgress) + Cursor = DragInfo.Cursor; } private void pbBoxSlot_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) { if (e.Action == DragAction.Cancel || e.Action == DragAction.Drop) { - slotLeftMouseIsDown = false; - slotRightMouseIsDown = false; - slotDragDropInProgress = false; + DragInfo.slotLeftMouseIsDown = false; + DragInfo.slotRightMouseIsDown = false; + DragInfo.slotDragDropInProgress = false; + } + } + + public static class DragInfo + { + public static bool slotLeftMouseIsDown; + public static bool slotRightMouseIsDown; + public static bool slotDragDropInProgress; + + public static byte[] slotPkmSource; + public static byte[] slotPkmDestination; + + public static int slotSourceOffset = -1; + public static int slotSourceSlotNumber = -1; + public static int slotSourceBoxNumber = -1; + + public static int slotDestinationOffset = -1; + public static int slotDestinationSlotNumber = -1; + public static int slotDestinationBoxNumber = -1; + + public static Cursor Cursor; + public static string CurrentPath; + + public static bool SameBox => slotSourceBoxNumber > -1 && slotSourceBoxNumber == slotDestinationBoxNumber; + public static void Reset() + { + slotLeftMouseIsDown = false; + slotRightMouseIsDown = false; + slotDragDropInProgress = false; + + slotPkmSource = null; + slotSourceOffset = slotSourceSlotNumber = slotSourceBoxNumber = -1; + slotPkmDestination = null; + slotDestinationOffset = slotSourceBoxNumber = slotDestinationBoxNumber = -1; + + Cursor = null; + CurrentPath = null; } } - private static bool slotLeftMouseIsDown = false; - private static bool slotRightMouseIsDown = false; - private static bool slotDragDropInProgress = false; - private byte[] slotPkmSource; - private int slotSourceOffset; - private int slotSourceSlotNumber = -1; #endregion } } diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index a0a1c2b8b..eae839e4b 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -189,6 +189,12 @@ SAV_PokeBlockORAS.cs + + Form + + + SAV_BoxViewer.cs + Form @@ -338,6 +344,9 @@ SAV_PokeBlockORAS.cs + + SAV_BoxViewer.cs + SAV_Database.cs @@ -2704,7 +2713,12 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + + + A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AA8AA + AAPAAAADwAAAA8AAAAPAAAAD4AAAB/gAAB////// + + + \ No newline at end of file From fb45f95578bef2ac9953624200566852522a6535 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Fri, 26 Aug 2016 16:34:28 -0700 Subject: [PATCH 14/43] Fix o-power saving (x/y) --- PKHeX/Subforms/Save Editors/Gen6/SAV_OPower.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKHeX/Subforms/Save Editors/Gen6/SAV_OPower.cs b/PKHeX/Subforms/Save Editors/Gen6/SAV_OPower.cs index 30d59b879..4049a860e 100644 --- a/PKHeX/Subforms/Save Editors/Gen6/SAV_OPower.cs +++ b/PKHeX/Subforms/Save Editors/Gen6/SAV_OPower.cs @@ -86,7 +86,7 @@ namespace PKHeX { data[c] = 1; } - Array.Copy(data, 0, Main.SAV.Data, o + offsets[i], data.Length); + Array.Copy(data, 0, SAV.Data, o + offsets[i], data.Length); } // Save Maxes From 3ded8b61c6b86fb002a30e8783525172e33c3e17 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 27 Aug 2016 01:52:34 -0700 Subject: [PATCH 15/43] Initial PK1 implementation. --- PKHeX/PKHeX.csproj | 2 + PKHeX/PKM/PK1.cs | 307 +++++++++++++++++++++++++++++++++++++++++ PKHeX/PKM/PKX.cs | 21 +++ PKHeX/Util/ByteUtil.cs | 49 +++++++ 4 files changed, 379 insertions(+) create mode 100644 PKHeX/PKM/PK1.cs create mode 100644 PKHeX/Util/ByteUtil.cs diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index eae839e4b..4af47f6a3 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -95,6 +95,7 @@ + @@ -300,6 +301,7 @@ SplashScreen.cs + diff --git a/PKHeX/PKM/PK1.cs b/PKHeX/PKM/PK1.cs new file mode 100644 index 000000000..89370505f --- /dev/null +++ b/PKHeX/PKM/PK1.cs @@ -0,0 +1,307 @@ +using System; +using System.Linq; + +namespace PKHeX +{ + class PK1 : PKM + { + // Internal use only + protected byte[] otname; + protected byte[] nick; + + public sealed override int SIZE_PARTY => PKX.SIZE_1PARTY; + public override int SIZE_STORED => PKX.SIZE_1STORED; + internal const int STRLEN_J = 6; + internal const int STRLEN_U = 11; + private int StringLength => Japanese ? STRLEN_J : STRLEN_U; + + public override int Format => 1; + + public bool Japanese => otname.Length == STRLEN_J; + + public PK1(byte[] decryptedData = null, string ident = null, bool jp = false) + { + Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone(); + Identifier = ident; + if (Data.Length != SIZE_PARTY) + Array.Resize(ref Data, SIZE_PARTY); + int strLen = STRLEN_U; + if (jp) + { + strLen = STRLEN_J; + } + otname = Enumerable.Repeat((byte) 0x50, strLen).ToArray(); + nick = Enumerable.Repeat((byte) 0x50, strLen).ToArray(); + } + + public override PKM Clone() + { + PK1 new_pk1 = new PK1(Data); + Array.Copy(otname, 0, new_pk1.otname, 0, otname.Length); + Array.Copy(nick, 0, new_pk1.nick, 0, nick.Length); + return new_pk1; + } + public override string Nickname + { + get { return PKX.getG1Str(nick, Japanese); } + set + { + byte[] strdata = PKX.setG1Str(value, Japanese); + if (strdata.Length > StringLength) + throw new ArgumentOutOfRangeException("OT Name too long for given PK1"); + strdata.CopyTo(nick, 0); + } + } + + public override string OT_Name + { + get { return PKX.getG1Str(otname, Japanese); } + set + { + byte[] strdata = PKX.setG1Str(value, Japanese); + if (strdata.Length > StringLength) + throw new ArgumentOutOfRangeException("OT Name too long for given PK1"); + strdata.CopyTo(otname, 0); + } + } + + public override byte[] Encrypt() + { + throw new NotImplementedException(); + } + + public override bool IsNicknamed { get { throw new NotImplementedException(); } set { } } + + #region Stored Attributes + public override int Species { get { return Data[0]; } set { } } + + public override int Stat_HPCurrent { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x1); } } + public int Status_Condition { get { return Data[4]; } set { Data[4] = (byte)value; } } + public int Type_A { get { return Data[5]; } set { Data[5] = (byte)value; } } + public int Type_B { get { return Data[6]; } set { Data[6] = (byte)value; } } + public int Catch_Rate { get { return Data[7]; } set { Data[7] = (byte)value; } } + public override int Move1 { get { return Data[8]; } set { Data[8] = (byte) value; } } + public override int Move2 { get { return Data[9]; } set { Data[9] = (byte)value; } } + public override int Move3 { get { return Data[10]; } set { Data[10] = (byte)value; } } + public override int Move4 { get { return Data[11]; } set { Data[11] = (byte)value; } } + public override int TID { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0xC)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0xC); } } + public override uint EXP + { + get { return Util.SwapEndianness(BitConverter.ToUInt32(Data, 0xE)) & 0x00FFFFFF; } + set { Array.Copy(BitConverter.GetBytes(Util.SwapEndianness((value << 8) & 0xFFFFFF00)), 0, Data, 0xE, 3); } + } + public override int EV_HP { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x11)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x11); } } + public override int EV_ATK { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x13)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x13); } } + public override int EV_DEF { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x15)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x15); } } + public override int EV_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x17)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x17); } } + public int EV_SPC { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x19)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x19); } } + public override int EV_SPA { get { return EV_SPC; } set { EV_SPC = value; } } + public override int EV_SPD { get { return EV_SPC; } set { EV_SPC = value; } } + public ushort DV16 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1B)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x1B); } } + public override int IV_HP { get { return ((IV_ATK & 1) << 3) | ((IV_DEF & 1) << 2) | ((IV_SPD & 1) << 1) | ((IV_SPC & 1) << 0); } set { } } + public override int IV_ATK { get { return (DV16 >> 12) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 12)) | (ushort)((value > 0xF ? 0xF : value) << 12)); } } + public override int IV_DEF { get { return (DV16 >> 8) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 8)) | (ushort)((value > 0xF ? 0xF : value) << 8)); } } + public override int IV_SPE { get { return (DV16 >> 4) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 4)) | (ushort)((value > 0xF ? 0xF : value) << 4)); } } + public int IV_SPC { get { return (DV16 >> 0) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 0)) | (ushort)((value > 0xF ? 0xF : value) << 0)); } } + public override int IV_SPA { get { return IV_SPC; } set { IV_SPC = value; } } + public override int IV_SPD { get { return IV_SPC; } set { IV_SPC = value; } } + public override int Move1_PP { get { return Data[0x1D] & 0x3F; } set { Data[0x1D] = (byte)((Data[0x1D] & 0xC0) | (value & 0x3F)); } } + public override int Move2_PP { get { return Data[0x1E] & 0x3F; } set { Data[0x1E] = (byte)((Data[0x1E] & 0xC0) | (value & 0x3F)); } } + public override int Move3_PP { get { return Data[0x1F] & 0x3F; } set { Data[0x1F] = (byte)((Data[0x1F] & 0xC0) | (value & 0x3F)); } } + public override int Move4_PP { get { return Data[0x20] & 0x3F; } set { Data[0x20] = (byte)((Data[0x20] & 0xC0) | (value & 0x3F)); } } + public override int Move1_PPUps { get { return (Data[0x1D] & 0xC0) >> 6; } set { Data[0x1D] = (byte)((Data[0x1D] & 0x3F) | ((value & 0x3) << 6)); } } + public override int Move2_PPUps { get { return (Data[0x1E] & 0xC0) >> 6; } set { Data[0x1E] = (byte)((Data[0x1E] & 0x3F) | ((value & 0x3) << 6)); } } + public override int Move3_PPUps { get { return (Data[0x1F] & 0xC0) >> 6; } set { Data[0x1F] = (byte)((Data[0x1F] & 0x3F) | ((value & 0x3) << 6)); } } + public override int Move4_PPUps { get { return (Data[0x20] & 0xC0) >> 6; } set { Data[0x20] = (byte)((Data[0x20] & 0x3F) | ((value & 0x3) << 6)); } } + #endregion + + #region Party Attributes + public override int Stat_Level + { + get { return Data[0x21]; } + set { Data[0x21] = (byte)value; Data[0x3] = (byte)value; } + } + public override int Stat_HPMax { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x22)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x22); } } + public override int Stat_ATK { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x24)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x24); } } + public override int Stat_DEF { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x26)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x26); } } + public override int Stat_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x28)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x28); } } + public int Stat_SPC { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2A)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2A); } } + // Leave SPA and SPD as alias for SPC + public override int Stat_SPA { get { return Stat_SPC; } set { Stat_SPC = value; } } + public override int Stat_SPD { get { return Stat_SPC; } set { Stat_SPC = value; } } + #endregion + + #region Future, Unused Attributes + public override bool getGenderIsValid() + { + return true; + } + public override uint EncryptionConstant { get { return 0; } set { } } + public override uint PID { get { return 0; } set { } } + public override int Met_Level { get { return 0; } set { } } + public override int Nature { get { return 0; } set { } } + public override int AltForm { get { return 0; } set { } } + public override bool IsEgg { get { return false; } set { } } + public override int Gender { get { return 0; } set { } } + public override int HeldItem { get { return 0; } set { } } + public override ushort Sanity { get { return 0; } set { } } + public override ushort Checksum { get { return 0; } set { } } + public override int Language { get { return 0; } set { } } + public override bool FatefulEncounter { get { return false; } set { } } + public override int TSV => 0; + public override int PSV => 0; + public override int Characteristic => -1; + public override byte MarkByte { get { return 0; } protected set { } } + public override int CurrentFriendship { get { return 0; } set { } } + public override int Ability { get { return 0; } set { } } + public override int CurrentHandler { get { return 0; } set { } } + public override int Met_Location { get { return 0; } set { } } + public override int Egg_Location { get { return 0; } set { } } + public override int OT_Friendship { get { return 0; } set { } } + public override int OT_Gender { get { return 0; } set { } } + public override int Ball { get { return 0; } set { } } + public override int Version { get { return 0; } set { } } + public override int SID { get { return 0; } set { } } + public override int PKRS_Strain { get { return 0; } set { } } + public override int PKRS_Days { get { return 0; } set { } } + public override int CNT_Cool { get { return 0; } set { } } + public override int CNT_Beauty { get { return 0; } set { } } + public override int CNT_Cute { get { return 0; } set { } } + public override int CNT_Smart { get { return 0; } set { } } + public override int CNT_Tough { get { return 0; } set { } } + public override int CNT_Sheen { get { return 0; } set { } } + #endregion + } + + class PokemonList + { + internal const int CAPACITY_DAYCARE = 1; + internal const int CAPACITY_PARTY = 6; + internal const int CAPACITY_STORED = 20; + internal const int CAPACITY_STORED_JP = 30; + + private bool Japanese; + + private int StringLength => Japanese ? PK1.STRLEN_J : PK1.STRLEN_U; + + internal static readonly byte[] EMPTY_LIST = { 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50 }; + public enum CapacityType + { + Daycare = CAPACITY_DAYCARE, + Party = CAPACITY_PARTY, + Stored = CAPACITY_STORED, + StoredJP = CAPACITY_STORED_JP, + Single + } + + public static int getEntrySize(CapacityType c) + { + return c == CapacityType.Single || c == CapacityType.Party + ? PKX.SIZE_1PARTY + : PKX.SIZE_1STORED; + } + + public static byte getCapacity(CapacityType c) + { + return c == CapacityType.Single ? (byte)1 : (byte)c; + } + + private byte[] getEmptyList(CapacityType c, bool is_JP = false) + { + int cap = getCapacity(c); + return new[] { (byte)0 }.Concat(Enumerable.Repeat((byte)0xFF, cap + 1)).Concat(Enumerable.Repeat((byte)0, getEntrySize(c) * cap)).Concat(Enumerable.Repeat((byte)0x50, (is_JP ? PK1.STRLEN_J : PK1.STRLEN_U) * 2 * cap)).ToArray(); + } + + public PokemonList(byte[] d, CapacityType c = CapacityType.Single, bool jp = false) + { + Japanese = jp; + Data = d ?? getEmptyList(c, Japanese); + Capacity = getCapacity(c); + Entry_Size = getEntrySize(c); + + if (Data.Length != DataSize) + { + Array.Resize(ref Data, DataSize); + } + + Pokemon = new PK1[Capacity]; + for (int i = 0; i < Capacity; i++) + { + int base_ofs = 2 + Capacity; + byte[] dat = Data.Skip(base_ofs + Entry_Size * i).Take(Entry_Size).ToArray(); + Pokemon[i] = new PK1(dat, null, jp); + Pokemon[i].OT_Name = PKX.getG1Str(Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * i).Take(StringLength).ToArray(), Japanese); + Pokemon[i].Nickname = PKX.getG1Str(Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * Capacity + StringLength * i).Take(StringLength).ToArray(), Japanese); + } + } + + public PokemonList(CapacityType c = CapacityType.Single, bool jp = false) + : this(null, c, jp) + { + Count = 1; + } + + public PokemonList(PK1 pk) + : this(CapacityType.Single, pk.Japanese) + { + this[0] = pk; + Count = 1; + } + + private readonly byte[] Data; + private readonly byte Capacity; + private readonly int Entry_Size; + + public byte Count + { + get { return Data[0]; } + set { Data[0] = value > Capacity ? Capacity : value; } + } + + public int GetCapacity() + { + return Capacity; + } + + public readonly PK1[] Pokemon; + + public PK1 this[int i] + { + get + { + if (i > Capacity || i < 0) throw new IndexOutOfRangeException($"Invalid PokemonList Access: {i}"); + return Pokemon[i]; + } + set + { + if (value == null) return; + Pokemon[i] = (PK1)value.Clone(); + } + } + + private void Update() + { + for (int i = 0; i < Count; i++) + { + Data[1 + i] = (byte)Pokemon[i].Species; + Array.Copy(Pokemon[i].Data, 0, Data, 2 + Capacity + Entry_Size * i, Entry_Size); + Array.Copy(PKX.setG1Str(Pokemon[i].OT_Name, Japanese), 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * i, StringLength); + Array.Copy(PKX.setG1Str(Pokemon[i].Nickname, Japanese), 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * Capacity + StringLength * i, StringLength); + } + Data[1 + Count] = byte.MaxValue; + } + + public byte[] GetBytes() + { + Update(); + return Data; + } + + private int DataSize => Capacity * (Entry_Size + 1 + 2 * StringLength) + 2; + + public static int GetDataLength(CapacityType c, bool jp = false) + { + return getCapacity(c) * (getEntrySize(c) + 1 + 2 * (jp ? PK1.STRLEN_J : PK1.STRLEN_U)) + 2; + } + } +} diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index 8aebbcbae..2020b083a 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -9,6 +9,11 @@ namespace PKHeX { public static class PKX { + internal const int SIZE_1ULIST = 69; + internal const int SIZE_1JLIST = 59; + internal const int SIZE_1PARTY = 40; + internal const int SIZE_1STORED = 33; + internal const int SIZE_3PARTY = 100; internal const int SIZE_3STORED = 80; internal const int SIZE_3BLOCK = 12; @@ -1617,5 +1622,21 @@ namespace PKHeX return 0xFFFF; return arr[g3val]; } + + public static byte setG1Char(ushort chr, bool jp) + { + throw new NotImplementedException(); + } + + public static string getG1Str(byte[] strdata, bool jp) + { + throw new NotImplementedException(); + } + + public static byte[] setG1Str(string str, bool jp) + { + throw new NotImplementedException(); + } + } } diff --git a/PKHeX/Util/ByteUtil.cs b/PKHeX/Util/ByteUtil.cs new file mode 100644 index 000000000..422ac6d9d --- /dev/null +++ b/PKHeX/Util/ByteUtil.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PKHeX +{ + public partial class Util + { + /// + /// Swaps the Endianness of an int + /// Value to swap endianness of. + /// The endianness-swapped value. + internal static int SwapEndianness(int val) + { + return (int) SwapEndianness((uint) val); + } + + /// + /// Swaps the Endianness of a uint + /// Value to swap endianness of. + /// The endianness-swapped value. + internal static uint SwapEndianness(uint val) + { + return ((val & 0x000000FF) << 24) + | ((val & 0x0000FF00) << 8) + | ((val & 0x00FF0000) >> 8) + | ((val & 0xFF000000) >> 24); + } + + /// + /// Swaps the Endianness of a short + /// Value to swap endianness of. + /// The endianness-swapped value. + internal static int SwapEndianness(short val) + { + return (short)SwapEndianness((ushort)val); + } + + /// + /// Swaps the Endianness of a ushort + /// Value to swap endianness of. + /// The endianness-swapped value. + internal static ushort SwapEndianness(ushort val) + { + return (ushort) (((val & 0x00FF) << 8) | ((val & 0xFF00) >> 8)); + } + } +} From b5ec320b0392efe85118c33f1048c675cdad6859 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 27 Aug 2016 02:48:04 -0700 Subject: [PATCH 16/43] Cleanup, add Personal table for RBY --- PKHeX/PKM/PK1.cs | 6 +-- PKHeX/PKM/PKX.cs | 12 +++++ PKHeX/PersonalInfo/PersonalInfoG1.cs | 67 +++++++++++++++++++++++++ PKHeX/PersonalInfo/PersonalTable.cs | 6 +++ PKHeX/Properties/Resources.Designer.cs | 10 ++++ PKHeX/Properties/Resources.resx | 3 ++ PKHeX/Resources/byte/personal_rby | Bin 0 -> 4256 bytes PKHeX/Saves/SaveUtil.cs | 2 + 8 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 PKHeX/PersonalInfo/PersonalInfoG1.cs create mode 100644 PKHeX/Resources/byte/personal_rby diff --git a/PKHeX/PKM/PK1.cs b/PKHeX/PKM/PK1.cs index 89370505f..3b0fcb0f4 100644 --- a/PKHeX/PKM/PK1.cs +++ b/PKHeX/PKM/PK1.cs @@ -73,7 +73,7 @@ namespace PKHeX public override bool IsNicknamed { get { throw new NotImplementedException(); } set { } } #region Stored Attributes - public override int Species { get { return Data[0]; } set { } } + public override int Species { get { return PKX.getG1Species(Data[0]); } set { Data[0] = (byte)PKX.setG1Species(Data[0]); } } public override int Stat_HPCurrent { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x1); } } public int Status_Condition { get { return Data[4]; } set { Data[4] = (byte)value; } } @@ -148,8 +148,8 @@ namespace PKHeX public override ushort Checksum { get { return 0; } set { } } public override int Language { get { return 0; } set { } } public override bool FatefulEncounter { get { return false; } set { } } - public override int TSV => 0; - public override int PSV => 0; + public override int TSV => 0x0000; + public override int PSV => 0xFFFF; public override int Characteristic => -1; public override byte MarkByte { get { return 0; } protected set { } } public override int CurrentFriendship { get { return 0; } set { } } diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index 2020b083a..ebdf74080 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -1623,6 +1623,18 @@ namespace PKHeX return arr[g3val]; } + public static int getG1Species(int raw_id) + { + int[] table = { 0x00, 0x70, 0x73, 0x20, 0x23, 0x15, 0x64, 0x22, 0x50, 0x02, 0x67, 0x6C, 0x66, 0x58, 0x5E, 0x1D, 0x1F, 0x68, 0x6F, 0x83, 0x3B, 0x97, 0x82, 0x5A, 0x48, 0x5C, 0x7B, 0x78, 0x09, 0x7F, 0x72, 0x00, 0x00, 0x3A, 0x5F, 0x16, 0x10, 0x4F, 0x40, 0x4B, 0x71, 0x43, 0x7A, 0x6A, 0x6B, 0x18, 0x2F, 0x36, 0x60, 0x4C, 0x00, 0x7E, 0x00, 0x7D, 0x52, 0x6D, 0x00, 0x38, 0x56, 0x32, 0x80, 0x00, 0x00, 0x00, 0x53, 0x30, 0x95, 0x00, 0x00, 0x00, 0x54, 0x3C, 0x7C, 0x92, 0x90, 0x91, 0x84, 0x34, 0x62, 0x00, 0x00, 0x00, 0x25, 0x26, 0x19, 0x1A, 0x00, 0x00, 0x93, 0x94, 0x8C, 0x8D, 0x74, 0x75, 0x00, 0x00, 0x1B, 0x1C, 0x8A, 0x8B, 0x27, 0x28, 0x85, 0x88, 0x87, 0x86, 0x42, 0x29, 0x17, 0x2E, 0x3D, 0x3E, 0x0D, 0x0E, 0x0F, 0x00, 0x55, 0x39, 0x33, 0x31, 0x57, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x44, 0x00, 0x37, 0x61, 0x2A, 0x96, 0x8F, 0x81, 0x00, 0x00, 0x59, 0x00, 0x63, 0x5B, 0x00, 0x65, 0x24, 0x6E, 0x35, 0x69, 0x00, 0x5D, 0x3F, 0x41, 0x11, 0x12, 0x79, 0x01, 0x03, 0x49, 0x00, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4E, 0x13, 0x14, 0x21, 0x1E, 0x4A, 0x89, 0x8E, 0x00, 0x51, 0x00, 0x00, 0x04, 0x07, 0x05, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x2C, 0x2D, 0x45, 0x46, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + return table[raw_id]; + } + + public static int setG1Species(int dex_id) + { + int[] table = { 0x00, 0x99, 0x09, 0x9A, 0xB0, 0xB2, 0xB4, 0xB1, 0xB3, 0x1C, 0x7B, 0x7C, 0x7D, 0x70, 0x71, 0x72, 0x24, 0x96, 0x97, 0xA5, 0xA6, 0x05, 0x23, 0x6C, 0x2D, 0x54, 0x55, 0x60, 0x61, 0x0F, 0xA8, 0x10, 0x03, 0xA7, 0x07, 0x04, 0x8E, 0x52, 0x53, 0x64, 0x65, 0x6B, 0x82, 0xB9, 0xBA, 0xBB, 0x6D, 0x2E, 0x41, 0x77, 0x3B, 0x76, 0x4D, 0x90, 0x2F, 0x80, 0x39, 0x75, 0x21, 0x14, 0x47, 0x6E, 0x6F, 0x94, 0x26, 0x95, 0x6A, 0x29, 0x7E, 0xBC, 0xBD, 0xBE, 0x18, 0x9B, 0xA9, 0x27, 0x31, 0xA3, 0xA4, 0x25, 0x08, 0xAD, 0x36, 0x40, 0x46, 0x74, 0x3A, 0x78, 0x0D, 0x88, 0x17, 0x8B, 0x19, 0x93, 0x0E, 0x22, 0x30, 0x81, 0x4E, 0x8A, 0x06, 0x8D, 0x0C, 0x0A, 0x11, 0x91, 0x2B, 0x2C, 0x0B, 0x37, 0x8F, 0x12, 0x01, 0x28, 0x1E, 0x02, 0x5C, 0x5D, 0x9D, 0x9E, 0x1B, 0x98, 0x2A, 0x1A, 0x48, 0x35, 0x33, 0x1D, 0x3C, 0x85, 0x16, 0x13, 0x4C, 0x66, 0x69, 0x68, 0x67, 0xAA, 0x62, 0x63, 0x5A, 0x5B, 0xAB, 0x84, 0x4A, 0x4B, 0x49, 0x58, 0x59, 0x42, 0x83, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + return table[dex_id]; + } + public static byte setG1Char(ushort chr, bool jp) { throw new NotImplementedException(); diff --git a/PKHeX/PersonalInfo/PersonalInfoG1.cs b/PKHeX/PersonalInfo/PersonalInfoG1.cs new file mode 100644 index 000000000..f2ae6ff06 --- /dev/null +++ b/PKHeX/PersonalInfo/PersonalInfoG1.cs @@ -0,0 +1,67 @@ +using System; +using System.Linq; + +namespace PKHeX +{ + public class PersonalInfoG1 : PersonalInfo + { + protected PersonalInfoG1() { } + public const int SIZE = 0x1C; + public PersonalInfoG1(byte[] data) + { + if (data.Length != SIZE) + return; + + Data = data; + TMHM = getBits(Data.Skip(0x14).Take(0x8).ToArray()); + } + public override byte[] Write() + { + setBits(TMHM).CopyTo(Data, 0x14); + return Data; + } + + public int DEX_ID { get { return Data[0x00]; } set { Data[0x00] = (byte)value; } } + public override int HP { get { return Data[0x01]; } set { Data[0x01] = (byte)value; } } + public override int ATK { get { return Data[0x02]; } set { Data[0x02] = (byte)value; } } + public override int DEF { get { return Data[0x03]; } set { Data[0x03] = (byte)value; } } + public override int SPE { get { return Data[0x04]; } set { Data[0x04] = (byte)value; } } + public int SPC { get { return Data[0x05]; } set { Data[0x05] = (byte)value; } } + public override int SPA { get { return SPC; } set { SPC = value; } } + public override int SPD { get { return SPC; } set { SPC = value; } } + public override int[] Types + { + get { return new int[] { Data[0x06], Data[0x07] }; } + set + { + if (value?.Length != 2) return; + Data[0x06] = (byte)value[0]; + Data[0x07] = (byte)value[1]; + } + } + public override int CatchRate { get { return Data[0x08]; } set { Data[0x08] = (byte)value; } } + public override int BaseEXP { get { return Data[0x09]; } set { Data[0x09] = (byte)value; } } + public int Move1 { get { return Data[0x0A]; } set { Data[0x0A] = (byte)value; } } + public int Move2 { get { return Data[0x0B]; } set { Data[0x0B] = (byte)value; } } + public int Move3 { get { return Data[0x0C]; } set { Data[0x0C] = (byte)value; } } + public int Move4 { get { return Data[0x0D]; } set { Data[0x0D] = (byte)value; } } + public override int EXPGrowth { get { return Data[0x13]; } set { Data[0x13] = (byte)value; } } + + // Future game values, unused + public override int[] Items { get { return new[] { 0, 0 }; } set { } } + public override int[] EggGroups { get { return new[] { 0, 0 }; } set { } } + public override int[] Abilities { get { return new[] { 0, 0 }; } set { } } + public override int Gender { get { return 0; } set { } } + public override int HatchCycles { get { return 0; } set { } } + public override int BaseFriendship { get { return 0; } set { } } + public override int EscapeRate { get { return 0; } set { } } + public override int Color { get { return 0; } set { } } + private int EVYield { get { return 0; } set { } } + public override int EV_HP { get { return 0; } set { } } + public override int EV_ATK { get { return 0; } set { } } + public override int EV_DEF { get { return 0; } set { } } + public override int EV_SPE { get { return 0; } set { } } + public override int EV_SPA { get { return 0; } set { } } + public override int EV_SPD { get { return 0; } set { } } + } +} diff --git a/PKHeX/PersonalInfo/PersonalTable.cs b/PKHeX/PersonalInfo/PersonalTable.cs index 59d877243..942f1ab5c 100644 --- a/PKHeX/PersonalInfo/PersonalTable.cs +++ b/PKHeX/PersonalInfo/PersonalTable.cs @@ -15,6 +15,7 @@ namespace PKHeX internal static readonly PersonalTable FR = new PersonalTable(Properties.Resources.personal_fr, GameVersion.FR); internal static readonly PersonalTable E = new PersonalTable(Properties.Resources.personal_e, GameVersion.E); internal static readonly PersonalTable RS = new PersonalTable(Properties.Resources.personal_rs, GameVersion.RS); + internal static readonly PersonalTable RBY = new PersonalTable(Properties.Resources.personal_rby, GameVersion.RBY); private static byte[][] splitBytes(byte[] data, int size) { @@ -31,6 +32,7 @@ namespace PKHeX int size = 0; switch (format) { + case GameVersion.RBY: size = PersonalInfoG1.SIZE;break; case GameVersion.RS: case GameVersion.E: case GameVersion.FR: @@ -52,6 +54,10 @@ namespace PKHeX switch (format) { + case GameVersion.RBY: + for (int i = 0; i < d.Length; i++) + d[i] = new PersonalInfoG1(entries[i]); + break; case GameVersion.RS: case GameVersion.E: case GameVersion.FR: diff --git a/PKHeX/Properties/Resources.Designer.cs b/PKHeX/Properties/Resources.Designer.cs index 1f66ae539..f71d2bdbb 100644 --- a/PKHeX/Properties/Resources.Designer.cs +++ b/PKHeX/Properties/Resources.Designer.cs @@ -15555,6 +15555,16 @@ namespace PKHeX.Properties { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] personal_rby { + get { + object obj = ResourceManager.GetObject("personal_rby", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// diff --git a/PKHeX/Properties/Resources.resx b/PKHeX/Properties/Resources.resx index 67d0daac7..0d2026914 100644 --- a/PKHeX/Properties/Resources.resx +++ b/PKHeX/Properties/Resources.resx @@ -6391,4 +6391,7 @@ ..\Resources\img\box\swapBox.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\byte\personal_rby;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/PKHeX/Resources/byte/personal_rby b/PKHeX/Resources/byte/personal_rby new file mode 100644 index 0000000000000000000000000000000000000000..ccd7a53c07b5faaf351958bdef89fb92da377e52 GIT binary patch literal 4256 zcmZ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aveUtil.cs +++ b/PKHeX/Saves/SaveUtil.cs @@ -18,6 +18,8 @@ namespace PKHeX SN = 28, MN = 29, // Game Groupings (SaveFile type) + RBY = 98, + GSC = 99, RS = 100, FRLG = 101, DP = 102, From e4ec1cb45fc479e7216cfb4e2dda2462521a6ddd Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 27 Aug 2016 02:56:15 -0700 Subject: [PATCH 17/43] Fix PK1 Species setting --- PKHeX/PKM/PK1.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/PKHeX/PKM/PK1.cs b/PKHeX/PKM/PK1.cs index 3b0fcb0f4..ffe725310 100644 --- a/PKHeX/PKM/PK1.cs +++ b/PKHeX/PKM/PK1.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Linq.Expressions; namespace PKHeX { @@ -73,7 +74,19 @@ namespace PKHeX public override bool IsNicknamed { get { throw new NotImplementedException(); } set { } } #region Stored Attributes - public override int Species { get { return PKX.getG1Species(Data[0]); } set { Data[0] = (byte)PKX.setG1Species(Data[0]); } } + public override int Species + { + get { return PKX.getG1Species(Data[0]); } + set + { + // Before updating catch rate, check if Special Yellow Version Pikachu + if (!(PKX.getG1Species(Data[0]) == 25 && value == 25 && Catch_Rate == 163)) + Catch_Rate = PersonalTable.RBY[value].CatchRate; + Data[0] = (byte)PKX.setG1Species(value); + Type_A = PersonalTable.RBY[value].Types[0]; + Type_B = PersonalTable.RBY[value].Types[1]; + } + } public override int Stat_HPCurrent { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x1); } } public int Status_Condition { get { return Data[4]; } set { Data[4] = (byte)value; } } From b2342cddb9f6e9c1c636c0d2080d7c07adec4351 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 27 Aug 2016 04:33:21 -0700 Subject: [PATCH 18/43] SAV1 skeleton implementation --- PKHeX/PKHeX.csproj | 3 + PKHeX/PKM/PK1.cs | 8 +- PKHeX/PersonalInfo/PersonalInfoG1.cs | 16 +- PKHeX/Saves/Inventory.cs | 4 +- PKHeX/Saves/SAV1.cs | 312 +++++++++++++++++++++++++++ PKHeX/Saves/SaveFile.cs | 2 + PKHeX/Saves/SaveUtil.cs | 45 ++++ 7 files changed, 378 insertions(+), 12 deletions(-) create mode 100644 PKHeX/Saves/SAV1.cs diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index 4af47f6a3..db1be6497 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -90,6 +90,7 @@ + @@ -115,6 +116,7 @@ + @@ -462,6 +464,7 @@ + diff --git a/PKHeX/PKM/PK1.cs b/PKHeX/PKM/PK1.cs index ffe725310..07d4365a8 100644 --- a/PKHeX/PKM/PK1.cs +++ b/PKHeX/PKM/PK1.cs @@ -186,7 +186,7 @@ namespace PKHeX #endregion } - class PokemonList + class PokemonList1 { internal const int CAPACITY_DAYCARE = 1; internal const int CAPACITY_PARTY = 6; @@ -225,7 +225,7 @@ namespace PKHeX return new[] { (byte)0 }.Concat(Enumerable.Repeat((byte)0xFF, cap + 1)).Concat(Enumerable.Repeat((byte)0, getEntrySize(c) * cap)).Concat(Enumerable.Repeat((byte)0x50, (is_JP ? PK1.STRLEN_J : PK1.STRLEN_U) * 2 * cap)).ToArray(); } - public PokemonList(byte[] d, CapacityType c = CapacityType.Single, bool jp = false) + public PokemonList1(byte[] d, CapacityType c = CapacityType.Single, bool jp = false) { Japanese = jp; Data = d ?? getEmptyList(c, Japanese); @@ -248,13 +248,13 @@ namespace PKHeX } } - public PokemonList(CapacityType c = CapacityType.Single, bool jp = false) + public PokemonList1(CapacityType c = CapacityType.Single, bool jp = false) : this(null, c, jp) { Count = 1; } - public PokemonList(PK1 pk) + public PokemonList1(PK1 pk) : this(CapacityType.Single, pk.Japanese) { this[0] = pk; diff --git a/PKHeX/PersonalInfo/PersonalInfoG1.cs b/PKHeX/PersonalInfo/PersonalInfoG1.cs index f2ae6ff06..7d4d8bbc0 100644 --- a/PKHeX/PersonalInfo/PersonalInfoG1.cs +++ b/PKHeX/PersonalInfo/PersonalInfoG1.cs @@ -47,6 +47,15 @@ namespace PKHeX public int Move4 { get { return Data[0x0D]; } set { Data[0x0D] = (byte)value; } } public override int EXPGrowth { get { return Data[0x13]; } set { Data[0x13] = (byte)value; } } + // EV Yields are just aliases for base stats in Gen I + public override int EV_HP { get { return HP; } set { } } + public override int EV_ATK { get { return ATK; } set { } } + public override int EV_DEF { get { return DEF; } set { } } + public override int EV_SPE { get { return SPE; } set { } } + public int EV_SPC { get { return SPC; } set { } } + public override int EV_SPA { get { return EV_SPC; } set { } } + public override int EV_SPD { get { return EV_SPC; } set { } } + // Future game values, unused public override int[] Items { get { return new[] { 0, 0 }; } set { } } public override int[] EggGroups { get { return new[] { 0, 0 }; } set { } } @@ -56,12 +65,5 @@ namespace PKHeX public override int BaseFriendship { get { return 0; } set { } } public override int EscapeRate { get { return 0; } set { } } public override int Color { get { return 0; } set { } } - private int EVYield { get { return 0; } set { } } - public override int EV_HP { get { return 0; } set { } } - public override int EV_ATK { get { return 0; } set { } } - public override int EV_DEF { get { return 0; } set { } } - public override int EV_SPE { get { return 0; } set { } } - public override int EV_SPA { get { return 0; } set { } } - public override int EV_SPD { get { return 0; } set { } } } } diff --git a/PKHeX/Saves/Inventory.cs b/PKHeX/Saves/Inventory.cs index 036bb9e39..c49391632 100644 --- a/PKHeX/Saves/Inventory.cs +++ b/PKHeX/Saves/Inventory.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace PKHeX { @@ -23,7 +24,8 @@ namespace PKHeX public readonly InventoryType Type; public readonly ushort[] LegalItems; public readonly int MaxCount; - private readonly int Offset; + public int Count => Items.Count(it => it.Count > 0); + public readonly int Offset; private readonly int PouchDataSize; public uint SecurityKey { private get; set; } // = 0 // Gen3 Only public InventoryItem[] Items; diff --git a/PKHeX/Saves/SAV1.cs b/PKHeX/Saves/SAV1.cs new file mode 100644 index 000000000..30e0cad31 --- /dev/null +++ b/PKHeX/Saves/SAV1.cs @@ -0,0 +1,312 @@ +using System; +using System.Globalization; +using System.Linq; + +namespace PKHeX +{ + public sealed class SAV1 : SaveFile + { + public override string BAKName => $"{FileName} [{OT} ({Version})" +/* - {LastSavedTime}*/ "].bak"; + public override string Filter => "SAV File|*.sav"; + public override string Extension => ".sav"; + + public SAV1(byte[] data = null) + { + Data = data == null ? new byte[SaveUtil.SIZE_G1RAW] : (byte[])data.Clone(); + BAK = (byte[])Data.Clone(); + Exportable = !Data.SequenceEqual(new byte[Data.Length]); + + if (data == null) + Version = GameVersion.RBY; + else Version = SaveUtil.getIsG1SAV(Data); + if (Version == GameVersion.Invalid) + return; + + Japanese = SaveUtil.getIsG1SAVJ(data); + + OFS_PouchHeldItem = (Japanese ? 0x25C4 : 0x25C9); + OFS_PCItem = (Japanese ? 0x27DC : 0x27E6); + Personal = PersonalTable.RBY; + + if (!Exportable) + resetBoxes(); + } + + private const int SIZE_RESERVED = 0x10000; // unpacked box data + public override byte[] Write(bool DSV) + { + + setChecksums(); + return Data; + } + + + // Configuration + public override SaveFile Clone() { return new SAV1(Data); } + + public override int SIZE_STORED => PKX.SIZE_1STORED; + public override int SIZE_PARTY => PKX.SIZE_1PARTY; + public override PKM BlankPKM => new PK1(); + protected override Type PKMType => typeof(PK1); + + public override int MaxMoveID => 165; + public override int MaxSpeciesID => 151; + public override int MaxAbilityID => 0; + public override int MaxItemID => 255; + public override int MaxBallID => 0; + public override int MaxGameID => 99; // What do I set this to...? + + public override int BoxCount => Japanese ? 8 : 12; + public override int MaxEV => 65535; + public override int Generation => 1; + protected override int GiftCountMax => 0; + public override int OTLength => Japanese ? 5 : 10; + public override int NickLength => Japanese ? 5 : 10; + + public override bool HasParty => true; + + // Checksums + protected override void setChecksums() + { + int CHECKSUM_OFS = Japanese ? 0x3594 : 0x3523; + Data[CHECKSUM_OFS] = 0; + uint chksum = 0; + for (int i = 0x2598; i < CHECKSUM_OFS; i++) + { + chksum += Data[i]; + } + + chksum = ~chksum; + chksum &= 0xFF; + + Data[CHECKSUM_OFS] = (byte)chksum; + } + public override bool ChecksumsValid + { + get + { + int CHECKSUM_OFS = Japanese ? 0x3594 : 0x3523; + Data[CHECKSUM_OFS] = 0; + uint chksum = 0; + for (int i = 0x2598; i < CHECKSUM_OFS; i++) + { + chksum += Data[i]; + } + + chksum = ~chksum; + chksum &= 0xFF; + + return Data[CHECKSUM_OFS] == (byte)chksum; + } + } + public override string ChecksumInfo + { + get + { + return ChecksumsValid ? "Checksum valid." : "Checksum invalid"; + } + } + + // Trainer Info + public override GameVersion Version { get; protected set; } + + private int StringLength => Japanese ? PK1.STRLEN_J : PK1.STRLEN_U; + + public override string OT + { + get { return PKX.getG3Str(Data.Skip(0x2598).Take(StringLength).ToArray(), Japanese); } + set + { + byte[] strdata = PKX.setG1Str(value, Japanese); + if (strdata.Length > StringLength) + throw new ArgumentOutOfRangeException("OT Name too long for given save file."); + strdata.CopyTo(Data, 0x2598); + } + } + public override int Gender + { + get { return 0; } + set { } + } + public override ushort TID + { + get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, Japanese ? 0x25FB : 0x2605)); } + set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, Japanese ? 0x25FB : 0x2605); } + } + public override ushort SID + { + get { return 0; } + set { } + } + public override int PlayedHours + { + get { return BitConverter.ToUInt16(Data, Japanese ? 0x2CA0 : 0x2CED); } + set { BitConverter.GetBytes((ushort)value).CopyTo(Data, Japanese ? 0x2CA0 : 0x2CED); } + } + public override int PlayedMinutes + { + get { return Data[Japanese ? 0x2CA2 : 0x2CEF]; } + set { Data[Japanese ? 0x2CA2 : 0x2CEF] = (byte)value; } + } + public override int PlayedSeconds + { + get { return Data[Japanese ? 0x2CA3 : 0x2CF0]; } + set { Data[Japanese ? 0x2CA3 : 0x2CF0] = (byte)value; } + } + + public override uint Money + { + get { return uint.Parse((Util.SwapEndianness(BitConverter.ToUInt32(Data, Japanese ? 0x25EE : 0x25F3)) >> 8).ToString("X6")); } + set + { + BitConverter.GetBytes(Util.SwapEndianness(uint.Parse(value.ToString("000000"), NumberStyles.HexNumber))).Skip(1).ToArray().CopyTo(Data, Japanese ? 0x25EE : 0x25F3); + } + } + public uint Coin + { + get + { + return uint.Parse(Util.SwapEndianness(BitConverter.ToUInt16(Data, Japanese ? 0x2846 : 0x2850)).ToString("X4")); + } + set + { + BitConverter.GetBytes(Util.SwapEndianness(ushort.Parse(value.ToString("0000"), NumberStyles.HexNumber))).ToArray().CopyTo(Data, Japanese ? 0x2846 : 0x2850); + } + } + + private readonly ushort[] LegalItems, LegalKeyItems, LegalBalls, LegalTMHMs, LegalBerries; + public override InventoryPouch[] Inventory + { + get + { + ushort[] legalItems = LegalItems; + InventoryPouch[] pouch = + { + new InventoryPouch(InventoryType.Items, legalItems, 99, OFS_PouchHeldItem + 2, 20), + new InventoryPouch(InventoryType.Items, legalItems, 99, OFS_PCItem + 2, 50), + }; + foreach (var p in pouch) + { + p.getPouch(ref Data); + int ofs = 0; + for (int i = 0; i < p.Count; i++) + { + while (p.Items[ofs].Count == 0) + ofs++; + p.Items[i] = p.Items[ofs++]; + } + while (ofs < p.MaxCount) + p.Items[ofs++] = new InventoryItem { Count = 0, Index = 0 }; + } + return pouch; + } + set + { + foreach (var p in value) + { + int ofs = 0; + for (int i = 0; i < p.Count; i++) + { + while (p.Items[ofs].Count == 0) + ofs++; + p.Items[i] = p.Items[ofs++]; + } + while (ofs < p.MaxCount) + p.Items[ofs++] = new InventoryItem { Count = 0, Index = 0 }; + p.setPouch(ref Data); + Data[p.Offset - 2] = (byte)p.Count; + } + } + } + public override int getDaycareSlotOffset(int loc = 0, int slot = 0) + { + return Daycare; + } + public override ulong? getDaycareRNGSeed(int loc) + { + return null; + } + public override uint? getDaycareEXP(int loc = 0, int slot = 0) + { + return null; + } + public override bool? getDaycareOccupied(int loc, int slot) + { + return null; + } + public override void setDaycareEXP(int loc, int slot, uint EXP) + { + + } + public override void setDaycareOccupied(int loc, int slot, bool occupied) + { + + } + + // Storage + public override int PartyCount + { + get { return Data[Japanese ? 0x2ED5 : 0x2F2C]; } + protected set + { + Data[Japanese ? 0x2ED5 : 0x2F2C] = (byte)value; + } + } + public override int getBoxOffset(int box) + { + throw new NotImplementedException(); + } + public override int getPartyOffset(int slot) + { + throw new NotImplementedException(); + } + public override int CurrentBox + { + get { return Data[Japanese ? 0x2842 : 0x284C]; } + set { Data[Japanese ? 0x2842 : 0x284C] = (byte)value; } + } + public override int getBoxWallpaper(int box) + { + return 0; + } + public override string getBoxName(int box) + { + int boxNum = box + 1; + return $"Box {boxNum}"; + } + public override void setBoxName(int box, string value) + { + + } + public override PKM getPKM(byte[] data) + { + if (data.Length == PKX.SIZE_1JLIST || data.Length == PKX.SIZE_1ULIST) + return new PokemonList1(data, PokemonList1.CapacityType.Single, Japanese)[0]; + return new PK1(data); + } + public override byte[] decryptPKM(byte[] data) + { + return data; + } + + protected override void setDex(PKM pkm) + { + if (pkm.Species == 0) + return; + if (pkm.Species > MaxSpeciesID) + return; + if (Version == GameVersion.Unknown) + return; + + int bit = pkm.Species - 1; + int ofs = bit >> 3; + byte bitval = (byte)(1 << (bit % 7)); + + // Set the Captured Flag + Data[(Japanese ? 0x259E : 0x25A3) + ofs] |= bitval; + + // Set the Seen Flag + Data[(Japanese ? 0x25B1 : 0x25B6) + ofs] |= bitval; + } + } +} diff --git a/PKHeX/Saves/SaveFile.cs b/PKHeX/Saves/SaveFile.cs index 8db12ea12..84533da8c 100644 --- a/PKHeX/Saves/SaveFile.cs +++ b/PKHeX/Saves/SaveFile.cs @@ -58,6 +58,7 @@ namespace PKHeX public bool E => Version == GameVersion.E; public bool FRLG => Version == GameVersion.FRLG; public bool RS => Version == GameVersion.RS; + public bool RBY => Version == GameVersion.RBY; public virtual int MaxMoveID => int.MaxValue; public virtual int MaxSpeciesID => int.MaxValue; @@ -260,6 +261,7 @@ namespace PKHeX protected int OFS_PouchBalls { get; set; } = int.MinValue; protected int OFS_BattleItems { get; set; } = int.MinValue; protected int OFS_MailItems { get; set; } = int.MinValue; + protected int OFS_PCItem { get; set; } = int.MinValue; // Mystery Gift protected virtual bool[] MysteryGiftReceivedFlags { get { return null; } set { } } diff --git a/PKHeX/Saves/SaveUtil.cs b/PKHeX/Saves/SaveUtil.cs index f4c54989b..f10c94de9 100644 --- a/PKHeX/Saves/SaveUtil.cs +++ b/PKHeX/Saves/SaveUtil.cs @@ -45,6 +45,8 @@ namespace PKHeX internal const int SIZE_G4RAW = 0x80000; internal const int SIZE_G3RAW = 0x20000; internal const int SIZE_G3RAWHALF = 0x10000; + internal const int SIZE_G1RAW = 0x8000; + internal const int SIZE_G1BAT = 0x802C; internal static readonly byte[] FOOTER_DSV = Encoding.ASCII.GetBytes("|-DESMUME SAVE-|"); @@ -53,6 +55,8 @@ namespace PKHeX /// Version Identifier or Invalid if type cannot be determined. public static int getSAVGeneration(byte[] data) { + if (getIsG1SAV(data) != GameVersion.Invalid) + return 1; if (getIsG3SAV(data) != GameVersion.Invalid) return 3; if (getIsG4SAV(data) != GameVersion.Invalid) @@ -63,6 +67,47 @@ namespace PKHeX return 6; return -1; } + /// Determines the type of 1st gen save + /// Save data of which to determine the type + /// Version Identifier or Invalid if type cannot be determined. + public static GameVersion getIsG1SAV(byte[] data) + { + if (data.Length != SIZE_G1RAW && data.Length != SIZE_G1BAT) + return GameVersion.Invalid; + + // Check if it's not an american save or a japanese save + if (!(getIsG1SAVU(data) || getIsG1SAVJ(data))) + return GameVersion.Invalid; + // I can't actually detect which game version, because it's not stored anywhere. + // If you can think of anything to do here, please implement :) + return GameVersion.RBY; + } + /// Determines if 1st gen save is non-japanese + /// Save data of which to determine the region + /// True if a valid non-japanese save, False otherwise. + public static bool getIsG1SAVU(byte[] data) + { + foreach (int ofs in new[] { 0x2F2C, 0x30C0 }) + { + byte num_entries = data[ofs]; + if (num_entries > 20 || data[ofs + 1 + num_entries] != 0xFF) + return false; + } + return true; + } + /// Determines if 1st gen save is japanese + /// Save data of which to determine the region + /// True if a valid japanese save, False otherwise. + public static bool getIsG1SAVJ(byte[] data) + { + foreach (int ofs in new[] { 0x2ED5, 0x302D }) + { + byte num_entries = data[ofs]; + if (num_entries > 30 || data[ofs + 1 + num_entries] != 0xFF) + return false; + } + return true; + } /// Determines the type of 3th gen save /// Save data of which to determine the type /// Version Identifier or Invalid if type cannot be determined. From e0298595f4d500f9e43d1feed82086de331ce50f Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 27 Aug 2016 08:30:56 -0700 Subject: [PATCH 19/43] Fix evomethod 2 Fixes #203, thanks @Rohul1997 ! --- PKHeX/Legality/Core.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 29fcad10c..f29c885f9 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -525,7 +525,7 @@ namespace PKHeX if (lvl >= pk6.Met_Level && lvl >= evo.Level) dl.Add(new DexLevel {Species = evo.Species, Level = lvl}); else break; - if (evo.Level > 1) // Level Up (from previous level) + if (evo.Level > 2) // Level Up (from previous level) lvl--; } return dl; From 3291f4eb2b81115c1d6442ef5fde27b6e3b7be8d Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 27 Aug 2016 08:43:36 -0700 Subject: [PATCH 20/43] Relocate relearnmoves derived property --- PKHeX/PKM/PK6.cs | 12 ------------ PKHeX/PKM/PKM.cs | 11 +++++++++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/PKHeX/PKM/PK6.cs b/PKHeX/PKM/PK6.cs index b731d2b26..c30b9db71 100644 --- a/PKHeX/PKM/PK6.cs +++ b/PKHeX/PKM/PK6.cs @@ -411,18 +411,6 @@ namespace PKHeX public bool IsUntraded => string.IsNullOrWhiteSpace(HT_Name); public bool IsUntradedEvent6 => Geo1_Country == 0 && Geo1_Region == 0 && Met_Location / 10000 == 4 && Gen6; - public int[] RelearnMoves - { - get { return new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 }; } - set - { - if (value.Length > 0) RelearnMove1 = value[0]; - if (value.Length > 1) RelearnMove2 = value[1]; - if (value.Length > 2) RelearnMove3 = value[2]; - if (value.Length > 3) RelearnMove4 = value[3]; - } - } - // Complex Generated Attributes public override int Characteristic diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 949efd682..50343529c 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -287,6 +287,17 @@ namespace PKHeX get { return new[] { Move1, Move2, Move3, Move4 }; } set { if (value?.Length != 4) return; Move1 = value[0]; Move2 = value[1]; Move3 = value[2]; Move4 = value[3]; } } + public int[] RelearnMoves + { + get { return new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 }; } + set + { + if (value.Length > 0) RelearnMove1 = value[0]; + if (value.Length > 1) RelearnMove2 = value[1]; + if (value.Length > 2) RelearnMove3 = value[2]; + if (value.Length > 3) RelearnMove4 = value[3]; + } + } public int PIDAbility { get From 1484c15ff39e226fb541a028679422b1443b1123 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 27 Aug 2016 08:56:50 -0700 Subject: [PATCH 21/43] Refresh suggested relearn indication Closes #202 Wasn't a bug, just that the indication didn't update. Don't do a per-move update, just refresh the legality. --- PKHeX/MainWindow/Main.cs | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 5f63b6f04..99351aa3b 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -2236,28 +2236,13 @@ namespace PKHeX if (new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 }.Contains(sender)) // Move updatePP(sender, e); - // Refresh Relearn if... - if (new[] { CB_RelearnMove1, CB_RelearnMove2, CB_RelearnMove3, CB_RelearnMove4 }.Contains(sender)) - { - if (pkm.Format < 6) - return; - ((PK6) pkm).RelearnMoves = new[] { Util.getIndex(CB_RelearnMove1), Util.getIndex(CB_RelearnMove2), Util.getIndex(CB_RelearnMove3), Util.getIndex(CB_RelearnMove4) }; - Legality.updateRelearnLegality(); - for (int i = 0; i < 4; i++) - movePB[i].Visible = !Legality.vRelearn[i].Valid; - } - // else, Refresh Moves - { - pkm.Moves = new[] { Util.getIndex(CB_Move1), Util.getIndex(CB_Move2), Util.getIndex(CB_Move3), Util.getIndex(CB_Move4) }; - Legality.updateMoveLegality(); - for (int i = 0; i < 4; i++) - movePB[i].Visible = !Legality.vMoves[i].Valid; - } - if (relearnPB.Any(p => p.Visible) || movePB.Any(p => p.Visible)) - { - Legality.Valid = false; - PB_Legal.Image = Properties.Resources.warn; - } + if (pkm.Format < 6) + return; + + // Legality + pkm.Moves = new[] { Util.getIndex(CB_Move1), Util.getIndex(CB_Move2), Util.getIndex(CB_Move3), Util.getIndex(CB_Move4) }; + pkm.RelearnMoves = new[] { Util.getIndex(CB_RelearnMove1), Util.getIndex(CB_RelearnMove2), Util.getIndex(CB_RelearnMove3), Util.getIndex(CB_RelearnMove4) }; + updateLegality(); } private void validateLocation(object sender, EventArgs e) { @@ -2293,8 +2278,15 @@ namespace PKHeX // Refresh Move Legality for (int i = 0; i < 4; i++) movePB[i].Visible = !Legality.vMoves[i].Valid && !HaX; + + int[] suggested = Legality.getSuggestedRelearn(); for (int i = 0; i < 4; i++) - relearnPB[i].Visible = !Legality.vRelearn[i].Valid && !HaX; + { + if (pkm.RelearnMoves[i] == 0 && suggested[i] != 0) + relearnPB[i].Visible = !HaX; + else + relearnPB[i].Visible = !Legality.vRelearn[i].Valid && !HaX; + } } private void updateStats() { From a2f00998227e99f9475d4b0af1b486bc9f8b2aff Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 27 Aug 2016 13:05:01 -0700 Subject: [PATCH 22/43] Per-Version sorting for met lists Closes #197 Populates raw location lists on language init, when changing selected version it obtains a new list and sorts. --- PKHeX/MainWindow/Main.cs | 237 +++++++++++++++++++++++---------------- PKHeX/Saves/SaveUtil.cs | 75 ++++++++++++- 2 files changed, 212 insertions(+), 100 deletions(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 99351aa3b..86f234ed9 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -151,6 +151,7 @@ namespace PKHeX public static string[] wallpapernames, puffs = { }; public static bool unicode; public static List MoveDataSource, ItemDataSource, SpeciesDataSource, BallDataSource, NatureDataSource, AbilityDataSource, VersionDataSource; + private static List metGen1, metGen2, metGen3, metGen4, metGen5, metGen6; public static volatile bool formInitialized, fieldsInitialized, fieldsLoaded; private static int colorizedbox = -1; @@ -172,7 +173,7 @@ namespace PKHeX "中文", // CHN "Português", // Portuguese }; - private static string origintrack; + private static GameVersion origintrack; private readonly PictureBox[] SlotPictureBoxes, movePB, relearnPB; private readonly ToolTip Tip1 = new ToolTip(), Tip2 = new ToolTip(), Tip3 = new ToolTip(), NatureTip = new ToolTip(); #endregion @@ -1051,7 +1052,7 @@ namespace PKHeX abilitylist[0] = itemlist[0] = movelist[0] = metXY_00000[0] = metBW2_00000[0] = metHGSS_00000[0] = "(" + itemlist[0] + ")"; // Force an update to the met locations - origintrack = ""; + origintrack = GameVersion.Unknown; // Update Legality Analysis strings LegalityAnalysis.movelist = movelist; @@ -1108,6 +1109,48 @@ namespace PKHeX MoveDataSource = Util.getCBList(movelist, null); + #region Met Locations + // Gen 3 + { + var met_list = Util.getCBList(metRSEFRLG_00000, Enumerable.Range(0, 213).ToArray()); + met_list = Util.getOffsetCBList(met_list, metRSEFRLG_00000, 00000, new[] { 253, 254, 255 }); + metGen3 = met_list; + } + // Gen 4 + { + var met_list = Util.getCBList(metHGSS_00000, new[] { 0 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2000 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2002 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, new[] { 3001 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_00000, 0000, Legal.Met_HGSS_0); + met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, Legal.Met_HGSS_2); + met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, Legal.Met_HGSS_3); + metGen4 = met_list; + } + // Gen 5 + { + var met_list = Util.getCBList(metBW2_00000, new[] { 0 }); + met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, new[] { 60002 }); + met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, new[] { 30003 }); + met_list = Util.getOffsetCBList(met_list, metBW2_00000, 00000, Legal.Met_BW2_0); + met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, Legal.Met_BW2_3); + met_list = Util.getOffsetCBList(met_list, metBW2_40000, 40001, Legal.Met_BW2_4); + met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, Legal.Met_BW2_6); + metGen5 = met_list; + } + // Gen 6 + { + var met_list = Util.getCBList(metXY_00000, new[] { 0 }); + met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, new[] { 60002 }); + met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, new[] { 30002 }); + met_list = Util.getOffsetCBList(met_list, metXY_00000, 00000, Legal.Met_XY_0); + met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, Legal.Met_XY_3); + met_list = Util.getOffsetCBList(met_list, metXY_40000, 40001, Legal.Met_XY_4); + met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, Legal.Met_XY_6); + metGen6 = met_list; + } + #endregion + CB_EncounterType.DataSource = Util.getCBList(encountertypelist, new[] { 0 }, Legal.Gen4EncounterTypes); CB_HPType.DataSource = Util.getCBList(types.Skip(1).Take(16).ToArray(), null); CB_Nature.DataSource = new BindingSource(NatureDataSource, null); @@ -1877,114 +1920,112 @@ namespace PKHeX updateLegality(); } + private IEnumerable getLocationList(GameVersion Version, int SaveFormat, bool egg) + { + if (egg) + { + if (Version < GameVersion.W && SaveFormat >= 5) + return metGen4; + } + + switch (Version) + { + case GameVersion.CXD: + if (SaveFormat == 3) + return metGen3; + break; + + case GameVersion.R: + case GameVersion.S: + if (SaveFormat == 3) + return metGen3.OrderByDescending(loc => loc.Value <= 87); // Ferry + break; + case GameVersion.E: + if (SaveFormat == 3) + return metGen3.OrderByDescending(loc => loc.Value <= 87 || (loc.Value >= 196 && loc.Value <= 212)); // Trainer Hill + break; + case GameVersion.FR: + case GameVersion.LG: + if (SaveFormat == 3) + return metGen3.OrderByDescending(loc => loc.Value > 87 && loc.Value < 197); // Celadon Dept. + break; + + case GameVersion.D: + case GameVersion.P: + if (SaveFormat == 4 || (SaveFormat >= 5 && egg)) + return metGen4.Take(4).Concat(metGen6.Skip(4).OrderByDescending(loc => loc.Value <= 111)); // Battle Park + break; + + case GameVersion.Pt: + if (SaveFormat == 4 || (SaveFormat >= 5 && egg)) + return metGen4.Take(4).Concat(metGen6.Skip(4).OrderByDescending(loc => loc.Value <= 125)); // Rock Peak Ruins + break; + + case GameVersion.HG: + case GameVersion.SS: + if (SaveFormat == 4 || (SaveFormat >= 5 && egg)) + return metGen4.Take(4).Concat(metGen6.Skip(4).OrderByDescending(loc => loc.Value > 125 && loc.Value < 234)); // Celadon Dept. + break; + + case GameVersion.B: + case GameVersion.W: + return metGen5; + + case GameVersion.B2: + case GameVersion.W2: + return metGen5.Take(3).Concat(metGen5.Skip(3).OrderByDescending(loc => loc.Value <= 116)); // Abyssal Ruins + + case GameVersion.X: + case GameVersion.Y: + return metGen6.Take(3).Concat(metGen6.Skip(3).OrderByDescending(loc => loc.Value <= 168)); // Unknown Dungeon + + case GameVersion.OR: + case GameVersion.AS: + return metGen6.Take(3).Concat(metGen6.Skip(3).OrderByDescending(loc => loc.Value > 168 && loc.Value <= 354)); // Secret Base + } + + // Currently on a future game, return corresponding list for generation + if (Version <= GameVersion.CXD && SaveFormat == 4) + return metGen4.Where(loc => loc.Value == 0x37) // Pal Park to front + .Concat(metGen4.Take(4)) + .Concat(metGen4.Skip(4).Where(loc => loc.Value != 0x37)); + + if (Version < GameVersion.X && SaveFormat >= 5) // PokéTransfer to front + return metGen5.Where(loc => loc.Value == 30001) + .Concat(metGen5.Take(3)) + .Concat(metGen5.Skip(3).Where(loc => loc.Value != 30001)); + + return metGen6; + } private void updateOriginGame(object sender, EventArgs e) { - int Version = Util.getIndex(CB_GameOrigin); - - if (SAV.Generation == 3 && origintrack != "Gen3") + GameVersion Version = (GameVersion)Util.getIndex(CB_GameOrigin); + + // check if differs + GameVersion newTrack = SaveUtil.getVersionGroup(Version); + if (newTrack != origintrack) { - var met_list = Util.getCBList(metRSEFRLG_00000, Enumerable.Range(0, 213).ToArray()); - met_list = Util.getOffsetCBList(met_list, metRSEFRLG_00000, 00000, new[] {253, 254, 255}); - origintrack = "Gen3"; + var met_list = getLocationList(Version, SAV.Generation, egg:false); CB_MetLocation.DisplayMember = "Text"; CB_MetLocation.ValueMember = "Value"; - CB_MetLocation.DataSource = met_list; - CB_MetLocation.SelectedValue = 0; - } - else if (SAV.Generation == 4 && origintrack != "Gen4") - { - var met_list = Util.getCBList(metHGSS_00000, new[] { 0 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2000 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2002 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, new[] { 3001 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_00000, 0000, Legal.Met_HGSS_0); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, Legal.Met_HGSS_2); - met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, Legal.Met_HGSS_3); - CB_MetLocation.DisplayMember = "Text"; - CB_MetLocation.ValueMember = "Value"; - CB_MetLocation.DataSource = met_list; + CB_MetLocation.DataSource = new BindingSource(met_list, null); + CB_MetLocation.SelectedIndex = 0; // transporter or pal park for past gen pkm + + var egg_list = getLocationList(Version, SAV.Generation, egg:true); CB_EggLocation.DisplayMember = "Text"; CB_EggLocation.ValueMember = "Value"; - CB_EggLocation.DataSource = new BindingSource(met_list, null); - CB_EggLocation.SelectedValue = 0; - CB_MetLocation.SelectedValue = 0; - origintrack = "Gen4"; - } - else if (Version < 24 && origintrack != "Past" && SAV.Generation >= 5) - { - // Load Past Gen Locations - #region B2W2 Met Locations - { - // Build up our met list - var met_list = Util.getCBList(metBW2_00000, new[] { 0 }); - met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, new[] { 60002 }); - met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, new[] { 30003 }); - met_list = Util.getOffsetCBList(met_list, metBW2_00000, 00000, Legal.Met_BW2_0); - met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, Legal.Met_BW2_3); - met_list = Util.getOffsetCBList(met_list, metBW2_40000, 40001, Legal.Met_BW2_4); - met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, Legal.Met_BW2_6); - CB_MetLocation.DisplayMember = "Text"; - CB_MetLocation.ValueMember = "Value"; - CB_MetLocation.DataSource = met_list; - CB_EggLocation.DisplayMember = "Text"; - CB_EggLocation.ValueMember = "Value"; - CB_EggLocation.DataSource = new BindingSource(met_list, null); - CB_EggLocation.SelectedValue = 0; - CB_MetLocation.SelectedValue = Version < 20 ? 30001 : 60001; - origintrack = "Past"; - } - #endregion - } - else if (Version > 23 && origintrack != "XY") - { - // Load X/Y/OR/AS locations - #region ORAS Met Locations - { - // Build up our met list - var met_list = Util.getCBList(metXY_00000, new[] { 0 }); - met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, new[] { 60002 }); - met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, new[] { 30002 }); - met_list = Util.getOffsetCBList(met_list, metXY_00000, 00000, Legal.Met_XY_0); - met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, Legal.Met_XY_3); - met_list = Util.getOffsetCBList(met_list, metXY_40000, 40001, Legal.Met_XY_4); - met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, Legal.Met_XY_6); - CB_MetLocation.DisplayMember = "Text"; - CB_MetLocation.ValueMember = "Value"; - CB_MetLocation.DataSource = met_list; - CB_EggLocation.DisplayMember = "Text"; - CB_EggLocation.ValueMember = "Value"; - CB_EggLocation.DataSource = new BindingSource(met_list, null); - CB_EggLocation.SelectedValue = 0; - CB_MetLocation.SelectedValue = 0; - origintrack = "XY"; - } - #endregion - } + CB_EggLocation.DataSource = new BindingSource(egg_list, null); + CB_EggLocation.SelectedIndex = CHK_AsEgg.Checked ? 1 : 0; // daycare : none - if (SAV.Generation >= 4 && Version < 0x10 && origintrack != "Gen4") - { - // Load Gen 4 egg locations if Gen 4 Origin. - #region HGSS Met Locations - var met_list = Util.getCBList(metHGSS_00000, new[] { 0 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2000 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2002 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, new[] { 3001 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_00000, 0000, Legal.Met_HGSS_0); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, Legal.Met_HGSS_2); - met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, Legal.Met_HGSS_3); - - CB_EggLocation.DisplayMember = "Text"; - CB_EggLocation.ValueMember = "Value"; - CB_EggLocation.DataSource = met_list; - CB_EggLocation.SelectedValue = 0; - origintrack = "Gen4"; - #endregion + origintrack = newTrack; } // Visibility logic for Gen 4 encounter type; only show for Gen 4 Pokemon. if (SAV.Generation >= 4) { - bool g4 = Version >= 7 && Version <= 12 && Version != 9; + bool g4 = Version >= GameVersion.D && Version <= GameVersion.SS; + if ((int) Version == 9) // invalid + g4 = false; CB_EncounterType.Visible = Label_EncounterType.Visible = g4; if (!g4) CB_EncounterType.SelectedValue = 0; @@ -1993,7 +2034,7 @@ namespace PKHeX setMarkings(); // Set/Remove KB marking if (!fieldsLoaded) return; - pkm.Version = Version; + pkm.Version = (int)Version; updateLegality(); } private void updateExtraByteValue(object sender, EventArgs e) diff --git a/PKHeX/Saves/SaveUtil.cs b/PKHeX/Saves/SaveUtil.cs index 9ad69d911..ec44a1a14 100644 --- a/PKHeX/Saves/SaveUtil.cs +++ b/PKHeX/Saves/SaveUtil.cs @@ -158,6 +158,59 @@ namespace PKHeX return GameVersion.Invalid; } + /// Determines the Version Grouping of an input Version ID + /// Version of which to determine the group + /// Version Group Identifier or Invalid if type cannot be determined. + public static GameVersion getVersionGroup(GameVersion Version) + { + switch (Version) + { + case GameVersion.CXD: + return GameVersion.CXD; + + case GameVersion.R: + case GameVersion.S: + return GameVersion.RS; + + case GameVersion.E: + return GameVersion.E; + + case GameVersion.FR: + case GameVersion.LG: + return GameVersion.FR; + + case GameVersion.D: + case GameVersion.P: + return GameVersion.DP; + + case GameVersion.Pt: + return GameVersion.Pt; + + case GameVersion.HG: + case GameVersion.SS: + return GameVersion.HGSS; + + case GameVersion.B: + case GameVersion.W: + return GameVersion.BW; + + case GameVersion.B2: + case GameVersion.W2: + return GameVersion.B2W2; + + case GameVersion.X: + case GameVersion.Y: + return GameVersion.XY; + + case GameVersion.OR: + case GameVersion.AS: + return GameVersion.ORAS; + + default: + return GameVersion.Invalid; + } + } + /// Creates an instance of a SaveFile using the given save data. /// Save data from which to create a SaveFile. /// An appropriate type of save file for the given data, or null if the save data is invalid. @@ -286,7 +339,7 @@ namespace PKHeX return (ushort)((val & 0xFFFF) + (val >> 16)); } - public static int getDexFormIndexXY(int species, int formct) + public static int getDexFormIndexBW(int species, int formct) { if (formct < 1 || species < 0) return -1; // invalid @@ -308,11 +361,29 @@ namespace PKHeX case 648: return 066; // 2 Meloetta case 555: return 068; // 2 Darmanitan case 550: return 070; // 2 Basculin + default: return -1; + } + } + public static int getDexFormIndexB2W2(int species, int formct) + { + if (formct < 1 || species < 0) + return -1; // invalid + switch (species) + { case 646: return 072; // 3 Kyurem case 647: return 075; // 2 Keldeo case 642: return 077; // 2 Thundurus case 641: return 079; // 2 Tornadus case 645: return 081; // 2 Landorus + default: return getDexFormIndexBW(species, formct); + } + } + public static int getDexFormIndexXY(int species, int formct) + { + if (formct < 1 || species < 0) + return -1; // invalid + switch (species) + { case 666: return 083; // 20 Vivillion case 669: return 103; // 5 Flabébé case 670: return 108; // 6 Floette @@ -349,7 +420,7 @@ namespace PKHeX case 445: return 183; // 2 Garchomp case 448: return 185; // 2 Lucario case 460: return 187; // 2 Abomasnow - default: return -1; + default: return getDexFormIndexB2W2(species, formct); } } public static int getDexFormIndexORAS(int species, int formct) From 7e456ca2844f3ddf9619b90946b76b7911e720fc Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 27 Aug 2016 13:06:01 -0700 Subject: [PATCH 23/43] Add gen5 form bool setting SAV6 updated for visual parity, no functional change --- PKHeX/Saves/SAV5.cs | 42 ++++++++++++++++++++++++++++--------- PKHeX/Saves/SAV6.cs | 50 ++++++++++++++++++++++----------------------- 2 files changed, 56 insertions(+), 36 deletions(-) diff --git a/PKHeX/Saves/SAV5.cs b/PKHeX/Saves/SAV5.cs index 068006099..5f7870931 100644 --- a/PKHeX/Saves/SAV5.cs +++ b/PKHeX/Saves/SAV5.cs @@ -622,25 +622,47 @@ namespace PKHeX int shiftoff = shiny * brSize * 2 + gender * brSize + brSize; // Set the Species Owned Flag - Data[PokeDex + bit / 8 + 0x8] |= (byte)(1 << (bit % 8)); + Data[PokeDex + 0x8 + bit / 8] |= (byte)(1 << (bit % 8)); // Set the [Species/Gender/Shiny] Seen Flag - Data[PokeDex + shiftoff + bit / 8 + 0x8] |= (byte)(1 << (bit % 8)); + Data[PokeDex + 0x8 + shiftoff + bit / 8] |= (byte)(1 << (bit % 8)); // Set the Display flag if none are set bool Displayed = false; - Displayed |= (Data[PokeDex + brSize * 5 + bit / 8 + 0x8] & (byte)(1 << (bit % 8))) != 0; - Displayed |= (Data[PokeDex + brSize * 6 + bit / 8 + 0x8] & (byte)(1 << (bit % 8))) != 0; - Displayed |= (Data[PokeDex + brSize * 7 + bit / 8 + 0x8] & (byte)(1 << (bit % 8))) != 0; - Displayed |= (Data[PokeDex + brSize * 8 + bit / 8 + 0x8] & (byte)(1 << (bit % 8))) != 0; - if (!Displayed) // offset is already biased by 0x60, reuse shiftoff but for the display flags. - Data[PokeDex + shiftoff + brSize * 4 + bit / 8 + 0x8] |= (byte)(1 << (bit % 8)); + Displayed |= (Data[PokeDex + 0x8 + brSize*5 + bit/8] & (byte)(1 << (bit%8))) != 0; + Displayed |= (Data[PokeDex + 0x8 + brSize*6 + bit/8] & (byte)(1 << (bit%8))) != 0; + Displayed |= (Data[PokeDex + 0x8 + brSize*7 + bit/8] & (byte)(1 << (bit%8))) != 0; + Displayed |= (Data[PokeDex + 0x8 + brSize*8 + bit/8] & (byte)(1 << (bit%8))) != 0; + if (!Displayed) // offset is already biased by brSize, reuse shiftoff but for the display flags. + Data[PokeDex + 0x8 + shiftoff + brSize*4 + bit/8] |= (byte)(1 << (bit%8)); // Set the Language if (lang < 0) lang = 1; - Data[PokeDexLanguageFlags + (bit * 7 + lang) / 8] |= (byte)(1 << ((bit * 7 + lang) % 8)); + Data[PokeDexLanguageFlags + (bit*7 + lang) / 8] |= (byte)(1 << ((bit*7 + lang) % 8)); - // Formes : todo + // Formes + int fc = Personal[pkm.Species].FormeCount; + int f = B2W2 ? SaveUtil.getDexFormIndexB2W2(pkm.Species, fc) : SaveUtil.getDexFormIndexBW(pkm.Species, fc); + if (f < 0) return; + + int FormLen = B2W2 ? 0xB : 0x9; + int FormDex = PokeDex + 0x8 + brSize*9; + bit = f + pkm.AltForm; + + // Set Form Seen Flag + Data[FormDex + FormLen*shiny + bit/8] |= (byte)(1 << (bit%8)); + + // Set Displayed Flag if necessary, check all flags + for (int i = 0; i < fc; i++) + { + bit = f + i; + if ((Data[FormDex + FormLen*2 + bit/8] & (byte)(1 << (bit%8))) != 0) // Nonshiny + return; // already set + if ((Data[FormDex + FormLen*3 + bit/8] & (byte)(1 << (bit%8))) != 0) // Shiny + return; // already set + } + bit = f + pkm.AltForm; + Data[FormDex + FormLen * (2 + shiny) + bit / 8] |= (byte)(1 << (bit % 8)); } } } diff --git a/PKHeX/Saves/SAV6.cs b/PKHeX/Saves/SAV6.cs index e18a4319d..9063f81ec 100644 --- a/PKHeX/Saves/SAV6.cs +++ b/PKHeX/Saves/SAV6.cs @@ -730,35 +730,33 @@ namespace PKHeX if (lang < 0) lang = 1; Data[PokeDexLanguageFlags + (bit * 7 + lang) / 8] |= (byte)(1 << ((bit * 7 + lang) % 8)); - // Set Form flags - int fc = Personal[pkm.Species].FormeCount; - int f = ORAS ? SaveUtil.getDexFormIndexORAS(pkm.Species, fc) : SaveUtil.getDexFormIndexXY(pkm.Species, fc); - if (f >= 0) - { - int FormLen = ORAS ? 0x26 : 0x18; - int FormDex = PokeDex + 0x368; - bit = f + pkm.AltForm; - // Set Seen Flag - Data[FormDex + FormLen * shiny + bit / 8] |= (byte)(1 << (bit % 8)); - - // Set Displayed Flag if necessary, check all flags - bool FormDisplayed = false; - for (int i = 0; i < fc; i++) - { - bit = f + i; - FormDisplayed |= (Data[FormDex + FormLen * 2 + bit / 8] & (byte)(1 << (bit % 8))) != 0; // Nonshiny - FormDisplayed |= (Data[FormDex + FormLen * 3 + bit / 8] & (byte)(1 << (bit % 8))) != 0; // Shiny - } - if (!FormDisplayed) - { - bit = f + pkm.AltForm; - Data[FormDex + FormLen * (2 + shiny) + bit / 8] |= (byte)(1 << (bit % 8)); - } - } - // Set DexNav count (only if not encountered previously) if (ORAS && getEncounterCount(pkm.Species - 1) == 0) setEncounterCount(pkm.Species - 1, 1); + + // Set Form flags + int fc = Personal[pkm.Species].FormeCount; + int f = ORAS ? SaveUtil.getDexFormIndexORAS(pkm.Species, fc) : SaveUtil.getDexFormIndexXY(pkm.Species, fc); + if (f < 0) return; + + int FormLen = ORAS ? 0x26 : 0x18; + int FormDex = PokeDex + 0x8 + brSize*9; + bit = f + pkm.AltForm; + + // Set Form Seen Flag + Data[FormDex + FormLen*shiny + bit/8] |= (byte)(1 << (bit%8)); + + // Set Displayed Flag if necessary, check all flags + for (int i = 0; i < fc; i++) + { + bit = f + i; + if ((Data[FormDex + FormLen*2 + bit/8] & (byte) (1 << (bit%8))) != 0) // Nonshiny + return; // already set + if ((Data[FormDex + FormLen*3 + bit/8] & (byte) (1 << (bit%8))) != 0) // Shiny + return; // already set + } + bit = f + pkm.AltForm; + Data[FormDex + FormLen * (2 + shiny) + bit / 8] |= (byte)(1 << (bit % 8)); } public override byte[] decryptPKM(byte[] data) { From ec0b502e3a49d36ef34ae33a5e9a6af298d0b784 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 27 Aug 2016 13:07:21 -0700 Subject: [PATCH 24/43] Add gen4 language dex set Formes are still todo; they aren't bitflags but are packed values --- PKHeX/Saves/SAV4.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/PKHeX/Saves/SAV4.cs b/PKHeX/Saves/SAV4.cs index dabfeb61c..e00c34328 100644 --- a/PKHeX/Saves/SAV4.cs +++ b/PKHeX/Saves/SAV4.cs @@ -692,7 +692,25 @@ namespace PKHeX // Set the Species Seen Flag Data[PokeDex + brSize * 1 + bit / 8 + 0x4] |= (byte)(1 << (bit % 8)); - // Formes : todo + int FormOffset = PokeDex + 0x108; + int PokeDexLanguageFlags = FormOffset + 0x20 + 494 + 6; + + // Set the Language + if (!DP) + { + int lang = pkm.Language - 1; if (lang > 5) lang = 0; // no KOR + if (lang < 0) lang = 1; + Data[PokeDexLanguageFlags + pkm.Species] |= (byte)(1 << lang); + } + + // Formes : Castform & Cherrim do not have entries (Battle Only formes) + // Lowest sub-value of formevalue is displayed, else is order of formes displayed. + + // Standard Forme Bytes (DP) + // [Shellos-Gastrodon-Burmy-Wormadam],[Unown*0x1C] + + // Extra Forme Bytes (PtHGSS) + // [Rotom*4-highest bits unused],[Shaymin],[Giratina],[Pichu-HGSS ONLY] } } } From 7a5d4898b75b06a13922da0f6a7a810a39979b87 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 27 Aug 2016 18:41:40 -0700 Subject: [PATCH 25/43] Fix gen4 gastrodon HasFormes Thanks NinFanBoyFTW! --- PKHeX/Resources/byte/personal_dp | Bin 22044 -> 22044 bytes PKHeX/Resources/byte/personal_hgss | Bin 22352 -> 22352 bytes PKHeX/Resources/byte/personal_pt | Bin 22352 -> 22352 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/PKHeX/Resources/byte/personal_dp b/PKHeX/Resources/byte/personal_dp index 48373cc00aef3a22ea9065e9b4bd5dcdf0c2c16e..4962a7a18a59c9108729c7e95124f9ded64a7c4f 100644 GIT binary patch delta 22 ecmbQUhH=gs#tp3=j0}_8Ji-~7HsABG;{^a?YX|TE delta 22 ecmbQUhH=gs#tp3=j7*c;Ji-|nHsABG;{^a?cL(qQ diff --git a/PKHeX/Resources/byte/personal_hgss b/PKHeX/Resources/byte/personal_hgss index c0a9df7fa5174a08d04b234df2a855825adb6947..9dbd2eaa1a41d47c7777dac38e3c21be3065d544 100644 GIT binary patch delta 22 ecmcbxj`6}e#tp3=j0}_8Ji-~7HsA9o;sXF|b_kIG delta 22 ecmcbxj`6}e#tp3=j7*c;Ji-|nHsA9o;sXF|f(VfS diff --git a/PKHeX/Resources/byte/personal_pt b/PKHeX/Resources/byte/personal_pt index c16af449e79e637c07d436ee4eb112b2581194ee..f627c2cf8da4192ac030058668b3fcc7d3007a81 100644 GIT binary patch delta 22 ecmcbxj`6}e#tp3=j0}_8Ji-~7HsA9o;sXF|b_kIG delta 22 ecmcbxj`6}e#tp3=j7*c;Ji-|nHsA9o;sXF|f(VfS From c382388843c29bbe83dcd379b04bd78e71599b42 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 27 Aug 2016 18:42:07 -0700 Subject: [PATCH 26/43] Fix gen3 unown form change Thanks NinFanBoyFTW! --- PKHeX/MainWindow/Main.cs | 5 ++++- PKHeX/PKM/PKM.cs | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 86f234ed9..08c8e8753 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -1769,7 +1769,10 @@ namespace PKHeX if (Util.getIndex(CB_Species) == 201) { if (fieldsLoaded && SAV.Generation == 3) - updateRandomPID(sender, e); // Fix AltForm + { + pkm.setPIDUnown3(CB_Form.SelectedIndex); + TB_PID.Text = pkm.PID.ToString("X8"); + } } else if (PKX.getGender(CB_Form.Text) < 2) Label_Gender.Text = CB_Form.Text; diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 50343529c..053c93554 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -476,5 +476,9 @@ namespace PKHeX if (GenNumber < 6) EncryptionConstant = PID; } + public void setPIDUnown3(int form) + { + do PID = Util.rnd32(); while (PKX.getUnownForm(PID) != form); + } } } From a4c70eec636ba2f052b784061fc387cf6dc3ed8f Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 27 Aug 2016 20:12:33 -0700 Subject: [PATCH 27/43] Basic G1 String conversion --- PKHeX/PKM/PKX.cs | 501 +++++++++++++++++++++++++++++++++++++++++++- PKHeX/Saves/SAV1.cs | 2 +- 2 files changed, 495 insertions(+), 8 deletions(-) diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index ebdf74080..1aef62f70 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -1,8 +1,10 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Drawing.Text; using System.Linq; using System.Runtime.InteropServices; +using System.Runtime.Remoting.Messaging; using PKHeX.Properties; namespace PKHeX @@ -1623,6 +1625,484 @@ namespace PKHeX return arr[g3val]; } + #region Gen 1 Character Tables + internal static Dictionary RBY2U_U => new Dictionary{ + {0x50, "\0"}, + {0x5D, "[TRAINER]"}, + {0x7F, " "}, + {0x80, "A"}, + {0x81, "B"}, + {0x82, "C"}, + {0x83, "D"}, + {0x84, "E"}, + {0x85, "F"}, + {0x86, "G"}, + {0x87, "H"}, + {0x88, "I"}, + {0x89, "J"}, + {0x8A, "K"}, + {0x8B, "L"}, + {0x8C, "M"}, + {0x8D, "N"}, + {0x8E, "O"}, + {0x8F, "P"}, + {0x90, "Q"}, + {0x91, "R"}, + {0x92, "S"}, + {0x93, "T"}, + {0x94, "U"}, + {0x95, "V"}, + {0x96, "W"}, + {0x97, "X"}, + {0x98, "Y"}, + {0x99, "Z"}, + {0x9A, "["}, + {0x9B, "\\"}, + {0x9C, "]"}, + {0x9D, "^"}, + {0x9E, "_"}, + {0x9F, "`"}, + {0xA0, "a"}, + {0xA1, "b"}, + {0xA2, "c"}, + {0xA3, "d"}, + {0xA4, "e"}, + {0xA5, "f"}, + {0xA6, "g"}, + {0xA7, "h"}, + {0xA8, "i"}, + {0xA9, "j"}, + {0xAA, "k"}, + {0xAB, "l"}, + {0xAC, "m"}, + {0xAD, "n"}, + {0xAE, "o"}, + {0xAF, "p"}, + {0xB0, "q"}, + {0xB1, "r"}, + {0xB2, "s"}, + {0xB3, "t"}, + {0xB4, "u"}, + {0xB5, "v"}, + {0xB6, "w"}, + {0xB7, "x"}, + {0xB8, "y"}, + {0xB9, "z"}, + {0xE1, "{"}, /* Pk */ + {0xE2, "}"}, /* Mn */ + {0xE3, "-"}, + {0xE6, "?"}, + {0xE7, "!"}, + {0xE8, "."}, + {0xEF, "♂"}, + {0xF2, "."}, + {0xF3, "/"}, + {0xF4, ","}, + {0xF5, "♀"}, + {0xF6, "0"}, + {0xF7, "1"}, + {0xF8, "2"}, + {0xF9, "3"}, + {0xFA, "4"}, + {0xFB, "5"}, + {0xFC, "6"}, + {0xFD, "7"}, + {0xFE, "8"}, + {0xFF, "9"} + }; + + internal static Dictionary U2RBY_U => new Dictionary { + {"\0", 0x50}, + {"[TRAINER]", 0x5D}, + {" ", 0x7F}, + {"A", 0x80}, + {"B", 0x81}, + {"C", 0x82}, + {"D", 0x83}, + {"E", 0x84}, + {"F", 0x85}, + {"G", 0x86}, + {"H", 0x87}, + {"I", 0x88}, + {"J", 0x89}, + {"K", 0x8A}, + {"L", 0x8B}, + {"M", 0x8C}, + {"N", 0x8D}, + {"O", 0x8E}, + {"P", 0x8F}, + {"Q", 0x90}, + {"R", 0x91}, + {"S", 0x92}, + {"T", 0x93}, + {"U", 0x94}, + {"V", 0x95}, + {"W", 0x96}, + {"X", 0x97}, + {"Y", 0x98}, + {"Z", 0x99}, + {"[", 0x9A}, + {"\\", 0x9B}, + {"]", 0x9C}, + {"^", 0x9D}, + {"_", 0x9E}, + {"`", 0x9F}, + {"a", 0xA0}, + {"b", 0xA1}, + {"c", 0xA2}, + {"d", 0xA3}, + {"e", 0xA4}, + {"f", 0xA5}, + {"g", 0xA6}, + {"h", 0xA7}, + {"i", 0xA8}, + {"j", 0xA9}, + {"k", 0xAA}, + {"l", 0xAB}, + {"m", 0xAC}, + {"n", 0xAD}, + {"o", 0xAE}, + {"p", 0xAF}, + {"q", 0xB0}, + {"r", 0xB1}, + {"s", 0xB2}, + {"t", 0xB3}, + {"u", 0xB4}, + {"v", 0xB5}, + {"w", 0xB6}, + {"x", 0xB7}, + {"y", 0xB8}, + {"z", 0xB9}, + {"{", 0xE1}, /* Pk */ + {"}", 0xE2}, /* Mn */ + {"-", 0xE3}, + {"?", 0xE6}, + {"!", 0xE7}, + {".", 0xE8}, + {"♂", 0xEF}, + {".", 0xF2}, + {"/", 0xF3}, + {",", 0xF4}, + {"♀", 0xF5}, + {"0", 0xF6}, + {"1", 0xF7}, + {"2", 0xF8}, + {"3", 0xF9}, + {"4", 0xFA}, + {"5", 0xFB}, + {"6", 0xFC}, + {"7", 0xFD}, + {"8", 0xFE}, + {"9", 0xFF} + }; + internal static Dictionary U2RBY_J => new Dictionary { + {"ガ", 0x05}, + {"ギ", 0x06}, + {"グ", 0x07}, + {"ゲ", 0x08}, + {"ゴ", 0x09}, + {"ザ", 0x0A}, + {"ジ", 0x0B}, + {"ズ", 0x0C}, + {"ゼ", 0x0D}, + {"ゾ", 0x0E}, + {"ダ", 0x0F}, + {"ヂ", 0x10}, + {"ヅ", 0x11}, + {"デ", 0x12}, + {"ド", 0x13}, + {"バ", 0x19}, + {"ビ", 0x1A}, + {"ブ", 0x1B}, + {"ボ", 0x1C}, + {"が", 0x26}, + {"ぎ", 0x27}, + {"ぐ", 0x28}, + {"げ", 0x29}, + {"ご", 0x2A}, + {"ざ", 0x2B}, + {"じ", 0x2C}, + {"ず", 0x2D}, + {"ぜ", 0x2E}, + {"ぞ", 0x2F}, + {"だ", 0x30}, + {"ぢ", 0x31}, + {"づ", 0x32}, + {"で", 0x33}, + {"ど", 0x34}, + {"ば", 0x3A}, + {"び", 0x3B}, + {"ぶ", 0x3C}, + {"べ", 0x3D}, + {"ぼ", 0x3E}, + {"パ", 0x40}, + {"ピ", 0x41}, + {"プ", 0x42}, + {"ポ", 0x43}, + {"ぱ", 0x44}, + {"ぴ", 0x45}, + {"ぷ", 0x46}, + {"ぺ", 0x47}, + {"ぽ", 0x48}, + {"トレーナー", 0x5D}, + {"ア", 0x80}, + {"イ", 0x81}, + {"ウ", 0x82}, + {"エ", 0x83}, + {"ォ", 0x84}, + {"カ", 0x85}, + {"キ", 0x86}, + {"ク", 0x87}, + {"ケ", 0x88}, + {"コ", 0x89}, + {"サ", 0x8A}, + {"シ", 0x8B}, + {"ス", 0x8C}, + {"セ", 0x8D}, + {"ソ", 0x8E}, + {"タ", 0x8F}, + {"チ", 0x90}, + {"ツ", 0x91}, + {"テ", 0x92}, + {"ト", 0x93}, + {"ナ", 0x94}, + {"ニ", 0x95}, + {"ヌ", 0x96}, + {"ネ", 0x97}, + {"ノ", 0x98}, + {"ハ", 0x99}, + {"ヒ", 0x9A}, + {"フ", 0x9B}, + {"ホ", 0x9C}, + {"マ", 0x9D}, + {"ミ", 0x9E}, + {"ム", 0x9F}, + {"メ", 0xA0}, + {"モ", 0xA1}, + {"ヤ", 0xA2}, + {"ユ", 0xA3}, + {"ヨ", 0xA4}, + {"ラ", 0xA5}, + {"ル", 0xA6}, + {"レ", 0xA7}, + {"ロ", 0xA8}, + {"ワ", 0xA9}, + {"ヲ", 0xAA}, + {"ン", 0xAB}, + {"ッ", 0xAC}, + {"ャ", 0xAD}, + {"ュ", 0xAE}, + {"ョ", 0xAF}, + {"ィ", 0xB0}, + {"あ", 0xB1}, + {"い", 0xB2}, + {"う", 0xB3}, + {"え", 0xB4}, + {"お", 0xB5}, + {"か", 0xB6}, + {"き", 0xB7}, + {"く", 0xB8}, + {"け", 0xB9}, + {"こ", 0xBA}, + {"さ", 0xBB}, + {"し", 0xBC}, + {"す", 0xBD}, + {"せ", 0xBE}, + {"そ", 0xBF}, + {"た", 0xC0}, + {"ち", 0xC1}, + {"つ", 0xC2}, + {"て", 0xC3}, + {"と", 0xC4}, + {"な", 0xC5}, + {"に", 0xC6}, + {"ぬ", 0xC7}, + {"ね", 0xC8}, + {"の", 0xC9}, + {"は", 0xCA}, + {"ひ", 0xCB}, + {"ふ", 0xCC}, + {"へ", 0xCD}, + {"ほ", 0xCE}, + {"ま", 0xCF}, + {"み", 0xD0}, + {"む", 0xD1}, + {"め", 0xD2}, + {"も", 0xD3}, + {"や", 0xD4}, + {"ゆ", 0xD5}, + {"よ", 0xD6}, + {"ら", 0xD7}, + {"り", 0xD8}, + {"る", 0xD9}, + {"れ", 0xDA}, + {"ろ", 0xDB}, + {"わ", 0xDC}, + {"を", 0xDD}, + {"ん", 0xDE}, + {"っ", 0xDF}, + {"ゃ", 0xE0}, + {"ゅ", 0xE1}, + {"ょ", 0xE2}, + {"ー", 0xE3}, + {"ァ", 0xE9}, + }; + + static Dictionary RBY2U_J => new Dictionary { + {0x05, "ガ"}, + {0x06, "ギ"}, + {0x07, "グ"}, + {0x08, "ゲ"}, + {0x09, "ゴ"}, + {0x0A, "ザ"}, + {0x0B, "ジ"}, + {0x0C, "ズ"}, + {0x0D, "ゼ"}, + {0x0E, "ゾ"}, + {0x0F, "ダ"}, + {0x10, "ヂ"}, + {0x11, "ヅ"}, + {0x12, "デ"}, + {0x13, "ド"}, + {0x19, "バ"}, + {0x1A, "ビ"}, + {0x1B, "ブ"}, + {0x1C, "ボ"}, + {0x26, "が"}, + {0x27, "ぎ"}, + {0x28, "ぐ"}, + {0x29, "げ"}, + {0x2A, "ご"}, + {0x2B, "ざ"}, + {0x2C, "じ"}, + {0x2D, "ず"}, + {0x2E, "ぜ"}, + {0x2F, "ぞ"}, + {0x30, "だ"}, + {0x31, "ぢ"}, + {0x32, "づ"}, + {0x33, "で"}, + {0x34, "ど"}, + {0x3A, "ば"}, + {0x3B, "び"}, + {0x3C, "ぶ"}, + {0x3D, "べ"}, + {0x3E, "ぼ"}, + {0x40, "パ"}, + {0x41, "ピ"}, + {0x42, "プ"}, + {0x43, "ポ"}, + {0x44, "ぱ"}, + {0x45, "ぴ"}, + {0x46, "ぷ"}, + {0x47, "ぺ"}, + {0x48, "ぽ"}, + {0x50, "\0"}, + {0x5D, "トレーナー"}, + {0x80, "ア"}, + {0x81, "イ"}, + {0x82, "ウ"}, + {0x83, "エ"}, + {0x84, "ォ"}, + {0x85, "カ"}, + {0x86, "キ"}, + {0x87, "ク"}, + {0x88, "ケ"}, + {0x89, "コ"}, + {0x8A, "サ"}, + {0x8B, "シ"}, + {0x8C, "ス"}, + {0x8D, "セ"}, + {0x8E, "ソ"}, + {0x8F, "タ"}, + {0x90, "チ"}, + {0x91, "ツ"}, + {0x92, "テ"}, + {0x93, "ト"}, + {0x94, "ナ"}, + {0x95, "ニ"}, + {0x96, "ヌ"}, + {0x97, "ネ"}, + {0x98, "ノ"}, + {0x99, "ハ"}, + {0x9A, "ヒ"}, + {0x9B, "フ"}, + {0x9C, "ホ"}, + {0x9D, "マ"}, + {0x9E, "ミ"}, + {0x9F, "ム"}, + {0xA0, "メ"}, + {0xA1, "モ"}, + {0xA2, "ヤ"}, + {0xA3, "ユ"}, + {0xA4, "ヨ"}, + {0xA5, "ラ"}, + {0xA6, "ル"}, + {0xA7, "レ"}, + {0xA8, "ロ"}, + {0xA9, "ワ"}, + {0xAA, "ヲ"}, + {0xAB, "ン"}, + {0xAC, "ッ"}, + {0xAD, "ャ"}, + {0xAE, "ュ"}, + {0xAF, "ョ"}, + {0xB0, "ィ"}, + {0xB1, "あ"}, + {0xB2, "い"}, + {0xB3, "う"}, + {0xB4, "え"}, + {0xB5, "お"}, + {0xB6, "か"}, + {0xB7, "き"}, + {0xB8, "く"}, + {0xB9, "け"}, + {0xBA, "こ"}, + {0xBB, "さ"}, + {0xBC, "し"}, + {0xBD, "す"}, + {0xBE, "せ"}, + {0xBF, "そ"}, + {0xC0, "た"}, + {0xC1, "ち"}, + {0xC2, "つ"}, + {0xC3, "て"}, + {0xC4, "と"}, + {0xC5, "な"}, + {0xC6, "に"}, + {0xC7, "ぬ"}, + {0xC8, "ね"}, + {0xC9, "の"}, + {0xCA, "は"}, + {0xCB, "ひ"}, + {0xCC, "ふ"}, + {0xCD, "へ"}, + {0xCE, "ほ"}, + {0xCF, "ま"}, + {0xD0, "み"}, + {0xD1, "む"}, + {0xD2, "め"}, + {0xD3, "も"}, + {0xD4, "や"}, + {0xD5, "ゆ"}, + {0xD6, "よ"}, + {0xD7, "ら"}, + {0xD8, "り"}, + {0xD9, "る"}, + {0xDA, "れ"}, + {0xDB, "ろ"}, + {0xDC, "わ"}, + {0xDD, "を"}, + {0xDE, "ん"}, + {0xDF, "っ"}, + {0xE0, "ゃ"}, + {0xE1, "ゅ"}, + {0xE2, "ょ"}, + {0xE3, "ー"}, + {0xE9, "ァ"}, + }; + #endregion + public static int getG1Species(int raw_id) { int[] table = { 0x00, 0x70, 0x73, 0x20, 0x23, 0x15, 0x64, 0x22, 0x50, 0x02, 0x67, 0x6C, 0x66, 0x58, 0x5E, 0x1D, 0x1F, 0x68, 0x6F, 0x83, 0x3B, 0x97, 0x82, 0x5A, 0x48, 0x5C, 0x7B, 0x78, 0x09, 0x7F, 0x72, 0x00, 0x00, 0x3A, 0x5F, 0x16, 0x10, 0x4F, 0x40, 0x4B, 0x71, 0x43, 0x7A, 0x6A, 0x6B, 0x18, 0x2F, 0x36, 0x60, 0x4C, 0x00, 0x7E, 0x00, 0x7D, 0x52, 0x6D, 0x00, 0x38, 0x56, 0x32, 0x80, 0x00, 0x00, 0x00, 0x53, 0x30, 0x95, 0x00, 0x00, 0x00, 0x54, 0x3C, 0x7C, 0x92, 0x90, 0x91, 0x84, 0x34, 0x62, 0x00, 0x00, 0x00, 0x25, 0x26, 0x19, 0x1A, 0x00, 0x00, 0x93, 0x94, 0x8C, 0x8D, 0x74, 0x75, 0x00, 0x00, 0x1B, 0x1C, 0x8A, 0x8B, 0x27, 0x28, 0x85, 0x88, 0x87, 0x86, 0x42, 0x29, 0x17, 0x2E, 0x3D, 0x3E, 0x0D, 0x0E, 0x0F, 0x00, 0x55, 0x39, 0x33, 0x31, 0x57, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x44, 0x00, 0x37, 0x61, 0x2A, 0x96, 0x8F, 0x81, 0x00, 0x00, 0x59, 0x00, 0x63, 0x5B, 0x00, 0x65, 0x24, 0x6E, 0x35, 0x69, 0x00, 0x5D, 0x3F, 0x41, 0x11, 0x12, 0x79, 0x01, 0x03, 0x49, 0x00, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4E, 0x13, 0x14, 0x21, 0x1E, 0x4A, 0x89, 0x8E, 0x00, 0x51, 0x00, 0x00, 0x04, 0x07, 0x05, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x2C, 0x2D, 0x45, 0x46, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -1635,19 +2115,26 @@ namespace PKHeX return table[dex_id]; } - public static byte setG1Char(ushort chr, bool jp) - { - throw new NotImplementedException(); - } - public static string getG1Str(byte[] strdata, bool jp) { - throw new NotImplementedException(); + Dictionary dict = jp ? RBY2U_J : RBY2U_U; + return strdata + .TakeWhile(b => dict.ContainsKey(b)) + .Select(b => dict[b]) + .TakeWhile(s => s != "\0") + .Aggregate("", (current, cur) => current + cur); } public static byte[] setG1Str(string str, bool jp) { - throw new NotImplementedException(); + Dictionary dict = jp ? U2RBY_J : U2RBY_U; + if (dict.ContainsKey(str)) // Handle "[TRAINER]" + return new[] {dict[str], dict["\0"]}; + return str + .TakeWhile(c => dict.ContainsKey(c.ToString())) + .Select(c => dict[c.ToString()]) + .Concat(new[] {dict["\0"]}) + .ToArray(); } } diff --git a/PKHeX/Saves/SAV1.cs b/PKHeX/Saves/SAV1.cs index 30e0cad31..e19cfe335 100644 --- a/PKHeX/Saves/SAV1.cs +++ b/PKHeX/Saves/SAV1.cs @@ -174,7 +174,7 @@ namespace PKHeX } } - private readonly ushort[] LegalItems, LegalKeyItems, LegalBalls, LegalTMHMs, LegalBerries; + private readonly ushort[] LegalItems; public override InventoryPouch[] Inventory { get From 49435dc3792e5ea3f340a6980c2345f31856f65d Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sat, 27 Aug 2016 23:30:49 -0700 Subject: [PATCH 28/43] Add gen4 Form 'flags' --- PKHeX/Saves/SAV4.cs | 158 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 145 insertions(+), 13 deletions(-) diff --git a/PKHeX/Saves/SAV4.cs b/PKHeX/Saves/SAV4.cs index e00c34328..7384563ca 100644 --- a/PKHeX/Saves/SAV4.cs +++ b/PKHeX/Saves/SAV4.cs @@ -687,30 +687,162 @@ namespace PKHeX int bit = pkm.Species - 1; // Set the Species Owned Flag - Data[PokeDex + brSize * 0 + bit / 8 + 0x4] |= (byte)(1 << (bit % 8)); + Data[PokeDex + brSize*0 + bit/8 + 0x4] |= (byte) (1 << (bit%8)); // Set the Species Seen Flag - Data[PokeDex + brSize * 1 + bit / 8 + 0x4] |= (byte)(1 << (bit % 8)); + Data[PokeDex + brSize*1 + bit/8 + 0x4] |= (byte) (1 << (bit%8)); - int FormOffset = PokeDex + 0x108; - int PokeDexLanguageFlags = FormOffset + 0x20 + 494 + 6; - - // Set the Language - if (!DP) - { - int lang = pkm.Language - 1; if (lang > 5) lang = 0; // no KOR - if (lang < 0) lang = 1; - Data[PokeDexLanguageFlags + pkm.Species] |= (byte)(1 << lang); - } + int FormOffset1 = PokeDex + 0x108; + int PokeDexLanguageFlags = FormOffset1 + 0x20; // Formes : Castform & Cherrim do not have entries (Battle Only formes) // Lowest sub-value of formevalue is displayed, else is order of formes displayed. + // Deoxys forms 1-2 are stored in the last byte of the first bitRegion. + // Deoxys forms 3-4 are stored in the last byte of the second bitRegion. + if (pkm.Species == 386) + { + uint val = (uint)(Data[PokeDex + 0x4 + 1*brSize - 1] | Data[PokeDex + 0x4 + 2*brSize - 1] << 8); + int[] forms = getDexFormValues(val, 4, 4); + checkInsertForm(ref forms, pkm.AltForm); + uint newval = setDexFormValues(forms, 4, 4); + + Data[PokeDex + 0x4 + 1*brSize - 1] = (byte)(newval & 0xFF); + Data[PokeDex + 0x4 + 2*brSize - 1] = (byte)((newval>>8) & 0xFF); + } + + // After the BitRegions is 0x20 bytes for the rest of the formes. // Standard Forme Bytes (DP) // [Shellos-Gastrodon-Burmy-Wormadam],[Unown*0x1C] + if (pkm.Species == 422) // Shellos + { + int[] forms = getDexFormValues(Data[FormOffset1 + 0], 2, 2); + checkInsertForm(ref forms, pkm.AltForm); + uint newval = setDexFormValues(forms, 2, 2); + Data[FormOffset1 + 0] = (byte)newval; + } + if (pkm.Species == 423) // Gastrodon + { + int[] forms = getDexFormValues(Data[FormOffset1 + 1], 2, 2); + checkInsertForm(ref forms, pkm.AltForm); + uint newval = setDexFormValues(forms, 2, 2); + Data[FormOffset1 + 1] = (byte)newval; + } + if (pkm.Species == 412) // Burmy + { + int[] forms = getDexFormValues(Data[FormOffset1 + 2], 2, 3); + checkInsertForm(ref forms, pkm.AltForm); + uint newval = setDexFormValues(forms, 2, 3); + Data[FormOffset1 + 2] = (byte)newval; + } + if (pkm.Species == 413) // Wormadam + { + int[] forms = getDexFormValues(Data[FormOffset1 + 3], 2, 3); + checkInsertForm(ref forms, pkm.AltForm); + uint newval = setDexFormValues(forms, 2, 3); + Data[FormOffset1 + 3] = (byte)newval; + } + if (pkm.Species == 201) // Unown + { + for (int i = 0; i < 0x1C; i++) + { + byte val = Data[FormOffset1 + 4 + i]; + if (val == pkm.AltForm) + break; // already set + if (val != 0xFF) + continue; // keep searching - // Extra Forme Bytes (PtHGSS) + Data[FormOffset1 + 4 + i] = (byte)pkm.AltForm; + break; // form now set + } + } + + // DP stops here. + if (DP) + return; + + // Set the Language + int lang = pkm.Language - 1; + if (lang > 5) lang = 0; // no KOR + if (lang < 0) lang = 1; + Data[PokeDexLanguageFlags + pkm.Species] |= (byte) (1 << lang); + + int FormOffset2 = PokeDexLanguageFlags + 0x210; + // PtHGSS added more forms. // [Rotom*4-highest bits unused],[Shaymin],[Giratina],[Pichu-HGSS ONLY] + if (pkm.Species == 479) // Rotom + { + int[] forms = getDexFormValues(BitConverter.ToUInt32(Data, FormOffset2), 3, 6); + checkInsertForm(ref forms, pkm.AltForm); + uint newval = setDexFormValues(forms, 3, 6); + BitConverter.GetBytes(newval).CopyTo(Data, FormOffset2); + } + if (pkm.Species == 492) // Shaymin + { + int[] forms = getDexFormValues(Data[FormOffset2 + 4], 2, 2); + uint newval = setDexFormValues(forms, 2, 2); + Data[FormOffset1 + 3] = (byte)newval; + } + if (pkm.Species == 487) // Giratina + { + int[] forms = getDexFormValues(Data[FormOffset2 + 5], 2, 2); + uint newval = setDexFormValues(forms, 2, 2); + Data[FormOffset1 + 3] = (byte)newval; + } + if (pkm.Species == 172 && HGSS) // Pichu + { + int[] forms = getDexFormValues(Data[FormOffset2 + 6], 2, 3); + uint newval = setDexFormValues(forms, 2, 3); + Data[FormOffset1 + 3] = (byte)newval; + } + } + private int[] getDexFormValues(uint Value, int BitsPerForm, int readCt) + { + int[] Forms = new int[readCt]; + int n1 = 0xFF >> (8 - BitsPerForm); + for (int i = 0; i < Forms.Length; i++) + { + int val = (int)(Value >> (i*BitsPerForm))&n1; + if (n1 == val) + Forms[i] = -1; + else + Forms[i] = val; + } + return Forms; + } + private uint setDexFormValues(int[] Forms, int BitsPerForm, int readCt) + { + int n1 = 0xFF >> (8 - BitsPerForm); + uint Value = 0xFFFFFFFF << (Forms.Length*BitsPerForm); + for (int i = 0; i < Forms.Length; i++) + { + int val = Forms[i]; + if (val == -1) + val = n1; + + Value |= (uint)(val << (BitsPerForm*i)); + } + return Value; + } + private bool checkInsertForm(ref int[] Forms, int FormNum) + { + if (Forms.Any(num => num == FormNum)) + { + return false; // already in list + } + if (Forms.All(num => num == -1)) + { + Forms[0] = FormNum; + return true; // none in list, insert at top + } + + // insert at first empty + int n1 = Array.IndexOf(Forms, -1); + if (n1 < 0) + return false; + + Forms[n1] = FormNum; + return true; } } } From 4738a2c716c94ce6b20bc54015a6ef73f03b3986 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 28 Aug 2016 03:18:22 -0700 Subject: [PATCH 29/43] Initial support for SAV1 loading...warning: mostly broken --- PKHeX/MainWindow/Main.Designer.cs | 44 ++++----- PKHeX/MainWindow/Main.cs | 148 +++++++++++++++++++++-------- PKHeX/MainWindow/MainPK1.cs | 123 ++++++++++++++++++++++++ PKHeX/PKHeX.csproj | 3 + PKHeX/PKM/PK1.cs | 47 +++++++-- PKHeX/PKM/PKM.cs | 12 +-- PKHeX/PKM/PKX.cs | 40 ++++---- PKHeX/PersonalInfo/PersonalInfo.cs | 3 + PKHeX/Saves/Inventory.cs | 38 ++++++++ PKHeX/Saves/SAV1.cs | 125 +++++++++++++++++------- PKHeX/Saves/SaveFile.cs | 32 ++++--- PKHeX/Saves/SaveUtil.cs | 2 + 12 files changed, 482 insertions(+), 135 deletions(-) create mode 100644 PKHeX/MainWindow/MainPK1.cs diff --git a/PKHeX/MainWindow/Main.Designer.cs b/PKHeX/MainWindow/Main.Designer.cs index 51e1d7dc1..dbc698903 100644 --- a/PKHeX/MainWindow/Main.Designer.cs +++ b/PKHeX/MainWindow/Main.Designer.cs @@ -348,10 +348,10 @@ this.B_OpenOPowers = new System.Windows.Forms.Button(); this.B_OpenEventFlags = new System.Windows.Forms.Button(); this.B_OpenPokedex = new System.Windows.Forms.Button(); - this.B_OpenBerryField = new System.Windows.Forms.Button(); - this.B_OpenSecretBase = new System.Windows.Forms.Button(); - this.B_Pokeblocks = new System.Windows.Forms.Button(); this.B_LinkInfo = new System.Windows.Forms.Button(); + this.B_OpenBerryField = new System.Windows.Forms.Button(); + this.B_Pokeblocks = new System.Windows.Forms.Button(); + this.B_OpenSecretBase = new System.Windows.Forms.Button(); this.B_OpenPokepuffs = new System.Windows.Forms.Button(); this.B_OpenSuperTraining = new System.Windows.Forms.Button(); this.B_OpenHallofFame = new System.Windows.Forms.Button(); @@ -4454,6 +4454,16 @@ this.B_OpenPokedex.UseVisualStyleBackColor = true; this.B_OpenPokedex.Click += new System.EventHandler(this.B_OpenPokedex_Click); // + // B_LinkInfo + // + this.B_LinkInfo.Location = new System.Drawing.Point(96, 61); + this.B_LinkInfo.Name = "B_LinkInfo"; + this.B_LinkInfo.Size = new System.Drawing.Size(87, 23); + this.B_LinkInfo.TabIndex = 23; + this.B_LinkInfo.Text = "Link Data"; + this.B_LinkInfo.UseVisualStyleBackColor = true; + this.B_LinkInfo.Click += new System.EventHandler(this.B_LinkInfo_Click); + // // B_OpenBerryField // this.B_OpenBerryField.Location = new System.Drawing.Point(189, 61); @@ -4464,17 +4474,6 @@ this.B_OpenBerryField.UseVisualStyleBackColor = true; this.B_OpenBerryField.Click += new System.EventHandler(this.B_OpenBerryField_Click); // - // B_OpenSecretBase - // - this.B_OpenSecretBase.Location = new System.Drawing.Point(96, 90); - this.B_OpenSecretBase.Name = "B_OpenSecretBase"; - this.B_OpenSecretBase.Size = new System.Drawing.Size(87, 23); - this.B_OpenSecretBase.TabIndex = 21; - this.B_OpenSecretBase.Text = "Secret Base"; - this.B_OpenSecretBase.UseVisualStyleBackColor = true; - this.B_OpenSecretBase.Visible = false; - this.B_OpenSecretBase.Click += new System.EventHandler(this.B_OpenSecretBase_Click); - // // B_Pokeblocks // this.B_Pokeblocks.Location = new System.Drawing.Point(3, 90); @@ -4486,15 +4485,16 @@ this.B_Pokeblocks.Visible = false; this.B_Pokeblocks.Click += new System.EventHandler(this.B_OpenPokeblocks_Click); // - // B_LinkInfo + // B_OpenSecretBase // - this.B_LinkInfo.Location = new System.Drawing.Point(96, 61); - this.B_LinkInfo.Name = "B_LinkInfo"; - this.B_LinkInfo.Size = new System.Drawing.Size(87, 23); - this.B_LinkInfo.TabIndex = 23; - this.B_LinkInfo.Text = "Link Data"; - this.B_LinkInfo.UseVisualStyleBackColor = true; - this.B_LinkInfo.Click += new System.EventHandler(this.B_LinkInfo_Click); + this.B_OpenSecretBase.Location = new System.Drawing.Point(96, 90); + this.B_OpenSecretBase.Name = "B_OpenSecretBase"; + this.B_OpenSecretBase.Size = new System.Drawing.Size(87, 23); + this.B_OpenSecretBase.TabIndex = 21; + this.B_OpenSecretBase.Text = "Secret Base"; + this.B_OpenSecretBase.UseVisualStyleBackColor = true; + this.B_OpenSecretBase.Visible = false; + this.B_OpenSecretBase.Click += new System.EventHandler(this.B_OpenSecretBase_Click); // // B_OpenPokepuffs // diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 5f63b6f04..1adc20910 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -710,7 +710,7 @@ namespace PKHeX SaveFile sav = SaveUtil.getVariantSAV(input); if (sav == null || sav.Version == GameVersion.Invalid) { Util.Error("Invalid save file loaded. Aborting.", path); return; } - if (sav.Generation <= 3) // Japanese Save files are different. Get isJapanese + if (sav.Generation == 3) // Japanese Save files are different. Get isJapanese { if (sav.Version == GameVersion.Unknown) { @@ -839,11 +839,60 @@ namespace PKHeX TB_AbilityNumber.Visible = SAV.Generation >= 6 && DEV_Ability.Enabled; CB_Ability.Visible = !DEV_Ability.Enabled && SAV.Generation >= 3; + GB_ExtraBytes.Visible = SAV.Generation > 1; + GB_Markings.Visible = SAV.Generation > 2; + + Label_HeldItem.Visible = CB_HeldItem.Visible = SAV.Generation > 1; + Label_Total.Visible = TB_IVTotal.Visible = TB_EVTotal.Visible = L_Potential.Visible = + Label_HiddenPowerPrefix.Visible = CB_HPType.Visible = SAV.Generation > 1; + Label_CharacteristicPrefix.Visible = L_Characteristic.Visible = SAV.Generation > 1; + Label_ContestStats.Visible = Label_Cool.Visible = Label_Tough.Visible = Label_Smart.Visible = + Label_Sheen.Visible = Label_Beauty.Visible = Label_Cute.Visible = TB_Cool.Visible = TB_Tough.Visible = + TB_Smart.Visible = TB_Sheen.Visible = TB_Beauty.Visible = TB_Cute.Visible = SAV.Generation >= 3; + + if (1 <= sav.Generation && sav.Generation <= 2) + { + Label_SPD.Visible = TB_SPDEV.Visible = TB_SPDIV.Visible = Stat_SPD.Visible = false; + Label_SPA.Text = "Spc"; + TB_HPIV.ReadOnly = true; + Control[] evControls = { TB_SPAEV, TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPDEV }; + foreach (MaskedTextBox ctrl in evControls) + { + ctrl.Mask = "00000"; + ctrl.Size = new Size(37, 20); + } + Control[] statControls = {Stat_HP, Stat_ATK, Stat_DEF, Stat_SPA, Stat_SPD, Stat_SPE}; + foreach (Control ctrl in statControls) + ctrl.Location = new Point(173, ctrl.Location.Y); + Label_Stats.Location = new Point(168, Label_Stats.Location.Y); + } + else + { + Label_SPD.Visible = TB_SPDEV.Visible = TB_SPDIV.Visible = Stat_SPD.Visible = true; + Label_SPA.Text = "SpA"; + TB_HPIV.ReadOnly = false; + Control[] evControls = { TB_SPAEV, TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPDEV }; + foreach (MaskedTextBox ctrl in evControls) + { + ctrl.Mask = "000"; + ctrl.Size = new Size(31, 20); + } + Control[] statControls = { Stat_HP, Stat_ATK, Stat_DEF, Stat_SPA, Stat_SPD, Stat_SPE }; + foreach (Control ctrl in statControls) + ctrl.Location = new Point(167, ctrl.Location.Y); + Label_Stats.Location = new Point(162, Label_Stats.Location.Y); + } + // Recenter PKM SubEditors FLP_PKMEditors.Location = new Point((tabMain.TabPages[4].Width - FLP_PKMEditors.Width) / 2, FLP_PKMEditors.Location.Y); switch (SAV.Generation) { + case 1: + getFieldsfromPKM = populateFieldsPK1; + getPKMfromFields = preparePK1; + extraBytes = new byte[] {}; + break; case 3: getFieldsfromPKM = populateFieldsPK3; getPKMfromFields = preparePK3; @@ -886,10 +935,13 @@ namespace PKHeX TB_Level.Visible = !HaX; // Load Extra Byte List - CB_ExtraBytes.Items.Clear(); - foreach (byte b in extraBytes) - CB_ExtraBytes.Items.Add("0x" + b.ToString("X2")); - CB_ExtraBytes.SelectedIndex = 0; + if (GB_ExtraBytes.Visible) + { + CB_ExtraBytes.Items.Clear(); + foreach (byte b in extraBytes) + CB_ExtraBytes.Items.Add("0x" + b.ToString("X2")); + CB_ExtraBytes.SelectedIndex = 0; + } // Refresh PK#->PK6 conversion info PKMConverter.updateConfig(SAV.SubRegion, SAV.Country, SAV.ConsoleRegion, SAV.OT, SAV.Gender); @@ -1116,12 +1168,15 @@ namespace PKHeX } private void populateFilteredDataSources() { - string[] items = itemlist; - if (SAV.Generation == 3) - items = g3items; + if (SAV.Generation > 1) + { + string[] items = itemlist; + if (SAV.Generation == 3) + items = g3items; - ItemDataSource = Util.getCBList(items, (HaX ? Enumerable.Range(0, SAV.MaxItemID) : SAV.HeldItems.Select(i => (int)i)).ToArray()); - CB_HeldItem.DataSource = new BindingSource(ItemDataSource.Where(i => i.Value <= SAV.MaxItemID).ToList(), null); + ItemDataSource = Util.getCBList(items, (HaX ? Enumerable.Range(0, SAV.MaxItemID) : SAV.HeldItems.Select(i => (int)i)).ToArray()); + CB_HeldItem.DataSource = new BindingSource(ItemDataSource.Where(i => i.Value <= SAV.MaxItemID).ToList(), null); + } CB_Ball.DataSource = new BindingSource(BallDataSource.Where(b => b.Value <= SAV.MaxBallID).ToList(), null); CB_Species.DataSource = new BindingSource(SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID).ToList(), null); @@ -1504,7 +1559,11 @@ namespace PKHeX } changingFields = false; if (fieldsLoaded) + { pkm.EXP = Util.ToUInt32(TB_EXP.Text); + if (SAV.Generation < 3) + pkm.Stat_Level = Util.ToInt32(TB_Level.Text); + } updateStats(); updateLegality(); } @@ -1534,8 +1593,8 @@ namespace PKHeX private void updateIVs(object sender, EventArgs e) { if (changingFields || !fieldsInitialized) return; - if (sender != null && Util.ToInt32(((MaskedTextBox) sender).Text) > 31) - ((MaskedTextBox) sender).Text = "31"; + if (sender != null && Util.ToInt32(((MaskedTextBox) sender).Text) > SAV.MaxIV) + ((MaskedTextBox) sender).Text = SAV.MaxIV.ToString("00"); changingFields = true; @@ -1546,6 +1605,11 @@ namespace PKHeX pkm.IV_SPE = Util.ToInt32(TB_SPEIV.Text); pkm.IV_SPA = Util.ToInt32(TB_SPAIV.Text); pkm.IV_SPD = Util.ToInt32(TB_SPDIV.Text); + + if (SAV.Generation < 3) + { + TB_HPIV.Text = pkm.IV_HP.ToString("00"); + } CB_HPType.SelectedValue = pkm.HPType; changingFields = false; @@ -1601,21 +1665,21 @@ namespace PKHeX if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift) { // Max IVs - TB_HPIV.Text = 31.ToString(); - TB_ATKIV.Text = 31.ToString(); - TB_DEFIV.Text = 31.ToString(); - TB_SPAIV.Text = 31.ToString(); - TB_SPDIV.Text = 31.ToString(); - TB_SPEIV.Text = 31.ToString(); + TB_HPIV.Text = SAV.MaxIV.ToString(); + TB_ATKIV.Text = SAV.MaxIV.ToString(); + TB_DEFIV.Text = SAV.MaxIV.ToString(); + TB_SPAIV.Text = SAV.MaxIV.ToString(); + TB_SPDIV.Text = SAV.MaxIV.ToString(); + TB_SPEIV.Text = SAV.MaxIV.ToString(); } else { - TB_HPIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_ATKIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_DEFIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_SPAIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_SPDIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_SPEIV.Text = (Util.rnd32() & 0x1F).ToString(); + TB_HPIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString(); + TB_ATKIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString(); + TB_DEFIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString(); + TB_SPAIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString(); + TB_SPDIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString(); + TB_SPEIV.Text = (Util.rnd32() % (SAV.MaxIV + 1)).ToString(); } changingFields = false; updateIVs(null, null); @@ -1624,7 +1688,7 @@ namespace PKHeX { if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift) { - // Max IVs + // Max EVs TB_HPEV.Text = 0.ToString(); TB_ATKEV.Text = 0.ToString(); TB_DEFEV.Text = 0.ToString(); @@ -1634,7 +1698,7 @@ namespace PKHeX } else { - byte[] evs = PKX.getRandomEVs(); + var evs = PKX.getRandomEVs(SAV.Generation); TB_HPEV.Text = evs[0].ToString(); TB_ATKEV.Text = evs[1].ToString(); TB_DEFEV.Text = evs[2].ToString(); @@ -2384,7 +2448,7 @@ namespace PKHeX for (int i = 0; i < cba.Length; i++) { int back = cba[i].BackColor.ToArgb(); - if (back == SystemColors.Control.ToArgb() || back == 0 || + if (!cba[i].Visible || back == SystemColors.Control.ToArgb() || back == 0 || !(back != -1 & back != defaultControlWhite.ToArgb())) continue; if (i < 6) // Main Tab tabMain.SelectedIndex = 0; @@ -2396,7 +2460,7 @@ namespace PKHeX } #endregion // Further logic checking - if (Convert.ToUInt32(TB_EVTotal.Text) > 510 && !CHK_HackedStats.Checked) + if (SAV.Generation >= 3 && Convert.ToUInt32(TB_EVTotal.Text) > 510 && !CHK_HackedStats.Checked) { tabMain.SelectedIndex = 2; goto invalid; } // If no errors detected... if (Util.getIndex(CB_Species) != 0) return true; @@ -2411,14 +2475,17 @@ namespace PKHeX { // Check if PKM properties are outside of the valid range List errata = new List(); - if (pk.HeldItem > itemlist.Length) - errata.Add($"Item Index beyond range: {pk.HeldItem}"); - else + if (SAV.Generation > 1) { - if (pk.HeldItem > SAV.MaxItemID) - errata.Add($"Game can't obtain item: {itemlist[pk.HeldItem]}"); - if (!pk.CanHoldItem(SAV.HeldItems)) - errata.Add($"Game can't hold item: {itemlist[pk.HeldItem]}"); + if (pk.HeldItem > itemlist.Length) + errata.Add($"Item Index beyond range: {pk.HeldItem}"); + else + { + if (pk.HeldItem > SAV.MaxItemID) + errata.Add($"Game can't obtain item: {itemlist[pk.HeldItem]}"); + if (!pk.CanHoldItem(SAV.HeldItems)) + errata.Add($"Game can't hold item: {itemlist[pk.HeldItem]}"); + } } if (pk.Species > specieslist.Length) @@ -2911,9 +2978,16 @@ namespace PKHeX int boxoffset = SAV.getBoxOffset(CB_BoxSelect.SelectedIndex); int boxbgval = SAV.getBoxWallpaper(CB_BoxSelect.SelectedIndex); PAN_Box.BackgroundImage = BoxWallpaper.getWallpaper(SAV, boxbgval); - for (int i = 0; i < 30; i++) - getSlotFiller(boxoffset + SAV.SIZE_STORED * i, SlotPictureBoxes[i]); + { + if (i < SAV.BoxSlotCount) + getSlotFiller(boxoffset + SAV.SIZE_STORED*i, SlotPictureBoxes[i]); + else + { + SlotPictureBoxes[i].Image = null; + SlotPictureBoxes[i].BackColor = Color.Gray; + } + } } // Reload Party diff --git a/PKHeX/MainWindow/MainPK1.cs b/PKHeX/MainWindow/MainPK1.cs new file mode 100644 index 000000000..f34be25cf --- /dev/null +++ b/PKHeX/MainWindow/MainPK1.cs @@ -0,0 +1,123 @@ +using System; + +namespace PKHeX +{ + public partial class Main + { + private void populateFieldsPK1() + { + PK1 pk1 = pkm as PK1; + if (pk1 == null) + return; + + // Do first + pk1.Stat_Level = PKX.getLevel(pk1.Species, pk1.EXP); + if (pk1.Stat_Level == 100) + pk1.EXP = PKX.getEXP(pk1.Stat_Level, pk1.Species); + + CB_Species.SelectedValue = pk1.Species; + TB_Level.Text = pk1.Stat_Level.ToString(); + TB_EXP.Text = pk1.EXP.ToString(); + + // Load rest + TB_TID.Text = pk1.TID.ToString("00000"); + TB_Nickname.Text = pk1.Nickname; + TB_OT.Text = pk1.OT_Name; + GB_OT.BackgroundImage = null; + + // Reset Label and ComboBox visibility, as well as non-data checked status. + Label_PKRS.Visible = false; + Label_PKRSdays.Visible = false; + + TB_HPIV.Text = pk1.IV_HP.ToString(); + TB_ATKIV.Text = pk1.IV_ATK.ToString(); + TB_DEFIV.Text = pk1.IV_DEF.ToString(); + TB_SPEIV.Text = pk1.IV_SPE.ToString(); + TB_SPAIV.Text = pk1.IV_SPA.ToString(); + + TB_HPEV.Text = pk1.EV_HP.ToString(); + TB_ATKEV.Text = pk1.EV_ATK.ToString(); + TB_DEFEV.Text = pk1.EV_DEF.ToString(); + TB_SPEEV.Text = pk1.EV_SPE.ToString(); + TB_SPAEV.Text = pk1.EV_SPA.ToString(); + + CB_Move1.SelectedValue = pk1.Move1; + CB_Move2.SelectedValue = pk1.Move2; + CB_Move3.SelectedValue = pk1.Move3; + CB_Move4.SelectedValue = pk1.Move4; + CB_PPu1.SelectedIndex = pk1.Move1_PPUps; + CB_PPu2.SelectedIndex = pk1.Move2_PPUps; + CB_PPu3.SelectedIndex = pk1.Move3_PPUps; + CB_PPu4.SelectedIndex = pk1.Move4_PPUps; + TB_PP1.Text = pk1.Move1_PP.ToString(); + TB_PP2.Text = pk1.Move2_PP.ToString(); + TB_PP3.Text = pk1.Move3_PP.ToString(); + TB_PP4.Text = pk1.Move4_PP.ToString(); + + updateStats(); + + TB_EXP.Text = pk1.EXP.ToString(); + } + private PKM preparePK1() + { + PK1 pk1 = pkm as PK1; + if (pk1 == null) + return null; + + pk1.Species = Util.getIndex(CB_Species); + pk1.TID = Util.ToInt32(TB_TID.Text); + pk1.EXP = Util.ToUInt32(TB_EXP.Text); + + pk1.EV_HP = Util.ToInt32(TB_HPEV.Text); + pk1.EV_ATK = Util.ToInt32(TB_ATKEV.Text); + pk1.EV_DEF = Util.ToInt32(TB_DEFEV.Text); + pk1.EV_SPE = Util.ToInt32(TB_SPEEV.Text); + pk1.EV_SPC = Util.ToInt32(TB_SPAEV.Text); + + pk1.Nickname = TB_Nickname.Text; + pk1.Move1 = Util.getIndex(CB_Move1); + pk1.Move2 = Util.getIndex(CB_Move2); + pk1.Move3 = Util.getIndex(CB_Move3); + pk1.Move4 = Util.getIndex(CB_Move4); + pk1.Move1_PP = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; + pk1.Move2_PP = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; + pk1.Move3_PP = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; + pk1.Move4_PP = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; + pk1.Move1_PPUps = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; + pk1.Move2_PPUps = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; + pk1.Move3_PPUps = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; + pk1.Move4_PPUps = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0; + + pk1.IV_HP = Util.ToInt32(TB_HPIV.Text); + pk1.IV_ATK = Util.ToInt32(TB_ATKIV.Text); + pk1.IV_DEF = Util.ToInt32(TB_DEFIV.Text); + pk1.IV_SPE = Util.ToInt32(TB_SPEIV.Text); + pk1.IV_SPA = Util.ToInt32(TB_SPAIV.Text); + + + pk1.OT_Name = TB_OT.Text; + + // Toss in Party Stats + Array.Resize(ref pk1.Data, pk1.SIZE_PARTY); + pk1.Stat_Level = Util.ToInt32(TB_Level.Text); + pk1.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text); + pk1.Stat_HPMax = Util.ToInt32(Stat_HP.Text); + pk1.Stat_ATK = Util.ToInt32(Stat_ATK.Text); + pk1.Stat_DEF = Util.ToInt32(Stat_DEF.Text); + pk1.Stat_SPE = Util.ToInt32(Stat_SPE.Text); + pk1.Stat_SPA = Util.ToInt32(Stat_SPA.Text); + pk1.Stat_SPD = Util.ToInt32(Stat_SPD.Text); + + if (HaX) + { + pk1.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); + } + + // Fix Moves if a slot is empty + pk1.FixMoves(); + + pk1.RefreshChecksum(); + return pk1; + } + } +} diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index db1be6497..21ee6cfea 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -73,6 +73,9 @@ + + Form + Form diff --git a/PKHeX/PKM/PK1.cs b/PKHeX/PKM/PK1.cs index 07d4365a8..64f7307b6 100644 --- a/PKHeX/PKM/PK1.cs +++ b/PKHeX/PKM/PK1.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Linq; using System.Linq.Expressions; @@ -10,6 +11,9 @@ namespace PKHeX protected byte[] otname; protected byte[] nick; + public byte[] OT_Name_Raw => (byte[])otname.Clone(); + public byte[] Nickname_Raw => (byte[])nick.Clone(); + public sealed override int SIZE_PARTY => PKX.SIZE_1PARTY; public override int SIZE_STORED => PKX.SIZE_1STORED; internal const int STRLEN_J = 6; @@ -68,9 +72,15 @@ namespace PKHeX public override byte[] Encrypt() { - throw new NotImplementedException(); + // Oh god this is such total abuse of what this method is meant to do + // Please forgive me + return new PokemonList1(this).GetBytes(); } + // Please forgive me. + public override byte[] EncryptedPartyData => Encrypt().ToArray(); + public override byte[] EncryptedBoxData => Encrypt().ToArray(); + public override bool IsNicknamed { get { throw new NotImplementedException(); } set { } } #region Stored Attributes @@ -100,7 +110,7 @@ namespace PKHeX public override int TID { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0xC)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0xC); } } public override uint EXP { - get { return Util.SwapEndianness(BitConverter.ToUInt32(Data, 0xE)) & 0x00FFFFFF; } + get { return (Util.SwapEndianness(BitConverter.ToUInt32(Data, 0xE)) >> 8) & 0x00FFFFFF; } set { Array.Copy(BitConverter.GetBytes(Util.SwapEndianness((value << 8) & 0xFFFFFF00)), 0, Data, 0xE, 3); } } public override int EV_HP { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x11)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x11); } } @@ -111,13 +121,13 @@ namespace PKHeX public override int EV_SPA { get { return EV_SPC; } set { EV_SPC = value; } } public override int EV_SPD { get { return EV_SPC; } set { EV_SPC = value; } } public ushort DV16 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1B)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x1B); } } - public override int IV_HP { get { return ((IV_ATK & 1) << 3) | ((IV_DEF & 1) << 2) | ((IV_SPD & 1) << 1) | ((IV_SPC & 1) << 0); } set { } } + public override int IV_HP { get { return ((IV_ATK & 1) << 3) | ((IV_DEF & 1) << 2) | ((IV_SPE & 1) << 1) | ((IV_SPC & 1) << 0); } set { } } public override int IV_ATK { get { return (DV16 >> 12) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 12)) | (ushort)((value > 0xF ? 0xF : value) << 12)); } } public override int IV_DEF { get { return (DV16 >> 8) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 8)) | (ushort)((value > 0xF ? 0xF : value) << 8)); } } public override int IV_SPE { get { return (DV16 >> 4) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 4)) | (ushort)((value > 0xF ? 0xF : value) << 4)); } } public int IV_SPC { get { return (DV16 >> 0) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 0)) | (ushort)((value > 0xF ? 0xF : value) << 0)); } } public override int IV_SPA { get { return IV_SPC; } set { IV_SPC = value; } } - public override int IV_SPD { get { return IV_SPC; } set { IV_SPC = value; } } + public override int IV_SPD { get { return IV_SPC; } set { } } public override int Move1_PP { get { return Data[0x1D] & 0x3F; } set { Data[0x1D] = (byte)((Data[0x1D] & 0xC0) | (value & 0x3F)); } } public override int Move2_PP { get { return Data[0x1E] & 0x3F; } set { Data[0x1E] = (byte)((Data[0x1E] & 0xC0) | (value & 0x3F)); } } public override int Move3_PP { get { return Data[0x1F] & 0x3F; } set { Data[0x1F] = (byte)((Data[0x1F] & 0xC0) | (value & 0x3F)); } } @@ -144,6 +154,23 @@ namespace PKHeX public override int Stat_SPD { get { return Stat_SPC; } set { Stat_SPC = value; } } #endregion + public override ushort[] getStats(PersonalInfo p) + { + ushort[] Stats = new ushort[6]; + for (int i = 0; i < Stats.Length; i++) + { + ushort L = (ushort)Stat_Level; + ushort B = (ushort)p.Stats[i]; + ushort I = (ushort)IVs[i]; + ushort E = // Fixed formula via http://www.smogon.com/ingame/guides/rby_gsc_stats + (ushort)Math.Floor(Math.Min(255, Math.Floor(Math.Sqrt(Math.Max(0, EVs[i] - 1)) + 1)) / 4.0); + Stats[i] = (ushort)Math.Floor((2 * (B + I) + E) * L / 100.0 + 5); + } + Stats[0] += (ushort)(5 + Stat_Level); // HP + + return Stats; + } + #region Future, Unused Attributes public override bool getGenderIsValid() { @@ -157,7 +184,15 @@ namespace PKHeX public override bool IsEgg { get { return false; } set { } } public override int Gender { get { return 0; } set { } } public override int HeldItem { get { return 0; } set { } } + + public override bool CanHoldItem(ushort[] ValidArray) + { + return false; + } + public override ushort Sanity { get { return 0; } set { } } + + public override bool ChecksumValid => true; public override ushort Checksum { get { return 0; } set { } } public override int Language { get { return 0; } set { } } public override bool FatefulEncounter { get { return false; } set { } } @@ -298,8 +333,8 @@ namespace PKHeX { Data[1 + i] = (byte)Pokemon[i].Species; Array.Copy(Pokemon[i].Data, 0, Data, 2 + Capacity + Entry_Size * i, Entry_Size); - Array.Copy(PKX.setG1Str(Pokemon[i].OT_Name, Japanese), 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * i, StringLength); - Array.Copy(PKX.setG1Str(Pokemon[i].Nickname, Japanese), 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * Capacity + StringLength * i, StringLength); + Array.Copy(Pokemon[i].OT_Name_Raw, 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * i, StringLength); + Array.Copy(Pokemon[i].Nickname_Raw, 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * Capacity + StringLength * i, StringLength); } Data[1 + Count] = byte.MaxValue; } diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 949efd682..517e36570 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -16,10 +16,10 @@ namespace PKHeX public int Box { get; set; } = -1; // Batch Editor public int Slot { get; set; } = -1; // Batch Editor - public byte[] EncryptedPartyData => Encrypt().Take(SIZE_PARTY).ToArray(); - public byte[] EncryptedBoxData => Encrypt().Take(SIZE_STORED).ToArray(); - public byte[] DecryptedPartyData => Write().Take(SIZE_PARTY).ToArray(); - public byte[] DecryptedBoxData => Write().Take(SIZE_STORED).ToArray(); + public virtual byte[] EncryptedPartyData => Encrypt().Take(SIZE_PARTY).ToArray(); + public virtual byte[] EncryptedBoxData => Encrypt().Take(SIZE_STORED).ToArray(); + public virtual byte[] DecryptedPartyData => Write().Take(SIZE_PARTY).ToArray(); + public virtual byte[] DecryptedBoxData => Write().Take(SIZE_STORED).ToArray(); protected ushort CalculateChecksum() { @@ -250,7 +250,7 @@ namespace PKHeX } public bool PKRS_Infected => PKRS_Strain > 0; public bool PKRS_Cured => PKRS_Days == 0 && PKRS_Strain > 0; - public bool ChecksumValid => Checksum == CalculateChecksum(); + public virtual bool ChecksumValid => Checksum == CalculateChecksum(); public int CurrentLevel => PKX.getLevel(Species, EXP); public bool MarkCircle { get { return (MarkByte & (1 << 0)) == 1 << 0; } set { MarkByte = (byte)(MarkByte & ~(1 << 0) | (value ? 1 << 0 : 0)); } } public bool MarkTriangle { get { return (MarkByte & (1 << 1)) == 1 << 1; } set { MarkByte = (byte)(MarkByte & ~(1 << 0) | (value ? 1 << 0 : 0)); } } @@ -391,7 +391,7 @@ namespace PKHeX } } - public ushort[] getStats(PersonalInfo p) + public virtual ushort[] getStats(PersonalInfo p) { int level = CurrentLevel; ushort[] Stats = new ushort[6]; diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index 1aef62f70..ee24587f5 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -4,7 +4,6 @@ using System.Drawing; using System.Drawing.Text; using System.Linq; using System.Runtime.InteropServices; -using System.Runtime.Remoting.Messaging; using PKHeX.Properties; namespace PKHeX @@ -13,7 +12,7 @@ namespace PKHeX { internal const int SIZE_1ULIST = 69; internal const int SIZE_1JLIST = 59; - internal const int SIZE_1PARTY = 40; + internal const int SIZE_1PARTY = 44; internal const int SIZE_1STORED = 33; internal const int SIZE_3PARTY = 100; @@ -195,19 +194,30 @@ namespace PKHeX public static readonly PersonalTable Personal = PersonalTable.AO; // Stat Fetching - public static byte[] getRandomEVs() + public static uint[] getRandomEVs(int Generation = 6) { - byte[] evs = new byte[6]; - do { - evs[0] = (byte)Math.Min(Util.rnd32() % 300, 252); // bias two to get maybe 252 - evs[1] = (byte)Math.Min(Util.rnd32() % 300, 252); - evs[2] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1]), 252); - evs[3] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2]), 252); - evs[4] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2] - evs[3]), 252); - evs[5] = (byte)Math.Min(510 - evs[0] - evs[1] - evs[2] - evs[3] - evs[4], 252); - } while (evs.Sum(b => b) > 510); // recalculate random EVs... - Util.Shuffle(evs); - return evs; + if (Generation > 2) + { + uint[] evs = new uint[6]; + do + { + evs[0] = (byte)Math.Min(Util.rnd32() % 300, 252); // bias two to get maybe 252 + evs[1] = (byte)Math.Min(Util.rnd32() % 300, 252); + evs[2] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1]), 252); + evs[3] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2]), 252); + evs[4] = (byte)Math.Min(Util.rnd32() % (510 - evs[0] - evs[1] - evs[2] - evs[3]), 252); + evs[5] = (byte)Math.Min(510 - evs[0] - evs[1] - evs[2] - evs[3] - evs[4], 252); + } while (evs.Sum(b => b) > 510); // recalculate random EVs... + Util.Shuffle(evs); + return evs; + } + else + { + uint[] evs = new uint[6]; + for (int i = 0; i < evs.Length; i++) + evs[i] = Util.rnd32()%0x10000; + return evs; + } } public static int getLevel(int species, uint exp) { @@ -1693,7 +1703,6 @@ namespace PKHeX {0xE3, "-"}, {0xE6, "?"}, {0xE7, "!"}, - {0xE8, "."}, {0xEF, "♂"}, {0xF2, "."}, {0xF3, "/"}, @@ -1778,7 +1787,6 @@ namespace PKHeX {"-", 0xE3}, {"?", 0xE6}, {"!", 0xE7}, - {".", 0xE8}, {"♂", 0xEF}, {".", 0xF2}, {"/", 0xF3}, diff --git a/PKHeX/PersonalInfo/PersonalInfo.cs b/PKHeX/PersonalInfo/PersonalInfo.cs index 10e76c4f1..fa5abb10d 100644 --- a/PKHeX/PersonalInfo/PersonalInfo.cs +++ b/PKHeX/PersonalInfo/PersonalInfo.cs @@ -10,6 +10,9 @@ public abstract int SPE { get; set; } public abstract int SPA { get; set; } public abstract int SPD { get; set; } + + public int[] Stats => new[] { HP, ATK, DEF, SPE, SPA, SPD }; + public abstract int EV_HP { get; set; } public abstract int EV_ATK { get; set; } public abstract int EV_DEF { get; set; } diff --git a/PKHeX/Saves/Inventory.cs b/PKHeX/Saves/Inventory.cs index c49391632..cc2ab1281 100644 --- a/PKHeX/Saves/Inventory.cs +++ b/PKHeX/Saves/Inventory.cs @@ -63,5 +63,43 @@ namespace PKHeX BitConverter.GetBytes((ushort)((ushort)Items[i].Count ^ (ushort)SecurityKey)).CopyTo(Data, Offset + i*4 + 2); } } + + public void getPouchG1(ref byte[] Data) + { + InventoryItem[] items = new InventoryItem[PouchDataSize]; + int numStored = Data[Offset]; + for (int i = 0; i < numStored; i++) + { + items[i] = new InventoryItem + { + Index = Data[Offset + i * 2 + 1], + Count = Data[Offset + i * 2 + 2] + }; + } + for (int i = numStored; i < items.Length; i++) + { + items[i] = new InventoryItem + { + Index = 0, + Count = 0 + }; + } + Items = items; + + } + + public void setPouchG1(ref byte[] Data) + { + if (Items.Length != PouchDataSize) + throw new ArgumentException("Item array length does not match original pouch size."); + + for (int i = 0; i < Items.Length; i++) + { + Data[Offset + i * 2 + 1] = (byte)Items[i].Index; + Data[Offset + i * 2 + 2] = (byte)Items[i].Count; + } + Data[Offset] = (byte) Count; + Data[Offset + 1 + 2*Count] = 0xFF; + } } } diff --git a/PKHeX/Saves/SAV1.cs b/PKHeX/Saves/SAV1.cs index e19cfe335..bc98a5600 100644 --- a/PKHeX/Saves/SAV1.cs +++ b/PKHeX/Saves/SAV1.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Globalization; using System.Linq; @@ -22,21 +23,83 @@ namespace PKHeX if (Version == GameVersion.Invalid) return; - Japanese = SaveUtil.getIsG1SAVJ(data); + Box = Data.Length; + Array.Resize(ref Data, Data.Length + SIZE_RESERVED); + Party = getPartyOffset(0); - OFS_PouchHeldItem = (Japanese ? 0x25C4 : 0x25C9); - OFS_PCItem = (Japanese ? 0x27DC : 0x27E6); + Japanese = SaveUtil.getIsG1SAVJ(data); Personal = PersonalTable.RBY; + // Stash boxes after the save file's end. + byte[] TempBox = new byte[SIZE_BOX]; + for (int i = 0; i < BoxCount; i++) + { + if (i < BoxCount / 2) + Array.Copy(Data, 0x4000 + i * TempBox.Length, TempBox, 0, TempBox.Length); + else + Array.Copy(Data, 0x6000 + (i - BoxCount / 2) * TempBox.Length, TempBox, 0, TempBox.Length); + PokemonList1 PL1 = new PokemonList1(TempBox, Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese); + for (int j = 0; j < PL1.Pokemon.Length; j++) + { + if (j < PL1.Count) + { + byte[] pkDat = new PokemonList1(PL1[j]).GetBytes(); + pkDat.CopyTo(Data, Data.Length - SIZE_RESERVED + i * SIZE_BOX + j * SIZE_STORED); + } + else + { + byte[] pkDat = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Single, Japanese)]; + pkDat.CopyTo(Data, Data.Length - SIZE_RESERVED + i * SIZE_BOX + j * SIZE_STORED); + } + } + } + + Array.Copy(Data, Japanese ? 0x302D : 0x30C0, TempBox, 0, TempBox.Length); + PokemonList1 curBoxPL = new PokemonList1(TempBox, Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese); + for (int i = 0; i < curBoxPL.Pokemon.Length; i++) + { + if (i < curBoxPL.Count) + { + byte[] pkDat = new PokemonList1(curBoxPL[i]).GetBytes(); + pkDat.CopyTo(Data, Data.Length - SIZE_RESERVED + CurrentBox * SIZE_BOX + i * SIZE_STORED); + } + else + { + byte[] pkDat = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Single, Japanese)]; + pkDat.CopyTo(Data, Data.Length - SIZE_RESERVED + CurrentBox * SIZE_BOX + i * SIZE_STORED); + } + } + + byte[] TempParty = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Party, Japanese)]; + Array.Copy(Data, Japanese ? 0x2ED5 : 0x2F2C, TempParty, 0, TempParty.Length); + PokemonList1 partyList = new PokemonList1(TempParty, PokemonList1.CapacityType.Party, Japanese); + for (int i = 0; i < partyList.Pokemon.Length; i++) + { + if (i < partyList.Count) + { + byte[] pkDat = new PokemonList1(partyList[i]).GetBytes(); + pkDat.CopyTo(Data, getPartyOffset(i)); + } + else + { + byte[] pkDat = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Single, Japanese)]; + pkDat.CopyTo(Data, getPartyOffset(i)); + } + } + + File.WriteAllBytes("temp.sav", Data); + + if (!Exportable) resetBoxes(); } - private const int SIZE_RESERVED = 0x10000; // unpacked box data + private const int SIZE_RESERVED = 0x8000; // unpacked box data public override byte[] Write(bool DSV) { - + // TODO: Implement Box Data Relocation setChecksums(); + Array.Resize(ref Data, Data.Length - SIZE_RESERVED); return Data; } @@ -44,9 +107,11 @@ namespace PKHeX // Configuration public override SaveFile Clone() { return new SAV1(Data); } - public override int SIZE_STORED => PKX.SIZE_1STORED; - public override int SIZE_PARTY => PKX.SIZE_1PARTY; - public override PKM BlankPKM => new PK1(); + public override int SIZE_STORED => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST; + public override int SIZE_PARTY => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST; + + public int SIZE_BOX => PokemonList1.GetDataLength(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese); + public override PKM BlankPKM => new PK1(null, null, Japanese); protected override Type PKMType => typeof(PK1); public override int MaxMoveID => 165; @@ -58,6 +123,7 @@ namespace PKHeX public override int BoxCount => Japanese ? 8 : 12; public override int MaxEV => 65535; + public override int MaxIV => 15; public override int Generation => 1; protected override int GiftCountMax => 0; public override int OTLength => Japanese ? 5 : 10; @@ -114,7 +180,7 @@ namespace PKHeX public override string OT { - get { return PKX.getG3Str(Data.Skip(0x2598).Take(StringLength).ToArray(), Japanese); } + get { return PKX.getG1Str(Data.Skip(0x2598).Take(StringLength).ToArray(), Japanese); } set { byte[] strdata = PKX.setG1Str(value, Japanese); @@ -174,7 +240,7 @@ namespace PKHeX } } - private readonly ushort[] LegalItems; + private readonly ushort[] LegalItems = Enumerable.Range(1, 255).Select(i => (ushort)i).ToArray(); public override InventoryPouch[] Inventory { get @@ -182,21 +248,12 @@ namespace PKHeX ushort[] legalItems = LegalItems; InventoryPouch[] pouch = { - new InventoryPouch(InventoryType.Items, legalItems, 99, OFS_PouchHeldItem + 2, 20), - new InventoryPouch(InventoryType.Items, legalItems, 99, OFS_PCItem + 2, 50), + new InventoryPouch(InventoryType.Items, legalItems, 99, (Japanese ? 0x25C4 : 0x25C9), 20), + new InventoryPouch(InventoryType.Items, legalItems, 99, (Japanese ? 0x27DC : 0x27E6), 50), }; foreach (var p in pouch) { - p.getPouch(ref Data); - int ofs = 0; - for (int i = 0; i < p.Count; i++) - { - while (p.Items[ofs].Count == 0) - ofs++; - p.Items[i] = p.Items[ofs++]; - } - while (ofs < p.MaxCount) - p.Items[ofs++] = new InventoryItem { Count = 0, Index = 0 }; + p.getPouchG1(ref Data); } return pouch; } @@ -211,10 +268,9 @@ namespace PKHeX ofs++; p.Items[i] = p.Items[ofs++]; } - while (ofs < p.MaxCount) + while (ofs < p.Items.Length) p.Items[ofs++] = new InventoryItem { Count = 0, Index = 0 }; - p.setPouch(ref Data); - Data[p.Offset - 2] = (byte)p.Count; + p.setPouchG1(ref Data); } } } @@ -244,6 +300,9 @@ namespace PKHeX } // Storage + + public override int BoxSlotCount => Japanese ? 30 : 20; + public override int PartyCount { get { return Data[Japanese ? 0x2ED5 : 0x2F2C]; } @@ -254,16 +313,16 @@ namespace PKHeX } public override int getBoxOffset(int box) { - throw new NotImplementedException(); + return Data.Length - SIZE_RESERVED + box * SIZE_BOX; } public override int getPartyOffset(int slot) { - throw new NotImplementedException(); + return Data.Length - SIZE_RESERVED + BoxCount * SIZE_BOX + slot * SIZE_STORED; } public override int CurrentBox { - get { return Data[Japanese ? 0x2842 : 0x284C]; } - set { Data[Japanese ? 0x2842 : 0x284C] = (byte)value; } + get { return Data[Japanese ? 0x2842 : 0x284C] & 0x7F; } + set { Data[Japanese ? 0x2842 : 0x284C] = (byte)((Data[Japanese ? 0x2842 : 0x284C] & 0x80) | (value & 0x7F)); } } public override int getBoxWallpaper(int box) { @@ -271,16 +330,16 @@ namespace PKHeX } public override string getBoxName(int box) { - int boxNum = box + 1; - return $"Box {boxNum}"; + return string.Format("Box {0}", box + 1); } public override void setBoxName(int box, string value) { - + // Don't allow for custom box names } + public override PKM getPKM(byte[] data) { - if (data.Length == PKX.SIZE_1JLIST || data.Length == PKX.SIZE_1ULIST) + if (data.Length == SIZE_STORED) return new PokemonList1(data, PokemonList1.CapacityType.Single, Japanese)[0]; return new PK1(data); } diff --git a/PKHeX/Saves/SaveFile.cs b/PKHeX/Saves/SaveFile.cs index 84533da8c..fdc5c86d5 100644 --- a/PKHeX/Saves/SaveFile.cs +++ b/PKHeX/Saves/SaveFile.cs @@ -29,6 +29,7 @@ namespace PKHeX public abstract int SIZE_STORED { get; } public abstract int SIZE_PARTY { get; } public abstract int MaxEV { get; } + public virtual int MaxIV => 31; public ushort[] HeldItems { get; protected set; } // General SAV Properties @@ -128,13 +129,13 @@ namespace PKHeX { get { - PKM[] data = new PKM[BoxCount*30]; + PKM[] data = new PKM[BoxCount*BoxSlotCount]; for (int i = 0; i < data.Length; i++) { - data[i] = getStoredSlot(getBoxOffset(i/30) + SIZE_STORED*(i%30)); - data[i].Identifier = $"{getBoxName(i/30)}:{(i%30 + 1).ToString("00")}"; - data[i].Box = i/30 + 1; - data[i].Slot = i%30 + 1; + data[i] = getStoredSlot(getBoxOffset(i/BoxSlotCount) + SIZE_STORED*(i%BoxSlotCount)); + data[i].Identifier = $"{getBoxName(i/BoxSlotCount)}:{(i%BoxSlotCount + 1).ToString("00")}"; + data[i].Box = i/BoxSlotCount + 1; + data[i].Slot = i%BoxSlotCount + 1; } return data; } @@ -142,13 +143,13 @@ namespace PKHeX { if (value == null) throw new ArgumentNullException(); - if (value.Length != BoxCount*30) - throw new ArgumentException($"Expected {BoxCount*30}, got {value.Length}"); + if (value.Length != BoxCount*BoxSlotCount) + throw new ArgumentException($"Expected {BoxCount*BoxSlotCount}, got {value.Length}"); if (value.Any(pk => PKMType != pk.GetType())) throw new ArgumentException($"Not {PKMType} array."); for (int i = 0; i < value.Length; i++) - setStoredSlot(value[i], getBoxOffset(i/30) + SIZE_STORED*(i%30)); + setStoredSlot(value[i], getBoxOffset(i/BoxSlotCount) + SIZE_STORED*(i%BoxSlotCount)); } } public PKM[] PartyData @@ -330,6 +331,7 @@ namespace PKHeX public abstract void setDaycareOccupied(int loc, int slot, bool occupied); // Storage + public virtual int BoxSlotCount => 30; public PKM getPartySlot(int offset) { return getPKM(decryptPKM(getData(offset, SIZE_PARTY))); @@ -417,9 +419,9 @@ namespace PKHeX public void sortBoxes(int BoxStart = 0, int BoxEnd = -1) { PKM[] BD = BoxData; - var Section = BD.Skip(BoxStart*30); + var Section = BD.Skip(BoxStart*BoxSlotCount); if (BoxEnd > BoxStart) - Section = Section.Take(30*(BoxEnd - BoxStart)); + Section = Section.Take(BoxSlotCount*(BoxEnd - BoxStart)); var Sorted = Section .OrderBy(p => p.Species == 0) // empty slots at end @@ -427,7 +429,7 @@ namespace PKHeX .ThenBy(p => p.Species) // species sorted .ThenBy(p => p.IsNicknamed).ToArray(); - Array.Copy(Sorted, 0, BD, BoxStart*30, Sorted.Length); + Array.Copy(Sorted, 0, BD, BoxStart*BoxSlotCount, Sorted.Length); BoxData = BD; } public void resetBoxes(int BoxStart = 0, int BoxEnd = -1) @@ -437,13 +439,13 @@ namespace PKHeX for (int i = BoxStart; i < BoxEnd; i++) { int offset = getBoxOffset(i); - for (int p = 0; p < 30; p++) + for (int p = 0; p < BoxSlotCount; p++) setStoredSlot(BlankPKM, offset + SIZE_STORED * p); } } public byte[] getPCBin() { return BoxData.SelectMany(pk => pk.EncryptedBoxData).ToArray(); } - public byte[] getBoxBin(int box) { return BoxData.Skip(box*30).Take(30).SelectMany(pk => pk.EncryptedBoxData).ToArray(); } + public byte[] getBoxBin(int box) { return BoxData.Skip(box*BoxSlotCount).Take(BoxSlotCount).SelectMany(pk => pk.EncryptedBoxData).ToArray(); } public bool setPCBin(byte[] data) { if (data.Length != getPCBin().Length) @@ -476,8 +478,8 @@ namespace PKHeX } PKM[] pkms = BoxData; - for (int i = 0; i < 30; i++) - pkms[box*30 + i].Data = decryptPKM(pkdata[i]); + for (int i = 0; i < BoxSlotCount; i++) + pkms[box*BoxSlotCount + i].Data = decryptPKM(pkdata[i]); BoxData = pkms; return true; } diff --git a/PKHeX/Saves/SaveUtil.cs b/PKHeX/Saves/SaveUtil.cs index f10c94de9..8c53069c5 100644 --- a/PKHeX/Saves/SaveUtil.cs +++ b/PKHeX/Saves/SaveUtil.cs @@ -212,6 +212,8 @@ namespace PKHeX { switch (getSAVGeneration(data)) { + case 1: + return new SAV1(data); case 3: return new SAV3(data); case 4: From c9f0eab1c96ee16fe4008b84cb859af3133d03b2 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 28 Aug 2016 12:42:29 -0700 Subject: [PATCH 30/43] Fix pt encountertype appearance >= 7, <= 12, != 9 Wrong GameVersion enum values (why hgss uses a number before idk) Thanks JSS! --- PKHeX/MainWindow/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 08c8e8753..f03025b10 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -2026,7 +2026,7 @@ namespace PKHeX // Visibility logic for Gen 4 encounter type; only show for Gen 4 Pokemon. if (SAV.Generation >= 4) { - bool g4 = Version >= GameVersion.D && Version <= GameVersion.SS; + bool g4 = Version >= GameVersion.HG && Version <= GameVersion.Pt; if ((int) Version == 9) // invalid g4 = false; CB_EncounterType.Visible = Label_EncounterType.Visible = g4; From d41c8f97312916c5d75f0d90abfa639f358e3ebf Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 28 Aug 2016 20:13:52 -0700 Subject: [PATCH 31/43] Allow multiple boxview popups Moved to new doubleClick method, can pop up more than one by holding Shift --- PKHeX/MainWindow/Main.Designer.cs | 45 ++++++++++++++++--------------- PKHeX/MainWindow/Main.cs | 12 ++++++--- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/PKHeX/MainWindow/Main.Designer.cs b/PKHeX/MainWindow/Main.Designer.cs index 51e1d7dc1..ed26d445d 100644 --- a/PKHeX/MainWindow/Main.Designer.cs +++ b/PKHeX/MainWindow/Main.Designer.cs @@ -348,10 +348,10 @@ this.B_OpenOPowers = new System.Windows.Forms.Button(); this.B_OpenEventFlags = new System.Windows.Forms.Button(); this.B_OpenPokedex = new System.Windows.Forms.Button(); - this.B_OpenBerryField = new System.Windows.Forms.Button(); - this.B_OpenSecretBase = new System.Windows.Forms.Button(); - this.B_Pokeblocks = new System.Windows.Forms.Button(); this.B_LinkInfo = new System.Windows.Forms.Button(); + this.B_OpenBerryField = new System.Windows.Forms.Button(); + this.B_Pokeblocks = new System.Windows.Forms.Button(); + this.B_OpenSecretBase = new System.Windows.Forms.Button(); this.B_OpenPokepuffs = new System.Windows.Forms.Button(); this.B_OpenSuperTraining = new System.Windows.Forms.Button(); this.B_OpenHallofFame = new System.Windows.Forms.Button(); @@ -3007,6 +3007,7 @@ this.tabBoxMulti.Size = new System.Drawing.Size(310, 225); this.tabBoxMulti.TabIndex = 50; this.tabBoxMulti.Click += new System.EventHandler(this.clickBoxSort); + this.tabBoxMulti.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.clickBoxDouble); // // Tab_Box // @@ -4454,6 +4455,16 @@ this.B_OpenPokedex.UseVisualStyleBackColor = true; this.B_OpenPokedex.Click += new System.EventHandler(this.B_OpenPokedex_Click); // + // B_LinkInfo + // + this.B_LinkInfo.Location = new System.Drawing.Point(96, 61); + this.B_LinkInfo.Name = "B_LinkInfo"; + this.B_LinkInfo.Size = new System.Drawing.Size(87, 23); + this.B_LinkInfo.TabIndex = 23; + this.B_LinkInfo.Text = "Link Data"; + this.B_LinkInfo.UseVisualStyleBackColor = true; + this.B_LinkInfo.Click += new System.EventHandler(this.B_LinkInfo_Click); + // // B_OpenBerryField // this.B_OpenBerryField.Location = new System.Drawing.Point(189, 61); @@ -4464,17 +4475,6 @@ this.B_OpenBerryField.UseVisualStyleBackColor = true; this.B_OpenBerryField.Click += new System.EventHandler(this.B_OpenBerryField_Click); // - // B_OpenSecretBase - // - this.B_OpenSecretBase.Location = new System.Drawing.Point(96, 90); - this.B_OpenSecretBase.Name = "B_OpenSecretBase"; - this.B_OpenSecretBase.Size = new System.Drawing.Size(87, 23); - this.B_OpenSecretBase.TabIndex = 21; - this.B_OpenSecretBase.Text = "Secret Base"; - this.B_OpenSecretBase.UseVisualStyleBackColor = true; - this.B_OpenSecretBase.Visible = false; - this.B_OpenSecretBase.Click += new System.EventHandler(this.B_OpenSecretBase_Click); - // // B_Pokeblocks // this.B_Pokeblocks.Location = new System.Drawing.Point(3, 90); @@ -4486,15 +4486,16 @@ this.B_Pokeblocks.Visible = false; this.B_Pokeblocks.Click += new System.EventHandler(this.B_OpenPokeblocks_Click); // - // B_LinkInfo + // B_OpenSecretBase // - this.B_LinkInfo.Location = new System.Drawing.Point(96, 61); - this.B_LinkInfo.Name = "B_LinkInfo"; - this.B_LinkInfo.Size = new System.Drawing.Size(87, 23); - this.B_LinkInfo.TabIndex = 23; - this.B_LinkInfo.Text = "Link Data"; - this.B_LinkInfo.UseVisualStyleBackColor = true; - this.B_LinkInfo.Click += new System.EventHandler(this.B_LinkInfo_Click); + this.B_OpenSecretBase.Location = new System.Drawing.Point(96, 90); + this.B_OpenSecretBase.Name = "B_OpenSecretBase"; + this.B_OpenSecretBase.Size = new System.Drawing.Size(87, 23); + this.B_OpenSecretBase.TabIndex = 21; + this.B_OpenSecretBase.Text = "Secret Base"; + this.B_OpenSecretBase.UseVisualStyleBackColor = true; + this.B_OpenSecretBase.Visible = false; + this.B_OpenSecretBase.Click += new System.EventHandler(this.B_OpenSecretBase_Click); // // B_OpenPokepuffs // diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index f03025b10..82cd76d35 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -2662,14 +2662,20 @@ namespace PKHeX setPKXBoxes(); Util.Alert("Current Box sorted!"); } - else if (ModifierKeys == Keys.Shift) + } + private void clickBoxDouble(object sender, MouseEventArgs e) + { + if (tabBoxMulti.SelectedIndex != 0) + return; + if (!SAV.HasBox) + return; + if (ModifierKeys != Keys.Shift) { var z = Application.OpenForms.Cast().FirstOrDefault(form => form.GetType() == typeof(SAV_BoxViewer)) as SAV_BoxViewer; if (z != null) { Util.CenterToForm(z, this); z.BringToFront(); return; } - - new SAV_BoxViewer(this).Show(); } + new SAV_BoxViewer(this).Show(); } public int swapBoxesViewer(int viewBox) { From 8cfe57d504c41331b1855c0a6abb9c3853b40916 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 28 Aug 2016 22:21:55 -0700 Subject: [PATCH 32/43] Implement PK1 loading/editing/saving. --- PKHeX/MainWindow/Main.cs | 45 +++++++++++++++++++++++++++++-------- PKHeX/MainWindow/MainPK1.cs | 2 +- PKHeX/PKM/PK1.cs | 40 ++++++++++++++++++++++++--------- PKHeX/PKM/PKM.cs | 2 +- PKHeX/PKM/PKMConverter.cs | 20 +++++++++++++++++ PKHeX/PKM/PKX.cs | 3 ++- PKHeX/Saves/SAV1.cs | 2 +- PKHeX/Saves/SaveFile.cs | 2 ++ 8 files changed, 93 insertions(+), 23 deletions(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 1adc20910..3af0b7051 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -237,7 +237,7 @@ namespace PKHeX SaveFileDialog sfd = new SaveFileDialog { Filter = $"Decrypted PKM File|*.{pkx}" + - $"|Encrypted PKM File|*.{ekx}" + + (SAV.Generation > 2 ? "" : $"|Encrypted PKM File|*.{ekx}") + "|Binary File|*.bin" + "|All Files|*.*", DefaultExt = pkx, @@ -592,6 +592,8 @@ namespace PKHeX PKM pk = PKMConverter.convertToFormat(temp, SAV.Generation, out c); if (pk == null) Util.Alert("Conversion failed.", c); + else if (SAV.Generation == 1 && ((PK1) pk).Japanese != SAV.GetJapanese) + Util.Alert(string.Format("Cannot load {0} PK1 in {1} save file.", SAV.GetJapanese ? "an International" : "a Japanese", SAV.GetJapanese ? "a Japanese" : "an International")); else populateFields(pk); Console.WriteLine(c); @@ -848,7 +850,23 @@ namespace PKHeX Label_CharacteristicPrefix.Visible = L_Characteristic.Visible = SAV.Generation > 1; Label_ContestStats.Visible = Label_Cool.Visible = Label_Tough.Visible = Label_Smart.Visible = Label_Sheen.Visible = Label_Beauty.Visible = Label_Cute.Visible = TB_Cool.Visible = TB_Tough.Visible = - TB_Smart.Visible = TB_Sheen.Visible = TB_Beauty.Visible = TB_Cute.Visible = SAV.Generation >= 3; + TB_Smart.Visible = TB_Sheen.Visible = TB_Beauty.Visible = TB_Cute.Visible = Label_Nature.Visible = + CB_Nature.Visible = Label_Language.Visible = CB_Language.Visible = Label_Ability.Visible = + Label_Friendship.Visible = Label_HatchCounter.Visible = TB_Friendship.Visible = BTN_RerollPID.Visible = + Label_PID.Visible = TB_PID.Visible = Label_SID.Visible = TB_SID.Visible = SAV.Generation >= 3; + + // Met Tab + CHK_Fateful.Visible = Label_OriginGame.Visible = Label_Ball.Visible = Label_MetLevel.Visible = + Label_MetLocation.Visible = CB_GameOrigin.Visible = CB_Ball.Visible = CB_MetLocation.Visible = + TB_MetLevel.Visible = SAV.Generation > 2; + + CHK_Infected.Visible = CHK_Cured.Visible = SAV.Generation >= 3; + + CHK_IsEgg.Visible = Label_Gender.Visible = SAV.Generation > 1; + + Label_OTGender.Visible = SAV.Generation > 1; + + CHK_Nicknamed.Enabled = SAV.Generation > 2; if (1 <= sav.Generation && sav.Generation <= 2) { @@ -922,7 +940,7 @@ namespace PKHeX bool init = fieldsInitialized; fieldsInitialized = false; populateFilteredDataSources(); - populateFields(pkm.Format != SAV.Generation ? SAV.BlankPKM : pk); + populateFields((pkm.Format != SAV.Generation || SAV.Generation == 1) ? SAV.BlankPKM : pk); fieldsInitialized |= init; // SAV Specific Limits @@ -1312,8 +1330,8 @@ namespace PKHeX bool isShiny = pkm.IsShiny; // Set the Controls - BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny; - Label_IsShiny.Visible = isShiny; + BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny && SAV.Generation > 2; + Label_IsShiny.Visible = isShiny && SAV.Generation > 1; // Refresh Markings (for Shiny Star if applicable) setMarkings(); @@ -1686,6 +1704,7 @@ namespace PKHeX } private void updateRandomEVs(object sender, EventArgs e) { + changingFields = true; if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift) { // Max EVs @@ -1706,6 +1725,8 @@ namespace PKHeX TB_SPDEV.Text = evs[4].ToString(); TB_SPEEV.Text = evs[5].ToString(); } + changingFields = false; + updateEVs(null, null); } private void updateRandomPID(object sender, EventArgs e) { @@ -2174,8 +2195,9 @@ namespace PKHeX } } // Display hatch counter if it is an egg, Display Friendship if it is not. - Label_HatchCounter.Visible = CHK_IsEgg.Checked; - Label_Friendship.Visible = !CHK_IsEgg.Checked; + Label_HatchCounter.Visible = CHK_IsEgg.Checked && SAV.Generation > 1; + Label_Friendship.Visible = !CHK_IsEgg.Checked && SAV.Generation > 2; + // Update image to (not) show egg. if (!fieldsInitialized) return; @@ -2981,11 +3003,13 @@ namespace PKHeX for (int i = 0; i < 30; i++) { if (i < SAV.BoxSlotCount) - getSlotFiller(boxoffset + SAV.SIZE_STORED*i, SlotPictureBoxes[i]); + { + getSlotFiller(boxoffset + SAV.SIZE_STORED * i, SlotPictureBoxes[i]); + } else { SlotPictureBoxes[i].Image = null; - SlotPictureBoxes[i].BackColor = Color.Gray; + SlotPictureBoxes[i].Visible = false; } } } @@ -3100,6 +3124,7 @@ namespace PKHeX // 00s present in slot. pb.Image = null; pb.BackColor = Color.Transparent; + pb.Visible = true; return; } PKM p = SAV.getStoredSlot(offset); @@ -3108,11 +3133,13 @@ namespace PKHeX // Bad Egg present in slot. pb.Image = null; pb.BackColor = Color.Red; + pb.Visible = true; return; } // Something stored in slot. Only display if species is valid. pb.Image = p.Species == 0 ? null : p.Sprite; pb.BackColor = Color.Transparent; + pb.Visible = true; } private void getSlotColor(int slot, Image color) { diff --git a/PKHeX/MainWindow/MainPK1.cs b/PKHeX/MainWindow/MainPK1.cs index f34be25cf..401bff69f 100644 --- a/PKHeX/MainWindow/MainPK1.cs +++ b/PKHeX/MainWindow/MainPK1.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace PKHeX { @@ -94,7 +95,6 @@ namespace PKHeX pk1.IV_SPE = Util.ToInt32(TB_SPEIV.Text); pk1.IV_SPA = Util.ToInt32(TB_SPAIV.Text); - pk1.OT_Name = TB_OT.Text; // Toss in Party Stats diff --git a/PKHeX/PKM/PK1.cs b/PKHeX/PKM/PK1.cs index 64f7307b6..cebcf5208 100644 --- a/PKHeX/PKM/PK1.cs +++ b/PKHeX/PKM/PK1.cs @@ -8,8 +8,8 @@ namespace PKHeX class PK1 : PKM { // Internal use only - protected byte[] otname; - protected byte[] nick; + protected internal byte[] otname; + protected internal byte[] nick; public byte[] OT_Name_Raw => (byte[])otname.Clone(); public byte[] Nickname_Raw => (byte[])nick.Clone(); @@ -24,6 +24,8 @@ namespace PKHeX public bool Japanese => otname.Length == STRLEN_J; + public override string FileName => $"{Species.ToString("000")} - {Nickname} - {OT_Name}.{Extension}"; + public PK1(byte[] decryptedData = null, string ident = null, bool jp = false) { Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone(); @@ -41,7 +43,7 @@ namespace PKHeX public override PKM Clone() { - PK1 new_pk1 = new PK1(Data); + PK1 new_pk1 = new PK1(Data, Identifier, Japanese); Array.Copy(otname, 0, new_pk1.otname, 0, otname.Length); Array.Copy(nick, 0, new_pk1.nick, 0, nick.Length); return new_pk1; @@ -53,7 +55,15 @@ namespace PKHeX { byte[] strdata = PKX.setG1Str(value, Japanese); if (strdata.Length > StringLength) - throw new ArgumentOutOfRangeException("OT Name too long for given PK1"); + throw new ArgumentOutOfRangeException($"Nickname {value} too long for given PK1"); + if (nick.Any(b => b == 0) && nick[StringLength - 1] == 0x50 && Array.FindIndex(nick, b => b == 0) == strdata.Length - 1) // Handle JP Mew event with grace + { + int firstInd = Array.FindIndex(nick, b => b == 0); + for (int i = firstInd; i < StringLength - 1; i++) + if (nick[i] != 0) + break; + strdata = strdata.Take(strdata.Length - 1).ToArray(); + } strdata.CopyTo(nick, 0); } } @@ -65,7 +75,15 @@ namespace PKHeX { byte[] strdata = PKX.setG1Str(value, Japanese); if (strdata.Length > StringLength) - throw new ArgumentOutOfRangeException("OT Name too long for given PK1"); + throw new ArgumentOutOfRangeException($"OT Name {value} too long for given PK1"); + if (otname.Any(b => b == 0) && otname[StringLength - 1] == 0x50 && Array.FindIndex(otname, b => b == 0) == strdata.Length - 1) // Handle JP Mew event with grace + { + int firstInd = Array.FindIndex(otname, b => b == 0); + for (int i = firstInd; i < StringLength - 1; i++) + if (otname[i] != 0) + break; + strdata = strdata.Take(strdata.Length - 1).ToArray(); + } strdata.CopyTo(otname, 0); } } @@ -80,6 +98,8 @@ namespace PKHeX // Please forgive me. public override byte[] EncryptedPartyData => Encrypt().ToArray(); public override byte[] EncryptedBoxData => Encrypt().ToArray(); + public override byte[] DecryptedBoxData => Encrypt().ToArray(); + public override byte[] DecryptedPartyData => Encrypt().ToArray(); public override bool IsNicknamed { get { throw new NotImplementedException(); } set { } } @@ -119,7 +139,7 @@ namespace PKHeX public override int EV_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x17)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x17); } } public int EV_SPC { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x19)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x19); } } public override int EV_SPA { get { return EV_SPC; } set { EV_SPC = value; } } - public override int EV_SPD { get { return EV_SPC; } set { EV_SPC = value; } } + public override int EV_SPD { get { return EV_SPC; } set { } } public ushort DV16 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1B)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x1B); } } public override int IV_HP { get { return ((IV_ATK & 1) << 3) | ((IV_DEF & 1) << 2) | ((IV_SPE & 1) << 1) | ((IV_SPC & 1) << 0); } set { } } public override int IV_ATK { get { return (DV16 >> 12) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 12)) | (ushort)((value > 0xF ? 0xF : value) << 12)); } } @@ -151,7 +171,7 @@ namespace PKHeX public int Stat_SPC { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2A)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2A); } } // Leave SPA and SPD as alias for SPC public override int Stat_SPA { get { return Stat_SPC; } set { Stat_SPC = value; } } - public override int Stat_SPD { get { return Stat_SPC; } set { Stat_SPC = value; } } + public override int Stat_SPD { get { return Stat_SPC; } set { } } #endregion public override ushort[] getStats(PersonalInfo p) @@ -278,8 +298,8 @@ namespace PKHeX int base_ofs = 2 + Capacity; byte[] dat = Data.Skip(base_ofs + Entry_Size * i).Take(Entry_Size).ToArray(); Pokemon[i] = new PK1(dat, null, jp); - Pokemon[i].OT_Name = PKX.getG1Str(Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * i).Take(StringLength).ToArray(), Japanese); - Pokemon[i].Nickname = PKX.getG1Str(Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * Capacity + StringLength * i).Take(StringLength).ToArray(), Japanese); + Pokemon[i].otname = Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * i).Take(StringLength).ToArray(); + Pokemon[i].nick = Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * Capacity + StringLength * i).Take(StringLength).ToArray(); } } @@ -331,7 +351,7 @@ namespace PKHeX { for (int i = 0; i < Count; i++) { - Data[1 + i] = (byte)Pokemon[i].Species; + Data[1 + i] = (byte)PKX.setG1Species(Pokemon[i].Species); Array.Copy(Pokemon[i].Data, 0, Data, 2 + Capacity + Entry_Size * i, Entry_Size); Array.Copy(Pokemon[i].OT_Name_Raw, 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * i, StringLength); Array.Copy(Pokemon[i].Nickname_Raw, 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * Capacity + StringLength * i, StringLength); diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 517e36570..84b89785f 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -261,7 +261,7 @@ namespace PKHeX public Image Sprite => PKX.getSprite(this); public string ShowdownText => ShowdownSet.getShowdownText(this); public string[] QRText => PKX.getQRText(this); - public string FileName => $"{Species.ToString("000")}{(IsShiny ? " ★" : "")} - {Nickname} - {Checksum.ToString("X4")}{EncryptionConstant.ToString("X8")}.{Extension}"; + public virtual string FileName => $"{Species.ToString("000")}{(IsShiny ? " ★" : "")} - {Nickname} - {Checksum.ToString("X4")}{EncryptionConstant.ToString("X8")}.{Extension}"; public int[] IVs { get { return new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; } diff --git a/PKHeX/PKM/PKMConverter.cs b/PKHeX/PKM/PKMConverter.cs index be573542a..6637c6579 100644 --- a/PKHeX/PKM/PKMConverter.cs +++ b/PKHeX/PKM/PKMConverter.cs @@ -31,6 +31,9 @@ namespace PKHeX switch (data.Length) { + case PKX.SIZE_1JLIST: + case PKX.SIZE_1ULIST: + return 1; case PKX.SIZE_3PARTY: case PKX.SIZE_3STORED: return 3; @@ -70,6 +73,11 @@ namespace PKHeX checkEncrypted(ref data); switch (getPKMDataFormat(data)) { + case 1: + var PL = new PokemonList1(data, PokemonList1.CapacityType.Single, data.Length == PKX.SIZE_1JLIST); + if (ident != null) + PL[0].Identifier = ident; + return PL[0]; case 3: return new PK3(data, ident); case 4: @@ -101,6 +109,17 @@ namespace PKHeX + "Desired Format: " + Format; return null; } + if ((pk.Format == 1 || pk.Format == 2) && 2 < Format && Format < 7) + { + comment = $"Cannot convert a PK{pk.Format} to a PK{Format}."; + return null; + } + if (pk.Format == 1 && Format == 7) + { + comment = "PK1 to PK7 conversion is not yet supported." + Environment.NewLine + + "Please wait for Sun/Moon to release and documentation to occur."; + return null; + } string currentFormat = pk.Format.ToString(); PKM pkm = pk.Clone(); if (pkm.IsEgg) // force hatch @@ -130,6 +149,7 @@ namespace PKHeX ushort chk = 0; switch (format) { + case 1: case 3: // TOneverDO, nobody exports encrypted pk3s return; case 4: diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index ee24587f5..c2c5d6066 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -38,7 +38,7 @@ namespace PKHeX /// A boolean indicating whether or not the length is valid for a Pokemon file. public static bool getIsPKM(long len) { - return new[] {SIZE_3STORED, SIZE_3PARTY, SIZE_4STORED, SIZE_4PARTY, SIZE_5PARTY, SIZE_6STORED, SIZE_6PARTY}.Contains((int)len); + return new[] {SIZE_1JLIST, SIZE_1ULIST, SIZE_3STORED, SIZE_3PARTY, SIZE_4STORED, SIZE_4PARTY, SIZE_5PARTY, SIZE_6STORED, SIZE_6PARTY}.Contains((int)len); } // C# PKX Function Library @@ -1852,6 +1852,7 @@ namespace PKHeX {"ぷ", 0x46}, {"ぺ", 0x47}, {"ぽ", 0x48}, + {"\0", 0x50}, {"トレーナー", 0x5D}, {"ア", 0x80}, {"イ", 0x81}, diff --git a/PKHeX/Saves/SAV1.cs b/PKHeX/Saves/SAV1.cs index bc98a5600..386bffb98 100644 --- a/PKHeX/Saves/SAV1.cs +++ b/PKHeX/Saves/SAV1.cs @@ -105,7 +105,7 @@ namespace PKHeX // Configuration - public override SaveFile Clone() { return new SAV1(Data); } + public override SaveFile Clone() { return new SAV1(Data.Take(Data.Length - SIZE_RESERVED).ToArray()); } public override int SIZE_STORED => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST; public override int SIZE_PARTY => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST; diff --git a/PKHeX/Saves/SaveFile.cs b/PKHeX/Saves/SaveFile.cs index fdc5c86d5..f171242a3 100644 --- a/PKHeX/Saves/SaveFile.cs +++ b/PKHeX/Saves/SaveFile.cs @@ -21,6 +21,8 @@ namespace PKHeX public byte[] Footer { protected get; set; } = new byte[0]; // .dsv public bool Japanese { protected get; set; } + public bool GetJapanese => Japanese; + // General PKM Properties protected abstract Type PKMType { get; } public abstract PKM getPKM(byte[] data); From b94f3c8918eb808b497d58e3ee5956610e33f265 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 29 Aug 2016 13:27:17 -0700 Subject: [PATCH 33/43] Implement SAV1 exporting. --- PKHeX/MainWindow/Main.Designer.cs | 1 + PKHeX/MainWindow/Main.cs | 30 ++++++++++++++- PKHeX/MainWindow/MainPK1.cs | 3 ++ PKHeX/PKM/PK1.cs | 26 ++++++++++++- PKHeX/PKM/PKX.cs | 19 +++++++--- PKHeX/Saves/SAV1.cs | 62 +++++++++++++++++++++++++++---- PKHeX/Saves/SaveFile.cs | 2 +- 7 files changed, 126 insertions(+), 17 deletions(-) diff --git a/PKHeX/MainWindow/Main.Designer.cs b/PKHeX/MainWindow/Main.Designer.cs index dbc698903..14db5ba68 100644 --- a/PKHeX/MainWindow/Main.Designer.cs +++ b/PKHeX/MainWindow/Main.Designer.cs @@ -926,6 +926,7 @@ this.TB_Nickname.Name = "TB_Nickname"; this.TB_Nickname.Size = new System.Drawing.Size(122, 20); this.TB_Nickname.TabIndex = 5; + this.TB_Nickname.TextChanged += new System.EventHandler(this.updateIsNicknamed); this.TB_Nickname.MouseDown += new System.Windows.Forms.MouseEventHandler(this.updateNicknameClick); // // CB_Species diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 3af0b7051..33c389038 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -862,12 +862,13 @@ namespace PKHeX CHK_Infected.Visible = CHK_Cured.Visible = SAV.Generation >= 3; + // Second daycare slot + SlotPictureBoxes[43].Visible = SAV.Generation > 1; + CHK_IsEgg.Visible = Label_Gender.Visible = SAV.Generation > 1; Label_OTGender.Visible = SAV.Generation > 1; - CHK_Nicknamed.Enabled = SAV.Generation > 2; - if (1 <= sav.Generation && sav.Generation <= 2) { Label_SPD.Visible = TB_SPDEV.Visible = TB_SPDIV.Visible = Stat_SPD.Visible = false; @@ -2141,6 +2142,8 @@ namespace PKHeX if (SAV.Generation < 5) // All caps GenIV and previous nick = nick.ToUpper(); TB_Nickname.Text = nick; + if (SAV.Generation == 1) + ((PK1)pkm).setNotNicknamed(); } } private void updateNicknameClick(object sender, MouseEventArgs e) @@ -2943,6 +2946,28 @@ namespace PKHeX SAV.Edited = true; } } + + private void updateIsNicknamed(object sender, EventArgs e) + { + if (!CHK_Nicknamed.Checked) + { + int species = Util.getIndex(CB_Species); + if (species < 1 || species > SAV.MaxSpeciesID) + return; + int lang = Util.getIndex(CB_Language); + if (CHK_IsEgg.Checked) species = 0; // Set species to 0 to get the egg name. + string nick = PKX.getSpeciesName(CHK_IsEgg.Checked ? 0 : species, lang); + + if (SAV.Generation < 5) // All caps GenIV and previous + nick = nick.ToUpper(); + if (TB_Nickname.Text != nick) + { + CHK_Nicknamed.Checked = true; + pkm.Nickname = TB_Nickname.Text; + } + } + } + // Generic Subfunctions // private void setParty() { @@ -3155,6 +3180,7 @@ namespace PKHeX } private void getBox(object sender, EventArgs e) { + SAV.CurrentBox = CB_BoxSelect.SelectedIndex; setPKXBoxes(); } private void switchDaycare(object sender, EventArgs e) diff --git a/PKHeX/MainWindow/MainPK1.cs b/PKHeX/MainWindow/MainPK1.cs index 401bff69f..06d755fe1 100644 --- a/PKHeX/MainWindow/MainPK1.cs +++ b/PKHeX/MainWindow/MainPK1.cs @@ -22,6 +22,7 @@ namespace PKHeX // Load rest TB_TID.Text = pk1.TID.ToString("00000"); + CHK_Nicknamed.Checked = pk1.IsNicknamed; TB_Nickname.Text = pk1.Nickname; TB_OT.Text = pk1.OT_Name; GB_OT.BackgroundImage = null; @@ -55,6 +56,8 @@ namespace PKHeX TB_PP3.Text = pk1.Move3_PP.ToString(); TB_PP4.Text = pk1.Move4_PP.ToString(); + CB_Language.SelectedIndex = pk1.Japanese ? 0 : 1; + updateStats(); TB_EXP.Text = pk1.EXP.ToString(); diff --git a/PKHeX/PKM/PK1.cs b/PKHeX/PKM/PK1.cs index cebcf5208..de49fd3f9 100644 --- a/PKHeX/PKM/PK1.cs +++ b/PKHeX/PKM/PK1.cs @@ -101,7 +101,25 @@ namespace PKHeX public override byte[] DecryptedBoxData => Encrypt().ToArray(); public override byte[] DecryptedPartyData => Encrypt().ToArray(); - public override bool IsNicknamed { get { throw new NotImplementedException(); } set { } } + public override bool IsNicknamed + { + get + { + string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper(); + return + !nick.SequenceEqual( + PKX.setG1Str(spName, Japanese) + .Concat(Enumerable.Repeat((byte) 0x50, StringLength - spName.Length - 1))); + } + set { } + } + + public void setNotNicknamed() + { + string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper(); + nick = PKX.setG1Str(spName, Japanese).Concat(Enumerable.Repeat((byte)0x50, StringLength - spName.Length - 1)).ToArray(); + } + #region Stored Attributes public override int Species @@ -343,12 +361,16 @@ namespace PKHeX set { if (value == null) return; - Pokemon[i] = (PK1)value.Clone(); + Pokemon[i] = (PK1)(((PK1)value).Clone()); } } private void Update() { + if (Pokemon.Any(pk => (pk.Species == 0))) + Count = (byte) Array.FindIndex(Pokemon, pk => (pk.Species == 0)); + else + Count = Capacity; for (int i = 0; i < Count; i++) { Data[1 + i] = (byte)PKX.setG1Species(Pokemon[i].Species); diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index c2c5d6066..53facdc21 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -1841,6 +1841,7 @@ namespace PKHeX {"ば", 0x3A}, {"び", 0x3B}, {"ぶ", 0x3C}, + {"ベ", 0x3D}, {"べ", 0x3D}, {"ぼ", 0x3E}, {"パ", 0x40}, @@ -1851,13 +1852,16 @@ namespace PKHeX {"ぴ", 0x45}, {"ぷ", 0x46}, {"ぺ", 0x47}, + {"ペ", 0x47}, {"ぽ", 0x48}, {"\0", 0x50}, {"トレーナー", 0x5D}, {"ア", 0x80}, {"イ", 0x81}, {"ウ", 0x82}, + {"ェ", 0x83}, {"エ", 0x83}, + {"オ", 0x84}, {"ォ", 0x84}, {"カ", 0x85}, {"キ", 0x86}, @@ -1942,6 +1946,7 @@ namespace PKHeX {"ゆ", 0xD5}, {"よ", 0xD6}, {"ら", 0xD7}, + {"リ", 0xD8}, {"り", 0xD8}, {"る", 0xD9}, {"れ", 0xDA}, @@ -1955,6 +1960,8 @@ namespace PKHeX {"ょ", 0xE2}, {"ー", 0xE3}, {"ァ", 0xE9}, + {"♂", 0xEF}, + {"♀", 0xF5} }; static Dictionary RBY2U_J => new Dictionary { @@ -1995,7 +2002,7 @@ namespace PKHeX {0x3A, "ば"}, {0x3B, "び"}, {0x3C, "ぶ"}, - {0x3D, "べ"}, + {0x3D, "ベ"}, {0x3E, "ぼ"}, {0x40, "パ"}, {0x41, "ピ"}, @@ -2004,15 +2011,15 @@ namespace PKHeX {0x44, "ぱ"}, {0x45, "ぴ"}, {0x46, "ぷ"}, - {0x47, "ぺ"}, + {0x47, "ペ"}, {0x48, "ぽ"}, {0x50, "\0"}, {0x5D, "トレーナー"}, {0x80, "ア"}, {0x81, "イ"}, {0x82, "ウ"}, - {0x83, "エ"}, - {0x84, "ォ"}, + {0x83, "ェ"}, + {0x84, "オ"}, {0x85, "カ"}, {0x86, "キ"}, {0x87, "ク"}, @@ -2096,7 +2103,7 @@ namespace PKHeX {0xD5, "ゆ"}, {0xD6, "よ"}, {0xD7, "ら"}, - {0xD8, "り"}, + {0xD8, "リ"}, {0xD9, "る"}, {0xDA, "れ"}, {0xDB, "ろ"}, @@ -2109,6 +2116,8 @@ namespace PKHeX {0xE2, "ょ"}, {0xE3, "ー"}, {0xE9, "ァ"}, + {0xEF, "♂"}, + {0xF5, "♀"} }; #endregion diff --git a/PKHeX/Saves/SAV1.cs b/PKHeX/Saves/SAV1.cs index 386bffb98..76c13180d 100644 --- a/PKHeX/Saves/SAV1.cs +++ b/PKHeX/Saves/SAV1.cs @@ -31,7 +31,7 @@ namespace PKHeX Personal = PersonalTable.RBY; // Stash boxes after the save file's end. - byte[] TempBox = new byte[SIZE_BOX]; + byte[] TempBox = new byte[SIZE_STOREDBOX]; for (int i = 0; i < BoxCount; i++) { if (i < BoxCount / 2) @@ -87,8 +87,16 @@ namespace PKHeX } } - File.WriteAllBytes("temp.sav", Data); - + byte[] rawDC = new byte[0x38]; + Array.Copy(Data, Japanese ? 0x2CA7 : 0x2CF4, rawDC, 0, rawDC.Length); + byte[] TempDaycare = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Single, Japanese)]; + TempDaycare[0] = rawDC[0]; + Array.Copy(rawDC, 1, TempDaycare, 2 + 1 + PKX.SIZE_1PARTY + StringLength, StringLength); + Array.Copy(rawDC, 1 + StringLength, TempDaycare, 2 + 1 + PKX.SIZE_1PARTY, StringLength); + Array.Copy(rawDC, 1 + 2 * StringLength, TempDaycare, 2 + 1, PKX.SIZE_1STORED); + PokemonList1 daycareList = new PokemonList1(TempDaycare, PokemonList1.CapacityType.Single, Japanese); + daycareList.GetBytes().CopyTo(Data, getPartyOffset(7)); + Daycare = getPartyOffset(7); if (!Exportable) resetBoxes(); @@ -97,10 +105,47 @@ namespace PKHeX private const int SIZE_RESERVED = 0x8000; // unpacked box data public override byte[] Write(bool DSV) { - // TODO: Implement Box Data Relocation + for (int i = 0; i < BoxCount; i++) + { + PokemonList1 boxPL = new PokemonList1(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese); + int slot = 0; + for (int j = 0; j < boxPL.Pokemon.Length; j++) + { + PK1 boxPK = (PK1) getPKM(getData(getBoxOffset(i) + j*SIZE_STORED, SIZE_STORED)); + if (boxPK.Species > 0) + boxPL[slot++] = boxPK; + } + if (i < BoxCount / 2) + boxPL.GetBytes().CopyTo(Data, 0x4000 + i * SIZE_STOREDBOX); + else + boxPL.GetBytes().CopyTo(Data, 0x6000 + (i - BoxCount / 2) * SIZE_STOREDBOX); + if (i == CurrentBox) + boxPL.GetBytes().CopyTo(Data, Japanese ? 0x302D : 0x30C0); + } + + PokemonList1 partyPL = new PokemonList1(PokemonList1.CapacityType.Party, Japanese); + int pSlot = 0; + for (int i = 0; i < 6; i++) + { + PK1 partyPK = (PK1)getPKM(getData(getPartyOffset(i), SIZE_STORED)); + if (partyPK.Species > 0) + partyPL[pSlot++] = partyPK; + } + partyPL.GetBytes().CopyTo(Data, Japanese ? 0x2ED5 : 0x2F2C); + + // Daycare is read-only, but in case it ever becomes editable, copy it back in. + byte[] rawDC = getData(getDaycareSlotOffset(0, 0), SIZE_STORED); + byte[] dc = new byte[1 + 2*StringLength + PKX.SIZE_1STORED]; + dc[0] = rawDC[0]; + Array.Copy(rawDC, 2 + 1 + PKX.SIZE_1PARTY + StringLength, dc, 1, StringLength); + Array.Copy(rawDC, 2 + 1 + PKX.SIZE_1PARTY, dc, 1 + StringLength, StringLength); + Array.Copy(rawDC, 2 + 1, dc, 1 + 2*StringLength, PKX.SIZE_1STORED); + dc.CopyTo(Data, Japanese ? 0x2CA7 : 0x2CF4); + setChecksums(); - Array.Resize(ref Data, Data.Length - SIZE_RESERVED); - return Data; + byte[] outData = new byte[Data.Length - SIZE_RESERVED]; + Array.Copy(Data, outData, outData.Length); + return outData; } @@ -110,7 +155,10 @@ namespace PKHeX public override int SIZE_STORED => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST; public override int SIZE_PARTY => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST; - public int SIZE_BOX => PokemonList1.GetDataLength(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese); + public int SIZE_BOX => BoxSlotCount*SIZE_STORED; + + public int SIZE_STOREDBOX => PokemonList1.GetDataLength(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese); + public override PKM BlankPKM => new PK1(null, null, Japanese); protected override Type PKMType => typeof(PK1); diff --git a/PKHeX/Saves/SaveFile.cs b/PKHeX/Saves/SaveFile.cs index f171242a3..5ff237205 100644 --- a/PKHeX/Saves/SaveFile.cs +++ b/PKHeX/Saves/SaveFile.cs @@ -361,7 +361,7 @@ namespace PKHeX Console.WriteLine(""); Edited = true; } - public void setStoredSlot(PKM pkm, int offset, bool? trade = null, bool? dex = null) + public virtual void setStoredSlot(PKM pkm, int offset, bool? trade = null, bool? dex = null) { if (pkm == null) return; if (pkm.GetType() != PKMType) From b91324fb2eecdf4c9baf66999b05fbd2fb749abb Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 29 Aug 2016 17:48:05 -0700 Subject: [PATCH 34/43] Trainer Info/Pokedex editing for Gen I --- PKHeX/MainWindow/Main.cs | 2 + PKHeX/PKHeX.csproj | 10 + PKHeX/Saves/SAV1.cs | 121 +++++++++- PKHeX/Saves/SaveFile.cs | 11 +- .../SAV_SimplePokedex.Designer.cs | 179 +++++++++++++++ .../Save Editors/SAV_SimplePokedex.cs | 93 ++++++++ .../Save Editors/SAV_SimplePokedex.resx | 216 ++++++++++++++++++ .../SAV_SimpleTrainer.Designer.cs | 145 +++++++++++- .../Save Editors/SAV_SimpleTrainer.cs | 41 +++- .../Save Editors/SAV_SimpleTrainer.resx | 96 ++++++++ 10 files changed, 902 insertions(+), 12 deletions(-) create mode 100644 PKHeX/Subforms/Save Editors/SAV_SimplePokedex.Designer.cs create mode 100644 PKHeX/Subforms/Save Editors/SAV_SimplePokedex.cs create mode 100644 PKHeX/Subforms/Save Editors/SAV_SimplePokedex.resx diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 33c389038..a2739c7b0 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -3366,6 +3366,8 @@ namespace PKHeX new SAV_PokedexORAS().ShowDialog(); else if (SAV.XY) new SAV_PokedexXY().ShowDialog(); + else if (SAV.RBY) + new SAV_SimplePokedex().ShowDialog(); } private void B_OUTPasserby_Click(object sender, EventArgs e) { diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index 21ee6cfea..00903517d 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -201,6 +201,12 @@ SAV_BoxViewer.cs + + Form + + + SAV_SimplePokedex.cs + Form @@ -354,6 +360,9 @@ SAV_BoxViewer.cs + + SAV_SimplePokedex.cs + SAV_Database.cs @@ -412,6 +421,7 @@ Designer + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/PKHeX/Saves/SAV1.cs b/PKHeX/Saves/SAV1.cs index 76c13180d..e94815e49 100644 --- a/PKHeX/Saves/SAV1.cs +++ b/PKHeX/Saves/SAV1.cs @@ -98,6 +98,9 @@ namespace PKHeX daycareList.GetBytes().CopyTo(Data, getPartyOffset(7)); Daycare = getPartyOffset(7); + // Enable Pokedex editing + PokeDex = 0; + if (!Exportable) resetBoxes(); } @@ -134,7 +137,7 @@ namespace PKHeX partyPL.GetBytes().CopyTo(Data, Japanese ? 0x2ED5 : 0x2F2C); // Daycare is read-only, but in case it ever becomes editable, copy it back in. - byte[] rawDC = getData(getDaycareSlotOffset(0, 0), SIZE_STORED); + byte[] rawDC = getData(getDaycareSlotOffset(), SIZE_STORED); byte[] dc = new byte[1 + 2*StringLength + PKX.SIZE_1STORED]; dc[0] = rawDC[0]; Array.Copy(rawDC, 2 + 1 + PKX.SIZE_1PARTY + StringLength, dc, 1, StringLength); @@ -268,6 +271,58 @@ namespace PKHeX set { Data[Japanese ? 0x2CA3 : 0x2CF0] = (byte)value; } } + public int Badges + { + get { return Data[Japanese ? 0x25F8 : 0x2602]; } + set { if (value < 0) return; Data[Japanese ? 0x25F8 : 0x2602] = (byte)value; } + } + + private byte Options + { + get { return Data[Japanese ? 0x25F7 : 0x2601]; } + set { Data[Japanese ? 0x25F7 : 0x2601] = value; } + } + + public bool BattleEffects + { + get { return (Options & 0x80) == 0; } + set { Options = (byte)((Options & 0x7F) | (value ? 0 : 0x80)); } + } + + public bool BattleStyleSwitch + { + get { return (Options & 0x40) == 0; } + set { Options = (byte)((Options & 0xBF) | (value ? 0 : 0x40)); } + } + + public int Sound + { + get { return (Options & 0x30) >> 4; } + set + { + var new_sound = value; + if (new_sound > 3) + new_sound = 3; + if (new_sound < 0) + new_sound = 0; + Options = (byte)((Options & 0xCF) | (new_sound << 4)); + } + } + + public int TextSpeed + { + get { return Options & 0x7; } + set + { + var new_speed = value; + if (new_speed > 7) + new_speed = 7; + if (new_speed < 0) + new_speed = 0; + Options = (byte)((Options & 0xF8) | new_speed); + } + } + public override uint Money { get { return uint.Parse((Util.SwapEndianness(BitConverter.ToUInt32(Data, Japanese ? 0x25EE : 0x25F3)) >> 8).ToString("X6")); } @@ -396,7 +451,39 @@ namespace PKHeX return data; } - protected override void setDex(PKM pkm) + public override bool getSeen(PKM pkm) + { + if (pkm.Species == 0) + return false; + if (pkm.Species > MaxSpeciesID) + return false; + if (Version == GameVersion.Unknown) + return false; + + int bit = pkm.Species - 1; + int ofs = bit >> 3; + byte bitval = (byte)(1 << (bit & 7)); + // Get the Seen Flag + return (Data[(Japanese ? 0x25B1 : 0x25B6) + ofs] & bitval) != 0; + } + + public override bool getCaught(PKM pkm) + { + if (pkm.Species == 0) + return false; + if (pkm.Species > MaxSpeciesID) + return false; + if (Version == GameVersion.Unknown) + return false; + + int bit = pkm.Species - 1; + int ofs = bit >> 3; + byte bitval = (byte)(1 << (bit & 7)); + // Get the Caught Flag + return (Data[(Japanese ? 0x259E : 0x25A3) + ofs] & bitval) != 0; + } + + protected internal override void setSeen(PKM pkm, bool seen) { if (pkm.Species == 0) return; @@ -404,16 +491,32 @@ namespace PKHeX return; if (Version == GameVersion.Unknown) return; - + int bit = pkm.Species - 1; int ofs = bit >> 3; - byte bitval = (byte)(1 << (bit % 7)); - - // Set the Captured Flag - Data[(Japanese ? 0x259E : 0x25A3) + ofs] |= bitval; - + byte bitval = (byte)(1 << (bit & 7)); // Set the Seen Flag - Data[(Japanese ? 0x25B1 : 0x25B6) + ofs] |= bitval; + Data[(Japanese ? 0x25B1 : 0x25B6) + ofs] &= (byte)(~bitval); + if (seen) + Data[(Japanese ? 0x25B1 : 0x25B6) + ofs] |= bitval; + } + + protected internal override void setCaught(PKM pkm, bool caught) + { + if (pkm.Species == 0) + return; + if (pkm.Species > MaxSpeciesID) + return; + if (Version == GameVersion.Unknown) + return; + + int bit = pkm.Species - 1; + int ofs = bit >> 3; + byte bitval = (byte)(1 << (bit & 7)); + // Set the Captured Flag + Data[(Japanese ? 0x259E : 0x25A3) + ofs] &= (byte)(~bitval); + if (caught) + Data[(Japanese ? 0x259E : 0x25A3) + ofs] |= bitval; } } } diff --git a/PKHeX/Saves/SaveFile.cs b/PKHeX/Saves/SaveFile.cs index 5ff237205..1d672eb03 100644 --- a/PKHeX/Saves/SaveFile.cs +++ b/PKHeX/Saves/SaveFile.cs @@ -487,7 +487,16 @@ namespace PKHeX } protected virtual void setPKM(PKM pkm) { } - protected virtual void setDex(PKM pkm) { } + protected virtual void setDex(PKM pkm) + { + setSeen(pkm); + setCaught(pkm); + } + + public virtual bool getSeen(PKM pkm) { throw new NotImplementedException(); } + public virtual bool getCaught(PKM pkm) { throw new NotImplementedException(); } + protected internal virtual void setSeen(PKM pkm, bool seen = true) { } + protected internal virtual void setCaught(PKM pkm, bool caught = true) { } public byte[] getData(int Offset, int Length) { diff --git a/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.Designer.cs b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.Designer.cs new file mode 100644 index 000000000..cf25e0653 --- /dev/null +++ b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.Designer.cs @@ -0,0 +1,179 @@ +namespace PKHeX +{ + partial class SAV_SimplePokedex + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_SimplePokedex)); + this.B_Save = new System.Windows.Forms.Button(); + this.B_Cancel = new System.Windows.Forms.Button(); + this.B_CaughtNone = new System.Windows.Forms.Button(); + this.B_CaughtAll = new System.Windows.Forms.Button(); + this.B_SeenNone = new System.Windows.Forms.Button(); + this.B_SeenAll = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.CLB_Caught = new System.Windows.Forms.CheckedListBox(); + this.Label_Seen = new System.Windows.Forms.Label(); + this.CLB_Seen = new System.Windows.Forms.CheckedListBox(); + this.SuspendLayout(); + // + // B_Save + // + this.B_Save.Location = new System.Drawing.Point(146, 301); + this.B_Save.Name = "B_Save"; + this.B_Save.Size = new System.Drawing.Size(85, 23); + this.B_Save.TabIndex = 19; + this.B_Save.Text = "Save"; + this.B_Save.UseVisualStyleBackColor = true; + this.B_Save.Click += new System.EventHandler(this.B_Save_Click); + // + // B_Cancel + // + this.B_Cancel.Location = new System.Drawing.Point(53, 301); + this.B_Cancel.Name = "B_Cancel"; + this.B_Cancel.Size = new System.Drawing.Size(85, 23); + this.B_Cancel.TabIndex = 18; + this.B_Cancel.Text = "Cancel"; + this.B_Cancel.UseVisualStyleBackColor = true; + this.B_Cancel.Click += new System.EventHandler(this.B_Cancel_Click); + // + // B_CaughtNone + // + this.B_CaughtNone.Location = new System.Drawing.Point(151, 267); + this.B_CaughtNone.Name = "B_CaughtNone"; + this.B_CaughtNone.Size = new System.Drawing.Size(120, 23); + this.B_CaughtNone.TabIndex = 17; + this.B_CaughtNone.Text = "Caught None"; + this.B_CaughtNone.UseVisualStyleBackColor = true; + this.B_CaughtNone.Click += new System.EventHandler(this.B_CaughtNone_Click); + // + // B_CaughtAll + // + this.B_CaughtAll.Location = new System.Drawing.Point(151, 238); + this.B_CaughtAll.Name = "B_CaughtAll"; + this.B_CaughtAll.Size = new System.Drawing.Size(120, 23); + this.B_CaughtAll.TabIndex = 16; + this.B_CaughtAll.Text = "Caught All"; + this.B_CaughtAll.UseVisualStyleBackColor = true; + this.B_CaughtAll.Click += new System.EventHandler(this.B_CaughtAll_Click); + // + // B_SeenNone + // + this.B_SeenNone.Location = new System.Drawing.Point(14, 267); + this.B_SeenNone.Name = "B_SeenNone"; + this.B_SeenNone.Size = new System.Drawing.Size(120, 23); + this.B_SeenNone.TabIndex = 15; + this.B_SeenNone.Text = "Seen None"; + this.B_SeenNone.UseVisualStyleBackColor = true; + this.B_SeenNone.Click += new System.EventHandler(this.B_SeenNone_Click); + // + // B_SeenAll + // + this.B_SeenAll.Location = new System.Drawing.Point(14, 238); + this.B_SeenAll.Name = "B_SeenAll"; + this.B_SeenAll.Size = new System.Drawing.Size(120, 23); + this.B_SeenAll.TabIndex = 14; + this.B_SeenAll.Text = "Seen All"; + this.B_SeenAll.UseVisualStyleBackColor = true; + this.B_SeenAll.Click += new System.EventHandler(this.B_SeenAll_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(151, 13); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(44, 13); + this.label2.TabIndex = 13; + this.label2.Text = "Caught:"; + // + // CLB_Caught + // + this.CLB_Caught.FormattingEnabled = true; + this.CLB_Caught.Location = new System.Drawing.Point(151, 33); + this.CLB_Caught.Name = "CLB_Caught"; + this.CLB_Caught.Size = new System.Drawing.Size(120, 199); + this.CLB_Caught.TabIndex = 12; + this.CLB_Caught.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.CLB_Caught_ItemCheck); + // + // Label_Seen + // + this.Label_Seen.AutoSize = true; + this.Label_Seen.Location = new System.Drawing.Point(14, 13); + this.Label_Seen.Name = "Label_Seen"; + this.Label_Seen.Size = new System.Drawing.Size(35, 13); + this.Label_Seen.TabIndex = 11; + this.Label_Seen.Text = "Seen:"; + // + // CLB_Seen + // + this.CLB_Seen.FormattingEnabled = true; + this.CLB_Seen.Location = new System.Drawing.Point(14, 33); + this.CLB_Seen.Name = "CLB_Seen"; + this.CLB_Seen.Size = new System.Drawing.Size(120, 199); + this.CLB_Seen.TabIndex = 10; + this.CLB_Seen.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.CLB_Seen_ItemCheck); + // + // SAV_SimplePokedex + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 336); + this.Controls.Add(this.B_Save); + this.Controls.Add(this.B_Cancel); + this.Controls.Add(this.B_CaughtNone); + this.Controls.Add(this.B_CaughtAll); + this.Controls.Add(this.B_SeenNone); + this.Controls.Add(this.B_SeenAll); + this.Controls.Add(this.label2); + this.Controls.Add(this.CLB_Caught); + this.Controls.Add(this.Label_Seen); + this.Controls.Add(this.CLB_Seen); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximumSize = new System.Drawing.Size(300, 375); + this.MinimumSize = new System.Drawing.Size(300, 375); + this.Name = "SAV_SimplePokedex"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Pokedex Editor"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button B_Save; + private System.Windows.Forms.Button B_Cancel; + private System.Windows.Forms.Button B_CaughtNone; + private System.Windows.Forms.Button B_CaughtAll; + private System.Windows.Forms.Button B_SeenNone; + private System.Windows.Forms.Button B_SeenAll; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.CheckedListBox CLB_Caught; + private System.Windows.Forms.Label Label_Seen; + private System.Windows.Forms.CheckedListBox CLB_Seen; + } +} \ No newline at end of file diff --git a/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.cs b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.cs new file mode 100644 index 000000000..7821be892 --- /dev/null +++ b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.cs @@ -0,0 +1,93 @@ +using System; +using System.Linq; +using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; + +namespace PKHeX +{ + public partial class SAV_SimplePokedex : Form + { + public SAV_SimplePokedex() + { + InitializeComponent(); + Util.TranslateInterface(this, Main.curlanguage); + seen = new bool[SAV.MaxSpeciesID]; + caught = new bool[SAV.MaxSpeciesID]; + + string[] spec = Util.getSpeciesList(Main.curlanguage); + for (int i = 0; i < seen.Length; i++) + { + PKM tempPkm = new PK6(); + tempPkm.Species = i + 1; + seen[i] = SAV.getSeen(tempPkm); + caught[i] = SAV.getCaught(tempPkm); + CLB_Seen.Items.Add(spec[i + 1]); + CLB_Caught.Items.Add(spec[i + 1]); + CLB_Seen.SetItemChecked(i, seen[i]); + CLB_Caught.SetItemChecked(i, caught[i]); + } + initialized = true; + } + private readonly CheckBox[] cba; + private readonly SaveFile SAV = Main.SAV.Clone(); + + private bool[] seen; + private bool[] caught; + private bool initialized; + + private void B_Save_Click(object sender, EventArgs e) + { + for (int i = 0; i < seen.Length; i++) + { + PKM tempPkm = new PK6(); + tempPkm.Species = i + 1; + SAV.setSeen(tempPkm, seen[i]); + SAV.setCaught(tempPkm, caught[i]); + } + SAV.Data.CopyTo(Main.SAV.Data, 0); + Main.SAV.Edited = true; + Close(); + } + + private void B_Cancel_Click(object sender, EventArgs e) + { + Close(); + } + + private void B_SeenAll_Click(object sender, EventArgs e) + { + for (int i = 0; i < SAV.MaxSpeciesID; i++) + CLB_Seen.SetItemChecked(i, true); + } + + private void B_SeenNone_Click(object sender, EventArgs e) + { + for (int i = 0; i < SAV.MaxSpeciesID; i++) + CLB_Seen.SetItemChecked(i, false); + } + + private void B_CaughtAll_Click(object sender, EventArgs e) + { + for (int i = 0; i < SAV.MaxSpeciesID; i++) + CLB_Caught.SetItemChecked(i, true); + } + + private void B_CaughtNone_Click(object sender, EventArgs e) + { + for (int i = 0; i < SAV.MaxSpeciesID; i++) + CLB_Caught.SetItemChecked(i, false); + } + + private void CLB_Seen_ItemCheck(object sender, ItemCheckEventArgs e) + { + if (!initialized) return; + seen[e.Index] = e.NewValue == CheckState.Checked; + } + + private void CLB_Caught_ItemCheck(object sender, ItemCheckEventArgs e) + { + if (!initialized) return; + caught[e.Index] = e.NewValue == CheckState.Checked; + } + } +} diff --git a/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.resx b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.resx new file mode 100644 index 000000000..603f660be --- /dev/null +++ b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.resx @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAE + AAAAAAAAAAAAAAAAAAAAAAAAIyMjAQAAAAALCwsPJiYmJysrKycqKionKSkpJykpKScpKSknKioqJyoq + KicrKysnJycnJw0ODQ8AAAAAJiYmAQAAAABpaWlHq6ur17+/v+6+vr7svr6+7b6+vu2+vr7tvr6+7b6+ + vu2+vr7tvr6+7L+/v+6rq6vXampqSAAAAAAoKSgXvr++3eLi4v/g4OD94eHh/+Hh4f/i4uL/4uLi/+Li + 4v/i4uL/4eHh/+Dh4P/g4OD94uLi/7+/v90sLCwXfn5+PNna2frg4OD/39/f/uHh4f7h4eH+39/f/uDg + 4P7g4OD+39/f/uHh4f7h4OH+39/f/t/g3//a2tr6g4ODPoOCgz7X19f64+Pj/+Li4v7k5OT/4+Tj//Ly + 8v/19fX/9PT0//T09P/k5OT/5OTk/+Pj4/7j4+P/19jX+4qLikCDhIM+2tra++Xl5f/k5eT+5OTk//Lz + 8v+urq7/RUVF/z4+Pv+Zmpn/8fHx/+Xm5f/k5eT+5eXl/9ra2vyLi4tAhYWFPuXm5vvx8vP/7+/w/v// + //+sra3/AgIC/15eXv9tbG3/BQUF/4yMjP//////7+/w/vHy8//l5ub8jY2NQC4uLD5LS0f7UFBL/09P + Sv5YWVP/FBUS/29wcP///////////5SUlP8PDw//U1NO/1BQS/5PT0r/S0tH/DIyMEAAAAs+AAAM+wAA + Dv8AAA/+AwMS/wAAAP+UlJX///////////+3t7n/AAAA/wAAD/8BAQ/+AAAO/wAADPwCAg5ABARSPgoK + k/sNDab/DQ2o/hAQv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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////8AAAD+AAAAfAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAAD4AAAB/gAAB////// + + + \ No newline at end of file diff --git a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.Designer.cs b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.Designer.cs index 111a04802..9cdf8aca3 100644 --- a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.Designer.cs +++ b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_SimpleTrainer)); this.GB_Adventure = new System.Windows.Forms.GroupBox(); this.L_Started = new System.Windows.Forms.Label(); this.CAL_AdventureStartDate = new System.Windows.Forms.DateTimePicker(); @@ -63,6 +64,9 @@ this.B_Save = new System.Windows.Forms.Button(); this.B_Cancel = new System.Windows.Forms.Button(); this.GB_Trainer = new System.Windows.Forms.GroupBox(); + this.B_MaxCoins = new System.Windows.Forms.Button(); + this.L_Coins = new System.Windows.Forms.Label(); + this.MT_Coins = new System.Windows.Forms.MaskedTextBox(); this.GB_Badges = new System.Windows.Forms.GroupBox(); this.CHK_H8 = new System.Windows.Forms.CheckBox(); this.CHK_H7 = new System.Windows.Forms.CheckBox(); @@ -80,6 +84,14 @@ this.CHK_3 = new System.Windows.Forms.CheckBox(); this.CHK_2 = new System.Windows.Forms.CheckBox(); this.CHK_1 = new System.Windows.Forms.CheckBox(); + this.GB_Options = new System.Windows.Forms.GroupBox(); + this.label1 = new System.Windows.Forms.Label(); + this.CB_SoundType = new System.Windows.Forms.ComboBox(); + this.LBL_TextSpeed = new System.Windows.Forms.Label(); + this.CB_TextSpeed = new System.Windows.Forms.ComboBox(); + this.LBL_BattleStyle = new System.Windows.Forms.Label(); + this.CB_BattleStyle = new System.Windows.Forms.ComboBox(); + this.CHK_BattleEffects = new System.Windows.Forms.CheckBox(); this.GB_Adventure.SuspendLayout(); this.GB_Map.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Z)).BeginInit(); @@ -88,6 +100,7 @@ ((System.ComponentModel.ISupportInitialize)(this.NUD_X)).BeginInit(); this.GB_Trainer.SuspendLayout(); this.GB_Badges.SuspendLayout(); + this.GB_Options.SuspendLayout(); this.SuspendLayout(); // // GB_Adventure @@ -248,7 +261,7 @@ this.CB_Gender.Items.AddRange(new object[] { "♂", "♀"}); - this.CB_Gender.Location = new System.Drawing.Point(99, 55); + this.CB_Gender.Location = new System.Drawing.Point(119, 55); this.CB_Gender.Name = "CB_Gender"; this.CB_Gender.Size = new System.Drawing.Size(40, 21); this.CB_Gender.TabIndex = 68; @@ -458,6 +471,9 @@ // // GB_Trainer // + this.GB_Trainer.Controls.Add(this.B_MaxCoins); + this.GB_Trainer.Controls.Add(this.L_Coins); + this.GB_Trainer.Controls.Add(this.MT_Coins); this.GB_Trainer.Controls.Add(this.TB_OTName); this.GB_Trainer.Controls.Add(this.B_MaxCash); this.GB_Trainer.Controls.Add(this.MT_SID); @@ -475,6 +491,37 @@ this.GB_Trainer.TabStop = false; this.GB_Trainer.Text = "Trainer"; // + // B_MaxCoins + // + this.B_MaxCoins.Location = new System.Drawing.Point(95, 56); + this.B_MaxCoins.Name = "B_MaxCoins"; + this.B_MaxCoins.Size = new System.Drawing.Size(20, 20); + this.B_MaxCoins.TabIndex = 71; + this.B_MaxCoins.Text = "+"; + this.B_MaxCoins.UseVisualStyleBackColor = true; + this.B_MaxCoins.Visible = false; + // + // L_Coins + // + this.L_Coins.AutoSize = true; + this.L_Coins.Location = new System.Drawing.Point(11, 59); + this.L_Coins.Name = "L_Coins"; + this.L_Coins.Size = new System.Drawing.Size(36, 13); + this.L_Coins.TabIndex = 70; + this.L_Coins.Text = "Coins:"; + this.L_Coins.Visible = false; + // + // MT_Coins + // + this.MT_Coins.Location = new System.Drawing.Point(53, 55); + this.MT_Coins.Mask = "00000"; + this.MT_Coins.Name = "MT_Coins"; + this.MT_Coins.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.MT_Coins.Size = new System.Drawing.Size(39, 20); + this.MT_Coins.TabIndex = 69; + this.MT_Coins.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.MT_Coins.Visible = false; + // // GB_Badges // this.GB_Badges.Controls.Add(this.CHK_H8); @@ -660,17 +707,100 @@ this.CHK_1.UseVisualStyleBackColor = true; this.CHK_1.Visible = false; // + // GB_Options + // + this.GB_Options.Controls.Add(this.label1); + this.GB_Options.Controls.Add(this.CB_SoundType); + this.GB_Options.Controls.Add(this.LBL_TextSpeed); + this.GB_Options.Controls.Add(this.CB_TextSpeed); + this.GB_Options.Controls.Add(this.LBL_BattleStyle); + this.GB_Options.Controls.Add(this.CB_BattleStyle); + this.GB_Options.Controls.Add(this.CHK_BattleEffects); + this.GB_Options.Location = new System.Drawing.Point(217, 99); + this.GB_Options.Name = "GB_Options"; + this.GB_Options.Size = new System.Drawing.Size(157, 125); + this.GB_Options.TabIndex = 72; + this.GB_Options.TabStop = false; + this.GB_Options.Text = "Options"; + this.GB_Options.Visible = false; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 71); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(68, 13); + this.label1.TabIndex = 25; + this.label1.Text = "Sound Type:"; + // + // CB_SoundType + // + this.CB_SoundType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_SoundType.FormattingEnabled = true; + this.CB_SoundType.Location = new System.Drawing.Point(71, 68); + this.CB_SoundType.Name = "CB_SoundType"; + this.CB_SoundType.Size = new System.Drawing.Size(80, 21); + this.CB_SoundType.TabIndex = 24; + // + // LBL_TextSpeed + // + this.LBL_TextSpeed.AutoSize = true; + this.LBL_TextSpeed.Location = new System.Drawing.Point(6, 98); + this.LBL_TextSpeed.Name = "LBL_TextSpeed"; + this.LBL_TextSpeed.Size = new System.Drawing.Size(65, 13); + this.LBL_TextSpeed.TabIndex = 23; + this.LBL_TextSpeed.Text = "Text Speed:"; + // + // CB_TextSpeed + // + this.CB_TextSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_TextSpeed.FormattingEnabled = true; + this.CB_TextSpeed.Location = new System.Drawing.Point(71, 95); + this.CB_TextSpeed.Name = "CB_TextSpeed"; + this.CB_TextSpeed.Size = new System.Drawing.Size(80, 21); + this.CB_TextSpeed.TabIndex = 22; + // + // LBL_BattleStyle + // + this.LBL_BattleStyle.AutoSize = true; + this.LBL_BattleStyle.Location = new System.Drawing.Point(8, 44); + this.LBL_BattleStyle.Name = "LBL_BattleStyle"; + this.LBL_BattleStyle.Size = new System.Drawing.Size(63, 13); + this.LBL_BattleStyle.TabIndex = 21; + this.LBL_BattleStyle.Text = "Battle Style:"; + // + // CB_BattleStyle + // + this.CB_BattleStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_BattleStyle.FormattingEnabled = true; + this.CB_BattleStyle.Location = new System.Drawing.Point(71, 41); + this.CB_BattleStyle.Name = "CB_BattleStyle"; + this.CB_BattleStyle.Size = new System.Drawing.Size(80, 21); + this.CB_BattleStyle.TabIndex = 20; + // + // CHK_BattleEffects + // + this.CHK_BattleEffects.AutoSize = true; + this.CHK_BattleEffects.Location = new System.Drawing.Point(26, 18); + this.CHK_BattleEffects.Name = "CHK_BattleEffects"; + this.CHK_BattleEffects.Size = new System.Drawing.Size(111, 17); + this.CHK_BattleEffects.TabIndex = 19; + this.CHK_BattleEffects.Text = "Use Battle Effects"; + this.CHK_BattleEffects.UseVisualStyleBackColor = true; + // // SAV_SimpleTrainer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(384, 261); + this.Controls.Add(this.GB_Options); this.Controls.Add(this.GB_Badges); this.Controls.Add(this.GB_Trainer); this.Controls.Add(this.B_Save); this.Controls.Add(this.B_Cancel); this.Controls.Add(this.GB_Map); this.Controls.Add(this.GB_Adventure); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MinimumSize = new System.Drawing.Size(400, 300); this.Name = "SAV_SimpleTrainer"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; @@ -686,6 +816,8 @@ this.GB_Trainer.PerformLayout(); this.GB_Badges.ResumeLayout(false); this.GB_Badges.PerformLayout(); + this.GB_Options.ResumeLayout(false); + this.GB_Options.PerformLayout(); this.ResumeLayout(false); } @@ -744,5 +876,16 @@ private System.Windows.Forms.CheckBox CHK_H3; private System.Windows.Forms.CheckBox CHK_H2; private System.Windows.Forms.CheckBox CHK_H1; + private System.Windows.Forms.Button B_MaxCoins; + private System.Windows.Forms.Label L_Coins; + private System.Windows.Forms.MaskedTextBox MT_Coins; + private System.Windows.Forms.GroupBox GB_Options; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox CB_SoundType; + private System.Windows.Forms.Label LBL_TextSpeed; + private System.Windows.Forms.ComboBox CB_TextSpeed; + private System.Windows.Forms.Label LBL_BattleStyle; + private System.Windows.Forms.ComboBox CB_BattleStyle; + private System.Windows.Forms.CheckBox CHK_BattleEffects; } } \ No newline at end of file diff --git a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.cs b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.cs index cd77cf21f..ea487cb4c 100644 --- a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.cs +++ b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.cs @@ -14,10 +14,15 @@ namespace PKHeX cba = new[] {CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_6, CHK_7, CHK_8}; TB_OTName.MaxLength = SAV.OTLength; B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999"; + B_MaxCoins.Click += (sender, e) => MT_Coins.Text = "9999"; CB_Gender.Items.Clear(); CB_Gender.Items.AddRange(Main.gendersymbols.Take(2).ToArray()); // m/f depending on unicode selection + L_SID.Visible = MT_SID.Visible = SAV.Generation > 2; + L_Coins.Visible = B_MaxCoins.Visible = MT_Coins.Visible = SAV.Generation < 3; + CB_Gender.Visible = SAV.Generation > 1; + TB_OTName.Text = SAV.OT; CB_Gender.SelectedIndex = SAV.Gender; MT_TID.Text = SAV.TID.ToString("00000"); @@ -27,6 +32,29 @@ namespace PKHeX MT_Minutes.Text = SAV.PlayedMinutes.ToString(); MT_Seconds.Text = SAV.PlayedSeconds.ToString(); + + int badgeval = 0; + if (SAV is SAV1) + { + SAV1 sav1 = (SAV1)SAV; + MT_Coins.Text = sav1.Coin.ToString(); + badgeval = sav1.Badges; + + L_Started.Visible = L_Fame.Visible = false; + CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false; + CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false; + GB_Map.Visible = false; + GB_Options.Visible = true; + CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" }); + CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo", "Earphone2", "Earphone3" }); + CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" }); + + CHK_BattleEffects.Checked = sav1.BattleEffects; + CB_BattleStyle.SelectedIndex = sav1.BattleStyleSwitch ? 0 : 1; + CB_SoundType.SelectedIndex = sav1.Sound; + CB_TextSpeed.SelectedIndex = sav1.TextSpeed; + } + if (SAV is SAV3) { GB_Map.Visible = false; @@ -38,7 +66,6 @@ namespace PKHeX return; } - int badgeval = 0; if (SAV is SAV4) { SAV4 s = (SAV4)SAV; @@ -104,6 +131,18 @@ namespace PKHeX for (int i = 0; i < cba.Length; i++) badgeval |= (cba[i].Checked ? 1 : 0) << i; + if (SAV is SAV1) + { + SAV1 sav1 = (SAV1) SAV; + sav1.Coin = (ushort) Util.ToUInt32(MT_Coins.Text); + sav1.Badges = badgeval & 0xFF; + + sav1.BattleEffects = CHK_BattleEffects.Checked; + sav1.BattleStyleSwitch = CB_BattleStyle.SelectedIndex == 0; + sav1.Sound = CB_SoundType.SelectedIndex; + sav1.TextSpeed = CB_TextSpeed.SelectedIndex; + } + if (SAV is SAV4) { SAV4 s = (SAV4)SAV; diff --git a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.resx b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.resx index 1af7de150..603f660be 100644 --- a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.resx +++ b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.resx @@ -117,4 +117,100 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAE + AAAAAAAAAAAAAAAAAAAAAAAAIyMjAQAAAAALCwsPJiYmJysrKycqKionKSkpJykpKScpKSknKioqJyoq + KicrKysnJycnJw0ODQ8AAAAAJiYmAQAAAABpaWlHq6ur17+/v+6+vr7svr6+7b6+vu2+vr7tvr6+7b6+ + vu2+vr7tvr6+7L+/v+6rq6vXampqSAAAAAAoKSgXvr++3eLi4v/g4OD94eHh/+Hh4f/i4uL/4uLi/+Li + 4v/i4uL/4eHh/+Dh4P/g4OD94uLi/7+/v90sLCwXfn5+PNna2frg4OD/39/f/uHh4f7h4eH+39/f/uDg + 4P7g4OD+39/f/uHh4f7h4OH+39/f/t/g3//a2tr6g4ODPoOCgz7X19f64+Pj/+Li4v7k5OT/4+Tj//Ly + 8v/19fX/9PT0//T09P/k5OT/5OTk/+Pj4/7j4+P/19jX+4qLikCDh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/xkZzv8YGM3/GBjN/xgYzf8YGM3/GBjN/xgYzP8YGMz/FxfK/yMj0v4zM5WfFBRkBwAA + AAAAAAAAAAAAAAAAAAAAAAAAHBx7Ay0tdkg3N5emMTGpxSwsp8gsLKfILCynyCwsp8gsLKfILCynyCws + p8gsLKfILCynyCwsp8gsLKfILCynyCwsp8gsLKfILCynyCwsp8gsLKfILCynyDExqcU2NpenLi54Shsb + ewMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////8AAAD+AAAAfAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAAD4AAAB/gAAB////// + + \ No newline at end of file From 4d666aa2aab03c1efe126f486d1d85592bb28443 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 29 Aug 2016 20:34:02 -0700 Subject: [PATCH 35/43] Inventory editing for Gen I --- PKHeX/PKM/PKX.cs | 19 +++++++++++++++++++ PKHeX/Saves/SAV1.cs | 4 ++-- PKHeX/Saves/SaveUtil.cs | 3 +++ PKHeX/Subforms/Save Editors/SAV_Inventory.cs | 16 +++++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index 53facdc21..675679597 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -2121,6 +2121,25 @@ namespace PKHeX }; #endregion + #region Gen 1 Item Table + public static string[] getG1ItemList() + { + return new[] { "(None)", "Master Ball", "Ultra Ball", "Great Ball", "Poké Ball", "Town Map", "Bicycle", "????? (7)", "Safari Ball", "Pokédex", "Moon Stone", "Antidote", "Burn Heal", "Ice Heal", "Awakening", "Parlyz Heal", "Full Restore", "Max Potion", "Hyper Potion", "Super Potion", "Potion", "BoulderBadge", "CascadeBadge", "ThunderBadge", "RainbowBadge", "SoulBadge", "MarshBadge", "VolcanoBadge", "EarthBadge", "Escape Rope", "Repel", "Old Amber", "Fire Stone", "Thunder Stone", "Water Stone", "HP Up", "Protein", "Iron", "Carbos", "Calcium", "Rare Candy", "Dome Fossil", "Helix Fossil", "Secret Key", "????? (44)", "Bike Voucher", "X Accuracy", "Leaf Stone", "Card Key", "Nugget", "PP Up (Unused)", "Poké Doll", "Full Heal", "Revive", "Max Revive", "Guard Spec.", "Super Repel", "Max Repel", "Dire Hit", "Coin", "Fresh Water", "Soda Pop", "Lemonade", "S.S. Ticket", "Gold Teeth", "X Attack", "X Defend", "X Speed", "X Special", "Coin Case", "Oak's Parcel", "Itemfinder", "Silph Scope", "Poké Flute", "Lift Key", "Exp. All", "Old Rod", "Good Rod", "Super Rod", "PP Up", "Ether", "Max Ether", "Elixer", "Max Elixer", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "HM01", "HM02", "HM03", "HM04", "HM05", "TM01", "TM02", "TM03", "TM04", "TM05", "TM06", "TM07", "TM08", "TM09", "TM10", "TM11", "TM12", "TM13", "TM14", "TM15", "TM16", "TM17", "TM18", "TM19", "TM20", "TM21", "TM22", "TM23", "TM24", "TM25", "TM26", "TM27", "TM28", "TM29", "TM30", "TM31", "TM32", "TM33", "TM34", "TM35", "TM36", "TM37", "TM38", "TM39", "TM40", "TM41", "TM42", "TM43", "TM44", "TM45", "TM46", "TM47", "TM48", "TM49", "TM50", "TM51", "TM52", "TM53", "TM54", "TM55" }; + } + + #endregion + public static int[] getG1LegalItems() + { + return Enumerable.Range(0, 7) // 0-6 + .Concat(Enumerable.Range(10, 11)) // 10-20 + .Concat(Enumerable.Range(29, 15)) // 29-43 + .Concat(Enumerable.Range(45, 5)) // 45-49 + .Concat(Enumerable.Range(51, 8)) // 51-58 + .Concat(Enumerable.Range(60, 24)) // 60-83 + .Concat(Enumerable.Range(196, 54)) // 196-249 + .ToArray(); + } + public static int getG1Species(int raw_id) { int[] table = { 0x00, 0x70, 0x73, 0x20, 0x23, 0x15, 0x64, 0x22, 0x50, 0x02, 0x67, 0x6C, 0x66, 0x58, 0x5E, 0x1D, 0x1F, 0x68, 0x6F, 0x83, 0x3B, 0x97, 0x82, 0x5A, 0x48, 0x5C, 0x7B, 0x78, 0x09, 0x7F, 0x72, 0x00, 0x00, 0x3A, 0x5F, 0x16, 0x10, 0x4F, 0x40, 0x4B, 0x71, 0x43, 0x7A, 0x6A, 0x6B, 0x18, 0x2F, 0x36, 0x60, 0x4C, 0x00, 0x7E, 0x00, 0x7D, 0x52, 0x6D, 0x00, 0x38, 0x56, 0x32, 0x80, 0x00, 0x00, 0x00, 0x53, 0x30, 0x95, 0x00, 0x00, 0x00, 0x54, 0x3C, 0x7C, 0x92, 0x90, 0x91, 0x84, 0x34, 0x62, 0x00, 0x00, 0x00, 0x25, 0x26, 0x19, 0x1A, 0x00, 0x00, 0x93, 0x94, 0x8C, 0x8D, 0x74, 0x75, 0x00, 0x00, 0x1B, 0x1C, 0x8A, 0x8B, 0x27, 0x28, 0x85, 0x88, 0x87, 0x86, 0x42, 0x29, 0x17, 0x2E, 0x3D, 0x3E, 0x0D, 0x0E, 0x0F, 0x00, 0x55, 0x39, 0x33, 0x31, 0x57, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x44, 0x00, 0x37, 0x61, 0x2A, 0x96, 0x8F, 0x81, 0x00, 0x00, 0x59, 0x00, 0x63, 0x5B, 0x00, 0x65, 0x24, 0x6E, 0x35, 0x69, 0x00, 0x5D, 0x3F, 0x41, 0x11, 0x12, 0x79, 0x01, 0x03, 0x49, 0x00, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4E, 0x13, 0x14, 0x21, 0x1E, 0x4A, 0x89, 0x8E, 0x00, 0x51, 0x00, 0x00, 0x04, 0x07, 0x05, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x2C, 0x2D, 0x45, 0x46, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/PKHeX/Saves/SAV1.cs b/PKHeX/Saves/SAV1.cs index e94815e49..546a0987e 100644 --- a/PKHeX/Saves/SAV1.cs +++ b/PKHeX/Saves/SAV1.cs @@ -343,7 +343,7 @@ namespace PKHeX } } - private readonly ushort[] LegalItems = Enumerable.Range(1, 255).Select(i => (ushort)i).ToArray(); + private readonly ushort[] LegalItems = PKX.getG1LegalItems().Select(i => (ushort)i).ToArray(); public override InventoryPouch[] Inventory { get @@ -352,7 +352,7 @@ namespace PKHeX InventoryPouch[] pouch = { new InventoryPouch(InventoryType.Items, legalItems, 99, (Japanese ? 0x25C4 : 0x25C9), 20), - new InventoryPouch(InventoryType.Items, legalItems, 99, (Japanese ? 0x27DC : 0x27E6), 50), + new InventoryPouch(InventoryType.MailItems, legalItems, 99, (Japanese ? 0x27DC : 0x27E6), 50) }; foreach (var p in pouch) { diff --git a/PKHeX/Saves/SaveUtil.cs b/PKHeX/Saves/SaveUtil.cs index f8d7db77e..9102c5627 100644 --- a/PKHeX/Saves/SaveUtil.cs +++ b/PKHeX/Saves/SaveUtil.cs @@ -215,6 +215,9 @@ namespace PKHeX case GameVersion.CXD: return GameVersion.CXD; + case GameVersion.RBY: + return GameVersion.RBY; + case GameVersion.R: case GameVersion.S: return GameVersion.RS; diff --git a/PKHeX/Subforms/Save Editors/SAV_Inventory.cs b/PKHeX/Subforms/Save Editors/SAV_Inventory.cs index b9094f50a..c997680e7 100644 --- a/PKHeX/Subforms/Save Editors/SAV_Inventory.cs +++ b/PKHeX/Subforms/Save Editors/SAV_Inventory.cs @@ -10,7 +10,19 @@ namespace PKHeX { InitializeComponent(); Util.TranslateInterface(this, Main.curlanguage); - itemlist = SAV.Generation == 3 ? Main.g3items : Main.itemlist; + switch (SAV.Generation) + { + case 1: + itemlist = PKX.getG1ItemList(); + B_GiveAll.Visible = false; // Can't give all, not enough room + break; + case 3: + itemlist = Main.g3items; + break; + default: + itemlist = Main.itemlist; + break; + } Pouches = SAV.Inventory; getBags(); } @@ -155,6 +167,8 @@ namespace PKHeX itemcnt++; // No 0 count of items else if (itemcnt > 995) itemcnt = 995; // cap out + else if (itemcnt > 99 && SAV.Generation < 3) + itemcnt = 99; if (itemindex == 0) // Compression of Empty Slots continue; From f10811900378fb1217dd517ca23773068f3dc521 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Mon, 29 Aug 2016 21:52:55 -0700 Subject: [PATCH 36/43] Add Secret Complete bitflag Thanks @SciresM ! 0x72 = 3 for unlocked(1) & complete(2) Closes #210 indirectly. --- PKHeX/PKM/PK6.cs | 3 +- PKHeX/Resources/text/de/lang_de.txt | 3 +- PKHeX/Resources/text/en/lang_en.txt | 3 +- PKHeX/Resources/text/es/lang_es.txt | 3 +- PKHeX/Resources/text/fr/lang_fr.txt | 3 +- PKHeX/Resources/text/it/lang_it.txt | 3 +- PKHeX/Resources/text/ja/lang_ja.txt | 3 +- PKHeX/Resources/text/ko/lang_ko.txt | 3 +- PKHeX/Resources/text/other/lang_pt.txt | 3 +- PKHeX/Resources/text/zh/lang_zh.txt | 3 +- .../SuperTrainingEditor.Designer.cs | 46 ++++++++++++------- .../PKM Editors/SuperTrainingEditor.cs | 20 +++++--- 12 files changed, 63 insertions(+), 33 deletions(-) diff --git a/PKHeX/PKM/PK6.cs b/PKHeX/PKM/PK6.cs index c30b9db71..22c9bd5f5 100644 --- a/PKHeX/PKM/PK6.cs +++ b/PKHeX/PKM/PK6.cs @@ -273,7 +273,8 @@ namespace PKHeX get { return BitConverter.ToUInt16(Data, 0x70); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x70); } } - public bool SecretSuperTraining { get { return Data[0x72] == 1; } set { Data[0x72] = (byte)((Data[0x72] & ~1) | (value ? 1 : 0)); } } + public bool SecretSuperTrainingUnlocked { get { return (Data[0x72] & 1) == 1; } set { Data[0x72] = (byte)((Data[0x72] & ~1) | (value ? 1 : 0)); } } + public bool SecretSuperTrainingComplete { get { return (Data[0x72] & 2) == 2; } set { Data[0x72] = (byte)((Data[0x72] & ~2) | (value ? 2 : 0)); } } public byte _0x73 { get { return Data[0x73]; } set { Data[0x73] = value; } } private uint IV32 { get { return BitConverter.ToUInt32(Data, 0x74); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x74); } } public override int IV_HP { get { return (int)(IV32 >> 00) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } } diff --git a/PKHeX/Resources/text/de/lang_de.txt b/PKHeX/Resources/text/de/lang_de.txt index 407439b28..abe10b4de 100644 --- a/PKHeX/Resources/text/de/lang_de.txt +++ b/PKHeX/Resources/text/de/lang_de.txt @@ -307,7 +307,8 @@ CHK_SuperTrain3_DEF = Rang 3: Def CHK_SuperTrain3_SPA = Rang 3: SpA CHK_SuperTrain3_SPD = Rang 3: SpD CHK_SuperTrain3_SPE = Rang 3: Init -CHK_Secret = Geheimtraining verfügbar +CHK_SecretUnlocked = Geheimtraining Verfügbar +CHK_SecretComplete = Geheimtraining Komplett CHK_SuperTrain4_1 = Rang 4: Unheil CHK_SuperTrain5_1 = Rang 5: Blattst. CHK_SuperTrain5_2 = Rang 5: Feuerst. diff --git a/PKHeX/Resources/text/en/lang_en.txt b/PKHeX/Resources/text/en/lang_en.txt index 67fe2dc47..d71b13a26 100644 --- a/PKHeX/Resources/text/en/lang_en.txt +++ b/PKHeX/Resources/text/en/lang_en.txt @@ -309,7 +309,8 @@ CHK_SuperTrain3_DEF = Rank 3: Def CHK_SuperTrain3_SPA = Rank 3: SpA CHK_SuperTrain3_SPD = Rank 3: SpD CHK_SuperTrain3_SPE = Rank 3: Spe -CHK_Secret = Secret Training Enabled +CHK_SecretUnlocked = Secret Training Unlocked +CHK_SecretComplete = Secret Training Complete CHK_SuperTrain4_1 = Rank 4: Troubles CHK_SuperTrain5_1 = Rank 5: Leaf CHK_SuperTrain5_2 = Rank 5: Fire diff --git a/PKHeX/Resources/text/es/lang_es.txt b/PKHeX/Resources/text/es/lang_es.txt index 916db7d46..150bf0dba 100644 --- a/PKHeX/Resources/text/es/lang_es.txt +++ b/PKHeX/Resources/text/es/lang_es.txt @@ -310,7 +310,8 @@ CHK_SuperTrain3_DEF = Nv. 3: Def CHK_SuperTrain3_SPA = Nv. 3: AtE CHK_SuperTrain3_SPD = Nv. 3: DfE CHK_SuperTrain3_SPE = Nv. 3: Vel -CHK_Secret = Superentrenamiento +CHK_SecretUnlocked = Superentrenamiento Desbloqueado +CHK_SecretComplete = Superentrenamiento Completa CHK_SuperTrain4_1 = Nv. 4: Dificultad tras otra CHK_SuperTrain5_1 = Nv. 5: Hoja CHK_SuperTrain5_2 = Nv. 5: Fuego diff --git a/PKHeX/Resources/text/fr/lang_fr.txt b/PKHeX/Resources/text/fr/lang_fr.txt index 4c5974a69..aff610202 100644 --- a/PKHeX/Resources/text/fr/lang_fr.txt +++ b/PKHeX/Resources/text/fr/lang_fr.txt @@ -308,7 +308,8 @@ CHK_SuperTrain3_DEF = Rang 3: Déf. CHK_SuperTrain3_SPA = Rang 3: A. Spé. CHK_SuperTrain3_SPD = Rang 3: D. Spé. CHK_SuperTrain3_SPE = Rang 3: Vit. -CHK_Secret = Entraînement Secret Activé +CHK_SecretUnlocked = Entraînement Secret Activé +CHK_SecretComplete = Entraînement Secret Formazione CHK_SuperTrain4_1 = Rang 4: Troubles CHK_SuperTrain5_1 = Rang 5: Plante CHK_SuperTrain5_2 = Rang 5: Feu diff --git a/PKHeX/Resources/text/it/lang_it.txt b/PKHeX/Resources/text/it/lang_it.txt index e3c1ccb30..929fc0f61 100644 --- a/PKHeX/Resources/text/it/lang_it.txt +++ b/PKHeX/Resources/text/it/lang_it.txt @@ -309,7 +309,8 @@ CHK_SuperTrain3_DEF = Rank 3: Def CHK_SuperTrain3_SPA = Rank 3: SpA CHK_SuperTrain3_SPD = Rank 3: SpD CHK_SuperTrain3_SPE = Rank 3: Spe -CHK_Secret = Secret Training Enabled +CHK_SecretUnlocked = Secret Training Unlocked +CHK_SecretComplete = Secret Training Complete CHK_SuperTrain4_1 = Rank 4: Troubles CHK_SuperTrain5_1 = Rank 5: Leaf CHK_SuperTrain5_2 = Rank 5: Fire diff --git a/PKHeX/Resources/text/ja/lang_ja.txt b/PKHeX/Resources/text/ja/lang_ja.txt index 5aebea89f..36faee058 100644 --- a/PKHeX/Resources/text/ja/lang_ja.txt +++ b/PKHeX/Resources/text/ja/lang_ja.txt @@ -308,7 +308,8 @@ CHK_SuperTrain3_DEF = ランク3: 防御 CHK_SuperTrain3_SPA = ランク3: 特攻 CHK_SuperTrain3_SPD = ランク3: 特防 CHK_SuperTrain3_SPE = ランク3: 素早さ -CHK_Secret = 秘密の訓練 +CHK_SecretUnlocked = 秘密の訓練ロック解除 +CHK_SecretComplete = 秘密の訓練を完了 CHK_SuperTrain4_1 = ランク4: Troubles CHK_SuperTrain5_1 = ランク5: Leaf CHK_SuperTrain5_2 = ランク5: Fire diff --git a/PKHeX/Resources/text/ko/lang_ko.txt b/PKHeX/Resources/text/ko/lang_ko.txt index c66077b15..8b03134ed 100644 --- a/PKHeX/Resources/text/ko/lang_ko.txt +++ b/PKHeX/Resources/text/ko/lang_ko.txt @@ -309,7 +309,8 @@ CHK_SuperTrain3_DEF = 랭크 3: Def(방어) CHK_SuperTrain3_SPA = 랭크 3: SpA(특공) CHK_SuperTrain3_SPD = 랭크 3: SpD(특방) CHK_SuperTrain3_SPE = 랭크 3: Spe(스피드) -CHK_Secret = 비밀 트레이닝 활성화 +CHK_SecretUnlocked = 비밀 트레이닝 활성화 +CHK_SecretComplete = 비밀 트레이닝 완료 CHK_SuperTrain4_1 = 랭크 4: Troubles CHK_SuperTrain5_1 = 랭크 5: 풀 CHK_SuperTrain5_2 = 랭크 5: 불 diff --git a/PKHeX/Resources/text/other/lang_pt.txt b/PKHeX/Resources/text/other/lang_pt.txt index 105e8aa93..b6855cac9 100644 --- a/PKHeX/Resources/text/other/lang_pt.txt +++ b/PKHeX/Resources/text/other/lang_pt.txt @@ -309,7 +309,8 @@ CHK_SuperTrain3_DEF = Rank 3: Def CHK_SuperTrain3_SPA = Rank 3: SpA CHK_SuperTrain3_SPD = Rank 3: SpD CHK_SuperTrain3_SPE = Rank 3: Spe -CHK_Secret = Super Treino Activado +CHK_SecretUnlocked = Super Treino Activado +CHK_SecretComplete = Super Treino Concluído CHK_SuperTrain4_1 = Rank 4: Problemas CHK_SuperTrain5_1 = Rank 5: Erva CHK_SuperTrain5_2 = Rank 5: Fogo diff --git a/PKHeX/Resources/text/zh/lang_zh.txt b/PKHeX/Resources/text/zh/lang_zh.txt index 08fb9c463..84e766b48 100644 --- a/PKHeX/Resources/text/zh/lang_zh.txt +++ b/PKHeX/Resources/text/zh/lang_zh.txt @@ -309,7 +309,8 @@ CHK_SuperTrain3_DEF = 等级3: 防御 CHK_SuperTrain3_SPA = 等级3: 特攻 CHK_SuperTrain3_SPD = 等级3: 特防 CHK_SuperTrain3_SPE = 等级3: 速度 -CHK_Secret = 秘密训练开启 +CHK_SecretUnlocked = 秘密训练开启 +CHK_SecretComplete = 秘密训练完成 CHK_SuperTrain4_1 = 等级4: 困境 CHK_SuperTrain5_1 = 等级5: 草之石 CHK_SuperTrain5_2 = 等级5: 火之石 diff --git a/PKHeX/Subforms/PKM Editors/SuperTrainingEditor.Designer.cs b/PKHeX/Subforms/PKM Editors/SuperTrainingEditor.Designer.cs index 52ccdfadc..7ea3f27e0 100644 --- a/PKHeX/Subforms/PKM Editors/SuperTrainingEditor.Designer.cs +++ b/PKHeX/Subforms/PKM Editors/SuperTrainingEditor.Designer.cs @@ -36,7 +36,8 @@ this.PAN_Training = new System.Windows.Forms.Panel(); this.SPLIT_Training = new System.Windows.Forms.SplitContainer(); this.TLP_SuperTrain = new System.Windows.Forms.TableLayoutPanel(); - this.CHK_Secret = new System.Windows.Forms.CheckBox(); + this.CHK_SecretComplete = new System.Windows.Forms.CheckBox(); + this.CHK_SecretUnlocked = new System.Windows.Forms.CheckBox(); this.CB_Bag = new System.Windows.Forms.ComboBox(); this.L_Bag = new System.Windows.Forms.Label(); this.NUD_BagHits = new System.Windows.Forms.NumericUpDown(); @@ -123,7 +124,8 @@ // // SPLIT_Training.Panel2 // - this.SPLIT_Training.Panel2.Controls.Add(this.CHK_Secret); + this.SPLIT_Training.Panel2.Controls.Add(this.CHK_SecretComplete); + this.SPLIT_Training.Panel2.Controls.Add(this.CHK_SecretUnlocked); this.SPLIT_Training.Panel2.Controls.Add(this.CB_Bag); this.SPLIT_Training.Panel2.Controls.Add(this.L_Bag); this.SPLIT_Training.Panel2.Controls.Add(this.NUD_BagHits); @@ -150,23 +152,34 @@ this.TLP_SuperTrain.Size = new System.Drawing.Size(173, 229); this.TLP_SuperTrain.TabIndex = 4; // - // CHK_Secret + // CHK_SecretComplete // - this.CHK_Secret.AutoSize = true; - this.CHK_Secret.Location = new System.Drawing.Point(2, 2); - this.CHK_Secret.Name = "CHK_Secret"; - this.CHK_Secret.Size = new System.Drawing.Size(171, 17); - this.CHK_Secret.TabIndex = 36; - this.CHK_Secret.Text = "Secret Super Training Enabled"; - this.CHK_Secret.UseVisualStyleBackColor = true; - this.CHK_Secret.CheckedChanged += new System.EventHandler(this.CHK_Secret_CheckedChanged); + this.CHK_SecretComplete.AutoSize = true; + this.CHK_SecretComplete.Enabled = false; + this.CHK_SecretComplete.Location = new System.Drawing.Point(3, 17); + this.CHK_SecretComplete.Name = "CHK_SecretComplete"; + this.CHK_SecretComplete.Size = new System.Drawing.Size(145, 17); + this.CHK_SecretComplete.TabIndex = 37; + this.CHK_SecretComplete.Text = "Secret Training Complete"; + this.CHK_SecretComplete.UseVisualStyleBackColor = true; + // + // CHK_SecretUnlocked + // + this.CHK_SecretUnlocked.AutoSize = true; + this.CHK_SecretUnlocked.Location = new System.Drawing.Point(3, 2); + this.CHK_SecretUnlocked.Name = "CHK_SecretUnlocked"; + this.CHK_SecretUnlocked.Size = new System.Drawing.Size(147, 17); + this.CHK_SecretUnlocked.TabIndex = 36; + this.CHK_SecretUnlocked.Text = "Secret Training Unlocked"; + this.CHK_SecretUnlocked.UseVisualStyleBackColor = true; + this.CHK_SecretUnlocked.CheckedChanged += new System.EventHandler(this.CHK_Secret_CheckedChanged); // // CB_Bag // this.CB_Bag.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.CB_Bag.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.CB_Bag.FormattingEnabled = true; - this.CB_Bag.Location = new System.Drawing.Point(46, 50); + this.CB_Bag.Location = new System.Drawing.Point(46, 54); this.CB_Bag.Name = "CB_Bag"; this.CB_Bag.Size = new System.Drawing.Size(138, 21); this.CB_Bag.TabIndex = 35; @@ -174,7 +187,7 @@ // L_Bag // this.L_Bag.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.L_Bag.Location = new System.Drawing.Point(31, 34); + this.L_Bag.Location = new System.Drawing.Point(31, 38); this.L_Bag.Name = "L_Bag"; this.L_Bag.Size = new System.Drawing.Size(100, 13); this.L_Bag.TabIndex = 34; @@ -184,7 +197,7 @@ // NUD_BagHits // this.NUD_BagHits.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.NUD_BagHits.Location = new System.Drawing.Point(134, 75); + this.NUD_BagHits.Location = new System.Drawing.Point(134, 79); this.NUD_BagHits.Maximum = new decimal(new int[] { 255, 0, @@ -203,7 +216,7 @@ // L_Hits // this.L_Hits.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.L_Hits.Location = new System.Drawing.Point(31, 77); + this.L_Hits.Location = new System.Drawing.Point(31, 81); this.L_Hits.Name = "L_Hits"; this.L_Hits.Size = new System.Drawing.Size(100, 13); this.L_Hits.TabIndex = 32; @@ -264,8 +277,9 @@ private System.Windows.Forms.NumericUpDown NUD_BagHits; private System.Windows.Forms.Label L_Bag; private System.Windows.Forms.ComboBox CB_Bag; - private System.Windows.Forms.CheckBox CHK_Secret; + private System.Windows.Forms.CheckBox CHK_SecretUnlocked; private System.Windows.Forms.TableLayoutPanel TLP_SuperTrain; private System.Windows.Forms.SplitContainer SPLIT_Training; + private System.Windows.Forms.CheckBox CHK_SecretComplete; } } \ No newline at end of file diff --git a/PKHeX/Subforms/PKM Editors/SuperTrainingEditor.cs b/PKHeX/Subforms/PKM Editors/SuperTrainingEditor.cs index 5f148bb31..d80df49e2 100644 --- a/PKHeX/Subforms/PKM Editors/SuperTrainingEditor.cs +++ b/PKHeX/Subforms/PKM Editors/SuperTrainingEditor.cs @@ -32,8 +32,9 @@ namespace PKHeX if (pkm is PK6) { PK6 pk6 = (PK6) pkm; - CHK_Secret.Checked = pk6.SecretSuperTraining; - if (!CHK_Secret.Checked) // force update to disable checkboxes + CHK_SecretUnlocked.Checked = pk6.SecretSuperTrainingUnlocked; + CHK_SecretComplete.Checked = pk6.SecretSuperTrainingComplete; + if (!CHK_SecretUnlocked.Checked) // force update to disable checkboxes CHK_Secret_CheckedChanged(null, null); CB_Bag.SelectedIndex = pk6.TrainingBag; NUD_BagHits.Value = pk6.TrainingBagHits; @@ -111,7 +112,8 @@ namespace PKHeX if (pkm is PK6) { PK6 pk6 = (PK6) pkm; - pk6.SecretSuperTraining = CHK_Secret.Checked; + pk6.SecretSuperTrainingUnlocked = CHK_SecretUnlocked.Checked; + pk6.SecretSuperTrainingComplete = CHK_SecretComplete.Checked; pk6.TrainingBag = CB_Bag.SelectedIndex; pk6.TrainingBagHits = (int)NUD_BagHits.Value; } @@ -132,7 +134,8 @@ namespace PKHeX private void B_All_Click(object sender, EventArgs e) { - CHK_Secret.Checked = true; + CHK_SecretUnlocked.Checked = true; + CHK_SecretComplete.Checked = true; foreach (var c in TLP_SuperTrain.Controls.OfType()) c.Checked = true; foreach (var c in TLP_DistSuperTrain.Controls.OfType()) @@ -140,7 +143,8 @@ namespace PKHeX } private void B_None_Click(object sender, EventArgs e) { - CHK_Secret.Checked = false; + CHK_SecretUnlocked.Checked = false; + CHK_SecretComplete.Checked = false; foreach (var c in TLP_SuperTrain.Controls.OfType()) c.Checked = false; foreach (var c in TLP_DistSuperTrain.Controls.OfType()) @@ -148,10 +152,12 @@ namespace PKHeX } private void CHK_Secret_CheckedChanged(object sender, EventArgs e) { + CHK_SecretComplete.Checked &= CHK_SecretUnlocked.Checked; + CHK_SecretComplete.Enabled = CHK_SecretUnlocked.Checked; foreach (var c in TLP_SuperTrain.Controls.OfType().Where(chk => Convert.ToInt16(chk.Name[14]+"") >= 4)) { - c.Enabled = CHK_Secret.Checked; - if (!CHK_Secret.Checked) + c.Enabled = CHK_SecretUnlocked.Checked; + if (!CHK_SecretUnlocked.Checked) c.Checked = false; } } From 037db774728df4d7047cd8e8ebdebc91303608c8 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Mon, 29 Aug 2016 23:15:27 -0700 Subject: [PATCH 37/43] Fix dragout-drop of party/battle slots BoxView window opened another can of worms. --- PKHeX/MainWindow/Main.cs | 11 +++++++---- PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs | 7 ++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 82cd76d35..f91ed9125 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -3420,7 +3420,7 @@ namespace PKHeX // Prepare Data DragInfo.slotPkmSource = SAV.getData(offset, SAV.SIZE_STORED); DragInfo.slotSourceOffset = offset; - DragInfo.slotSourceBoxNumber = CB_BoxSelect.SelectedIndex; + DragInfo.slotSourceBoxNumber = DragInfo.slotSourceSlotNumber >= 30 ? -1 : CB_BoxSelect.SelectedIndex; // Make a new file name based off the PID byte[] dragdata = SAV.decryptPKM(DragInfo.slotPkmSource); @@ -3440,7 +3440,7 @@ namespace PKHeX // Thread Blocks on DoDragDrop DragInfo.CurrentPath = newfile; DragDropEffects result = pb.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); - if (result != DragDropEffects.Link) // not dropped to another box slot, restore img + if (!DragInfo.SourceValid || result != DragDropEffects.Link) // not dropped to another box slot, restore img pb.Image = img; else // refresh image getQuickFiller(pb, SAV.getStoredSlot(DragInfo.slotSourceOffset)); @@ -3512,7 +3512,8 @@ namespace PKHeX else { PKM pkz = SAV.getStoredSlot(DragInfo.slotSourceOffset); - if (ModifierKeys == Keys.Alt && DragInfo.slotDestinationSlotNumber > -1) // overwrite delete old slot + if (!DragInfo.SourceValid) { } // not overwritable, do nothing + else if (ModifierKeys == Keys.Alt && DragInfo.DestinationValid) // overwrite delete old slot { // Clear from slot if (DragInfo.SameBox) @@ -3520,7 +3521,7 @@ namespace PKHeX SAV.setStoredSlot(SAV.BlankPKM, DragInfo.slotSourceOffset); } - else if (ModifierKeys != Keys.Control && DragInfo.slotDestinationSlotNumber > -1) + else if (ModifierKeys != Keys.Control && DragInfo.DestinationValid) { // Load data from destination PKM pk = ((PictureBox) sender).Image != null @@ -3586,6 +3587,8 @@ namespace PKHeX public static string CurrentPath; public static bool SameBox => slotSourceBoxNumber > -1 && slotSourceBoxNumber == slotDestinationBoxNumber; + public static bool SourceValid => slotSourceBoxNumber > -1; + public static bool DestinationValid => slotDestinationBoxNumber > -1; public static void Reset() { slotLeftMouseIsDown = false; diff --git a/PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs b/PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs index d7a2fffe2..e66675e51 100644 --- a/PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs +++ b/PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs @@ -182,7 +182,7 @@ namespace PKHeX // Thread Blocks on DoDragDrop DragInfo.CurrentPath = newfile; DragDropEffects result = pb.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); - if (result != DragDropEffects.Link) // not dropped to another box slot, restore img + if (!DragInfo.SourceValid || result != DragDropEffects.Link) // not dropped to another box slot, restore img pb.Image = img; else // refresh image getQuickFiller(pb, SAV.getStoredSlot(DragInfo.slotSourceOffset)); @@ -250,7 +250,8 @@ namespace PKHeX else { PKM pkz = SAV.getStoredSlot(DragInfo.slotSourceOffset); - if (ModifierKeys == Keys.Alt && DragInfo.slotDestinationSlotNumber > -1) // overwrite + if (!DragInfo.SourceValid) { } // not overwritable, do nothing + else if (ModifierKeys == Keys.Alt && DragInfo.DestinationValid) // overwrite { // Clear from slot if (DragInfo.SameBox) @@ -258,7 +259,7 @@ namespace PKHeX SAV.setStoredSlot(SAV.BlankPKM, DragInfo.slotSourceOffset); } - else if (ModifierKeys != Keys.Control && DragInfo.slotDestinationSlotNumber > -1) // move + else if (ModifierKeys != Keys.Control && DragInfo.DestinationValid) // move { // Load data from destination PKM pk = ((PictureBox)sender).Image != null From b6b931220d0c045be1ad9d0639ddf6ce15c299d7 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Tue, 30 Aug 2016 20:31:14 -0700 Subject: [PATCH 38/43] Separate out QR web requests Moved to Util --- PKHeX/Misc/QR.cs | 12 ++---------- PKHeX/PKHeX.csproj | 1 + PKHeX/Util/NetUtil.cs | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 PKHeX/Util/NetUtil.cs diff --git a/PKHeX/Misc/QR.cs b/PKHeX/Misc/QR.cs index ebf8dc130..e4df20778 100644 --- a/PKHeX/Misc/QR.cs +++ b/PKHeX/Misc/QR.cs @@ -1,7 +1,5 @@ using System; using System.Drawing; -using System.IO; -using System.Net; using System.Web; using System.Windows.Forms; @@ -57,10 +55,7 @@ namespace PKHeX string webURL = "http://api.qrserver.com/v1/read-qr-code/?fileurl=" + HttpUtility.UrlEncode(address); try { - HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL); - HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); - var reader = new StreamReader(httpWebReponse.GetResponseStream()); - string data = reader.ReadToEnd(); + string data = Util.getStringFromURL(webURL); if (data.Contains("could not find")) { Util.Alert("Reader could not find QR data in the image."); return null; } if (data.Contains("filetype not supported")) { Util.Alert("Input URL is not valid. Double check that it is an image (jpg/png).", address); return null; } // Quickly convert the json response to a data string @@ -82,10 +77,7 @@ namespace PKHeX try { - HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL); - HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); - Stream stream = httpWebReponse.GetResponseStream(); - if (stream != null) return Image.FromStream(stream); + return Util.getImageFromURL(webURL); } catch { diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index eae839e4b..8780ef3be 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -304,6 +304,7 @@ + diff --git a/PKHeX/Util/NetUtil.cs b/PKHeX/Util/NetUtil.cs new file mode 100644 index 000000000..d013c8b25 --- /dev/null +++ b/PKHeX/Util/NetUtil.cs @@ -0,0 +1,41 @@ +using System; +using System.Drawing; +using System.IO; +using System.Net; + +namespace PKHeX +{ + public partial class Util + { + public static string getStringFromURL(string webURL) + { + try + { + HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL); + HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); + var reader = new StreamReader(httpWebReponse.GetResponseStream()); + return reader.ReadToEnd(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return null; + } + } + public static Image getImageFromURL(string webURL) + { + try + { + HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL); + HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); + Stream stream = httpWebReponse.GetResponseStream(); + return stream != null ? Image.FromStream(stream) : null; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return null; + } + } + } +} From 14b4bfb2f4bb21e0d2778b0b29e809f0c33c9b7e Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Tue, 30 Aug 2016 21:12:47 -0700 Subject: [PATCH 39/43] Add update available indication version.txt as a program resource -> check against online copy, if online has an earlier date then indicate that an update is available. When posting a new update, the version.txt has to be updated with a new yyyyMMdd. Ask me on IRC why I prefer to do things this way ;) --- PKHeX/MainWindow/Main.Designer.cs | 28 ++++++++++-------- PKHeX/MainWindow/Main.cs | 41 +++++++++++++++++++++++--- PKHeX/MainWindow/Main.resx | 6 ++-- PKHeX/PKHeX.csproj | 3 ++ PKHeX/Properties/Resources.Designer.cs | 9 ++++++ PKHeX/Properties/Resources.resx | 3 ++ PKHeX/Resources/text/version.txt | 1 + 7 files changed, 71 insertions(+), 20 deletions(-) create mode 100644 PKHeX/Resources/text/version.txt diff --git a/PKHeX/MainWindow/Main.Designer.cs b/PKHeX/MainWindow/Main.Designer.cs index ed26d445d..b46c66d52 100644 --- a/PKHeX/MainWindow/Main.Designer.cs +++ b/PKHeX/MainWindow/Main.Designer.cs @@ -245,7 +245,6 @@ this.Menu_ModifyPKM = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_Unicode = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_About = new System.Windows.Forms.ToolStripMenuItem(); - this.L_Save = new System.Windows.Forms.Label(); this.tabBoxMulti = new System.Windows.Forms.TabControl(); this.Tab_Box = new System.Windows.Forms.TabPage(); this.PAN_Box = new System.Windows.Forms.Panel(); @@ -363,6 +362,7 @@ this.mnuLQR = new System.Windows.Forms.ToolStripMenuItem(); this.mnuLSave = new System.Windows.Forms.ToolStripMenuItem(); this.PB_Legal = new System.Windows.Forms.PictureBox(); + this.L_UpdateAvailable = new System.Windows.Forms.LinkLabel(); this.tabMain.SuspendLayout(); this.Tab_Main.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.Label_IsShiny)).BeginInit(); @@ -2985,16 +2985,6 @@ this.Menu_About.Text = "About &PKHeX"; this.Menu_About.Click += new System.EventHandler(this.mainMenuAbout); // - // L_Save - // - this.L_Save.AutoSize = true; - this.L_Save.Location = new System.Drawing.Point(300, 5); - this.L_Save.Name = "L_Save"; - this.L_Save.Size = new System.Drawing.Size(54, 13); - this.L_Save.TabIndex = 4; - this.L_Save.Text = "SAV: N/A"; - this.L_Save.Click += new System.EventHandler(this.clickSaveFileName); - // // tabBoxMulti // this.tabBoxMulti.Controls.Add(this.Tab_Box); @@ -4604,16 +4594,28 @@ this.PB_Legal.TabStop = false; this.PB_Legal.Click += new System.EventHandler(this.clickLegality); // + // L_UpdateAvailable + // + this.L_UpdateAvailable.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.L_UpdateAvailable.Location = new System.Drawing.Point(305, 5); + this.L_UpdateAvailable.Name = "L_UpdateAvailable"; + this.L_UpdateAvailable.Size = new System.Drawing.Size(300, 13); + this.L_UpdateAvailable.TabIndex = 102; + this.L_UpdateAvailable.TabStop = true; + this.L_UpdateAvailable.Text = "New Update Available!"; + this.L_UpdateAvailable.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.L_UpdateAvailable.Visible = false; + // // Main // this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(614, 361); + this.Controls.Add(this.L_UpdateAvailable); this.Controls.Add(this.PB_Legal); this.Controls.Add(this.dragout); this.Controls.Add(this.tabBoxMulti); - this.Controls.Add(this.L_Save); this.Controls.Add(this.tabMain); this.Controls.Add(this.menuStrip1); this.Controls.Add(this.GB_SAVtools); @@ -4884,7 +4886,6 @@ private System.Windows.Forms.Label L_Characteristic; private System.Windows.Forms.TextBox TB_IVTotal; private System.Windows.Forms.Label L_Potential; - private System.Windows.Forms.Label L_Save; private System.Windows.Forms.TabControl tabBoxMulti; private System.Windows.Forms.TabPage Tab_Box; private System.Windows.Forms.TabPage Tab_PartyBattle; @@ -5085,6 +5086,7 @@ private System.Windows.Forms.FlowLayoutPanel FLP_PKMEditors; private System.Windows.Forms.Button B_LinkInfo; private System.Windows.Forms.Button B_CGearSkin; + private System.Windows.Forms.LinkLabel L_UpdateAvailable; } } diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index f91ed9125..817610a0c 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.Globalization; using System.IO; using System.Linq; using System.Media; @@ -19,6 +20,31 @@ namespace PKHeX new Thread(() => new SplashScreen().ShowDialog()).Start(); DragInfo.slotPkmSource = SAV.BlankPKM.EncryptedPartyData; InitializeComponent(); + + // Check for Updates + L_UpdateAvailable.Click += (sender, e) => { Process.Start(ThreadPath); }; + new Thread(() => + { + string data = Util.getStringFromURL(VersionPath); + if (data == null) + return; + try + { + DateTime upd = DateTime.ParseExact(data, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None); + DateTime cur = DateTime.ParseExact(Properties.Resources.ProgramVersion, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None); + + if (upd <= cur) + return; + + string message = $"New Update Available! {upd.ToString("d")}"; + if (InvokeRequired) + try { Invoke((MethodInvoker) delegate { L_UpdateAvailable.Visible = true; L_UpdateAvailable.Text = message; }); } + catch { L_UpdateAvailable.Visible = true; L_UpdateAvailable.Text = message; } + else { L_UpdateAvailable.Visible = true; L_UpdateAvailable.Text = message; } + } + catch { } + }).Start(); + CB_ExtraBytes.SelectedIndex = 0; SaveFile.SetUpdateDex = Menu_ModifyDex.Checked; SaveFile.SetUpdatePKM = Menu_ModifyPKM.Checked; @@ -184,6 +210,8 @@ namespace PKHeX public static string DatabasePath => Path.Combine(WorkingDirectory, "db"); private static string WC6DatabasePath => Path.Combine(WorkingDirectory, "wc6"); private static string BackupPath => Path.Combine(WorkingDirectory, "bak"); + private static string ThreadPath => @"https://projectpokemon.org/forums/showthread.php?36986"; + private static string VersionPath => @"https://raw.githubusercontent.com/kwsch/PKHeX/master/PKHeX/Resources/Text/version.txt"; #endregion @@ -756,7 +784,7 @@ namespace PKHeX SAV.FileName = Path.GetExtension(path) == ".bak" ? Path.GetFileName(path).Split(new[] { " [" }, StringSplitOptions.None)[0] : Path.GetFileName(path); - L_Save.Text = $"SAV{SAV.Generation}: {Path.GetFileNameWithoutExtension(Util.CleanFileName(SAV.BAKName))}"; // more descriptive + Text = "PKHeX - " + $"SAV{SAV.Generation}: {Path.GetFileNameWithoutExtension(Util.CleanFileName(SAV.BAKName))}"; // more descriptive // If backup folder exists, save a backup. string backupName = Path.Combine(BackupPath, Util.CleanFileName(SAV.BAKName)); @@ -769,7 +797,7 @@ namespace PKHeX { SAV.FilePath = null; SAV.FileName = "Blank Save File"; - L_Save.Text = $"SAV{SAV.Generation}: {SAV.FileName} [{SAV.OT} ({SAV.Version})]"; + Text = "PKHeX - " + $"SAV{SAV.Generation}: {SAV.FileName} [{SAV.OT} ({SAV.Version})]"; GB_SAVtools.Visible = false; } @@ -2622,7 +2650,7 @@ namespace PKHeX } private void clickBoxSort(object sender, EventArgs e) { - if (tabBoxMulti.SelectedIndex != 0) + if (tabBoxMulti.SelectedTab != Tab_Box) return; if (!SAV.HasBox) return; @@ -2665,7 +2693,12 @@ namespace PKHeX } private void clickBoxDouble(object sender, MouseEventArgs e) { - if (tabBoxMulti.SelectedIndex != 0) + if (tabBoxMulti.SelectedTab == Tab_SAV) + { + clickSaveFileName(sender, e); + return; + } + if (tabBoxMulti.SelectedTab != Tab_Box) return; if (!SAV.HasBox) return; diff --git a/PKHeX/MainWindow/Main.resx b/PKHeX/MainWindow/Main.resx index 1d654adaa..df010947a 100644 --- a/PKHeX/MainWindow/Main.resx +++ b/PKHeX/MainWindow/Main.resx @@ -877,9 +877,6 @@ True - - True - True @@ -1332,6 +1329,9 @@ SiSLGvswRQAAAABJRU5ErkJggg== + + True + True diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index 8780ef3be..f4eab194c 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -2720,6 +2720,9 @@ + + +