Skip to content

Commit

Permalink
Extracted builder in library.
Browse files Browse the repository at this point in the history
Added example pack
  • Loading branch information
artyfarty committed Jan 24, 2012
1 parent d91bdef commit f54383a
Show file tree
Hide file tree
Showing 17 changed files with 527 additions and 357 deletions.
28 changes: 28 additions & 0 deletions UniversalEmoticonPackBuilder.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,48 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "qip_buildmap", "qip_buildma
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "emoticon_build", "UniversalEmoticonPackBuilder\emoticon_build.csproj", "{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEmoticonPackBuilderLib", "UniversalEmoticonPackBuilderLib\UniversalEmoticonPackBuilderLib.csproj", "{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Debug|Any CPU.ActiveCfg = Debug|x86
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Debug|Mixed Platforms.Build.0 = Debug|x86
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Debug|x86.ActiveCfg = Debug|x86
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Debug|x86.Build.0 = Debug|x86
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Release|Any CPU.ActiveCfg = Release|x86
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Release|Mixed Platforms.ActiveCfg = Release|x86
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Release|Mixed Platforms.Build.0 = Release|x86
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Release|x86.ActiveCfg = Release|x86
{FC8DA446-6B5C-4BD0-881F-D683068A5259}.Release|x86.Build.0 = Release|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Debug|Any CPU.ActiveCfg = Debug|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Debug|Mixed Platforms.Build.0 = Debug|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Debug|x86.ActiveCfg = Debug|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Debug|x86.Build.0 = Debug|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Release|Any CPU.ActiveCfg = Release|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Release|Mixed Platforms.ActiveCfg = Release|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Release|Mixed Platforms.Build.0 = Release|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Release|x86.ActiveCfg = Release|x86
{FB29B9CB-D6D8-43F4-9011-538A0B9C7451}.Release|x86.Build.0 = Release|x86
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Debug|x86.ActiveCfg = Debug|Any CPU
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Release|Any CPU.Build.0 = Release|Any CPU
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2619794A-0A5D-4ED8-A3A8-1D36F1594CDC}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
117 changes: 11 additions & 106 deletions UniversalEmoticonPackBuilder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
using System.Threading;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using Ionic.Zip;
using UniversalEmoticonPackBuilderLib;
using UniversalEmoticonPackBuilderLib.Builders;

namespace QIPSmileBuilder
namespace ConsoleUniversalEmoticonPackBuilder
{
class Program
{
public static CMDArgs Config;
public static BuilderConfig Config;

static void Main(string[] args)
{
// Default config
Config = new CMDArgs()
Config = new BuilderConfig()
{
version = "1.0.0",
author = "VA",
Expand All @@ -35,116 +36,20 @@ static void Main(string[] args)
if (File.Exists(cfg_file))
{
Config =
(CMDArgs)
new DataContractJsonSerializer(typeof(CMDArgs))
(BuilderConfig)
new DataContractJsonSerializer(typeof(BuilderConfig))
.ReadObject(
new StreamReader(cfg_file, Encoding.UTF8).BaseStream
);
Directory.SetCurrentDirectory(new FileInfo(cfg_file).DirectoryName);
}

// Initialize
var packinfo = new PackInfo() { name = Config.name, version = Config.version, author = Config.author };

var build_dir = "build/";// +Directory.CreateDirectory("build/build_" + (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds).Name + "/";


// Cleanup and create build dir
try
{
Directory.CreateDirectory(build_dir).Delete(true);
Directory.CreateDirectory(build_dir);
}
catch (IOException)
{

}

// Load builders
List<SmileConfig> builders = new List<SmileConfig>();
foreach (var b in Config.builders)
switch (b) {
case "qip":
builders.Add(new QipSmileConfig(build_dir, packinfo));
break;
case "pidgin":
builders.Add(new PidginSmileConfig(build_dir, packinfo));
break;
case "adium":
builders.Add(new AdiumSmileConfig(build_dir, packinfo));
break;
case "miranda":
builders.Add(new MirandaSmileConfig(build_dir, packinfo));
break;
case "wim":
builders.Add(new WIMSkin(build_dir, packinfo));
break;
case "gmail":
builders.Add(new GMailUserjs(build_dir, packinfo));
break;
}


// Load pack
Dictionary<string, string> pack = new Dictionary<string, string>();

if (Config.map.Length > 0)
{
string line;
var map = new StreamReader(Config.map);
while ((line = map.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);
}
}
else
throw new Exception("No map defined");// pack = Config.Pack;

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

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

// class that stores emoticon pack info
class PackInfo {
public string name;
public string version;
public string author;

public string FullName {
get {
return String.Format("{0} {1} by {2}", name, version, author);
}
}

public string Description {
get {
return FullName;
}
private static void BuildPacks(BuilderConfig Config)
{
throw new NotImplementedException();
}
}

// Class for config json deserialization
[DataContract]
class CMDArgs {
[DataMember]
public string name;
[DataMember]
public string version;
[DataMember]
public string author;
[DataMember]
public string map;
[DataMember]
public List<string> builders;
}
}
Loading

0 comments on commit f54383a

Please sign in to comment.