Skip to content

Commit

Permalink
more rfactoring
Browse files Browse the repository at this point in the history
example map commented
  • Loading branch information
artyfarty committed Jan 24, 2012
1 parent f54383a commit 1a54edf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
30 changes: 19 additions & 11 deletions UniversalEmoticonPackBuilderLib/main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace UniversalEmoticonPackBuilderLib
{
public static class UniversalEmoticonPackBuilder {
public static void BuildPacks(PackInfo packinfo, string build_dir, List<string> requested_builders, string mapfile)
public static void BuildPacks(PackInfo packinfo, string build_dir, List<string> requested_builders, Dictionary<string, string> map)
{
// Cleanup and create build dir
try
Expand Down Expand Up @@ -47,33 +47,41 @@ public static void BuildPacks(PackInfo packinfo, string build_dir, List<string>
break;
}

// Build!
foreach (var s in map)
builders.ForEach(c => c.CopySmiley(s.Key, s.Value.Split(',')));

builders.ForEach(c => c.Finish());
}

public static void BuildPacks(PackInfo packinfo, string build_dir, List<string> requested_builders, string mapfile) {
// Load pack
Dictionary<string, string> pack = new Dictionary<string, string>();
Dictionary<string, string> map = new Dictionary<string, string>();

if (mapfile.Length > 0)
{
string line;
var map = new StreamReader(mapfile);
while ((line = map.ReadLine()) != null)
var mapStream = new StreamReader(mapfile);
while ((line = mapStream.ReadLine()) != null)
{
if (line.IndexOf('#') == 0) continue;
var spl = line.Split(new[] { ':' }, 2);
if (spl.Length < 2) continue;

var sname = spl[0];
var scode = spl[1];
pack.Add(sname, scode);
map.Add(sname, scode);
}
}
else
throw new Exception("No map defined");// pack = Config.Pack;
throw new Exception("No map defined");

// Build!
foreach (var s in pack)
builders.ForEach(c => c.CopySmiley(s.Key, s.Value.Split(',')));

builders.ForEach(c => c.Finish());
BuildPacks(
packinfo,
build_dir,
requested_builders,
map
);
}

public static void BuildPacks(BuilderConfig Config)
Expand Down
11 changes: 9 additions & 2 deletions examplePack/map.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
ff.gif:(fuu)
# Comment

# empty lines ok
#
# Entry format:
# imagefile:code[,alternativecode[,alternativecode[,alternativecode ... ]]]

ff.gif:(fuu)
fi.gif:(gyay)
fl.gif:(aha)
ft.gif:(troll)
ft.gif:(troll),troll.jpg

0 comments on commit 1a54edf

Please sign in to comment.