Add Static Encounter editor

This commit is contained in:
Kurt
2016-12-04 21:43:05 -08:00
parent b70f557704
commit d3add2f95c
10 changed files with 1070 additions and 0 deletions

View File

@@ -114,6 +114,8 @@ public GARCReference getRelativeGARC(int offset, string name = "")
new GARCReference(104, "trclass"),
new GARCReference(105, "trdata"),
new GARCReference(106, "trpoke"),
new GARCReference(155, "encounterstatic"),
// Varied
new GARCReference(030, "gametext", true),

View File

@@ -252,6 +252,9 @@ private void toggleSubEditors()
romfs = new Control[] {B_GameText, B_StoryText, B_Personal, B_Evolution, B_LevelUp, B_Wild, B_MegaEvo, B_EggMove, B_Trainer, B_Item, B_Move, };
exefs = new Control[] {B_TMHM, B_TypeChart};
cro = new Control[] {B_Mart};
if (Config.Version != GameVersion.SMDEMO)
romfs = romfs.Concat(new[] {B_Static}).ToArray();
break;
default:
romfs = exefs = cro = new Control[] {new Label {Text = "No editors available."}};
@@ -898,6 +901,21 @@ private void B_Gift_Click(object sender, EventArgs e)
private void B_Static_Click(object sender, EventArgs e)
{
if (threadActive()) return;
if (Config.Generation == 7)
{
new Thread(() =>
{
var esg = Config.getGARCData("encounterstatic");
byte[][] es = esg.Files;
Invoke((Action)(() => new StaticEncounterEditor7(es).ShowDialog()));
esg.Files = es;
esg.Save();
}).Start();
return;
}
if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo,
"CRO Editing causes crashes if you do not patch the RO module.", "Continue anyway?"))
return;

View File

@@ -0,0 +1,8 @@
namespace pk3DS
{
public abstract class EncounterStatic
{
public abstract int Species { get; set; }
public abstract int HeldItem { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using System;
namespace pk3DS
{
public class EncounterGift7 : EncounterStatic
{
public const int SIZE = 0x14;
public readonly byte[] Data;
public EncounterGift7(byte[] data)
{
Data = data;
}
public override int Species
{
get { return BitConverter.ToUInt16(Data, 0x0); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0); }
}
public int Form { get { return Data[0x2]; } set { Data[0x2] = (byte)value; } }
public int Level { get { return Data[0x3]; } set { Data[0x3] = (byte)value; } }
public int Gender { get { return Data[0x4]; } set { Data[0x4] = (byte)value; } }
public override int HeldItem { get { return BitConverter.ToUInt16(Data, 0x8); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x8); } }
}
}

View File

@@ -0,0 +1,81 @@
using System;
namespace pk3DS
{
public class EncounterStatic7 : EncounterStatic
{
public const int SIZE = 0x38;
public readonly byte[] Data;
public EncounterStatic7(byte[] data)
{
Data = data;
}
public override int Species
{
get { return BitConverter.ToUInt16(Data, 0x0); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0); }
}
public int Form { get { return Data[0x2]; } set { Data[0x2] = (byte)value; } }
public int Level { get { return Data[0x3]; } set { Data[0x3] = (byte)value; } }
public override int HeldItem
{
get
{
int item = BitConverter.ToInt16(Data, 0x4);
if (item < 0) item = 0;
return item;
}
set
{
if (value == 0) value = -1;
BitConverter.GetBytes((short)value).CopyTo(Data, 0x4);
}
}
public bool ShinyLock { get { return (Data[0x6] & 2) >> 1 == 1; } set { Data[0x6] = (byte)(Data[0x6] & ~2 | (value ? 2 : 0)); } }
public int Gender { get { return (Data[0x6] & 0xC) >> 2; } set { Data[0x6] = (byte)(Data[0x6] & ~0xC | ((value & 3) << 2)); } }
public int Ability { get { return (Data[0x6] & 0x70) >> 4; } set { Data[0x6] = (byte)(Data[0x6] & ~0x70 | ((value & 7) << 4)); } }
public bool IV3 { get { return (Data[0x7] & 1) >> 0 == 1; } set { Data[0x7] = (byte)(Data[0x7] & ~1 | (value ? 1 : 0)); } }
public bool IV3_1 { get { return (Data[0x7] & 2) >> 1 == 1; } set { Data[0x7] = (byte)(Data[0x7] & ~2 | (value ? 2 : 0)); } }
public int[] RelearnMoves
{
get
{
return new int[]
{
BitConverter.ToUInt16(Data, 0xC),
BitConverter.ToUInt16(Data, 0xE),
BitConverter.ToUInt16(Data, 0x10),
BitConverter.ToUInt16(Data, 0x12),
};
}
set
{
if (value.Length != 4)
return;
for (int i = 0; i < 4; i++)
BitConverter.GetBytes((ushort)value[i]).CopyTo(Data, 0xC + i * 2);
}
}
public int[] IVs
{
get
{
return new int[]
{
(sbyte) Data[0x15], (sbyte) Data[0x16], (sbyte) Data[0x17], (sbyte) Data[0x18], (sbyte) Data[0x19], (sbyte) Data[0x1A]
};
}
set
{
if (value.Length != 6)
return;
for (int i = 0; i < 6; i++)
Data[i + 0x15] = (byte)Convert.ToSByte(value[i]);
}
}
}
}

