Initial Commit

Still a WIP but some stuff works.
This commit is contained in:
Kurt
2015-01-04 00:52:06 -08:00
parent 457e0bcc3e
commit a3a56275a7
22 changed files with 7413 additions and 0 deletions

20
pk3DS.sln Normal file
View File

@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pk3DS", "pk3DS\pk3DS.csproj", "{C4CB2488-2DB9-489F-8B02-A8E872C6C6AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C4CB2488-2DB9-489F-8B02-A8E872C6C6AB}.Debug|x86.ActiveCfg = Debug|x86
{C4CB2488-2DB9-489F-8B02-A8E872C6C6AB}.Debug|x86.Build.0 = Debug|x86
{C4CB2488-2DB9-489F-8B02-A8E872C6C6AB}.Release|x86.ActiveCfg = Release|x86
{C4CB2488-2DB9-489F-8B02-A8E872C6C6AB}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

1153
pk3DS/GARCTool.cs Normal file

File diff suppressed because it is too large Load Diff

120
pk3DS/Legal.cs Normal file
View File

@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pk3DS
{
class Legal
{
internal static readonly ushort[] Pouch_Items_XY = {
000,001,002,003,004,005,006,007,008,009,010,011,012,013,014,015,016,055,056,
057,058,059,060,061,062,063,064,065,066,067,068,069,070,071,072,073,074,075,
076,077,078,079,080,081,082,083,084,085,086,087,088,089,090,091,092,093,094,
099,100,101,102,103,104,105,106,107,108,109,110,112,116,117,118,119,135,136,
213,214,215,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,
233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,
252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,
271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,
290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,
309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,
492,493,494,495,496,497,498,499,500,537,538,539,540,541,542,543,544,545,546,
547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,571,
572,573,576,577,580,581,582,583,584,585,586,587,588,589,590,639,640,644,646,
647,648,649,650,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,
667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,
699,704,710,711,715,
};
internal static readonly ushort[] Pouch_Items_ORAS = {
000,001,002,003,004,005,006,007,008,009,010,011,012,013,014,015,016,055,056,
057,058,059,060,061,062,063,064,068,069,070,071,072,073,074,075,
076,077,078,079,080,081,082,083,084,085,086,087,088,089,090,091,092,093,094,
099,100,101,102,103,104,105,106,107,108,109,110,112,116,117,118,119,135,136,
213,214,215,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,
233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,
252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,
271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,
290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,
309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,
492,493,494,495,496,497,498,499,500,537,538,539,540,541,542,543,544,545,546,
547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,571,
572,573,576,577,580,581,582,583,584,585,586,587,588,589,590,639,640,644,646,
647,648,649,650,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,
667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,
699,704,710,711,715,
// ORAS
534,535,
752,753,754,755,756,757,758,759,760,761,762,763,764,767,768,769,770,
};
internal static readonly ushort[] Pouch_Key_XY = {
000,216,431,442,445,446,447,450,465,466,471,628,
629,631,632,638,641,642,643,689,695,696,697,698,
700,701,702,703,705,706,707,712,713,714,
// Illegal
716,717, // For the cheaters who want useless items...
};
internal static readonly ushort[] Pouch_Key_ORAS = {
000,216, 445,446,447, 465,466,471,628,
629,631,632,638, 697,
// Illegal
716,717,745,746,747,748,749,750, // For the cheaters who want useless items...
// ORAS
457,474,503,
718,719,
720,721,722,723,724,725,726,727,728,729,
730,731,732,733,734,735,736, 738,739,
740,741,742,743,744,
751,765,766,771,772,774,775,
};
internal static readonly ushort[] Pouch_TMHM_XY = {
0,
328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,
346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,
364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,
382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,
400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,
418,419,618,619,620,690,691,692,693,694,
420,421,422,423,424,
};
internal static readonly ushort[] Pouch_TMHM_ORAS = {
0,
328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,
346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,
364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,
382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,
400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,
418,419,618,619,620,690,691,692,693,694,
420,421,422,423,424,
// ORAS
425,737,
};
internal static readonly ushort[] Pouch_Medicine_XY = {
000,017,018,019,020,021,022,023,024,025,026,027,028,029,030,031,032,033,
034,035,036,037,038,039,040,041,042,043,044,045,046,047,048,049,050,051,
052,053,054,134,504,565,566,567,568,569,570,571,591,645,708,709,
};
internal static readonly ushort[] Pouch_Medicine_ORAS = {
000,017,018,019,020,021,022,023,024,025,026,027,028,029,030,031,032,033,
034,035,036,037,038,039,040,041,042,043,044,045,046,047,048,049,050,051,
052,053,054,134,504,565,566,567,568,569,570,571,591,645,708,709,
//ORAS
065,066,067
};
internal static readonly ushort[] Pouch_Berry_XY = {
0,149,150,151,152,153,154,155,156,157,158,159,160,161,162,
163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,
178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,
193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,686,687,688,
};
}
}

286
pk3DS/Main.Designer.cs generated Normal file
View File

@@ -0,0 +1,286 @@
namespace pk3DS
{
partial class Main
{
/// <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.B_Open = new System.Windows.Forms.Button();
this.TB_Path = new System.Windows.Forms.TextBox();
this.GB_Tools = new System.Windows.Forms.GroupBox();
this.B_StoryText = new System.Windows.Forms.Button();
this.B_Item = new System.Windows.Forms.Button();
this.B_Move = new System.Windows.Forms.Button();
this.B_Evolution = new System.Windows.Forms.Button();
this.B_Personal = new System.Windows.Forms.Button();
this.B_MegaEvo = new System.Windows.Forms.Button();
this.B_Wild = new System.Windows.Forms.Button();
this.B_Trainer = new System.Windows.Forms.Button();
this.B_GameText = new System.Windows.Forms.Button();
this.CB_Lang = new System.Windows.Forms.ComboBox();
this.L_Lang = new System.Windows.Forms.Label();
this.L_Game = new System.Windows.Forms.Label();
this.pBar1 = new System.Windows.Forms.ProgressBar();
this.L_About = new System.Windows.Forms.Label();
this.GB_Tools.SuspendLayout();
this.SuspendLayout();
//
// B_Open
//
this.B_Open.Location = new System.Drawing.Point(12, 12);
this.B_Open.Name = "B_Open";
this.B_Open.Size = new System.Drawing.Size(75, 23);
this.B_Open.TabIndex = 0;
this.B_Open.Text = "Open \'a\'";
this.B_Open.UseVisualStyleBackColor = true;
this.B_Open.Click += new System.EventHandler(this.B_Open_Click);
//
// TB_Path
//
this.TB_Path.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TB_Path.Location = new System.Drawing.Point(93, 14);
this.TB_Path.Name = "TB_Path";
this.TB_Path.ReadOnly = true;
this.TB_Path.Size = new System.Drawing.Size(244, 20);
this.TB_Path.TabIndex = 1;
//
// GB_Tools
//
this.GB_Tools.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.GB_Tools.Controls.Add(this.B_StoryText);
this.GB_Tools.Controls.Add(this.B_Item);
this.GB_Tools.Controls.Add(this.B_Move);
this.GB_Tools.Controls.Add(this.B_Evolution);
this.GB_Tools.Controls.Add(this.B_Personal);
this.GB_Tools.Controls.Add(this.B_MegaEvo);
this.GB_Tools.Controls.Add(this.B_Wild);
this.GB_Tools.Controls.Add(this.B_Trainer);
this.GB_Tools.Controls.Add(this.B_GameText);
this.GB_Tools.Enabled = false;
this.GB_Tools.Location = new System.Drawing.Point(12, 67);
this.GB_Tools.Name = "GB_Tools";
this.GB_Tools.Size = new System.Drawing.Size(325, 110);
this.GB_Tools.TabIndex = 2;
this.GB_Tools.TabStop = false;
this.GB_Tools.Text = "ROM Editing Tools";
//
// B_StoryText
//
this.B_StoryText.Location = new System.Drawing.Point(6, 48);
this.B_StoryText.Name = "B_StoryText";
this.B_StoryText.Size = new System.Drawing.Size(100, 23);
this.B_StoryText.TabIndex = 8;
this.B_StoryText.Text = "Story Text Editor";
this.B_StoryText.UseVisualStyleBackColor = true;
this.B_StoryText.Click += new System.EventHandler(this.B_StoryText_Click);
//
// B_Item
//
this.B_Item.Location = new System.Drawing.Point(218, 48);
this.B_Item.Name = "B_Item";
this.B_Item.Size = new System.Drawing.Size(100, 23);
this.B_Item.TabIndex = 7;
this.B_Item.Text = "Item Editor";
this.B_Item.UseVisualStyleBackColor = true;
this.B_Item.Click += new System.EventHandler(this.B_Item_Click);
//
// B_Move
//
this.B_Move.Location = new System.Drawing.Point(218, 19);
this.B_Move.Name = "B_Move";
this.B_Move.Size = new System.Drawing.Size(100, 23);
this.B_Move.TabIndex = 6;
this.B_Move.Text = "Move Editor";
this.B_Move.UseVisualStyleBackColor = true;
this.B_Move.Click += new System.EventHandler(this.B_Move_Click);
//
// B_Evolution
//
this.B_Evolution.Location = new System.Drawing.Point(112, 48);
this.B_Evolution.Name = "B_Evolution";
this.B_Evolution.Size = new System.Drawing.Size(100, 23);
this.B_Evolution.TabIndex = 5;
this.B_Evolution.Text = "Evolution Editor";
this.B_Evolution.UseVisualStyleBackColor = true;
this.B_Evolution.Click += new System.EventHandler(this.B_Evolution_Click);
//
// B_Personal
//
this.B_Personal.Location = new System.Drawing.Point(112, 19);
this.B_Personal.Name = "B_Personal";
this.B_Personal.Size = new System.Drawing.Size(100, 23);
this.B_Personal.TabIndex = 4;
this.B_Personal.Text = "Personal Editor";
this.B_Personal.UseVisualStyleBackColor = true;
this.B_Personal.Click += new System.EventHandler(this.B_Personal_Click);
//
// B_MegaEvo
//
this.B_MegaEvo.Location = new System.Drawing.Point(112, 77);
this.B_MegaEvo.Name = "B_MegaEvo";
this.B_MegaEvo.Size = new System.Drawing.Size(100, 23);
this.B_MegaEvo.TabIndex = 3;
this.B_MegaEvo.Text = "Mega Evo Editor";
this.B_MegaEvo.UseVisualStyleBackColor = true;
this.B_MegaEvo.Click += new System.EventHandler(this.B_MegaEvo_Click);
//
// B_Wild
//
this.B_Wild.Location = new System.Drawing.Point(6, 77);
this.B_Wild.Name = "B_Wild";
this.B_Wild.Size = new System.Drawing.Size(100, 23);
this.B_Wild.TabIndex = 2;
this.B_Wild.Text = "Wild Editor";
this.B_Wild.UseVisualStyleBackColor = true;
this.B_Wild.Click += new System.EventHandler(this.B_Wild_Click);
//
// B_Trainer
//
this.B_Trainer.Location = new System.Drawing.Point(218, 77);
this.B_Trainer.Name = "B_Trainer";
this.B_Trainer.Size = new System.Drawing.Size(100, 23);
this.B_Trainer.TabIndex = 1;
this.B_Trainer.Text = "Trainer Editor";
this.B_Trainer.UseVisualStyleBackColor = true;
this.B_Trainer.Click += new System.EventHandler(this.B_Trainer_Click);
//
// B_GameText
//
this.B_GameText.Location = new System.Drawing.Point(6, 19);
this.B_GameText.Name = "B_GameText";
this.B_GameText.Size = new System.Drawing.Size(100, 23);
this.B_GameText.TabIndex = 0;
this.B_GameText.Text = "Game Text Editor";
this.B_GameText.UseVisualStyleBackColor = true;
this.B_GameText.Click += new System.EventHandler(this.B_GameText_Click);
//
// CB_Lang
//
this.CB_Lang.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.CB_Lang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_Lang.FormattingEnabled = true;
this.CB_Lang.Items.AddRange(new object[] {
"カタカナ",
"漢字",
"English",
"Français",
"Italiano",
"Deutsch",
"Español",
"한국"});
this.CB_Lang.Location = new System.Drawing.Point(216, 40);
this.CB_Lang.Name = "CB_Lang";
this.CB_Lang.Size = new System.Drawing.Size(121, 21);
this.CB_Lang.TabIndex = 3;
this.CB_Lang.SelectedIndexChanged += new System.EventHandler(this.changeLanguage);
//
// L_Lang
//
this.L_Lang.AutoSize = true;
this.L_Lang.Location = new System.Drawing.Point(152, 43);
this.L_Lang.Name = "L_Lang";
this.L_Lang.Size = new System.Drawing.Size(58, 13);
this.L_Lang.TabIndex = 4;
this.L_Lang.Text = "Language:";
//
// L_Game
//
this.L_Game.AutoSize = true;
this.L_Game.ForeColor = System.Drawing.Color.Red;
this.L_Game.Location = new System.Drawing.Point(15, 43);
this.L_Game.Name = "L_Game";
this.L_Game.Size = new System.Drawing.Size(91, 13);
this.L_Game.TabIndex = 5;
this.L_Game.Text = "No Game Loaded";
//
// pBar1
//
this.pBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pBar1.Location = new System.Drawing.Point(12, 182);
this.pBar1.Name = "pBar1";
this.pBar1.Size = new System.Drawing.Size(325, 14);
this.pBar1.TabIndex = 6;
//
// L_About
//
this.L_About.AutoSize = true;
this.L_About.Location = new System.Drawing.Point(-2, -1);
this.L_About.Name = "L_About";
this.L_About.Size = new System.Drawing.Size(20, 13);
this.L_About.TabIndex = 7;
this.L_About.Text = "[A]";
this.L_About.Click += new System.EventHandler(this.L_About_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(349, 202);
this.Controls.Add(this.L_About);
this.Controls.Add(this.pBar1);
this.Controls.Add(this.L_Game);
this.Controls.Add(this.L_Lang);
this.Controls.Add(this.CB_Lang);
this.Controls.Add(this.GB_Tools);
this.Controls.Add(this.TB_Path);
this.Controls.Add(this.B_Open);
this.MaximumSize = new System.Drawing.Size(800, 240);
this.MinimumSize = new System.Drawing.Size(365, 240);
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "pk3DS";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.formClosing);
this.GB_Tools.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button B_Open;
private System.Windows.Forms.TextBox TB_Path;
private System.Windows.Forms.GroupBox GB_Tools;
private System.Windows.Forms.Button B_Trainer;
private System.Windows.Forms.Button B_GameText;
private System.Windows.Forms.Button B_Wild;
private System.Windows.Forms.Button B_Item;
private System.Windows.Forms.Button B_Move;
private System.Windows.Forms.Button B_Evolution;
private System.Windows.Forms.Button B_Personal;
private System.Windows.Forms.Button B_MegaEvo;
private System.Windows.Forms.Button B_StoryText;
private System.Windows.Forms.ComboBox CB_Lang;
private System.Windows.Forms.Label L_Lang;
private System.Windows.Forms.Label L_Game;
private System.Windows.Forms.ProgressBar pBar1;
private System.Windows.Forms.Label L_About;
}
}

