More tools organization

This commit is contained in:
jeffman 2019-01-02 22:05:51 -05:00
parent 49e28ed9d2
commit 8e2486e61b
67 changed files with 12376 additions and 201 deletions

View File

@ -1,22 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolTableBuilder", "SymbolTableBuilder\SymbolTableBuilder.csproj", "{6B1381C7-93F9-4976-8856-E995A5A25102}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6B1381C7-93F9-4976-8856-E995A5A25102}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B1381C7-93F9-4976-8856-E995A5A25102}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B1381C7-93F9-4976-8856-E995A5A25102}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B1381C7-93F9-4976-8856-E995A5A25102}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

View File

@ -1,36 +0,0 @@
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("SymbolTableBuilder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SymbolTableBuilder")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[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("6b1381c7-93f9-4976-8856-e995a5a25102")]
// 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")]

View File

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6B1381C7-93F9-4976-8856-E995A5A25102}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SymbolTableBuilder</RootNamespace>
<AssemblyName>symbols</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</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>

3
build-tools.bat Normal file
View File

@ -0,0 +1,3 @@
dotnet build tools/ScriptTool -o bin/ScriptTool
dotnet build tools/SymbolTableBuilder -o bin/SymbolTableBuilder
dotnet build tools/CompileTool -o bin/CompileTool

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,12 @@
using System;
namespace CompileTool
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

43
tools/M12Tools.sln Normal file
View File

@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompileTool", "CompileTool\CompileTool.csproj", "{44399E43-DE61-41ED-85AE-5F3A9DA15970}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptTool", "ScriptTool\ScriptTool.csproj", "{29AB41A8-6405-4C4B-A374-BF1BD7AF1A27}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SymbolTableBuilder", "SymbolTableBuilder\SymbolTableBuilder.csproj", "{2E0E2F98-4EB7-48C7-968D-1BEDCADA37F2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptToolGui", "ScriptToolGui\ScriptToolGui.csproj", "{BAE5CBBF-D0B3-4F82-A80A-957CEC379238}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{44399E43-DE61-41ED-85AE-5F3A9DA15970}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44399E43-DE61-41ED-85AE-5F3A9DA15970}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44399E43-DE61-41ED-85AE-5F3A9DA15970}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44399E43-DE61-41ED-85AE-5F3A9DA15970}.Release|Any CPU.Build.0 = Release|Any CPU
{29AB41A8-6405-4C4B-A374-BF1BD7AF1A27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29AB41A8-6405-4C4B-A374-BF1BD7AF1A27}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29AB41A8-6405-4C4B-A374-BF1BD7AF1A27}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29AB41A8-6405-4C4B-A374-BF1BD7AF1A27}.Release|Any CPU.Build.0 = Release|Any CPU
{2E0E2F98-4EB7-48C7-968D-1BEDCADA37F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E0E2F98-4EB7-48C7-968D-1BEDCADA37F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E0E2F98-4EB7-48C7-968D-1BEDCADA37F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E0E2F98-4EB7-48C7-968D-1BEDCADA37F2}.Release|Any CPU.Build.0 = Release|Any CPU
{BAE5CBBF-D0B3-4F82-A80A-957CEC379238}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAE5CBBF-D0B3-4F82-A80A-957CEC379238}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAE5CBBF-D0B3-4F82-A80A-957CEC379238}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAE5CBBF-D0B3-4F82-A80A-957CEC379238}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F18C3A5C-4E09-4F69-8D46-3B39B431C382}
EndGlobalSection
EndGlobal

View File

@ -28,66 +28,77 @@ namespace ScriptTool
static Compiler m12Compiler; static Compiler m12Compiler;
static StreamWriter IncludeFile; static StreamWriter IncludeFile;
static void Main(string[] args) static int Main(string[] args)
{ {
options = ParseCommandLine(args); try
if (options == null)
{ {
Usage(); options = ParseCommandLine(args);
return; if (options == null)
}
m12CharLookup = JsonConvert.DeserializeObject<Dictionary<byte, string>>(File.ReadAllText("m12-char-lookup.json"));
ebCharLookup = JsonConvert.DeserializeObject<Dictionary<byte, string>>(File.ReadAllText("eb-char-lookup.json"));
if (options.Command == CommandType.Decompile)
{
// Set up decompilers
m12Decompiler = new Decompiler(M12ControlCode.Codes, m12CharLookup, (rom, address) => rom[address + 1] == 0xFF);
ebDecompiler = new Decompiler(EbControlCode.Codes, ebCharLookup, (rom, address) => rom[address] < 0x20);
// Load ROMs
ebRom = File.ReadAllBytes(options.EbRom);
m12Rom = File.ReadAllBytes(options.M12Rom);
// Decompile misc string tables
if (options.DoMiscText)
{ {
//DecompileEbMisc(); Usage();
DecompileM12Misc(); return -1;
} }
// Decompile main string tables m12CharLookup = JsonConvert.DeserializeObject<Dictionary<byte, string>>(File.ReadAllText("m12-char-lookup.json"));
if (options.DoMainText) ebCharLookup = JsonConvert.DeserializeObject<Dictionary<byte, string>>(File.ReadAllText("eb-char-lookup.json"));
if (options.Command == CommandType.Decompile)
{ {
DecompileEb(); // Set up decompilers
DecompileM12(); m12Decompiler = new Decompiler(M12ControlCode.Codes, m12CharLookup, (rom, address) => rom[address + 1] == 0xFF);
} ebDecompiler = new Decompiler(EbControlCode.Codes, ebCharLookup, (rom, address) => rom[address] < 0x20);
}
else if (options.Command == CommandType.Compile)
{
// Set up compilers
m12Compiler = new Compiler(M12ControlCode.Codes, (rom, address) => rom[address + 1] == 0xFF);
using (IncludeFile = File.CreateText(Path.Combine(options.WorkingDirectory, "m12-includes.asm"))) // Load ROMs
{ ebRom = File.ReadAllBytes(options.EbRom);
IncludeFile.WriteLine(".gba"); m12Rom = File.ReadAllBytes(options.M12Rom);
IncludeFile.WriteLine(".open \"../m12.gba\",0x8000000");
// Compile main string tables // Decompile misc string tables
if (options.DoMainText)
{
CompileM12();
}
// Compile misc string tables
if (options.DoMiscText) if (options.DoMiscText)
{ {
CompileM12Misc(); //DecompileEbMisc();
DecompileM12Misc();
} }
IncludeFile.WriteLine(".close"); // Decompile main string tables
if (options.DoMainText)
{
DecompileEb();
DecompileM12();
}
} }
else if (options.Command == CommandType.Compile)
{
// Set up compilers
m12Compiler = new Compiler(M12ControlCode.Codes, (rom, address) => rom[address + 1] == 0xFF);
using (IncludeFile = File.CreateText(Path.Combine(options.WorkingDirectory, "m12-includes.asm")))
{
IncludeFile.WriteLine(".gba");
IncludeFile.WriteLine(".open \"../m12.gba\",0x8000000");
// Compile main string tables
if (options.DoMainText)
{
CompileM12();
}
// Compile misc string tables
if (options.DoMiscText)
{
CompileM12Misc();
}
IncludeFile.WriteLine(".close");
}
}
return 0;
}
catch (Exception ex)
{
Console.WriteLine("Encountered exception:");
Console.WriteLine(ex);
return -1;
} }
} }
@ -138,7 +149,10 @@ namespace ScriptTool
string working = argList[0]; string working = argList[0];
if (!Directory.Exists(working)) if (!Directory.Exists(working))
{
Console.WriteLine("Directory does not exist: " + Path.GetFullPath(working));
return null; return null;
}
// Check for ROM paths // Check for ROM paths
string ebRom = null; string ebRom = null;
@ -147,8 +161,18 @@ namespace ScriptTool
{ {
ebRom = argList[1]; ebRom = argList[1];
m12Rom = argList[2]; m12Rom = argList[2];
if (!File.Exists(ebRom) || !File.Exists(m12Rom))
if (!File.Exists(ebRom))
{
Console.WriteLine("File does not exist: " + Path.GetFullPath(ebRom));
return null; return null;
}
if (!File.Exists(m12Rom))
{
Console.WriteLine("File does not exist: " + Path.GetFullPath(m12Rom));
return null;
}
} }
return new CommandOptions return new CommandOptions

View File

@ -0,0 +1,9 @@
{
"profiles": {
"ScriptTool": {
"commandName": "Project",
"commandLineArgs": "-compile -main -misc \"..\\working\" \"..\\eb.smc\" \"..\\m12fresh.gba\"",
"workingDirectory": "C:\\Users\\jeffe\\M12\\bin\\ScriptTool"
}
}
}

View File

