Add more misc edits

Closes #179
Not allowing people to import a jpeg.
This commit is contained in:
Kurt
2020-05-09 09:39:35 -07:00
parent 56fd88cabb
commit 60f3fa84a3
10 changed files with 209 additions and 19 deletions

View File

@@ -130,9 +130,11 @@ public GSaveDateMD Birthday
set => value.ToBytes().CopyTo(Data, Offsets.Birthday);
}
#region Profile
public byte[] GetPhotoData()
{
var offset = Offsets.Photo;
var offset = Offsets.ProfilePhoto;
// Expect jpeg marker
if (BitConverter.ToUInt16(Data, offset) != 0xD8FF)
@@ -140,5 +142,31 @@ public byte[] GetPhotoData()
var len = BitConverter.ToInt32(Data, offset - 4);
return Data.Slice(offset, len);
}
public GSaveDateMD ProfileBirthday
{
get => Data.ToStructure<GSaveDateMD>(Offsets.ProfileBirthday, GSaveDateMD.SIZE);
set => value.ToBytes().CopyTo(Data, Offsets.ProfileBirthday);
}
public ushort ProfileFruit
{
get => BitConverter.ToUInt16(Data, Offsets.ProfileFruit);
set => BitConverter.GetBytes(value).CopyTo(Data, Offsets.ProfileFruit);
}
public GSaveDate ProfileTimestamp
{
get => Data.ToStructure<GSaveDate>(Offsets.ProfileTimestamp, GSaveDate.SIZE);
set => value.ToBytes().CopyTo(Data, Offsets.ProfileTimestamp);
}
public bool ProfileIsMakeVillage
{
get => Data[Offsets.ProfileIsMakeVillage] != 0;
set => Data[Offsets.ProfileIsMakeVillage] = (byte)(value ? 1 : 0);
}
#endregion
}
}

View File

@@ -14,7 +14,13 @@ public abstract class PersonalOffsets
public abstract int NowPoint { get; }
public abstract int TotalPoint { get; }
public abstract int Birthday { get; }
public abstract int Photo { get; }
public abstract int ProfileMain { get; }
public abstract int ProfilePhoto { get; }
public abstract int ProfileBirthday { get; }
public abstract int ProfileFruit { get; }
public abstract int ProfileTimestamp { get; }
public abstract int ProfileIsMakeVillage { get; }
public abstract int Pockets1 { get; }
public abstract int Pockets2 { get; }

View File

@@ -17,8 +17,12 @@ public sealed class PersonalOffsets10 : PersonalOffsets
public override int TotalPoint => NowPoint + 8; // Total Nook Miles Earned
public override int Birthday => Player + 0x11478;
private const int GSaveNetPlayerProfile = Player + 0x11480;
public override int Photo => GSaveNetPlayerProfile + 0x24;
public override int ProfileMain => Player + 0x11488;
public override int ProfilePhoto => ProfileMain + 0x14;
public override int ProfileBirthday => ProfileMain + 0x23040;
public override int ProfileFruit => ProfileMain + 0x23044;
public override int ProfileTimestamp => ProfileMain + 0x230B4;
public override int ProfileIsMakeVillage => ProfileMain + 0x230B8;
// end player

View File

@@ -17,8 +17,12 @@ public sealed class PersonalOffsets11 : PersonalOffsets
public override int TotalPoint => NowPoint + 8; // Total Nook Miles Earned
public override int Birthday => Player + 0x11488;
private const int GSaveNetPlayerProfile = Player + 0x11490;
public override int Photo => GSaveNetPlayerProfile + 0x24;
public override int ProfileMain => Player + 0x114A0;
public override int ProfilePhoto => ProfileMain + 0x14;
public override int ProfileBirthday => ProfileMain + 0x23058;
public override int ProfileFruit => ProfileMain + 0x2305C;
public override int ProfileTimestamp => ProfileMain + 0x230CC;
public override int ProfileIsMakeVillage => ProfileMain + 0x230D0;
// end player

View File