274
pk3DS/Main.cs Normal file
View File

@@ -0,0 +1,274 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace pk3DS
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
this.AllowDrop = GB_Tools.AllowDrop = TB_Path.AllowDrop = true;
this.DragEnter += tabMain_DragEnter;
this.DragDrop += tabMain_DragDrop;
GB_Tools.DragEnter += tabMain_DragEnter;
GB_Tools.DragDrop += tabMain_DragDrop;
TB_Path.DragEnter += tabMain_DragEnter;
TB_Path.DragDrop += tabMain_DragDrop;
CB_Lang.SelectedIndex = 2;
}
public bool oras = false;
public volatile int threads = 0;
private void B_Open_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
openQuick(fbd.SelectedPath);
}
private void openQuick(string path)
{
// Check to see if the folder is romfs
FileInfo fi = new FileInfo(path);
if (fi.Name.Contains("a"))
{
string[] files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
System.Media.SystemSounds.Asterisk.Play();
if (files.Length == 299) // ORAS
oras = true;
else if (files.Length == 301) // ORAS demo
oras = true;
else if (files.Length == 271)
oras = false;
else
{
TB_Path.Text = ""; GB_Tools.Enabled = false;
L_Game.Text = "No Game Loaded";
return;
}
TB_Path.Text = path; GB_Tools.Enabled = true;
L_Game.Text = (oras) ? "Game Loaded: ORAS" : "Game Loaded: XY";
changeLanguage(null, null); // Trigger Text Loading
}
}
private void tabMain_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}
private void tabMain_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
string path = files[0]; // open first D&D
openQuick(path);
}
// Subform Items
private void B_GameText_Click(object sender, EventArgs e)
{
new Thread(() =>
{
string toEdit = "gametext";
string GARC = getGARCFileName(toEdit);
// threadGet(TB_Path.Text + getGARCFileName(toEdit), toEdit); // We don't need this because loading and changing language does it for us.
Invoke((Action)(() => { new xytext(Directory.GetFiles(toEdit)).ShowDialog(); }));
// When closed, create a new thread to set the GARC back.
threadSet(TB_Path.Text + GARC, toEdit);
}).Start();
}
private void B_StoryText_Click(object sender, EventArgs e)
{
if (threads > 0) { Util.Alert("Please wait for all operations to finish first."); return; }
new Thread(() =>
{
string toEdit = "storytext";
string GARC = getGARCFileName(toEdit);
threadGet(TB_Path.Text + GARC, toEdit, true, true);
while (threads > 0) // Let threads complete
Thread.Sleep(100);
Invoke((Action)(() => { new xytext(Directory.GetFiles(toEdit)).ShowDialog(); }));
// When closed, create a new thread to set the GARC back.
threadSet(TB_Path.Text + GARC, toEdit);
while (threads > 0) // Let threads complete
Thread.Sleep(100);
if (Directory.Exists(toEdit)) Directory.Delete(toEdit, true);
}).Start();
} volatile bool StoryTextOpen = false;
private void B_Wild_Click(object sender, EventArgs e)
{
Util.Alert("Not implemented yet.");
}
private void B_Personal_Click(object sender, EventArgs e)
{
Util.Alert("Not implemented yet.");
}
private void B_Evolution_Click(object sender, EventArgs e)
{
Util.Alert("Not implemented yet.");
}
private void B_MegaEvo_Click(object sender, EventArgs e)
{
Util.Alert("Not implemented yet.");
}
private void B_Move_Click(object sender, EventArgs e)
{
Util.Alert("Not implemented yet.");
}
private void B_Item_Click(object sender, EventArgs e)
{
Util.Alert("Not implemented yet.");
}
private void B_Trainer_Click(object sender, EventArgs e)
{
if (threads > 0) { Util.Alert("Please wait for all operations to finish first."); return; }
if (!oras) { Util.Alert("X/Y not supported yet."); return; }
new Thread(() =>
{
string trdata = "trdata";
string trdataGARC = getGARCFileName(trdata);
threadGet(TB_Path.Text + trdataGARC, trdata, true, true);
while (threads > 0) // Let threads complete
Thread.Sleep(50);
string trpoke = "trpoke";
string trpokeGARC = getGARCFileName(trpoke);
threadGet(TB_Path.Text + trpokeGARC, trpoke, true, true);
while (threads > 0) // Let threads complete
Thread.Sleep(50);
string personal = "personal";
string personalGARC = getGARCFileName(personal);
threadGet(TB_Path.Text + personalGARC, personal, true, true);
while (threads > 0) // Let threads complete
Thread.Sleep(100);
Invoke((Action)(() => { new RSTE(oras, Directory.GetFiles(trdata), Directory.GetFiles(trpoke)).ShowDialog(); }));
// When closed, create a new thread to set the GARC back.
threadSet(TB_Path.Text + trdataGARC, trdata);
while (threads > 0) // Let threads complete
Thread.Sleep(100);
if (Directory.Exists(trdata)) Directory.Delete(trdata, true);
threadSet(TB_Path.Text + trpokeGARC, trpoke);
while (threads > 0) // Let threads complete
Thread.Sleep(100);
if (Directory.Exists(trpoke)) Directory.Delete(trpoke, true);
}).Start();
}
// GARC Requests
public bool getGARC(string infile, string outfolder, bool PB, bool bypassExt = false)
{
bool success = GARCTool.garcUnpack(infile, outfolder, bypassExt, (PB) ? pBar1 : null, null, true, bypassExt);
Console.WriteLine("Get Status: " + success.ToString());
threads--;
return success;
}
public bool setGARC(string outfile, string infolder, bool PB)
{
string temp = Util.getRandomFileName();
bool success = GARCTool.garcPack(infolder, temp, (PB) ? pBar1 : null, null, true);
Console.WriteLine("Set Status: " + success.ToString());
try { File.Delete(outfile); File.Move(temp, outfile); }
catch (Exception e) { Util.Error("Could not set the GARC back:", e.ToString()); }
threads--;
return success;
}
public void threadGet(string infile, string outfolder, bool PB = true, bool bypassExt = false)
{
if (Directory.Exists(outfolder)) Directory.Delete(outfolder, true);
Thread thread = new Thread(() => getGARC(infile, outfolder, PB, bypassExt));
thread.Start(); threads++;
}
public void threadSet(string outfile, string infolder, bool PB = true)
{
Thread thread = new Thread(() => setGARC(outfile, infolder, PB));
thread.Start(); threads++;
}
public string getGARCFileName(string request)
{
int lang = 0;
if (CB_Lang.InvokeRequired)
CB_Lang.Invoke((MethodInvoker)delegate { lang = CB_Lang.SelectedIndex; });
else lang = CB_Lang.SelectedIndex;
string ans = "";
switch (request)
{
case "gametext": ans = (oras) ? getFileName(0, 7, 1 + lang) : getFileName(0, 7, 2 + lang);
break;
case "storytext": ans = (oras) ? getFileName(0, 7 + ((lang + 9) / 10), (10 + (lang + 9)) % 10) : getFileName(0, 8, lang);
break;
case "personal": ans = (oras) ? getFileName(1, 9, 5) : getFileName(2, 1, 8);
break;
case "trdata": ans = (oras) ? getFileName(0, 3, 6) : getFileName(0, 3, 8);
break;
case "trpoke": ans = (oras) ? getFileName(0, 3, 8) : getFileName(0, 4, 0);
break;
}
return ans;
}
// Text Requests
internal static string[] getText(int file)
{
return xytext.getStringsFromFile("gametext" + Path.DirectorySeparatorChar + file.ToString("000") + ".bin");
}
public bool setText(int file, string[] strings)
{
byte[] data = xytext.getBytesForFile(strings);
string path = "text" + Path.DirectorySeparatorChar + file.ToString("000") + ".bin";
File.WriteAllBytes(path, data);
return true;
}
private void changeLanguage(object sender, EventArgs e)
{
if (!GB_Tools.Enabled) return;
// Gather the Text Language Strings
threadGet(TB_Path.Text + getGARCFileName("gametext"), "gametext", true, true);
}
private string getFileName(int A, int B, int C)
{
return Path.DirectorySeparatorChar + A.ToString() + Path.DirectorySeparatorChar + B.ToString() + Path.DirectorySeparatorChar + C.ToString();
}
private void formClosing(object sender, FormClosingEventArgs e)
{
this.Hide();
if (!GB_Tools.Enabled) return; // No data/threads need to be addressed if we haven't loaded anything.
// Set the GameText back as other forms may have edited it.
threadSet(TB_Path.Text + getGARCFileName("gametext"), "gametext", false);
threadSet(TB_Path.Text + getGARCFileName("personal"), "personal", false);
int timeout = 0; // Time out after 7 seconds.
while (threads > 0 && timeout++ < 70)
Thread.Sleep(100);
if (Directory.Exists("gametext")) Directory.Delete("gametext", true);
if (Directory.Exists("personal")) Directory.Delete("personal", true);
}
private void L_About_Click(object sender, EventArgs e)
{
Util.Alert(
"pk3DS: A package of Pokémon X/Y/OR/AS tools by various contributors.",
"GARCTool (Backbone): Kaphotics" + Environment.NewLine +
"Text Editing (xytext): Kaphotics" + Environment.NewLine +
"Wild Editor (**WE): SciresM & Kaphotics" + Environment.NewLine +
"Trainer Editor (**TE): SciresM & Kaphotics" + Environment.NewLine +
"Personal Editor: SciresM" + Environment.NewLine +
"Mega Evolution Editor (MEE): Huntereb & SciresM" + Environment.NewLine +
"Evolutions, Moves, and Items and more have yet to be implemented.",
"Big thanks to the ProjectPokemon community!");
}
}
}

120
pk3DS/Main.resx Normal file
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>

21
pk3DS/Program.cs Normal file
View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace pk3DS
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("pk3DS")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("pk3DS")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("dcec1a61-b0cd-4982-a8d8-9024970c4f16")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