@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
<ItemGroup>
<None Update="eb-char-lookup.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="eb-codelist.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="eb-compressed-strings.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="item-map.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="m12-char-lookup.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="m12-codelist.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="m2-widths-main.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="m2-widths-saturn.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2050
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptTool", "ScriptTool\ScriptTool.csproj", "{17C0EE03-1D07-45AB-8F22-09C41230A231}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{17C0EE03-1D07-45AB-8F22-09C41230A231}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17C0EE03-1D07-45AB-8F22-09C41230A231}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17C0EE03-1D07-45AB-8F22-09C41230A231}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17C0EE03-1D07-45AB-8F22-09C41230A231}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D88AC004-012A-4D81-A9A0-9BC8F4D3D881}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,99 @@
{
"80": " ",
"81": "!",
"82": "\"",
"83": "#",
"84": "$",
"85": "%",
"86": "&",
"87": "'",
"88": "(",
"89": ")",
"90": "*",
"91": "+",
"92": ",",
"93": "-",
"94": ".",
"95": "/",
"96": "0",
"97": "1",
"98": "2",
"99": "3",
"100": "4",
"101": "5",
"102": "6",
"103": "7",
"104": "8",
"105": "9",
"106": ":",
"107": ";",
"108": "<",
"109": "=",
"110": ">",
"111": "?",
"112": "@",
"113": "A",
"114": "B",
"115": "C",
"116": "D",
"117": "E",
"118": "F",
"119": "G",
"120": "H",
"121": "I",
"122": "J",
"123": "K",
"124": "L",
"125": "M",
"126": "N",
"127": "O",
"128": "P",
"129": "Q",
"130": "R",
"131": "S",
"132": "T",
"133": "U",
"134": "V",
"135": "W",
"136": "X",
"137": "Y",
"138": "Z",
"139": "[8B]",
"140": "[8C]",
"141": "[8D]",
"142": "[8E]",
"143": "[8F]",
"144": "`",
"145": "a",
"146": "b",
"147": "c",
"148": "d",
"149": "e",
"150": "f",
"151": "g",
"152": "h",
"153": "i",
"154": "j",
"155": "k",
"156": "l",
"157": "m",
"158": "n",
"159": "o",
"160": "p",
"161": "q",
"162": "r",
"163": "s",
"164": "t",
"165": "u",
"166": "v",
"167": "w",
"168": "x",
"169": "y",
"170": "z",
"171": "{",
"172": "|",
"173": "}",
"174": "~",
"175": "\\",
"189": "➨"
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,768 @@
in the
that
...
and
this
to the
about
just
of the
something
going to
to
you have
your
for
you're
@You
really
don't
@The
e the
e you
...
the
will
...Brick Road
ing
some
@Do you want to
like
ou don't have
is
you
you
anything else
the
you want to
for the
friend
at the
ould you like
from
would
he Runaway Five
with
want to
@If you
you don't
s the
ed to
e...
something
t the
@...
@Please
's
of your
@It's
@Thank you
@I
here.
in
@Do you
I'll
have
e of
d you
@I'm
me to
@I don't
@Well,
@This is
ed the
@You're
for a
anything
ing
of
you should
I
from the
s...
it's
time
e to
ed
e of the
to you
n't you
again
for you.
other
ation
little
ing to
can't
much
someone
on the
looks like
don't you
very
the
can
you
that you
it
you want
ou can't
able to
already
give you
understand
my
you can
that
what
here's
there
n the
@What
Thank you
I can't
one
@The
thought
not
You should
ou know
has
back
of
ve been
I'm
there
with you
@I heard
in
here
Fourside
I wonder
to
could
think
out
good
the
You
too much
ome back
t...
here
thing
come
ly
ent
strong
money.
@I'll
an
ou must
are you
with the
on your
too many
you.
know
to be
around
if you
@Are you
ome again
e and
more
think
e your
@Don't
nd the
t to
rea
he
me
strange
for you
ight
a
be
ther
all
cannot
here is
You have
Monotoli
was
ll you
hat
, but
stuff
eep
it
didn't
like th
ll right
should
over
@Oh,
hear
every
I'm not
about t
zombies
damage
his is
all
some
@It
attack
right
ally
orry
ess
er
@That's
carry it
ake
t was
, the
n you
sn't
help
king
ear
ing the
It's
very
talking
ou've
that's
to me
@Hello
enemy
you are
by
IBNT
ight
on't
est
ick
power
s that
s are
call
t is
is
age
, and
great
@Thanks
people
ter
not
ill
ness
@This
into
ha
I can
t your
before
things
tion
for
be
this
Happy
You
out
enough
I'm
@You
go
for
all th
though
ing you
e you
ring
one
get
t you
@I'm s
the s
e's
port
d...
out
@What
get
I have
looking
n this
of my
have a
ent
do
d of
ting
ncrease
Twoson
through
s your
ou'll
place
right
Onett
our
too
ater
be
ain
ing.
take
e is
the
please
do you
need
use
now.
got
and
ning
sta
the t
I was
y the
his
appe
con
ho
hat's
Threed
get
s of
inter
talk
man
day
ove
ha ha
inally
monkey
s and
ate
see
town
side
y to
ever
equip
than
who
long
care
room
e are
ard
end
, you
the b
I know
think
s you
time
ment
so
!
I've
ell
wa
ious
reat
live
ange
we
ble
@.....
ecover
only
thing
er...
Mr.
ough
now
I
wor
to
ed.
I
're
give
ing a
return
better
ince
well
one
still
ying
me...
sta
ust
per
lease
ling
point
ect
ast
pretty
Giygas
ecause
member
carry
used
elieve
money
pres
way
di
even
ound
s to
ting
ted
oing
and
ine
T
sure
on
@...I
while
@but
@We
ice
se
ive
rea
com
est
have
but
away
here
must
but
want
ready
I'm
carr
my
ay...
are
@Hey,
world
ing a
happ
seem
his
nder
se
ant
item
@But
sho
in a
made
night
et's
like
The
che
de
ful
hat
and
self
ould
@No
car
tr
good
stor
ombie
@Oh
@It
s a
vent
ant
so
olla
ree
Your
make
work
power
home
also
ance
@How
h...
@If
ple
buy
e,
n't
oke
n't
more
Good
t a
all
take
round
when
name
being
attle
ite
ack
y...
@Whe
with
al
have
look
t of
aster
a lo
feel
here
count
monst
now
ark
ous
'll
bus
head
any
t you
erson
after
ummer
hard
ful
ever
kid
a b
kay
tra
pla
ook
ome
eat
@Wel
off
turn
I am
oney
any
ave
any
enem
con
me
red
en
bo
re
ell
sell
what
next
ure
bu
pro
on
res
es
lo
our
use
iste
ood
no
ope
ock
row
@He
how
may
as
stor
are
ost
mean
We
He
@An
it
in
ound
one.
come
blue
way,
or
mo
.
each
some
@(Th
otel
hand
came
ca
ame
@Hey
een
spec
red
ing!
...
hose
ind
ice
ver
W
min
et
on
ace
er.
are
nter
o...
were
help
old
it.
hear
stop
look
com
@Do
her
pro
chin
ble
e a
girl
luck
B
act
ike
down
part
see
use
uch
from
just
llow
@Her
at
@So,
ye
ser
ying
ring
eave
big
ried
was
say
su
her
it.
Man
kin
up
ers
@Why
p...
cour
him
agic
any
fin
eal
he
ide
oor
ity
got
ens
ish
ive
sa
oon
fee
s a
nce
D
uck
ass
man
a p
@(I
@Wh
gu
(
bus
los
ts
ba
S
if
@Ha
ma
unn
ay
ner
@A
or
stu
ust
kya
shi
pos
A
int
le
ary
ven
ch
own
hu
@My
@So
sp
sh
wan
ool
Y
old
eas
, I
iki
@Ky
@Ye
spi

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,233 @@
{
"0": "ぁ",
"1": "あ",
"2": "ぃ",
"3": "い",
"4": "ぅ",
"5": "う",
"6": "ぇ",
"7": "え",
"8": "ぉ",
"9": "お",
"10": "か",
"11": "が",
"12": "き",
"13": "ぎ",
"14": "く",
"15": "ぐ",
"16": "け",
"17": "げ",
"18": "こ",
"19": "ご",
"20": "さ",
"21": "ざ",
"22": "し",
"23": "じ",
"24": "す",
"25": "ず",
"26": "せ",
"27": "ぜ",
"28": "そ",
"29": "ぞ",
"30": "た",
"31": "だ",
"32": "ち",
"33": "ぢ",
"34": "っ",
"35": "つ",
"36": "づ",
"37": "て",
"38": "で",
"39": "と",
"40": "ど",
"41": "な",
"42": "に",
"43": "ぬ",
"44": "ね",
"45": "の",
"46": "は",
"47": "ば",
"48": "ぱ",
"49": "ひ",
"50": "び",
"51": "ぴ",
"52": "ふ",
"53": "ぶ",
"54": "ぷ",
"55": "へ",
"56": "べ",
"57": "ぺ",
"58": "ほ",
"59": "ぼ",
"60": "ぽ",
"61": "ま",
"62": "み",
"63": "む",
"64": "め",
"65": "も",
"66": "ゃ",
"67": "や",
"68": "ゅ",
"69": "ゆ",
"70": "ょ",
"71": "よ",
"72": "ら",
"73": "り",
"74": "る",
"75": "れ",
"76": "ろ",
"77": " ",
"78": "わ",
"79": " ",
"80": " ",
"81": "を",
"82": "ん",
"93": "➨",
"96": "ァ",
"97": "ア",
"98": "ィ",
"99": "イ",
"100": "ゥ",
"101": "ウ",
"102": "ェ",
"103": "エ",
"104": "ォ",
"105": "オ",
"106": "カ",
"107": "ガ",
"108": "キ",
"109": "ギ",
"110": "ク",
"111": "グ",
"112": "ケ",
"113": "ゲ",
"114": "コ",
"115": "ゴ",
"116": "サ",
"117": "ザ",
"118": "シ",
"119": "ジ",
"120": "ス",
"121": "ズ",
"122": "セ",
"123": "ゼ",
"124": "ソ",
"125": "ゾ",
"126": "タ",
"127": "ダ",
"128": "チ",
"129": "ヂ",
"130": "ッ",
"131": "ツ",
"132": "ヅ",
"133": "テ",
"134": "デ",
"135": "ト",
"136": "ド",
"137": "ナ",
"138": "ニ",
"139": "ヌ",
"140": "ネ",
"141": "",
"142": "ハ",
"143": "バ",
"144": "パ",
"145": "ヒ",
"146": "ビ",
"147": "ピ",
"148": "フ",
"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": "ン",
"192": "A",
"193": "B",
"194": "C",
"195": "D",
"196": "E",
"197": "F",
"198": "G",
"199": "H",
"200": "I",
"201": "J",
"202": "K",
"203": "L",
"204": "M",
"205": "N",
"206": "O",
"207": "P",
"208": "Q",
"209": "R",
"210": "S",
"211": "T",
"212": "U",
"213": "V",
"214": "W",
"215": "X",
"216": "Y",
"217": "Z",
"218": "α",
"219": "β",
"220": "γ",
"221": "Σ",
"222": "Ω",
"223": " ",
"224": "0",
"225": "1",
"226": "2",
"227": "3",
"228": "4",
"229": "5",
"230": "6",
"231": "7",
"232": "8",
"233": "9",
"234": "#",
"235": "!",
"236": "?",
"237": "/",
"238": ":",
"239": "-",
"240": "~",
"241": "・",
"242": "¨",
"243": "。",
"244": "「",
"245": "」",
"246": "(",
"247": ")",
"248": "♪",
"249": "◯",
"250": "$",
"251": "\"",
"252": "°",
"253": "◆",
"254": "Ê"
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
namespace ScriptToolGui
{
class Config
{
public string WorkingFolder { get; set; }
public static Config Read(string configPath)
{
if (!File.Exists(configPath))
return null;
return JsonConvert.DeserializeObject<Config>(File.ReadAllText(configPath));
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ScriptTool;
namespace ScriptToolGui
{
class IndexLabel
{
public int Index { get; private set; }
public string Label { get; private set; }
public IndexLabel(int index, string label)
{
Index = index;
Label = label;
}
public IndexLabel(MainStringRef stringRef)
: this(stringRef.Index, stringRef.Label)
{
}
}
}

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScriptToolGui
{
class IndexMapping : IEnumerable<IndexPair>, ICollection<IndexPair>
{
public ICollection<IndexPair> Pairs { get; private set; }
public IndexMapping()
{
Pairs = new List<IndexPair>();
}
public void Add(int first, int second)
{
Pairs.Add(new IndexPair(first, second));
}
public IEnumerator<IndexPair> GetEnumerator()
{
return Pairs.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Add(IndexPair item)
{
Pairs.Add(item);
}
public void Clear()
{
Pairs.Clear();
}
public bool Contains(IndexPair item)
{
return Pairs.Contains(item);
}
public void CopyTo(IndexPair[] array, int arrayIndex)
{
Pairs.CopyTo(array, arrayIndex);
}
public int Count
{
get { return Pairs.Count; }
}
public bool IsReadOnly
{
get { return Pairs.IsReadOnly; }
}
public bool Remove(IndexPair item)
{
return Pairs.Remove(item);
}
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScriptToolGui
{
class IndexPair
{
public int First { get; private set; }
public int Second { get; private set; }
public IndexPair(int first, int second)
{
First = first;
Second = second;
}
public override string ToString()
{
return String.Format("First: {0}, Second: {1}", First, Second);
}
}
}

603
tools/ScriptToolGui/MainForm.Designer.cs generated Normal file
View File

@ -0,0 +1,603 @@
namespace ScriptToolGui
{
partial class MainForm
{
/// <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.components = new System.ComponentModel.Container();
this.mainMenu = new System.Windows.Forms.MenuStrip();
this.fileMenu = new System.Windows.Forms.ToolStripMenuItem();
this.saveMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolsMenu = new System.Windows.Forms.ToolStripMenuItem();
this.resolveDuplicateLabelsMenu = new System.Windows.Forms.ToolStripMenuItem();
this.checkCompletionMenu = new System.Windows.Forms.ToolStripMenuItem();
this.autosaveMenu = new System.Windows.Forms.ToolStripMenuItem();
this.topPanel = new System.Windows.Forms.FlowLayoutPanel();
this.label1 = new System.Windows.Forms.Label();
this.collectionSelector = new System.Windows.Forms.ComboBox();
this.groupSelector = new System.Windows.Forms.ComboBox();
this.prevButton = new System.Windows.Forms.Button();
this.nextButton = new System.Windows.Forms.Button();
this.backButton = new System.Windows.Forms.Button();
this.mainPanel = new System.Windows.Forms.Panel();
this.mainSplitContainer = new System.Windows.Forms.SplitContainer();
this.leftSplitContainer = new System.Windows.Forms.SplitContainer();
this.textBoxPanel = new System.Windows.Forms.Panel();
this.ebString = new System.Windows.Forms.TextBox();
this.m12String = new System.Windows.Forms.TextBox();
this.m12StringEnglish = new System.Windows.Forms.TextBox();
this.lineOpsPanel = new System.Windows.Forms.FlowLayoutPanel();
this.copyCodesButton = new System.Windows.Forms.Button();
this.previewButton = new System.Windows.Forms.Button();
this.translateButton = new System.Windows.Forms.Button();
this.codeSplitContainer = new System.Windows.Forms.SplitContainer();
this.codeList = new System.Windows.Forms.ListBox();
this.label2 = new System.Windows.Forms.Label();
this.referenceList = new System.Windows.Forms.ListBox();
this.label3 = new System.Windows.Forms.Label();
this.gameSelectorPanel = new System.Windows.Forms.FlowLayoutPanel();
this.ebSelector = new System.Windows.Forms.RadioButton();
this.m12Selector = new System.Windows.Forms.RadioButton();
this.statusBar = new System.Windows.Forms.StatusStrip();
this.writeLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.writeTimer = new System.Windows.Forms.Timer(this.components);
this.previewer = new ScriptToolGui.StringPreviewer();
this.mainMenu.SuspendLayout();
this.topPanel.SuspendLayout();
this.mainPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
this.mainSplitContainer.Panel1.SuspendLayout();
this.mainSplitContainer.Panel2.SuspendLayout();
this.mainSplitContainer.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.leftSplitContainer)).BeginInit();
this.leftSplitContainer.Panel1.SuspendLayout();
this.leftSplitContainer.Panel2.SuspendLayout();
this.leftSplitContainer.SuspendLayout();
this.textBoxPanel.SuspendLayout();
this.lineOpsPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.codeSplitContainer)).BeginInit();
this.codeSplitContainer.Panel1.SuspendLayout();
this.codeSplitContainer.Panel2.SuspendLayout();
this.codeSplitContainer.SuspendLayout();
this.gameSelectorPanel.SuspendLayout();
this.statusBar.SuspendLayout();
this.SuspendLayout();
//
// mainMenu
//
this.mainMenu.BackColor = System.Drawing.SystemColors.Control;
this.mainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileMenu,
this.toolsMenu});
this.mainMenu.Location = new System.Drawing.Point(0, 0);
this.mainMenu.Name = "mainMenu";
this.mainMenu.Size = new System.Drawing.Size(1026, 24);
this.mainMenu.TabIndex = 8;
this.mainMenu.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";
this.saveMenu.Click += new System.EventHandler(this.saveMenu_Click);
//
// toolsMenu
//
this.toolsMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.resolveDuplicateLabelsMenu,
this.checkCompletionMenu,
this.autosaveMenu});
this.toolsMenu.Name = "toolsMenu";
this.toolsMenu.Size = new System.Drawing.Size(47, 20);
this.toolsMenu.Text = "Tools";
//
// resolveDuplicateLabelsMenu
//
this.resolveDuplicateLabelsMenu.Name = "resolveDuplicateLabelsMenu";
this.resolveDuplicateLabelsMenu.Size = new System.Drawing.Size(214, 22);
this.resolveDuplicateLabelsMenu.Text = "Resolve duplicate labels...";
this.resolveDuplicateLabelsMenu.Click += new System.EventHandler(this.resolveDuplicateLabelsMenu_Click);
//
// checkCompletionMenu
//
this.checkCompletionMenu.Name = "checkCompletionMenu";
this.checkCompletionMenu.Size = new System.Drawing.Size(214, 22);
this.checkCompletionMenu.Text = "Check completion status...";
this.checkCompletionMenu.Click += new System.EventHandler(this.checkCompletionMenu_Click);
//
// autosaveMenu
//
this.autosaveMenu.Checked = true;
this.autosaveMenu.CheckOnClick = true;
this.autosaveMenu.CheckState = System.Windows.Forms.CheckState.Checked;
this.autosaveMenu.Name = "autosaveMenu";
this.autosaveMenu.Size = new System.Drawing.Size(214, 22);
this.autosaveMenu.Text = "Autosave";
this.autosaveMenu.Click += new System.EventHandler(this.autosaveMenu_Click);
//
// topPanel
//
this.topPanel.AutoSize = true;
this.topPanel.Controls.Add(this.label1);
this.topPanel.Controls.Add(this.collectionSelector);
this.topPanel.Controls.Add(this.groupSelector);
this.topPanel.Controls.Add(this.prevButton);
this.topPanel.Controls.Add(this.nextButton);
this.topPanel.Controls.Add(this.backButton);
this.topPanel.Dock = System.Windows.Forms.DockStyle.Top;
this.topPanel.Location = new System.Drawing.Point(0, 24);
this.topPanel.Name = "topPanel";
this.topPanel.Size = new System.Drawing.Size(1026, 29);
this.topPanel.TabIndex = 10;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(3, 8);
this.label1.Margin = new System.Windows.Forms.Padding(3, 8, 0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(39, 13);
this.label1.TabIndex = 13;
this.label1.Text = "Group:";
//
// collectionSelector
//
this.collectionSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.collectionSelector.FormattingEnabled = true;
this.collectionSelector.Location = new System.Drawing.Point(45, 4);
this.collectionSelector.Margin = new System.Windows.Forms.Padding(3, 4, 3, 3);
this.collectionSelector.Name = "collectionSelector";
this.collectionSelector.Size = new System.Drawing.Size(157, 21);
this.collectionSelector.TabIndex = 14;
this.collectionSelector.SelectionChangeCommitted += new System.EventHandler(this.collectionSelector_SelectionChangeCommitted);
//
// groupSelector
//
this.groupSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.groupSelector.FormattingEnabled = true;
this.groupSelector.Location = new System.Drawing.Point(208, 4);
this.groupSelector.Margin = new System.Windows.Forms.Padding(3, 4, 3, 3);
this.groupSelector.Name = "groupSelector";
this.groupSelector.Size = new System.Drawing.Size(238, 21);
this.groupSelector.TabIndex = 10;
this.groupSelector.SelectionChangeCommitted += new System.EventHandler(this.groupSelector_SelectionChangeCommitted);
//
// prevButton
//
this.prevButton.Location = new System.Drawing.Point(452, 3);
this.prevButton.Name = "prevButton";
this.prevButton.Size = new System.Drawing.Size(45, 23);
this.prevButton.TabIndex = 16;
this.prevButton.Text = "˄";
this.prevButton.UseVisualStyleBackColor = true;
this.prevButton.Click += new System.EventHandler(this.prevButton_Click);
//
// nextButton
//
this.nextButton.Location = new System.Drawing.Point(503, 3);
this.nextButton.Name = "nextButton";
this.nextButton.Size = new System.Drawing.Size(45, 23);
this.nextButton.TabIndex = 15;
this.nextButton.Text = "˅";
this.nextButton.UseVisualStyleBackColor = true;
this.nextButton.Click += new System.EventHandler(this.nextButton_Click);
//
// 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(554, 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);
//
// mainPanel
//
this.mainPanel.AutoSize = true;
this.mainPanel.BackColor = System.Drawing.SystemColors.Control;
this.mainPanel.Controls.Add(this.mainSplitContainer);
this.mainPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainPanel.Location = new System.Drawing.Point(0, 53);
this.mainPanel.Name = "mainPanel";
this.mainPanel.Size = new System.Drawing.Size(1026, 667);
this.mainPanel.TabIndex = 11;
//
// mainSplitContainer
//
this.mainSplitContainer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.mainSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.mainSplitContainer.Location = new System.Drawing.Point(0, 0);
this.mainSplitContainer.Name = "mainSplitContainer";
//
// mainSplitContainer.Panel1
//
this.mainSplitContainer.Panel1.AutoScroll = true;
this.mainSplitContainer.Panel1.BackColor = System.Drawing.SystemColors.Control;
this.mainSplitContainer.Panel1.Controls.Add(this.leftSplitContainer);
//
// mainSplitContainer.Panel2
//
this.mainSplitContainer.Panel2.BackColor = System.Drawing.SystemColors.Control;
this.mainSplitContainer.Panel2.Controls.Add(this.codeSplitContainer);
this.mainSplitContainer.Panel2.Controls.Add(this.gameSelectorPanel);
this.mainSplitContainer.Size = new System.Drawing.Size(1026, 667);
this.mainSplitContainer.SplitterDistance = 800;
this.mainSplitContainer.TabIndex = 6;
//
// leftSplitContainer
//
this.leftSplitContainer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.leftSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.leftSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.leftSplitContainer.Location = new System.Drawing.Point(0, 0);
this.leftSplitContainer.Name = "leftSplitContainer";
this.leftSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// leftSplitContainer.Panel1
//
this.leftSplitContainer.Panel1.Controls.Add(this.textBoxPanel);
this.leftSplitContainer.Panel1.Controls.Add(this.lineOpsPanel);
//
// leftSplitContainer.Panel2
//
this.leftSplitContainer.Panel2.Controls.Add(this.previewer);
this.leftSplitContainer.Size = new System.Drawing.Size(800, 667);
this.leftSplitContainer.SplitterDistance = 526;
this.leftSplitContainer.TabIndex = 5;
//
// textBoxPanel
//
this.textBoxPanel.AutoScroll = true;
this.textBoxPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.textBoxPanel.Controls.Add(this.ebString);
this.textBoxPanel.Controls.Add(this.m12String);
this.textBoxPanel.Controls.Add(this.m12StringEnglish);
this.textBoxPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBoxPanel.Location = new System.Drawing.Point(0, 0);
this.textBoxPanel.Name = "textBoxPanel";
this.textBoxPanel.Size = new System.Drawing.Size(796, 489);
this.textBoxPanel.TabIndex = 10;
//
// ebString
//
this.ebString.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ebString.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ebString.Location = new System.Drawing.Point(3, 4);
this.ebString.Multiline = true;
this.ebString.Name = "ebString";
this.ebString.ReadOnly = true;
this.ebString.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.ebString.Size = new System.Drawing.Size(786, 128);
this.ebString.TabIndex = 9;
//
// m12String
//
this.m12String.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.m12String.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.m12String.Location = new System.Drawing.Point(3, 138);
this.m12String.Multiline = true;
this.m12String.Name = "m12String";
this.m12String.ReadOnly = true;
this.m12String.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.m12String.Size = new System.Drawing.Size(786, 128);
this.m12String.TabIndex = 10;
//
// m12StringEnglish
//
this.m12StringEnglish.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.m12StringEnglish.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.m12StringEnglish.Location = new System.Drawing.Point(3, 272);
this.m12StringEnglish.Multiline = true;
this.m12StringEnglish.Name = "m12StringEnglish";
this.m12StringEnglish.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.m12StringEnglish.Size = new System.Drawing.Size(786, 128);
this.m12StringEnglish.TabIndex = 11;
this.m12StringEnglish.MouseClick += new System.Windows.Forms.MouseEventHandler(this.m12StringEnglish_MouseClick);
//
// lineOpsPanel
//
this.lineOpsPanel.AutoSize = true;
this.lineOpsPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lineOpsPanel.Controls.Add(this.copyCodesButton);
this.lineOpsPanel.Controls.Add(this.previewButton);
this.lineOpsPanel.Controls.Add(this.translateButton);
this.lineOpsPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.lineOpsPanel.Location = new System.Drawing.Point(0, 489);
this.lineOpsPanel.Name = "lineOpsPanel";
this.lineOpsPanel.Size = new System.Drawing.Size(796, 33);
this.lineOpsPanel.TabIndex = 9;
//
// copyCodesButton
//
this.copyCodesButton.Location = new System.Drawing.Point(3, 3);
this.copyCodesButton.Name = "copyCodesButton";
this.copyCodesButton.Size = new System.Drawing.Size(124, 23);
this.copyCodesButton.TabIndex = 0;
this.copyCodesButton.Text = "Copy codes and labels";
this.copyCodesButton.UseVisualStyleBackColor = true;
this.copyCodesButton.Click += new System.EventHandler(this.copyCodesButton_Click);
//
// previewButton
//
this.previewButton.Location = new System.Drawing.Point(133, 3);
this.previewButton.Name = "previewButton";
this.previewButton.Size = new System.Drawing.Size(75, 23);
this.previewButton.TabIndex = 1;
this.previewButton.Text = "Preview";
this.previewButton.UseVisualStyleBackColor = true;
this.previewButton.Click += new System.EventHandler(this.previewButton_Click);
//
// translateButton
//
this.translateButton.Location = new System.Drawing.Point(214, 3);
this.translateButton.Name = "translateButton";
this.translateButton.Size = new System.Drawing.Size(114, 23);
this.translateButton.TabIndex = 2;
this.translateButton.Text = "Google Translate";
this.translateButton.UseVisualStyleBackColor = true;
this.translateButton.Click += new System.EventHandler(this.translateButton_Click);
//
// codeSplitContainer
//
this.codeSplitContainer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.codeSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.codeSplitContainer.Location = new System.Drawing.Point(0, 33);
this.codeSplitContainer.Name = "codeSplitContainer";
this.codeSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// codeSplitContainer.Panel1
//
this.codeSplitContainer.Panel1.Controls.Add(this.codeList);
this.codeSplitContainer.Panel1.Controls.Add(this.label2);
//
// codeSplitContainer.Panel2
//
this.codeSplitContainer.Panel2.Controls.Add(this.referenceList);
this.codeSplitContainer.Panel2.Controls.Add(this.label3);
this.codeSplitContainer.Size = new System.Drawing.Size(222, 634);
this.codeSplitContainer.SplitterDistance = 292;
this.codeSplitContainer.TabIndex = 1;
//
// codeList
//
this.codeList.Dock = System.Windows.Forms.DockStyle.Fill;
this.codeList.FormattingEnabled = true;
this.codeList.HorizontalScrollbar = true;
this.codeList.Location = new System.Drawing.Point(0, 19);
this.codeList.Name = "codeList";
this.codeList.Size = new System.Drawing.Size(218, 269);
this.codeList.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Dock = System.Windows.Forms.DockStyle.Top;
this.label2.Location = new System.Drawing.Point(0, 0);
this.label2.Margin = new System.Windows.Forms.Padding(0);
this.label2.Name = "label2";
this.label2.Padding = new System.Windows.Forms.Padding(3);
this.label2.Size = new System.Drawing.Size(46, 19);
this.label2.TabIndex = 0;
this.label2.Text = "Codes:";
//
// referenceList
//
this.referenceList.Dock = System.Windows.Forms.DockStyle.Fill;
this.referenceList.FormattingEnabled = true;
this.referenceList.HorizontalScrollbar = true;
this.referenceList.Location = new System.Drawing.Point(0, 19);
this.referenceList.Name = "referenceList";
this.referenceList.Size = new System.Drawing.Size(218, 315);
this.referenceList.TabIndex = 2;
this.referenceList.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.referenceList_MouseDoubleClick);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Dock = System.Windows.Forms.DockStyle.Top;
this.label3.Location = new System.Drawing.Point(0, 0);
this.label3.Name = "label3";
this.label3.Padding = new System.Windows.Forms.Padding(3);
this.label3.Size = new System.Drawing.Size(71, 19);
this.label3.TabIndex = 1;
this.label3.Text = "References:";
//
// gameSelectorPanel
//
this.gameSelectorPanel.AutoSize = true;
this.gameSelectorPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.gameSelectorPanel.Controls.Add(this.ebSelector);
this.gameSelectorPanel.Controls.Add(this.m12Selector);
this.gameSelectorPanel.Dock = System.Windows.Forms.DockStyle.Top;
this.gameSelectorPanel.Location = new System.Drawing.Point(0, 0);
this.gameSelectorPanel.Name = "gameSelectorPanel";
this.gameSelectorPanel.Size = new System.Drawing.Size(222, 33);
this.gameSelectorPanel.TabIndex = 0;
//
// ebSelector
//
this.ebSelector.Appearance = System.Windows.Forms.Appearance.Button;
this.ebSelector.Location = new System.Drawing.Point(3, 3);
this.ebSelector.Name = "ebSelector";
this.ebSelector.Size = new System.Drawing.Size(64, 23);
this.ebSelector.TabIndex = 0;
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
//
this.m12Selector.Appearance = System.Windows.Forms.Appearance.Button;
this.m12Selector.Checked = true;
this.m12Selector.Location = new System.Drawing.Point(73, 3);
this.m12Selector.Name = "m12Selector";
this.m12Selector.Size = new System.Drawing.Size(64, 23);
this.m12Selector.TabIndex = 1;
this.m12Selector.TabStop = true;
this.m12Selector.Text = "M12";
this.m12Selector.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.m12Selector.UseVisualStyleBackColor = true;
this.m12Selector.CheckedChanged += new System.EventHandler(this.gameSelector_CheckedChanged);
//
// statusBar
//
this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.writeLabel});
this.statusBar.Location = new System.Drawing.Point(0, 720);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(1026, 22);
this.statusBar.TabIndex = 7;
this.statusBar.Text = "statusStrip1";
//
// writeLabel
//
this.writeLabel.Name = "writeLabel";
this.writeLabel.Size = new System.Drawing.Size(0, 17);
//
// writeTimer
//
this.writeTimer.Enabled = true;
this.writeTimer.Interval = 10000;
this.writeTimer.Tick += new System.EventHandler(this.writeTimer_Tick);
//
// previewer
//
this.previewer.AutoScroll = true;
this.previewer.CharLookup = null;
this.previewer.Dock = System.Windows.Forms.DockStyle.Fill;
this.previewer.Location = new System.Drawing.Point(0, 0);
this.previewer.M12Compiler = null;
this.previewer.MaxWidth = 0;
this.previewer.Name = "previewer";
this.previewer.Size = new System.Drawing.Size(796, 133);
this.previewer.TabIndex = 0;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1026, 742);
this.Controls.Add(this.mainPanel);
this.Controls.Add(this.topPanel);
this.Controls.Add(this.mainMenu);
this.Controls.Add(this.statusBar);
this.MainMenuStrip = this.mainMenu;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "MOTHER 1+2 Funland";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.mainMenu.ResumeLayout(false);
this.mainMenu.PerformLayout();
this.topPanel.ResumeLayout(false);
this.topPanel.PerformLayout();
this.mainPanel.ResumeLayout(false);
this.mainSplitContainer.Panel1.ResumeLayout(false);
this.mainSplitContainer.Panel2.ResumeLayout(false);
this.mainSplitContainer.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).EndInit();
this.mainSplitContainer.ResumeLayout(false);
this.leftSplitContainer.Panel1.ResumeLayout(false);
this.leftSplitContainer.Panel1.PerformLayout();
this.leftSplitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.leftSplitContainer)).EndInit();
this.leftSplitContainer.ResumeLayout(false);
this.textBoxPanel.ResumeLayout(false);
this.textBoxPanel.PerformLayout();
this.lineOpsPanel.ResumeLayout(false);
this.codeSplitContainer.Panel1.ResumeLayout(false);
this.codeSplitContainer.Panel1.PerformLayout();
this.codeSplitContainer.Panel2.ResumeLayout(false);
this.codeSplitContainer.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.codeSplitContainer)).EndInit();
this.codeSplitContainer.ResumeLayout(false);
this.gameSelectorPanel.ResumeLayout(false);
this.statusBar.ResumeLayout(false);
this.statusBar.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip mainMenu;
private System.Windows.Forms.ToolStripMenuItem fileMenu;
private System.Windows.Forms.ToolStripMenuItem saveMenu;
private System.Windows.Forms.FlowLayoutPanel topPanel;
private System.Windows.Forms.Button backButton;
private System.Windows.Forms.ComboBox groupSelector;
private System.Windows.Forms.Panel mainPanel;
private System.Windows.Forms.SplitContainer mainSplitContainer;
private System.Windows.Forms.SplitContainer leftSplitContainer;
private System.Windows.Forms.SplitContainer codeSplitContainer;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ListBox referenceList;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.FlowLayoutPanel gameSelectorPanel;
private System.Windows.Forms.RadioButton ebSelector;
private System.Windows.Forms.RadioButton m12Selector;
private System.Windows.Forms.StatusStrip statusBar;
private System.Windows.Forms.ToolStripStatusLabel writeLabel;
private System.Windows.Forms.Timer writeTimer;
private System.Windows.Forms.Panel textBoxPanel;
private System.Windows.Forms.TextBox ebString;
private System.Windows.Forms.TextBox m12String;
private System.Windows.Forms.TextBox m12StringEnglish;
private System.Windows.Forms.FlowLayoutPanel lineOpsPanel;
private System.Windows.Forms.Button copyCodesButton;
private System.Windows.Forms.ListBox codeList;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox collectionSelector;
private System.Windows.Forms.Button previewButton;
private StringPreviewer previewer;
private System.Windows.Forms.ToolStripMenuItem toolsMenu;
private System.Windows.Forms.ToolStripMenuItem resolveDuplicateLabelsMenu;
private System.Windows.Forms.ToolStripMenuItem checkCompletionMenu;
private System.Windows.Forms.Button prevButton;
private System.Windows.Forms.Button nextButton;
private System.Windows.Forms.ToolStripMenuItem autosaveMenu;
private System.Windows.Forms.Button translateButton;
}
}