View File

@@ -0,0 +1,59 @@
using System;
namespace pk3DS
{
public class EncounterTrade7 : EncounterStatic
{
public const int SIZE = 0x34;
public readonly byte[] Data;
public EncounterTrade7(byte[] data)
{
Data = data;
}
public override int Species
{
get { return BitConverter.ToUInt16(Data, 0x0); }
set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0); }
}
public int Form { get { return Data[0x4]; } set { Data[0x4] = (byte)value; } }
public int Level { get { return Data[0x5]; } set { Data[0x5] = (byte)value; } }
public int[] IVs
{
get
{
return new int[]
{
(sbyte) Data[0x6], (sbyte) Data[0x7], (sbyte) Data[0x8], (sbyte) Data[0x9], (sbyte) Data[0xA], (sbyte) Data[0xB]
};
}
set
{
if (value.Length != 6)
return;
for (int i = 0; i < 6; i++)
Data[i + 0x6] = (byte)Convert.ToSByte(value[i]);
}
}
public int Ability { get { return Data[0xC]; } set { Data[0xC] = (byte)value; } }
public int Nature { get { return Data[0xD]; } set { Data[0xD] = (byte)value; } }
public int Gender { get { return Data[0xE]; } set { Data[0xE] = (byte)value; } }
public int TID { get { return BitConverter.ToUInt16(Data, 0x10); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x10); } }
public int SID { get { return BitConverter.ToUInt16(Data, 0x12); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x12); } }
public override int HeldItem
{
get
{
int item = BitConverter.ToInt16(Data, 0x14);
if (item < 0) item = 0;
return item;
}
set
{
if (value == 0) value = -1;
BitConverter.GetBytes((short)value).CopyTo(Data, 0x14);
}
}
public int trGender { get { return Data[0x1A]; } set { Data[0x1A] = (byte)value; } }
}
}

View File

