Added config file
This commit is contained in:
parent
f40e9b221b
commit
882e5a5b51
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,8 +15,10 @@ namespace ScriptToolGui
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
|
// Config
|
||||||
|
Config config;
|
||||||
|
|
||||||
// Static/const members
|
// Static/const members
|
||||||
const string workingFolder = @"..\..\..\..\working";
|
|
||||||
static Compiler m12Compiler = new Compiler(M12ControlCode.Codes, (rom, address) => rom[address + 1] == 0xFF);
|
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 Compiler ebCompiler = new Compiler(EbControlCode.Codes, (rom, address) => rom[address] < 0x20);
|
||||||
static readonly Game[] validGames;
|
static readonly Game[] validGames;
|
||||||
|
@ -73,6 +75,8 @@ namespace ScriptToolGui
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
config = Config.Read("config.json");
|
||||||
|
|
||||||
previewer.M12Compiler = m12Compiler;
|
previewer.M12Compiler = m12Compiler;
|
||||||
previewer.CharLookup = ebCharLookup;
|
previewer.CharLookup = ebCharLookup;
|
||||||
|
|
||||||
|
@ -201,15 +205,15 @@ namespace ScriptToolGui
|
||||||
|
|
||||||
private MainStringRef[] ImportStringRefs(string fileName)
|
private MainStringRef[] ImportStringRefs(string fileName)
|
||||||
{
|
{
|
||||||
string jsonString = File.ReadAllText(Path.Combine(workingFolder, fileName));
|
string jsonString = File.ReadAllText(Path.Combine(config.WorkingFolder, fileName));
|
||||||
return JsonConvert.DeserializeObject<MainStringRef[]>(jsonString);
|
return JsonConvert.DeserializeObject<MainStringRef[]>(jsonString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ImportAllStrings()
|
private void ImportAllStrings()
|
||||||
{
|
{
|
||||||
string m12FileName = Path.Combine(workingFolder, "m12-strings.txt");
|
string m12FileName = Path.Combine(config.WorkingFolder, "m12-strings.txt");
|
||||||
string m12EnglishFileName = Path.Combine(workingFolder, "m12-strings-english.txt");
|
string m12EnglishFileName = Path.Combine(config.WorkingFolder, "m12-strings-english.txt");
|
||||||
string ebFileName = Path.Combine(workingFolder, "eb-strings.txt");
|
string ebFileName = Path.Combine(config.WorkingFolder, "eb-strings.txt");
|
||||||
|
|
||||||
m12Strings = ImportStrings(m12FileName);
|
m12Strings = ImportStrings(m12FileName);
|
||||||
m12StringsEnglish = ImportStrings(m12EnglishFileName);
|
m12StringsEnglish = ImportStrings(m12EnglishFileName);
|
||||||
|
@ -526,7 +530,7 @@ namespace ScriptToolGui
|
||||||
{
|
{
|
||||||
//if (changesMade)
|
//if (changesMade)
|
||||||
{
|
{
|
||||||
using (StreamWriter sw = File.CreateText(Path.Combine(workingFolder, "m12-strings-english.txt")))
|
using (StreamWriter sw = File.CreateText(Path.Combine(config.WorkingFolder, "m12-strings-english.txt")))
|
||||||
{
|
{
|
||||||
foreach (string line in m12StringsEnglish)
|
foreach (string line in m12StringsEnglish)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Config.cs" />
|
||||||
<Compile Include="IndexLabel.cs" />
|
<Compile Include="IndexLabel.cs" />
|
||||||
<Compile Include="IndexMapping.cs" />
|
<Compile Include="IndexMapping.cs" />
|
||||||
<Compile Include="IndexPair.cs" />
|
<Compile Include="IndexPair.cs" />
|
||||||
|
@ -85,6 +86,9 @@
|
||||||
<EmbeddedResource Include="StringPreviewer.resx">
|
<EmbeddedResource Include="StringPreviewer.resx">
|
||||||
<DependentUpon>StringPreviewer.cs</DependentUpon>
|
<DependentUpon>StringPreviewer.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<None Include="config.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"WorkingFolder": "..\\..\\..\\..\\working"
|
||||||
|
}
|
Loading…
Reference in New Issue