got rid of dependency injection, it doesn't add anything at this point and only slows down things and makes a mess. Also some refactoring.
This commit is contained in:
@@ -34,11 +34,10 @@ import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Image;
|
||||
import yugecin.opsudance.core.events.EventBus;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.events.BarNotificationEvent;
|
||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
||||
import yugecin.opsudance.options.Configuration;
|
||||
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
|
||||
/**
|
||||
@@ -46,9 +45,6 @@ import static yugecin.opsudance.options.Options.*;
|
||||
*/
|
||||
public class DownloadNode {
|
||||
|
||||
@Inject
|
||||
private Configuration config;
|
||||
|
||||
/** The associated Download object. */
|
||||
private Download download;
|
||||
|
||||
|
||||
@@ -35,26 +35,18 @@ import java.util.Properties;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
import org.newdawn.slick.util.Log;
|
||||
import org.newdawn.slick.util.ResourceLoader;
|
||||
import yugecin.opsudance.core.Constants;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||
import yugecin.opsudance.core.events.EventBus;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.events.BarNotificationEvent;
|
||||
import yugecin.opsudance.options.Configuration;
|
||||
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
/**
|
||||
* Handles automatic program updates.
|
||||
*/
|
||||
public class Updater {
|
||||
|
||||
@Inject
|
||||
private Configuration config;
|
||||
|
||||
private static Updater updater;
|
||||
|
||||
public static Updater get() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
/** The exit confirmation message. */
|
||||
public static final String EXIT_CONFIRMATION = "An opsu! update is being downloaded.\nAre you sure you want to quit opsu!?";
|
||||
|
||||
@@ -95,7 +87,7 @@ public class Updater {
|
||||
* Returns the status description.
|
||||
*/
|
||||
public String getDescription() { return description; }
|
||||
};
|
||||
}
|
||||
|
||||
/** The current updater status. */
|
||||
private Status status;
|
||||
@@ -119,10 +111,8 @@ public class Updater {
|
||||
return currentVersion.getMajorVersion() + "." + currentVersion.getMinorVersion() + "." + currentVersion.getIncrementalVersion();
|
||||
}
|
||||
|
||||
@Inject
|
||||
public Updater() {
|
||||
status = Status.INITIAL;
|
||||
updater = this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +135,7 @@ public class Updater {
|
||||
Date date = null;
|
||||
try {
|
||||
Properties props = new Properties();
|
||||
props.load(ResourceLoader.getResourceAsStream(config.VERSION_FILE));
|
||||
props.load(ResourceLoader.getResourceAsStream(Constants.VERSION_FILE));
|
||||
String build = props.getProperty("build.date");
|
||||
if (build == null || build.equals("${timestamp}") || build.equals("${maven.build.timestamp}"))
|
||||
date = new Date();
|
||||
@@ -214,16 +204,16 @@ public class Updater {
|
||||
|
||||
// get current version
|
||||
Properties props = new Properties();
|
||||
props.load(ResourceLoader.getResourceAsStream(config.VERSION_FILE));
|
||||
props.load(ResourceLoader.getResourceAsStream(Constants.VERSION_FILE));
|
||||
if ((currentVersion = getVersion(props)) == null)
|
||||
return;
|
||||
|
||||
// get latest version
|
||||
String s = null;
|
||||
try {
|
||||
s = Utils.readDataFromUrl(new URL(config.VERSION_REMOTE));
|
||||
s = Utils.readDataFromUrl(new URL(Constants.VERSION_REMOTE));
|
||||
} catch (UnknownHostException e) {
|
||||
Log.warn(String.format("Check for updates failed. Please check your internet connection, or your connection to %s.", config.VERSION_REMOTE));
|
||||
Log.warn(String.format("Check for updates failed. Please check your internet connection, or your connection to %s.", Constants.VERSION_REMOTE));
|
||||
}
|
||||
if (s == null) {
|
||||
status = Status.CONNECTION_ERROR;
|
||||
|
||||
@@ -34,17 +34,12 @@ import java.util.Date;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
|
||||
/**
|
||||
* Download server: http://bloodcat.com/osu/
|
||||
*/
|
||||
public class BloodcatServer extends DownloadServer {
|
||||
|
||||
@Inject
|
||||
public InstanceContainer instanceContainer;
|
||||
|
||||
/** Server name. */
|
||||
private static final String SERVER_NAME = "Bloodcat";
|
||||
|
||||
@@ -60,10 +55,6 @@ public class BloodcatServer extends DownloadServer {
|
||||
/** Total result count from the last query. */
|
||||
private int totalResults = -1;
|
||||
|
||||
@Inject
|
||||
public BloodcatServer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() { return SERVER_NAME; }
|
||||
|
||||
@@ -89,12 +80,12 @@ public class BloodcatServer extends DownloadServer {
|
||||
nodes = new DownloadNode[arr.length()];
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
JSONObject item = arr.getJSONObject(i);
|
||||
nodes[i] = instanceContainer.injectFields(new DownloadNode(
|
||||
nodes[i] = new DownloadNode(
|
||||
item.getInt("id"), formatDate(item.getString("synced")), //"date"
|
||||
item.getString("title"), item.isNull("titleU") ? null : item.getString("titleU"), //"titleUnicode"
|
||||
item.getString("artist"), item.isNull("artistU") ? null : item.getString("artistU"), //"artistUnicode"
|
||||
item.getString("creator")
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// store total result count
|
||||
|
||||
@@ -30,8 +30,6 @@ import java.net.URLEncoder;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
|
||||
/**
|
||||
* Download server: https://osu.hexide.com/
|
||||
@@ -40,9 +38,6 @@ import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
*/
|
||||
public class HexideServer extends DownloadServer {
|
||||
|
||||
@Inject
|
||||
private InstanceContainer instanceContainer;
|
||||
|
||||
/** Server name. */
|
||||
private static final String SERVER_NAME = "Hexide";
|
||||
|
||||
@@ -64,10 +59,6 @@ public class HexideServer extends DownloadServer {
|
||||
/** Total result count from the last query. */
|
||||
private int totalResults = -1;
|
||||
|
||||
@Inject
|
||||
public HexideServer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() { return SERVER_NAME; }
|
||||
|
||||
@@ -124,10 +115,10 @@ public class HexideServer extends DownloadServer {
|
||||
artist = creator = "?";
|
||||
}
|
||||
}
|
||||
nodes[i] = instanceContainer.injectFields(new DownloadNode(
|
||||
nodes[i] = new DownloadNode(
|
||||
item.getInt("ranked_id"), item.getString("date"),
|
||||
title, null, artist, null, creator
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// store total result count
|
||||
|
||||
@@ -30,17 +30,12 @@ import java.net.URLEncoder;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
|
||||
/**
|
||||
* Download server: http://osu.mengsky.net/
|
||||
*/
|
||||
public class MengSkyServer extends DownloadServer {
|
||||
|
||||
@Inject
|
||||
private InstanceContainer instanceContainer;
|
||||
|
||||
/** Server name. */
|
||||
private static final String SERVER_NAME = "MengSky";
|
||||
|
||||
@@ -56,10 +51,6 @@ public class MengSkyServer extends DownloadServer {
|
||||
/** Total result count from the last query. */
|
||||
private int totalResults = -1;
|
||||
|
||||
@Inject
|
||||
public MengSkyServer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() { return SERVER_NAME; }
|
||||
|
||||
@@ -93,10 +84,10 @@ public class MengSkyServer extends DownloadServer {
|
||||
// sometimes titleU is artistU instead of the proper title
|
||||
if (titleU.equals(artistU) && !titleU.equals(title))
|
||||
titleU = title;
|
||||
nodes[i] = instanceContainer.injectFields(new DownloadNode(
|
||||
nodes[i] = new DownloadNode(
|
||||
item.getInt("id"), item.getString("syncedDateTime"),
|
||||
title, titleU, artist, artistU, creator
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// store total result count
|
||||
|
||||
@@ -21,8 +21,6 @@ package itdelatrisu.opsu.downloads.servers;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.downloads.DownloadNode;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -39,9 +37,6 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class MnetworkServer extends DownloadServer {
|
||||
|
||||
@Inject
|
||||
private InstanceContainer instanceContainer;
|
||||
|
||||
/** Server name. */
|
||||
private static final String SERVER_NAME = "Mnetwork";
|
||||
|
||||
@@ -57,10 +52,6 @@ public class MnetworkServer extends DownloadServer {
|
||||
/** Beatmap pattern. */
|
||||
private Pattern BEATMAP_PATTERN = Pattern.compile("^(\\d+) ([^-]+) - (.+)\\.osz$");
|
||||
|
||||
@Inject
|
||||
public MnetworkServer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() { return SERVER_NAME; }
|
||||
|
||||
@@ -119,7 +110,7 @@ public class MnetworkServer extends DownloadServer {
|
||||
if (!m.matches())
|
||||
continue;
|
||||
|
||||
nodeList.add(instanceContainer.injectFields(new DownloadNode(Integer.parseInt(m.group(1)), date, m.group(3), null, m.group(2), null, "")));
|
||||
nodeList.add(new DownloadNode(Integer.parseInt(m.group(1)), date, m.group(3), null, m.group(2), null, ""));
|
||||
}
|
||||
|
||||
nodes = nodeList.toArray(new DownloadNode[nodeList.size()]);
|
||||
|
||||
@@ -36,8 +36,6 @@ import java.util.TimeZone;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
|
||||
/**
|
||||
* Download server: http://loli.al/
|
||||
@@ -46,9 +44,6 @@ import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
*/
|
||||
public class OsuMirrorServer extends DownloadServer {
|
||||
|
||||
@Inject
|
||||
private InstanceContainer instanceContainer;
|
||||
|
||||
/** Server name. */
|
||||
private static final String SERVER_NAME = "osu!Mirror";
|
||||
|
||||
@@ -73,10 +68,6 @@ public class OsuMirrorServer extends DownloadServer {
|
||||
/** Lookup table from beatmap set ID -> server download ID. */
|
||||
private HashMap<Integer, Integer> idTable = new HashMap<Integer, Integer>();
|
||||
|
||||
@Inject
|
||||
public OsuMirrorServer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() { return SERVER_NAME; }
|
||||
|
||||
@@ -113,12 +104,12 @@ public class OsuMirrorServer extends DownloadServer {
|
||||
JSONObject item = arr.getJSONObject(i);
|
||||
int beatmapSetID = item.getInt("OSUSetid");
|
||||
int serverID = item.getInt("id");
|
||||
nodes[i] = instanceContainer.injectFields(new DownloadNode(
|
||||
nodes[i] = new DownloadNode(
|
||||
beatmapSetID, formatDate(item.getString("ModifyDate")),
|
||||
item.getString("Title"), null,
|
||||
item.getString("Artist"), null,
|
||||
item.getString("Mapper")
|
||||
));
|
||||
);
|
||||
idTable.put(beatmapSetID, serverID);
|
||||
if (serverID > maxServerID)
|
||||
maxServerID = serverID;
|
||||
|
||||
@@ -34,17 +34,12 @@ import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
|
||||
/**
|
||||
* Download server: http://osu.yas-online.net/
|
||||
*/
|
||||
public class YaSOnlineServer extends DownloadServer {
|
||||
|
||||
@Inject
|
||||
public InstanceContainer instanceContainer;
|
||||
|
||||
/** Server name. */
|
||||
private static final String SERVER_NAME = "YaS Online";
|
||||
|
||||
@@ -72,10 +67,6 @@ public class YaSOnlineServer extends DownloadServer {
|
||||
/** Max server download ID seen (for approximating total pages). */
|
||||
private int maxServerID = 0;
|
||||
|
||||
@Inject
|
||||
public YaSOnlineServer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() { return SERVER_NAME; }
|
||||
|
||||
@@ -183,7 +174,7 @@ public class YaSOnlineServer extends DownloadServer {
|
||||
if (serverID > maxServerID)
|
||||
maxServerID = serverID;
|
||||
|
||||
nodeList.add(instanceContainer.injectFields(new DownloadNode(item.getInt("mapid"), date, title, null, artist, null, "")));
|
||||
nodeList.add(new DownloadNode(item.getInt("mapid"), date, title, null, artist, null, ""));
|
||||
}
|
||||
nodes = nodeList.toArray(new DownloadNode[nodeList.size()]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user