Skip to content

Commit

Permalink
Now packs are correctly named and zipped
Browse files Browse the repository at this point in the history
  • Loading branch information
artyfarty committed Jan 23, 2012
1 parent 1afb3b8 commit 65c9594
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 16 deletions.
Binary file added UniversalEmoticonPackBuilder/Ionic.Zip.dll
Binary file not shown.
26 changes: 23 additions & 3 deletions UniversalEmoticonPackBuilder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using Ionic.Zip;

namespace QIPSmileBuilder
{
Expand Down Expand Up @@ -112,23 +113,37 @@ static void Main(string[] args)

abstract class SmileConfig
{
protected string packRootPath;
protected string path;
protected string imagePath;

protected PackInfo pack;
protected string client;

public SmileConfig(PackInfo pack, string client) {

public SmileConfig(PackInfo pack, string client, string path)
{
this.pack = pack;
this.client = client;
this.packRootPath = path + String.Format("{0}/", PathPackFullName);
}

public void CopySmiley(string orig_file, string[] equivs)
{
File.Copy(orig_file, path + RenameFile(orig_file), true);
File.Copy(orig_file, imagePath + RenameFile(orig_file), true);
WriteEntry(RenameFile(orig_file), equivs);
}

public void Finish() {
EndFile();

using (ZipFile zip = new ZipFile())
{
zip.FlattenFoldersOnExtract = false;
zip.AddDirectory(packRootPath);
zip.Comment = pack.Description;
zip.Save(String.Format("build/{0}.zip", PathPackFullName));
}
Directory.CreateDirectory(packRootPath).Delete(true);
}

protected abstract void WriteEntry(string file, string[] equivs);
Expand All @@ -142,6 +157,11 @@ public string PackFullName
{
get { return String.Format("{0} for {1}", pack.FullName, client); }
}

public string PathPackFullName
{
get { return PackFullName.Replace(' ', '_').ToLower(); }
}
}

// class that stores emoticon pack info
Expand Down
41 changes: 28 additions & 13 deletions UniversalEmoticonPackBuilder/Writers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ class QipSmileConfig : SmileConfig
private int counter = 0;

public QipSmileConfig(string path, PackInfo pack)
: base(pack, "QIP")
: base(pack, "QIP", path)
{
this.path = path + String.Format("{0}/", PackFullName);
this.path = packRootPath + String.Format("{0}/", PackFullName);
this.imagePath = this.path;

Directory.CreateDirectory(this.path);

defineFile = new StreamWriter(this.path + "_define.ini", false, Encoding.GetEncoding("windows-1251"));
Expand All @@ -29,9 +31,14 @@ protected override void WriteEntry(string file, string[] equivs)
protected override void EndFile()
{
defineFile.Flush();
var w = new StreamWriter(this.path + "_define_vis.ini", false, Encoding.GetEncoding("windows-1251"));
w.Write("1-{0}", counter + 1);
w.Flush();
defineFile.Close();

using (var w = new StreamWriter(this.path + "_define_vis.ini", false, Encoding.GetEncoding("windows-1251")))
{
w.Write("1-{0}", counter + 1);
w.Flush();
w.Close();
}
}

protected override string RenameFile(string fname)
Expand Down Expand Up @@ -59,9 +66,10 @@ class PidginSmileConfig : SmileConfig
private StreamWriter pidginTheme;

public PidginSmileConfig(string path, PackInfo pack)
: base(pack, "Pidgin")
: base(pack, "Pidgin", path)
{
this.path = path + String.Format("{0}/{1}/", PackFullName);
this.path = packRootPath + String.Format("{0}/", PackFullName);
this.imagePath = this.path;
Directory.CreateDirectory(this.path);

pidginTheme = new StreamWriter(this.path + "theme", false, Encoding.GetEncoding("windows-1251"));
Expand All @@ -81,6 +89,7 @@ protected override void WriteEntry(string file, string[] equivs)
protected override void EndFile()
{
pidginTheme.Flush();
pidginTheme.Close();
}
}

Expand All @@ -89,9 +98,10 @@ class AdiumSmileConfig : SmileConfig
private XmlTextWriter plistWriter;

public AdiumSmileConfig(string path, PackInfo pack)
: base(pack, "Adium")
: base(pack, "Adium", path)
{
this.path = path + String.Format("{0} {1} by {2} for {3}/{0}.AdiumEmoticonSet/", pack.name, pack.version, pack.author, client);
this.path = packRootPath + String.Format("{0}.AdiumEmoticonSet/", PackFullName);
this.imagePath = this.path;
Directory.CreateDirectory(this.path);

plistWriter = new XmlTextWriter(this.path + "Emoticons.plist", Encoding.UTF8);
Expand Down Expand Up @@ -130,6 +140,7 @@ protected override void EndFile()
plistWriter.WriteEndElement();
plistWriter.WriteEndDocument();
plistWriter.Flush();
plistWriter.Close();
}
}

Expand All @@ -138,9 +149,10 @@ class MirandaSmileConfig : SmileConfig
private StreamWriter mirandaTheme;

public MirandaSmileConfig(string path, PackInfo pack)
: base(pack, "Miranda")
: base(pack, "Miranda", path)
{
this.path = path + String.Format("{0} {1} by {2} for Miranda/Animated/", pack.name, pack.version, pack.author);
this.path = packRootPath + String.Format("{0}/", PackFullName);
this.imagePath = this.path + "Animated/";
Directory.CreateDirectory(this.path);

mirandaTheme = new StreamWriter(this.path + pack.name + ".msl", false, Encoding.GetEncoding("utf-8"));
Expand All @@ -159,6 +171,7 @@ protected override void WriteEntry(string file, string[] equivs)
protected override void EndFile()
{
mirandaTheme.Flush();
mirandaTheme.Close();
}
}

Expand All @@ -167,9 +180,10 @@ class WIMSkin : SmileConfig
private StreamWriter wimSkin;

public WIMSkin(string path, PackInfo pack)
: base(pack, "WIM")
: base(pack, "WIM", path)
{
this.path = path + String.Format("{0} {1} by {2} for WIM/PlurkSmilies/", pack.name, pack.version, pack.author);
this.path = packRootPath + String.Format("{0}/", PackFullName);
this.imagePath = this.path + "PlurkSmilies/";
Directory.CreateDirectory(this.path);

wimSkin = new StreamWriter(this.path + pack.name + ".lua", false, Encoding.GetEncoding("utf-8"));
Expand All @@ -189,5 +203,6 @@ protected override void EndFile()
{
wimSkin.WriteLine("};");
wimSkin.Flush();
wimSkin.Close();
}
}
3 changes: 3 additions & 0 deletions UniversalEmoticonPackBuilder/emoticon_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ionic.Zip">
<HintPath>.\Ionic.Zip.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
Expand Down

0 comments on commit 65c9594

Please sign in to comment.