@@ -0,0 +1,507 @@
namespace pk3DS
{
partial class StaticEncounterEditor7
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.TC_Tabs = new System.Windows.Forms.TabControl();
this.Tab_Gifts = new System.Windows.Forms.TabPage();
this.CB_GHeldItem = new System.Windows.Forms.ComboBox();
this.L_GHeldItem = new System.Windows.Forms.Label();
this.CB_GSpecies = new System.Windows.Forms.ComboBox();
this.L_GForm = new System.Windows.Forms.Label();
this.NUD_GForm = new System.Windows.Forms.NumericUpDown();
this.L_GLevel = new System.Windows.Forms.Label();
this.L_GSpecies = new System.Windows.Forms.Label();
this.NUD_GLevel = new System.Windows.Forms.NumericUpDown();
this.LB_Gift = new System.Windows.Forms.ListBox();
this.Tab_Encounters = new System.Windows.Forms.TabPage();
this.CB_EHeldItem = new System.Windows.Forms.ComboBox();
this.L_EHeldItem = new System.Windows.Forms.Label();
this.CB_ESpecies = new System.Windows.Forms.ComboBox();
this.L_EForm = new System.Windows.Forms.Label();
this.NUD_EForm = new System.Windows.Forms.NumericUpDown();
this.L_ELevel = new System.Windows.Forms.Label();
this.L_ESpecies = new System.Windows.Forms.Label();
this.NUD_ELevel = new System.Windows.Forms.NumericUpDown();
this.LB_Encounter = new System.Windows.Forms.ListBox();
this.Tab_Trades = new System.Windows.Forms.TabPage();
this.CB_THeldItem = new System.Windows.Forms.ComboBox();
this.L_THeldItem = new System.Windows.Forms.Label();
this.CB_TSpecies = new System.Windows.Forms.ComboBox();
this.L_TForm = new System.Windows.Forms.Label();
this.NUD_TForm = new System.Windows.Forms.NumericUpDown();
this.L_TLevel = new System.Windows.Forms.Label();
this.L_TSpecies = new System.Windows.Forms.Label();
this.NUD_TLevel = new System.Windows.Forms.NumericUpDown();
this.LB_Trade = new System.Windows.Forms.ListBox();
this.B_Save = new System.Windows.Forms.Button();
this.TC_Tabs.SuspendLayout();
this.Tab_Gifts.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_GForm)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_GLevel)).BeginInit();
this.Tab_Encounters.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_EForm)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_ELevel)).BeginInit();
this.Tab_Trades.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_TForm)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_TLevel)).BeginInit();
this.SuspendLayout();
//
// TC_Tabs
//
this.TC_Tabs.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.TC_Tabs.Controls.Add(this.Tab_Gifts);
this.TC_Tabs.Controls.Add(this.Tab_Encounters);
this.TC_Tabs.Controls.Add(this.Tab_Trades);
this.TC_Tabs.Location = new System.Drawing.Point(12, 12);
this.TC_Tabs.Name = "TC_Tabs";
this.TC_Tabs.SelectedIndex = 0;
this.TC_Tabs.Size = new System.Drawing.Size(395, 347);
this.TC_Tabs.TabIndex = 0;
//
// Tab_Gifts
//
this.Tab_Gifts.Controls.Add(this.CB_GHeldItem);
this.Tab_Gifts.Controls.Add(this.L_GHeldItem);
this.Tab_Gifts.Controls.Add(this.CB_GSpecies);
this.Tab_Gifts.Controls.Add(this.L_GForm);
this.Tab_Gifts.Controls.Add(this.NUD_GForm);
this.Tab_Gifts.Controls.Add(this.L_GLevel);
this.Tab_Gifts.Controls.Add(this.L_GSpecies);
this.Tab_Gifts.Controls.Add(this.NUD_GLevel);
this.Tab_Gifts.Controls.Add(this.LB_Gift);
this.Tab_Gifts.Location = new System.Drawing.Point(4, 22);
this.Tab_Gifts.Name = "Tab_Gifts";
this.Tab_Gifts.Size = new System.Drawing.Size(387, 321);
this.Tab_Gifts.TabIndex = 2;
this.Tab_Gifts.Text = "Gifts";
this.Tab_Gifts.UseVisualStyleBackColor = true;
//
// CB_GHeldItem
//
this.CB_GHeldItem.FormattingEnabled = true;
this.CB_GHeldItem.Location = new System.Drawing.Point(230, 91);
this.CB_GHeldItem.Name = "CB_GHeldItem";
this.CB_GHeldItem.Size = new System.Drawing.Size(121, 21);
this.CB_GHeldItem.TabIndex = 8;
//
// L_GHeldItem
//
this.L_GHeldItem.Location = new System.Drawing.Point(124, 89);
this.L_GHeldItem.Name = "L_GHeldItem";
this.L_GHeldItem.Size = new System.Drawing.Size(100, 23);
this.L_GHeldItem.TabIndex = 7;
this.L_GHeldItem.Text = "Held Item:";
this.L_GHeldItem.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_GSpecies
//
this.CB_GSpecies.FormattingEnabled = true;
this.CB_GSpecies.Location = new System.Drawing.Point(230, 18);
this.CB_GSpecies.Name = "CB_GSpecies";
this.CB_GSpecies.Size = new System.Drawing.Size(121, 21);
this.CB_GSpecies.TabIndex = 6;
this.CB_GSpecies.SelectedIndexChanged += new System.EventHandler(this.changeSpecies);
//
// L_GForm
//
this.L_GForm.Location = new System.Drawing.Point(124, 62);
this.L_GForm.Name = "L_GForm";
this.L_GForm.Size = new System.Drawing.Size(100, 23);
this.L_GForm.TabIndex = 5;
this.L_GForm.Text = "Form:";
this.L_GForm.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_GForm
//
this.NUD_GForm.Location = new System.Drawing.Point(230, 65);
this.NUD_GForm.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_GForm.Name = "NUD_GForm";
this.NUD_GForm.Size = new System.Drawing.Size(48, 20);
this.NUD_GForm.TabIndex = 4;
this.NUD_GForm.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// L_GLevel
//
this.L_GLevel.Location = new System.Drawing.Point(124, 39);
this.L_GLevel.Name = "L_GLevel";
this.L_GLevel.Size = new System.Drawing.Size(100, 23);
this.L_GLevel.TabIndex = 3;
this.L_GLevel.Text = "Level:";
this.L_GLevel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// L_GSpecies
//
this.L_GSpecies.Location = new System.Drawing.Point(124, 16);
this.L_GSpecies.Name = "L_GSpecies";
this.L_GSpecies.Size = new System.Drawing.Size(100, 23);
this.L_GSpecies.TabIndex = 2;
this.L_GSpecies.Text = "Species:";
this.L_GSpecies.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_GLevel
//
this.NUD_GLevel.Location = new System.Drawing.Point(230, 42);
this.NUD_GLevel.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_GLevel.Name = "NUD_GLevel";
this.NUD_GLevel.Size = new System.Drawing.Size(48, 20);
this.NUD_GLevel.TabIndex = 1;
this.NUD_GLevel.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// LB_Gift
//
this.LB_Gift.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.LB_Gift.FormattingEnabled = true;
this.LB_Gift.Location = new System.Drawing.Point(3, 3);
this.LB_Gift.Name = "LB_Gift";
this.LB_Gift.Size = new System.Drawing.Size(115, 316);
this.LB_Gift.TabIndex = 0;
this.LB_Gift.SelectedIndexChanged += new System.EventHandler(this.LB_Gift_SelectedIndexChanged);
//
// Tab_Encounters
//
this.Tab_Encounters.Controls.Add(this.CB_EHeldItem);
this.Tab_Encounters.Controls.Add(this.L_EHeldItem);
this.Tab_Encounters.Controls.Add(this.CB_ESpecies);
this.Tab_Encounters.Controls.Add(this.L_EForm);
this.Tab_Encounters.Controls.Add(this.NUD_EForm);
this.Tab_Encounters.Controls.Add(this.L_ELevel);
this.Tab_Encounters.Controls.Add(this.L_ESpecies);
this.Tab_Encounters.Controls.Add(this.NUD_ELevel);
this.Tab_Encounters.Controls.Add(this.LB_Encounter);
this.Tab_Encounters.Location = new System.Drawing.Point(4, 22);
this.Tab_Encounters.Name = "Tab_Encounters";
this.Tab_Encounters.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Encounters.Size = new System.Drawing.Size(387, 321);
this.Tab_Encounters.TabIndex = 0;
this.Tab_Encounters.Text = "Encounters";
this.Tab_Encounters.UseVisualStyleBackColor = true;
//
// CB_EHeldItem
//
this.CB_EHeldItem.FormattingEnabled = true;
this.CB_EHeldItem.Location = new System.Drawing.Point(230, 91);
this.CB_EHeldItem.Name = "CB_EHeldItem";
this.CB_EHeldItem.Size = new System.Drawing.Size(121, 21);
this.CB_EHeldItem.TabIndex = 16;
//
// L_EHeldItem
//
this.L_EHeldItem.Location = new System.Drawing.Point(124, 89);
this.L_EHeldItem.Name = "L_EHeldItem";
this.L_EHeldItem.Size = new System.Drawing.Size(100, 23);
this.L_EHeldItem.TabIndex = 15;
this.L_EHeldItem.Text = "Held Item:";
this.L_EHeldItem.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_ESpecies
//
this.CB_ESpecies.FormattingEnabled = true;
this.CB_ESpecies.Location = new System.Drawing.Point(230, 18);
this.CB_ESpecies.Name = "CB_ESpecies";
this.CB_ESpecies.Size = new System.Drawing.Size(121, 21);
this.CB_ESpecies.TabIndex = 14;
this.CB_ESpecies.SelectedIndexChanged += new System.EventHandler(this.changeSpecies);
//
// L_EForm
//
this.L_EForm.Location = new System.Drawing.Point(124, 62);
this.L_EForm.Name = "L_EForm";
this.L_EForm.Size = new System.Drawing.Size(100, 23);
this.L_EForm.TabIndex = 13;
this.L_EForm.Text = "Form:";
this.L_EForm.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_EForm
//
this.NUD_EForm.Location = new System.Drawing.Point(230, 65);
this.NUD_EForm.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_EForm.Name = "NUD_EForm";
this.NUD_EForm.Size = new System.Drawing.Size(48, 20);
this.NUD_EForm.TabIndex = 12;
this.NUD_EForm.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// L_ELevel
//
this.L_ELevel.Location = new System.Drawing.Point(124, 39);
this.L_ELevel.Name = "L_ELevel";
this.L_ELevel.Size = new System.Drawing.Size(100, 23);
this.L_ELevel.TabIndex = 11;
this.L_ELevel.Text = "Level:";
this.L_ELevel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// L_ESpecies
//
this.L_ESpecies.Location = new System.Drawing.Point(124, 16);
this.L_ESpecies.Name = "L_ESpecies";
this.L_ESpecies.Size = new System.Drawing.Size(100, 23);
this.L_ESpecies.TabIndex = 10;
this.L_ESpecies.Text = "Species:";
this.L_ESpecies.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_ELevel
//
this.NUD_ELevel.Location = new System.Drawing.Point(230, 42);
this.NUD_ELevel.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_ELevel.Name = "NUD_ELevel";
this.NUD_ELevel.Size = new System.Drawing.Size(48, 20);
this.NUD_ELevel.TabIndex = 9;
this.NUD_ELevel.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// LB_Encounter
//
this.LB_Encounter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.LB_Encounter.FormattingEnabled = true;
this.LB_Encounter.Location = new System.Drawing.Point(3, 3);
this.LB_Encounter.Name = "LB_Encounter";
this.LB_Encounter.Size = new System.Drawing.Size(115, 316);
this.LB_Encounter.TabIndex = 1;
this.LB_Encounter.SelectedIndexChanged += new System.EventHandler(this.LB_Encounter_SelectedIndexChanged);
//
// Tab_Trades
//
this.Tab_Trades.Controls.Add(this.CB_THeldItem);
this.Tab_Trades.Controls.Add(this.L_THeldItem);
this.Tab_Trades.Controls.Add(this.CB_TSpecies);
this.Tab_Trades.Controls.Add(this.L_TForm);
this.Tab_Trades.Controls.Add(this.NUD_TForm);
this.Tab_Trades.Controls.Add(this.L_TLevel);
this.Tab_Trades.Controls.Add(this.L_TSpecies);
this.Tab_Trades.Controls.Add(this.NUD_TLevel);
this.Tab_Trades.Controls.Add(this.LB_Trade);
this.Tab_Trades.Location = new System.Drawing.Point(4, 22);
this.Tab_Trades.Name = "Tab_Trades";
this.Tab_Trades.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Trades.Size = new System.Drawing.Size(387, 321);
this.Tab_Trades.TabIndex = 1;
this.Tab_Trades.Text = "Trades";
this.Tab_Trades.UseVisualStyleBackColor = true;
//
// CB_THeldItem
//
this.CB_THeldItem.FormattingEnabled = true;
this.CB_THeldItem.Location = new System.Drawing.Point(230, 91);
this.CB_THeldItem.Name = "CB_THeldItem";
this.CB_THeldItem.Size = new System.Drawing.Size(121, 21);
this.CB_THeldItem.TabIndex = 24;
//
// L_THeldItem
//
this.L_THeldItem.Location = new System.Drawing.Point(124, 89);
this.L_THeldItem.Name = "L_THeldItem";
this.L_THeldItem.Size = new System.Drawing.Size(100, 23);
this.L_THeldItem.TabIndex = 23;
this.L_THeldItem.Text = "Held Item:";
this.L_THeldItem.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_TSpecies
//
this.CB_TSpecies.FormattingEnabled = true;
this.CB_TSpecies.Location = new System.Drawing.Point(230, 18);
this.CB_TSpecies.Name = "CB_TSpecies";
this.CB_TSpecies.Size = new System.Drawing.Size(121, 21);
this.CB_TSpecies.TabIndex = 22;
this.CB_TSpecies.SelectedIndexChanged += new System.EventHandler(this.changeSpecies);
//
// L_TForm
//
this.L_TForm.Location = new System.Drawing.Point(124, 62);
this.L_TForm.Name = "L_TForm";
this.L_TForm.Size = new System.Drawing.Size(100, 23);
this.L_TForm.TabIndex = 21;
this.L_TForm.Text = "Form:";
this.L_TForm.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_TForm
//
this.NUD_TForm.Location = new System.Drawing.Point(230, 65);
this.NUD_TForm.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_TForm.Name = "NUD_TForm";
this.NUD_TForm.Size = new System.Drawing.Size(48, 20);
this.NUD_TForm.TabIndex = 20;
this.NUD_TForm.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// L_TLevel
//
this.L_TLevel.Location = new System.Drawing.Point(124, 39);
this.L_TLevel.Name = "L_TLevel";
this.L_TLevel.Size = new System.Drawing.Size(100, 23);
this.L_TLevel.TabIndex = 19;
this.L_TLevel.Text = "Level:";
this.L_TLevel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// L_TSpecies
//
this.L_TSpecies.Location = new System.Drawing.Point(124, 16);
this.L_TSpecies.Name = "L_TSpecies";
this.L_TSpecies.Size = new System.Drawing.Size(100, 23);
this.L_TSpecies.TabIndex = 18;
this.L_TSpecies.Text = "Species:";
this.L_TSpecies.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_TLevel
//
this.NUD_TLevel.Location = new System.Drawing.Point(230, 42);
this.NUD_TLevel.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_TLevel.Name = "NUD_TLevel";
this.NUD_TLevel.Size = new System.Drawing.Size(48, 20);
this.NUD_TLevel.TabIndex = 17;
this.NUD_TLevel.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// LB_Trade
//
this.LB_Trade.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.LB_Trade.FormattingEnabled = true;
this.LB_Trade.Location = new System.Drawing.Point(3, 3);
this.LB_Trade.Name = "LB_Trade";
this.LB_Trade.Size = new System.Drawing.Size(115, 316);
this.LB_Trade.TabIndex = 2;
this.LB_Trade.SelectedIndexChanged += new System.EventHandler(this.LB_Trade_SelectedIndexChanged);
//
// B_Save
//
this.B_Save.Location = new System.Drawing.Point(328, 365);
this.B_Save.Name = "B_Save";
this.B_Save.Size = new System.Drawing.Size(75, 23);
this.B_Save.TabIndex = 1;
this.B_Save.Text = "Save";
this.B_Save.UseVisualStyleBackColor = true;
this.B_Save.Click += new System.EventHandler(this.B_Save_Click);
//
// StaticEncounterEditor7
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(419, 395);
this.Controls.Add(this.B_Save);
this.Controls.Add(this.TC_Tabs);
this.Name = "StaticEncounterEditor7";
this.Text = "StaticEncounterEditor7";
this.TC_Tabs.ResumeLayout(false);
this.Tab_Gifts.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NUD_GForm)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_GLevel)).EndInit();
this.Tab_Encounters.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NUD_EForm)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_ELevel)).EndInit();
this.Tab_Trades.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NUD_TForm)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_TLevel)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl TC_Tabs;
private System.Windows.Forms.TabPage Tab_Encounters;
private System.Windows.Forms.TabPage Tab_Trades;
private System.Windows.Forms.TabPage Tab_Gifts;
private System.Windows.Forms.ListBox LB_Gift;
private System.Windows.Forms.ListBox LB_Encounter;
private System.Windows.Forms.ListBox LB_Trade;
private System.Windows.Forms.Button B_Save;
private System.Windows.Forms.NumericUpDown NUD_GLevel;
private System.Windows.Forms.Label L_GSpecies;
private System.Windows.Forms.Label L_GForm;
private System.Windows.Forms.NumericUpDown NUD_GForm;
private System.Windows.Forms.Label L_GLevel;
private System.Windows.Forms.ComboBox CB_GSpecies;
private System.Windows.Forms.ComboBox CB_GHeldItem;
private System.Windows.Forms.Label L_GHeldItem;
private System.Windows.Forms.ComboBox CB_EHeldItem;
private System.Windows.Forms.Label L_EHeldItem;
private System.Windows.Forms.ComboBox CB_ESpecies;
private System.Windows.Forms.Label L_EForm;
private System.Windows.Forms.NumericUpDown NUD_EForm;
private System.Windows.Forms.Label L_ELevel;
private System.Windows.Forms.Label L_ESpecies;
private System.Windows.Forms.NumericUpDown NUD_ELevel;
private System.Windows.Forms.ComboBox CB_THeldItem;
private System.Windows.Forms.Label L_THeldItem;
private System.Windows.Forms.ComboBox CB_TSpecies;
private System.Windows.Forms.Label L_TForm;
private System.Windows.Forms.NumericUpDown NUD_TForm;
private System.Windows.Forms.Label L_TLevel;
private System.Windows.Forms.Label L_TSpecies;
private System.Windows.Forms.NumericUpDown NUD_TLevel;
}
}