View File

@ -0,0 +1,997 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ScriptTool;
using System.IO;
using Newtonsoft.Json;
namespace ScriptToolGui
{
public partial class MainForm : Form
{
// Config
Config config;
// Static/const members
static Compiler m12Compiler = new Compiler(M12ControlCode.Codes, (rom, address) => rom[address + 1] == 0xFF);
static Compiler ebCompiler = new Compiler(EbControlCode.Codes, (rom, address) => rom[address] < 0x20);
static readonly Game[] validGames;
static IDictionary<byte, string> ebCharLookup;
static IDictionary<byte, string> m12CharLookup;
// Lookups
Dictionary<Game, TextBox> textboxLookup;
Dictionary<Game, List<string>> stringsLookup;
// Saving changes
object changeLock = new object();
bool changesMade = false;
// Strings
List<string> m12Strings;
List<string> m12StringsEnglish;
List<string> ebStrings;
// Index mappings
IndexMapping itemMapping = new IndexMapping();
// Matched reference pairs
MatchedGroupCollection tptGroups = new MatchedGroupCollection("TPT", Game.Eb, Game.M12, Game.M12English);
MatchedGroupCollection battleActionGroups = new MatchedGroupCollection("Battle actions", Game.Eb, Game.M12, Game.M12English);
MatchedGroupCollection itemHelpGroups = new MatchedGroupCollection("Item help", Game.Eb, Game.M12, Game.M12English);
MatchedGroupCollection psiHelpGroups = new MatchedGroupCollection("PSI help", Game.Eb, Game.M12, Game.M12English);
MatchedGroupCollection enemyEncounterGroups = new MatchedGroupCollection("Enemy encounters", Game.Eb, Game.M12, Game.M12English);
MatchedGroupCollection enemyDeathGroups = new MatchedGroupCollection("Enemy deaths", Game.Eb, Game.M12, Game.M12English);
MatchedGroupCollection rawM12Groups = new MatchedGroupCollection("Raw M12 strings", Game.M12, Game.M12English);
MatchedGroupCollection rawEbGroups = new MatchedGroupCollection("Raw EB strings", Game.Eb);
List<MatchedGroupCollection> matchedCollections = new List<MatchedGroupCollection>();
// Navigation stack
IDictionary<Game, int> currentIndex;
NavigationEntry previousNavigationState = null;
Stack<NavigationEntry> navigationStack = new Stack<NavigationEntry>();
MatchedGroupCollection currentCollection = null;
// Misc
bool badStart = false;
static MainForm()
{
validGames = new Game[] { Game.Eb, Game.M12, Game.M12English };
ebCharLookup = JsonConvert.DeserializeObject<Dictionary<byte, string>>(File.ReadAllText("eb-char-lookup.json"));
m12CharLookup = JsonConvert.DeserializeObject<Dictionary<byte, string>>(File.ReadAllText("m12-char-lookup.json"));
}
string ReadEbString(byte[] rom, int address, int length)
{
var sb = new StringBuilder();
for (int i = 0; i < length && rom[address] != 0; i++)
{
sb.Append((char)(rom[address++] - 0x30));
}
return sb.ToString();
}
public MainForm()
{
InitializeComponent();
try
{
config = Config.Read("config.json");
previewer.M12Compiler = m12Compiler;
previewer.CharLookup = ebCharLookup;
ImportAllStrings();
ImportAllStringRefs();
InitLookups();
PopulateCollectionSelector();
collectionSelector.SelectedIndex = 0;
collectionSelector_SelectionChangeCommitted(null, null);
}
catch (Exception e)
{
MessageBox.Show("There was an error starting the tool." + Environment.NewLine +
"Reason: " + e.Message);
badStart = true;
this.Load += (s, ee) => this.Close();
}
}
private void PopulateCollectionSelector()
{
collectionSelector.Items.Clear();
collectionSelector.Items.AddRange(matchedCollections.ToArray());
}
private void PopulateGroupSelector(MatchedGroupCollection collection)
{
groupSelector.Items.Clear();
if (collection != null)
{
groupSelector.Items.AddRange(collection.Groups.ToArray());
}
}
private void InitLookups()
{
textboxLookup = new Dictionary<Game, TextBox> {
{ Game.Eb, ebString },
{ Game.M12, m12String },
{ Game.M12English, m12StringEnglish }
};
stringsLookup = new Dictionary<Game, List<string>> {
{ Game.Eb, ebStrings },
{ Game.M12, m12Strings },
{ Game.M12English, m12StringsEnglish }
};
currentIndex = new Dictionary<Game, int> {
{ Game.Eb, -1 },
{ Game.M12, -1 },
{ Game.M12English,-1 }
};
}
private void ImportAllStringRefs()
{
// TPT
var m12PrimaryTptRefs = ImportStringRefs("m12-tpt-primary.json");
var ebPrimaryTptRefs = ImportStringRefs("eb-tpt-primary.json");
var m12SecondaryTptRefs = ImportStringRefs("m12-tpt-secondary.json");
var ebSecondaryTptRefs = ImportStringRefs("eb-tpt-secondary.json");
tptGroups.Groups.AddRange(MatchRefs(ebPrimaryTptRefs, m12PrimaryTptRefs));
tptGroups.Groups.AddRange(MatchRefs(ebSecondaryTptRefs, m12SecondaryTptRefs));
tptGroups.SortGroups();
// Battle actions
var m12BattleActionRefs = ImportStringRefs("m12-battle-actions.json");
var ebBattleActionRefs = ImportStringRefs("eb-battle-actions.json");
battleActionGroups.Groups.AddRange(MatchRefs(ebBattleActionRefs, m12BattleActionRefs));
battleActionGroups.SortGroups();
// Item help
itemMapping = JsonConvert.DeserializeObject<IndexMapping>(File.ReadAllText("item-map.json"));
var m12ItemHelpRefs = ImportStringRefs("m12-item-help.json");
var ebItemHelpRefs = ImportStringRefs("eb-item-help.json");
var itemHelpMappingGroups = itemMapping.Select(p => new MatchedGroup(
ebItemHelpRefs.First(e => e.Index == p.First),
m12ItemHelpRefs.First(m => m.Index == p.Second)))
.OrderBy(g => g.Refs[Game.Eb].Index)
.ToArray();
itemHelpGroups.Groups.AddRange(itemHelpMappingGroups);
// PSI help
var m12PsiHelpRefs = ImportStringRefs("m12-psi-help.json");
var ebPsiHelpRefs = ImportStringRefs("eb-psi-help.json");
var psiHelpMappingGroups = ebPsiHelpRefs.Select(e =>
new MatchedGroup(e,
m12PsiHelpRefs.First(m => m.Index == e.Index - 1)))
.ToArray();
psiHelpGroups.Groups.AddRange(psiHelpMappingGroups);
psiHelpGroups.SortGroups();
// Enemy encounters
var m12EncounterRefs = ImportStringRefs("m12-enemy-encounters.json");
var ebEncounterRefs = ImportStringRefs("eb-enemy-encounters.json");
enemyEncounterGroups.Groups.AddRange(MatchRefs(ebEncounterRefs, m12EncounterRefs));
// Enemy deaths
var m12DeathRefs = ImportStringRefs("m12-enemy-deaths.json");
var ebDeathRefs = ImportStringRefs("eb-enemy-deaths.json");
enemyDeathGroups.Groups.AddRange(MatchRefs(ebDeathRefs, m12DeathRefs));
// Raw M12
var labels = Enumerable.Range(0, 5864);
foreach (int i in labels)
{
rawM12Groups.Groups.Add(new MatchedGroup(i, "L" + i.ToString()));
}
// Raw EB
labels = Enumerable.Range(0, 5357);
foreach (int i in labels)
{
rawEbGroups.Groups.Add(new MatchedGroup(Game.Eb, i, "L" + i.ToString()));
}
matchedCollections.Add(tptGroups);
matchedCollections.Add(battleActionGroups);
matchedCollections.Add(itemHelpGroups);
matchedCollections.Add(psiHelpGroups);
matchedCollections.Add(enemyEncounterGroups);
matchedCollections.Add(enemyDeathGroups);
matchedCollections.Add(rawM12Groups);
matchedCollections.Add(rawEbGroups);
}
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 MatchedGroup(p.e, p.m))
.ToArray();
}
private MainStringRef[] ImportStringRefs(string fileName)
{
string jsonString = File.ReadAllText(Path.Combine(config.WorkingFolder, fileName));
return JsonConvert.DeserializeObject<MainStringRef[]>(jsonString);
}
private void ImportAllStrings()
{
string m12FileName = Path.Combine(config.WorkingFolder, "m12-strings.txt");
string m12EnglishFileName = Path.Combine(config.WorkingFolder, "m12-strings-english.txt");
string ebFileName = Path.Combine(config.WorkingFolder, "eb-strings.txt");
m12Strings = ImportStrings(m12FileName);
m12StringsEnglish = ImportStrings(m12EnglishFileName);
ebStrings = ImportStrings(ebFileName);
}
private List<string> ImportStrings(string fileName)
{
return new List<string>(File.ReadAllLines(fileName).Where(l => !l.Equals("")));
}
private Game GetCurrentGame()
{
if (ebSelector.Checked)
return Game.Eb;
else if (m12Selector.Checked)
return Game.M12;
return Game.None;
}
private void PopulateCodeList()
{
codeList.Items.Clear();
ISet<IControlCode> codes = null;
if (ebSelector.Checked)
ebCompiler.ScanString(ebString.Text, ebCharLookup, true, out codes);
else if (m12Selector.Checked)
m12Compiler.ScanString(m12String.Text, ebCharLookup, true, out codes);
var sorted = codes.Distinct().OrderBy(c => c).ToArray();
codeList.Items.AddRange(sorted.ToArray());
}
private void PopulateReferenceList()
{
referenceList.Items.Clear();
IList<string> references = null;
if (ebSelector.Checked)
ebCompiler.ScanString(ebString.Text, ebCharLookup, true, out references);
else if (m12Selector.Checked)
m12Compiler.ScanString(m12String.Text, ebCharLookup, true, out references);
references = references.Distinct().OrderBy(r => r).ToList();
referenceList.Items.AddRange(references.ToArray());
}
private string GetString(Game game, MatchedGroup group)
{
int index;
return GetString(game, group, out index);
}
private string GetString(Game game, MatchedGroup group, out int index)
{
if (!group.Refs.ContainsKey(game))
{
index = -1;
return null;
}
return GetString(game, group.Refs[game].Label, out index);
}
private string GetString(Game game, string label, out int index)
{
string labelDef = "^" + label + "^";
var str = stringsLookup[game].Select((l, i) => new { Index = i, Line = l })
.FirstOrDefault(a => a.Line.Contains(labelDef));
if (str == null)
index = -1;
else
index = str.Index;
if (str == null)
return null;
else
return str.Line;
}
private void NavigateTo(MatchedGroup group, MatchedGroupCollection collection)
{
if (group == null)
{
ebString.Text = "";
m12String.Text = "";
m12StringEnglish.Text = "";
}
else
{
int index;
string eb = GetString(Game.Eb, group, out index);
currentIndex[Game.Eb] = index;
string m12 = GetString(Game.M12, group, out index);
currentIndex[Game.M12] = index;
string m12English = GetString(Game.M12English, group, out index);
currentIndex[Game.M12English] = index;
ebString.Text = eb;
m12String.Text = m12;
m12StringEnglish.Text = m12English;
previousNavigationState = new MatchedGroupNavigationEntry(group, collection);
if (m12 != null && m12 == m12Compiler.StripText(m12))
{
m12String.BackColor = Color.Orange;
}
else
{
m12String.BackColor = SystemColors.Control;
}
}
PopulateCodeList();
PopulateReferenceList();
previewButton_Click(null, null);
}
private void SelectGroup(MatchedGroup group, MatchedGroupCollection collection)
{
if (collection != null)
{
if ((MatchedGroupCollection)collectionSelector.SelectedItem !=
collection)
{
collectionSelector.SelectedItem = collection;
PopulateGroupSelector(collection);
}
if (group != null)
{
groupSelector.SelectedItem = group;
}
else
{
groupSelector.SelectedIndex = -1;
}
}
else
{
collectionSelector.SelectedIndex = -1;
groupSelector.SelectedIndex = -1;
}
currentCollection = collection;
}
private void FindGroup(Game game, string label, out MatchedGroup group, out MatchedGroupCollection collection)
{
// Attempt to find the label
string labelDef = "^" + label + "^";
string str = stringsLookup[game].First(s => s.Contains(labelDef));
foreach (var coll in matchedCollections.Where(c => c.Games.Contains(game)))
{
var match = coll.Groups.FirstOrDefault(g => str.Contains("^" + g.Refs[game].Label + "^"));
if (match != null)
{
group = match;
collection = coll;
return;
}
}
group = null;
collection = null;
}
private void NavigateTo(Game game, string label, out MatchedGroup group, out MatchedGroupCollection collection)
{
foreach (var eachGame in validGames)
{
currentIndex[eachGame] = -1;
textboxLookup[eachGame].Text = "";
}
string labelDef = "^" + label + "^";
int index;
textboxLookup[game].Text = GetString(game, label, out index);
currentIndex[game] = index;
if (game == Game.M12 || game == Game.M12English)
{
if (game == Game.M12)
{
textboxLookup[Game.M12English].Text = GetString(Game.M12English, label, out index);
currentIndex[Game.M12English] = index;
}
else if (game == Game.M12English)
{
textboxLookup[Game.M12].Text = GetString(Game.M12, label, out index);
currentIndex[Game.M12] = index;
}
string m12 = textboxLookup[Game.M12].Text;
if (m12 != null && m12 == m12Compiler.StripText(m12))
{
m12String.BackColor = Color.Orange;
}
else
{
m12String.BackColor = SystemColors.Control;
}
}
else
{
m12String.BackColor = SystemColors.Control;
}
previousNavigationState = new ReferenceNavigationEntry(game, label);
FindGroup(game, label, out group, out collection);
// Check if any other games have this matched ref
if (group != null)
{
foreach (var otherGame in group.Refs.Where(kv => kv.Key != game))
{
labelDef = "^" + otherGame.Value.Label + "^";
textboxLookup[otherGame.Key].Text = GetString(otherGame.Key, otherGame.Value.Label, out index);
currentIndex[otherGame.Key] = index;
}
}
PopulateCodeList();
PopulateReferenceList();
previewButton_Click(null, null);
}
private void PushPreviousNavigationState()
{
if (previousNavigationState == null)
return;
navigationStack.Push(previousNavigationState);
}
private async void SaveCurrentState(bool insertEndcode)
{
string endcodeInsertion = null;
lock (changeLock)
{
foreach (var game in validGames)
{
if (currentIndex[game] >= 0)
{
string oldString = stringsLookup[game][currentIndex[game]];
string newString = textboxLookup[game].Text.Replace(Environment.NewLine, "");
if (game == Game.M12English)
{
if (oldString != newString)
{
changesMade = true;
}
if (insertEndcode)
{
// Special case -- for M12 English, if the line is modified,
// check for an end code and insert if it's missing
var lastCode = m12Compiler.GetLastControlCode(newString);
if (!IsJustALabel(newString) && (lastCode == null || (lastCode != null
&& !lastCode.IsEnd)))
{
newString += "[00 FF]";
endcodeInsertion = "Inserted missing [00 FF]";
}
}
}
stringsLookup[game][currentIndex[game]] = newString;
if (!textboxLookup[game].Text.Equals(newString))
{
// Update the text box as well
textboxLookup[game].Text = newString;
}
}
}
}
if (endcodeInsertion != null)
{
await SetMessageLabel(endcodeInsertion);
}
}
public static bool IsJustALabel(string str)
{
return (str.Length > 2) && (str[0] == '^') &&
(str[str.Length - 1] == '^') && !str.Skip(1).Take(str.Length - 2).Contains('^');
}
private void WriteChanges(bool insertEndcode)
{
SaveCurrentState(insertEndcode);
lock (changeLock)
{
//if (changesMade)
{
using (StreamWriter sw = File.CreateText(Path.Combine(config.WorkingFolder, "m12-strings-english.txt")))
{
foreach (string line in m12StringsEnglish)
{
sw.WriteLine(line);
}
}
UpdateStatus(String.Format("Last saved: {0:G}", DateTime.Now));
changesMade = false;
}
}
}
private static IList<string> ExtractLabels(string str)
{
if (str == null)
return null;
var labels = new List<string>();
for (int i = 0; i < str.Length; )
{
// Find the first caret
if (str[i] == '^')
{
// Find the next caret
bool foundNext = false;
for (int j = i + 1; j < str.Length; j++)
{
if (str[j] == '^')
{
// Get the label
string label = str.Substring(i + 1, j - i - 1);
labels.Add(label);
i = j + 1;
foundNext = true;
break;
}
}
if (!foundNext)
{
throw new Exception("Found opening caret with no closing caret: " + str);
}
}
else
{
i++;
}
}
return labels;
}
private void UpdateStatus(string text)
{
if (statusBar.InvokeRequired)
{
statusBar.Invoke(new Action<string>(UpdateStatus), text);
}
else
{
writeLabel.Text = text;
}
}
private void groupSelector_SelectionChangeCommitted(object sender, EventArgs e)
{
SaveCurrentState(true);
if (groupSelector.SelectedIndex == -1)
{
NavigateTo(null, null);
}
else
{
PushPreviousNavigationState();
var currentGroup = (MatchedGroup)groupSelector.SelectedItem;
var currentCollection = (MatchedGroupCollection)collectionSelector.SelectedItem;
NavigateTo(currentGroup, currentCollection);
}
}
private void gameSelector_CheckedChanged(object sender, EventArgs e)
{
PopulateCodeList();
PopulateReferenceList();
}
private void referenceList_MouseDoubleClick(object sender, MouseEventArgs e)
{
int match = referenceList.IndexFromPoint(e.Location);
if (match != ListBox.NoMatches)
{
Game game = GetCurrentGame();
string label = (string)referenceList.SelectedItem;
// Only navigate if we're not already at the target label
if (!stringsLookup[game].Contains("^" + label + "^"))
{
SaveCurrentState(true);
PushPreviousNavigationState();
MatchedGroup group;
MatchedGroupCollection collection;
NavigateTo(game, label, out group, out collection);
SelectGroup(group, collection);
}
}
}
private void backButton_Click(object sender, EventArgs e)
{
if (navigationStack.Count < 1)
return;
SaveCurrentState(true);
var nav = navigationStack.Pop();
if (nav.Type == NavigationType.MatchedGroup)
{
var matchedEntry = (MatchedGroupNavigationEntry)nav;
NavigateTo(matchedEntry.Group, matchedEntry.Collection);
SelectGroup(matchedEntry.Group, matchedEntry.Collection);
}
else if (nav.Type == NavigationType.Reference)
{
var referenceEntry = (ReferenceNavigationEntry)nav;
MatchedGroup group;
MatchedGroupCollection collection;
NavigateTo(referenceEntry.Game, referenceEntry.Label, out group, out collection);
SelectGroup(group, collection);
}
}
private void saveMenu_Click(object sender, EventArgs e)
{
WriteChanges(true);
}
private void writeTimer_Tick(object sender, EventArgs e)
{
WriteChanges(false);
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (badStart)
return;
writeTimer.Enabled = false;
WriteChanges(true);
}
private void copyCodesButton_Click(object sender, EventArgs e)
{
m12StringEnglish.Text = m12Compiler.StripText(m12String.Text);
groupSelector.Focus();
}
private void collectionSelector_SelectionChangeCommitted(object sender, EventArgs e)
{
if (collectionSelector.SelectedIndex == -1)
{
groupSelector.Items.Clear();
previewer.DisplayString(null, false);
}
else
{
var collection = (MatchedGroupCollection)collectionSelector.SelectedItem;
// Set the previewer width before we do navigation stuff
if (collection == psiHelpGroups)
{
previewer.MaxWidth = 224;
}
else if (collection == battleActionGroups)
{
previewer.MaxWidth = 176;
}
else
{
previewer.MaxWidth = 144;
}
// Take no action if we haven't actually changed the collection
// (otherwise, the group selector would jump to 0, probably unwanted)
if (collection == currentCollection)
return;
currentCollection = collection;
PopulateGroupSelector(collection);
groupSelector.SelectedIndex = 0;
groupSelector_SelectionChangeCommitted(null, null);
}
}
private void previewButton_Click(object sender, EventArgs e)
{
previewer.DisplayString(m12StringEnglish.Text, true);
}
private void m12StringEnglish_MouseClick(object sender, MouseEventArgs e)
{
if (ModifierKeys == Keys.Control)
{
// Insert a line break
int currentSelectionStart = m12StringEnglish.SelectionStart;
m12StringEnglish.Text = m12StringEnglish.Text.Insert(m12StringEnglish.SelectionStart, "[01 FF]");
m12StringEnglish.SelectionStart = currentSelectionStart + 7;
}
}
private async Task SetMessageLabel(string message)
{
var messageLabel = new ToolStripStatusLabel(message);
messageLabel.Font = new Font(messageLabel.Font, FontStyle.Bold);
messageLabel.BackColor = SystemColors.Highlight;
statusBar.Items.Add(messageLabel);
await Task.Delay(3000);
statusBar.Items.Remove(messageLabel);
}
private void resolveDuplicateLabelsMenu_Click(object sender, EventArgs e)
{
SaveCurrentState(false);
try
{
// Enumerate all labels
var labels = m12StringsEnglish.Select((s, i) => new { Labels = ExtractLabels(s), Index = i });
// Find duplicates
var flattened = labels.SelectMany(l => l.Labels.Select(b => new { Label = b, Index = l.Index }));
var duplicates = flattened.GroupBy(f => f.Label)
.Where(g => g.Count() > 1)
.Select(g => new
{
Label = g.Key,
Indices = g.Select(r => new { Index = r.Index, Trivial = IsJustALabel(m12StringsEnglish[r.Index]) }).ToList()
})
.ToList();
// Find the duplicates that can be resolved
var canBeResolved = duplicates.Where(d => d.Indices.Where(i => !i.Trivial).Count() <= 1).ToList();
// Find the duplicates that can't be resolved
var cantBeResolved = duplicates.Where(d => d.Indices.Where(i => !i.Trivial).Count() > 1).ToList();
if (duplicates.Count == 0)
{
MessageBox.Show("No duplicates found.", "Duplicates", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
string message = "Duplicates were found.";
if (canBeResolved.Count > 0)
{
message += Environment.NewLine + Environment.NewLine +
"The following duplicates may be resolved automatically:" + Environment.NewLine +
String.Join(", ", canBeResolved.Select(d => d.Label).ToArray());
}
if (cantBeResolved.Count > 0)
{
message += Environment.NewLine + Environment.NewLine +
"The following duplicates cannot be resolved manually:" + Environment.NewLine +
String.Join(", ", cantBeResolved.Select(d => d.Label).ToArray());
}
if (canBeResolved.Count > 0)
{
message += Environment.NewLine + Environment.NewLine +
"Would you like to fix the resolvable duplicates now?";
var dialogResult = MessageBox.Show(message, "Duplicates", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
// The trivial duplicates may simply be removed from the strings collection
// Unless, however, a label has no non-trivial duplicates; in that case, keep one of them
var noNonTrivial = canBeResolved.Where(d => !d.Indices.Any(i => !i.Trivial));
foreach (var toBeSaved in noNonTrivial)
toBeSaved.Indices.RemoveAt(0);
var toBeRemoved = canBeResolved.Where(d => d.Indices.Any(i => !i.Trivial))
.Concat(noNonTrivial)
.SelectMany(d => d.Indices)
.Where(i => i.Trivial)
.Select(i => i.Index)
.Distinct()
.OrderByDescending(i => i);
// If there are no non-trivial duplicates, we must leave exactly one trivial duplicate
// Make sure we aren't currently on a string that's about to be removed (shouldn't ever actually happen...)
if (toBeRemoved.Any(i => i == currentIndex[Game.M12English]))
{
MessageBox.Show("Could not remove duplicates because one of them is currently selected! Navigate away first.",
"Could not resolve", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
foreach (int i in toBeRemoved)
{
// Remove the string
m12StringsEnglish.RemoveAt(i);
// Update currentIndex
if (currentIndex[Game.M12English] > i)
{
currentIndex[Game.M12English]--;
}
}
MessageBox.Show("Duplicates removed!", "Finished", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show(message, "Duplicates", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error extracting labels. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
private void checkCompletionMenu_Click(object sender, EventArgs e)
{
int completedCount = m12StringsEnglish.Count(s => !IsJustALabel(s));
int total = m12StringsEnglish.Count;
MessageBox.Show(String.Format("Completed: {0}/{1} ({2:F2}%)", completedCount, total, (double)completedCount * 100d / (double)total));
}
private void prevButton_Click(object sender, EventArgs e)
{
if (groupSelector.SelectedIndex < 1)
{
return;
}
groupSelector.SelectedIndex--;
groupSelector_SelectionChangeCommitted(null, null);
}
private void nextButton_Click(object sender, EventArgs e)
{
if (groupSelector.SelectedIndex == -1 || groupSelector.SelectedIndex == groupSelector.Items.Count - 1)
{
return;
}
groupSelector.SelectedIndex++;
groupSelector_SelectionChangeCommitted(null, null);
}
private void autosaveMenu_Click(object sender, EventArgs e)
{
writeTimer.Enabled = autosaveMenu.Checked;
}
private void translateButton_Click(object sender, EventArgs e)
{
string toTranslate = StripCodes(m12String.Text);
Translate(toTranslate);
}
private void Translate(string toTranslate)
{
var builder = new StringBuilder();
builder.Append("https://translate.google.com/#ja/en/");
var bytes = Encoding.UTF8.GetBytes(toTranslate);
foreach (byte b in bytes)
{
builder.Append('%');
builder.Append(b.ToString("X2"));
}
System.Diagnostics.Process.Start(builder.ToString());
}
private string StripCodes(string str)
{
var builder = new StringBuilder();
bool inCode = false;
foreach(char c in str)
{
if (c == '[')
{
inCode = true;
}
else if (c == ']')
{
inCode = false;
builder.Append(' ');
}
else if (c == '^')
{
inCode = !inCode;
}
else
{
if (!inCode)
builder.Append(c);
}
}
return builder.ToString();
}
}
enum Game
{
None,
Eb,
M2,
M12,
M12English
}
}

View File

@ -0,0 +1,129 @@
<?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>
<metadata name="mainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="statusBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>127, 17</value>
</metadata>
<metadata name="writeTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>228, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,63 @@
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, IndexLabel> Refs { get; private set; }
public MatchedGroup()
{
Refs = new Dictionary<Game, IndexLabel>();
}
public MatchedGroup(MainStringRef ebRef, MainStringRef m12Ref)
: this()
{
Refs.Add(Game.Eb, new IndexLabel(ebRef));
Refs.Add(Game.M12, new IndexLabel(m12Ref));
Refs.Add(Game.M12English, new IndexLabel(m12Ref));
}
public MatchedGroup(MainStringRef m12Ref)
: this()
{
Refs.Add(Game.M12, new IndexLabel(m12Ref));
Refs.Add(Game.M12English, new IndexLabel(m12Ref));
}
public MatchedGroup(int m12Index, string m12Label)
: this()
{
Refs.Add(Game.M12, new IndexLabel(m12Index, m12Label));
Refs.Add(Game.M12English, new IndexLabel(m12Index, m12Label));
}
public MatchedGroup(Game game, int index, string label)
: this()
{
Refs.Add(game, new IndexLabel(index, label));
}
public override string ToString()
{
var parts = new List<string>();
if (Refs.ContainsKey(Game.Eb))
{
parts.Add(String.Format("[{0:D4}] EB: {1}", Refs[Game.Eb].Index, Refs[Game.Eb].Label));
}
if (Refs.ContainsKey(Game.M12))
{
parts.Add(String.Format("[{0:D4}] M12: {1}", Refs[Game.M12].Index, Refs[Game.M12].Label));
}
return String.Join(" / ", parts.ToArray());
}
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScriptToolGui
{
class MatchedGroupCollection : IEnumerable<MatchedGroup>
{
public string Name { get; set; }
public List<MatchedGroup> Groups { get; private set; }
public List<Game> Games { get; private set; }
public MatchedGroupCollection(string name, params Game[] games)
{
Name = name;
Groups = new List<MatchedGroup>();
Games = new List<Game>(games);
}
public void SortGroups()
{
Groups.Sort((g1, g2) => g1.Refs[Game.Eb].Index.CompareTo(g2.Refs[Game.Eb].Index));
}
public IEnumerator<MatchedGroup> GetEnumerator()
{
return Groups.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public override string ToString()
{
return Name;
}
}
}

View File

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScriptToolGui
{
abstract class NavigationEntry
{
public abstract NavigationType Type { get; }
}
enum NavigationType
{
MatchedGroup,
Reference
}
class MatchedGroupNavigationEntry : NavigationEntry
{
public override NavigationType Type { get { return NavigationType.MatchedGroup; } }
public MatchedGroup Group { get; private set; }
public MatchedGroupCollection Collection { get; private set; }
public MatchedGroupNavigationEntry(MatchedGroup group, MatchedGroupCollection collection)
{
Group = group;
Collection = collection;
}
}
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;
}
}
}

View File

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

View File

@ -0,0 +1,48 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="ScriptTool">
<HintPath>..\ScriptTool\bin\$(Configuration)\netcoreapp2.1\ScriptTool.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Update="config.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="eb-char-lookup.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="eb-codelist.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="eb-compressed-strings.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="item-map.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="m12-char-lookup.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="m12-codelist.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="m2-widths-main.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="m2-widths-saturn.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,62 @@
namespace ScriptToolGui
{
partial class StringPreviewer
{
/// <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 Component 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.stringPanel = new System.Windows.Forms.FlowLayoutPanel();
this.SuspendLayout();
//
// stringPanel
//
this.stringPanel.AutoSize = true;
this.stringPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stringPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.stringPanel.Location = new System.Drawing.Point(0, 0);
this.stringPanel.Name = "stringPanel";
this.stringPanel.Size = new System.Drawing.Size(0, 0);
this.stringPanel.TabIndex = 0;
//
// StringPreviewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
this.Controls.Add(this.stringPanel);
this.Name = "StringPreviewer";
this.Size = new System.Drawing.Size(324, 105);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.FlowLayoutPanel stringPanel;
}
}

View File

@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ScriptTool;
namespace ScriptToolGui
{
public partial class StringPreviewer : UserControl
{
public Compiler M12Compiler { get; set; }
public IDictionary<byte, string> CharLookup { get; set; }
public int MaxWidth { get; set; }
public StringPreviewer()
{
InitializeComponent();
}
private void RedrawFancy(string str)
{
stringPanel.Controls.Clear();
if (M12Compiler == null || CharLookup == null || str == null)
{
return;
}
try
{
IList<int> widths;
IList<string> parsed = M12Compiler.FormatPreviewM12(str, out widths, CharLookup);
for (int i = 0; i < parsed.Count; i++)
{
var label = new Label();
label.AutoSize = true;
label.Text = parsed[i] + " (" + widths[i] + ")";
if (widths[i] <= MaxWidth)
label.ForeColor = Color.Green;
else
label.ForeColor = Color.Red;
stringPanel.Controls.Add(label);
}
}
catch (Exception e)
{
stringPanel.Controls.Clear();
var errLabel = new Label();
errLabel.AutoSize = true;
errLabel.Font = new Font(errLabel.Font, FontStyle.Bold);
errLabel.Text = "Error: " + e.Message;
stringPanel.Controls.Add(errLabel);
}
}
private void RedrawPlain(string str)
{
stringPanel.Controls.Clear();
if (str == null)
return;
var label = new Label
{
AutoSize = true,
Text = str
};
stringPanel.Controls.Add(label);
}
public void DisplayString(string str, bool fancy)
{
if (fancy)
RedrawFancy(str);
else
RedrawPlain(str);
}
}
}

View File

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

View File

@ -0,0 +1,3 @@
{
"WorkingFolder": "..\\..\\..\\..\\..\\working"
}

View File

@ -0,0 +1,99 @@
{
"80": " ",
"81": "!",
"82": "\"",
"83": "#",
"84": "$",
"85": "%",
"86": "&",
"87": "'",
"88": "(",
"89": ")",
"90": "*",
"91": "+",
"92": ",",
"93": "-",
"94": ".",
"95": "/",
"96": "0",
"97": "1",
"98": "2",
"99": "3",
"100": "4",
"101": "5",
"102": "6",
"103": "7",
"104": "8",
"105": "9",
"106": ":",
"107": ";",
"108": "<",
"109": "=",
"110": ">",
"111": "?",
"112": "@",
"113": "A",
"114": "B",
"115": "C",
"116": "D",
"117": "E",
"118": "F",
"119": "G",
"120": "H",
"121": "I",
"122": "J",
"123": "K",
"124": "L",
"125": "M",
"126": "N",
"127": "O",
"128": "P",
"129": "Q",
"130": "R",
"131": "S",
"132": "T",
"133": "U",
"134": "V",
"135": "W",
"136": "X",
"137": "Y",
"138": "Z",
"139": "[8B]",
"140": "[8C]",
"141": "[8D]",
"142": "[8E]",
"143": "[8F]",
"144": "`",
"145": "a",
"146": "b",
"147": "c",
"148": "d",
"149": "e",
"150": "f",
"151": "g",
"152": "h",
"153": "i",
"154": "j",
"155": "k",
"156": "l",
"157": "m",
"158": "n",
"159": "o",
"160": "p",
"161": "q",
"162": "r",
"163": "s",
"164": "t",
"165": "u",
"166": "v",
"167": "w",
"168": "x",
"169": "y",
"170": "z",
"171": "{",
"172": "|",
"173": "}",
"174": "~",
"175": "\\",
"189": "➨"
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,768 @@
in the
that
...
and
this
to the
about
just
of the
something
going to
to
you have
your
for
you're
@You
really
don't
@The
e the
e you
...
the
will
...Brick Road
ing
some
@Do you want to
like
ou don't have
is
you
you
anything else
the
you want to
for the
friend
at the
ould you like
from
would
he Runaway Five
with
want to
@If you
you don't
s the
ed to
e...
something
t the
@...
@Please
's
of your
@It's
@Thank you
@I
here.
in
@Do you
I'll
have
e of
d you
@I'm
me to
@I don't
@Well,
@This is
ed the
@You're
for a
anything
ing
of
you should
I
from the
s...
it's
time
e to
ed
e of the
to you
n't you
again
for you.
other
ation
little
ing to
can't
much
someone
on the
looks like
don't you
very
the
can
you
that you
it
you want
ou can't
able to
already
give you
understand
my
you can
that
what
here's
there
n the
@What
Thank you
I can't
one
@The
thought
not
You should
ou know
has
back
of
ve been
I'm
there
with you
@I heard
in
here
Fourside
I wonder
to
could
think
out
good
the
You
too much
ome back
t...
here
thing
come
ly
ent
strong
money.
@I'll
an
ou must
are you
with the
on your
too many
you.
know
to be
around
if you
@Are you
ome again
e and
more
think
e your
@Don't
nd the
t to
rea
he
me
strange
for you
ight
a
be
ther
all
cannot
here is
You have
Monotoli
was
ll you
hat
, but
stuff
eep
it
didn't
like th
ll right
should
over
@Oh,
hear
every
I'm not
about t
zombies
damage
his is
all
some
@It
attack
right
ally
orry
ess
er
@That's
carry it
ake
t was
, the
n you
sn't
help
king
ear
ing the
It's
very
talking
ou've
that's
to me
@Hello
enemy
you are
by
IBNT
ight
on't
est
ick
power
s that
s are
call
t is
is
age
, and
great
@Thanks
people
ter
not
ill
ness
@This
into
ha
I can
t your
before
things
tion
for
be
this
Happy
You
out
enough
I'm
@You
go
for
all th
though
ing you
e you
ring
one
get
t you
@I'm s
the s
e's
port
d...
out
@What
get
I have
looking
n this
of my
have a
ent
do
d of
ting
ncrease
Twoson
through
s your
ou'll
place
right
Onett
our
too
ater
be
ain
ing.
take
e is
the
please
do you
need
use
now.
got
and
ning
sta
the t
I was
y the
his
appe
con
ho
hat's
Threed
get
s of
inter
talk
man
day
ove
ha ha
inally
monkey
s and
ate
see
town
side
y to
ever
equip
than
who
long
care
room
e are
ard
end
, you
the b
I know
think
s you
time
ment
so
!
I've
ell
wa
ious
reat
live
ange
we
ble
@.....
ecover
only
thing
er...
Mr.
ough
now
I
wor
to
ed.
I
're
give
ing a
return
better
ince
well
one
still
ying
me...
sta
ust
per
lease
ling
point
ect
ast
pretty
Giygas
ecause
member
carry
used
elieve
money
pres
way
di
even
ound
s to
ting
ted
oing
and
ine
T
sure
on
@...I
while
@but
@We
ice
se
ive
rea
com
est
have
but
away
here
must
but
want
ready
I'm
carr
my
ay...
are
@Hey,
world
ing a
happ
seem
his
nder
se
ant
item
@But
sho
in a
made
night
et's
like
The
che
de
ful
hat
and
self
ould
@No
car
tr
good
stor
ombie
@Oh
@It
s a
vent
ant
so
olla
ree
Your
make
work
power
home
also
ance
@How
h...
@If
ple
buy
e,
n't
oke
n't
more
Good
t a
all
take
round
when
name
being
attle
ite
ack
y...
@Whe
with
al
have
look
t of
aster
a lo
feel
here
count
monst
now
ark
ous
'll
bus
head
any
t you
erson
after
ummer
hard
ful
ever
kid
a b
kay
tra
pla
ook
ome
eat
@Wel
off
turn
I am
oney
any
ave
any
enem
con
me
red
en
bo
re
ell
sell
what
next
ure
bu
pro
on
res
es
lo
our
use
iste
ood
no
ope
ock
row
@He
how
may
as
stor
are
ost
mean
We
He
@An
it
in
ound
one.
come
blue
way,
or
mo
.
each
some
@(Th
otel
hand
came
ca
ame
@Hey
een
spec
red
ing!
...
hose
ind
ice
ver
W
min
et
on
ace
er.
are
nter
o...
were
help
old
it.
hear
stop
look
com
@Do
her
pro
chin
ble
e a
girl
luck
B
act
ike
down
part
see
use
uch
from
just
llow
@Her
at
@So,
ye
ser
ying
ring
eave
big
ried
was
say
su
her
it.
Man
kin
up
ers
@Why
p...
cour
him
agic
any
fin
eal
he
ide
oor
ity
got
ens
ish
ive
sa
oon
fee
s a
nce
D
uck
ass
man
a p
@(I
@Wh
gu
(
bus
los
ts
ba
S
if
@Ha
ma
unn
ay
ner
@A
or
stu
ust
kya
shi
pos
A
int
le
ary
ven
ch
own
hu
@My
@So
sp
sh
wan
ool
Y
old
eas
, I
iki
@Ky
@Ye
spi

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,233 @@
{
"0": "ぁ",
"1": "あ",
"2": "ぃ",
"3": "い",
"4": "ぅ",
"5": "う",
"6": "ぇ",
"7": "え",
"8": "ぉ",
"9": "お",
"10": "か",
"11": "が",
"12": "き",
"13": "ぎ",
"14": "く",
"15": "ぐ",
"16": "け",
"17": "げ",
"18": "こ",
"19": "ご",
"20": "さ",
"21": "ざ",
"22": "し",
"23": "じ",
"24": "す",
"25": "ず",
"26": "せ",
"27": "ぜ",
"28": "そ",
"29": "ぞ",
"30": "た",
"31": "だ",
"32": "ち",
"33": "ぢ",
"34": "っ",
"35": "つ",
"36": "づ",
"37": "て",
"38": "で",
"39": "と",
"40": "ど",
"41": "な",
"42": "に",
"43": "ぬ",
"44": "ね",
"45": "の",
"46": "は",
"47": "ば",
"48": "ぱ",
"49": "ひ",
"50": "び",
"51": "ぴ",
"52": "ふ",
"53": "ぶ",
"54": "ぷ",
"55": "へ",
"56": "べ",
"57": "ぺ",
"58": "ほ",
"59": "ぼ",
"60": "ぽ",
"61": "ま",
"62": "み",
"63": "む",
"64": "め",
"65": "も",
"66": "ゃ",
"67": "や",
"68": "ゅ",
"69": "ゆ",
"70": "ょ",
"71": "よ",
"72": "ら",
"73": "り",
"74": "る",
"75": "れ",
"76": "ろ",
"77": " ",
"78": "わ",
"79": " ",
"80": " ",
"81": "を",
"82": "ん",
"93": "➨",
"96": "ァ",
"97": "ア",
"98": "ィ",
"99": "イ",
"100": "ゥ",
"101": "ウ",
"102": "ェ",
"103": "エ",
"104": "ォ",
"105": "オ",
"106": "カ",
"107": "ガ",
"108": "キ",
"109": "ギ",
"110": "ク",
"111": "グ",
"112": "ケ",
"113": "ゲ",
"114": "コ",
"115": "ゴ",
"116": "サ",
"117": "ザ",
"118": "シ",
"119": "ジ",
"120": "ス",
"121": "ズ",
"122": "セ",
"123": "ゼ",
"124": "ソ",
"125": "ゾ",
"126": "タ",
"127": "ダ",
"128": "チ",
"129": "ヂ",
"130": "ッ",
"131": "ツ",
"132": "ヅ",
"133": "テ",
"134": "デ",
"135": "ト",
"136": "ド",
"137": "ナ",
"138": "ニ",
"139": "ヌ",
"140": "ネ",
"141": "",
"142": "ハ",
"143": "バ",
"144": "パ",
"145": "ヒ",
"146": "ビ",
"147": "ピ",
"148": "フ",
"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": "ン",
"192": "A",
"193": "B",
"194": "C",
"195": "D",
"196": "E",
"197": "F",
"198": "G",
"199": "H",
"200": "I",
"201": "J",
"202": "K",
"203": "L",
"204": "M",
"205": "N",
"206": "O",
"207": "P",
"208": "Q",
"209": "R",
"210": "S",
"211": "T",
"212": "U",
"213": "V",
"214": "W",
"215": "X",
"216": "Y",
"217": "Z",
"218": "α",
"219": "β",
"220": "γ",
"221": "Σ",
"222": "Ω",
"223": " ",
"224": "0",
"225": "1",
"226": "2",
"227": "3",
"228": "4",
"229": "5",
"230": "6",
"231": "7",
"232": "8",
"233": "9",
"234": "#",
"235": "!",
"236": "?",
"237": "/",
"238": ":",
"239": "-",
"240": "~",
"241": "・",
"242": "¨",
"243": "。",
"244": "「",
"245": "」",
"246": "(",
"247": ")",
"248": "♪",
"249": "◯",
"250": "$",
"251": "\"",
"252": "°",
"253": "◆",
"254": "Ê"
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -5,8 +5,4 @@
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
</Project> </Project>