-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data export will attempt to preserve existing data (recipes, boostset…
…s, product catalog, etc) rather than overwrite the files. Set bonuses can now be selected from a dropdown list.
- Loading branch information
1 parent
106e928
commit aa1b6a7
Showing
14 changed files
with
7,286 additions
and
263 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Specialized; | ||
using System.IO; | ||
|
||
namespace Inventor | ||
{ | ||
public class BoostSets | ||
{ | ||
public OrderedDictionary list; | ||
|
||
public BoostSets() | ||
{ | ||
list = new OrderedDictionary(StringComparer.OrdinalIgnoreCase); | ||
} | ||
|
||
public void Add(string name, string text) | ||
{ | ||
if (list.Contains(name)) | ||
{ | ||
list[name] = text; | ||
} | ||
else | ||
{ | ||
list.Add(name, text); | ||
} | ||
} | ||
|
||
public void AddFile(string file) | ||
{ | ||
// Really, really, REALLY dumb parser for files that have a single non-nesting structure. | ||
if (File.Exists(file)) | ||
{ | ||
int depth = 0; | ||
string line; | ||
string name = String.Empty; | ||
string text = String.Empty; | ||
StreamReader sr = new StreamReader(file); | ||
while ((line = sr.ReadLine()) != null) | ||
{ | ||
string l = line.Trim().ToUpper(); | ||
if (l.Equals("BOOSTSET")) | ||
{ | ||
name = String.Empty; | ||
text = String.Empty; | ||
} | ||
else if (l.Equals("{")) | ||
{ | ||
depth++; | ||
if (depth > 1) | ||
{ | ||
text += line + Environment.NewLine; | ||
} | ||
} | ||
else if (l.Equals("}")) | ||
{ | ||
depth--; | ||
if (depth > 0) | ||
{ | ||
text += line + Environment.NewLine; | ||
} | ||
else | ||
{ | ||
Add(name, text); | ||
} | ||
} | ||
else | ||
{ | ||
if (l.IndexOf("NAME ") == 0) | ||
{ | ||
name = l.Substring(5).Trim(); | ||
} | ||
text += line + Environment.NewLine; | ||
} | ||
} | ||
|
||
sr.Close(); | ||
} | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
string s = String.Empty; | ||
foreach (DictionaryEntry recipe in list) | ||
{ | ||
s += "BoostSet" + Environment.NewLine; | ||
s += "{" + Environment.NewLine; | ||
s += recipe.Value; | ||
s += "}" + Environment.NewLine; | ||
} | ||
list.Clear(); | ||
return s; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using Force.Crc32; | ||
|
||
namespace Inventor | ||
{ | ||
class PString | ||
{ | ||
public Dictionary<string, string> cache = new Dictionary<string, string>(); | ||
|
||
public string Add(string text) | ||
{ | ||
string hash = "P" + Crc32Algorithm.Compute(Encoding.ASCII.GetBytes(text)); | ||
if (!cache.ContainsKey(hash)) cache.Add(hash, text); | ||
return hash; | ||
} | ||
|
||
public void AddFile(string file) | ||
{ | ||
if (File.Exists(file)) | ||
{ | ||
Parser parser = new Parser(File.ReadAllText(file), null); | ||
if (parser.ParseNext(null)) | ||
{ | ||
foreach (KeyValuePair<string, string> pstring in parser.results) | ||
{ | ||
if (!cache.ContainsKey(pstring.Key)) cache.Add(pstring.Key, pstring.Value); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void AddPath(string dir) | ||
{ | ||
if (Directory.Exists(dir)) | ||
{ | ||
foreach (string file in Directory.GetFiles(dir)) | ||
{ | ||
if (file.ToLower().EndsWith(".ms")) | ||
{ | ||
AddFile(file); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
string s = String.Empty; | ||
foreach (KeyValuePair<string, string> entry in cache.OrderBy(x => x.Value)) | ||
{ | ||
s += "\"" + entry.Key + "\" \"" + entry.Value + "\"" + Environment.NewLine; | ||
} | ||
cache.Clear(); | ||
return s; | ||
} | ||
} | ||
} |
Oops, something went wrong.