63
pk3DS/Properties/Resources.Designer.cs generated Normal file
View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace pk3DS.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("pk3DS.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

26
pk3DS/Properties/Settings.Designer.cs generated Normal file
View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace pk3DS.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

2259
pk3DS/RSTE.Designer.cs generated Normal file

File diff suppressed because it is too large Load Diff

988
pk3DS/RSTE.cs Normal file
View File

@@ -0,0 +1,988 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace pk3DS
{
public partial class RSTE : Form
{
public RSTE(bool rom_oras, string[] trdata, string[] trpoke)
{
oras = rom_oras;
trdatapaths = trdata;
trpokepaths = trpoke;
abilitylist = Main.getText((oras) ? 37 : 34);
movelist = Main.getText((oras) ? 14 : 13);
itemlist = Main.getText((oras) ? 114 : 96);
specieslist = Main.getText((oras) ? 98 : 80);
types = Main.getText((oras) ? 18 : 17);
forms = Main.getText((oras) ? 5 : 5);
trName = Main.getText((oras) ? 22 : 21);
trClass = Main.getText((oras) ? 21 : 20);
InitializeComponent();
// String Fetching
#region Combo Box Arrays
trpk_pkm = new ComboBox[]
{
CB_Pokemon_1_Pokemon,
CB_Pokemon_2_Pokemon,
CB_Pokemon_3_Pokemon,
CB_Pokemon_4_Pokemon,
CB_Pokemon_5_Pokemon,
CB_Pokemon_6_Pokemon,
};
trpk_lvl = new ComboBox[]
{
CB_Pokemon_1_Level,
CB_Pokemon_2_Level,
CB_Pokemon_3_Level,
CB_Pokemon_4_Level,
CB_Pokemon_5_Level,
CB_Pokemon_6_Level,
};
trpk_item = new ComboBox[]
{
CB_Pokemon_1_Item,
CB_Pokemon_2_Item,
CB_Pokemon_3_Item,
CB_Pokemon_4_Item,
CB_Pokemon_5_Item,
CB_Pokemon_6_Item,
};
trpk_abil = new ComboBox[]
{
CB_Pokemon_1_Ability,
CB_Pokemon_2_Ability,
CB_Pokemon_3_Ability,
CB_Pokemon_4_Ability,
CB_Pokemon_5_Ability,
CB_Pokemon_6_Ability,
};
trpk_m1 = new ComboBox[]
{
CB_Pokemon_1_Move_1,
CB_Pokemon_2_Move_1,
CB_Pokemon_3_Move_1,
CB_Pokemon_4_Move_1,
CB_Pokemon_5_Move_1,
CB_Pokemon_6_Move_1,
};
trpk_m2 = new ComboBox[]
{
CB_Pokemon_1_Move_2,
CB_Pokemon_2_Move_2,
CB_Pokemon_3_Move_2,
CB_Pokemon_4_Move_2,
CB_Pokemon_5_Move_2,
CB_Pokemon_6_Move_2,
};
trpk_m3 = new ComboBox[]
{
CB_Pokemon_1_Move_3,
CB_Pokemon_2_Move_3,
CB_Pokemon_3_Move_3,
CB_Pokemon_4_Move_3,
CB_Pokemon_5_Move_3,
CB_Pokemon_6_Move_3,
};
trpk_m4 = new ComboBox[]
{
CB_Pokemon_1_Move_4,
CB_Pokemon_2_Move_4,
CB_Pokemon_3_Move_4,
CB_Pokemon_4_Move_4,
CB_Pokemon_5_Move_4,
CB_Pokemon_6_Move_4,
};
trpk_IV = new ComboBox[]
{
CB_Pokemon_1_IVs,
CB_Pokemon_2_IVs,
CB_Pokemon_3_IVs,
CB_Pokemon_4_IVs,
CB_Pokemon_5_IVs,
CB_Pokemon_6_IVs,
};
trpk_form = new ComboBox[]
{
CB_Pokemon_1_Form,
CB_Pokemon_2_Form,
CB_Pokemon_3_Form,
CB_Pokemon_4_Form,
CB_Pokemon_5_Form,
CB_Pokemon_6_Form,
};
trpk_gender = new ComboBox[]
{
CB_Pokemon_1_Gender,
CB_Pokemon_2_Gender,
CB_Pokemon_3_Gender,
CB_Pokemon_4_Gender,
CB_Pokemon_5_Gender,
CB_Pokemon_6_Gender,
};
#endregion
Setup();
}
internal static Random rand = new Random();
internal static uint rnd32()
{
return (uint)(rand.Next(1 << 30)) << 2 | (uint)(rand.Next(1 << 2));
}
bool oras = false;
bool start = true;
bool loading = true;
byte[][] personal;
int index = -1;
#region Global Variables
private ComboBox[] trpk_pkm;
private ComboBox[] trpk_lvl;
private ComboBox[] trpk_item;
private ComboBox[] trpk_abil;
private ComboBox[] trpk_m1;
private ComboBox[] trpk_m2;
private ComboBox[] trpk_m3;
private ComboBox[] trpk_m4;
private ComboBox[] trpk_IV;
private ComboBox[] trpk_form;
private ComboBox[] trpk_gender;
private string[] abilitylist, movelist, itemlist, specieslist, types, forms;
private string[] trName, trClass;
#endregion
// Form Loading
public void setForms(int species, ComboBox cb)
{
// Form Tables
//
var form_unown = new[] {
new { Text = "A", Value = 0 },
new { Text = "B", Value = 1 },
new { Text = "C", Value = 2 },
new { Text = "D", Value = 3 },
new { Text = "E", Value = 4 },
new { Text = "F", Value = 5 },
new { Text = "G", Value = 6 },
new { Text = "H", Value = 7 },
new { Text = "I", Value = 8 },
new { Text = "J", Value = 9 },
new { Text = "K", Value = 10 },
new { Text = "L", Value = 11 },
new { Text = "M", Value = 12 },
new { Text = "N", Value = 13 },
new { Text = "O", Value = 14 },
new { Text = "P", Value = 15 },
new { Text = "Q", Value = 16 },
new { Text = "R", Value = 17 },
new { Text = "S", Value = 18 },
new { Text = "T", Value = 19 },
new { Text = "U", Value = 20 },
new { Text = "V", Value = 21 },
new { Text = "W", Value = 22 },
new { Text = "X", Value = 23 },
new { Text = "Y", Value = 24 },
new { Text = "Z", Value = 25 },
new { Text = "!", Value = 26 },
new { Text = "?", Value = 27 },
};
var form_castform = new[] {
new { Text = types[0], Value = 0 }, // Normal
new { Text = forms[789], Value = 1 }, // Sunny
new { Text = forms[790], Value = 2 }, // Rainy
new { Text = forms[791], Value = 3 }, // Snowy
};
var form_shellos = new[] {
new { Text = forms[422], Value = 0 }, // West
new { Text = forms[811], Value = 1 }, // East
};
var form_deoxys = new[] {
new { Text = types[0], Value = 0 }, // Normal
new { Text = forms[802], Value = 1 }, // Attack
new { Text = forms[803], Value = 2 }, // Defense
new { Text = forms[804], Value = 3 }, // Speed
};
var form_burmy = new[] {
new { Text = forms[412], Value = 0 }, // Plant
new { Text = forms[805], Value = 1 }, // Sandy
new { Text = forms[806], Value = 2 }, // Trash
};
var form_cherrim = new[] {
new { Text = forms[421], Value = 0 }, // Overcast
new { Text = forms[809], Value = 1 }, // Sunshine
};
var form_rotom = new[] {
new { Text = types[0], Value = 0 }, // Normal
new { Text = forms[817], Value = 1 }, // Heat
new { Text = forms[818], Value = 2 }, // Wash
new { Text = forms[819], Value = 3 }, // Frost
new { Text = forms[820], Value = 4 }, // Fan
new { Text = forms[821], Value = 5 }, // Mow
};
var form_giratina = new[] {
new { Text = forms[487], Value = 0 }, // Altered
new { Text = forms[822], Value = 1 }, // Origin
};
var form_shaymin = new[] {
new { Text = forms[492], Value = 0 }, // Land
new { Text = forms[823], Value = 1 }, // Sky
};
var form_arceus = new[] {
new { Text = types[0], Value = 0 }, // Normal
new { Text = types[1], Value = 1 }, // Fighting
new { Text = types[2], Value = 2 }, // Flying
new { Text = types[3], Value = 3 }, // Poison
new { Text = types[4], Value = 4 }, // etc
new { Text = types[5], Value = 5 },
new { Text = types[6], Value = 6 },
new { Text = types[7], Value = 7 },
new { Text = types[8], Value = 8 },
new { Text = types[9], Value = 9 },
new { Text = types[10], Value = 10 },
new { Text = types[11], Value = 11 },
new { Text = types[12], Value = 12 },
new { Text = types[13], Value = 13 },
new { Text = types[14], Value = 14 },
new { Text = types[15], Value = 15 },
new { Text = types[16], Value = 16 },
new { Text = types[17], Value = 17 },
};
var form_basculin = new[] {
new { Text = forms[550], Value = 0 }, // Red
new { Text = forms[842], Value = 1 }, // Blue
};
var form_darmanitan = new[] {
new { Text = forms[555], Value = 0 }, // Standard
new { Text = forms[843], Value = 1 }, // Zen
};
var form_deerling = new[] {
new { Text = forms[585], Value = 0 }, // Spring
new { Text = forms[844], Value = 1 }, // Summer
new { Text = forms[845], Value = 2 }, // Autumn
new { Text = forms[846], Value = 3 }, // Winter
};
var form_gender = new[] {
new { Text = "♂", Value = 0 }, // Male
new { Text = "♀", Value = 1 }, // Female
};
var form_therian = new[] {
new { Text = forms[641], Value = 0 }, // Incarnate
new { Text = forms[852], Value = 1 }, // Therian
};
var form_kyurem = new[] {
new { Text = types[0], Value = 0 }, // Normal
new { Text = forms[853], Value = 1 }, // White
new { Text = forms[854], Value = 2 }, // Black
};
var form_keldeo = new[] {
new { Text = forms[647], Value = 0 }, // Ordinary
new { Text = forms[855], Value = 1 }, // Resolute
};
var form_meloetta = new[] {
new { Text = forms[648], Value = 0 }, // Aria
new { Text = forms[856], Value = 1 }, // Pirouette
};
var form_genesect = new[] {
new { Text = types[0], Value = 0 }, // Normal
new { Text = types[10], Value = 1 }, // Douse
new { Text = types[12], Value = 2 }, // Shock
new { Text = types[9], Value = 3 }, // Burn
new { Text = types[14], Value = 4 }, // Chill
};
var form_flabebe = new[] {
new { Text = forms[669], Value = 0 }, // Red
new { Text = forms[884], Value = 1 }, // Yellow
new { Text = forms[885], Value = 2 }, // Orange
new { Text = forms[886], Value = 3 }, // Blue
new { Text = forms[887], Value = 4 }, // White
};
var form_floette = new[] {
new { Text = forms[669], Value = 0 }, // Red
new { Text = forms[884], Value = 1 }, // Yellow
new { Text = forms[885], Value = 2 }, // Orange
new { Text = forms[886], Value = 3 }, // Blue
new { Text = forms[887], Value = 4 }, // White
new { Text = forms[888], Value = 5 }, // Eternal
};
var form_furfrou = new[] {
new { Text = forms[676], Value = 0 }, // Natural
new { Text = forms[893], Value = 1 }, // Heart
new { Text = forms[894], Value = 2 }, // Star
new { Text = forms[895], Value = 3 }, // Diamond
new { Text = forms[896], Value = 4 }, // Deputante
new { Text = forms[897], Value = 5 }, // Matron
new { Text = forms[898], Value = 6 }, // Dandy
new { Text = forms[899], Value = 7 }, // La Reine
new { Text = forms[900], Value = 8 }, // Kabuki
new { Text = forms[901], Value = 9 }, // Pharaoh
};
var form_aegislash = new[] {
new { Text = forms[681], Value = 0 }, // Shield
new { Text = forms[903], Value = 1 }, // Blade
};
var form_butterfly = new[] {
new { Text = forms[666], Value = 0 }, // Icy Snow
new { Text = forms[861], Value = 1 }, // Polar
new { Text = forms[862], Value = 2 }, // Tundra
new { Text = forms[863], Value = 3 }, // Continental
new { Text = forms[864], Value = 4 }, // Garden
new { Text = forms[865], Value = 5 }, // Elegant
new { Text = forms[866], Value = 6 }, // Meadow
new { Text = forms[867], Value = 7 }, // Modern
new { Text = forms[868], Value = 8 }, // Marine
new { Text = forms[869], Value = 9 }, // Archipelago
new { Text = forms[870], Value = 10 }, // High-Plains
new { Text = forms[871], Value = 11 }, // Sandstorm
new { Text = forms[872], Value = 12 }, // River
new { Text = forms[873], Value = 13 }, // Monsoon
new { Text = forms[874], Value = 14 }, // Savannah
new { Text = forms[875], Value = 15 }, // Sun
new { Text = forms[876], Value = 16 }, // Ocean
new { Text = forms[877], Value = 17 }, // Jungle
new { Text = forms[878], Value = 18 }, // Fancy
new { Text = forms[879], Value = 19 }, // Poké Ball
};
var form_list = new[] {
new { Text = "", Value = 0}, // None
};
var form_pump = new[] {
new { Text = forms[904], Value = 0 }, // Small
new { Text = forms[710], Value = 1 }, // Average
new { Text = forms[905], Value = 2 }, // Large
new { Text = forms[907], Value = 3 }, // Super
};
var form_mega = new[] {
new { Text = types[0], Value = 0}, // Normal
new { Text = forms[723], Value = 1}, // Mega
};
var form_megaxy = new[] {
new { Text = types[0], Value = 0}, // Normal
new { Text = forms[724], Value = 1}, // Mega X
new { Text = forms[725], Value = 2}, // Mega Y
};
var form_primal = new[] {
new { Text = types[0], Value = 0},
new { Text = forms[800], Value = 1},
};
var form_hoopa = new[] {
new { Text = types[0], Value = 0},
new { Text = forms[912], Value = 1},
};
var form_pikachu = new[] {
new { Text = types[0], Value = 0}, // Normal
new { Text = forms[729], Value = 1}, // Rockstar
new { Text = forms[730], Value = 2}, // Belle
new { Text = forms[731], Value = 3}, // Pop
new { Text = forms[732], Value = 4}, // PhD
new { Text = forms[733], Value = 5}, // Libre
new { Text = forms[734], Value = 6}, // Cosplay
};
cb.DataSource = form_list;
cb.DisplayMember = "Text";
cb.ValueMember = "Value";
// Mega List
int[] mspec = { // XY
003, 009, 065, 094, 115, 127, 130, 142, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359, 380, 381, 445, 448, 460,
// ORAS
015, 018, 080, 208, 254, 260, 302, 319, 323, 334, 362, 373, 376, 384, 428, 475, 531, 719,
};
for (int i = 0; i < mspec.Length; i++)
{
if (mspec[i] == species)
{
cb.DataSource = form_mega;
cb.Enabled = true; // Mega Form Selection
return;
}
}
// MegaXY List
if ((species == 6) || (species == 150))
{
cb.DataSource = form_megaxy;
cb.Enabled = true; // Mega Form Selection
return;
}
// Regular Form List
if (species == 025) { form_list = form_pikachu; }
else if (species == 201) { form_list = form_unown; }
else if (species == 351) { form_list = form_castform; }
else if (species == 386) { form_list = form_deoxys; }
else if (species == 421) { form_list = form_cherrim; }
else if (species == 479) { form_list = form_rotom; }
else if (species == 487) { form_list = form_giratina; }
else if (species == 492) { form_list = form_shaymin; }
else if (species == 493) { form_list = form_arceus; }
else if (species == 550) { form_list = form_basculin; }
else if (species == 555) { form_list = form_darmanitan; }
else if (species == 646) { form_list = form_kyurem; }
else if (species == 647) { form_list = form_keldeo; }
else if (species == 648) { form_list = form_meloetta; }
else if (species == 649) { form_list = form_genesect; }
else if (species == 676) { form_list = form_furfrou; }
else if (species == 681) { form_list = form_aegislash; }
else if (species == 670) { form_list = form_floette; }
else if ((species == 669) || (species == 671)) { form_list = form_flabebe; }
else if ((species == 412) || (species == 413)) { form_list = form_burmy; }
else if ((species == 422) || (species == 423)) { form_list = form_shellos; }
else if ((species == 585) || (species == 586)) { form_list = form_deerling; }
else if ((species == 710) || (species == 711)) { form_list = form_pump; }
else if ((species == 666) || (species == 665) || (species == 664)) { form_list = form_butterfly; }
else if ((species == 592) || (species == 593) || (species == 678)) { form_list = form_gender; }
else if ((species == 641) || (species == 642) || (species == 645)) { form_list = form_therian; }
// ORAS
else if (species == 382 || species == 383) { form_list = form_primal; }
else if (species == 720) { form_list = form_hoopa; }
else
{
cb.Enabled = false;
return;
};
cb.DataSource = form_list;
cb.Enabled = true;
}
// Ability Loading
private void refreshFormAbility(object sender, EventArgs e)
{
int i = Array.IndexOf(trpk_form, sender as ComboBox);
refreshPKMSlotAbility(i);
}
private void refreshSpeciesAbility(object sender, EventArgs e)
{
int i = Array.IndexOf(trpk_pkm, sender as ComboBox);
setForms(trpk_pkm[i].SelectedIndex, trpk_form[i]);
refreshPKMSlotAbility(i);
}
private void refreshPKMSlotAbility(int slot)
{
int species = trpk_pkm[slot].SelectedIndex;
uint[] abils = { 0, 0, 0 };
int formnum = trpk_form[slot].SelectedIndex;
if (formnum == 0) { }
// Previous Games
else if (species == 492 && formnum == 1) { species = 727; } // Shaymin Sky
else if (species == 487 && formnum == 1) { species = 728; } // Giratina-O
else if (species == 550 && formnum == 1) { species = 738; } // Basculin Blue
else if (species == 646 && formnum == 1) { species = 741; } // Kyurem White
else if (species == 646 && formnum == 2) { species = 742; } // Kyurem Black
else if (species == 641 && formnum == 1) { species = 744; } // Tornadus-T
else if (species == 642 && formnum == 1) { species = 745; } // Thundurus-T
else if (species == 645 && formnum == 1) { species = 746; } // Landorus-T
// XY
else if (species == 678 && formnum == 1) { species = 748; } // Meowstic Female
else if (species == 094 && formnum == 1) { species = 747; } // Mega Gengar
else if (species == 282 && formnum == 1) { species = 758; } // Mega Gardevoir
else if (species == 181 && formnum == 1) { species = 759; } // Mega Ampharos
else if (species == 003 && formnum == 1) { species = 760; } // Mega Venusaur
else if (species == 006 && formnum == 1) { species = 761; } // Mega Charizard X
else if (species == 006 && formnum == 2) { species = 762; } // Mega Charizard Y
else if (species == 150 && formnum == 1) { species = 763; } // Mega MewtwoX
else if (species == 150 && formnum == 2) { species = 764; } // Mega MewtwoY
else if (species == 257 && formnum == 1) { species = 765; } // Mega Blaziken
else if (species == 308 && formnum == 1) { species = 766; } // Mega Medicham
else if (species == 229 && formnum == 1) { species = 767; } // Mega Houndoom
else if (species == 306 && formnum == 1) { species = 768; } // Mega Aggron
else if (species == 354 && formnum == 1) { species = 769; } // Mega Banette
else if (species == 248 && formnum == 1) { species = 770; } // Mega Tyranitar
else if (species == 212 && formnum == 1) { species = 771; } // Mega Scizor
else if (species == 127 && formnum == 1) { species = 772; } // Mega Pinsir
else if (species == 142 && formnum == 1) { species = 773; } // Mega Aerodactyl
else if (species == 448 && formnum == 1) { species = 774; } // Mega Lucario
else if (species == 460 && formnum == 1) { species = 775; } // Mega Abomasnow
else if (species == 009 && formnum == 1) { species = 777; } // Mega Blastoise
else if (species == 115 && formnum == 1) { species = 778; } // Mega Kangaskhan
else if (species == 130 && formnum == 1) { species = 779; } // Mega Gyarados
else if (species == 359 && formnum == 1) { species = 780; } // Mega Absol
else if (species == 065 && formnum == 1) { species = 781; } // Mega Alakazam
else if (species == 214 && formnum == 1) { species = 782; } // Mega Heracross
else if (species == 303 && formnum == 1) { species = 783; } // Mega Mawile
else if (species == 310 && formnum == 1) { species = 784; } // Mega Manectric
else if (species == 445 && formnum == 1) { species = 785; } // Mega Garchomp
else if (species == 381 && formnum == 1) { species = 786; } // Mega Latios
else if (species == 380 && formnum == 1) { species = 787; } // Mega Latias
// ORAS
else if (species == 382 && formnum == 1) { species = 812; } // Primal Kyogre
else if (species == 383 && formnum == 1) { species = 813; } // Primal Groudon
else if (species == 720 && formnum == 1) { species = 821; } // Hoopa Unbound
else if (species == 015 && formnum == 1) { species = 825; } // Mega Beedrill
else if (species == 018 && formnum == 1) { species = 808; } // Mega Pidgeot
else if (species == 080 && formnum == 1) { species = 806; } // Mega Slowbro
else if (species == 208 && formnum == 1) { species = 807; } // Mega Steelix
else if (species == 254 && formnum == 1) { species = 800; } // Mega Sceptile
else if (species == 260 && formnum == 1) { species = 799; } // Mega Swampert
else if (species == 302 && formnum == 1) { species = 801; } // Mega Sableye
else if (species == 319 && formnum == 1) { species = 805; } // Mega Sharpedo
else if (species == 323 && formnum == 1) { species = 822; } // Mega Camerupt
else if (species == 334 && formnum == 1) { species = 802; } // Mega Altaria
else if (species == 362 && formnum == 1) { species = 809; } // Mega Glalie
else if (species == 373 && formnum == 1) { species = 824; } // Mega Salamence
else if (species == 376 && formnum == 1) { species = 811; } // Mega Metagross
else if (species == 384 && formnum == 1) { species = 814; } // Mega Rayquaza
else if (species == 428 && formnum == 1) { species = 823; } // Mega Lopunny
else if (species == 475 && formnum == 1) { species = 803; } // Mega Gallade
else if (species == 531 && formnum == 1) { species = 804; } // Mega Audino
else if (species == 719 && formnum == 1) { species = 810; } // Mega Diancie
byte[] persdata = File.ReadAllBytes("personal" + Path.DirectorySeparatorChar + species.ToString("000") + ".bin");
Array.Copy(persdata, 0x18, abils, 0, 3);
trpk_abil[slot].Items.Clear();
trpk_abil[slot].Items.Add("Any (1 or 2)");
trpk_abil[slot].Items.Add(abilitylist[abils[0]] + " (1)");
trpk_abil[slot].Items.Add(abilitylist[abils[1]] + " (2)");
trpk_abil[slot].Items.Add(abilitylist[abils[2]] + " (H)");
trpk_abil[slot].SelectedIndex = 0;
}
// Set Loading
private void changeTrainerType(object sender, EventArgs e)
{
if (start || loading) return;
int pkm = CB_numPokemon.SelectedIndex;
{
for (int i = 0; i < 6; i++) // enable all if the pkm exists
{
trpk_pkm[i].Enabled =
trpk_gender[i].Enabled =
trpk_abil[i].Enabled =
trpk_IV[i].Enabled =
trpk_lvl[i].Enabled = (i < pkm);
trpk_item[i].Enabled = (i < pkm) && (checkBox_Item.Checked);
trpk_m1[i].Enabled =
trpk_m2[i].Enabled =
trpk_m3[i].Enabled =
trpk_m4[i].Enabled = (i < pkm) && (checkBox_Moves.Checked);
if (!trpk_pkm[i].Enabled)
{
trpk_pkm[i].SelectedIndex =
trpk_gender[i].SelectedIndex =
trpk_form[i].SelectedIndex =
trpk_abil[i].SelectedIndex =
trpk_IV[i].SelectedIndex =
trpk_lvl[i].SelectedIndex = 0;
}
if (!trpk_item[i].Enabled)
{
trpk_item[i].SelectedIndex = 0;
}
if (!trpk_m1[i].Enabled)
{
trpk_m1[i].SelectedIndex =
trpk_m2[i].SelectedIndex =
trpk_m3[i].SelectedIndex =
trpk_m4[i].SelectedIndex = 0;
}
}
for (int i = pkm; i < 6; i++)
trpk_form[i].Enabled = false;
}
}
// Dumping
private string getTRSummary()
{
string toret = "======\n";
toret += CB_TrainerID.SelectedIndex + " - " + CB_Trainer_Class.Text.Substring(6, CB_Trainer_Class.Text.Length - 6) + " " + CB_TrainerID.Text.Substring(6, CB_TrainerID.Text.Length - 6) + "\n";
toret += "======\n";
int pkm = CB_numPokemon.SelectedIndex;
toret += "Pokemon: " + pkm + "\n";
for (int i = 0; i < pkm; i++)
{
toret += trpk_pkm[i].Text + " (Lv. " + trpk_lvl[i].SelectedIndex + ") ";
if (trpk_item[i].SelectedIndex > 0)
toret += "@" + trpk_item[i].Text;
if (trpk_abil[i].SelectedIndex != 0)
{
string abil = trpk_abil[i].Text;
abil = abil.Substring(0, abil.Length - 4);
toret += " (Ability: " + abil + ")";
}
if (checkBox_Moves.Checked)
{
toret += " (Moves: ";
if (trpk_m1[i].SelectedIndex > 0) toret += trpk_m1[i].Text;
if (trpk_m2[i].SelectedIndex > 0) toret += " / " + trpk_m2[i].Text;
if (trpk_m3[i].SelectedIndex > 0) toret += " / " + trpk_m3[i].Text;
if (trpk_m4[i].SelectedIndex > 0) toret += " / " + trpk_m4[i].Text;
toret += ")";
}
toret += " IVs: All " + (Convert.ToInt32(trpk_IV[i].SelectedIndex) / 8);
toret += "\n";
}
toret += "\n";
return toret;
}
private void B_Dump_Click(object sender, EventArgs e)
{
string toret = "";
for (int i = 1; i < 950; i++)
{
CB_TrainerID.SelectedIndex = i;
string tdata = getTRSummary();
toret += tdata;
}
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = "Battles.txt";
sfd.Filter = "Text File|*.txt";
System.Media.SystemSounds.Asterisk.Play();
if (sfd.ShowDialog() == DialogResult.OK)
{
string path = sfd.FileName;
File.WriteAllText(path, toret, System.Text.Encoding.Unicode);
}
}
// Top Level Functions
private string[] trdatapaths;
private string[] trpokepaths;
// Change Read
private void changeTrainerIndex(object sender, EventArgs e)
{
if (index > -1) writeFile();
readFile(); // Load the new file.
}
private void readFile()
{
if (start) return;
index = CB_TrainerID.SelectedIndex;
loading = true;
int format;
if (index == 0) return;
// Load Trainer Data
using (BinaryReader br = new BinaryReader((Stream) File.OpenRead(trdatapaths[index])))
{
if (br.BaseStream.Length != 24) // required length
throw new Exception("Invalid file attempted to load.\n\n" + trdatapaths[index]);
// load trainer data
tabControl1.Enabled = true;
{
br.BaseStream.Position = 0;
format = br.ReadUInt16();
checkBox_Item.Checked = ((format >> 1) & 1) == 1;
checkBox_Moves.Checked = ((format) & 1) == 1;
CB_Trainer_Class.SelectedIndex = br.ReadUInt16();
br.ReadByte();
br.ReadByte();
CB_Battle_Type.SelectedIndex = br.ReadByte();
CB_numPokemon.SelectedIndex = br.ReadByte();
CB_Item_1.SelectedIndex = br.ReadUInt16();
CB_Item_2.SelectedIndex = br.ReadUInt16();
CB_Item_3.SelectedIndex = br.ReadUInt16();
CB_Item_4.SelectedIndex = br.ReadUInt16();
CB_AI.SelectedIndex = br.ReadByte();
br.ReadByte();
br.ReadByte();
br.ReadByte();
checkBox_Healer.Checked = Convert.ToBoolean(br.ReadByte());
CB_Money.SelectedIndex = br.ReadByte();
CB_Prize.SelectedIndex = br.ReadUInt16();
}
}
// Load Pokemon Data
using (BinaryReader br = new BinaryReader((Stream)File.OpenRead(trpokepaths[index])))
{
br.BaseStream.Position = 0;
for (int i = 0; i < CB_numPokemon.SelectedIndex; i++)
{
trpk_IV[i].SelectedIndex = br.ReadByte();
byte PID = br.ReadByte();
trpk_lvl[i].SelectedIndex = br.ReadUInt16();
trpk_pkm[i].SelectedIndex = br.ReadUInt16();
setForms(trpk_pkm[i].SelectedIndex, trpk_form[i]);
trpk_form[i].SelectedIndex = br.ReadUInt16();
refreshPKMSlotAbility(i); // Repopulate Abilities
trpk_abil[i].SelectedIndex = PID >> 4;
trpk_gender[i].SelectedIndex = PID & 3;
if (((format >> 1) & 1) == 1) // Items Exist in Data
trpk_item[i].SelectedIndex = br.ReadUInt16();
if (((format) & 1) == 1) // Moves Exist in Data
{
trpk_m1[i].SelectedIndex = br.ReadUInt16();
trpk_m2[i].SelectedIndex = br.ReadUInt16();
trpk_m3[i].SelectedIndex = br.ReadUInt16();
trpk_m4[i].SelectedIndex = br.ReadUInt16();
}
}
}
loading = false;
changeTrainerType(null, null); // Prompt cleaning update of PKM fields
}
// Change Write
private void writeFile()
{
// fetch trainer format we're saving as
// index = index;
ushort format = (ushort)(Convert.ToByte(checkBox_Moves.Checked) + (Convert.ToByte(checkBox_Item.Checked) << 1));
// Write Trainer Data
using (MemoryStream ms = new MemoryStream())
using (BinaryWriter bw = new BinaryWriter(ms))
{
bw.BaseStream.Position = 0;
bw.Write((ushort)format);
bw.Write((ushort)CB_Trainer_Class.SelectedIndex);
bw.Write((byte)0);
bw.Write((byte)0);
bw.Write((byte)CB_Battle_Type.SelectedIndex);
bw.Write((byte)CB_numPokemon.SelectedIndex);
bw.Write((ushort)CB_Item_1.SelectedIndex);
bw.Write((ushort)CB_Item_2.SelectedIndex);
bw.Write((ushort)CB_Item_3.SelectedIndex);
bw.Write((ushort)CB_Item_4.SelectedIndex);
bw.Write((byte)CB_AI.SelectedIndex);
bw.Write((byte)0);
bw.Write((byte)0);
bw.Write((byte)0);
bw.Write((byte)Convert.ToByte(checkBox_Healer.Checked));
bw.Write((byte)CB_Money.SelectedIndex);
bw.Write((ushort)CB_Prize.SelectedIndex);
File.WriteAllBytes(trdatapaths[index], ms.ToArray());
}
// Load Pokemon Data
using (MemoryStream ms = new MemoryStream())
using (BinaryWriter bw = new BinaryWriter(ms))
{
bw.BaseStream.Position = 0;
for (int i = 0; i < CB_numPokemon.SelectedIndex; i++)
{
bw.Write((byte)trpk_IV[i].SelectedIndex);
byte PID = (byte)((trpk_abil[i].SelectedIndex << 4) + trpk_gender[i].SelectedIndex);
bw.Write((byte)PID);
bw.Write((ushort)trpk_lvl[i].SelectedIndex);
bw.Write((ushort)trpk_pkm[i].SelectedIndex);
bw.Write((ushort)trpk_form[i].SelectedIndex);
if (((format >> 1) & 1) == 1) // Items Exist in Data
bw.Write((ushort)trpk_item[i].SelectedIndex);
if (((format) & 1) == 1) // Moves Exist in Data
{
bw.Write((ushort)trpk_m1[i].SelectedIndex);
bw.Write((ushort)trpk_m2[i].SelectedIndex);
bw.Write((ushort)trpk_m3[i].SelectedIndex);
bw.Write((ushort)trpk_m4[i].SelectedIndex);
}
}
File.WriteAllBytes(trpokepaths[index],ms.ToArray());
}
}
private void Setup()
{
start = true;
string[] personalList = Directory.GetFiles("personal");
personal = new byte[personalList.Length][];
for (int i = 0; i < personalList.Length; i++)
personal[i] = File.ReadAllBytes("personal" + Path.DirectorySeparatorChar + i.ToString("000") + ".bin");
CB_TrainerID.Items.Clear();
for (int i = 0; i < trdatapaths.Length; i++)
CB_TrainerID.Items.Add(String.Format("{1} - {0}", i.ToString("000"), trName[i]));
CB_Trainer_Class.Items.Clear();
for (int i = 0; i < trClass.Length; i++)
CB_Trainer_Class.Items.Add(String.Format("{1} - {0}", i.ToString("000"), trClass[i]));
specieslist[0] = "---";
abilitylist[0] = itemlist[0] = movelist[0] = "";
for (int i = 0; i < 6; i++)
{
trpk_pkm[i].Items.Clear();
foreach (string s in specieslist)
trpk_pkm[i].Items.Add(s);
trpk_m1[i].Items.Clear();
trpk_m2[i].Items.Clear();
trpk_m3[i].Items.Clear();
trpk_m4[i].Items.Clear();
foreach (string s in movelist)
{
trpk_m1[i].Items.Add(s);
trpk_m2[i].Items.Add(s);
trpk_m3[i].Items.Add(s);
trpk_m4[i].Items.Add(s);
}
trpk_item[i].Items.Clear();
foreach (string s in itemlist)
trpk_item[i].Items.Add(s);
trpk_lvl[i].Items.Clear();
for (int z = 0; z <= 100; z++)
trpk_lvl[i].Items.Add((z).ToString());
trpk_IV[i].Items.Clear();
for (int z = 0; z < 256; z++)
trpk_IV[i].Items.Add(z.ToString());
trpk_gender[i].Items.Clear();
trpk_gender[i].Items.Add("♂ / M");
trpk_gender[i].Items.Add("♀ / F");
trpk_gender[i].Items.Add("- / G");
trpk_form[i].Items.Add("");
trpk_pkm[i].SelectedIndex = 0;
}
CB_Item_1.Items.Clear();
CB_Item_2.Items.Clear();
CB_Item_3.Items.Clear();
CB_Item_4.Items.Clear();
CB_Prize.Items.Clear();
foreach (string s in itemlist)
{
CB_Item_1.Items.Add(s);
CB_Item_2.Items.Add(s);
CB_Item_3.Items.Add(s);
CB_Item_4.Items.Add(s);
CB_Prize.Items.Add(s);
}
CB_AI.Items.Clear(); CB_Money.Items.Clear();
for (int i = 0; i < 256; i++)
{ CB_AI.Items.Add(i.ToString()); CB_Money.Items.Add(i.ToString()); }
CB_Battle_Type.Items.Clear();
CB_Battle_Type.Items.Add("Single");
CB_Battle_Type.Items.Add("Double");
CB_Battle_Type.Items.Add("Triple");
CB_Battle_Type.Items.Add("Rotation");
CB_Battle_Type.Items.Add("Horde");
CB_TrainerID.SelectedIndex = 1;
start = false;
readFile();
System.Media.SystemSounds.Asterisk.Play();
}
public static bool rPKM, rMove, rAbility, rDiffAI, rDiffIV, rClass, rGift, rItem, rDoRand;
public static decimal rGiftPercent;
private void B_Randomize_Click(object sender, EventArgs e)
{
rPKM = rMove = rAbility = rDiffAI = rDiffIV = rClass = rGift = rItem = rDoRand = false; // init to false
rGiftPercent = 0; // 0
(new TrainerRand()).ShowDialog(); // Open Randomizer Config to get config vals
if (rDoRand)
Randomize();
}
private void Randomize()
{
for (int i = 1; i < CB_TrainerID.Items.Count; i++)
{
CB_TrainerID.SelectedIndex = i; // data is loaded
// Setup
checkBox_Moves.Checked = rMove;
checkBox_Item.Checked = rItem;
// Randomize Trainer Stats
if (rDiffAI)
CB_AI.SelectedIndex = CB_AI.Items.Count - 1; // max
if (rClass)
CB_Trainer_Class.SelectedIndex = (int)(rnd32() % (CB_Trainer_Class.Items.Count));
if (rGift && rnd32() % 100 < rGiftPercent)
#region Random Prize Logic
{
ushort[] items;
uint rand = rnd32() % 10;
if (rand < 2) // held item
items = (oras) ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY;
else if (rand < 5) // medicine
items = (oras) ? Legal.Pouch_Medicine_ORAS : Legal.Pouch_Medicine_XY;
else // berry
items = Legal.Pouch_Berry_XY;
CB_Prize.SelectedIndex = items[(rnd32() % items.Length)];
}
#endregion
else if (rGift)
CB_Prize.SelectedIndex = 0;
ushort[] itemlist = (oras) ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY;
itemlist = itemlist.Concat(Legal.Pouch_Berry_XY).ToArray();
int moves = trpk_m1[0].Items.Count;
int itemC = itemlist.Length;
// Randomize Pokemon
for (int p = 0; p < CB_numPokemon.SelectedIndex; p++)
{
if (rPKM)
{
// randomize pokemon
int species = (int)(rnd32() % 722);
trpk_pkm[p].SelectedIndex = species;
// Set Gender
{
int gv = personal[species][0x12];
int g = (int)(rnd32() % 0x100);
if (gv == 0xFF) // genderless
g = 2;
else if (gv == 0xFE) // female only
g = 1;
else if (gv == 0) // male only
g = 0;
else
g = Convert.ToInt16(g < gv); // if greater than, is female
trpk_gender[p].SelectedIndex = g;
}
// randomize form
int forms = (trpk_form[p].Items.Count - 1);
if (forms > 0)
trpk_form[p].SelectedIndex = (int)(rnd32() % (forms + 1));
}
if (rAbility)
trpk_abil[p].SelectedIndex = (int)(1 + rnd32() % 3);
if (rDiffIV)
trpk_IV[p].SelectedIndex = 255;
if (rItem)
#region RandomItem
trpk_item[p].SelectedIndex = itemlist[(rnd32() % itemC)];
#endregion
if (rMove)
{
trpk_m1[p].SelectedIndex = (int)(rnd32() % (moves));
trpk_m2[p].SelectedIndex = (int)(rnd32() % (moves));
trpk_m3[p].SelectedIndex = (int)(rnd32() % (moves));
trpk_m4[p].SelectedIndex = (int)(rnd32() % (moves));
}
}
}
CB_TrainerID.SelectedIndex = 1;
Util.Alert("Randomized all trainers according to specification!", "Press the Dump to TXT to view the new trainer information!");
}
}
}

120
pk3DS/RSTE.resx Normal file
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>

215
pk3DS/TrainerRand.Designer.cs generated Normal file
View File

@@ -0,0 +1,215 @@
namespace pk3DS
{
partial class TrainerRand
{
/// <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.CHK_RandomPKM = new System.Windows.Forms.CheckBox();
this.CHK_RandomItems = new System.Windows.Forms.CheckBox();
this.CHK_RandomMoves = new System.Windows.Forms.CheckBox();
this.CHK_RandomAbilities = new System.Windows.Forms.CheckBox();
this.CHK_RandomGift = new System.Windows.Forms.CheckBox();
this.CHK_RandomClass = new System.Windows.Forms.CheckBox();
this.CHK_MaxDiffAI = new System.Windows.Forms.CheckBox();
this.CHK_MaxDiffPKM = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.NUD_GiftPercent = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.NUD_GiftPercent)).BeginInit();
this.SuspendLayout();
//
// CHK_RandomPKM
//
this.CHK_RandomPKM.AutoSize = true;
this.CHK_RandomPKM.Checked = true;
this.CHK_RandomPKM.CheckState = System.Windows.Forms.CheckState.Checked;
this.CHK_RandomPKM.Location = new System.Drawing.Point(12, 12);
this.CHK_RandomPKM.Name = "CHK_RandomPKM";
this.CHK_RandomPKM.Size = new System.Drawing.Size(114, 17);
this.CHK_RandomPKM.TabIndex = 0;
this.CHK_RandomPKM.Text = "Random Pokemon";
this.CHK_RandomPKM.UseVisualStyleBackColor = true;
//
// CHK_RandomItems
//
this.CHK_RandomItems.AutoSize = true;
this.CHK_RandomItems.Location = new System.Drawing.Point(12, 193);
this.CHK_RandomItems.Name = "CHK_RandomItems";
this.CHK_RandomItems.Size = new System.Drawing.Size(119, 17);
this.CHK_RandomItems.TabIndex = 1;
this.CHK_RandomItems.Text = "Random Held Items";
this.CHK_RandomItems.UseVisualStyleBackColor = true;
//
// CHK_RandomMoves
//
this.CHK_RandomMoves.AutoSize = true;
this.CHK_RandomMoves.Checked = true;
this.CHK_RandomMoves.CheckState = System.Windows.Forms.CheckState.Checked;
this.CHK_RandomMoves.Location = new System.Drawing.Point(12, 35);
this.CHK_RandomMoves.Name = "CHK_RandomMoves";
this.CHK_RandomMoves.Size = new System.Drawing.Size(101, 17);
this.CHK_RandomMoves.TabIndex = 2;
this.CHK_RandomMoves.Text = "Random Moves";
this.CHK_RandomMoves.UseVisualStyleBackColor = true;
//
// CHK_RandomAbilities
//
this.CHK_RandomAbilities.AutoSize = true;
this.CHK_RandomAbilities.Checked = true;
this.CHK_RandomAbilities.CheckState = System.Windows.Forms.CheckState.Checked;
this.CHK_RandomAbilities.Location = new System.Drawing.Point(12, 58);
this.CHK_RandomAbilities.Name = "CHK_RandomAbilities";
this.CHK_RandomAbilities.Size = new System.Drawing.Size(193, 17);
this.CHK_RandomAbilities.TabIndex = 3;
this.CHK_RandomAbilities.Text = "Random Abilities (Including Hidden)";
this.CHK_RandomAbilities.UseVisualStyleBackColor = true;
//
// CHK_RandomGift
//
this.CHK_RandomGift.AutoSize = true;
this.CHK_RandomGift.Location = new System.Drawing.Point(12, 170);
this.CHK_RandomGift.Name = "CHK_RandomGift";
this.CHK_RandomGift.Size = new System.Drawing.Size(145, 17);
this.CHK_RandomGift.TabIndex = 4;
this.CHK_RandomGift.Text = "Random After-Battle Gifts";
this.CHK_RandomGift.UseVisualStyleBackColor = true;
this.CHK_RandomGift.CheckedChanged += new System.EventHandler(this.CHK_RandomGift_CheckedChanged);
//
// CHK_RandomClass
//
this.CHK_RandomClass.AutoSize = true;
this.CHK_RandomClass.Location = new System.Drawing.Point(12, 147);
this.CHK_RandomClass.Name = "CHK_RandomClass";
this.CHK_RandomClass.Size = new System.Drawing.Size(141, 17);
this.CHK_RandomClass.TabIndex = 5;
this.CHK_RandomClass.Text = "Random Trainer Classes";
this.CHK_RandomClass.UseVisualStyleBackColor = true;
//
// CHK_MaxDiffAI
//
this.CHK_MaxDiffAI.AutoSize = true;
this.CHK_MaxDiffAI.Location = new System.Drawing.Point(12, 104);
this.CHK_MaxDiffAI.Name = "CHK_MaxDiffAI";
this.CHK_MaxDiffAI.Size = new System.Drawing.Size(219, 17);
this.CHK_MaxDiffAI.TabIndex = 6;
this.CHK_MaxDiffAI.Text = "[NOT VISIBLE] Max Difficulty (Trainer AI)";
this.CHK_MaxDiffAI.UseVisualStyleBackColor = true;
this.CHK_MaxDiffAI.Visible = false;
//
// CHK_MaxDiffPKM
//
this.CHK_MaxDiffPKM.AutoSize = true;
this.CHK_MaxDiffPKM.Checked = true;
this.CHK_MaxDiffPKM.CheckState = System.Windows.Forms.CheckState.Checked;
this.CHK_MaxDiffPKM.Location = new System.Drawing.Point(12, 81);
this.CHK_MaxDiffPKM.Name = "CHK_MaxDiffPKM";
this.CHK_MaxDiffPKM.Size = new System.Drawing.Size(161, 17);
this.CHK_MaxDiffPKM.TabIndex = 7;
this.CHK_MaxDiffPKM.Text = "Max Difficulty (Pokemon IVs)";
this.CHK_MaxDiffPKM.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(212, 189);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(60, 23);
this.button1.TabIndex = 8;
this.button1.Text = "OK";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.B_Save_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(146, 189);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(60, 23);
this.button2.TabIndex = 9;
this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.B_Close_Click);
//
// NUD_GiftPercent
//
this.NUD_GiftPercent.Enabled = false;
this.NUD_GiftPercent.Location = new System.Drawing.Point(163, 167);
this.NUD_GiftPercent.Name = "NUD_GiftPercent";
this.NUD_GiftPercent.Size = new System.Drawing.Size(43, 20);
this.NUD_GiftPercent.TabIndex = 10;
this.NUD_GiftPercent.ValueChanged += new System.EventHandler(this.changePercent);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(212, 171);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(15, 13);
this.label1.TabIndex = 11;
this.label1.Text = "%";
//
// Randomizer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 222);
this.Controls.Add(this.label1);
this.Controls.Add(this.NUD_GiftPercent);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.CHK_MaxDiffPKM);
this.Controls.Add(this.CHK_MaxDiffAI);
this.Controls.Add(this.CHK_RandomClass);
this.Controls.Add(this.CHK_RandomGift);
this.Controls.Add(this.CHK_RandomAbilities);
this.Controls.Add(this.CHK_RandomMoves);
this.Controls.Add(this.CHK_RandomItems);
this.Controls.Add(this.CHK_RandomPKM);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "Randomizer";
this.Text = "Randomizer";
((System.ComponentModel.ISupportInitialize)(this.NUD_GiftPercent)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.CheckBox CHK_RandomPKM;
private System.Windows.Forms.CheckBox CHK_RandomItems;
private System.Windows.Forms.CheckBox CHK_RandomMoves;
private System.Windows.Forms.CheckBox CHK_RandomAbilities;
private System.Windows.Forms.CheckBox CHK_RandomGift;
private System.Windows.Forms.CheckBox CHK_RandomClass;
private System.Windows.Forms.CheckBox CHK_MaxDiffAI;
private System.Windows.Forms.CheckBox CHK_MaxDiffPKM;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.NumericUpDown NUD_GiftPercent;
private System.Windows.Forms.Label label1;
}
}

