Add setting to show Gender in Gen1

Default false, current behavior.
Previous commits (years ago) would show Gender, but only current-format properties are shown now.

Fix some form scaling settings that haven't been reported, match other controls.
PKM property copy now checks if src==dest property type; for Gen6<-Gen7 markings, converting ushort -> byte can cause the conversion to fail if more than 8 bits are used. Just ignore copying the marking value, by only copying properties that have the same name AND type.
This commit is contained in:
Kurt 2024-04-16 21:01:14 -05:00
parent 2e62e41ab1
commit b60648627a
6 changed files with 21 additions and 15 deletions

View File

@ -1008,9 +1008,11 @@ static IEnumerable<Type> GetImplementingTypes(Type t)
var prop = src.GetValue(this);
if (prop is byte[] or null)
continue; // not a valid property transfer
if (pi.PropertyType != src.PropertyType)
continue; // property type mismatch (not really a 1:1 shared property)
// Write it to the destination.
ReflectUtil.SetValue(pi, result, prop);
pi.SetValue(result, prop);
}
// set shared properties for the Gen1/2 base class

View File

@ -1,5 +1,5 @@
using System;
using System.Buffers.Binary;
using static System.Buffers.Binary.BinaryPrimitives;
namespace PKHeX.Core;
@ -9,8 +9,8 @@ public class Record5(SAV5 SAV, Memory<byte> raw) : SaveBlock<SAV5>(SAV, raw)
private uint CryptoSeed // 0x1DC
{
get => BinaryPrimitives.ReadUInt32LittleEndian(Data[^4..]);
set => BinaryPrimitives.WriteUInt32LittleEndian(Data[^4..], value);
get => ReadUInt32LittleEndian(Data[^4..]);
set => WriteUInt32LittleEndian(Data[^4..], value);
}
private bool IsDecrypted;
@ -25,8 +25,8 @@ private void EnsureDecrypted(bool state = true)
public uint Revision // 0x00
{
get => BinaryPrimitives.ReadUInt32LittleEndian(Data);
set => BinaryPrimitives.WriteUInt32LittleEndian(Data, value);
get => ReadUInt32LittleEndian(Data);
set => WriteUInt32LittleEndian(Data, value);
}
public const int Record32 = 68;
@ -42,28 +42,28 @@ public uint GetRecord32(int index)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)index, Record32);
EnsureDecrypted();
return BinaryPrimitives.ReadUInt32LittleEndian(Record32Data[(index * 4)..]);
return ReadUInt32LittleEndian(Record32Data[(index * 4)..]);
}
public void SetRecord32(int index, uint value)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)index, Record32);
EnsureDecrypted();
BinaryPrimitives.WriteUInt32LittleEndian(Record32Data[(index * 4)..], value);
WriteUInt32LittleEndian(Record32Data[(index * 4)..], Math.Min(Max32, value));
}
public ushort GetRecord16(int index)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)index, Record16);
EnsureDecrypted();
return BinaryPrimitives.ReadUInt16LittleEndian(Record16Data[(index * 2)..]);
return ReadUInt16LittleEndian(Record16Data[(index * 2)..]);
}
public void SetRecord16(int index, ushort value)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)index, Record16);
EnsureDecrypted();
BinaryPrimitives.WriteUInt16LittleEndian(Record16Data[(index * 2)..], value);
WriteUInt16LittleEndian(Record16Data[(index * 2)..], Math.Min(Max16, value));
}
public enum Record5Index

View File

@ -1967,7 +1967,8 @@ private void ToggleInterface(byte format)
FLP_HeldItem.Visible = format >= 2;
CHK_IsEgg.Visible = CHK_IsEgg.TabStop = format >= 2;
FLP_PKRS.Visible = FLP_EggPKRSRight.Visible = format >= 2;
UC_Gender.Visible = UC_OTGender.Visible = UC_OTGender.TabStop = format >= 2;
UC_OTGender.Visible = UC_OTGender.TabStop = format >= 2;
UC_Gender.Visible = format >= 2 || (format == 1 && Main.Settings.EntityEditor.ShowGenderGen1);
FLP_CatchRate.Visible = format == 1;
// HaX override, needs to be after DEV_Ability enabled assignment.

View File

@ -217,8 +217,7 @@ private void InitializeComponent()
//
// PokePreview
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(148, 180);
Controls.Add(PAN_All);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

View File

@ -307,6 +307,9 @@ public sealed class EntityEditorSettings
[LocalizedDescription("When showing the list of balls to select, show the legal balls before the illegal balls rather than sorting by Ball ID.")]
public bool ShowLegalBallsFirst { get; set; } = true;
[LocalizedDescription("When showing a Generation 1 format entity, show the gender it would have if transferred to other generations.")]
public bool ShowGenderGen1 { get; set; }
}
public sealed class EncounterDatabaseSettings

View File

@ -115,8 +115,7 @@ private void InitializeComponent()
//
// SAV_Roamer6
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(414, 101);
Controls.Add(B_Save);
Controls.Add(B_Cancel);
@ -126,11 +125,13 @@ private void InitializeComponent()
Controls.Add(L_TimesEncountered);
Controls.Add(CB_Species);
Controls.Add(L_Species);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
Icon = Properties.Resources.Icon;
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
MaximizeBox = false;
MinimizeBox = false;
Name = "SAV_Roamer6";
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
Text = "Roamer Editor";
((System.ComponentModel.ISupportInitialize)NUD_TimesEncountered).EndInit();
ResumeLayout(false);