@@ -17,8 +17,12 @@ public sealed class PersonalOffsets12 : PersonalOffsets
public override int TotalPoint => NowPoint + 8; // Total Nook Miles Earned
public override int Birthday => Player + 0x1168C;
private const int GSaveNetPlayerProfile = Player + 0x11690;
public override int Photo => GSaveNetPlayerProfile + 0x24;
public override int ProfileMain => Player + 0x116A0;
public override int ProfilePhoto => ProfileMain + 0x14;
public override int ProfileBirthday => ProfileMain + 0x23058;
public override int ProfileFruit => ProfileMain + 0x2305C;
public override int ProfileTimestamp => ProfileMain + 0x230CC;
public override int ProfileIsMakeVillage => ProfileMain + 0x230D0;
// end player

View File

@@ -1,4 +1,5 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
@@ -14,5 +15,15 @@ public struct GSaveDate
public ushort Year { get; set; }
public byte Month { get; set; }
public byte Day { get; set; }
private GSaveDate(int year, int month, int day)
{
Year = (ushort) year;
Month = (byte) month;
Day = (byte) day;
}
public static implicit operator GSaveDate(DateTime dt) => new GSaveDate(dt.Year, dt.Month, dt.Day);
public static implicit operator DateTime(GSaveDate dt) => new DateTime(dt.Year, dt.Month, dt.Day);
}
}

View File

@@ -14,4 +14,18 @@ public struct GSaveDateMD
public byte Month { get; set; }
public byte Day { get; set; }
}
[StructLayout(LayoutKind.Sequential, Pack = 2)]
public struct GSavePlayerHandleName
{
public const int SIZE = 0xA;
private ushort ModifierId { get; set; }
public byte ModifierLevel { get; set; }
public ushort NounId { get; set; }
public byte NounLevel { get; set; }
public byte NounGenderType { get; set; }
public byte _fa0a936b { get; set; }
};
}

View File

@@ -19,6 +19,7 @@ public class FancyMarshalTests
[Fact] public void MarshalGSaveRoomFloorWall() => MarshalBytesTestS<GSaveRoomFloorWall>(GSaveRoomFloorWall.SIZE);
[Fact] public void MarshalGSaveManpu() => MarshalBytesTestS<GSavePlayerManpu>(GSavePlayerManpu.SIZE);
[Fact] public void MarshalGSavePlayerHandleName() => MarshalBytesTestS<GSavePlayerHandleName>(GSavePlayerHandleName.SIZE);
[Fact] public void MarshalGSaveFg() => MarshalBytesTest<GSaveFg>(GSaveFg.SIZE);
private static void MarshalBytesTestS<T>(int size) where T : struct

View File