52
pk3DS/TrainerRand.cs Normal file
View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace pk3DS
{
public partial class TrainerRand : Form
{
public TrainerRand()
{
InitializeComponent();
}
private void B_Close_Click(object sender, EventArgs e)
{
this.Close();
}
private void B_Save_Click(object sender, EventArgs e)
{
RSTE.rPKM = CHK_RandomPKM.Checked;
RSTE.rMove = CHK_RandomMoves.Checked;
RSTE.rAbility = CHK_RandomAbilities.Checked;
RSTE.rDiffAI = CHK_MaxDiffAI.Checked;
RSTE.rDiffIV = CHK_MaxDiffPKM.Checked;
RSTE.rClass = CHK_RandomClass.Checked;
RSTE.rGift = CHK_RandomGift.Checked;
RSTE.rGiftPercent = NUD_GiftPercent.Value;
RSTE.rItem = CHK_RandomItems.Checked;
RSTE.rDoRand = true;
this.Close();
}
private void CHK_RandomGift_CheckedChanged(object sender, EventArgs e)
{
NUD_GiftPercent.Enabled = CHK_RandomGift.Checked;
NUD_GiftPercent.Value = Convert.ToDecimal(CHK_RandomGift.Checked);
}
private void changePercent(object sender, EventArgs e)
{
CHK_RandomGift.Checked = (NUD_GiftPercent.Value != 0);
}
}
}