View File

@@ -0,0 +1,239 @@
using System;
using System.Linq;
using System.Windows.Forms;
namespace pk3DS
{
public partial class StaticEncounterEditor7 : Form
{
private readonly byte[][] files;
private readonly EncounterGift7[] Gifts;
private readonly EncounterStatic7[] Encounters;
private readonly EncounterTrade7[] Trades;
private readonly string[] movelist = Main.getText(TextName.MoveNames);
private readonly string[] itemlist = Main.getText(TextName.ItemNames);
private readonly string[] specieslist = Main.getText(TextName.SpeciesNames);
private readonly string[] natures = Main.getText(TextName.Natures);
public StaticEncounterEditor7(byte[][] infiles)
{
InitializeComponent();
files = infiles;
// File 0: Gifts
{
byte[] data = files[0];
Gifts = new EncounterGift7[data.Length / EncounterGift7.SIZE];
for (int i = 0; i < data.Length; i += EncounterGift7.SIZE)
{
byte[] entry = new byte[EncounterGift7.SIZE];
Array.Copy(data, i, entry, 0, entry.Length);
Gifts[i/EncounterGift7.SIZE] = new EncounterGift7(entry);
}
}
// File 1: Encounters
{
byte[] data = files[1];
Encounters = new EncounterStatic7[data.Length / EncounterStatic7.SIZE];
for (int i = 0; i < data.Length; i += EncounterStatic7.SIZE)
{
byte[] entry = new byte[EncounterStatic7.SIZE];
Array.Copy(data, i, entry, 0, entry.Length);
Encounters[i/EncounterStatic7.SIZE] = new EncounterStatic7(entry);
}
}
// File 4: Trades
{
byte[] data = files[4];
Trades = new EncounterTrade7[data.Length / EncounterTrade7.SIZE];
for (int i = 0; i < data.Length; i += EncounterTrade7.SIZE)
{
byte[] entry = new byte[EncounterTrade7.SIZE];
Array.Copy(data, i, entry, 0, entry.Length);
Trades[i/EncounterTrade7.SIZE] = new EncounterTrade7(entry);
}
}
itemlist[0] = specieslist[0] = "(None)";
foreach (var s in specieslist)
{
CB_GSpecies.Items.Add(s);
CB_ESpecies.Items.Add(s);
CB_TSpecies.Items.Add(s);
}
foreach (var s in itemlist)
{
CB_GHeldItem.Items.Add(s);
CB_EHeldItem.Items.Add(s);
CB_THeldItem.Items.Add(s);
}
LB_Gift.Items.Clear();
LB_Encounter.Items.Clear();
LB_Trade.Items.Clear();
for (int i = 0; i < Gifts.Length; i++)
LB_Gift.Items.Add(getEntryText(Gifts[i], i));
for (int i = 0; i < Encounters.Length; i++)
LB_Encounter.Items.Add(getEntryText(Encounters[i], i));
for (int i = 0; i < Trades.Length; i++)
LB_Trade.Items.Add(getEntryText(Trades[i], i));
LB_Gift.SelectedIndex = 0;
LB_Encounter.SelectedIndex = 0;
LB_Trade.SelectedIndex = 0;
}
private int gEntry = -1;
private int eEntry = -1;
private int tEntry = -1;
private void B_Save_Click(object sender, EventArgs e)
{
setGift();
setEncounters();
setTrade();
saveData();
Close();
}
private void saveData()
{
files[0] = Gifts.SelectMany(file => file.Data).ToArray();
files[1] = Encounters.SelectMany(file => file.Data).ToArray();
files[4] = Trades.SelectMany(file => file.Data).ToArray();
}
private string getEntryText(int species, int entry)
{
return $"{entry.ToString("00")} - {specieslist[species]}";
}
private string getEntryText(EncounterStatic enc, int entry)
{
return getEntryText(enc.Species, entry);
}
private void LB_Gift_SelectedIndexChanged(object sender, EventArgs e)
{
setGift();
gEntry = LB_Gift.SelectedIndex;
getGift();
}
private void LB_Encounter_SelectedIndexChanged(object sender, EventArgs e)
{
setEncounters();
eEntry = LB_Encounter.SelectedIndex;
getEncounters();
}
private void LB_Trade_SelectedIndexChanged(object sender, EventArgs e)
{
setTrade();
tEntry = LB_Trade.SelectedIndex;
getTrade();
}
private bool loading;
private void getGift()
{
if (gEntry < 0)
return;
loading = true;
var entry = Gifts[gEntry];
CB_GSpecies.SelectedIndex = entry.Species;
CB_GHeldItem.SelectedIndex = entry.HeldItem;
NUD_GLevel.Value = entry.Level;
NUD_GForm.Value = entry.Form;
loading = false;
}
private void setGift()
{
if (gEntry < 0)
return;
var entry = Gifts[gEntry];
entry.Species = CB_GSpecies.SelectedIndex;
entry.HeldItem = CB_GHeldItem.SelectedIndex;
entry.Level = (int)NUD_GLevel.Value;
entry.Form = (int)NUD_GForm.Value;
}
private void getEncounters()
{
if (eEntry < 0)
return;
loading = true;
var entry = Encounters[eEntry];
CB_ESpecies.SelectedIndex = entry.Species;
CB_EHeldItem.SelectedIndex = entry.HeldItem;
NUD_ELevel.Value = entry.Level;
NUD_EForm.Value = entry.Form;
loading = false;
}
private void setEncounters()
{
if (eEntry < 0)
return;
var entry = Encounters[eEntry];
entry.Species = CB_ESpecies.SelectedIndex;
entry.HeldItem = CB_EHeldItem.SelectedIndex;
entry.Level = (int)NUD_ELevel.Value;
entry.Form = (int)NUD_EForm.Value;
}
private void getTrade()
{
if (tEntry < 0)
return;
loading = true;
var entry = Trades[tEntry];
CB_TSpecies.SelectedIndex = entry.Species;
CB_THeldItem.SelectedIndex = entry.HeldItem;
NUD_TLevel.Value = entry.Level;
NUD_TForm.Value = entry.Form;
loading = false;
}
private void setTrade()
{
if (tEntry < 0)
return;
var entry = Trades[tEntry];
entry.Species = CB_TSpecies.SelectedIndex;
entry.HeldItem = CB_THeldItem.SelectedIndex;
entry.Level = (int)NUD_TLevel.Value;
entry.Form = (int)NUD_TForm.Value;
}
private void changeSpecies(object sender, EventArgs e)
{
if (loading)
return;
var cb = sender as ComboBox;
if (cb == null)
return;
if (sender == CB_GSpecies)
{
var entry = Gifts[gEntry];
entry.Species = cb.SelectedIndex;
LB_Gift.Items[gEntry] = getEntryText(entry, gEntry);
}
if (sender == CB_ESpecies)
{
var entry = Encounters[eEntry];
entry.Species = cb.SelectedIndex;
LB_Encounter.Items[eEntry] = getEntryText(entry, eEntry);
}
if (sender == CB_TSpecies)
{
var entry = Trades[tEntry];
entry.Species = cb.SelectedIndex;
LB_Trade.Items[tEntry] = getEntryText(entry, tEntry);
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -66,6 +66,10 @@
<Compile Include="Game\GARCReference.cs" />
<Compile Include="Game\TextReference.cs" />
<Compile Include="Game\TextVariableCode.cs" />
<Compile Include="Structures\EncounterStatic.cs" />
<Compile Include="Structures\Gen7\EncounterGift7.cs" />
<Compile Include="Structures\Gen7\EncounterStatic7.cs" />
<Compile Include="Structures\Gen7\EncounterTrade7.cs" />
<Compile Include="Structures\TypeChart.cs" />
<Compile Include="Misc\About.cs">
<SubType>Form</SubType>
@@ -173,6 +177,12 @@
<Compile Include="Subforms\Gen6\Experimental\MapPermView.Designer.cs">
<DependentUpon>MapPermView.cs</DependentUpon>
</Compile>
<Compile Include="Subforms\Gen7\StaticEncounterEditor7.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Subforms\Gen7\StaticEncounterEditor7.Designer.cs">
<DependentUpon>StaticEncounterEditor7.cs</DependentUpon>
</Compile>
<Compile Include="Subforms\Gen7\TMEditor7.cs">
<SubType>Form</SubType>
</Compile>
@@ -399,6 +409,9 @@
<EmbeddedResource Include="Subforms\Gen6\Experimental\MapPermView.resx">
<DependentUpon>MapPermView.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Subforms\Gen7\StaticEncounterEditor7.resx">
<DependentUpon>StaticEncounterEditor7.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Subforms\Gen7\TMEditor7.resx">
<DependentUpon>TMEditor7.cs</DependentUpon>
</EmbeddedResource>