summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Plugins/emoticons/MepEditor/src/emoticons/EmoFormat.java1
-rw-r--r--Plugins/emoticons/MepEditor/src/emoticons/ImageFile.java1
-rw-r--r--Plugins/emoticons/MepEditor/src/emoticons/ImageUtils.java2
-rw-r--r--Plugins/emoticons/MepEditor/src/emoticons/Images.java46
-rw-r--r--Plugins/emoticons/MepEditor/src/emoticons/MepEditor.java208
-rw-r--r--Plugins/emoticons/MepEditor/src/emoticons/MepFormat.java12
6 files changed, 185 insertions, 85 deletions
diff --git a/Plugins/emoticons/MepEditor/src/emoticons/EmoFormat.java b/Plugins/emoticons/MepEditor/src/emoticons/EmoFormat.java
index 7f01070..0310e8d 100644
--- a/Plugins/emoticons/MepEditor/src/emoticons/EmoFormat.java
+++ b/Plugins/emoticons/MepEditor/src/emoticons/EmoFormat.java
@@ -1,4 +1,5 @@
package emoticons;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
diff --git a/Plugins/emoticons/MepEditor/src/emoticons/ImageFile.java b/Plugins/emoticons/MepEditor/src/emoticons/ImageFile.java
index 8de644f..2767fe1 100644
--- a/Plugins/emoticons/MepEditor/src/emoticons/ImageFile.java
+++ b/Plugins/emoticons/MepEditor/src/emoticons/ImageFile.java
@@ -1,4 +1,5 @@
package emoticons;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
diff --git a/Plugins/emoticons/MepEditor/src/emoticons/ImageUtils.java b/Plugins/emoticons/MepEditor/src/emoticons/ImageUtils.java
index 81527d1..af87e65 100644
--- a/Plugins/emoticons/MepEditor/src/emoticons/ImageUtils.java
+++ b/Plugins/emoticons/MepEditor/src/emoticons/ImageUtils.java
@@ -1,4 +1,5 @@
package emoticons;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -39,6 +40,7 @@ public class ImageUtils
Image image = new Image(Display.getCurrent(), imageData);
fullGifGC.drawImage(image, 0, 0, imageData.width, imageData.height, imageData.x, imageData.y, imageData.width,
imageData.height);
+ image.dispose();
Image frame = new Image(Display.getCurrent(), loader.logicalScreenWidth, loader.logicalScreenHeight);
GC frameGC = new GC(frame);
diff --git a/Plugins/emoticons/MepEditor/src/emoticons/Images.java b/Plugins/emoticons/MepEditor/src/emoticons/Images.java
new file mode 100644
index 0000000..7e527ef
--- /dev/null
+++ b/Plugins/emoticons/MepEditor/src/emoticons/Images.java
@@ -0,0 +1,46 @@
+package emoticons;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+public class Images
+{
+ private static Map<String, Image> images = new HashMap<String, Image>();
+
+ public static Image get(String filename)
+ {
+ if (images.containsKey(filename))
+ return images.get(filename);
+
+ Image ret;
+ try
+ {
+ ret = new Image(Display.getCurrent(), filename);
+ }
+ catch (SWTException e)
+ {
+ ret = null;
+ }
+ images.put(filename, ret);
+ return ret;
+ }
+
+ public static Image get(File file)
+ {
+ try
+ {
+ return get(file.getCanonicalPath());
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/Plugins/emoticons/MepEditor/src/emoticons/MepEditor.java b/Plugins/emoticons/MepEditor/src/emoticons/MepEditor.java
index 6b9cfa5..c7f3910 100644
--- a/Plugins/emoticons/MepEditor/src/emoticons/MepEditor.java
+++ b/Plugins/emoticons/MepEditor/src/emoticons/MepEditor.java
@@ -50,13 +50,19 @@ public class MepEditor
new EmoFormat(emoticons, protocols).load();
Display display = new Display();
+// DeviceData data = new DeviceData();
+// data.tracking = true;
+// Display display = new Display(data);
+// Sleak sleak = new Sleak();
+// sleak.open();
+
shell = new Shell(display);
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE);
dialog.setText("Select folder with emoticon images");
String path = dialog.open();
if (path == null)
return;
- // String path = "C:\\Desenvolvimento\\Miranda\\bin\\Debug Unicode\\Customize\\Emoticons\\Originals";
+// String path = "C:\\Desenvolvimento\\Miranda\\bin\\Debug Unicode\\Customize\\Emoticons\\Originals";
File mepPath = new File(path);
if (!mepPath.exists())
return;
@@ -64,12 +70,10 @@ public class MepEditor
mepFormat = new MepFormat(mepPath, emoticons, protocols);
mep = mepFormat.load();
- shell.setLayout(new FillLayout());
-
createMainWindow(shell);
shell.setText("Emoticon Pack Editor");
- shell.setImage(new Image(Display.getCurrent(), "data/Defaults/smile.png"));
+ shell.setImage(Images.get("data/Defaults/smile.png"));
shell.setSize(500, 600);
shell.open();
@@ -105,7 +109,7 @@ public class MepEditor
private static void createToolbar(Composite main)
{
Button save = new Button(main, SWT.PUSH);
- save.setImage(new Image(Display.getCurrent(), "imgs/disk.png"));
+ save.setImage(Images.get("imgs/disk.png"));
save.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event)
{
@@ -121,6 +125,48 @@ public class MepEditor
});
}
+ private static void createPackGroup(Composite main)
+ {
+ Group group = new Group(main, SWT.NONE);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ group.setText("Pack");
+ group.setLayout(new GridLayout(2, false));
+
+ createBoldLabel(group, "Name:");
+ Text text = new Text(group, SWT.BORDER);
+ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ text.setText(mep.name);
+ text.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event e)
+ {
+ mep.name = ((Text) e.widget).getText();
+ }
+ });
+
+ createBoldLabel(group, "Creator:");
+ text = new Text(group, SWT.BORDER);
+ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ text.setText(mep.creator);
+ text.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event e)
+ {
+ mep.creator = ((Text) e.widget).getText();
+ }
+ });
+
+ createBoldLabel(group, "Updater URL:");
+ text = new Text(group, SWT.BORDER);
+ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ text.setText(mep.udaterURL);
+ text.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event e)
+ {
+ mep.udaterURL = ((Text) e.widget).getText();
+ }
+ });
+
+ }
+
private static void createEmoticonsGroup(final Composite main, String protocol)
{
final Group group = new Group(main, SWT.NONE);
@@ -130,9 +176,9 @@ public class MepEditor
emoticonsScroll = new ScrolledComposite(group, SWT.V_SCROLL);
emoticonsComposite = new Composite(emoticonsScroll, SWT.NONE);
- emoticonsComposite.setLayout(new GridLayout(2, false));
+ emoticonsComposite.setLayout(new GridLayout(4, false));
- createBoldLabel(emoticonsComposite, "Protocol:");
+ createBoldLabel(emoticonsComposite, "Protocol:", gridData(2, 1));
createProtoCombo(emoticonsComposite, protocol, main, group);
for (final Emoticon emo : mep.emoticons)
@@ -143,14 +189,8 @@ public class MepEditor
createEmoticonNameLabel(emoticonsComposite, emo);
- Composite attribs = new Composite(emoticonsComposite, SWT.NONE);
- attribs.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout gl = new GridLayout(2, false);
- gl.marginWidth = 0;
- attribs.setLayout(gl);
-
- createIconCombo(icon, attribs, emo, protocol);
- createFramesHolder(emo, icon, attribs);
+ createIconCombo(icon, emoticonsComposite, emo, protocol);
+ createFramesHolder(emo, icon, emoticonsComposite);
}
emoticonsScroll.setContent(emoticonsComposite);
@@ -171,33 +211,24 @@ public class MepEditor
private static void createEmoticonNameLabel(final Composite parent, final Emoticon emo)
{
- Composite nameComposite = new Composite(parent, SWT.NONE);
- nameComposite.setLayoutData(new GridData());
- nameComposite.setLayout(new GridLayout(2, false));
-
File defImage = new File("data/Defaults/" + emo.name + ".png");
if (defImage.exists())
{
- try
- {
- Image image = new Image(Display.getCurrent(), defImage.getCanonicalPath());
- Label label = new Label(nameComposite, SWT.NONE);
- label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- label.setImage(image);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
+ Label label = new Label(parent, SWT.NONE);
+ label.setLayoutData(gridData(1, 2));
+ label.setImage(Images.get(defImage));
+ createBoldLabel(parent, emo.name, gridData(1, 2));
+ }
+ else
+ {
+ createBoldLabel(parent, emo.name, gridData(2, 2));
}
-
- createBoldLabel(nameComposite, emo.name);
}
private static void createProtoCombo(final Composite parent, String protocol, final Composite main, final Group group)
{
final Combo protoCombo = new Combo(parent, SWT.READ_ONLY);
- protoCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ protoCombo.setLayoutData(gridData(GridData.FILL_HORIZONTAL, 2, 1));
protoCombo.add("All protocols");
for (String p : protocols)
protoCombo.add(p);
@@ -220,6 +251,22 @@ public class MepEditor
});
}
+ private static GridData gridData(int style, int horizontalSpan, int verticalSpan)
+ {
+ GridData gd = new GridData(style);
+ gd.horizontalSpan = horizontalSpan;
+ gd.verticalSpan = verticalSpan;
+ return gd;
+ }
+
+ private static GridData gridData(int horizontalSpan, int verticalSpan)
+ {
+ GridData gd = new GridData();
+ gd.horizontalSpan = horizontalSpan;
+ gd.verticalSpan = verticalSpan;
+ return gd;
+ }
+
private static void createIconCombo(final EmoticonImage icon, Composite parent, final Emoticon emo, final String protocol)
{
Label label = new Label(parent, SWT.NONE);
@@ -249,7 +296,10 @@ public class MepEditor
DelayedListener listener = new DelayedListener(new Listener() {
public void handleEvent(Event e)
{
- icon.image = mep.createTemporaryImage(combo.getText(), protocol);
+ if (combo.getText().trim().length() <= 0)
+ icon.image = null;
+ else
+ icon.image = mep.createTemporaryImage(combo.getText(), protocol);
fillFramesHolder(emo, icon);
}
});
@@ -278,6 +328,7 @@ public class MepEditor
DelayedListener.this.run();
}
};
+ private Color color;
public DelayedListener(Listener listener)
{
@@ -290,6 +341,8 @@ public class MepEditor
delayedListeners.remove(this);
((Control) event.widget).setBackground(bkg);
listener.handleEvent(event);
+ color.dispose();
+ color = null;
}
private void start(Event e)
@@ -298,7 +351,8 @@ public class MepEditor
if (bkg == null)
bkg = ((Control) e.widget).getBackground();
- ((Control) e.widget).setBackground(new Color(Display.getCurrent(), 255, 255, 200));
+ color = new Color(Display.getCurrent(), 255, 255, 200);
+ ((Control) e.widget).setBackground(color);
delayedListeners.add(this);
Display.getCurrent().timerExec(-1, run);
@@ -338,10 +392,17 @@ public class MepEditor
Display.getCurrent().asyncExec(new Runnable() {
public void run()
{
- disposeAllChildren(emo.frames);
+ if (emo.frames.isDisposed())
+ return;
+
+ boolean disposed = disposeAllChildren(emo.frames);
if (icon.image == null)
+ {
+ if (disposed)
+ layout();
return;
+ }
icon.image.loadFrames();
if (icon.image.frames == null)
@@ -379,6 +440,11 @@ public class MepEditor
button.addListener(SWT.Selection, listener);
}
+ layout();
+ }
+
+ private void layout()
+ {
emo.frames.layout();
emoticonsComposite.pack();
Rectangle r = emoticonsScroll.getClientArea();
@@ -387,11 +453,12 @@ public class MepEditor
});
}
- private static void disposeAllChildren(final Composite composite)
+ private static boolean disposeAllChildren(final Composite composite)
{
Control[] children = composite.getChildren();
for (int i = 0; i < children.length; i++)
children[i].dispose();
+ return children.length > 0;
}
private static void createFramesHolder(Emoticon emo, EmoticonImage icon, Composite parent)
@@ -408,64 +475,37 @@ public class MepEditor
fillFramesHolder(emo, icon);
}
- private static void createPackGroup(Composite main)
+ private static Label createBoldLabel(Composite parent, String text)
{
- Group group = new Group(main, SWT.NONE);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- group.setText("Pack");
- group.setLayout(new GridLayout(2, false));
-
- createBoldLabel(group, "Name:");
- Text text = new Text(group, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- text.setText(mep.name);
- text.addListener(SWT.Modify, new Listener() {
- public void handleEvent(Event e)
- {
- mep.name = ((Text) e.widget).getText();
- }
- });
-
- createBoldLabel(group, "Creator:");
- text = new Text(group, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- text.setText(mep.creator);
- text.addListener(SWT.Modify, new Listener() {
- public void handleEvent(Event e)
- {
- mep.creator = ((Text) e.widget).getText();
- }
- });
-
- createBoldLabel(group, "Updater URL:");
- text = new Text(group, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- text.setText(mep.udaterURL);
- text.addListener(SWT.Modify, new Listener() {
- public void handleEvent(Event e)
- {
- mep.udaterURL = ((Text) e.widget).getText();
- }
- });
-
+ Label label = new Label(parent, SWT.NONE);
+ label.setLayoutData(new GridData());
+ label.setText(text);
+ setBoldFont(label);
+ return label;
}
- private static void createBoldLabel(Composite parent, String text)
+ private static Label createBoldLabel(Composite parent, String text, GridData gd)
{
Label label = new Label(parent, SWT.NONE);
- label.setLayoutData(new GridData());
+ label.setLayoutData(gd);
label.setText(text);
setBoldFont(label);
+ return label;
}
+ private static Font boldFont;
+
private static void setBoldFont(Label name)
{
- Font initialFont = name.getFont();
- FontData[] fontData = initialFont.getFontData();
- for (int i = 0; i < fontData.length; i++)
- fontData[i].setStyle(SWT.BOLD);
- Font newFont = new Font(Display.getCurrent(), fontData);
- name.setFont(newFont);
+ if (boldFont == null)
+ {
+ Font initialFont = name.getFont();
+ FontData[] fontData = initialFont.getFontData();
+ for (int i = 0; i < fontData.length; i++)
+ fontData[i].setStyle(SWT.BOLD);
+ boldFont = new Font(Display.getCurrent(), fontData);
+ }
+ name.setFont(boldFont);
}
}
diff --git a/Plugins/emoticons/MepEditor/src/emoticons/MepFormat.java b/Plugins/emoticons/MepEditor/src/emoticons/MepFormat.java
index 1b96c63..e22d5d4 100644
--- a/Plugins/emoticons/MepEditor/src/emoticons/MepFormat.java
+++ b/Plugins/emoticons/MepEditor/src/emoticons/MepFormat.java
@@ -151,7 +151,7 @@ public class MepFormat
case 1:
{
name = txt;
- protocol = module;
+ protocol = getProtocol(module);
break;
}
case 3:
@@ -176,6 +176,16 @@ public class MepFormat
}
}
+ private String getProtocol(String module)
+ {
+ for (String proto : protocols)
+ {
+ if (proto.equalsIgnoreCase(module))
+ return proto;
+ }
+ return null;
+ }
+
private void addImages(File path, String protocol)
{
for (File file : path.listFiles())