2017-05-23 04:55:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using PKHeX.Core;
|
2019-09-29 16:47:06 +00:00
|
|
|
|
using PKHeX.Drawing;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
using System.ComponentModel;
|
2022-03-26 22:51:12 +00:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2021-11-27 23:48:08 +00:00
|
|
|
|
using PKHeX.Drawing.PokeSprite;
|
|
|
|
|
using PKHeX.Drawing.PokeSprite.Properties;
|
2018-04-06 04:25:18 +00:00
|
|
|
|
using static PKHeX.Core.MessageStrings;
|
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
namespace PKHeX.WinForms.Controls
|
|
|
|
|
{
|
2018-07-14 22:08:14 +00:00
|
|
|
|
public sealed partial class PKMEditor : UserControl, IMainEditor
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2021-11-20 02:23:49 +00:00
|
|
|
|
public bool IsInitialized { get; private set; }
|
2020-10-18 18:02:39 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
public PKMEditor()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
// Groupbox doesn't show Click event in Designer...
|
2021-07-31 01:05:17 +00:00
|
|
|
|
GB_OT.Click += ClickGT;
|
|
|
|
|
GB_nOT.Click += ClickGT;
|
|
|
|
|
GB_CurrentMoves.Click += ClickMoves;
|
|
|
|
|
GB_RelearnMoves.Click += ClickMoves;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
var font = FontUtil.GetPKXFont();
|
|
|
|
|
TB_Nickname.Font = TB_OT.Font = TB_OTt2.Font = font;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2018-03-11 02:03:09 +00:00
|
|
|
|
// Commonly reused Control arrays
|
|
|
|
|
Moves = new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 };
|
|
|
|
|
Relearn = new[] { CB_RelearnMove1, CB_RelearnMove2, CB_RelearnMove3, CB_RelearnMove4 };
|
|
|
|
|
PPUps = new[] { CB_PPu1, CB_PPu2, CB_PPu3, CB_PPu4 };
|
|
|
|
|
MovePP = new[] { TB_PP1, TB_PP2, TB_PP3, TB_PP4 };
|
2018-05-27 17:24:28 +00:00
|
|
|
|
Markings = new[] { PB_Mark1, PB_Mark2, PB_Mark3, PB_Mark4, PB_Mark5, PB_Mark6 };
|
2021-07-31 01:05:17 +00:00
|
|
|
|
|
|
|
|
|
// Legality Indicators
|
2017-05-23 04:55:05 +00:00
|
|
|
|
relearnPB = new[] { PB_WarnRelearn1, PB_WarnRelearn2, PB_WarnRelearn3, PB_WarnRelearn4 };
|
|
|
|
|
movePB = new[] { PB_WarnMove1, PB_WarnMove2, PB_WarnMove3, PB_WarnMove4 };
|
2019-02-10 01:07:44 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
// Validation of incompletely entered data fields
|
2022-03-16 02:23:13 +00:00
|
|
|
|
bool Criteria(Control c) => c.BackColor == Draw.InvalidSelection && c is ComboBox { Items.Count: not 0 };
|
2021-07-31 01:05:17 +00:00
|
|
|
|
ValidatedControls = new ValidationRequiredSet[]
|
|
|
|
|
{
|
|
|
|
|
new(Moves, _ => true, Criteria),
|
|
|
|
|
new(new[] {CB_Species}, _ => true, Criteria),
|
|
|
|
|
new(new[] {CB_HeldItem}, pk => pk.Format >= 2, Criteria),
|
|
|
|
|
new(new[] {CB_Ability, CB_Nature, CB_MetLocation, CB_Ball}, pk => pk.Format >= 3, Criteria),
|
|
|
|
|
new(new[] {CB_EggLocation}, pk => pk.Format >= 4, Criteria),
|
2021-11-20 02:23:49 +00:00
|
|
|
|
new(new[] {CB_Country, CB_SubRegion}, pk => pk is PK6 or PK7, Criteria),
|
2021-07-31 01:05:17 +00:00
|
|
|
|
new(Relearn, pk => pk.Format >= 6, Criteria),
|
|
|
|
|
new(new[] {CB_StatNature}, pk => pk.Format >= 8, Criteria),
|
2022-02-05 01:36:51 +00:00
|
|
|
|
new(new[] {CB_AlphaMastered}, pk => pk is PA8, Criteria),
|
2021-07-31 01:05:17 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-01-05 23:40:25 +00:00
|
|
|
|
foreach (var c in WinFormsUtil.GetAllControlsOfType<ComboBox>(this))
|
2017-06-18 04:49:14 +00:00
|
|
|
|
c.KeyDown += WinFormsUtil.RemoveDropCB;
|
2017-12-22 06:55:33 +00:00
|
|
|
|
|
2019-01-03 02:49:36 +00:00
|
|
|
|
Stats.MainEditor = this;
|
2017-12-22 06:55:33 +00:00
|
|
|
|
LoadShowdownSet = LoadShowdownSetDefault;
|
2021-07-31 01:05:17 +00:00
|
|
|
|
TID_Trainer.UpdatedID += Update_ID;
|
|
|
|
|
|
|
|
|
|
// Controls contained in a TabPage are not created until the tab page is shown
|
|
|
|
|
// Any data bindings in these controls are not activated until the tab page is shown.
|
|
|
|
|
FlickerInterface();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-06 07:54:59 +00:00
|
|
|
|
private sealed class ValidationRequiredSet
|
2021-07-31 01:05:17 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly Control[] Controls;
|
|
|
|
|
private readonly Func<PKM, bool> ShouldCheck;
|
|
|
|
|
private readonly Func<Control, bool> IsInvalidState;
|
|
|
|
|
|
|
|
|
|
public Control? IsNotValid(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
if (!ShouldCheck(pk))
|
|
|
|
|
return null;
|
|
|
|
|
return Array.Find(Controls, z => IsInvalidState(z));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ValidationRequiredSet(Control[] controls, Func<PKM, bool> shouldCheck, Func<Control, bool> state)
|
|
|
|
|
{
|
|
|
|
|
Controls = controls;
|
|
|
|
|
ShouldCheck = shouldCheck;
|
|
|
|
|
IsInvalidState = state;
|
|
|
|
|
}
|
2018-12-20 06:10:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void InitializeBinding()
|
|
|
|
|
{
|
|
|
|
|
ComboBox[] cbs =
|
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
CB_Nature, CB_StatNature,
|
2018-12-20 06:10:32 +00:00
|
|
|
|
CB_Country, CB_SubRegion, CB_3DSReg, CB_Language, CB_Ball, CB_HeldItem, CB_Species, DEV_Ability,
|
2021-07-04 06:25:09 +00:00
|
|
|
|
CB_GroundTile, CB_GameOrigin, CB_BattleVersion, CB_Ability, CB_MetLocation, CB_EggLocation, CB_Language, CB_HTLanguage,
|
2022-02-05 01:36:51 +00:00
|
|
|
|
CB_AlphaMastered,
|
2018-12-20 06:10:32 +00:00
|
|
|
|
};
|
|
|
|
|
foreach (var cb in cbs.Concat(Moves.Concat(Relearn)))
|
|
|
|
|
cb.InitializeBinding();
|
2021-11-20 02:23:49 +00:00
|
|
|
|
|
|
|
|
|
IsInitialized = true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-26 23:37:44 +00:00
|
|
|
|
private void UpdateStats()
|
|
|
|
|
{
|
|
|
|
|
Stats.UpdateStats();
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity is PB7)
|
2018-11-26 23:37:44 +00:00
|
|
|
|
SizeCP.TryResetStats();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void LoadPartyStats(PKM pk) => Stats.LoadPartyStats(pk);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
private void SavePartyStats(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
Stats.SavePartyStats(pk);
|
2020-01-09 16:17:41 +00:00
|
|
|
|
pk.Stat_Level = Util.ToInt32((HaX ? MT_Level : TB_Level).Text);
|
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
public PKM CurrentPKM { get => PreparePKM(); set => Entity = value; }
|
2017-06-19 05:27:40 +00:00
|
|
|
|
public bool ModifyPKM { private get; set; } = true;
|
2018-08-20 01:22:07 +00:00
|
|
|
|
private bool _hideSecret;
|
2018-12-20 06:10:32 +00:00
|
|
|
|
|
|
|
|
|
public bool HideSecretValues
|
|
|
|
|
{
|
|
|
|
|
private get => _hideSecret;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_hideSecret = value;
|
|
|
|
|
var sav = RequestSaveFile;
|
2020-10-18 18:02:39 +00:00
|
|
|
|
ToggleSecrets(_hideSecret, sav.Generation);
|
2018-12-20 06:10:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
public DrawConfig Draw { private get; set; } = null!;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public bool Unicode { get; set; } = true;
|
2019-01-03 02:49:36 +00:00
|
|
|
|
private bool _hax;
|
|
|
|
|
public bool HaX { get => _hax; set => _hax = Stats.HaX = value; }
|
2020-04-14 17:08:56 +00:00
|
|
|
|
private byte[] LastData = Array.Empty<byte>();
|
2017-06-19 05:27:40 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
public PKM Data { get => Entity; set => Entity = value; }
|
2020-10-18 18:02:39 +00:00
|
|
|
|
public PKM Entity { get; private set; } = null!;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public bool FieldsLoaded { get; private set; }
|
|
|
|
|
public bool ChangingFields { get; set; }
|
|
|
|
|
|
2020-06-20 23:23:03 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Currently loaded met location group that is populating Met and Egg location comboboxes
|
|
|
|
|
/// </summary>
|
2017-06-19 05:27:40 +00:00
|
|
|
|
private GameVersion origintrack;
|
2020-06-20 23:23:03 +00:00
|
|
|
|
|
2021-04-10 17:30:10 +00:00
|
|
|
|
private int originFormat = -1;
|
|
|
|
|
|
2020-06-20 23:23:03 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Action to perform when loading a PKM to the editor GUI.
|
|
|
|
|
/// </summary>
|
2020-10-18 18:02:39 +00:00
|
|
|
|
private Action GetFieldsfromPKM = null!;
|
2020-06-20 23:23:03 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Function that returns a <see cref="PKM"/> from the loaded fields.
|
|
|
|
|
/// </summary>
|
2020-10-18 18:02:39 +00:00
|
|
|
|
private Func<PKM> GetPKMfromFields = null!;
|
2020-06-20 23:23:03 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Latest legality check result used to show legality indication.
|
|
|
|
|
/// </summary>
|
2020-10-18 18:02:39 +00:00
|
|
|
|
private LegalityAnalysis Legality = null!;
|
2020-06-20 23:23:03 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// List of legal moves for the latest <see cref="Legality"/>.
|
|
|
|
|
/// </summary>
|
2020-12-22 07:37:07 +00:00
|
|
|
|
private readonly LegalMoveSource LegalMoveSource = new();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2020-06-20 23:23:03 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gender Symbols for showing Genders
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IReadOnlyList<string> gendersymbols = GameInfo.GenderSymbolUnicode;
|
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
public event EventHandler? LegalityChanged;
|
|
|
|
|
public event EventHandler? UpdatePreviewSprite;
|
|
|
|
|
public event EventHandler? RequestShowdownImport;
|
|
|
|
|
public event EventHandler? RequestShowdownExport;
|
|
|
|
|
public event ReturnSAVEventHandler SaveFileRequested = null!;
|
2017-12-16 22:11:41 +00:00
|
|
|
|
public delegate SaveFile ReturnSAVEventHandler(object sender, EventArgs e);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
private readonly PictureBox[] movePB, relearnPB;
|
2020-10-18 18:02:39 +00:00
|
|
|
|
public SaveFile RequestSaveFile => SaveFileRequested.Invoke(this, EventArgs.Empty);
|
2020-04-14 17:08:56 +00:00
|
|
|
|
public bool PKMIsUnsaved => FieldsLoaded && LastData.Any(b => b != 0) && !LastData.SequenceEqual(CurrentPKM.Data);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private readonly ComboBox[] Moves, Relearn, PPUps;
|
|
|
|
|
private readonly ValidationRequiredSet[] ValidatedControls;
|
2018-03-11 02:03:09 +00:00
|
|
|
|
private readonly MaskedTextBox[] MovePP;
|
2018-05-27 17:24:28 +00:00
|
|
|
|
private readonly PictureBox[] Markings;
|
2018-03-11 02:03:09 +00:00
|
|
|
|
|
2017-10-26 02:37:31 +00:00
|
|
|
|
private bool forceValidation;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public PKM PreparePKM(bool click = true)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (click)
|
2017-10-26 02:37:31 +00:00
|
|
|
|
{
|
|
|
|
|
forceValidation = true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
ValidateChildren();
|
2017-10-26 02:37:31 +00:00
|
|
|
|
forceValidation = false;
|
|
|
|
|
}
|
2019-09-03 02:30:58 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
var pk = GetPKMfromFields();
|
2019-09-03 02:30:58 +00:00
|
|
|
|
LastData = pk.Data;
|
|
|
|
|
return pk.Clone();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2019-02-10 01:07:44 +00:00
|
|
|
|
public bool EditsComplete
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-02-10 01:07:44 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (ModifierKeys == (Keys.Control | Keys.Shift | Keys.Alt))
|
|
|
|
|
return true; // Override
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
// If any controls are partially filled out, find the first one so we can indicate as such.
|
|
|
|
|
Control? cb = null;
|
|
|
|
|
foreach (var type in ValidatedControls)
|
|
|
|
|
{
|
|
|
|
|
cb = type.IsNotValid(Entity);
|
|
|
|
|
if (cb is not null)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-10 01:07:44 +00:00
|
|
|
|
if (cb != null)
|
|
|
|
|
tabMain.SelectedTab = WinFormsUtil.FindFirstControlOfType<TabPage>(cb);
|
|
|
|
|
else if (!Stats.Valid)
|
|
|
|
|
tabMain.SelectedTab = Tab_Stats;
|
2021-07-31 01:05:17 +00:00
|
|
|
|
else if (WinFormsUtil.GetIndex(CB_Species) == 0 && !HaX) // can't set an empty slot...
|
2019-02-10 01:07:44 +00:00
|
|
|
|
tabMain.SelectedTab = Tab_Main;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-02-10 01:07:44 +00:00
|
|
|
|
System.Media.SystemSounds.Exclamation.Play();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-20 02:23:49 +00:00
|
|
|
|
public void SetPKMFormatMode(PKM pk)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-12-20 06:10:32 +00:00
|
|
|
|
// Load Extra Byte List
|
|
|
|
|
SetPKMFormatExtraBytes(pk);
|
2021-11-20 02:23:49 +00:00
|
|
|
|
(GetFieldsfromPKM, GetPKMfromFields) = GetLoadSet(pk);
|
2018-12-20 06:10:32 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-11-20 02:23:49 +00:00
|
|
|
|
private (Action, Func<PKM>) GetLoadSet(PKM pk) => pk.Format switch
|
|
|
|
|
{
|
|
|
|
|
1 => (PopulateFieldsPK1, PreparePK1),
|
|
|
|
|
2 => (PopulateFieldsPK2, PreparePK2),
|
|
|
|
|
3 => (PopulateFieldsPK3, PreparePK3),
|
|
|
|
|
4 => (PopulateFieldsPK4, PreparePK4),
|
|
|
|
|
5 => (PopulateFieldsPK5, PreparePK5),
|
|
|
|
|
6 => (PopulateFieldsPK6, PreparePK6),
|
|
|
|
|
7 when pk is PK7 => (PopulateFieldsPK7, PreparePK7),
|
|
|
|
|
7 when pk is PB7 => (PopulateFieldsPB7, PreparePB7),
|
|
|
|
|
8 when pk is PK8 => (PopulateFieldsPK8, PreparePK8),
|
2022-02-05 01:36:51 +00:00
|
|
|
|
8 when pk is PA8 => (PopulateFieldsPA8, PreparePA8),
|
2021-11-20 02:23:49 +00:00
|
|
|
|
8 when pk is PB8 => (PopulateFieldsPB8, PreparePB8),
|
|
|
|
|
_ => throw new FormatException($"Unrecognized Type: {pk.GetType()}"),
|
|
|
|
|
};
|
|
|
|
|
|
2018-12-20 06:10:32 +00:00
|
|
|
|
private void SetPKMFormatExtraBytes(PKM pk)
|
|
|
|
|
{
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
var extraBytes = pk.ExtraBytes;
|
|
|
|
|
GB_ExtraBytes.Visible = GB_ExtraBytes.Enabled = extraBytes.Count != 0;
|
2017-05-23 15:28:53 +00:00
|
|
|
|
CB_ExtraBytes.Items.Clear();
|
2019-11-16 01:34:18 +00:00
|
|
|
|
foreach (var b in extraBytes)
|
2017-05-23 15:28:53 +00:00
|
|
|
|
CB_ExtraBytes.Items.Add($"0x{b:X2}");
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (GB_ExtraBytes.Enabled)
|
|
|
|
|
CB_ExtraBytes.SelectedIndex = 0;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-10-28 21:26:27 +00:00
|
|
|
|
public void PopulateFields(PKM pk, bool focus = true, bool skipConversionCheck = false) => LoadFieldsFromPKM(pk, focus, skipConversionCheck);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-07-21 07:58:30 +00:00
|
|
|
|
private void LoadFieldsFromPKM(PKM pk, bool focus = true, bool skipConversionCheck = true)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (focus)
|
|
|
|
|
Tab_Main.Focus();
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (!skipConversionCheck && !PKMConverter.TryMakePKMCompatible(pk, Entity, out string c, out pk))
|
2017-10-28 21:26:27 +00:00
|
|
|
|
{ WinFormsUtil.Alert(c); return; }
|
|
|
|
|
|
2019-02-10 01:07:44 +00:00
|
|
|
|
FieldsLoaded = false;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity = pk.Clone();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-12-08 08:03:08 +00:00
|
|
|
|
#if !DEBUG
|
2017-06-18 01:37:19 +00:00
|
|
|
|
try { GetFieldsfromPKM(); }
|
2019-02-15 04:18:31 +00:00
|
|
|
|
catch { }
|
2019-12-08 08:03:08 +00:00
|
|
|
|
#else
|
|
|
|
|
GetFieldsfromPKM();
|
|
|
|
|
#endif
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
Stats.UpdateIVs(this, EventArgs.Empty);
|
|
|
|
|
UpdatePKRSInfected(this, EventArgs.Empty);
|
|
|
|
|
UpdatePKRSCured(this, EventArgs.Empty);
|
2021-07-31 01:05:17 +00:00
|
|
|
|
UpdateNatureModification(CB_StatNature, Entity.StatNature);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
if (HaX) // Load original values from pk not pkm
|
|
|
|
|
{
|
2020-06-20 23:23:03 +00:00
|
|
|
|
MT_Level.Text = (pk.PartyStatsPresent ? pk.Stat_Level : pk.CurrentLevel).ToString();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
TB_EXP.Text = pk.EXP.ToString();
|
2019-01-12 18:54:38 +00:00
|
|
|
|
if (pk.PartyStatsPresent) // stats present
|
2018-02-27 05:22:35 +00:00
|
|
|
|
Stats.LoadPartyStats(pk);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
FieldsLoaded = true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
SetMarkings();
|
|
|
|
|
UpdateLegality();
|
2017-06-19 05:27:40 +00:00
|
|
|
|
UpdateSprite();
|
2020-04-14 17:08:56 +00:00
|
|
|
|
LastData = PreparePKM().Data;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
public void UpdateLegality(LegalityAnalysis? la = null, bool skipMoveRepop = false)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Legality = la ?? new LegalityAnalysis(Entity, RequestSaveFile.Personal);
|
|
|
|
|
if (!Legality.Parsed || HaX || Entity.Species == 0)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2022-03-26 22:51:12 +00:00
|
|
|
|
PB_WarnMove1.Visible = PB_WarnMove2.Visible = PB_WarnMove3.Visible = PB_WarnMove4.Visible = false;
|
|
|
|
|
PB_WarnRelearn1.Visible = PB_WarnRelearn2.Visible = PB_WarnRelearn3.Visible = PB_WarnRelearn4.Visible = false;
|
2019-02-02 18:19:41 +00:00
|
|
|
|
LegalityChanged?.Invoke(Legality.Valid, EventArgs.Empty);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Refresh Move Legality
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
2020-02-16 20:17:36 +00:00
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
var pb = movePB[i];
|
|
|
|
|
pb.Visible = true;
|
2022-03-26 22:51:12 +00:00
|
|
|
|
pb.Image = GetMoveImage(!Legality.Info.Moves[i].Valid, Entity, i);
|
2020-02-16 20:17:36 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format >= 6)
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
2020-04-14 17:08:56 +00:00
|
|
|
|
relearnPB[i].Visible = !Legality.Info.Relearn[i].Valid;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
if (skipMoveRepop)
|
|
|
|
|
return;
|
|
|
|
|
// Resort moves
|
2018-02-27 05:22:35 +00:00
|
|
|
|
FieldsLoaded = false;
|
2020-12-25 00:36:50 +00:00
|
|
|
|
LegalMoveSource.ReloadMoves(Legality.GetSuggestedMovesAndRelearn());
|
2019-02-10 01:07:44 +00:00
|
|
|
|
FieldsLoaded = true;
|
2019-02-02 18:19:41 +00:00
|
|
|
|
LegalityChanged?.Invoke(Legality.Valid, EventArgs.Empty);
|
2018-08-02 04:22:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-26 22:51:12 +00:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
private static Bitmap? GetMoveImage(bool isIllegal, PKM pkm, int index)
|
|
|
|
|
{
|
|
|
|
|
if (isIllegal)
|
|
|
|
|
return Resources.warn;
|
|
|
|
|
if (pkm.Format >= 8 && Legal.GetDummiedMovesHashSet(pkm).Contains(pkm.GetMove(index)))
|
|
|
|
|
return Resources.hint;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-21 05:55:28 +00:00
|
|
|
|
public void UpdateUnicode(IReadOnlyList<string> symbols)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
gendersymbols = symbols;
|
|
|
|
|
if (!Unicode)
|
|
|
|
|
{
|
2019-02-09 21:15:37 +00:00
|
|
|
|
BTN_Shinytize.Text = Draw.ShinyDefault;
|
2018-04-28 16:34:54 +00:00
|
|
|
|
TB_Nickname.Font = TB_OT.Font = TB_OTt2.Font = GB_OT.Font;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-02-09 21:15:37 +00:00
|
|
|
|
BTN_Shinytize.Text = Draw.ShinyUnicode;
|
2019-10-27 06:14:00 +00:00
|
|
|
|
TB_Nickname.Font = TB_OT.Font = TB_OTt2.Font = FontUtil.GetPKXFont();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2019-02-09 21:15:37 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
// Switch active gender labels to new if they are active.
|
2019-02-09 21:15:37 +00:00
|
|
|
|
ReloadGender(Label_Gender, gendersymbols);
|
|
|
|
|
ReloadGender(Label_OTGender, gendersymbols);
|
|
|
|
|
ReloadGender(Label_CTGender, gendersymbols);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2019-02-09 21:15:37 +00:00
|
|
|
|
private static string ReloadGender(string text, IReadOnlyList<string> genders)
|
|
|
|
|
{
|
|
|
|
|
var index = PKX.GetGenderFromString(text);
|
|
|
|
|
if (index >= 2)
|
|
|
|
|
return text;
|
|
|
|
|
return genders[index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ReloadGender(Label l, IReadOnlyList<string> genders) => l.Text = ReloadGender(l.Text, genders);
|
|
|
|
|
|
2020-10-25 20:47:42 +00:00
|
|
|
|
internal void UpdateSprite()
|
2017-06-19 05:27:40 +00:00
|
|
|
|
{
|
2019-02-10 01:07:44 +00:00
|
|
|
|
if (FieldsLoaded && !forceValidation)
|
2019-02-02 18:19:41 +00:00
|
|
|
|
UpdatePreviewSprite?.Invoke(this, EventArgs.Empty);
|
2017-06-19 05:27:40 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// General Use Functions //
|
2019-02-17 03:53:14 +00:00
|
|
|
|
private void SetDetailsOT(ITrainerInfo tr)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-02-17 03:53:14 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(tr.OT))
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Get Save Information
|
2019-02-17 03:53:14 +00:00
|
|
|
|
TB_OT.Text = tr.OT;
|
|
|
|
|
Label_OTGender.Text = gendersymbols[tr.Gender & 1];
|
|
|
|
|
Label_OTGender.ForeColor = Draw.GetGenderColor(tr.Gender & 1);
|
|
|
|
|
TID_Trainer.LoadInfo(tr);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-02-17 03:53:14 +00:00
|
|
|
|
if (tr.Game >= 0)
|
|
|
|
|
CB_GameOrigin.SelectedValue = tr.Game;
|
2018-12-20 06:10:32 +00:00
|
|
|
|
|
2019-02-17 03:53:14 +00:00
|
|
|
|
var lang = tr.Language;
|
2018-12-20 06:10:32 +00:00
|
|
|
|
if (lang <= 0)
|
|
|
|
|
lang = (int)LanguageID.English;
|
|
|
|
|
CB_Language.SelectedValue = lang;
|
2020-07-31 20:53:42 +00:00
|
|
|
|
if (tr is IRegionOrigin o)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2021-08-03 03:43:32 +00:00
|
|
|
|
CB_3DSReg.SelectedValue = (int)o.ConsoleRegion;
|
|
|
|
|
CB_Country.SelectedValue = (int)o.Country;
|
|
|
|
|
CB_SubRegion.SelectedValue = (int)o.Region;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-02-23 06:42:50 +00:00
|
|
|
|
|
|
|
|
|
// Copy OT trash bytes for sensitive games (Gen1/2)
|
2022-01-03 05:35:59 +00:00
|
|
|
|
if (tr is SAV1 s1 && Entity is PK1 p1) s1.OT_Trash.CopyTo(p1.OT_Trash);
|
|
|
|
|
else if (tr is SAV2 s2 && Entity is PK2 p2) s2.OT_Trash.CopyTo(p2.OT_Trash);
|
2018-02-23 06:42:50 +00:00
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
UpdateNickname(this, EventArgs.Empty);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2019-02-17 03:53:14 +00:00
|
|
|
|
private void SetDetailsHT(ITrainerInfo tr)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-02-17 03:53:14 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(tr.OT))
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (TB_OTt2.Text.Length > 0)
|
2019-11-16 01:34:18 +00:00
|
|
|
|
{
|
2019-02-17 03:53:14 +00:00
|
|
|
|
Label_CTGender.Text = gendersymbols[tr.Gender & 1];
|
2019-11-16 01:34:18 +00:00
|
|
|
|
if (Entity is IHandlerLanguage)
|
|
|
|
|
CB_HTLanguage.SelectedValue = tr.Language;
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-07 00:37:07 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void SetForms()
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
int species = Entity.Species;
|
2020-10-18 18:02:39 +00:00
|
|
|
|
var pi = RequestSaveFile.Personal[species];
|
2020-12-11 04:42:30 +00:00
|
|
|
|
bool hasForms = FormInfo.HasFormSelection(pi, species, Entity.Format);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
CB_Form.Enabled = CB_Form.Visible = Label_Form.Visible = hasForms;
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (HaX && Entity.Format >= 4)
|
2018-07-07 00:37:07 +00:00
|
|
|
|
Label_Form.Visible = true; // show with value entry textbox
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
if (!hasForms)
|
2020-12-28 19:51:25 +00:00
|
|
|
|
{
|
|
|
|
|
if (HaX)
|
|
|
|
|
return;
|
2020-12-30 08:32:17 +00:00
|
|
|
|
Entity.Form = 0;
|
|
|
|
|
if (CB_Form.Items.Count > 0)
|
|
|
|
|
CB_Form.SelectedIndex = 0;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
2020-12-28 19:51:25 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
var ds = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, gendersymbols, Entity.Format);
|
2018-09-03 01:02:25 +00:00
|
|
|
|
if (ds.Length == 1 && string.IsNullOrEmpty(ds[0])) // empty (Alolan Totems)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
CB_Form.Enabled = CB_Form.Visible = Label_Form.Visible = false;
|
2018-07-07 00:37:07 +00:00
|
|
|
|
else
|
|
|
|
|
CB_Form.DataSource = ds;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void SetAbilityList()
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format < 3) // no abilities
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format > 3 && FieldsLoaded) // has forms
|
2020-12-11 04:42:30 +00:00
|
|
|
|
Entity.Form = CB_Form.SelectedIndex; // update pkm field for form specific abilities
|
2017-10-03 06:13:40 +00:00
|
|
|
|
|
2017-12-22 06:55:33 +00:00
|
|
|
|
int abil = CB_Ability.SelectedIndex;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
bool tmp = FieldsLoaded;
|
|
|
|
|
FieldsLoaded = false;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
CB_Ability.DataSource = GameInfo.FilteredSources.GetAbilityList(Entity);
|
2017-12-22 06:55:33 +00:00
|
|
|
|
CB_Ability.SelectedIndex = GetSafeIndex(CB_Ability, abil); // restore original index if available
|
2018-02-27 05:22:35 +00:00
|
|
|
|
FieldsLoaded = tmp;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-12-22 06:55:33 +00:00
|
|
|
|
private static int GetSafeIndex(ComboBox cb, int index) => Math.Max(0, Math.Min(cb.Items.Count - 1, index));
|
|
|
|
|
|
2018-08-26 00:04:01 +00:00
|
|
|
|
private void UpdateIsShiny()
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2017-12-22 06:55:33 +00:00
|
|
|
|
// Recalculate shininiess
|
2019-10-27 19:57:04 +00:00
|
|
|
|
bool isShiny = Entity.IsShiny;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// Set the Controls
|
|
|
|
|
BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny;
|
2020-06-19 23:51:15 +00:00
|
|
|
|
if (Entity.Format >= 8 && (Entity.ShinyXor == 0 || Entity.FatefulEncounter || Entity.Version == (int)GameVersion.GO))
|
2020-02-14 00:51:14 +00:00
|
|
|
|
{
|
|
|
|
|
Label_IsShiny.Visible = false;
|
2019-11-25 17:27:42 +00:00
|
|
|
|
Label_IsShiny2.Visible = isShiny;
|
2020-02-14 00:51:14 +00:00
|
|
|
|
}
|
2019-11-25 17:27:42 +00:00
|
|
|
|
else
|
2020-02-14 00:51:14 +00:00
|
|
|
|
{
|
2019-11-25 17:27:42 +00:00
|
|
|
|
Label_IsShiny.Visible = isShiny;
|
2020-02-14 00:51:14 +00:00
|
|
|
|
Label_IsShiny2.Visible = false;
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// Refresh Markings (for Shiny Star if applicable)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
SetMarkings();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void SetMarkings()
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-05-27 17:24:28 +00:00
|
|
|
|
var pba = Markings;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
var markings = Entity.Markings;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
for (int i = 0; i < pba.Length; i++)
|
2020-06-20 23:23:03 +00:00
|
|
|
|
pba[i].Image = GetMarkSprite(pba[i], markings[i] != 0);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2020-06-20 23:23:03 +00:00
|
|
|
|
PB_MarkShiny.Image = GetMarkSprite(PB_MarkShiny, !BTN_Shinytize.Enabled);
|
|
|
|
|
PB_MarkCured.Image = GetMarkSprite(PB_MarkCured, CHK_Cured.Checked);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2020-12-22 06:33:48 +00:00
|
|
|
|
PB_Favorite.Image = GetMarkSprite(PB_Favorite, Entity is IFavorite {Favorite: true});
|
2019-11-16 01:34:18 +00:00
|
|
|
|
PB_Origin.Image = GetOriginSprite(Entity);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
// Colored Markings
|
|
|
|
|
if (Entity.Format < 7)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < pba.Length; i++)
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2019-02-09 21:15:37 +00:00
|
|
|
|
if (Draw.GetMarkingColor(markings[i], out Color c))
|
2017-08-13 07:21:42 +00:00
|
|
|
|
pba[i].Image = ImageUtil.ChangeAllColorTo(pba[i].Image, c);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2017-08-13 07:21:42 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
private static Image? GetOriginSprite(PKM pkm)
|
2019-11-16 01:34:18 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.Format < 6)
|
|
|
|
|
return null;
|
2020-03-17 17:34:23 +00:00
|
|
|
|
|
|
|
|
|
// Specific Markings
|
2019-11-29 19:21:35 +00:00
|
|
|
|
if (pkm.VC)
|
|
|
|
|
return Properties.Resources.gen_vc;
|
|
|
|
|
if (pkm.GO)
|
|
|
|
|
return Properties.Resources.gen_go;
|
2020-04-16 19:48:18 +00:00
|
|
|
|
if (pkm.LGPE)
|
2020-03-17 17:35:30 +00:00
|
|
|
|
return Properties.Resources.gen_gg;
|
2020-03-17 17:34:23 +00:00
|
|
|
|
|
|
|
|
|
// Lumped Generations
|
|
|
|
|
if (pkm.Gen6)
|
|
|
|
|
return Properties.Resources.gen_6;
|
|
|
|
|
if (pkm.Gen7)
|
|
|
|
|
return Properties.Resources.gen_7;
|
2021-11-20 02:23:49 +00:00
|
|
|
|
if (pkm.SWSH)
|
2020-03-17 17:34:23 +00:00
|
|
|
|
return Properties.Resources.gen_8;
|
2021-11-20 02:23:49 +00:00
|
|
|
|
if (pkm.BDSP)
|
|
|
|
|
return Properties.Resources.gen_bs;
|
2022-02-05 01:36:51 +00:00
|
|
|
|
if (pkm.LA)
|
|
|
|
|
return Properties.Resources.gen_la;
|
2020-03-17 17:34:23 +00:00
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-23 03:06:05 +00:00
|
|
|
|
private void UpdateGender() => UpdateGenderLabel(Label_Gender, Entity.GetSaneGender());
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2020-06-20 23:23:03 +00:00
|
|
|
|
private static void SetCountrySubRegion(ComboBox cb, string type)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2020-06-20 23:23:03 +00:00
|
|
|
|
int oldIndex = cb.SelectedIndex;
|
|
|
|
|
cb.DataSource = Util.GetCountryRegionList(type, GameInfo.CurrentLanguage);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2020-06-20 23:23:03 +00:00
|
|
|
|
if (oldIndex > 0 && oldIndex < cb.Items.Count)
|
|
|
|
|
cb.SelectedIndex = oldIndex;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prompted Updates of PKM //
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickFriendship(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2021-11-23 03:03:42 +00:00
|
|
|
|
var pk = Entity;
|
|
|
|
|
bool worst = ModifierKeys == Keys.Control ^ pk.IsEgg;
|
|
|
|
|
var current = int.Parse(TB_Friendship.Text);
|
|
|
|
|
var value = worst
|
|
|
|
|
? pk.IsEgg ? EggStateLegality.GetMinimumEggHatchCycles(pk) : 0
|
|
|
|
|
: pk.IsEgg ? EggStateLegality.GetMaximumEggHatchCycles(pk) : current == 255 ? pk.PersonalInfo.BaseFriendship : 255;
|
|
|
|
|
TB_Friendship.Text = value.ToString();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickLevel(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (ModifierKeys == Keys.Control)
|
|
|
|
|
((MaskedTextBox)sender).Text = "100";
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickGender(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (!Entity.PersonalInfo.IsDualGender)
|
2019-05-30 04:35:52 +00:00
|
|
|
|
return; // can't toggle
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2018-05-11 01:53:23 +00:00
|
|
|
|
int newGender = (PKX.GetGenderFromString(Label_Gender.Text) & 1) ^ 1;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format <= 2)
|
2017-09-23 23:50:38 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
Stats.SetATKIVGender(newGender);
|
2018-08-26 00:04:01 +00:00
|
|
|
|
UpdateIsShiny();
|
2017-09-23 23:50:38 +00:00
|
|
|
|
}
|
2019-10-27 19:57:04 +00:00
|
|
|
|
else if (Entity.Format <= 4)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Version = WinFormsUtil.GetIndex(CB_GameOrigin);
|
|
|
|
|
Entity.Nature = WinFormsUtil.GetIndex(CB_Nature);
|
2020-12-11 04:42:30 +00:00
|
|
|
|
Entity.Form = CB_Form.SelectedIndex;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetPIDGender(newGender);
|
|
|
|
|
TB_PID.Text = Entity.PID.ToString("X8");
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Gender = newGender;
|
2021-06-23 03:06:05 +00:00
|
|
|
|
UpdateGenderLabel(Label_Gender, newGender);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2017-10-03 06:13:40 +00:00
|
|
|
|
if (PKX.GetGenderFromString(CB_Form.Text) < 2) // Gendered Forms
|
2019-05-30 04:35:52 +00:00
|
|
|
|
CB_Form.SelectedIndex = Math.Min(newGender, CB_Form.Items.Count - 1);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
UpdatePreviewSprite?.Invoke(Label_Gender, EventArgs.Empty);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-01-04 04:07:56 +00:00
|
|
|
|
private void ClickPP(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < MovePP.Length; i++)
|
|
|
|
|
RefreshMovePP(i);
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickPPUps(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2020-05-26 23:59:47 +00:00
|
|
|
|
bool min = (ModifierKeys & Keys.Control) != 0;
|
2020-06-20 23:23:03 +00:00
|
|
|
|
static int GetValue(ListControl cb, bool zero) => zero || WinFormsUtil.GetIndex(cb) == 0 ? 0 : 3;
|
|
|
|
|
CB_PPu1.SelectedIndex = GetValue(CB_Move1, min);
|
|
|
|
|
CB_PPu2.SelectedIndex = GetValue(CB_Move2, min);
|
|
|
|
|
CB_PPu3.SelectedIndex = GetValue(CB_Move3, min);
|
|
|
|
|
CB_PPu4.SelectedIndex = GetValue(CB_Move4, min);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickMarking(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-11-14 03:25:03 +00:00
|
|
|
|
int index = Array.IndexOf(Markings, (PictureBox)sender);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.ToggleMarking(index);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
SetMarkings();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-12-05 02:38:47 +00:00
|
|
|
|
private void ClickFavorite(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
if (Entity is IFavorite pb7)
|
2018-12-05 02:38:47 +00:00
|
|
|
|
pb7.Favorite ^= true;
|
|
|
|
|
SetMarkings();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
private void ClickOT(object sender, EventArgs e) => SetDetailsOT(SaveFileRequested.Invoke(this, e));
|
|
|
|
|
private void ClickCT(object sender, EventArgs e) => SetDetailsHT(SaveFileRequested.Invoke(this, e));
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickTRGender(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (sender is not Label lbl)
|
2019-07-28 20:26:35 +00:00
|
|
|
|
return;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(lbl.Text))
|
|
|
|
|
return;
|
|
|
|
|
|
2021-07-06 15:42:15 +00:00
|
|
|
|
InvertGenderLabel(lbl);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-08-29 04:13:45 +00:00
|
|
|
|
private void ClickBall(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Ball = WinFormsUtil.GetIndex(CB_Ball);
|
2020-05-26 23:59:47 +00:00
|
|
|
|
if ((ModifierKeys & Keys.Alt) != 0)
|
2018-08-30 02:30:48 +00:00
|
|
|
|
{
|
2018-08-29 04:13:45 +00:00
|
|
|
|
CB_Ball.SelectedValue = (int)Ball.Poke;
|
2018-08-30 02:30:48 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2020-05-26 23:59:47 +00:00
|
|
|
|
if ((ModifierKeys & Keys.Shift) != 0)
|
2018-08-30 03:36:32 +00:00
|
|
|
|
{
|
2020-01-26 00:47:44 +00:00
|
|
|
|
CB_Ball.SelectedValue = BallApplicator.ApplyBallLegalByColor(Entity);
|
2018-08-30 03:36:32 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2018-08-30 02:30:48 +00:00
|
|
|
|
|
2019-10-08 01:40:09 +00:00
|
|
|
|
using var frm = new BallBrowser();
|
2019-10-27 19:57:04 +00:00
|
|
|
|
frm.LoadBalls(Entity);
|
2019-10-08 01:40:09 +00:00
|
|
|
|
frm.ShowDialog();
|
|
|
|
|
if (frm.BallChoice >= 0)
|
|
|
|
|
CB_Ball.SelectedValue = frm.BallChoice;
|
2018-08-29 04:13:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 04:49:14 +00:00
|
|
|
|
private void ClickShinyLeaf(object sender, EventArgs e) => ShinyLeaf.CheckAll(ModifierKeys != Keys.Control);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ClickMetLocation(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (HaX)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity = PreparePKM();
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality(skipMoveRepop: true);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (Legality.Valid)
|
|
|
|
|
return;
|
2017-06-30 02:32:29 +00:00
|
|
|
|
if (!SetSuggestedMetLocation())
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity = PreparePKM();
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private void ClickGT(object? sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (!GB_nOT.Visible)
|
|
|
|
|
return;
|
2019-10-02 01:12:08 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (sender == GB_OT)
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.CurrentHandler = 0;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
else if (TB_OTt2.Text.Length > 0)
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.CurrentHandler = 1;
|
2021-07-31 01:05:17 +00:00
|
|
|
|
UpadteHandlingTrainerBackground(Entity.CurrentHandler);
|
2019-10-02 01:12:08 +00:00
|
|
|
|
|
2021-11-22 03:53:13 +00:00
|
|
|
|
ReloadToFriendshipTextBox(Entity);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2019-12-04 04:12:13 +00:00
|
|
|
|
private void ClickNature(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Entity.Format < 8)
|
|
|
|
|
return;
|
|
|
|
|
if (sender == Label_Nature)
|
|
|
|
|
CB_Nature.SelectedIndex = CB_StatNature.SelectedIndex;
|
|
|
|
|
else
|
|
|
|
|
CB_StatNature.SelectedIndex = CB_Nature.SelectedIndex;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private void ClickMoves(object? sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality(skipMoveRepop: true);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (sender == GB_CurrentMoves)
|
|
|
|
|
{
|
2021-12-05 01:56:56 +00:00
|
|
|
|
bool random = ModifierKeys == Keys.Control;
|
|
|
|
|
if (!SetSuggestedMoves(random))
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (sender == GB_RelearnMoves)
|
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
if (!SetSuggestedRelearnMoves())
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateLegality();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-30 02:32:29 +00:00
|
|
|
|
private bool SetSuggestedMoves(bool random = false, bool silent = false)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
{
|
2020-04-12 23:07:59 +00:00
|
|
|
|
var m = Entity.GetMoveSet(random);
|
|
|
|
|
if (m.All(z => z == 0) || m.Length == 0)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
{
|
2017-06-30 02:32:29 +00:00
|
|
|
|
if (!silent)
|
2018-04-06 04:25:18 +00:00
|
|
|
|
WinFormsUtil.Alert(MsgPKMSuggestionFormat);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Moves.SequenceEqual(m))
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2017-06-30 02:32:29 +00:00
|
|
|
|
if (!silent)
|
|
|
|
|
{
|
2019-06-22 17:50:32 +00:00
|
|
|
|
var mv = GameInfo.Strings.Move;
|
|
|
|
|
var movestrings = m.Select(v => (uint)v >= mv.Count ? MsgProgramError : mv[v]);
|
2019-02-07 07:28:02 +00:00
|
|
|
|
var msg = string.Join(Environment.NewLine, movestrings);
|
|
|
|
|
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgPKMSuggestionMoves, msg))
|
2017-06-30 02:32:29 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetMoves(m);
|
2018-03-19 16:03:27 +00:00
|
|
|
|
FieldsLoaded = false;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
LoadMoves(Entity);
|
2020-10-18 18:02:39 +00:00
|
|
|
|
ClickPP(this, EventArgs.Empty);
|
2018-03-19 16:03:27 +00:00
|
|
|
|
FieldsLoaded = true;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 20:02:02 +00:00
|
|
|
|
private bool SetSuggestedRelearnMoves(bool silent = false)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format < 6)
|
2017-06-30 02:32:29 +00:00
|
|
|
|
return false;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-25 01:11:25 +00:00
|
|
|
|
var m = Legality.GetSuggestedRelearnMoves();
|
2019-11-27 00:12:57 +00:00
|
|
|
|
if (Entity.RelearnMoves.SequenceEqual(m) || m.Count != 4)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return false;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2017-06-30 02:32:29 +00:00
|
|
|
|
if (!silent)
|
|
|
|
|
{
|
2019-06-22 17:50:32 +00:00
|
|
|
|
var mv = GameInfo.Strings.Move;
|
|
|
|
|
var movestrings = m.Select(v => (uint)v >= mv.Count ? MsgProgramError : mv[v]);
|
2019-02-07 07:28:02 +00:00
|
|
|
|
var msg = string.Join(Environment.NewLine, movestrings);
|
|
|
|
|
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgPKMSuggestionRelearn, msg))
|
2017-06-30 02:32:29 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-02-08 00:54:56 +00:00
|
|
|
|
CB_RelearnMove1.SelectedValue = m[0];
|
|
|
|
|
CB_RelearnMove2.SelectedValue = m[1];
|
|
|
|
|
CB_RelearnMove3.SelectedValue = m[2];
|
|
|
|
|
CB_RelearnMove4.SelectedValue = m[3];
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-30 02:32:29 +00:00
|
|
|
|
private bool SetSuggestedMetLocation(bool silent = false)
|
|
|
|
|
{
|
2020-01-13 01:00:03 +00:00
|
|
|
|
var encounter = EncounterSuggestion.GetSuggestedMetInfo(Entity);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (encounter == null || (Entity.Format >= 3 && encounter.Location < 0))
|
2017-06-30 02:32:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (!silent)
|
2018-04-06 04:25:18 +00:00
|
|
|
|
WinFormsUtil.Alert(MsgPKMSuggestionNone);
|
2017-06-30 02:32:29 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-13 03:40:36 +00:00
|
|
|
|
int level = encounter.LevelMin;
|
2017-06-30 02:32:29 +00:00
|
|
|
|
int location = encounter.Location;
|
2020-01-29 00:21:38 +00:00
|
|
|
|
int minlvl = EncounterSuggestion.GetLowestLevel(Entity, encounter.LevelMin);
|
2017-06-30 02:32:29 +00:00
|
|
|
|
if (minlvl == 0)
|
|
|
|
|
minlvl = level;
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.CurrentLevel >= minlvl && Entity.Met_Level == level && Entity.Met_Location == location)
|
2020-10-08 22:01:23 +00:00
|
|
|
|
{
|
2021-07-04 06:25:09 +00:00
|
|
|
|
if (!encounter.HasGroundTile(Entity.Format) || WinFormsUtil.GetIndex(CB_GroundTile) == (int)encounter.GetSuggestedGroundTile())
|
2020-10-08 22:01:23 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-06-30 02:32:29 +00:00
|
|
|
|
if (minlvl < level)
|
|
|
|
|
minlvl = level;
|
|
|
|
|
|
|
|
|
|
if (!silent)
|
|
|
|
|
{
|
2021-06-08 03:02:57 +00:00
|
|
|
|
var suggestions = EntitySuggestionUtil.GetMetLocationSuggestionMessage(Entity, level, location, minlvl);
|
2019-02-07 07:28:02 +00:00
|
|
|
|
if (suggestions.Count <= 1) // no suggestion
|
2017-06-30 02:32:29 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2019-02-07 07:28:02 +00:00
|
|
|
|
var msg = string.Join(Environment.NewLine, suggestions);
|
|
|
|
|
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, msg) != DialogResult.Yes)
|
2017-06-30 02:32:29 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format >= 3)
|
2017-06-30 02:32:29 +00:00
|
|
|
|
{
|
2020-01-29 02:29:05 +00:00
|
|
|
|
Entity.Met_Location = location;
|
2020-01-13 03:40:36 +00:00
|
|
|
|
TB_MetLevel.Text = encounter.GetSuggestedMetLevel(Entity).ToString();
|
2017-06-30 02:32:29 +00:00
|
|
|
|
CB_MetLocation.SelectedValue = location;
|
2017-08-06 03:30:33 +00:00
|
|
|
|
|
2021-06-30 03:58:06 +00:00
|
|
|
|
if (encounter.HasGroundTile(Entity.Format))
|
2021-07-04 06:25:09 +00:00
|
|
|
|
CB_GroundTile.SelectedValue = (int)encounter.GetSuggestedGroundTile();
|
2020-10-08 22:01:23 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Gen6 && Entity.WasEgg && ModifyPKM)
|
|
|
|
|
Entity.SetHatchMemory6();
|
2017-06-30 02:32:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.CurrentLevel < minlvl)
|
2017-06-30 02:32:29 +00:00
|
|
|
|
TB_Level.Text = minlvl.ToString();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-07-06 15:42:15 +00:00
|
|
|
|
private void InvertGenderLabel(Label lbl)
|
|
|
|
|
{
|
|
|
|
|
int gender = (PKX.GetGenderFromString(lbl.Text) & 1) ^ 1;
|
|
|
|
|
UpdateGenderLabel(lbl, gender);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-23 03:06:05 +00:00
|
|
|
|
private void UpdateGenderLabel(Label c, int gender)
|
|
|
|
|
{
|
2021-07-06 15:42:15 +00:00
|
|
|
|
var symbols = gendersymbols;
|
|
|
|
|
if ((uint) gender >= symbols.Count)
|
|
|
|
|
gender = 0;
|
|
|
|
|
|
|
|
|
|
c.Text = gendersymbols[gender];
|
2021-06-23 03:06:05 +00:00
|
|
|
|
c.ForeColor = Draw.GetGenderColor(gender);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
public void UpdateIVsGB(bool skipForm)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-04-16 23:01:30 +00:00
|
|
|
|
if (!FieldsLoaded)
|
|
|
|
|
return;
|
2021-06-23 03:06:05 +00:00
|
|
|
|
UpdateGenderLabel(Label_Gender, Entity.Gender);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Species == (int)Species.Unown && !skipForm)
|
2020-12-11 04:42:30 +00:00
|
|
|
|
CB_Form.SelectedIndex = Entity.Form;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2018-08-26 00:04:01 +00:00
|
|
|
|
UpdateIsShiny();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
UpdateSprite();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateBall(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-07-21 04:32:33 +00:00
|
|
|
|
PB_Ball.Image = SpriteUtil.GetBallSprite(WinFormsUtil.GetIndex(CB_Ball));
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateEXPLevel(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-02-10 01:07:44 +00:00
|
|
|
|
if (ChangingFields)
|
2018-09-03 01:02:25 +00:00
|
|
|
|
return;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
ChangingFields = true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (sender == TB_EXP)
|
|
|
|
|
{
|
|
|
|
|
// Change the Level
|
|
|
|
|
uint EXP = Util.ToUInt32(TB_EXP.Text);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
var gr = Entity.PersonalInfo.EXPGrowth;
|
|
|
|
|
int Level = Experience.GetLevel(EXP, gr);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (Level == 100)
|
2019-11-16 01:34:18 +00:00
|
|
|
|
EXP = Experience.GetEXP(100, gr);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
TB_Level.Text = Level.ToString();
|
|
|
|
|
if (!HaX)
|
|
|
|
|
TB_EXP.Text = EXP.ToString();
|
|
|
|
|
else if (Level <= 100 && Util.ToInt32(MT_Level.Text) <= 100)
|
|
|
|
|
MT_Level.Text = Level.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Change the XP
|
|
|
|
|
int Level = Util.ToInt32((HaX ? MT_Level : TB_Level).Text);
|
2017-06-21 05:57:22 +00:00
|
|
|
|
if (Level <= 0)
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2017-06-21 05:57:22 +00:00
|
|
|
|
TB_Level.Text = "1";
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2017-06-21 05:57:22 +00:00
|
|
|
|
else if (Level > 100)
|
2017-05-24 00:46:32 +00:00
|
|
|
|
{
|
|
|
|
|
TB_Level.Text = "100";
|
|
|
|
|
if (!HaX)
|
|
|
|
|
Level = 100;
|
|
|
|
|
}
|
2018-08-26 00:04:01 +00:00
|
|
|
|
if (Level > byte.MaxValue)
|
|
|
|
|
MT_Level.Text = "255";
|
|
|
|
|
else if (Level <= 100)
|
2019-11-16 01:34:18 +00:00
|
|
|
|
TB_EXP.Text = Experience.GetEXP(Level, Entity.PersonalInfo.EXPGrowth).ToString();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
ChangingFields = false;
|
|
|
|
|
if (FieldsLoaded) // store values back
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.EXP = Util.ToUInt32(TB_EXP.Text);
|
|
|
|
|
Entity.Stat_Level = Util.ToInt32((HaX ? MT_Level : TB_Level).Text);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-11-26 23:37:44 +00:00
|
|
|
|
UpdateStats();
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateRandomPID(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format < 3)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (FieldsLoaded)
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.PID = Util.GetHexValue(TB_PID.Text);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
if (sender == Label_Gender)
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetPIDGender(Entity.Gender);
|
|
|
|
|
else if (sender == CB_Nature && Entity.Nature != WinFormsUtil.GetIndex(CB_Nature))
|
|
|
|
|
Entity.SetPIDNature(WinFormsUtil.GetIndex(CB_Nature));
|
2017-05-23 04:55:05 +00:00
|
|
|
|
else if (sender == BTN_RerollPID)
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetPIDGender(Entity.Gender);
|
|
|
|
|
else if (sender == CB_Ability && CB_Ability.SelectedIndex != Entity.PIDAbility && Entity.PIDAbility > -1)
|
|
|
|
|
Entity.SetAbilityIndex(CB_Ability.SelectedIndex);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TB_PID.Text = Entity.PID.ToString("X8");
|
|
|
|
|
if (Entity.Format >= 6 && (Entity.Gen3 || Entity.Gen4 || Entity.Gen5))
|
2017-05-23 04:55:05 +00:00
|
|
|
|
TB_EC.Text = TB_PID.Text;
|
2018-08-26 00:04:01 +00:00
|
|
|
|
Update_ID(TB_EC, e);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateRandomEC(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format < 6)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetRandomEC();
|
|
|
|
|
TB_EC.Text = Entity.EncryptionConstant.ToString("X8");
|
2018-08-26 00:04:01 +00:00
|
|
|
|
Update_ID(TB_EC, e);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void Update255_MTB(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (sender is not MaskedTextBox tb)
|
2018-08-26 00:04:01 +00:00
|
|
|
|
return;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (Util.ToInt32(tb.Text) > byte.MaxValue)
|
|
|
|
|
tb.Text = "255";
|
2022-01-03 05:35:59 +00:00
|
|
|
|
if (sender == TB_Friendship && int.TryParse(TB_Friendship.Text, out var value))
|
2018-11-26 23:42:40 +00:00
|
|
|
|
{
|
2022-01-03 05:35:59 +00:00
|
|
|
|
UpdateFromFriendshipTextBox(Entity, value);
|
2018-11-26 23:42:40 +00:00
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-03-04 04:22:57 +00:00
|
|
|
|
private void UpdateFormArgument(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (FieldsLoaded && Entity.Species == (int)Species.Alcremie)
|
|
|
|
|
UpdateSprite();
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateForm(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (CB_Form == sender && FieldsLoaded)
|
2018-11-27 00:55:16 +00:00
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
|
Entity.Form = CB_Form.SelectedIndex;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
uint EXP = Experience.GetEXP(Entity.CurrentLevel, Entity.PersonalInfo.EXPGrowth);
|
2018-11-27 00:55:16 +00:00
|
|
|
|
TB_EXP.Text = EXP.ToString();
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2018-11-26 23:37:44 +00:00
|
|
|
|
UpdateStats();
|
2017-06-18 01:37:19 +00:00
|
|
|
|
SetAbilityList();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// Gender Forms
|
2019-05-30 04:35:52 +00:00
|
|
|
|
if (WinFormsUtil.GetIndex(CB_Species) == (int)Species.Unown && FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format == 3)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetPIDUnown3(CB_Form.SelectedIndex);
|
|
|
|
|
TB_PID.Text = Entity.PID.ToString("X8");
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2019-10-27 19:57:04 +00:00
|
|
|
|
else if (Entity.Format == 2)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
int desiredForm = CB_Form.SelectedIndex;
|
2020-12-11 04:42:30 +00:00
|
|
|
|
while (Entity.Form != desiredForm)
|
2018-04-16 23:01:30 +00:00
|
|
|
|
{
|
|
|
|
|
FieldsLoaded = false;
|
2020-10-18 18:02:39 +00:00
|
|
|
|
Stats.UpdateRandomIVs(sender, EventArgs.Empty);
|
2018-04-16 23:01:30 +00:00
|
|
|
|
FieldsLoaded = true;
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-20 00:27:44 +00:00
|
|
|
|
else if (CB_Form.Enabled && PKX.GetGenderFromString(CB_Form.Text) < 2)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (CB_Form.Items.Count == 2) // actually M/F; Pumpkaboo formes in German are S,M,L,XL
|
2018-06-07 01:59:01 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Gender = CB_Form.SelectedIndex;
|
2018-06-07 01:59:01 +00:00
|
|
|
|
UpdateGender();
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-06-07 01:59:01 +00:00
|
|
|
|
else
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2018-06-07 01:59:01 +00:00
|
|
|
|
UpdateGender();
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-11-29 18:44:52 +00:00
|
|
|
|
RefreshFormArguments();
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (ChangingFields)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
2017-06-19 05:27:40 +00:00
|
|
|
|
UpdateSprite();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2019-11-29 18:44:52 +00:00
|
|
|
|
private void RefreshFormArguments()
|
|
|
|
|
{
|
2020-12-28 19:51:25 +00:00
|
|
|
|
if (Entity is not IFormArgument f)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-02-09 16:46:03 +00:00
|
|
|
|
if (FieldsLoaded)
|
|
|
|
|
FA_Form.SaveArgument(f);
|
2020-12-28 19:51:25 +00:00
|
|
|
|
FA_Form.LoadArgument(f, Entity.Species, Entity.Form, Entity.Format);
|
2019-11-29 18:44:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdatePP(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (sender is not ComboBox cb)
|
2018-03-11 02:03:09 +00:00
|
|
|
|
return;
|
|
|
|
|
int index = Array.IndexOf(Moves, cb);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (index < 0)
|
2018-03-11 02:03:09 +00:00
|
|
|
|
index = Array.IndexOf(PPUps, cb);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (index < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-01-04 04:07:56 +00:00
|
|
|
|
RefreshMovePP(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshMovePP(int index)
|
|
|
|
|
{
|
2018-03-11 02:03:09 +00:00
|
|
|
|
int move = WinFormsUtil.GetIndex(Moves[index]);
|
2020-06-20 23:23:03 +00:00
|
|
|
|
var ppUpControl = PPUps[index];
|
|
|
|
|
int ppUpCount = ppUpControl.SelectedIndex;
|
2018-03-11 02:03:09 +00:00
|
|
|
|
if (move <= 0)
|
2018-04-09 13:10:26 +00:00
|
|
|
|
{
|
2020-06-20 23:23:03 +00:00
|
|
|
|
ppUpControl.SelectedIndex = 0;
|
2018-04-09 13:10:26 +00:00
|
|
|
|
MovePP[index].Text = 0.ToString();
|
|
|
|
|
}
|
2018-03-11 02:03:09 +00:00
|
|
|
|
else
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2020-06-20 23:23:03 +00:00
|
|
|
|
MovePP[index].Text = Entity.GetMovePP(move, ppUpCount).ToString();
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdatePKRSstrain(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
// Change the PKRS Days to the legal bounds.
|
|
|
|
|
int currentDuration = CB_PKRSDays.SelectedIndex;
|
|
|
|
|
CB_PKRSDays.Items.Clear();
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
|
|
|
|
int max = (CB_PKRSStrain.SelectedIndex % 4) + 2;
|
|
|
|
|
foreach (int day in Enumerable.Range(0, max))
|
|
|
|
|
CB_PKRSDays.Items.Add(day);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// Set the days back if they're legal, else set it to 1. (0 always passes).
|
|
|
|
|
CB_PKRSDays.SelectedIndex = currentDuration < CB_PKRSDays.Items.Count ? currentDuration : 1;
|
|
|
|
|
|
2018-09-03 01:02:25 +00:00
|
|
|
|
if (CB_PKRSStrain.SelectedIndex != 0)
|
|
|
|
|
return;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// Never Infected
|
|
|
|
|
CB_PKRSDays.SelectedIndex = 0;
|
|
|
|
|
CHK_Cured.Checked = false;
|
|
|
|
|
CHK_Infected.Checked = false;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdatePKRSdays(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-09-03 01:02:25 +00:00
|
|
|
|
if (CB_PKRSDays.SelectedIndex != 0)
|
|
|
|
|
return;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// If no days are selected
|
|
|
|
|
if (CB_PKRSStrain.SelectedIndex == 0)
|
|
|
|
|
CHK_Cured.Checked = CHK_Infected.Checked = false; // No Strain = Never Cured / Infected, triggers Strain update
|
|
|
|
|
else CHK_Cured.Checked = true; // Any Strain = Cured
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdatePKRSCured(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
// Cured PokeRus is toggled
|
|
|
|
|
if (CHK_Cured.Checked)
|
|
|
|
|
{
|
|
|
|
|
// Has Had PokeRus
|
|
|
|
|
Label_PKRSdays.Visible = CB_PKRSDays.Visible = false;
|
|
|
|
|
CB_PKRSDays.SelectedIndex = 0;
|
|
|
|
|
|
|
|
|
|
Label_PKRS.Visible = CB_PKRSStrain.Visible = true;
|
|
|
|
|
CHK_Infected.Checked = true;
|
|
|
|
|
|
|
|
|
|
// If we're cured we have to have a strain infection.
|
|
|
|
|
if (CB_PKRSStrain.SelectedIndex == 0)
|
|
|
|
|
CB_PKRSStrain.SelectedIndex = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (!CHK_Infected.Checked)
|
|
|
|
|
{
|
|
|
|
|
// Not Infected, Disable the other
|
|
|
|
|
Label_PKRS.Visible = CB_PKRSStrain.Visible = false;
|
|
|
|
|
CB_PKRSStrain.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Still Infected for a duration
|
|
|
|
|
Label_PKRSdays.Visible = CB_PKRSDays.Visible = true;
|
|
|
|
|
CB_PKRSDays.SelectedValue = 1;
|
|
|
|
|
}
|
|
|
|
|
// if not cured yet, days > 0
|
|
|
|
|
if (!CHK_Cured.Checked && CHK_Infected.Checked && CB_PKRSDays.SelectedIndex == 0)
|
|
|
|
|
CB_PKRSDays.SelectedIndex++;
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
SetMarkings();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdatePKRSInfected(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-09-03 01:02:25 +00:00
|
|
|
|
if (CHK_Cured.Checked)
|
2021-03-14 23:16:55 +00:00
|
|
|
|
{
|
|
|
|
|
if (!CHK_Infected.Checked)
|
|
|
|
|
CHK_Cured.Checked = false;
|
2018-09-03 01:02:25 +00:00
|
|
|
|
return;
|
2021-03-14 23:16:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
Label_PKRS.Visible = CB_PKRSStrain.Visible = CHK_Infected.Checked;
|
2021-03-14 23:16:55 +00:00
|
|
|
|
if (!CHK_Infected.Checked)
|
|
|
|
|
{
|
|
|
|
|
CB_PKRSStrain.SelectedIndex = 0;
|
|
|
|
|
CB_PKRSDays.SelectedIndex = 0;
|
|
|
|
|
Label_PKRSdays.Visible = CB_PKRSDays.Visible = false;
|
|
|
|
|
}
|
2018-01-25 16:48:49 +00:00
|
|
|
|
else if (CB_PKRSStrain.SelectedIndex == 0)
|
|
|
|
|
{
|
|
|
|
|
CB_PKRSStrain.SelectedIndex = CB_PKRSDays.SelectedIndex = 1;
|
|
|
|
|
Label_PKRSdays.Visible = CB_PKRSDays.Visible = true;
|
|
|
|
|
UpdatePKRSCured(sender, e);
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateCountry(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2017-09-30 05:58:25 +00:00
|
|
|
|
int index;
|
|
|
|
|
if (sender is ComboBox c && (index = WinFormsUtil.GetIndex(c)) > 0)
|
|
|
|
|
SetCountrySubRegion(CB_SubRegion, $"sr_{index:000}");
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateSpecies(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
// Get Species dependent information
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (FieldsLoaded)
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Species = WinFormsUtil.GetIndex(CB_Species);
|
|
|
|
|
SpeciesIDTip.SetToolTip(CB_Species, Entity.Species.ToString("000"));
|
2017-06-18 01:37:19 +00:00
|
|
|
|
SetAbilityList();
|
|
|
|
|
SetForms();
|
2020-10-18 18:02:39 +00:00
|
|
|
|
UpdateForm(sender, EventArgs.Empty);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Recalculate EXP for Given Level
|
2019-11-16 01:34:18 +00:00
|
|
|
|
uint EXP = Experience.GetEXP(Entity.CurrentLevel, Entity.PersonalInfo.EXPGrowth);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
TB_EXP.Text = EXP.ToString();
|
|
|
|
|
|
|
|
|
|
// Check for Gender Changes
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateGender();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// If species changes and no nickname, set the new name == speciesName.
|
|
|
|
|
if (!CHK_Nicknamed.Checked)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateNickname(sender, e);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateOriginGame(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2020-06-20 23:23:03 +00:00
|
|
|
|
GameVersion version = (GameVersion)WinFormsUtil.GetIndex(CB_GameOrigin);
|
2021-04-10 17:30:10 +00:00
|
|
|
|
if (version.IsValidSavedVersion())
|
|
|
|
|
{
|
|
|
|
|
CheckMetLocationChange(version, Entity.Format);
|
|
|
|
|
if (FieldsLoaded)
|
|
|
|
|
Entity.Version = (int)version;
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-07-04 06:25:09 +00:00
|
|
|
|
// Visibility logic for Gen 4 ground tile; only show for Gen 4 Pokemon.
|
2021-06-30 03:58:06 +00:00
|
|
|
|
if (Entity is IGroundTile)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
bool g4 = Entity.Gen4;
|
2021-07-04 06:25:09 +00:00
|
|
|
|
CB_GroundTile.Visible = Label_GroundTile.Visible = g4 && Entity.Format < 7;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (!g4)
|
2021-11-22 02:36:02 +00:00
|
|
|
|
CB_GroundTile.SelectedValue = (int)GroundTileType.None;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
2018-05-24 23:53:51 +00:00
|
|
|
|
|
2021-02-10 22:02:25 +00:00
|
|
|
|
PB_Origin.Image = GetOriginSprite(Entity);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TID_Trainer.LoadIDValues(Entity);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-04-10 17:30:10 +00:00
|
|
|
|
private void CheckMetLocationChange(GameVersion version, int format)
|
2021-01-02 18:35:48 +00:00
|
|
|
|
{
|
|
|
|
|
// Does the list of locations need to be changed to another group?
|
|
|
|
|
var group = GameUtil.GetMetLocationVersionGroup(version);
|
2021-04-10 17:30:10 +00:00
|
|
|
|
if (group != origintrack || format != originFormat)
|
|
|
|
|
ReloadMetLocations(version, format);
|
2021-01-02 18:35:48 +00:00
|
|
|
|
origintrack = group;
|
2021-04-10 17:30:10 +00:00
|
|
|
|
originFormat = format;
|
2021-01-02 18:35:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-10 17:30:10 +00:00
|
|
|
|
private void ReloadMetLocations(GameVersion version, int format)
|
2018-05-24 23:53:51 +00:00
|
|
|
|
{
|
2021-04-10 17:30:10 +00:00
|
|
|
|
var metList = GameInfo.GetLocationList(version, format, egg: false);
|
2020-06-20 23:23:03 +00:00
|
|
|
|
CB_MetLocation.DataSource = new BindingSource(metList, null);
|
2021-11-24 21:14:02 +00:00
|
|
|
|
CB_MetLocation.DropDownWidth = GetWidth(metList, CB_MetLocation.Font);
|
2018-05-24 23:53:51 +00:00
|
|
|
|
|
2021-04-10 17:30:10 +00:00
|
|
|
|
var eggList = GameInfo.GetLocationList(version, format, egg: true);
|
2020-06-20 23:23:03 +00:00
|
|
|
|
CB_EggLocation.DataSource = new BindingSource(eggList, null);
|
2021-11-24 21:14:02 +00:00
|
|
|
|
CB_EggLocation.DropDownWidth = GetWidth(eggList, CB_EggLocation.Font);
|
|
|
|
|
|
2021-11-24 22:14:11 +00:00
|
|
|
|
static int GetWidth(IEnumerable<ComboItem> items, Font f) =>
|
2021-11-24 21:14:02 +00:00
|
|
|
|
items.Max(z => TextRenderer.MeasureText(z.Text, f).Width) +
|
|
|
|
|
SystemInformation.VerticalScrollBarWidth;
|
2018-05-24 23:53:51 +00:00
|
|
|
|
|
|
|
|
|
if (FieldsLoaded)
|
|
|
|
|
{
|
|
|
|
|
SetMarkings(); // Set/Remove the Nativity marking when gamegroup changes too
|
2019-10-27 19:57:04 +00:00
|
|
|
|
int metLoc = EncounterSuggestion.GetSuggestedTransferLocation(Entity);
|
2021-11-24 22:14:11 +00:00
|
|
|
|
int eggLoc = CHK_AsEgg.Checked
|
|
|
|
|
? EncounterSuggestion.GetSuggestedEncounterEggLocationEgg(format, version)
|
|
|
|
|
: Locations.GetNoneLocation(version);
|
|
|
|
|
|
2018-05-24 23:53:51 +00:00
|
|
|
|
CB_MetLocation.SelectedValue = Math.Max(0, metLoc);
|
2021-11-24 22:14:11 +00:00
|
|
|
|
CB_EggLocation.SelectedValue = eggLoc;
|
2018-05-24 23:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-09-18 02:20:24 +00:00
|
|
|
|
ValidateChildren(); // hacky validation forcing
|
2018-05-24 23:53:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateExtraByteValue(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (CB_ExtraBytes.Items.Count == 0 || sender is not MaskedTextBox mtb)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
// Changed Extra Byte's Value
|
2021-07-31 01:05:17 +00:00
|
|
|
|
var value = Util.ToInt32(mtb.Text);
|
|
|
|
|
if (value > byte.MaxValue)
|
|
|
|
|
{
|
2018-03-11 02:03:09 +00:00
|
|
|
|
mtb.Text = "255";
|
2021-07-31 01:05:17 +00:00
|
|
|
|
return; // above statement triggers the event again.
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
int offset = Convert.ToInt32(CB_ExtraBytes.Text, 16);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Data[offset] = (byte)value;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateExtraByteIndex(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (CB_ExtraBytes.Items.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
// Byte changed, need to refresh the Text box for the byte's value.
|
2021-07-31 01:05:17 +00:00
|
|
|
|
var offset = Convert.ToInt32(CB_ExtraBytes.Text, 16);
|
|
|
|
|
TB_ExtraByte.Text = Entity.Data[offset].ToString();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2022-01-26 00:45:41 +00:00
|
|
|
|
public void ChangeNature(int newNature)
|
|
|
|
|
{
|
|
|
|
|
if (Entity.Format < 3)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var cb = Entity.Format >= 8 ? CB_StatNature : CB_Nature;
|
|
|
|
|
cb.SelectedValue = newNature;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private void UpdateNatureModification(ComboBox cb, int nature)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2021-07-31 01:05:17 +00:00
|
|
|
|
string text = Stats.UpdateNatureModification(nature);
|
2019-11-18 00:00:23 +00:00
|
|
|
|
NatureTip.SetToolTip(cb, text);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateIsNicknamed(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Nickname = TB_Nickname.Text;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (CHK_Nicknamed.Checked)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
int species = WinFormsUtil.GetIndex(CB_Species);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (species < 1 || species > Entity.MaxSpeciesID)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (CHK_IsEgg.Checked)
|
|
|
|
|
species = 0; // get the egg name.
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (SpeciesName.IsNicknamedAnyLanguage(species, TB_Nickname.Text, Entity.Format))
|
2017-05-23 04:55:05 +00:00
|
|
|
|
CHK_Nicknamed.Checked = true;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateNickname(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2017-06-17 01:56:17 +00:00
|
|
|
|
if (sender == Label_Species)
|
|
|
|
|
{
|
|
|
|
|
switch (ModifierKeys)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Control: RequestShowdownImport?.Invoke(sender, e); return;
|
|
|
|
|
case Keys.Alt: RequestShowdownExport?.Invoke(sender, e); return;
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
int lang = WinFormsUtil.GetIndex(CB_Language);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-02-10 01:07:44 +00:00
|
|
|
|
if (CHK_Nicknamed.Checked)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Fetch Current Species and set it as Nickname Text
|
2017-06-18 01:37:19 +00:00
|
|
|
|
int species = WinFormsUtil.GetIndex(CB_Species);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (species < 1 || species > Entity.MaxSpeciesID)
|
2018-09-03 01:02:25 +00:00
|
|
|
|
{ TB_Nickname.Text = string.Empty; return; }
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
if (CHK_IsEgg.Checked)
|
|
|
|
|
species = 0; // get the egg name.
|
|
|
|
|
|
|
|
|
|
// If name is that of another language, don't replace the nickname
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (sender != CB_Language && species != 0 && !SpeciesName.IsNicknamedAnyLanguage(species, TB_Nickname.Text, Entity.Format))
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TB_Nickname.Text = SpeciesName.GetSpeciesNameGeneration(species, lang, Entity.Format);
|
|
|
|
|
if (Entity is GBPKM pk)
|
2018-09-03 17:30:35 +00:00
|
|
|
|
pk.SetNotNicknamed();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateNicknameClick(object sender, MouseEventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
TextBox tb = sender as TextBox ?? TB_Nickname;
|
|
|
|
|
// Special Character Form
|
|
|
|
|
if (ModifierKeys != Keys.Control)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-02-17 03:53:14 +00:00
|
|
|
|
var sav = RequestSaveFile;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
if (tb == TB_Nickname)
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Nickname = tb.Text;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
var span = Entity.Nickname_Trash;
|
|
|
|
|
var d = new TrashEditor(tb, span, sav);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
d.ShowDialog();
|
|
|
|
|
tb.Text = d.FinalString;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
d.FinalBytes.CopyTo(span);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
else if (tb == TB_OT)
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.OT_Name = tb.Text;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
var span = Entity.OT_Trash;
|
|
|
|
|
var d = new TrashEditor(tb, span, sav);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
d.ShowDialog();
|
|
|
|
|
tb.Text = d.FinalString;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
d.FinalBytes.CopyTo(span);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
else if (tb == TB_OTt2)
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.HT_Name = tb.Text;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
var span = Entity.HT_Trash;
|
|
|
|
|
var d = new TrashEditor(tb, span, sav);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
d.ShowDialog();
|
|
|
|
|
tb.Text = d.FinalString;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
d.FinalBytes.CopyTo(span);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateNotOT(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(TB_OTt2.Text))
|
|
|
|
|
{
|
2020-10-18 18:02:39 +00:00
|
|
|
|
ClickGT(GB_OT, EventArgs.Empty); // Switch CT over to OT.
|
2018-09-03 01:02:25 +00:00
|
|
|
|
Label_CTGender.Text = string.Empty;
|
2021-11-22 03:53:13 +00:00
|
|
|
|
ReloadToFriendshipTextBox(Entity);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
else if (string.IsNullOrWhiteSpace(Label_CTGender.Text))
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
Label_CTGender.Text = gendersymbols[0];
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateIsEgg(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
// Display hatch counter if it is an egg, Display Friendship if it is not.
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Label_HatchCounter.Visible = CHK_IsEgg.Checked && Entity.Format > 1;
|
|
|
|
|
Label_Friendship.Visible = !CHK_IsEgg.Checked && Entity.Format > 1;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2021-10-23 22:45:32 +00:00
|
|
|
|
if (Entity.Format == 3 && CHK_IsEgg.Checked)
|
|
|
|
|
Entity.OT_Name = TB_OT.Text; // going to be remapped
|
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.IsEgg = CHK_IsEgg.Checked;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
if (CHK_IsEgg.Checked)
|
|
|
|
|
{
|
2021-11-23 03:03:42 +00:00
|
|
|
|
TB_Friendship.Text = EggStateLegality.GetMinimumEggHatchCycles(Entity).ToString();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// If we are an egg, it won't have a met location.
|
|
|
|
|
CHK_AsEgg.Checked = true;
|
|
|
|
|
GB_EggConditions.Enabled = true;
|
|
|
|
|
|
|
|
|
|
CAL_MetDate.Value = new DateTime(2000, 01, 01);
|
|
|
|
|
|
|
|
|
|
// if egg wasn't originally obtained by OT => Link Trade, else => None
|
2020-07-06 22:32:40 +00:00
|
|
|
|
if (Entity.Format >= 4)
|
|
|
|
|
{
|
2020-10-18 18:02:39 +00:00
|
|
|
|
var sav = SaveFileRequested.Invoke(this, e);
|
|
|
|
|
bool isTraded = sav.OT != TB_OT.Text || sav.TID != Entity.TID || sav.SID != Entity.SID;
|
2021-11-22 02:47:57 +00:00
|
|
|
|
var loc = isTraded ? Locations.TradedEggLocation(sav.Generation, sav.Version) : Locations.GetNoneLocation(sav.Version);
|
2020-10-18 18:02:39 +00:00
|
|
|
|
CB_MetLocation.SelectedValue = loc;
|
2020-07-06 22:32:40 +00:00
|
|
|
|
}
|
2021-10-23 22:45:32 +00:00
|
|
|
|
else if (Entity.Format == 3)
|
|
|
|
|
{
|
|
|
|
|
CB_Language.SelectedValue = Entity.Language; // JPN
|
|
|
|
|
TB_OT.Text = Entity.OT_Name;
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-11-25 20:40:42 +00:00
|
|
|
|
CHK_Nicknamed.Checked = EggStateLegality.IsNicknameFlagSet(Entity);
|
|
|
|
|
TB_Nickname.Text = SpeciesName.GetSpeciesNameGeneration(0, WinFormsUtil.GetIndex(CB_Language), Entity.Format);
|
2017-08-06 03:30:33 +00:00
|
|
|
|
|
|
|
|
|
// Wipe egg memories
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format >= 6 && ModifyPKM)
|
|
|
|
|
Entity.ClearMemories();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
else // Not Egg
|
|
|
|
|
{
|
|
|
|
|
if (!CHK_Nicknamed.Checked)
|
2020-10-18 18:02:39 +00:00
|
|
|
|
UpdateNickname(this, EventArgs.Empty);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TB_Friendship.Text = Entity.PersonalInfo.BaseFriendship.ToString();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
if (CB_EggLocation.SelectedIndex == 0)
|
|
|
|
|
{
|
2021-12-03 00:35:35 +00:00
|
|
|
|
CAL_MetDate.Value = DateTime.Now;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
CAL_EggDate.Value = new DateTime(2000, 01, 01);
|
|
|
|
|
CHK_AsEgg.Checked = false;
|
|
|
|
|
GB_EggConditions.Enabled = false;
|
|
|
|
|
}
|
2021-12-03 00:35:35 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CAL_MetDate.Value = CAL_EggDate.Value;
|
|
|
|
|
CB_MetLocation.SelectedValue = EncounterSuggestion.GetSuggestedEggMetLocation(Entity);
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (TB_Nickname.Text == SpeciesName.GetSpeciesNameGeneration(0, WinFormsUtil.GetIndex(CB_Language), Entity.Format))
|
2017-05-23 04:55:05 +00:00
|
|
|
|
CHK_Nicknamed.Checked = false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
UpdateNickname(this, EventArgs.Empty);
|
2017-06-19 05:27:40 +00:00
|
|
|
|
UpdateSprite();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateMetAsEgg(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
GB_EggConditions.Enabled = CHK_AsEgg.Checked;
|
|
|
|
|
if (CHK_AsEgg.Checked)
|
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CAL_EggDate.Value = DateTime.Now;
|
2021-11-22 02:36:02 +00:00
|
|
|
|
|
|
|
|
|
bool isTradedEgg = Entity.IsEgg && Entity.Version != (int)RequestSaveFile.Version;
|
|
|
|
|
CB_EggLocation.SelectedValue = EncounterSuggestion.GetSuggestedEncounterEggLocationEgg(Entity, isTradedEgg);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Remove egg met data
|
|
|
|
|
CHK_IsEgg.Checked = false;
|
|
|
|
|
CAL_EggDate.Value = new DateTime(2000, 01, 01);
|
2021-11-22 02:36:02 +00:00
|
|
|
|
CB_EggLocation.SelectedValue = Locations.GetNoneLocation((GameVersion)Entity.Version);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateShinyPID(object sender, EventArgs e)
|
2017-06-03 10:02:22 +00:00
|
|
|
|
{
|
2020-10-25 17:42:48 +00:00
|
|
|
|
var changePID = Entity.Format >= 3 && (ModifierKeys & Keys.Alt) == 0;
|
|
|
|
|
UpdateShiny(changePID);
|
2017-06-03 10:02:22 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-10-25 17:42:48 +00:00
|
|
|
|
private void UpdateShiny(bool changePID)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.PID = Util.GetHexValue(TB_PID.Text);
|
|
|
|
|
Entity.Nature = WinFormsUtil.GetIndex(CB_Nature);
|
|
|
|
|
Entity.Gender = PKX.GetGenderFromString(Label_Gender.Text);
|
2020-12-11 04:42:30 +00:00
|
|
|
|
Entity.Form = CB_Form.SelectedIndex;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Version = WinFormsUtil.GetIndex(CB_GameOrigin);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format > 2)
|
2018-05-12 15:13:39 +00:00
|
|
|
|
{
|
2020-10-25 17:42:48 +00:00
|
|
|
|
var type = (ModifierKeys & ~Keys.Alt) switch
|
2017-06-03 10:02:22 +00:00
|
|
|
|
{
|
2020-10-25 17:42:48 +00:00
|
|
|
|
Keys.Shift => Shiny.AlwaysSquare,
|
|
|
|
|
Keys.Control => Shiny.AlwaysStar,
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => Shiny.Random,
|
2020-10-25 17:42:48 +00:00
|
|
|
|
};
|
|
|
|
|
if (changePID)
|
|
|
|
|
{
|
|
|
|
|
CommonEdits.SetShiny(Entity, type);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TB_PID.Text = Entity.PID.ToString("X8");
|
2017-06-03 10:02:22 +00:00
|
|
|
|
|
2020-12-11 04:42:30 +00:00
|
|
|
|
int gen = Entity.Generation;
|
2021-07-16 15:40:53 +00:00
|
|
|
|
bool pre3DS = gen is 3 or 4 or 5;
|
|
|
|
|
if (pre3DS && Entity.Format >= 6)
|
2017-06-03 10:02:22 +00:00
|
|
|
|
TB_EC.Text = TB_PID.Text;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-10-25 17:42:48 +00:00
|
|
|
|
Entity.SetShinySID(type);
|
2018-04-28 16:34:54 +00:00
|
|
|
|
TID_Trainer.UpdateSID();
|
2017-06-03 10:02:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.SetShiny();
|
|
|
|
|
Stats.LoadIVs(Entity.IVs);
|
2020-10-18 18:02:39 +00:00
|
|
|
|
Stats.UpdateIVs(this, EventArgs.Empty);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-26 00:04:01 +00:00
|
|
|
|
UpdateIsShiny();
|
2019-02-02 18:19:41 +00:00
|
|
|
|
UpdatePreviewSprite?.Invoke(this, EventArgs.Empty);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateTSV(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2020-06-19 23:59:00 +00:00
|
|
|
|
if (Entity.Format <= 2)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-04-28 16:34:54 +00:00
|
|
|
|
TID_Trainer.UpdateTSV();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.PID = Util.GetHexValue(TB_PID.Text);
|
2019-11-21 04:38:05 +00:00
|
|
|
|
var tip = $"PSV: {Entity.PSV:d4}";
|
|
|
|
|
if (Entity.IsShiny)
|
|
|
|
|
tip += $" | Xor = {Entity.ShinyXor}";
|
|
|
|
|
Tip3.SetToolTip(TB_PID, tip);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
private void Update_ID(object? sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-08-26 00:04:01 +00:00
|
|
|
|
if (!FieldsLoaded)
|
|
|
|
|
return;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
// Trim out nonhex characters
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TB_PID.Text = (Entity.PID = Util.GetHexValue(TB_PID.Text)).ToString("X8");
|
|
|
|
|
TB_EC.Text = (Entity.EncryptionConstant = Util.GetHexValue(TB_EC.Text)).ToString("X8");
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2018-08-26 00:04:01 +00:00
|
|
|
|
UpdateIsShiny();
|
2017-06-19 05:27:40 +00:00
|
|
|
|
UpdateSprite();
|
2018-07-07 00:37:07 +00:00
|
|
|
|
Stats.UpdateCharacteristic(); // If the EC is changed, EC%6 (Characteristic) might be changed.
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format <= 4)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
FieldsLoaded = false;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.PID = Util.GetHexValue(TB_PID.Text);
|
|
|
|
|
CB_Nature.SelectedValue = Entity.Nature;
|
2021-06-23 03:06:05 +00:00
|
|
|
|
UpdateGenderLabel(Label_Gender, Entity.Gender);
|
2021-10-16 01:27:16 +00:00
|
|
|
|
UpdateNatureModification(CB_Nature, Entity.Nature);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
FieldsLoaded = true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-02-13 02:10:03 +00:00
|
|
|
|
private void Update_ID64(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!FieldsLoaded)
|
|
|
|
|
return;
|
|
|
|
|
// Trim out nonhex characters
|
2020-02-13 02:52:48 +00:00
|
|
|
|
if (sender == TB_HomeTracker && Entity is IHomeTrack home)
|
2020-02-13 02:10:03 +00:00
|
|
|
|
{
|
|
|
|
|
var value = Util.GetHexValue64(TB_HomeTracker.Text);
|
2020-02-13 02:52:48 +00:00
|
|
|
|
home.Tracker = value;
|
2020-02-13 02:10:03 +00:00
|
|
|
|
TB_HomeTracker.Text = value.ToString("X16");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateShadowID(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
FLP_Purification.Visible = NUD_ShadowID.Value > 0;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdatePurification(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
FieldsLoaded = false;
|
2020-10-07 05:36:27 +00:00
|
|
|
|
var value = NUD_Purification.Value;
|
|
|
|
|
CHK_Shadow.Checked = Entity is CK3 ? value != CK3.Purified : value > 0;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
FieldsLoaded = true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateShadowCHK(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
FieldsLoaded = false;
|
2020-10-07 05:36:27 +00:00
|
|
|
|
NUD_Purification.Value = CHK_Shadow.Checked ? 1 : Entity is CK3 && NUD_ShadowID.Value != 0 ? CK3.Purified : 0;
|
2019-10-27 19:57:04 +00:00
|
|
|
|
((IShadowPKM)Entity).Purification = (int)NUD_Purification.Value;
|
2019-02-02 18:19:41 +00:00
|
|
|
|
UpdatePreviewSprite?.Invoke(this, EventArgs.Empty);
|
2018-02-27 05:22:35 +00:00
|
|
|
|
FieldsLoaded = true;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2019-02-15 08:50:23 +00:00
|
|
|
|
private void ValidateComboBox(ComboBox cb)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-05-27 17:24:28 +00:00
|
|
|
|
if (cb.Text.Length == 0 && cb.Items.Count > 0)
|
|
|
|
|
cb.SelectedIndex = 0;
|
|
|
|
|
else if (cb.SelectedValue == null)
|
2019-02-09 21:15:37 +00:00
|
|
|
|
cb.BackColor = Draw.InvalidSelection;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
else
|
|
|
|
|
cb.ResetBackColor();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ValidateComboBox(object sender, CancelEventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (sender is not ComboBox cb)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-02-15 08:50:23 +00:00
|
|
|
|
ValidateComboBox(cb);
|
2017-06-19 05:27:40 +00:00
|
|
|
|
UpdateSprite();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ValidateComboBox2(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-02-10 01:07:44 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
2018-07-07 00:37:07 +00:00
|
|
|
|
|
2020-10-18 18:02:39 +00:00
|
|
|
|
ValidateComboBox(sender, new CancelEventArgs());
|
2018-07-07 00:37:07 +00:00
|
|
|
|
if (sender == CB_Ability)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format >= 6)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
TB_AbilityNumber.Text = (1 << CB_Ability.SelectedIndex).ToString();
|
2019-10-27 19:57:04 +00:00
|
|
|
|
else if (Entity.Format <= 5 && CB_Ability.SelectedIndex < 2) // Format <= 5, not hidden
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateRandomPID(sender, e);
|
2018-07-07 00:37:07 +00:00
|
|
|
|
UpdateLegality();
|
|
|
|
|
}
|
|
|
|
|
else if (sender == CB_Nature)
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format <= 4)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateRandomPID(sender, e);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Nature = WinFormsUtil.GetIndex(CB_Nature);
|
2021-07-31 01:05:17 +00:00
|
|
|
|
UpdateNatureModification(CB_Nature, Entity.Nature);
|
2020-10-18 18:02:39 +00:00
|
|
|
|
Stats.UpdateIVs(sender, EventArgs.Empty); // updating Nature will trigger stats to update as well
|
2019-11-18 00:00:23 +00:00
|
|
|
|
UpdateLegality();
|
|
|
|
|
}
|
|
|
|
|
else if (sender == CB_StatNature)
|
|
|
|
|
{
|
|
|
|
|
Entity.StatNature = WinFormsUtil.GetIndex(CB_StatNature);
|
2021-07-31 01:05:17 +00:00
|
|
|
|
UpdateNatureModification(CB_StatNature, Entity.StatNature);
|
2020-10-18 18:02:39 +00:00
|
|
|
|
Stats.UpdateIVs(sender, EventArgs.Empty); // updating Nature will trigger stats to update as well
|
2018-07-07 00:37:07 +00:00
|
|
|
|
UpdateLegality();
|
|
|
|
|
}
|
|
|
|
|
else if (sender == CB_HeldItem)
|
|
|
|
|
{
|
|
|
|
|
UpdateLegality();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ValidateMove(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-02-10 01:07:44 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
var cb = (ComboBox) sender;
|
|
|
|
|
ValidateComboBox(cb);
|
|
|
|
|
if (Moves.Contains(cb)) // Move
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdatePP(sender, e);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
// Legality -- set all moves back (why all?)
|
|
|
|
|
Entity.Move1 = WinFormsUtil.GetIndex(CB_Move1);
|
|
|
|
|
Entity.Move2 = WinFormsUtil.GetIndex(CB_Move2);
|
|
|
|
|
Entity.Move3 = WinFormsUtil.GetIndex(CB_Move3);
|
|
|
|
|
Entity.Move4 = WinFormsUtil.GetIndex(CB_Move4);
|
|
|
|
|
if (Entity.Format >= 6)
|
|
|
|
|
{
|
|
|
|
|
Entity.RelearnMove1 = WinFormsUtil.GetIndex(CB_RelearnMove1);
|
|
|
|
|
Entity.RelearnMove2 = WinFormsUtil.GetIndex(CB_RelearnMove2);
|
|
|
|
|
Entity.RelearnMove3 = WinFormsUtil.GetIndex(CB_RelearnMove3);
|
|
|
|
|
Entity.RelearnMove4 = WinFormsUtil.GetIndex(CB_RelearnMove4);
|
|
|
|
|
}
|
2022-02-05 01:36:51 +00:00
|
|
|
|
if (Entity is PA8 pa8)
|
2022-03-06 20:01:47 +00:00
|
|
|
|
pa8.AlphaMove = (ushort)WinFormsUtil.GetIndex(CB_AlphaMastered);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality(skipMoveRepop: true);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ValidateMovePaint(object sender, DrawItemEventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-09-03 01:02:25 +00:00
|
|
|
|
if (e.Index < 0)
|
|
|
|
|
return;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-03-14 23:16:55 +00:00
|
|
|
|
var (text, value) = (ComboItem)((ComboBox)sender).Items[e.Index];
|
|
|
|
|
var valid = LegalMoveSource.CanLearn(value) && !HaX;
|
2019-05-30 04:35:52 +00:00
|
|
|
|
|
2021-07-31 01:05:17 +00:00
|
|
|
|
var current = (e.State & DrawItemState.Selected) != 0;
|
2019-05-30 04:35:52 +00:00
|
|
|
|
var brush = Draw.Brushes.GetBackground(valid, current);
|
|
|
|
|
var textColor = Draw.GetText(current);
|
|
|
|
|
|
2021-03-14 23:16:55 +00:00
|
|
|
|
DrawMoveRectangle(e, brush, text, textColor);
|
2019-05-30 04:35:52 +00:00
|
|
|
|
}
|
2019-02-10 02:44:21 +00:00
|
|
|
|
|
2019-05-30 04:35:52 +00:00
|
|
|
|
private static void DrawMoveRectangle(DrawItemEventArgs e, Brush brush, string text, Color textColor)
|
|
|
|
|
{
|
2019-02-10 02:44:21 +00:00
|
|
|
|
var rec = new Rectangle(e.Bounds.X - 1, e.Bounds.Y, e.Bounds.Width + 1, e.Bounds.Height + 0); // 1px left
|
|
|
|
|
e.Graphics.FillRectangle(brush, rec);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-02-10 02:44:21 +00:00
|
|
|
|
const TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis | TextFormatFlags.ExpandTabs | TextFormatFlags.SingleLine;
|
2019-05-30 04:35:52 +00:00
|
|
|
|
TextRenderer.DrawText(e.Graphics, text, e.Font, rec, textColor, flags);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2019-02-10 02:44:21 +00:00
|
|
|
|
private void MeasureDropDownHeight(object sender, MeasureItemEventArgs e) => e.ItemHeight = CB_RelearnMove1.ItemHeight;
|
|
|
|
|
|
2018-08-02 04:57:15 +00:00
|
|
|
|
private void ValidateMoveDropDown(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var s = (ComboBox) sender;
|
|
|
|
|
var index = Array.IndexOf(Moves, s);
|
2021-07-16 03:39:53 +00:00
|
|
|
|
|
|
|
|
|
// Populating the combobox drop-down list is deferred until the dropdown is entered into at least once.
|
|
|
|
|
// Saves some lag delays when viewing a pkm.
|
2019-05-30 04:35:52 +00:00
|
|
|
|
if (LegalMoveSource.IsMoveBoxOrdered[index])
|
2018-08-02 04:57:15 +00:00
|
|
|
|
return;
|
|
|
|
|
SetMoveDataSource(s);
|
2019-05-30 04:35:52 +00:00
|
|
|
|
LegalMoveSource.IsMoveBoxOrdered[index] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetMoveDataSource(ComboBox c)
|
|
|
|
|
{
|
|
|
|
|
var index = WinFormsUtil.GetIndex(c);
|
|
|
|
|
c.DataSource = new BindingSource(LegalMoveSource.DataSource, null);
|
|
|
|
|
c.SelectedValue = index;
|
2018-08-02 04:57:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void ValidateLocation(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-02-27 05:22:35 +00:00
|
|
|
|
if (!FieldsLoaded)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-02-15 08:50:23 +00:00
|
|
|
|
ValidateComboBox((ComboBox)sender);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.Met_Location = WinFormsUtil.GetIndex(CB_MetLocation);
|
|
|
|
|
Entity.Egg_Location = WinFormsUtil.GetIndex(CB_EggLocation);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
UpdateLegality();
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Secondary Windows for Ribbons/Amie/Memories
|
2019-10-20 03:33:37 +00:00
|
|
|
|
private void OpenRibbons(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
using var form = new RibbonEditor(Entity);
|
2019-10-20 03:33:37 +00:00
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OpenMedals(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
using var form = new SuperTrainingEditor(Entity);
|
2019-10-20 03:33:37 +00:00
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void OpenHistory(object sender, EventArgs e)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
// Write back current values
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity.HT_Name = TB_OTt2.Text;
|
|
|
|
|
Entity.OT_Name = TB_OT.Text;
|
|
|
|
|
Entity.IsEgg = CHK_IsEgg.Checked;
|
2021-11-22 03:53:13 +00:00
|
|
|
|
UpdateFromFriendshipTextBox(Entity, Util.ToInt32(TB_Friendship.Text));
|
2019-10-27 19:57:04 +00:00
|
|
|
|
using var form = new MemoryAmie(Entity);
|
2019-10-08 01:40:09 +00:00
|
|
|
|
form.ShowDialog();
|
2021-11-22 03:53:13 +00:00
|
|
|
|
ReloadToFriendshipTextBox(Entity);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-16 07:12:28 +00:00
|
|
|
|
private void B_Records_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2022-02-05 01:36:51 +00:00
|
|
|
|
if (Entity is not ITechRecord8 t)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (ModifierKeys == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
t.SetRecordFlags(Entity.Moves);
|
|
|
|
|
UpdateLegality();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using var form = new TechRecordEditor(t, Entity);
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
UpdateLegality();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void B_MoveShop_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Entity is not IMoveShop8Mastery m)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-11-16 07:22:21 +00:00
|
|
|
|
if (ModifierKeys == Keys.Shift)
|
|
|
|
|
{
|
2022-02-05 01:36:51 +00:00
|
|
|
|
m.ClearMoveShopFlags();
|
|
|
|
|
m.SetMoveShopFlags(Entity.Moves);
|
|
|
|
|
m.SetMoveShopFlagsMastered();
|
2019-11-16 07:22:21 +00:00
|
|
|
|
UpdateLegality();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 01:36:51 +00:00
|
|
|
|
using var form = new MoveShopEditor(m, m, Entity);
|
2019-11-16 07:12:28 +00:00
|
|
|
|
form.ShowDialog();
|
|
|
|
|
UpdateLegality();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Refreshes the interface for the current PKM format.
|
|
|
|
|
/// </summary>
|
2018-05-12 19:28:48 +00:00
|
|
|
|
/// <param name="sav">Save File context the editor is editing for</param>
|
|
|
|
|
/// <param name="pk">Pokémon data to edit</param>
|
2017-06-19 05:27:40 +00:00
|
|
|
|
public bool ToggleInterface(SaveFile sav, PKM pk)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Entity = sav.GetCompatiblePKM(pk);
|
|
|
|
|
ToggleInterface(Entity);
|
2017-06-21 00:57:23 +00:00
|
|
|
|
return FinalizeInterface(sav);
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-07-07 00:37:07 +00:00
|
|
|
|
private void ToggleInterface(PKM t)
|
2017-06-21 00:57:23 +00:00
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
var pb7 = t is PB7;
|
|
|
|
|
int gen = t.Format;
|
2018-07-07 00:37:07 +00:00
|
|
|
|
FLP_Purification.Visible = FLP_ShadowID.Visible = t is IShadowPKM;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
bool sizeCP = gen >= 8 || pb7;
|
|
|
|
|
FLP_SizeCP.Visible = sizeCP;
|
|
|
|
|
if (sizeCP)
|
|
|
|
|
SizeCP.ToggleVisibility(t);
|
|
|
|
|
PB_Favorite.Visible = t is IFavorite;
|
2020-06-19 23:51:15 +00:00
|
|
|
|
PB_BattleVersion.Visible = FLP_BattleVersion.Visible = t is IBattleVersion;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
BTN_History.Visible = gen >= 6 && !pb7;
|
|
|
|
|
BTN_Ribbons.Visible = gen >= 3 && !pb7;
|
2021-05-29 22:31:47 +00:00
|
|
|
|
BTN_Medals.Visible = gen is 6 or 7 && !pb7;
|
2020-10-04 21:15:13 +00:00
|
|
|
|
FLP_Country.Visible = FLP_SubRegion.Visible = FLP_3DSRegion.Visible = t is IRegionOrigin;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
FLP_OriginalNature.Visible = gen >= 8;
|
2022-02-05 01:36:51 +00:00
|
|
|
|
B_Records.Visible = t is ITechRecord8;
|
|
|
|
|
B_MoveShop.Visible = t is IMoveShop8Mastery;
|
2019-11-17 18:48:39 +00:00
|
|
|
|
CB_HTLanguage.Visible = gen >= 8;
|
2022-02-05 01:36:51 +00:00
|
|
|
|
L_AlphaMastered.Visible = CB_AlphaMastered.Visible = t is PA8;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
ToggleInterface(Entity.Format);
|
2017-06-21 00:57:23 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-08-20 01:22:07 +00:00
|
|
|
|
private void ToggleSecrets(bool hidden, int gen)
|
|
|
|
|
{
|
|
|
|
|
Label_EncryptionConstant.Visible = BTN_RerollEC.Visible = TB_EC.Visible = gen >= 6 && !hidden;
|
|
|
|
|
BTN_RerollPID.Visible = Label_PID.Visible = TB_PID.Visible = gen >= 3 && !hidden;
|
2020-03-21 17:56:15 +00:00
|
|
|
|
TB_HomeTracker.Visible = L_HomeTracker.Visible = gen >= 8 && !hidden;
|
2018-08-20 01:22:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-21 00:57:23 +00:00
|
|
|
|
private void ToggleInterface(int gen)
|
|
|
|
|
{
|
2018-08-20 01:22:07 +00:00
|
|
|
|
ToggleSecrets(HideSecretValues, gen);
|
2018-12-28 04:01:29 +00:00
|
|
|
|
GB_nOT.Visible = GB_RelearnMoves.Visible = gen >= 6;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
PB_Origin.Visible = gen >= 6;
|
2017-06-21 00:57:23 +00:00
|
|
|
|
FLP_NSparkle.Visible = L_NSparkle.Visible = CHK_NSparkle.Visible = gen == 5;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-01-01 19:29:20 +00:00
|
|
|
|
CHK_AsEgg.Visible = GB_EggConditions.Visible = PB_Mark5.Visible = PB_Mark6.Visible = gen >= 4;
|
2017-06-21 00:57:23 +00:00
|
|
|
|
FLP_ShinyLeaf.Visible = L_ShinyLeaf.Visible = ShinyLeaf.Visible = gen == 4;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2017-06-21 00:57:23 +00:00
|
|
|
|
DEV_Ability.Enabled = DEV_Ability.Visible = gen > 3 && HaX;
|
|
|
|
|
CB_Ability.Visible = !DEV_Ability.Enabled && gen >= 3;
|
|
|
|
|
FLP_Nature.Visible = gen >= 3;
|
|
|
|
|
FLP_Ability.Visible = gen >= 3;
|
|
|
|
|
GB_ExtraBytes.Visible = GB_ExtraBytes.Enabled = gen >= 3;
|
|
|
|
|
GB_Markings.Visible = gen >= 3;
|
2018-02-27 05:22:35 +00:00
|
|
|
|
CB_Form.Enabled = gen >= 3;
|
2020-12-31 23:15:22 +00:00
|
|
|
|
FA_Form.Visible = gen >= 6;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-12-26 22:52:50 +00:00
|
|
|
|
FLP_Friendship.Visible = FLP_Form.Visible = gen >= 2;
|
2017-06-21 00:57:23 +00:00
|
|
|
|
FLP_HeldItem.Visible = gen >= 2;
|
2017-09-06 16:12:56 +00:00
|
|
|
|
CHK_IsEgg.Visible = gen >= 2;
|
2017-06-21 00:57:23 +00:00
|
|
|
|
FLP_PKRS.Visible = FLP_EggPKRSRight.Visible = gen >= 2;
|
|
|
|
|
Label_OTGender.Visible = gen >= 2;
|
2018-09-30 17:16:45 +00:00
|
|
|
|
FLP_CatchRate.Visible = gen == 1;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// HaX override, needs to be after DEV_Ability enabled assignment.
|
2017-06-21 00:57:23 +00:00
|
|
|
|
TB_AbilityNumber.Visible = gen >= 6 && DEV_Ability.Enabled;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// Met Tab
|
2020-02-14 19:54:04 +00:00
|
|
|
|
L_HomeTracker.Visible = TB_HomeTracker.Visible = gen >= 8;
|
2017-06-21 00:57:23 +00:00
|
|
|
|
FLP_MetDate.Visible = gen >= 4;
|
|
|
|
|
FLP_Fateful.Visible = FLP_Ball.Visible = FLP_OriginGame.Visible = gen >= 3;
|
|
|
|
|
FLP_MetLocation.Visible = FLP_MetLevel.Visible = gen >= 2;
|
2021-07-04 06:25:09 +00:00
|
|
|
|
FLP_GroundTile.Visible = gen is 4 or 5 or 6;
|
2017-06-21 00:57:23 +00:00
|
|
|
|
FLP_TimeOfDay.Visible = gen == 2;
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2019-10-27 19:57:04 +00:00
|
|
|
|
Contest.ToggleInterface(Entity, gen);
|
|
|
|
|
Stats.ToggleInterface(Entity, gen);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2017-06-19 05:27:40 +00:00
|
|
|
|
CenterSubEditors();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-21 00:57:23 +00:00
|
|
|
|
private bool FinalizeInterface(SaveFile sav)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-02-10 01:07:44 +00:00
|
|
|
|
FieldsLoaded = false;
|
2017-06-19 05:27:40 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
bool TranslationRequired = false;
|
2017-06-21 00:57:23 +00:00
|
|
|
|
PopulateFilteredDataSources(sav);
|
2019-10-27 19:57:04 +00:00
|
|
|
|
PopulateFields(Entity);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2019-02-17 03:53:14 +00:00
|
|
|
|
// Save File Specific Limits
|
2019-10-27 19:57:04 +00:00
|
|
|
|
TB_OT.MaxLength = Entity.OTLength;
|
|
|
|
|
TB_OTt2.MaxLength = Entity.OTLength;
|
|
|
|
|
TB_Nickname.MaxLength = Entity.NickLength;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// Hide Unused Tabs
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format == 1 && tabMain.TabPages.Contains(Tab_Met))
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
tabMain.TabPages.Remove(Tab_Met);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2019-10-27 19:57:04 +00:00
|
|
|
|
else if (Entity.Format != 1 && !tabMain.TabPages.Contains(Tab_Met))
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
tabMain.TabPages.Insert(1, Tab_Met);
|
|
|
|
|
TranslationRequired = true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-14 03:25:03 +00:00
|
|
|
|
if (!HaX && sav is SAV7b)
|
|
|
|
|
{
|
|
|
|
|
FLP_HeldItem.Visible = false;
|
|
|
|
|
FLP_Country.Visible = false;
|
|
|
|
|
FLP_SubRegion.Visible = false;
|
|
|
|
|
FLP_3DSRegion.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-18 14:52:30 +00:00
|
|
|
|
if (!HaX && sav is SAV8LA)
|
|
|
|
|
{
|
|
|
|
|
FLP_HeldItem.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
// Common HaX Interface
|
2021-08-07 05:04:11 +00:00
|
|
|
|
MT_Level.Enabled = MT_Level.Visible = HaX;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
TB_Level.Visible = !HaX;
|
|
|
|
|
|
|
|
|
|
// pk2 save files do not have an Origin Game stored. Prompt the met location list to update.
|
2019-10-27 19:57:04 +00:00
|
|
|
|
if (Entity.Format == 2)
|
2021-04-10 17:30:10 +00:00
|
|
|
|
CheckMetLocationChange(GameVersion.C, Entity.Format);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
return TranslationRequired;
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-19 05:27:40 +00:00
|
|
|
|
private void CenterSubEditors()
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
// Recenter PKM SubEditors
|
2018-08-20 01:22:07 +00:00
|
|
|
|
FLP_PKMEditors.Location = new Point((tabMain.TabPages[0].Width - FLP_PKMEditors.Width) / 2, FLP_PKMEditors.Location.Y);
|
2022-02-05 01:36:51 +00:00
|
|
|
|
FLP_MoveFlags.Location = new Point((tabMain.TabPages[0].Width - FLP_MoveFlags.Width) / 2, FLP_MoveFlags.Location.Y);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
public void EnableDragDrop(DragEventHandler enter, DragEventHandler drop)
|
|
|
|
|
{
|
|
|
|
|
AllowDrop = true;
|
|
|
|
|
DragDrop += drop;
|
2020-10-18 18:02:39 +00:00
|
|
|
|
foreach (var tab in tabMain.TabPages.OfType<TabPage>())
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
tab.AllowDrop = true;
|
|
|
|
|
tab.DragEnter += enter;
|
|
|
|
|
tab.DragDrop += drop;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-22 06:55:33 +00:00
|
|
|
|
|
|
|
|
|
// ReSharper disable once FieldCanBeMadeReadOnly.Global
|
2020-04-12 20:05:29 +00:00
|
|
|
|
public Action<IBattleTemplate> LoadShowdownSet;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-04-12 20:05:29 +00:00
|
|
|
|
private void LoadShowdownSetDefault(IBattleTemplate Set)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2018-03-11 02:03:09 +00:00
|
|
|
|
var pk = PreparePKM();
|
|
|
|
|
pk.ApplySetDetails(Set);
|
|
|
|
|
PopulateFields(pk);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-02-27 05:22:35 +00:00
|
|
|
|
|
2020-06-19 23:51:15 +00:00
|
|
|
|
private void CB_BattleVersion_SelectedValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2021-01-19 02:18:42 +00:00
|
|
|
|
if (Entity is not IBattleVersion b)
|
|
|
|
|
return;
|
2022-03-06 20:01:47 +00:00
|
|
|
|
var value = (byte)WinFormsUtil.GetIndex(CB_BattleVersion);
|
|
|
|
|
b.BattleVersion = value;
|
|
|
|
|
PB_BattleVersion.Image = GetMarkSprite(PB_BattleVersion, value != 0);
|
2020-06-20 23:23:03 +00:00
|
|
|
|
}
|
2020-06-19 23:51:15 +00:00
|
|
|
|
|
2020-06-20 23:23:03 +00:00
|
|
|
|
private static Image GetMarkSprite(PictureBox p, bool opaque, double trans = 0.175)
|
|
|
|
|
{
|
|
|
|
|
var sprite = p.InitialImage;
|
|
|
|
|
return opaque ? sprite : ImageUtil.ChangeOpacity(sprite, trans);
|
2020-06-19 23:51:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-25 16:58:21 +00:00
|
|
|
|
private void ClickVersionMarking(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
tabMain.SelectedTab = Tab_Met;
|
|
|
|
|
if (sender == PB_BattleVersion)
|
|
|
|
|
CB_BattleVersion.DroppedDown = true;
|
|
|
|
|
else
|
|
|
|
|
CB_GameOrigin.DroppedDown = true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-22 17:50:32 +00:00
|
|
|
|
public void ChangeLanguage(ITrainerInfo sav, PKM pk)
|
2017-06-19 05:27:40 +00:00
|
|
|
|
{
|
|
|
|
|
// Force an update to the met locations
|
2018-03-12 01:07:48 +00:00
|
|
|
|
origintrack = GameVersion.Invalid;
|
2017-06-19 05:27:40 +00:00
|
|
|
|
|
|
|
|
|
InitializeLanguage(sav);
|
|
|
|
|
CenterSubEditors();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-19 05:27:40 +00:00
|
|
|
|
public void FlickerInterface()
|
|
|
|
|
{
|
|
|
|
|
tabMain.SelectedTab = Tab_Met; // parent tab of CB_GameOrigin
|
|
|
|
|
tabMain.SelectedTab = Tab_Main; // first tab
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-22 17:50:32 +00:00
|
|
|
|
private void InitializeLanguage(ITrainerInfo sav)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-06-22 17:50:32 +00:00
|
|
|
|
var source = GameInfo.FilteredSources;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
// Set the various ComboBox DataSources up with their allowed entries
|
2017-06-18 01:37:19 +00:00
|
|
|
|
SetCountrySubRegion(CB_Country, "countries");
|
2019-06-22 17:50:32 +00:00
|
|
|
|
CB_3DSReg.DataSource = source.ConsoleRegions;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2021-07-04 06:25:09 +00:00
|
|
|
|
CB_GroundTile.DataSource = new BindingSource(source.G4GroundTiles, null);
|
2019-06-22 17:50:32 +00:00
|
|
|
|
CB_Nature.DataSource = new BindingSource(source.Natures, null);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
CB_StatNature.DataSource = new BindingSource(source.Natures, null);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2018-02-27 05:22:35 +00:00
|
|
|
|
// Sub editors
|
|
|
|
|
Stats.InitializeDataSources();
|
|
|
|
|
|
2020-12-31 23:10:37 +00:00
|
|
|
|
PopulateFilteredDataSources(sav, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SetIfDifferentCount(IReadOnlyCollection<ComboItem> update, ComboBox exist, bool force = false)
|
|
|
|
|
{
|
|
|
|
|
if (!force && (exist.DataSource is BindingSource b && b.Count == update.Count))
|
|
|
|
|
return;
|
|
|
|
|
exist.DataSource = new BindingSource(update, null);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-12-31 23:10:37 +00:00
|
|
|
|
private void PopulateFilteredDataSources(ITrainerInfo sav, bool force = false)
|
2017-05-23 04:55:05 +00:00
|
|
|
|
{
|
2019-06-22 17:50:32 +00:00
|
|
|
|
var source = GameInfo.FilteredSources;
|
2021-01-02 20:46:46 +00:00
|
|
|
|
SetIfDifferentCount(source.Languages, CB_Language, force);
|
2019-06-22 17:50:32 +00:00
|
|
|
|
|
2020-12-31 23:10:37 +00:00
|
|
|
|
if (sav.Generation >= 2)
|
2021-01-02 18:35:48 +00:00
|
|
|
|
{
|
2021-01-02 20:46:46 +00:00
|
|
|
|
var game = (GameVersion) sav.Game;
|
|
|
|
|
if (game <= 0)
|
|
|
|
|
game = GameUtil.GetVersion(sav.Generation);
|
2021-04-10 17:30:10 +00:00
|
|
|
|
CheckMetLocationChange(game, sav.Generation);
|
2020-12-31 23:10:37 +00:00
|
|
|
|
SetIfDifferentCount(source.Items, CB_HeldItem, force);
|
2021-01-02 18:35:48 +00:00
|
|
|
|
}
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2020-12-31 23:10:37 +00:00
|
|
|
|
if (sav.Generation >= 3)
|
|
|
|
|
{
|
|
|
|
|
SetIfDifferentCount(source.Balls, CB_Ball, force);
|
|
|
|
|
SetIfDifferentCount(source.Games, CB_GameOrigin, force);
|
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
|
2020-12-31 23:10:37 +00:00
|
|
|
|
if (sav.Generation >= 4)
|
|
|
|
|
SetIfDifferentCount(source.Abilities, DEV_Ability, force);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
2020-12-31 23:10:37 +00:00
|
|
|
|
if (sav.Generation >= 8)
|
|
|
|
|
{
|
|
|
|
|
var lang = source.Languages;
|
|
|
|
|
var langWith0 = new List<ComboItem>(1 + lang.Count) {GameInfo.Sources.Empty};
|
|
|
|
|
langWith0.AddRange(lang);
|
|
|
|
|
SetIfDifferentCount(langWith0, CB_HTLanguage, force);
|
2020-06-19 23:51:15 +00:00
|
|
|
|
|
2020-12-31 23:10:37 +00:00
|
|
|
|
var game = source.Games;
|
|
|
|
|
var gamesWith0 = new List<ComboItem>(1 + game.Count) {GameInfo.Sources.Empty};
|
2021-01-01 07:13:27 +00:00
|
|
|
|
gamesWith0.AddRange(game);
|
2020-12-31 23:10:37 +00:00
|
|
|
|
SetIfDifferentCount(gamesWith0, CB_BattleVersion, force);
|
|
|
|
|
}
|
|
|
|
|
SetIfDifferentCount(source.Species, CB_Species, force);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
|
|
|
|
|
// Set the Move ComboBoxes too..
|
2019-06-22 17:50:32 +00:00
|
|
|
|
LegalMoveSource.ReloadMoves(source.Moves);
|
2018-03-11 02:03:09 +00:00
|
|
|
|
foreach (var cb in Moves.Concat(Relearn))
|
2020-12-31 23:10:37 +00:00
|
|
|
|
SetIfDifferentCount(source.Moves, cb, force);
|
2022-02-05 01:36:51 +00:00
|
|
|
|
if (sav is SAV8LA)
|
|
|
|
|
SetIfDifferentCount(source.Moves, CB_AlphaMastered, force);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|