595
pk3DS/Util.cs Normal file
View File

@@ -0,0 +1,595 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Text.RegularExpressions;
namespace pk3DS
{
class Util
{ // Image Layering/Blending Utility
internal static Bitmap LayerImage(Image baseLayer, Image overLayer, int x, int y, double trans)
{
Bitmap overlayImage = (Bitmap)overLayer;
Bitmap newImage = (Bitmap)baseLayer;
if (baseLayer == null) return overlayImage;
for (int i = 0; i < (overlayImage.Width * overlayImage.Height); i++)
{
Color newColor = overlayImage.GetPixel(i % (overlayImage.Width), i / (overlayImage.Width));
Color oldColor = newImage.GetPixel(i % (overlayImage.Width) + x, i / (overlayImage.Width) + y);
newColor = Color.FromArgb((int)((double)(newColor.A) * trans), newColor.R, newColor.G, newColor.B); // Apply transparency change
// if (newColor.A != 0) // If Pixel isn't transparent, we'll overwrite the color.
{
// if (newColor.A < 100)
newColor = AlphaBlend(newColor, oldColor);
newImage.SetPixel(
i % (overlayImage.Width) + x,
i / (overlayImage.Width) + y,
newColor);
}
}
return newImage;
}
internal static Bitmap ChangeOpacity(Image img, double trans)
{
if (img == null) return null;
Bitmap bmp = new Bitmap(img.Width, img.Height); // Determining Width and Height of Source Image
Graphics graphics = Graphics.FromImage(bmp);
ColorMatrix colormatrix = new ColorMatrix();
colormatrix.Matrix33 = (float)trans;
ImageAttributes imgAttribute = new ImageAttributes();
imgAttribute.SetColorMatrix(colormatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
graphics.DrawImage(img, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imgAttribute);
graphics.Dispose(); // Releasing all resource used by graphics
return bmp;
}
internal static Color AlphaBlend(Color ForeGround, Color BackGround)
{
if (ForeGround.A == 0)
return BackGround;
if (BackGround.A == 0)
return ForeGround;
if (ForeGround.A == 255)
return ForeGround;
int Alpha = Convert.ToInt32(ForeGround.A);
int B = Alpha * ForeGround.B + (255 - Alpha) * BackGround.B >> 8;
int G = Alpha * ForeGround.G + (255 - Alpha) * BackGround.G >> 8;
int R = Alpha * ForeGround.R + (255 - Alpha) * BackGround.R >> 8;
int A = ForeGround.A;
if (BackGround.A == 255)
A = 255;
if (A > 255)
A = 255;
if (R > 255)
R = 255;
if (G > 255)
G = 255;
if (B > 255)
B = 255;
return Color.FromArgb(Math.Abs(A), Math.Abs(R), Math.Abs(G), Math.Abs(B));
}
// Strings and Paths
internal static FileInfo GetNewestFile(DirectoryInfo directory)
{
return directory.GetFiles()
.Union(directory.GetDirectories().Select(d => GetNewestFile(d)))
.OrderByDescending(f => (f == null ? DateTime.MinValue : f.LastWriteTime))
.FirstOrDefault();
}
internal static string NormalizePath(string path)
{
return Path.GetFullPath(new Uri(path).LocalPath)
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
}
internal static string CleanFileName(string fileName)
{
return Path.GetInvalidFileNameChars().Aggregate(fileName, (current, c) => current.Replace(c.ToString(), string.Empty));
}
internal static string TrimFromZero(string input)
{
int index = input.IndexOf('\0');
if (index < 0)
return input;
return input.Substring(0, index);
}
internal static string[] getStringList(string f, string l)
{
object txt = Properties.Resources.ResourceManager.GetObject("text_" + f + "_" + l); // Fetch File, \n to list.
List<string> rawlist = ((string)txt).Split(new char[] { '\n' }).ToList();
string[] stringdata = new string[rawlist.Count];
for (int i = 0; i < rawlist.Count; i++)
stringdata[i] = rawlist[i].Trim();
return stringdata;
}
internal static string[] getSimpleStringList(string f)
{
object txt = Properties.Resources.ResourceManager.GetObject(f); // Fetch File, \n to list.
List<string> rawlist = ((string)txt).Split(new char[] { '\n' }).ToList();
string[] stringdata = new string[rawlist.Count];
for (int i = 0; i < rawlist.Count; i++)
stringdata[i] = rawlist[i].Trim();
return stringdata;
}
// Randomization
internal static Random rand = new Random();
internal static uint rnd32()
{
return (uint)(rand.Next(1 << 30)) << 2 | (uint)(rand.Next(1 << 2));
}
// Data Retrieval
internal static int ToInt32(TextBox tb)
{
string value = tb.Text;
return ToInt32(value);
}
internal static uint ToUInt32(TextBox tb)
{
string value = tb.Text;
return ToUInt32(value);
}
internal static int ToInt32(MaskedTextBox tb)
{
string value = tb.Text;
return ToInt32(value);
}
internal static uint ToUInt32(MaskedTextBox tb)
{
string value = tb.Text;
return ToUInt32(value);
}
internal static int ToInt32(String value)
{
value = value.Replace(" ", "");
if (String.IsNullOrEmpty(value))
return 0;
try
{
value = value.TrimEnd(new char[] { '_' });
return Int32.Parse(value);
}
catch { return 0; }
}
internal static uint ToUInt32(String value)
{
value = value.Replace(" ", "");
if (String.IsNullOrEmpty(value))
return 0;
try
{
value = value.TrimEnd(new char[] { '_' });
return UInt32.Parse(value);
}
catch { return 0; }
}
internal static uint getHEXval(TextBox tb)
{
if (tb.Text == null)
return 0;
string str = getOnlyHex(tb.Text);
return UInt32.Parse(str, NumberStyles.HexNumber);
}
internal static int getIndex(ComboBox cb)
{
int val = 0;
if (cb.SelectedValue == null)
return 0;
try
{ val = (int)cb.SelectedValue; }
catch
{ val = cb.SelectedIndex; if (val < 0) val = 0; }
return val;
}
internal static string getOnlyHex(string str)
{
if (str == null) return "0";
char c;
string s = "";
for (int i = 0; i < str.Length; i++)
{
c = str[i];
// filter for hex
if ((c < 0x0047 && c > 0x002F) || (c < 0x0067 && c > 0x0060))
s += c;
else
System.Media.SystemSounds.Beep.Play();
}
if (s.Length == 0)
s = "0";
return s;
}
// Data Manipulation
internal static void Shuffle<T>(T[] array)
{
int n = array.Length;
for (int i = 0; i < n; i++)
{
int r = i + (int)(rand.NextDouble() * (n - i));
T t = array[r];
array[r] = array[i];
array[i] = t;
}
}
// Form Translation
internal static void TranslateInterface(Control form, string lang, MenuStrip menu = null)
{
string FORM_NAME = form.Name;
Control.ControlCollection Controls = form.Controls;
// debug(Controls);
// Fetch a File
// Check to see if a the translation file exists in the same folder as the executable
string externalLangPath = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "lang_" + lang + ".txt";
string[] rawlist;
if (File.Exists(externalLangPath))
rawlist = File.ReadAllLines(externalLangPath);
else
{
object txt;
txt = Properties.Resources.ResourceManager.GetObject("lang_" + lang); // Fetch File, \n to list.
if (txt == null) return; // Translation file does not exist as a resource; abort this function and don't translate UI.
string[] stringSeparators = new string[] { "\r\n" }; // Resource files are notepad compatible
rawlist = ((string)txt).Split(stringSeparators, StringSplitOptions.None);
rawlist = rawlist.Select(i => i.Trim()).ToArray(); // Remove trailing spaces
}
string[] stringdata = new string[rawlist.Length];
int itemsToRename = 0;
for (int i = 0; i < rawlist.Length; i++)
{
// Find our starting point
if (rawlist[i].Contains("! " + FORM_NAME)) // Start our data
{
// Allow renaming of the Window Title
string[] WindowName = Regex.Split(rawlist[i], " = ");
if (WindowName.Length > 1) form.Text = WindowName[1];
// Copy our Control Names and Text to a new array for later processing.
for (int j = i + 1; j < rawlist.Length; j++)
{
if (rawlist[j].Length == 0)
continue; // Skip Over Empty Lines, errhandled
if (rawlist[j][0].ToString() != "-") // If line is not a comment line...
{
if (rawlist[j][0].ToString() == "!") // Stop if we have reached the end of translation
goto rename;
stringdata[itemsToRename] = rawlist[j]; // Add the entry to process later.
itemsToRename++;
}
}
}
}
return; // Not Found
// Now that we have our items to rename in: Control = Text format, let's execute the changes!
rename:
for (int i = 0; i < itemsToRename; i++)
{
string[] SplitString = Regex.Split(stringdata[i], " = ");
if (SplitString.Length < 2)
continue; // Error in Input, errhandled
string ctrl = SplitString[0]; // Control to change the text of...
string text = SplitString[1]; // Text to set Control.Text to...
Control[] controllist = Controls.Find(ctrl, true);
if (controllist.Length == 0) // If Control isn't found...
try
{
// Menu Items can't be found with Controls.Find as they aren't Controls
ToolStripDropDownItem TSI = (ToolStripDropDownItem)menu.Items[ctrl];
if (TSI != null)
{
// We'll rename the main and child in a row.
string[] ToolItems = Regex.Split(SplitString[1], " ; ");
TSI.Text = ToolItems[0]; // Set parent's text first
if (TSI.DropDownItems.Count != ToolItems.Length - 1)
continue; // Error in Input, errhandled
for (int ti = 1; ti <= TSI.DropDownItems.Count; ti++)
TSI.DropDownItems[ti - 1].Text = ToolItems[ti]; // Set child text
}
// If not found, it is not something to rename and is thus skipped.
}
catch { }
else // Set the input control's text.
controllist[0].Text = text;
}
}
// Message Displays
internal static DialogResult Error(params string[] lines)
{
System.Media.SystemSounds.Exclamation.Play();
string msg = String.Join(Environment.NewLine + Environment.NewLine, lines);
return (DialogResult)MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
internal static DialogResult Alert(params string[] lines)
{
System.Media.SystemSounds.Asterisk.Play();
string msg = String.Join(Environment.NewLine + Environment.NewLine, lines);
return (DialogResult)MessageBox.Show(msg, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
internal static DialogResult Prompt(MessageBoxButtons btn, params string[] lines)
{
System.Media.SystemSounds.Question.Play();
string msg = String.Join(Environment.NewLine + Environment.NewLine, lines);
return (DialogResult)MessageBox.Show(msg, "Prompt", btn, MessageBoxIcon.Asterisk);
}
// DataSource Providing
public class cbItem
{
public string Text { get; set; }
public object Value { get; set; }
}
internal static List<cbItem> getCBList(string textfile, string lang)
{
// Set up
List<cbItem> cbList = new List<cbItem>();
string[] inputCSV = Util.getSimpleStringList(textfile);
// Get Language we're fetching for
int index = Array.IndexOf(new string[] { "ja", "en", "fr", "de", "it", "es", "ko", "zh", }, lang);
// Set up our Temporary Storage
string[] unsortedList = new string[inputCSV.Length - 1];
int[] indexes = new int[inputCSV.Length - 1];
// Gather our data from the input file
for (int i = 1; i < inputCSV.Length; i++)
{
string[] countryData = inputCSV[i].Split(',');
indexes[i - 1] = Convert.ToInt32(countryData[0]);
unsortedList[i - 1] = countryData[index + 1];
}
// Sort our input data
string[] sortedList = new string[inputCSV.Length - 1];
Array.Copy(unsortedList, sortedList, unsortedList.Length);
Array.Sort(sortedList);
// Arrange the input data based on original number
for (int i = 0; i < sortedList.Length; i++)
{
cbItem ncbi = new cbItem();
ncbi.Text = sortedList[i];
ncbi.Value = indexes[Array.IndexOf(unsortedList, sortedList[i])];
cbList.Add(ncbi);
}
return cbList;
}
internal static List<cbItem> getCBList(string[] inStrings, params int[][] allowed)
{
List<cbItem> cbList = new List<cbItem>();
if (allowed == null)
allowed = new int[][] { Enumerable.Range(0, inStrings.Length).ToArray() };
foreach (int[] list in allowed)
{
// Sort the Rest based on String Name
string[] unsortedChoices = new string[list.Length];
for (int i = 0; i < list.Length; i++)
unsortedChoices[i] = inStrings[list[i]];
string[] sortedChoices = new string[unsortedChoices.Length];
Array.Copy(unsortedChoices, sortedChoices, unsortedChoices.Length);
Array.Sort(sortedChoices);
// Add the rest of the items
for (int i = 0; i < sortedChoices.Length; i++)
{
cbItem ncbi = new cbItem();
ncbi.Text = sortedChoices[i];
ncbi.Value = list[Array.IndexOf(unsortedChoices, sortedChoices[i])];
cbList.Add(ncbi);
}
}
return cbList;
}
internal static List<cbItem> getOffsetCBList(List<cbItem> cbList, string[] inStrings, int offset, int[] allowed)
{
if (allowed == null)
allowed = Enumerable.Range(0, inStrings.Length).ToArray();
int[] list = (int[])allowed.Clone();
for (int i = 0; i < list.Length; i++)
list[i] -= offset;
{
// Sort the Rest based on String Name
string[] unsortedChoices = new string[allowed.Length];
for (int i = 0; i < allowed.Length; i++)
unsortedChoices[i] = inStrings[list[i]];
string[] sortedChoices = new string[unsortedChoices.Length];
Array.Copy(unsortedChoices, sortedChoices, unsortedChoices.Length);
Array.Sort(sortedChoices);
// Add the rest of the items
for (int i = 0; i < sortedChoices.Length; i++)
{
cbItem ncbi = new cbItem();
ncbi.Text = sortedChoices[i];
ncbi.Value = allowed[Array.IndexOf(unsortedChoices, sortedChoices[i])];
cbList.Add(ncbi);
}
}
return cbList;
}
internal static List<cbItem> getVariedCBList(List<cbItem> cbList, string[] inStrings, int[] stringNum, int[] stringVal)
{
// Set up
List<cbItem> newlist = new List<cbItem>();
for (int i = 4; i > 1; i--) // add 4,3,2
{
// First 3 Balls are always first
cbItem ncbi = new cbItem();
ncbi.Text = inStrings[i];
ncbi.Value = i;
newlist.Add(ncbi);
}
// Sort the Rest based on String Name
string[] ballnames = new string[stringNum.Length];
for (int i = 0; i < stringNum.Length; i++)
ballnames[i] = inStrings[stringNum[i]];
string[] sortedballs = new string[stringNum.Length];
Array.Copy(ballnames, sortedballs, ballnames.Length);
Array.Sort(sortedballs);
// Add the rest of the balls
for (int i = 0; i < sortedballs.Length; i++)
{
cbItem ncbi = new cbItem();
ncbi.Text = sortedballs[i];
ncbi.Value = stringVal[Array.IndexOf(ballnames, sortedballs[i])];
newlist.Add(ncbi);
}
return newlist;
}
internal static List<cbItem> getUnsortedCBList(string textfile)
{
// Set up
List<cbItem> cbList = new List<cbItem>();
string[] inputCSV = Util.getSimpleStringList(textfile);
// Gather our data from the input file
for (int i = 1; i < inputCSV.Length; i++)
{
string[] inputData = inputCSV[i].Split(',');
cbItem ncbi = new cbItem();
ncbi.Value = Convert.ToInt32(inputData[0]);
ncbi.Text = inputData[1];
cbList.Add(ncbi);
}
return cbList;
}
// GARCTool Utility
internal static string GuessExtension(BinaryReader br, string defaultExt, bool bypass)
{
try
{
string ext = "";
long position = br.BaseStream.Position;
byte[] magic = System.Text.Encoding.ASCII.GetBytes(br.ReadChars(4));
// check for extensions
{
ushort count = BitConverter.ToUInt16(magic, 2);
// check for 2char container extensions
try
{
br.BaseStream.Position = position + 4 + 4 * count;
if (br.ReadUInt32() == br.BaseStream.Length)
{
ext += (char)magic[0] + (char)magic[1];
goto end;
}
}
catch { }
if (bypass) return defaultExt;
// check for darc
try
{
count = BitConverter.ToUInt16(magic, 0);
br.BaseStream.Position = position + 4 + 0x40 * count;
uint tableval = br.ReadUInt32();
br.BaseStream.Position += 0x20 * tableval;
while (br.PeekChar() == 0) // seek forward
br.ReadByte();
if (br.ReadUInt32() == 0x63726164)
return "darc";
}
catch { };
// check for bclim
try
{
br.BaseStream.Position = br.BaseStream.Length - 0x28;
if (br.ReadUInt32() == 0x4D494C43)
{
br.BaseStream.Position = br.BaseStream.Length - 0x4;
if (br.ReadUInt32() == br.BaseStream.Length - 0x28)
return "bclim";
}
}
catch { }
// generic check
{
if (magic[0] < 0x41)
return defaultExt;
for (int i = 0; i < magic.Length && i < 4; i++)
{
if ((magic[i] >= 'a' && magic[i] <= 'z') || (magic[i] >= 'A' && magic[i] <= 'Z')
|| char.IsDigit((char)magic[i]))
{
ext += (char)magic[i];
}
else
break;
}
}
}
end:
{
// Return BaseStream position to the start.
br.BaseStream.Position = position;
if (ext.Length <= 1)
return defaultExt;
return ext;
}
}
catch { return defaultExt; }
}
internal static string GuessExtension(string path, bool bypass)
{
using (BinaryReader br = new BinaryReader(System.IO.File.OpenRead(path)))
return Util.GuessExtension(br, "bin", bypass);
}
internal static uint Reverse(uint x)
{
uint y = 0;
for (int i = 0; i < 32; ++i)
{
y <<= 1;
y |= (x & 1);
x >>= 1;
}
return y;
}
internal static char[] Reverse(char[] charArray)
{
Array.Reverse(charArray);
return charArray;
}
// Text File Utility
internal static string getRandomFileName()
{
Random random = new Random((int)DateTime.Now.Ticks);//thanks to McAden
int size = 8;
string s = "";
for (int i = 0; i < size; i++)
s += Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
return s;
}
}
}

117
pk3DS/pk3DS.csproj Normal file
View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C4CB2488-2DB9-489F-8B02-A8E872C6C6AB}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>pk3DS</RootNamespace>
<AssemblyName>pk3DS</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GARCTool.cs" />
<Compile Include="Legal.cs" />
<Compile Include="Main.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Main.Designer.cs">
<DependentUpon>Main.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TrainerRand.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="TrainerRand.Designer.cs">
<DependentUpon>TrainerRand.cs</DependentUpon>
</Compile>
<Compile Include="RSTE.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RSTE.Designer.cs">
<DependentUpon>RSTE.cs</DependentUpon>
</Compile>
<Compile Include="Util.cs" />
<Compile Include="xytext.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="xytext.Designer.cs">
<DependentUpon>xytext.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Main.resx">
<DependentUpon>Main.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="RSTE.resx">
<DependentUpon>RSTE.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="xytext.resx">
<DependentUpon>xytext.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

141
pk3DS/xytext.Designer.cs generated Normal file
View File

@@ -0,0 +1,141 @@
namespace pk3DS
{
partial class xytext
{
/// <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.CB_Entry = new System.Windows.Forms.ComboBox();
this.dgv = new System.Windows.Forms.DataGridView();
this.B_AddLine = new System.Windows.Forms.Button();
this.B_RemoveLine = new System.Windows.Forms.Button();
this.B_Dump = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dgv)).BeginInit();
this.SuspendLayout();
//
// CB_Entry
//
this.CB_Entry.FormattingEnabled = true;
this.CB_Entry.Location = new System.Drawing.Point(68, 7);
this.CB_Entry.Name = "CB_Entry";
this.CB_Entry.Size = new System.Drawing.Size(79, 21);
this.CB_Entry.TabIndex = 5;
this.CB_Entry.SelectedIndexChanged += new System.EventHandler(this.changeEntry);
//
// dgv
//
this.dgv.AllowUserToAddRows = false;
this.dgv.AllowUserToDeleteRows = false;
this.dgv.AllowUserToResizeRows = false;
this.dgv.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.dgv.BackgroundColor = System.Drawing.SystemColors.Control;
this.dgv.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgv.Location = new System.Drawing.Point(12, 33);
this.dgv.Name = "dgv";
this.dgv.RowHeadersVisible = false;
this.dgv.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.dgv.ShowEditingIcon = false;
this.dgv.Size = new System.Drawing.Size(610, 317);
this.dgv.TabIndex = 0;
//
// B_AddLine
//
this.B_AddLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.B_AddLine.Location = new System.Drawing.Point(356, 5);
this.B_AddLine.Name = "B_AddLine";
this.B_AddLine.Size = new System.Drawing.Size(130, 23);
this.B_AddLine.TabIndex = 6;
this.B_AddLine.Text = "Add Line After Line";
this.B_AddLine.UseVisualStyleBackColor = true;
this.B_AddLine.Click += new System.EventHandler(this.B_AddLine_Click);
//
// B_RemoveLine
//
this.B_RemoveLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.B_RemoveLine.Location = new System.Drawing.Point(493, 5);
this.B_RemoveLine.Name = "B_RemoveLine";
this.B_RemoveLine.Size = new System.Drawing.Size(130, 23);
this.B_RemoveLine.TabIndex = 7;
this.B_RemoveLine.Text = "Remove Selected Line";
this.B_RemoveLine.UseVisualStyleBackColor = true;
this.B_RemoveLine.Click += new System.EventHandler(this.B_RemoveLine_Click);
//
// B_Dump
//
this.B_Dump.Location = new System.Drawing.Point(153, 6);
this.B_Dump.Name = "B_Dump";
this.B_Dump.Size = new System.Drawing.Size(88, 23);
this.B_Dump.TabIndex = 8;
this.B_Dump.Text = "Dump to .txt";
this.B_Dump.UseVisualStyleBackColor = true;
this.B_Dump.Click += new System.EventHandler(this.dumpTXT_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 10);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 13);
this.label1.TabIndex = 9;
this.label1.Text = "Text File:";
//
// xytext
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(634, 362);
this.Controls.Add(this.label1);
this.Controls.Add(this.B_Dump);
this.Controls.Add(this.B_RemoveLine);
this.Controls.Add(this.B_AddLine);
this.Controls.Add(this.dgv);
this.Controls.Add(this.CB_Entry);
this.MinimumSize = new System.Drawing.Size(400, 300);
this.Name = "xytext";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Text Editor";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.xytext_FormClosing);
((System.ComponentModel.ISupportInitialize)(this.dgv)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox CB_Entry;
private System.Windows.Forms.DataGridView dgv;
private System.Windows.Forms.Button B_AddLine;
private System.Windows.Forms.Button B_RemoveLine;
private System.Windows.Forms.Button B_Dump;
private System.Windows.Forms.Label label1;
}
}

563
pk3DS/xytext.cs Normal file
View File

@@ -0,0 +1,563 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.IO;
namespace pk3DS
{
public partial class xytext : Form
{
public xytext(string[] infiles)
{
InitializeComponent();
files = infiles;
for (int i = 0; i < files.Length; i++)
CB_Entry.Items.Add(i.ToString());
CB_Entry.SelectedIndex = 0;
}
private string[] files;
private int entry = -1;
// IO
private void dumpTXT_Click(object sender, EventArgs e)
{
if (files.Length > 0)
{
SaveFileDialog saveDump = new SaveFileDialog();
saveDump.Filter = "Text File|*.txt";
DialogResult sdr = saveDump.ShowDialog();
if (sdr == DialogResult.OK)
{
bool newline = false;
if (Util.Prompt(MessageBoxButtons.YesNo, "Remove newline formatting?") == DialogResult.Yes)
newline = true;
string path = saveDump.FileName;
using (MemoryStream ms = new MemoryStream())
{
using (TextWriter tw = new StreamWriter(ms))
for (int i = 0; i < files.Length; i++)
{
string[] data = getStringsFromFile(files[i]);
tw.WriteLine("~~~~~~~~~~~~~~~");
tw.WriteLine("Text File : " + i.ToString());
tw.WriteLine("~~~~~~~~~~~~~~~");
if (data != null)
foreach (string line in data)
{
if (newline)
tw.WriteLine(line.Replace("\\n\\n"," ").Replace("\\n", " ").Replace("\\c", "").Replace("\\r", "")); // Strip out formatting
else
tw.WriteLine(line);
}
}
File.WriteAllBytes(path, ms.ToArray());
}
}
}
}
private void changeEntry(object sender, EventArgs e)
{
// Save All the old text
if (entry > -1) File.WriteAllBytes(files[entry], getBytesForFile(getCurrentDGLines()));
// Reset
entry = CB_Entry.SelectedIndex;
string file = files[entry];
string[] data = getStringsFromFile(file);
setStringsDataGridView(data);
}
private void B_SaveText_Click(object sender, EventArgs e)
{
File.WriteAllBytes(files[CB_Entry.SelectedIndex], getBytesForFile(getCurrentDGLines()));
}
// Main Handling
private void setStringsDataGridView(string[] textArray)
{
// Clear the datagrid row content to remove all text lines.
dgv.Rows.Clear();
if (textArray == null) // Error handling for bad inputs.
return;
// Clear the header columns, these are repopulated every time.
dgv.Columns.Clear();
// Reset settings and columns.
dgv.AllowUserToResizeColumns = false;
DataGridViewColumn dgvLine = new DataGridViewTextBoxColumn();
{
dgvLine.HeaderText = "Line";
dgvLine.DisplayIndex = 0;
dgvLine.Width = 32;
dgvLine.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
dgvLine.ReadOnly = true;
dgvLine.SortMode = DataGridViewColumnSortMode.NotSortable;
}
DataGridViewTextBoxColumn dgvText = new DataGridViewTextBoxColumn();
{
dgvText.HeaderText = "Text";
dgvText.DisplayIndex = 1;
dgvText.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dgvText.SortMode = DataGridViewColumnSortMode.NotSortable;
}
// Re-add the columns.
dgv.Columns.Add(dgvLine);
dgv.Columns.Add(dgvText);
// Add empty rows equal to how many entries.
dgv.Rows.Add(textArray.Length);
// Add the text lines into their cells.
for (int i = 0; i < textArray.Length; i++)
{
dgv.Rows[i].Cells[0].Value = i;
dgv.Rows[i].Cells[1].Value = textArray[i];
}
}
private string[] getCurrentDGLines()
{
// Get Line Count
string[] lines = new string[dgv.RowCount];
for (int i = 0; i < dgv.RowCount; i++)
lines[i] = (string)dgv.Rows[i].Cells[1].Value ?? String.Format("[~ {0}]", i.ToString());
return lines;
}
// Meta Usage
private void B_AddLine_Click(object sender, EventArgs e)
{
int currentRow = 0;
try
{
currentRow = dgv.CurrentRow.Index;
}
catch
{
dgv.Rows.Add();
}
if (dgv.Rows.Count == 1) { }
else if (currentRow < dgv.Rows.Count - 1 || currentRow == 0)
{
if (ModifierKeys != Keys.Control && currentRow != 0)
{
if (Util.Prompt(MessageBoxButtons.YesNo, "Inserting in between rows will shift all subsequent lines.", "Continue?") != DialogResult.Yes) return;
}
dgv.Rows.Insert(currentRow + 1);
}
for (int i = 0; i < dgv.Rows.Count; i++)
dgv.Rows[i].Cells[0].Value = i.ToString();
}
private void B_RemoveLine_Click(object sender, EventArgs e)
{
int currentRow = dgv.CurrentRow.Index;
if (currentRow < dgv.Rows.Count - 1)
{
if ((ModifierKeys != Keys.Control) && DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Deleting a row above other lines will shift all subsequent lines.", "Continue?"))
return;
}
dgv.Rows.RemoveAt(currentRow);
for (int i = 0; i < dgv.Rows.Count; i++)
dgv.Rows[i].Cells[0].Value = i.ToString();
}
// Top Level Functions
internal static string[] getStringsFromFile(string path)
{
byte[] data = File.ReadAllBytes(path);
ushort textSections = BitConverter.ToUInt16(data, 0);
ushort lineCount = BitConverter.ToUInt16(data, 2);
if (lineCount == 0) return null;
uint totalLength = BitConverter.ToUInt32(data, 4);
uint initialKey = BitConverter.ToUInt32(data, 8);
int sectionData = BitConverter.ToInt32(data, 12);
try // Some sanity checking to prevent errors.
{
if (initialKey != 0) throw new Exception("Invalid initial key! Not 0?");
if (sectionData + totalLength != data.Length || textSections != 1) throw new Exception("Invalid Text File");
uint sectionLength = BitConverter.ToUInt32(data, sectionData);
if (sectionLength != totalLength) throw new Exception("Section size and overall size do not match.");
}
catch { return null; };
// Prep result storage.
ushort key = 0x7C89;
string[] result = new string[lineCount];
for (int i = 0; i < lineCount; i++)
{
// Init
ushort k = key;
string s = "";
int offset = BitConverter.ToInt32(data, i * 8 + sectionData + 4) + sectionData;
int length = BitConverter.ToInt16(data, i * 8 + sectionData + 8);
int start = offset;
ushort c = 0; // u16 char
while (offset < start + length * 2) // loop through the entire text line
{
decryptU16(data, ref offset, ref c, ref k);
if (c == 0) // Terminated Line
break;
else if (c == '\n') s += "\\n";
else if (c == 0x10) // Variable
decryptVar(data, ref offset, ref s, ref c, ref k);
else // Regular Character
{
// Check special characters...
if (c == 0xE07F)
s += (char)0x202F; // nbsp
else if (c == 0xE08D)
s += (char)0x2026; // …
else if (c == 0xE08E)
s += (char)0x2642; // ♂
else if (c == 0xE08F)
s += (char)0x2640; // ♀
// Else append character without modification.
else s += (char)c;
}
}
// store string and set key for next line (if needed)
result[i] = s;
key += 0x2983;
}
return result;
}
internal static byte[] getBytesForFile(string[] lines)
{
using (MemoryStream textFile = new MemoryStream())
using (BinaryWriter bw = new BinaryWriter(textFile))
using (MemoryStream data = new MemoryStream())
using (BinaryWriter bz = new BinaryWriter(data))
{
ushort baseKey = 0x7C89;
// Write up header template
bw.Write((ushort)1); // Always 1 ?
bw.Write((ushort)lines.Length); // Line Count
bw.Write((uint)0); // (Temporary) Data Length - fixed at the end.
bw.Write((uint)0); // Key, constant 0.
bw.Write((uint)0x10); // Pointer to line data.
// Begin data
bw.Write((uint)0); // (Temporary) Data Length - fixed at the end.
for (int i = 0; i < lines.Length; i++)
{
ushort key = baseKey;
uint pos = (uint)data.Position;
// Get crypted line data.
{
{
// Write each character to the data stream, with handling for special characters.
for (int j = 0; j < lines[i].Length; j++)
{
ushort val = lines[i][j];
// Handle special text characters
// Private Use Area characters
if (val == 0x202F) val = 0xE07F; // nbsp
else if (val == 0x2026) val = 0xE08D; // …
else if (val == 0x2642) val = 0xE08E; // ♂
else if (val == 0x2640) val = 0xE08F; // ♀
// Variables
else if (val == '[' || val == '\\') // Variable
encryptVar(bz, lines[i], ref j, ref key);
// Text
else bz.Write(encryptU16(val, ref key));
}
bz.Write(encryptU16(0, ref key)); // Add the null terminator, after encrypting it.
}
// Write the lineOffset and charCount to the header.
bw.Write((uint)(pos + 0x4 + lines.Length * 8));
bw.Write((uint)(data.Position - pos) / 2);
if (data.Position % 4 > 0) bz.Write((ushort)0);
// Increment the line initial key for the next line.
baseKey += 0x2983;
}
}
// Copy the data stream to the textFile stream.
data.Position = 0; data.CopyTo(textFile);
// Fix the temp values
textFile.Position = 0x4; bw.Write((uint)textFile.Length - 0x10);
textFile.Position = 0x10; bw.Write((uint)textFile.Length - 0x10);
return textFile.ToArray();
}
}
// Text Encrypting
internal static ushort encryptU16(ushort val, ref ushort key)
{
val = (ushort)(key ^ val);
key = (ushort)(((key << 3) | (key >> 13)) & 0xffff);
return val;
}
internal static ushort decryptU16(byte[] data, ref int offset, ref ushort val, ref ushort key)
{
val = (ushort)(BitConverter.ToUInt16(data, offset) ^ key);
offset += 2;
key = (ushort)(((key << 3) | (key >> 13)) & 0xffff);
return val;
}
// Variable Handling
internal static ushort getVariableBytes(string varType, ref List<ushort> args)
{
// Fetch the variable name...
int bracket = varType.IndexOf('(');
string variable = varType.Substring(0, bracket);
string[] arguments = varType.Substring(bracket + 1, varType.Length - bracket - 2).Split(',');
ushort varVal = 0;
switch (variable)
{
case "COLOR": varVal = 0xFF00; break;
case "TRNAME": varVal = 0x0100; break;
case "PKNAME": varVal = 0x0101; break;
case "PKNICK": varVal = 0x0102; break;
case "TYPE": varVal = 0x0103; break;
case "LOCATION": varVal = 0x0105; break;
case "ABILITY": varVal = 0x0106; break;
case "MOVE": varVal = 0x0107; break;
case "ITEM1": varVal = 0x0108; break;
case "ITEM2": varVal = 0x0109; break;
case "sTRBAG": varVal = 0x010A; break;
case "BOX": varVal = 0x010B; break;
case "EVSTAT": varVal = 0x010D; break;
case "OPOWER": varVal = 0x0110; break;
case "RIBBON": varVal = 0x0127; break;
case "MIINAME": varVal = 0x0134; break;
case "WEATHER": varVal = 0x013E; break;
case "TRNICK": varVal = 0x0189; break;
case "1stchrTR": varVal = 0x018A; break;
case "SHOUTOUT": varVal = 0x018B; break;
case "BERRY": varVal = 0x018E; break;
case "REMFEEL": varVal = 0x018F; break;
case "REMQUAL": varVal = 0x0190; break;
case "WEBSITE": varVal = 0x0191; break;
case "CHOICECOS": varVal = 0x019C; break;
case "GSYNCID": varVal = 0x01A1; break;
case "PRVIDSAY": varVal = 0x0192; break;
case "BTLTEST": varVal = 0x0193; break;
case "GENLOC": varVal = 0x0195; break;
case "CHOICEFOOD": varVal = 0x0199; break;
case "HOTELITEM": varVal = 0x019A; break;
case "TAXISTOP": varVal = 0x019B; break;
case "MAISTITLE": varVal = 0x019F; break;
case "ITEMPLUR0": varVal = 0x1000; break;
case "ITEMPLUR1": varVal = 0x1001; break;
case "GENDBR": varVal = 0x1100; break;
case "NUMBRNCH": varVal = 0x1101; break;
case "iCOLOR2": varVal = 0x1302; break;
case "iCOLOR3": varVal = 0x1303; break;
case "NUM1": varVal = 0x0200; break;
case "NUM2": varVal = 0x0201; break;
case "NUM3": varVal = 0x0202; break;
case "NUM4": varVal = 0x0203; break;
case "NUM5": varVal = 0x0204; break;
case "NUM6": varVal = 0x0205; break;
case "NUM7": varVal = 0x0206; break;
case "NUM8": varVal = 0x0207; break;
case "NUM9": varVal = 0x0208; break;
default: varVal = Convert.ToUInt16(variable, 16); break;
}
// Set arguments in.
for (int i = 0; i < arguments.Length; i++)
args.Add(Convert.ToUInt16(arguments[i], 16));
// All done.
return varVal;
}
internal static void encryptVar(BinaryWriter bw, string line, ref int i, ref ushort key)
{
ushort val = line[i];
if (val == '\\') // Line Break
if (line[i + 1] == 'n')
{
i++;
bw.Write(encryptU16('\n', ref key));
}
else if (line[i + 1] == 'r')
{
bw.Write(encryptU16(0x10, ref key)); i++;
bw.Write(encryptU16(1, ref key));
bw.Write(encryptU16(0xBE00, ref key));
}
else if (line[i + 1] == 'c')
{
bw.Write(encryptU16(0x10, ref key)); i++;
bw.Write(encryptU16(1, ref key));
bw.Write(encryptU16(0xBE01, ref key));
}
else { throw new Exception("Invalid terminated line"); }
else if (val == '[') // Special Variable
{
int bracket = line.Substring(i + 1).IndexOf(']');
if (bracket < 3) throw new Exception("Variable encoding error!");
// [VAR X(a, b)]
// Remove the [ ] -> VAR X(a, b)
string varCMD = line.Substring(i + 1, bracket);
i += bracket + 1; // Advance the index to the end of the bracket.
string varMethod = varCMD.Split(' ')[0]; // Returns VAR or WAIT or ~
string varType = varCMD.Substring(varMethod.Length + 1); // Returns the remainder of the var command data.
ushort varValue = 0;
// Set up argument storage (even if it not used)
List<ushort> args = new List<ushort>();
try
{
switch (varMethod)
{
case "~": // Blank Text Line Variable (No text set - debug/quality testing variable?)
{
varValue = 0xBDFF;
args.Add(Convert.ToUInt16(varType));
break;
}
case "WAIT": // Event pause Variable.
{
varValue = 0xBE02;
args.Add(Convert.ToUInt16(varType));
break;
}
case "VAR": // Text Variable
{
varValue = getVariableBytes(varType, ref args);
break;
}
default: throw new Exception("Unknown variable method type!");
}
}
catch (Exception e)
{
Util.Alert("Variable error. Current line text is:", line, e.ToString());
}
// Write the Variable prefix.
bw.Write(encryptU16(0x0010, ref key));
// Write Length of the following Variable Data
bw.Write(encryptU16((ushort)(1 + args.Count), ref key));
// Write the Variable type.
bw.Write(encryptU16(varValue, ref key));
for (int j = 0; j < args.Count; j++)
bw.Write(encryptU16((ushort)args[j], ref key));
// Done.
}
}
internal static void decryptVar(byte[] d, ref int o, ref string s, ref ushort v, ref ushort k)
{
ushort length = decryptU16(d, ref o, ref v, ref k);
ushort varType = decryptU16(d, ref o, ref v, ref k);
switch (varType)
{
// Check the nonvariable types...
case 0xBE00: // "Waitbutton then scroll text;; \r"
{ s += "\\r"; return; }
case 0xBE01: // "Waitbutton then clear text;; \c"
{ s += "\\c"; return; }
case 0xBE02: // Dramatic pause for a text line. New!
{ s += "[WAIT " + decryptU16(d, ref o, ref v, ref k).ToString() + "]"; return; }
case 0xBDFF: // Empty Text line? Includes linenum so maybe for betatest finding used-unused lines?
{ s += "[~ " + decryptU16(d, ref o, ref v, ref k).ToString() + "]"; return; }
// Else a text variable, so let's loop through all the variable types. If we cannot find it, we just write the u16 val.
default:
{
ushort varCode = varType; // decryptU16(d, ref o, ref v, ref k);
string tvname = "";
switch (varCode) // get variable's info name
{
case 0xFF00: tvname = "COLOR"; break; // Change text line color (0 = white, 1 = red, 2 = blue...)
case 0x0100: tvname = "TRNAME"; break; //
case 0x0101: tvname = "PKNAME"; break;
case 0x0102: tvname = "PKNICK"; break;
case 0x0103: tvname = "TYPE"; break;
case 0x0105: tvname = "LOCATION"; break;
case 0x0106: tvname = "ABILITY"; break;
case 0x0107: tvname = "MOVE"; break;
case 0x0108: tvname = "ITEM1"; break;
case 0x0109: tvname = "ITEM2"; break;
case 0x010A: tvname = "sTRBAG"; break;
case 0x010B: tvname = "BOX"; break;
case 0x010D: tvname = "EVSTAT"; break;
case 0x0110: tvname = "OPOWER"; break;
case 0x0127: tvname = "RIBBON"; break;
case 0x0134: tvname = "MIINAME"; break;
case 0x013E: tvname = "WEATHER"; break;
case 0x0189: tvname = "TRNICK"; break;
case 0x018A: tvname = "1stchrTR"; break;
case 0x018B: tvname = "SHOUTOUT"; break;
case 0x018E: tvname = "BERRY"; break;
case 0x018F: tvname = "REMFEEL"; break;
case 0x0190: tvname = "REMQUAL"; break;
case 0x0191: tvname = "WEBSITE"; break;
case 0x019C: tvname = "CHOICECOS"; break;
case 0x01A1: tvname = "GSYNCID"; break;
case 0x0192: tvname = "PRVIDSAY"; break;
case 0x0193: tvname = "BTLTEST"; break;
case 0x0195: tvname = "GENLOC"; break;
case 0x0199: tvname = "CHOICEFOOD"; break;
case 0x019A: tvname = "HOTELITEM"; break;
case 0x019B: tvname = "TAXISTOP"; break;
case 0x019F: tvname = "MAISTITLE"; break;
case 0x1000: tvname = "ITEMPLUR0"; break;
case 0x1001: tvname = "ITEMPLUR1"; break;
case 0x1100: tvname = "GENDBR"; break;
case 0x1101: tvname = "NUMBRNCH"; break;
case 0x1302: tvname = "iCOLOR2"; break;
case 0x1303: tvname = "iCOLOR3"; break;
case 0x0200: tvname = "NUM1"; break;
case 0x0201: tvname = "NUM2"; break;
case 0x0202: tvname = "NUM3"; break;
case 0x0203: tvname = "NUM4"; break;
case 0x0204: tvname = "NUM5"; break;
case 0x0205: tvname = "NUM6"; break;
case 0x0206: tvname = "NUM7"; break;
case 0x0207: tvname = "NUM8"; break;
case 0x0208: tvname = "NUM9"; break;
default: tvname = varCode.ToString("X4"); break;
}
s += "[VAR" + " " + tvname;
if (length > 1)
{
s += '(';
while (length > 1)
{
// Write arguments
ushort arg = decryptU16(d, ref o, ref v, ref k);
length--;
s += arg.ToString("X4");
if (length == 1) break;
s += ",";
}
s += ')';
}
s += "]";
break;
}
}
}
private void xytext_FormClosing(object sender, FormClosingEventArgs e)
{
// Save All the old text
if (entry > -1) File.WriteAllBytes(files[entry], getBytesForFile(getCurrentDGLines()));
}
}
}

120
pk3DS/xytext.resx Normal file
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>