@@ -33,14 +33,26 @@ private void InitializeComponent()
this.L_Birthday = new System.Windows.Forms.Label();
this.NUD_BirthMonth = new System.Windows.Forms.NumericUpDown();
this.NUD_BirthDay = new System.Windows.Forms.NumericUpDown();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.Tab_Misc = new System.Windows.Forms.TabPage();
this.Tab_Profile = new System.Windows.Forms.TabPage();
this.CAL_ProfileTimestamp = new System.Windows.Forms.DateTimePicker();
this.CHK_ProfileMadeVillage = new System.Windows.Forms.CheckBox();
this.L_ProfileSpecialtyFruit = new System.Windows.Forms.Label();
this.NUD_ProfileFruit = new System.Windows.Forms.NumericUpDown();
this.L_ProfileTimestamp = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.NUD_BirthMonth)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_BirthDay)).BeginInit();
this.tabControl1.SuspendLayout();
this.Tab_Misc.SuspendLayout();
this.Tab_Profile.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_ProfileFruit)).BeginInit();
this.SuspendLayout();
//
// B_Cancel
//
this.B_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.B_Cancel.Location = new System.Drawing.Point(272, 11);
this.B_Cancel.Location = new System.Drawing.Point(92, 156);
this.B_Cancel.Name = "B_Cancel";
this.B_Cancel.Size = new System.Drawing.Size(72, 23);
this.B_Cancel.TabIndex = 7;
@@ -51,7 +63,7 @@ private void InitializeComponent()
// B_Save
//
this.B_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.B_Save.Location = new System.Drawing.Point(350, 11);
this.B_Save.Location = new System.Drawing.Point(170, 156);
this.B_Save.Name = "B_Save";
this.B_Save.Size = new System.Drawing.Size(72, 23);
this.B_Save.TabIndex = 6;
@@ -61,7 +73,7 @@ private void InitializeComponent()
//
// L_Birthday
//
this.L_Birthday.Location = new System.Drawing.Point(12, 9);
this.L_Birthday.Location = new System.Drawing.Point(6, 3);
this.L_Birthday.Name = "L_Birthday";
this.L_Birthday.Size = new System.Drawing.Size(104, 23);
this.L_Birthday.TabIndex = 8;
@@ -71,7 +83,7 @@ private void InitializeComponent()
// NUD_BirthMonth
//
this.NUD_BirthMonth.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.NUD_BirthMonth.Location = new System.Drawing.Point(122, 12);
this.NUD_BirthMonth.Location = new System.Drawing.Point(116, 6);
this.NUD_BirthMonth.Name = "NUD_BirthMonth";
this.NUD_BirthMonth.Size = new System.Drawing.Size(37, 20);
this.NUD_BirthMonth.TabIndex = 9;
@@ -84,7 +96,7 @@ private void InitializeComponent()
// NUD_BirthDay
//
this.NUD_BirthDay.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.NUD_BirthDay.Location = new System.Drawing.Point(165, 12);
this.NUD_BirthDay.Location = new System.Drawing.Point(159, 6);
this.NUD_BirthDay.Name = "NUD_BirthDay";
this.NUD_BirthDay.Size = new System.Drawing.Size(37, 20);
this.NUD_BirthDay.TabIndex = 10;
@@ -94,16 +106,103 @@ private void InitializeComponent()
0,
0});
//
// tabControl1
//
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.Controls.Add(this.Tab_Misc);
this.tabControl1.Controls.Add(this.Tab_Profile);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(230, 138);
this.tabControl1.TabIndex = 12;
//
// Tab_Misc
//
this.Tab_Misc.Controls.Add(this.L_Birthday);
this.Tab_Misc.Controls.Add(this.NUD_BirthDay);
this.Tab_Misc.Controls.Add(this.NUD_BirthMonth);
this.Tab_Misc.Location = new System.Drawing.Point(4, 22);
this.Tab_Misc.Name = "Tab_Misc";
this.Tab_Misc.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Misc.Size = new System.Drawing.Size(222, 112);
this.Tab_Misc.TabIndex = 0;
this.Tab_Misc.Text = "Misc";
this.Tab_Misc.UseVisualStyleBackColor = true;
//
// Tab_Profile
//
this.Tab_Profile.Controls.Add(this.CAL_ProfileTimestamp);
this.Tab_Profile.Controls.Add(this.CHK_ProfileMadeVillage);
this.Tab_Profile.Controls.Add(this.L_ProfileSpecialtyFruit);
this.Tab_Profile.Controls.Add(this.NUD_ProfileFruit);
this.Tab_Profile.Controls.Add(this.L_ProfileTimestamp);
this.Tab_Profile.Location = new System.Drawing.Point(4, 22);
this.Tab_Profile.Name = "Tab_Profile";
this.Tab_Profile.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Profile.Size = new System.Drawing.Size(222, 112);
this.Tab_Profile.TabIndex = 1;
this.Tab_Profile.Text = "Profile";
this.Tab_Profile.UseVisualStyleBackColor = true;
//
// CAL_ProfileTimestamp
//
this.CAL_ProfileTimestamp.Location = new System.Drawing.Point(9, 22);
this.CAL_ProfileTimestamp.Name = "CAL_ProfileTimestamp";
this.CAL_ProfileTimestamp.Size = new System.Drawing.Size(200, 20);
this.CAL_ProfileTimestamp.TabIndex = 16;
//
// CHK_ProfileMadeVillage
//
this.CHK_ProfileMadeVillage.AutoSize = true;
this.CHK_ProfileMadeVillage.Location = new System.Drawing.Point(9, 87);
this.CHK_ProfileMadeVillage.Name = "CHK_ProfileMadeVillage";
this.CHK_ProfileMadeVillage.Size = new System.Drawing.Size(87, 17);
this.CHK_ProfileMadeVillage.TabIndex = 15;
this.CHK_ProfileMadeVillage.Text = "Made Village";
this.CHK_ProfileMadeVillage.UseVisualStyleBackColor = true;
//
// L_ProfileSpecialtyFruit
//
this.L_ProfileSpecialtyFruit.AutoSize = true;
this.L_ProfileSpecialtyFruit.Location = new System.Drawing.Point(6, 45);
this.L_ProfileSpecialtyFruit.Name = "L_ProfileSpecialtyFruit";
this.L_ProfileSpecialtyFruit.Size = new System.Drawing.Size(27, 13);
this.L_ProfileSpecialtyFruit.TabIndex = 14;
this.L_ProfileSpecialtyFruit.Text = "Fruit";
//
// NUD_ProfileFruit
//
this.NUD_ProfileFruit.Location = new System.Drawing.Point(9, 61);
this.NUD_ProfileFruit.Maximum = new decimal(new int[] {
65534,
0,
0,
0});
this.NUD_ProfileFruit.Name = "NUD_ProfileFruit";
this.NUD_ProfileFruit.Size = new System.Drawing.Size(58, 20);
this.NUD_ProfileFruit.TabIndex = 13;
//
// L_ProfileTimestamp
//
this.L_ProfileTimestamp.AutoSize = true;
this.L_ProfileTimestamp.Location = new System.Drawing.Point(6, 6);
this.L_ProfileTimestamp.Name = "L_ProfileTimestamp";
this.L_ProfileTimestamp.Size = new System.Drawing.Size(58, 13);
this.L_ProfileTimestamp.TabIndex = 12;
this.L_ProfileTimestamp.Text = "Timestamp";
//
// MiscPlayerEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(434, 46);
this.Controls.Add(this.NUD_BirthDay);
this.Controls.Add(this.NUD_BirthMonth);
this.Controls.Add(this.L_Birthday);
this.ClientSize = new System.Drawing.Size(254, 191);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.B_Cancel);
this.Controls.Add(this.B_Save);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = global::NHSE.WinForms.Properties.Resources.icon;
this.MaximizeBox = false;
this.MinimizeBox = false;
@@ -112,6 +211,11 @@ private void InitializeComponent()
this.Text = "Misc Player Detail Editor";
((System.ComponentModel.ISupportInitialize)(this.NUD_BirthMonth)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_BirthDay)).EndInit();
this.tabControl1.ResumeLayout(false);
this.Tab_Misc.ResumeLayout(false);
this.Tab_Profile.ResumeLayout(false);
this.Tab_Profile.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_ProfileFruit)).EndInit();
this.ResumeLayout(false);
}
@@ -123,5 +227,13 @@ private void InitializeComponent()
private System.Windows.Forms.Label L_Birthday;
private System.Windows.Forms.NumericUpDown NUD_BirthMonth;
private System.Windows.Forms.NumericUpDown NUD_BirthDay;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage Tab_Misc;
private System.Windows.Forms.TabPage Tab_Profile;
private System.Windows.Forms.Label L_ProfileTimestamp;
private System.Windows.Forms.Label L_ProfileSpecialtyFruit;
private System.Windows.Forms.NumericUpDown NUD_ProfileFruit;
private System.Windows.Forms.CheckBox CHK_ProfileMadeVillage;
private System.Windows.Forms.DateTimePicker CAL_ProfileTimestamp;
}
}

View File

@@ -26,7 +26,9 @@ private void LoadPlayer()
NUD_BirthDay.Value = bd.Day;
NUD_BirthMonth.Value = bd.Month;
pers.Birthday = bd;
CHK_ProfileMadeVillage.Checked = pers.ProfileIsMakeVillage;
NUD_ProfileFruit.Value = pers.ProfileFruit;
CAL_ProfileTimestamp.Value = pers.ProfileTimestamp;
}
private void B_Cancel_Click(object sender, EventArgs e) => Close();
@@ -47,6 +49,10 @@ private void SavePlayer()
bd.Month = (byte) NUD_BirthMonth.Value;
pers.Birthday = bd;
pers.ProfileBirthday = bd;
pers.ProfileIsMakeVillage = CHK_ProfileMadeVillage.Checked;
pers.ProfileFruit = (ushort)NUD_ProfileFruit.Value;
pers.ProfileTimestamp = CAL_ProfileTimestamp.Value;
}
}
}