Update GUI tool
Add battle actions and general code cleanup
This commit is contained in:
parent
63cf5252b4
commit
037d4f367d
|
@ -28,8 +28,16 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.tptSelector = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.battleActionSelector = new System.Windows.Forms.ComboBox();
|
||||
this.backButton = new System.Windows.Forms.Button();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.textSplitContainer = new System.Windows.Forms.SplitContainer();
|
||||
this.previewSplitContainer = new System.Windows.Forms.SplitContainer();
|
||||
this.ebString = new System.Windows.Forms.TextBox();
|
||||
|
@ -43,12 +51,9 @@
|
|||
this.gameSelectorPanel = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.ebSelector = new System.Windows.Forms.RadioButton();
|
||||
this.m12Selector = new System.Windows.Forms.RadioButton();
|
||||
this.backButton = new System.Windows.Forms.Button();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.fileMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.flowLayoutPanel1.SuspendLayout();
|
||||
this.panel2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.textSplitContainer)).BeginInit();
|
||||
this.textSplitContainer.Panel1.SuspendLayout();
|
||||
this.textSplitContainer.Panel2.SuspendLayout();
|
||||
|
@ -61,29 +66,110 @@
|
|||
this.codeSplitContainer.Panel2.SuspendLayout();
|
||||
this.codeSplitContainer.SuspendLayout();
|
||||
this.gameSelectorPanel.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.panel2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileMenu});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(761, 24);
|
||||
this.menuStrip1.TabIndex = 8;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileMenu
|
||||
//
|
||||
this.fileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveMenu});
|
||||
this.fileMenu.Name = "fileMenu";
|
||||
this.fileMenu.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileMenu.Text = "File";
|
||||
//
|
||||
// saveMenu
|
||||
//
|
||||
this.saveMenu.Name = "saveMenu";
|
||||
this.saveMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.saveMenu.Size = new System.Drawing.Size(138, 22);
|
||||
this.saveMenu.Text = "Save";
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.flowLayoutPanel1.AutoSize = true;
|
||||
this.flowLayoutPanel1.Controls.Add(this.label4);
|
||||
this.flowLayoutPanel1.Controls.Add(this.tptSelector);
|
||||
this.flowLayoutPanel1.Controls.Add(this.label1);
|
||||
this.flowLayoutPanel1.Controls.Add(this.battleActionSelector);
|
||||
this.flowLayoutPanel1.Controls.Add(this.backButton);
|
||||
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 24);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(761, 29);
|
||||
this.flowLayoutPanel1.TabIndex = 10;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(3, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Padding = new System.Windows.Forms.Padding(3, 6, 3, 6);
|
||||
this.label4.Size = new System.Drawing.Size(63, 25);
|
||||
this.label4.TabIndex = 14;
|
||||
this.label4.Text = "TPT entry:";
|
||||
//
|
||||
// tptSelector
|
||||
//
|
||||
this.tptSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.tptSelector.FormattingEnabled = true;
|
||||
this.tptSelector.Location = new System.Drawing.Point(66, 4);
|
||||
this.tptSelector.Location = new System.Drawing.Point(72, 4);
|
||||
this.tptSelector.Margin = new System.Windows.Forms.Padding(3, 4, 3, 3);
|
||||
this.tptSelector.Name = "tptSelector";
|
||||
this.tptSelector.Size = new System.Drawing.Size(238, 21);
|
||||
this.tptSelector.TabIndex = 0;
|
||||
this.tptSelector.SelectionChangeCommitted += new System.EventHandler(this.tptSelector_SelectionChangeCommitted);
|
||||
this.tptSelector.TabIndex = 10;
|
||||
this.tptSelector.SelectionChangeCommitted += new System.EventHandler(this.selector_SelectionChangeCommitted);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(3, 7);
|
||||
this.label1.Location = new System.Drawing.Point(316, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(57, 13);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "TPT entry:";
|
||||
this.label1.Padding = new System.Windows.Forms.Padding(3, 6, 3, 6);
|
||||
this.label1.Size = new System.Drawing.Size(75, 25);
|
||||
this.label1.TabIndex = 11;
|
||||
this.label1.Text = "Battle action:";
|
||||
//
|
||||
// battleActionSelector
|
||||
//
|
||||
this.battleActionSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.battleActionSelector.FormattingEnabled = true;
|
||||
this.battleActionSelector.Location = new System.Drawing.Point(397, 4);
|
||||
this.battleActionSelector.Margin = new System.Windows.Forms.Padding(3, 4, 3, 3);
|
||||
this.battleActionSelector.Name = "battleActionSelector";
|
||||
this.battleActionSelector.Size = new System.Drawing.Size(238, 21);
|
||||
this.battleActionSelector.TabIndex = 13;
|
||||
this.battleActionSelector.SelectionChangeCommitted += new System.EventHandler(this.selector_SelectionChangeCommitted);
|
||||
//
|
||||
// backButton
|
||||
//
|
||||
this.backButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.backButton.Location = new System.Drawing.Point(641, 3);
|
||||
this.backButton.Name = "backButton";
|
||||
this.backButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.backButton.TabIndex = 12;
|
||||
this.backButton.Text = "Back";
|
||||
this.backButton.UseVisualStyleBackColor = true;
|
||||
this.backButton.Click += new System.EventHandler(this.backButton_Click);
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.AutoSize = true;
|
||||
this.panel2.Controls.Add(this.textSplitContainer);
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel2.Location = new System.Drawing.Point(0, 53);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(761, 560);
|
||||
this.panel2.TabIndex = 11;
|
||||
//
|
||||
// textSplitContainer
|
||||
//
|
||||
|
@ -178,7 +264,7 @@
|
|||
this.codeSplitContainer.Panel2.Controls.Add(this.referenceList);
|
||||
this.codeSplitContainer.Panel2.Controls.Add(this.label3);
|
||||
this.codeSplitContainer.Size = new System.Drawing.Size(222, 527);
|
||||
this.codeSplitContainer.SplitterDistance = 245;
|
||||
this.codeSplitContainer.SplitterDistance = 244;
|
||||
this.codeSplitContainer.TabIndex = 1;
|
||||
//
|
||||
// codeList
|
||||
|
@ -190,7 +276,7 @@
|
|||
this.codeList.Name = "codeList";
|
||||
this.codeList.ReadOnly = true;
|
||||
this.codeList.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.codeList.Size = new System.Drawing.Size(218, 222);
|
||||
this.codeList.Size = new System.Drawing.Size(218, 221);
|
||||
this.codeList.TabIndex = 1;
|
||||
//
|
||||
// label2
|
||||
|
@ -211,7 +297,7 @@
|
|||
this.referenceList.FormattingEnabled = true;
|
||||
this.referenceList.Location = new System.Drawing.Point(0, 19);
|
||||
this.referenceList.Name = "referenceList";
|
||||
this.referenceList.Size = new System.Drawing.Size(218, 255);
|
||||
this.referenceList.Size = new System.Drawing.Size(218, 256);
|
||||
this.referenceList.TabIndex = 2;
|
||||
this.referenceList.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.referenceList_MouseDoubleClick);
|
||||
//
|
||||
|
@ -248,7 +334,6 @@
|
|||
this.ebSelector.Text = "EB";
|
||||
this.ebSelector.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.ebSelector.UseVisualStyleBackColor = true;
|
||||
this.ebSelector.CheckedChanged += new System.EventHandler(this.gameSelector_CheckedChanged);
|
||||
//
|
||||
// m12Selector
|
||||
//
|
||||
|
@ -262,65 +347,6 @@
|
|||
this.m12Selector.Text = "M12";
|
||||
this.m12Selector.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.m12Selector.UseVisualStyleBackColor = true;
|
||||
this.m12Selector.CheckedChanged += new System.EventHandler(this.gameSelector_CheckedChanged);
|
||||
//
|
||||
// backButton
|
||||
//
|
||||
this.backButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.backButton.Location = new System.Drawing.Point(683, 3);
|
||||
this.backButton.Name = "backButton";
|
||||
this.backButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.backButton.TabIndex = 7;
|
||||
this.backButton.Text = "Back";
|
||||
this.backButton.UseVisualStyleBackColor = true;
|
||||
this.backButton.Click += new System.EventHandler(this.backButton_Click);
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileMenu});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(761, 24);
|
||||
this.menuStrip1.TabIndex = 8;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.AutoSize = true;
|
||||
this.panel1.Controls.Add(this.label1);
|
||||
this.panel1.Controls.Add(this.backButton);
|
||||
this.panel1.Controls.Add(this.tptSelector);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 24);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(761, 29);
|
||||
this.panel1.TabIndex = 9;
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Controls.Add(this.textSplitContainer);
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel2.Location = new System.Drawing.Point(0, 53);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(761, 560);
|
||||
this.panel2.TabIndex = 10;
|
||||
//
|
||||
// fileMenu
|
||||
//
|
||||
this.fileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveMenu});
|
||||
this.fileMenu.Name = "fileMenu";
|
||||
this.fileMenu.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileMenu.Text = "File";
|
||||
//
|
||||
// saveMenu
|
||||
//
|
||||
this.saveMenu.Name = "saveMenu";
|
||||
this.saveMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.saveMenu.Size = new System.Drawing.Size(152, 22);
|
||||
this.saveMenu.Text = "Save";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
|
@ -328,12 +354,17 @@
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(761, 613);
|
||||
this.Controls.Add(this.panel2);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Controls.Add(this.flowLayoutPanel1);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "MainForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "MOTHER 1+2 Funland";
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.flowLayoutPanel1.ResumeLayout(false);
|
||||
this.flowLayoutPanel1.PerformLayout();
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.textSplitContainer.Panel1.ResumeLayout(false);
|
||||
this.textSplitContainer.Panel2.ResumeLayout(false);
|
||||
this.textSplitContainer.Panel2.PerformLayout();
|
||||
|
@ -350,11 +381,6 @@
|
|||
((System.ComponentModel.ISupportInitialize)(this.codeSplitContainer)).EndInit();
|
||||
this.codeSplitContainer.ResumeLayout(false);
|
||||
this.gameSelectorPanel.ResumeLayout(false);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -362,27 +388,29 @@
|
|||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ComboBox tptSelector;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveMenu;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.ComboBox battleActionSelector;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button backButton;
|
||||
private System.Windows.Forms.ComboBox tptSelector;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.SplitContainer textSplitContainer;
|
||||
private System.Windows.Forms.SplitContainer previewSplitContainer;
|
||||
private System.Windows.Forms.TextBox ebString;
|
||||
private System.Windows.Forms.TextBox m12String;
|
||||
private System.Windows.Forms.TextBox m12StringEnglish;
|
||||
private System.Windows.Forms.FlowLayoutPanel gameSelectorPanel;
|
||||
private System.Windows.Forms.RadioButton ebSelector;
|
||||
private System.Windows.Forms.RadioButton m12Selector;
|
||||
private System.Windows.Forms.SplitContainer codeSplitContainer;
|
||||
private System.Windows.Forms.TextBox codeList;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.ListBox referenceList;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button backButton;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveMenu;
|
||||
private System.Windows.Forms.FlowLayoutPanel gameSelectorPanel;
|
||||
private System.Windows.Forms.RadioButton ebSelector;
|
||||
private System.Windows.Forms.RadioButton m12Selector;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,13 @@ namespace ScriptToolGui
|
|||
IList<string> ebStrings;
|
||||
|
||||
// Matched reference pairs
|
||||
List<MatchedReferenceGroup> matchedGroups = new List<MatchedReferenceGroup>();
|
||||
List<MatchedGroup> tptGroups = new List<MatchedGroup>();
|
||||
List<MatchedGroup> battleActionGroups = new List<MatchedGroup>();
|
||||
List<MatchedGroup> matchedGroups = new List<MatchedGroup>();
|
||||
|
||||
// Navigation stack
|
||||
MatchedReferenceGroup previousGroup = null;
|
||||
Stack<MatchedReferenceGroup> navigationStack = new Stack<MatchedReferenceGroup>();
|
||||
NavigationEntry previousNavigationState = null;
|
||||
Stack<NavigationEntry> navigationStack = new Stack<NavigationEntry>();
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
|
@ -52,11 +54,12 @@ namespace ScriptToolGui
|
|||
{ Game.M12English, m12StringsEnglish }
|
||||
};
|
||||
|
||||
PopulateTptList();
|
||||
PopulateSelectors();
|
||||
}
|
||||
|
||||
private void ImportAllStringRefs(string folder)
|
||||
{
|
||||
// TPT
|
||||
string m12PrimaryFileName = Path.Combine(folder, "m12-tpt-primary.json");
|
||||
string ebPrimaryFileName = Path.Combine(folder, "eb-tpt-primary.json");
|
||||
|
||||
|
@ -69,16 +72,32 @@ namespace ScriptToolGui
|
|||
var m12SecondaryTptRefs = ImportStringRefs(m12SecondaryFileName);
|
||||
var ebSecondaryTptRefs = ImportStringRefs(ebSecondaryFileName);
|
||||
|
||||
matchedGroups.AddRange(MatchRefs(ebPrimaryTptRefs, m12PrimaryTptRefs));
|
||||
matchedGroups.AddRange(MatchRefs(ebSecondaryTptRefs, m12SecondaryTptRefs));
|
||||
tptGroups.AddRange(MatchRefs(ebPrimaryTptRefs, m12PrimaryTptRefs));
|
||||
tptGroups.AddRange(MatchRefs(ebSecondaryTptRefs, m12SecondaryTptRefs));
|
||||
tptGroups.Sort((g1, g2) => g1.Index.CompareTo(g2.Index));
|
||||
|
||||
matchedGroups.AddRange(tptGroups);
|
||||
|
||||
// Battle actions
|
||||
string m12BattleActionsFileName = Path.Combine(folder, "m12-battle-actions.json");
|
||||
string ebBattleActionsFileName = Path.Combine(folder, "eb-battle-actions.json");
|
||||
|
||||
var m12BattleActionRefs = ImportStringRefs(m12BattleActionsFileName);
|
||||
var ebBattleActionRefs = ImportStringRefs(ebBattleActionsFileName);
|
||||
|
||||
battleActionGroups.AddRange(MatchRefs(ebBattleActionRefs, m12BattleActionRefs));
|
||||
battleActionGroups.Sort((g1, g2) => g1.Index.CompareTo(g2.Index));
|
||||
|
||||
matchedGroups.AddRange(battleActionGroups);
|
||||
|
||||
matchedGroups.Sort((g1, g2) => g1.Index.CompareTo(g2.Index));
|
||||
|
||||
matchedGroups.Sort((g1, g2) => g1.EbRef.Index.CompareTo(g2.EbRef.Index));
|
||||
}
|
||||
|
||||
private MatchedReferenceGroup[] MatchRefs(MainStringRef[] ebRefs, MainStringRef[] m12Refs)
|
||||
private MatchedGroup[] MatchRefs(MainStringRef[] ebRefs, MainStringRef[] m12Refs)
|
||||
{
|
||||
return ebRefs.Join(m12Refs, e => e.Index, m => m.Index, (e, m) => new { e, m })
|
||||
.Select(p => new MatchedReferenceGroup(p.e, p.m))
|
||||
.Select(p => new MatchedGroup(p.e, p.m, p.m))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
|
@ -115,10 +134,13 @@ namespace ScriptToolGui
|
|||
return Game.None;
|
||||
}
|
||||
|
||||
private void PopulateTptList()
|
||||
private void PopulateSelectors()
|
||||
{
|
||||
tptSelector.Items.Clear();
|
||||
tptSelector.Items.AddRange(matchedGroups.ToArray());
|
||||
tptSelector.Items.AddRange(tptGroups.ToArray());
|
||||
|
||||
battleActionSelector.Items.Clear();
|
||||
battleActionSelector.Items.AddRange(battleActionGroups.ToArray());
|
||||
}
|
||||
|
||||
private void PopulateCodeList()
|
||||
|
@ -128,7 +150,6 @@ namespace ScriptToolGui
|
|||
|
||||
private void PopulateReferenceList()
|
||||
{
|
||||
codeList.Text = "";
|
||||
referenceList.Items.Clear();
|
||||
|
||||
if (ebSelector.Checked)
|
||||
|
@ -144,67 +165,105 @@ namespace ScriptToolGui
|
|||
|
||||
private string GetString(Game game, string label)
|
||||
{
|
||||
try
|
||||
{
|
||||
return stringsLookup[game].First(l => l.Contains("^" + label + "^"));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string labelDef = "^" + label + "^";
|
||||
return stringsLookup[game].FirstOrDefault(l => l.Contains(labelDef));
|
||||
}
|
||||
|
||||
private void NavigateTo(MatchedReferenceGroup group)
|
||||
private void NavigateTo(MatchedGroup group)
|
||||
{
|
||||
if (group == null)
|
||||
{
|
||||
ebString.Text = "";
|
||||
m12String.Text = "";
|
||||
m12StringEnglish.Text = "";
|
||||
|
||||
tptSelector.SelectedIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
string eb = GetString(Game.Eb, group.EbRef.Label);
|
||||
string m12 = GetString(Game.M12, group.M12Ref.Label);
|
||||
string m12English = GetString(Game.M12English, group.M12Ref.Label);
|
||||
string eb = GetString(Game.Eb, group.Refs[Game.Eb].Label);
|
||||
string m12 = GetString(Game.M12, group.Refs[Game.M12].Label);
|
||||
string m12English = GetString(Game.M12English, group.Refs[Game.M12].Label);
|
||||
|
||||
ebString.Text = eb;
|
||||
m12String.Text = m12;
|
||||
m12StringEnglish.Text = m12English;
|
||||
|
||||
tptSelector.SelectedItem = group;
|
||||
previousNavigationState = new MatchedGroupNavigationEntry(group);
|
||||
}
|
||||
|
||||
SelectGroup(tptSelector, group);
|
||||
SelectGroup(battleActionSelector, group);
|
||||
|
||||
PopulateCodeList();
|
||||
PopulateReferenceList();
|
||||
}
|
||||
|
||||
private void SelectGroup(ComboBox selector, MatchedGroup group)
|
||||
{
|
||||
if (group != null && selector.Items.Contains(group))
|
||||
selector.SelectedItem = group;
|
||||
else
|
||||
selector.SelectedIndex = -1;
|
||||
}
|
||||
|
||||
private MatchedGroup FindGroup(IEnumerable<MatchedGroup> groups, Game game, string label)
|
||||
{
|
||||
// Attempt to find the label
|
||||
string labelDef = "^" + label + "^";
|
||||
var match = groups.FirstOrDefault(g => GetString(game, g.Refs[game].Label).Contains(labelDef));
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
private void NavigateTo(Game game, string label)
|
||||
{
|
||||
foreach (var eachGame in Enum.GetValues(typeof(Game))
|
||||
.OfType<Game>().Where(g => textboxLookup.ContainsKey(g)))
|
||||
textboxLookup[eachGame].Text = "";
|
||||
|
||||
}
|
||||
string labelDef = "^" + label + "^";
|
||||
textboxLookup[game].Text = stringsLookup[game].First(l => l.Contains(labelDef));
|
||||
|
||||
private void PushPreviousGroup()
|
||||
{
|
||||
if (previousGroup != null)
|
||||
previousNavigationState = new ReferenceNavigationEntry(game, label);
|
||||
|
||||
MatchedGroup match = FindGroup(matchedGroups, game, label);
|
||||
|
||||
// Check if any other games have this matched ref
|
||||
if (match != null)
|
||||
{
|
||||
navigationStack.Push(previousGroup);
|
||||
foreach (var otherGame in match.Refs.Where(kv => kv.Key != game))
|
||||
{
|
||||
labelDef = "^" + otherGame.Value.Label + "^";
|
||||
textboxLookup[otherGame.Key].Text = stringsLookup[otherGame.Key].First(l => l.Contains(labelDef));
|
||||
}
|
||||
}
|
||||
|
||||
SelectGroup(tptSelector, match);
|
||||
SelectGroup(battleActionSelector, match);
|
||||
|
||||
PopulateCodeList();
|
||||
PopulateReferenceList();
|
||||
}
|
||||
|
||||
private void tptSelector_SelectionChangeCommitted(object sender, EventArgs e)
|
||||
private void PushPreviousNavigationState()
|
||||
{
|
||||
if (tptSelector.SelectedIndex == -1)
|
||||
if (previousNavigationState == null)
|
||||
return;
|
||||
|
||||
navigationStack.Push(previousNavigationState);
|
||||
}
|
||||
|
||||
private void selector_SelectionChangeCommitted(object sender, EventArgs e)
|
||||
{
|
||||
var selector = (ComboBox)sender;
|
||||
|
||||
if (selector.SelectedIndex == -1)
|
||||
NavigateTo(null);
|
||||
else
|
||||
{
|
||||
PushPreviousGroup();
|
||||
PushPreviousNavigationState();
|
||||
|
||||
var currentGroup = (MatchedReferenceGroup)tptSelector.SelectedItem;
|
||||
var currentGroup = (MatchedGroup)selector.SelectedItem;
|
||||
NavigateTo(currentGroup);
|
||||
previousGroup = currentGroup;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,7 +281,9 @@ namespace ScriptToolGui
|
|||
Game game = GetCurrentGame();
|
||||
string label = (string)referenceList.SelectedItem;
|
||||
|
||||
|
||||
PushPreviousNavigationState();
|
||||
|
||||
NavigateTo(game, label);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,9 +292,18 @@ namespace ScriptToolGui
|
|||
if (navigationStack.Count < 1)
|
||||
return;
|
||||
|
||||
var group = navigationStack.Pop();
|
||||
NavigateTo(group);
|
||||
previousGroup = group;
|
||||
var nav = navigationStack.Pop();
|
||||
|
||||
if (nav.Type == NavigationType.MatchedGroup)
|
||||
{
|
||||
var matchedEntry = (MatchedGroupNavigationEntry)nav;
|
||||
NavigateTo(matchedEntry.Group);
|
||||
}
|
||||
else if (nav.Type == NavigationType.Reference)
|
||||
{
|
||||
var referenceEntry = (ReferenceNavigationEntry)nav;
|
||||
NavigateTo(referenceEntry.Game, referenceEntry.Label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ScriptTool;
|
||||
|
||||
namespace ScriptToolGui
|
||||
{
|
||||
class MatchedGroup
|
||||
{
|
||||
public IDictionary<Game, MainStringRef> Refs { get; private set; }
|
||||
public int Index { get; private set; }
|
||||
|
||||
public MatchedGroup()
|
||||
{
|
||||
Refs = new Dictionary<Game, MainStringRef>();
|
||||
}
|
||||
|
||||
public MatchedGroup(MainStringRef ebRef, MainStringRef m12Ref, MainStringRef m12EnglishRef)
|
||||
: this()
|
||||
{
|
||||
if (ebRef.Index != m12Ref.Index)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Refs.Add(Game.Eb, ebRef);
|
||||
Refs.Add(Game.M12, m12Ref);
|
||||
Refs.Add(Game.M12English, m12EnglishRef);
|
||||
|
||||
Index = ebRef.Index;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("[{0:X3}] EB: {1} / M12: {2}", Index.ToString("X3"),
|
||||
Refs[Game.Eb].Label, Refs[Game.M12].Label);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ScriptTool;
|
||||
|
||||
namespace ScriptToolGui
|
||||
{
|
||||
class MatchedReferenceGroup
|
||||
{
|
||||
public MainStringRef EbRef { get; private set; }
|
||||
public MainStringRef M12Ref { get; private set; }
|
||||
|
||||
public MatchedReferenceGroup(MainStringRef ebRef, MainStringRef m12Ref)
|
||||
{
|
||||
if(ebRef.Index != m12Ref.Index)
|
||||
{
|
||||
|
||||
}
|
||||
EbRef = ebRef;
|
||||
M12Ref = m12Ref;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("[{0:X3}] EB: {1} / M12: {2}", EbRef.Index.ToString("X3"),
|
||||
EbRef.Label, M12Ref.Label);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,12 +6,37 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace ScriptToolGui
|
||||
{
|
||||
class NavigationLabel
|
||||
abstract class NavigationEntry
|
||||
{
|
||||
public Game Game { get; private set; }
|
||||
public string Label { get; private set; }
|
||||
public abstract NavigationType Type { get; }
|
||||
}
|
||||
|
||||
public NavigationLabel(Game game, string label)
|
||||
enum NavigationType
|
||||
{
|
||||
MatchedGroup,
|
||||
Reference
|
||||
}
|
||||
|
||||
class MatchedGroupNavigationEntry : NavigationEntry
|
||||
{
|
||||
public override NavigationType Type { get { return NavigationType.MatchedGroup; } }
|
||||
|
||||
public MatchedGroup Group { get; private set; }
|
||||
|
||||
public MatchedGroupNavigationEntry(MatchedGroup group)
|
||||
{
|
||||
Group = group;
|
||||
}
|
||||
}
|
||||
|
||||
class ReferenceNavigationEntry : NavigationEntry
|
||||
{
|
||||
public override NavigationType Type { get { return NavigationType.Reference; } }
|
||||
|
||||
public string Label { get; private set; }
|
||||
public Game Game { get; private set; }
|
||||
|
||||
public ReferenceNavigationEntry(Game game, string label)
|
||||
{
|
||||
Game = game;
|
||||
Label = label;
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MatchedReferenceGroup.cs" />
|
||||
<Compile Include="MatchedGroup.cs" />
|
||||
<Compile Include="NavigationEntry.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
Loading…
Reference in New Issue