Skip to content

Commit 2a16de6

Browse files
committed
Fix "overwrite" extension, browse for .exe on launch
- Fixes output extension always being .msg when decompiling with "overwrite" setting enabled - Prompts you for your AtlusScriptCompiler.exe path if the one in the Config.json isn't found - Added option to inject .msg into existing .bf (skips recompiling .BF to edit message data)
1 parent 14777fc commit 2a16de6

6 files changed

+88
-9
lines changed

AtlusScriptGUI.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@
112112
<Folder Include="Properties\" />
113113
</ItemGroup>
114114
<ItemGroup>
115+
<ProjectReference Include="..\Atlus-Script-Tools\Source\AtlusScriptLibrary\AtlusScriptLibrary.csproj">
116+
<Project>{62ee486f-ae33-4dbb-ac4c-409a22cb04ad}</Project>
117+
<Name>AtlusScriptLibrary</Name>
118+
</ProjectReference>
115119
<ProjectReference Include="..\ShrineFox.IO\ShrineFox.IO.csproj">
116120
<Project>{7640412a-7372-4925-b20c-0178d8818a8f}</Project>
117121
<Name>ShrineFox.IO</Name>

AtlusScriptGUI.sln

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AtlusScriptGUI", "AtlusScri
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShrineFox.IO", "..\ShrineFox.IO\ShrineFox.IO.csproj", "{7640412A-7372-4925-B20C-0178D8818A8F}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AtlusScriptLibrary", "..\Atlus-Script-Tools\Source\AtlusScriptLibrary\AtlusScriptLibrary.csproj", "{62EE486F-AE33-4DBB-AC4C-409A22CB04AD}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{7640412A-7372-4925-B20C-0178D8818A8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{7640412A-7372-4925-B20C-0178D8818A8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{7640412A-7372-4925-B20C-0178D8818A8F}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{62EE486F-AE33-4DBB-AC4C-409A22CB04AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{62EE486F-AE33-4DBB-AC4C-409A22CB04AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{62EE486F-AE33-4DBB-AC4C-409A22CB04AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{62EE486F-AE33-4DBB-AC4C-409A22CB04AD}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE

Events.cs

+44-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
using MetroSet_UI.Forms;
1+
using AtlusScriptLibrary.Common.Libraries;
2+
using AtlusScriptLibrary.Common.Logging;
3+
using AtlusScriptLibrary.Common.Text.Encodings;
4+
using AtlusScriptLibrary.FlowScriptLanguage;
5+
using AtlusScriptLibrary.MessageScriptLanguage.Compiler;
6+
using AtlusScriptLibrary.MessageScriptLanguage;
7+
using MetroSet_UI.Forms;
28
using ShrineFox.IO;
39
using System;
410
using System.Collections;
@@ -123,5 +129,42 @@ private void ToggleTheme_Click(object sender, EventArgs e)
123129
ToggleTheme();
124130
ApplyTheme();
125131
}
132+
133+
private void InjectMSG_Click(object sender, EventArgs e)
134+
{
135+
string bfPath = "";
136+
string msgPath = "";
137+
var bfSelect = ShrineFox.IO.WinFormsDialogs.SelectFile("Choose Original BF File", false, new string[] { "Flowscript Binary (.BF)" });
138+
if (bfSelect.Count <= 0 || string.IsNullOrEmpty(bfSelect.First()))
139+
return;
140+
else
141+
bfPath = bfSelect.FirstOrDefault();
142+
var msgSelect = ShrineFox.IO.WinFormsDialogs.SelectFile("Choose File To Inject", false, new string[] { "Messagescript Text (.MSG)", "Messagescript Binary (.BMD)" });
143+
if (msgSelect.Count <= 0 || string.IsNullOrEmpty(msgSelect.First()))
144+
return;
145+
else
146+
msgPath = msgSelect.FirstOrDefault();
147+
148+
FlowScript flowScript = FlowScript.FromFile(bfPath, AtlusEncoding.GetByName(comboBox_Encoding.SelectedItem.ToString()));
149+
MessageScript messageScript;
150+
151+
if (Path.GetExtension(msgPath).ToLower() == ".bmd")
152+
messageScript = MessageScript.FromFile(msgPath, AtlusScriptLibrary.MessageScriptLanguage.FormatVersion.Version1BigEndian, AtlusEncoding.GetByName(comboBox_Encoding.SelectedItem.ToString()));
153+
else
154+
using (FileStream fileStream = File.OpenRead(msgPath))
155+
{
156+
MessageScriptCompiler messageScriptCompiler = new MessageScriptCompiler(
157+
AtlusScriptLibrary.MessageScriptLanguage.FormatVersion.Version1BigEndian, AtlusEncoding.GetByName(comboBox_Encoding.SelectedItem.ToString()));
158+
messageScriptCompiler.AddListener(new ConsoleLogListener(true, LogLevel.Info | LogLevel.Warning
159+
| LogLevel.Error | LogLevel.Fatal));
160+
messageScriptCompiler.Library = LibraryLookup.GetLibrary("P5R");
161+
if (!messageScriptCompiler.TryCompile(fileStream, out messageScript))
162+
return;
163+
}
164+
flowScript.MessageScript = messageScript;
165+
flowScript.ToFile(bfPath);
166+
MessageBox.Show("Done injecting message into .BF!");
167+
}
168+
126169
}
127170
}

Forms/MainForm.Designer.cs

+16-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Forms/MainForm.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using ShrineFox.IO;
44
using System;
55
using System.IO;
6+
using System.Linq;
67
using System.Text;
78
using System.Threading;
89
using System.Windows.Forms;
@@ -11,7 +12,7 @@ namespace AtlusScriptGUI
1112
{
1213
public partial class MainForm : MetroSetForm
1314
{
14-
public static Version version = new Version(3, 2);
15+
public static Version version = new Version(3, 3);
1516
public Config settings = new Config();
1617
public string CompilerPath { get; set; } = "./AtlusScriptCompiler.exe";
1718

@@ -31,5 +32,6 @@ public MainForm(string[] args)
3132

3233
this.Text += $" v{version.Major}.{version.Minor}";
3334
}
35+
3436
}
3537
}

GUI.cs

+15-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ private void SetCompilerPath(string[] args)
6464
CompilerPath = Path.GetFullPath(args[0]);
6565
else
6666
CompilerPath = settings.CompilerPath;
67+
68+
while (!File.Exists(CompilerPath))
69+
{
70+
var fileSelect = WinFormsDialogs.SelectFile("Select your AtlusScriptCompiler.exe", false, new string[] { "Executable File (.exe)" });
71+
if (fileSelect.Count > 0 && File.Exists(fileSelect.First()))
72+
{
73+
CompilerPath = fileSelect.First();
74+
settings.CompilerPath = CompilerPath;
75+
settings.SaveJson(settings);
76+
}
77+
}
6778
}
6879

6980
private void SetDropDowns()
@@ -300,7 +311,10 @@ private string GetArguments(string droppedFilePath, string extension, string com
300311
else if (compileArg == "-Decompile " && settings.Overwrite)
301312
{
302313
string outPath = droppedFilePath.Replace(".bmd", "").Replace(".BMD", "");
303-
args.Append($"-Out \"{outPath + ".msg"}\" ");
314+
if (extension == ".BF")
315+
args.Append($"-Out \"{outPath + ".flow"}\" ");
316+
else if (extension == ".BMD")
317+
args.Append($"-Out \"{outPath + ".msg"}\" ");
304318
}
305319
}
306320

0 commit comments

Comments
 (0)