diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..e51b5ba
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index 58bcbf8..b8096d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,8 @@
Thumbs.db
ehthumbs.db
+*.class
+
# Folder config file
Desktop.ini
diff --git a/.project b/.project
new file mode 100644
index 0000000..abe8d1c
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ ImgurDownloader2
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..3a21537
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/src/ArrayListHelper.java b/src/ArrayListHelper.java
new file mode 100644
index 0000000..07529a5
--- /dev/null
+++ b/src/ArrayListHelper.java
@@ -0,0 +1,12 @@
+import java.util.ArrayList;
+
+
+public class ArrayListHelper {
+ public static String[] toArray(ArrayList list) {
+ String[] array = new String[list.size()];
+ for(int i = 0; i < array.length; i ++) {
+ array[i] = list.get(i);
+ }
+ return array;
+ }
+}
diff --git a/src/GraphicalImgurRequest.java b/src/GraphicalImgurRequest.java
new file mode 100644
index 0000000..b4b49d6
--- /dev/null
+++ b/src/GraphicalImgurRequest.java
@@ -0,0 +1,76 @@
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+
+public class GraphicalImgurRequest extends ImgurRequest{
+ private Point point = new Point(0, 0);
+ private Point desiredPoint = new Point(0, 0);
+ private double progress = 0;
+
+ public GraphicalImgurRequest(double x1, double y1, double x2, double y2) {
+ point.x = x1;
+ point.y = y1;
+ desiredPoint.x = x2;
+ desiredPoint.y = y2;
+
+
+ }
+
+ public void setDestination(double x, double y) {
+ desiredPoint.x = x;
+ desiredPoint.y = y;
+ }
+
+ public void tick() {
+ double x = point.x;
+ double y = point.y;
+
+ double x2 = desiredPoint.x;
+ double y2 = desiredPoint.y;
+
+ y -= (y - y2) / 8d;
+ x -= (x - x2) / 8d;
+
+ point.x = x;
+ point.y = y;
+
+ double newProgress = getProgress();
+ if(newProgress == newProgress)
+ progress -= (progress - newProgress) / 8d;
+
+ }
+
+ private class Point {
+ public double x, y;
+ public Point(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+ }
+
+ public void draw(Graphics2D g) {
+ final int WIDTH = 300;
+
+ int XOFF = (int)(point.x);
+ int YOFF = (int)(point.y);
+
+ FontMetrics metrics = g.getFontMetrics();
+
+ g.setColor(Color.BLACK);
+ g.fillRect(XOFF, YOFF + 13, (int) (WIDTH * progress), 20);
+ g.drawRect(XOFF, YOFF + 13, WIDTH, 20);
+
+ //total images
+ String str = "" + getImagesDiscovered();
+ g.drawString(str, XOFF + WIDTH - (metrics.charsWidth(str.toCharArray(), 0, str.length())) / 2, YOFF + 45);
+
+ //downloaded
+ str = "" + getImagesDownloaded();
+ g.drawString(str, XOFF + (int) (WIDTH * progress) - (metrics.charsWidth(str.toCharArray(), 0, str.length())) / 2, YOFF + 10);
+
+ // name of the thing
+ str = getTitle();
+ g.drawString(str, XOFF + (WIDTH / 2) - (metrics.charsWidth(str.toCharArray(), 0, str.length())) / 2, YOFF);
+
+ }
+}
diff --git a/src/ImgurDownloader.java b/src/ImgurDownloader.java
new file mode 100644
index 0000000..eb52cf5
--- /dev/null
+++ b/src/ImgurDownloader.java
@@ -0,0 +1,134 @@
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.event.KeyEvent;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import MAndEngine.BasicApp;
+import MAndEngine.Engine;
+
+public class ImgurDownloader implements BasicApp {
+
+ private ArrayList requests;
+ private String textBox = "";
+
+ @Override
+ public Dimension getResolution() {
+ return new Dimension(800, 600);
+ }
+
+ @Override
+ public void initialize() {
+
+ requests = new ArrayList();
+
+ }
+
+ @Override
+ public void resumeApp() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void pauseApp() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void tick() {
+ int GAP = 70;
+ int MARGIN_TOP = 30;
+
+ for (int i = 0; i < requests.size(); i++) {
+ requests.get(i).setDestination(450, MARGIN_TOP + (GAP * i));
+ requests.get(i).tick();
+ }
+
+ Iterator iterator = requests.iterator();
+ while(iterator.hasNext()) {
+ GraphicalImgurRequest req = iterator.next();
+ if(!req.isBusy()) {
+ iterator.remove();
+ }
+ }
+
+ if (Engine.keys[KeyEvent.VK_ENTER] && textBox != "") {
+ GraphicalImgurRequest request = new GraphicalImgurRequest(800, MARGIN_TOP + (GAP * (requests.size())), 450, MARGIN_TOP + (GAP * (requests.size())));
+ request.saveSubreddit(textBox, 10, "time");
+ requests.add(request);
+ textBox = "";
+ }
+ }
+
+ @Override
+ public void render(Graphics2D g) {
+ g.setColor(Color.WHITE);
+ g.fillRect(0, 0, 800, 600);
+ for (int i = 0; i < requests.size(); i++) {
+ requests.get(i).draw(g);
+ }
+ g.drawString(textBox, 100, 100);
+
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ char c = ("" + e.getKeyChar()).toLowerCase().charAt(0);
+ if (c >= 97 && c < 123) {
+
+ textBox += c;
+
+ }
+
+ else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
+ textBox = textBox.substring(0, textBox.length() - 1);
+ }
+
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getTitle() {
+ return "Imgur Downloader";
+ }
+
+ @Override
+ public Color getColor() {
+ return null;
+ }
+
+ @Override
+ public int getFramerate() {
+ return 30;
+ }
+
+ @Override
+ public boolean getResizable() {
+ return true;
+ }
+
+ @Override
+ public boolean visibleInMenu() {
+ return true;
+ }
+
+ @Override
+ public void resized(int width, int height) {
+ // not resizable
+ }
+
+ @Override
+ public void click() {
+ // TODO
+ }
+
+}
diff --git a/src/ListHelper.java b/src/ListHelper.java
new file mode 100644
index 0000000..56d296c
--- /dev/null
+++ b/src/ListHelper.java
@@ -0,0 +1,102 @@
+import java.io.File;
+import java.io.FileWriter;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+
+public class ListHelper {
+ public static final String listFilePath = System.getenv("APPDATA") + "\\MAndWorks\\Imgur\\settings\\list.txt";
+
+ public static String[] getList() {
+
+ System.out.println(listFilePath);
+
+ ArrayList list = new ArrayList();
+
+ try {
+
+
+ File file = new File(listFilePath);
+
+ Scanner s = new Scanner(file);
+
+ while (s.hasNextLine()) {
+
+ String line = s.nextLine();
+
+ list.add(line);
+ }
+ s.close();
+ } catch (Exception e) {
+ //hopefully this never happens
+ JFrame frame = new JFrame("Error");
+ frame.add(new JLabel(e.getMessage()));
+ frame.pack();
+ frame.setVisible(true);
+ frame.setLocationRelativeTo(null);
+ }
+
+ System.out.print("Opened List:\n");
+ for(String listItem : list)
+ System.out.print(" - " + listItem + "\n");
+ System.out.print("\n");
+
+ return ArrayListHelper.toArray(list);
+ }
+
+ public static void save(String[] contents) {
+ File file = new File(listFilePath);
+ file.delete();
+ try{
+ file.createNewFile();
+ FileWriter f = new FileWriter(file);
+ String newLine = System.getProperty("line.separator");
+ for(int i = 0; i < contents.length; i ++) {
+ f.write(contents[i] + newLine);
+ }
+ f.close();
+ }catch(Exception e) {
+ JFrame frame = new JFrame("Error");
+ frame.add(new JLabel(e.getMessage()));
+ frame.pack();
+ frame.setVisible(true);
+ frame.setLocationRelativeTo(null);
+ }
+
+ testSave(contents);
+
+ }
+
+ /**
+ * this will test to make sure these contents are in the save.
+ * if they aren't, then resave and check
+ *
+ * indirect recursion.
+ * @param contents
+ * @return
+ */
+ private static void testSave(String[] contents) {
+ String[] savedContents = getList();
+
+ if(contents.length != savedContents.length) save(contents);
+ for(int i = 0; i < contents.length; i ++) {
+ if(!contents[i].equals(savedContents[i])) save(contents);
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private static String arrayToString(Object[] array) {
+ String _return = "{";
+
+ for(Object item : array) {
+ _return += item.toString() + ", ";
+ }
+
+ return _return.substring(0, _return.length() - 2) + "}";
+
+
+
+ }
+}
diff --git a/src/Main.java b/src/Main.java
new file mode 100644
index 0000000..4b7c0fb
--- /dev/null
+++ b/src/Main.java
@@ -0,0 +1,11 @@
+import MAndEngine.Engine;
+
+
+public class Main {
+ public static void main(String[] args) {
+
+ Engine engine = new Engine(new String[] {"ImgurDownloader"}, false);
+ engine.run();
+
+ }
+}