overhaul event system
This commit is contained in:
parent
b8dd507dc5
commit
1df25520e4
|
@ -30,8 +30,7 @@ import org.newdawn.slick.SlickException;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
import yugecin.opsudance.skinning.SkinService;
|
import yugecin.opsudance.skinning.SkinService;
|
||||||
import yugecin.opsudance.utils.SlickUtil;
|
import yugecin.opsudance.utils.SlickUtil;
|
||||||
|
|
||||||
|
@ -733,7 +732,7 @@ public enum GameImage {
|
||||||
|
|
||||||
String err = String.format("Could not find default image '%s'.", filename);
|
String err = String.format("Could not find default image '%s'.", filename);
|
||||||
Log.warn(err);
|
Log.warn(err);
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -776,7 +775,9 @@ public enum GameImage {
|
||||||
* @return an array of the loaded images, or null if not found
|
* @return an array of the loaded images, or null if not found
|
||||||
*/
|
*/
|
||||||
private Image[] loadImageArray(File dir) {
|
private Image[] loadImageArray(File dir) {
|
||||||
if (filenameFormat != null) {
|
if (filenameFormat == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
for (String suffix : getSuffixes()) {
|
for (String suffix : getSuffixes()) {
|
||||||
List<Image> list = new ArrayList<Image>();
|
List<Image> list = new ArrayList<Image>();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -794,14 +795,15 @@ public enum GameImage {
|
||||||
img = img.getScaledCopy(0.5f);
|
img = img.getScaledCopy(0.5f);
|
||||||
list.add(img);
|
list.add(img);
|
||||||
} catch (SlickException e) {
|
} catch (SlickException e) {
|
||||||
EventBus.post(new BubbleNotificationEvent(String.format("Failed to set image '%s'.", name), BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(
|
||||||
|
String.format("Failed to set image '%s'.", name),
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!list.isEmpty())
|
if (!list.isEmpty())
|
||||||
return list.toArray(new Image[list.size()]);
|
return list.toArray(new Image[list.size()]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,15 +815,18 @@ public enum GameImage {
|
||||||
private Image loadImageSingle(File dir) {
|
private Image loadImageSingle(File dir) {
|
||||||
for (String suffix : getSuffixes()) {
|
for (String suffix : getSuffixes()) {
|
||||||
String name = getImageFileName(filename + suffix, dir, type, true);
|
String name = getImageFileName(filename + suffix, dir, type, true);
|
||||||
if (name != null) {
|
if (name == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Image img = new Image(name);
|
Image img = new Image(name);
|
||||||
if (suffix.equals(HD_SUFFIX))
|
if (suffix.equals(HD_SUFFIX))
|
||||||
img = img.getScaledCopy(0.5f);
|
img = img.getScaledCopy(0.5f);
|
||||||
return img;
|
return img;
|
||||||
} catch (SlickException e) {
|
} catch (SlickException e) {
|
||||||
EventBus.post(new BubbleNotificationEvent(String.format("Failed to set image '%s'.", filename), BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(
|
||||||
}
|
String.format("Failed to set image '%s'.", filename),
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -47,6 +47,7 @@ import com.sun.jna.platform.FileUtils;
|
||||||
import yugecin.opsudance.core.NotNull;
|
import yugecin.opsudance.core.NotNull;
|
||||||
import yugecin.opsudance.core.Nullable;
|
import yugecin.opsudance.core.Nullable;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,8 @@ import org.newdawn.slick.util.Log;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
import org.tritonus.share.sampled.file.TAudioFileFormat;
|
import org.tritonus.share.sampled.file.TAudioFileFormat;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
|
|
||||||
|
@ -103,7 +102,8 @@ public class MusicController {
|
||||||
if (lastBeatmap == null || !beatmap.audioFilename.equals(lastBeatmap.audioFilename)) {
|
if (lastBeatmap == null || !beatmap.audioFilename.equals(lastBeatmap.audioFilename)) {
|
||||||
final File audioFile = beatmap.audioFilename;
|
final File audioFile = beatmap.audioFilename;
|
||||||
if (!audioFile.isFile() && !ResourceLoader.resourceExists(audioFile.getPath())) {
|
if (!audioFile.isFile() && !ResourceLoader.resourceExists(audioFile.getPath())) {
|
||||||
EventBus.post(new BarNotificationEvent(String.format("Could not find track '%s'.", audioFile.getName())));
|
BarNotifListener.EVENT.make().onBarNotif(String.format("Could not find track '%s'.",
|
||||||
|
audioFile.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ public class MusicController {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String err = String.format("Could not play track '%s'.", file.getName());
|
String err = String.format("Could not play track '%s'.", file.getName());
|
||||||
Log.error(err, e);
|
Log.error(err, e);
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,8 @@ import javax.sound.sampled.LineUnavailableException;
|
||||||
import org.newdawn.slick.SlickException;
|
import org.newdawn.slick.SlickException;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
import yugecin.opsudance.options.Configuration;
|
import yugecin.opsudance.options.Configuration;
|
||||||
import yugecin.opsudance.skinning.SkinService;
|
import yugecin.opsudance.skinning.SkinService;
|
||||||
|
|
||||||
|
@ -220,7 +219,9 @@ public class SoundController {
|
||||||
// menu and game sounds
|
// menu and game sounds
|
||||||
for (SoundEffect s : SoundEffect.values()) {
|
for (SoundEffect s : SoundEffect.values()) {
|
||||||
if ((currentFileName = getSoundFileName(s.getFileName())) == null) {
|
if ((currentFileName = getSoundFileName(s.getFileName())) == null) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Could not find sound file " + s.getFileName(), BubbleNotificationEvent.COLOR_ORANGE));
|
BubNotifListener.EVENT.make().onBubNotif(
|
||||||
|
"Could not find sound file " + s.getFileName(),
|
||||||
|
BubNotifListener.COLOR_ORANGE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
MultiClip newClip = loadClip(currentFileName, currentFileName.endsWith(".mp3"));
|
MultiClip newClip = loadClip(currentFileName, currentFileName.endsWith(".mp3"));
|
||||||
|
@ -239,7 +240,9 @@ public class SoundController {
|
||||||
for (HitSound s : HitSound.values()) {
|
for (HitSound s : HitSound.values()) {
|
||||||
String filename = String.format("%s-%s", ss.getName(), s.getFileName());
|
String filename = String.format("%s-%s", ss.getName(), s.getFileName());
|
||||||
if ((currentFileName = getSoundFileName(filename)) == null) {
|
if ((currentFileName = getSoundFileName(filename)) == null) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Could not find hit sound file " + filename, BubbleNotificationEvent.COLOR_ORANGE));
|
BubNotifListener.EVENT.make().onBubNotif(
|
||||||
|
"Could not find hit sound file " + filename,
|
||||||
|
BubNotifListener.COLOR_ORANGE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
MultiClip newClip = loadClip(currentFileName, false);
|
MultiClip newClip = loadClip(currentFileName, false);
|
||||||
|
@ -396,7 +399,8 @@ public class SoundController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error() {
|
public void error() {
|
||||||
EventBus.post(new BarNotificationEvent("Failed to download track preview."));
|
BarNotifListener.EVENT.make().onBarNotif(
|
||||||
|
"Failed to download track preview");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -33,9 +33,9 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
|
import yugecin.opsudance.core.Nullable;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
import yugecin.opsudance.skinning.SkinService;
|
import yugecin.opsudance.skinning.SkinService;
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
@ -93,8 +93,8 @@ public class BeatmapParser {
|
||||||
* @param dirs the array of directories to parse
|
* @param dirs the array of directories to parse
|
||||||
* @return the last BeatmapSetNode parsed, or null if none
|
* @return the last BeatmapSetNode parsed, or null if none
|
||||||
*/
|
*/
|
||||||
public BeatmapSetNode parseDirectories(File[] dirs) {
|
public BeatmapSetNode parseDirectories(@Nullable File[] dirs) {
|
||||||
if (dirs == null)
|
if (dirs == null || dirs.length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// progress tracking
|
// progress tracking
|
||||||
|
@ -159,8 +159,8 @@ public class BeatmapParser {
|
||||||
try {
|
try {
|
||||||
beatmap = parseFile(file, dir, beatmaps, false);
|
beatmap = parseFile(file, dir, beatmaps, false);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
Log.error("could not parse beatmap " + file.getName() + ": " + e.getMessage());
|
logAndShowErrorNotification(e, "Could not parse beatmap %s: %s",
|
||||||
EventBus.post(new BubbleNotificationEvent("Could not parse beatmap " + file.getName(), BubbleNotificationEvent.COLOR_ORANGE));
|
file.getName(), e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to parsed beatmap list
|
// add to parsed beatmap list
|
||||||
|
@ -247,9 +247,7 @@ public class BeatmapParser {
|
||||||
}
|
}
|
||||||
map.timingPoints.trimToSize();
|
map.timingPoints.trimToSize();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String err = String.format("Failed to read file '%s'.", map.getFile().getAbsolutePath());
|
logAndShowErrorNotification(e, "Failed to read file '%s'.", map.getFile().getAbsolutePath());
|
||||||
Log.error(err, e);
|
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
|
ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
|
||||||
|
|
||||||
|
@ -652,9 +650,7 @@ public class BeatmapParser {
|
||||||
if (md5stream != null)
|
if (md5stream != null)
|
||||||
beatmap.md5Hash = md5stream.getMD5();
|
beatmap.md5Hash = md5stream.getMD5();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String err = String.format("Failed to read file '%s'.", file.getAbsolutePath());
|
logAndShowErrorNotification(e, "Failed to read file '%s'.", file.getAbsolutePath());
|
||||||
Log.error(err, e);
|
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
|
ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
|
||||||
|
|
||||||
|
@ -735,9 +731,8 @@ public class BeatmapParser {
|
||||||
}
|
}
|
||||||
beatmap.timingPoints.trimToSize();
|
beatmap.timingPoints.trimToSize();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String err = String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath());
|
logAndShowErrorNotification(e, "Failed to read file '%s'.",
|
||||||
Log.error(err, e);
|
beatmap.getFile().getAbsolutePath());
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -818,9 +813,8 @@ public class BeatmapParser {
|
||||||
ErrorHandler.error(String.format("Parsed %d objects for beatmap '%s', %d objects expected.",
|
ErrorHandler.error(String.format("Parsed %d objects for beatmap '%s', %d objects expected.",
|
||||||
objectIndex, beatmap.toString(), beatmap.objects.length), new Exception("no")).show();
|
objectIndex, beatmap.toString(), beatmap.objects.length), new Exception("no")).show();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String err = String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath());
|
logAndShowErrorNotification(e, "Failed to read file '%s'.",
|
||||||
Log.error(err, e);
|
beatmap.getFile().getAbsolutePath());
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -891,4 +885,10 @@ public class BeatmapParser {
|
||||||
return DBString;
|
return DBString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void logAndShowErrorNotification(Exception e, String message, Object... formatArgs) {
|
||||||
|
message = String.format(message, formatArgs);
|
||||||
|
Log.error(message, e);
|
||||||
|
BubNotifListener.EVENT.make().onBubNotif(message, BubNotifListener.COMMONCOLOR_RED);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,8 +21,7 @@ package itdelatrisu.opsu.beatmap;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import itdelatrisu.opsu.audio.MusicController;
|
import itdelatrisu.opsu.audio.MusicController;
|
||||||
import itdelatrisu.opsu.db.BeatmapDB;
|
import itdelatrisu.opsu.db.BeatmapDB;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -215,7 +214,8 @@ public class BeatmapSetList {
|
||||||
try {
|
try {
|
||||||
Utils.deleteToTrash(dir);
|
Utils.deleteToTrash(dir);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Could not delete song group", BubbleNotificationEvent.COLOR_ORANGE));
|
BubNotifListener.EVENT.make().onBubNotif("Could not delete song group",
|
||||||
|
BubNotifListener.COLOR_ORANGE);
|
||||||
}
|
}
|
||||||
if (ws != null)
|
if (ws != null)
|
||||||
ws.resume();
|
ws.resume();
|
||||||
|
@ -271,7 +271,7 @@ public class BeatmapSetList {
|
||||||
try {
|
try {
|
||||||
Utils.deleteToTrash(file);
|
Utils.deleteToTrash(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Could not delete song", BubbleNotificationEvent.COLOR_ORANGE));
|
BubNotifListener.EVENT.make().onBubNotif("Could not delete song", BubNotifListener.COLOR_ORANGE);
|
||||||
}
|
}
|
||||||
if (ws != null)
|
if (ws != null)
|
||||||
ws.resume();
|
ws.resume();
|
||||||
|
|
|
@ -39,8 +39,8 @@ import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
|
@ -100,7 +100,8 @@ public class BeatmapWatchService {
|
||||||
ws.register(config.beatmapDir.toPath());
|
ws.register(config.beatmapDir.toPath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.error("Could not create watch service", e);
|
Log.error("Could not create watch service", e);
|
||||||
EventBus.post(new BubbleNotificationEvent("Could not create watch service", BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif("Could not create watch service",
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +122,9 @@ public class BeatmapWatchService {
|
||||||
ws.service.shutdownNow();
|
ws.service.shutdownNow();
|
||||||
ws = null;
|
ws = null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.error("An I/O exception occurred while closing the previous watch service.", e);
|
String msg = "An I/O exception occurred while closing the previous watch service.";
|
||||||
EventBus.post(new BubbleNotificationEvent("An I/O exception occurred while closing the previous watch service.", BubbleNotificationEvent.COMMONCOLOR_RED));
|
Log.error(msg, e);
|
||||||
|
BarNotifListener.EVENT.make().onBarNotif(msg);
|
||||||
ws = null;
|
ws = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +139,10 @@ public class BeatmapWatchService {
|
||||||
return ws;
|
return ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Watch service listener interface. */
|
/**
|
||||||
|
* Watch service listener interface.
|
||||||
|
* TODO: replace by event system?
|
||||||
|
*/
|
||||||
public interface BeatmapWatchServiceListener {
|
public interface BeatmapWatchServiceListener {
|
||||||
/**
|
/**
|
||||||
* Indication that an event was received.
|
* Indication that an event was received.
|
||||||
|
|
|
@ -26,8 +26,7 @@ import java.util.List;
|
||||||
import net.lingala.zip4j.core.ZipFile;
|
import net.lingala.zip4j.core.ZipFile;
|
||||||
import net.lingala.zip4j.exception.ZipException;
|
import net.lingala.zip4j.exception.ZipException;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ public class OszUnpacker {
|
||||||
} catch (ZipException e) {
|
} catch (ZipException e) {
|
||||||
String err = String.format("Failed to unzip file %s to dest %s.", file.getAbsolutePath(), dest.getAbsolutePath());
|
String err = String.format("Failed to unzip file %s to dest %s.", file.getAbsolutePath(), dest.getAbsolutePath());
|
||||||
Log.error(err, e);
|
Log.error(err, e);
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File download.
|
* File download.
|
||||||
|
@ -219,7 +218,7 @@ public class Download {
|
||||||
else if (redirectCount > MAX_REDIRECTS)
|
else if (redirectCount > MAX_REDIRECTS)
|
||||||
error = String.format("Download for URL '%s' is attempting too many redirects (over %d).", base.toString(), MAX_REDIRECTS);
|
error = String.format("Download for URL '%s' is attempting too many redirects (over %d).", base.toString(), MAX_REDIRECTS);
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
EventBus.post(new BubbleNotificationEvent(error, BubbleNotificationEvent.COLOR_ORANGE));
|
BubNotifListener.EVENT.make().onBubNotif(error, BubNotifListener.COLOR_ORANGE);
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,8 @@ import java.io.File;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
|
@ -281,12 +280,14 @@ public class DownloadNode {
|
||||||
download.setListener(new DownloadListener() {
|
download.setListener(new DownloadListener() {
|
||||||
@Override
|
@Override
|
||||||
public void completed() {
|
public void completed() {
|
||||||
EventBus.post(new BarNotificationEvent(String.format("Download complete: %s", getTitle())));
|
BarNotifListener.EVENT.make().onBarNotif(
|
||||||
|
String.format("Download complete: %s", getTitle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error() {
|
public void error() {
|
||||||
EventBus.post(new BarNotificationEvent("Download failed due to a connection error."));
|
BarNotifListener.EVENT.make().onBarNotif(
|
||||||
|
"Download failed due to a connection error.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.download = download;
|
this.download = download;
|
||||||
|
@ -408,7 +409,9 @@ public class DownloadNode {
|
||||||
public void drawDownload(Graphics g, float position, int id, boolean hover) {
|
public void drawDownload(Graphics g, float position, int id, boolean hover) {
|
||||||
Download download = this.download; // in case clearDownload() is called asynchronously
|
Download download = this.download; // in case clearDownload() is called asynchronously
|
||||||
if (download == null) {
|
if (download == null) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Trying to draw download information for button without Download object", BubbleNotificationEvent.COLOR_ORANGE));
|
BubNotifListener.EVENT.make().onBubNotif(
|
||||||
|
"Trying to draw download information for button without Download object",
|
||||||
|
BubNotifListener.COLOR_ORANGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,7 @@ import org.newdawn.slick.util.Log;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
import yugecin.opsudance.core.Constants;
|
import yugecin.opsudance.core.Constants;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
|
@ -242,13 +241,14 @@ public class Updater {
|
||||||
@Override
|
@Override
|
||||||
public void completed() {
|
public void completed() {
|
||||||
status = Status.UPDATE_DOWNLOADED;
|
status = Status.UPDATE_DOWNLOADED;
|
||||||
EventBus.post(new BarNotificationEvent("Update has finished downloading"));
|
BarNotifListener.EVENT.make().onBarNotif("Update has finished downloading");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error() {
|
public void error() {
|
||||||
status = Status.CONNECTION_ERROR;
|
status = Status.CONNECTION_ERROR;
|
||||||
EventBus.post(new BarNotificationEvent("Update failed due to a connection error."));
|
BarNotifListener.EVENT.make().onBarNotif(
|
||||||
|
"Update failed due to a connection error.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,7 @@ import org.newdawn.slick.util.Log;
|
||||||
|
|
||||||
import lzma.streams.LzmaOutputStream;
|
import lzma.streams.LzmaOutputStream;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
|
@ -275,7 +274,7 @@ public class Replay {
|
||||||
public void save() {
|
public void save() {
|
||||||
// create replay directory
|
// create replay directory
|
||||||
if (!config.replayDir.isDirectory() && !config.replayDir.mkdir()) {
|
if (!config.replayDir.isDirectory() && !config.replayDir.mkdir()) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Failed to create replay directory.", BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif("Failed to create replay directory", BubNotifListener.COMMONCOLOR_RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
|
@ -69,7 +68,7 @@ public class ReplayImporter {
|
||||||
if (!config.replayDir.isDirectory() && !config.replayDir.mkdir()) {
|
if (!config.replayDir.isDirectory() && !config.replayDir.mkdir()) {
|
||||||
String err = String.format("Failed to create replay directory '%s'.", config.replayDir.getAbsolutePath());
|
String err = String.format("Failed to create replay directory '%s'.", config.replayDir.getAbsolutePath());
|
||||||
Log.error(err);
|
Log.error(err);
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +82,8 @@ public class ReplayImporter {
|
||||||
moveToFailedDirectory(file);
|
moveToFailedDirectory(file);
|
||||||
String err = String.format("Failed to import replay '%s'. The replay file could not be parsed.", file.getName());
|
String err = String.format("Failed to import replay '%s'. The replay file could not be parsed.", file.getName());
|
||||||
Log.error(err, e);
|
Log.error(err, e);
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(err,
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Beatmap beatmap = BeatmapSetList.get().getBeatmapFromHash(r.beatmapHash);
|
Beatmap beatmap = BeatmapSetList.get().getBeatmapFromHash(r.beatmapHash);
|
||||||
|
@ -102,7 +102,7 @@ public class ReplayImporter {
|
||||||
moveToFailedDirectory(file);
|
moveToFailedDirectory(file);
|
||||||
String err = String.format("Failed to import replay '%s'. The associated beatmap could not be found.", file.getName());
|
String err = String.format("Failed to import replay '%s'. The associated beatmap could not be found.", file.getName());
|
||||||
Log.error(err);
|
Log.error(err);
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,7 @@ import java.util.LinkedList;
|
||||||
|
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads skin configuration files.
|
* Loads skin configuration files.
|
||||||
|
@ -293,7 +292,8 @@ public class SkinLoader {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String err = String.format("Failed to read file '%s'.", skinFile.getAbsolutePath());
|
String err = String.format("Failed to read file '%s'.", skinFile.getAbsolutePath());
|
||||||
Log.error(err, e);
|
Log.error(err, e);
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(err,
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return skin;
|
return skin;
|
||||||
|
|
|
@ -52,9 +52,8 @@ import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.SlickException;
|
import org.newdawn.slick.SlickException;
|
||||||
import org.newdawn.slick.gui.TextField;
|
import org.newdawn.slick.gui.TextField;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
|
||||||
import yugecin.opsudance.core.state.ComplexOpsuState;
|
import yugecin.opsudance.core.state.ComplexOpsuState;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
|
@ -266,16 +265,20 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||||
private void importBeatmaps() {
|
private void importBeatmaps() {
|
||||||
// invoke unpacker and parser
|
// invoke unpacker and parser
|
||||||
File[] dirs = oszunpacker.unpackAll();
|
File[] dirs = oszunpacker.unpackAll();
|
||||||
if (dirs != null && dirs.length > 0) {
|
|
||||||
this.importedNode = beatmapParser.parseDirectories(dirs);
|
this.importedNode = beatmapParser.parseDirectories(dirs);
|
||||||
if (importedNode != null) {
|
|
||||||
// send notification
|
|
||||||
EventBus.post(new BarNotificationEvent((dirs.length == 1) ? "Imported 1 new song." :
|
|
||||||
String.format("Imported %d new songs.", dirs.length)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadList.get().clearDownloads(Download.Status.COMPLETE);
|
DownloadList.get().clearDownloads(Download.Status.COMPLETE);
|
||||||
|
|
||||||
|
if (this.importedNode == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String msg;
|
||||||
|
if (dirs.length == 1) {
|
||||||
|
msg = "Imported 1 new song.";
|
||||||
|
} else {
|
||||||
|
msg = String.format("Imported %d new songs.", dirs.length);
|
||||||
|
}
|
||||||
|
BarNotifListener.EVENT.make().onBarNotif(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,7 +685,7 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||||
if (playing)
|
if (playing)
|
||||||
previewID = node.getID();
|
previewID = node.getID();
|
||||||
} catch (SlickException e) {
|
} catch (SlickException e) {
|
||||||
EventBus.post(new BarNotificationEvent("Failed to load track preview. See log for details."));
|
BarNotifListener.EVENT.make().onBarNotif("Failed to load track preview. See log for details.");
|
||||||
Log.error(e);
|
Log.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,7 +708,7 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||||
if (!DownloadList.get().contains(node.getID())) {
|
if (!DownloadList.get().contains(node.getID())) {
|
||||||
node.createDownload(serverMenu.getSelectedItem());
|
node.createDownload(serverMenu.getSelectedItem());
|
||||||
if (node.getDownload() == null) {
|
if (node.getDownload() == null) {
|
||||||
EventBus.post(new BarNotificationEvent("The download could not be started"));
|
BarNotifListener.EVENT.make().onBarNotif("The download could not be started");
|
||||||
} else {
|
} else {
|
||||||
DownloadList.get().addNode(node);
|
DownloadList.get().addNode(node);
|
||||||
node.getDownload().start();
|
node.getDownload().start();
|
||||||
|
@ -947,7 +950,7 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||||
pageDir = Page.RESET;
|
pageDir = Page.RESET;
|
||||||
previewID = -1;
|
previewID = -1;
|
||||||
if (barNotificationOnLoad != null) {
|
if (barNotificationOnLoad != null) {
|
||||||
EventBus.post(new BarNotificationEvent(barNotificationOnLoad));
|
BarNotifListener.EVENT.make().onBarNotif(barNotificationOnLoad);
|
||||||
barNotificationOnLoad = null;
|
barNotificationOnLoad = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import itdelatrisu.opsu.audio.MusicController;
|
||||||
import itdelatrisu.opsu.audio.SoundController;
|
import itdelatrisu.opsu.audio.SoundController;
|
||||||
import itdelatrisu.opsu.audio.SoundEffect;
|
import itdelatrisu.opsu.audio.SoundEffect;
|
||||||
import itdelatrisu.opsu.beatmap.Beatmap;
|
import itdelatrisu.opsu.beatmap.Beatmap;
|
||||||
import itdelatrisu.opsu.beatmap.BeatmapParser;
|
|
||||||
import itdelatrisu.opsu.beatmap.HitObject;
|
import itdelatrisu.opsu.beatmap.HitObject;
|
||||||
import itdelatrisu.opsu.beatmap.TimingPoint;
|
import itdelatrisu.opsu.beatmap.TimingPoint;
|
||||||
import itdelatrisu.opsu.db.BeatmapDB;
|
import itdelatrisu.opsu.db.BeatmapDB;
|
||||||
|
@ -57,13 +56,11 @@ import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.SlickException;
|
import org.newdawn.slick.SlickException;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.*;
|
import yugecin.opsudance.*;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
|
||||||
import yugecin.opsudance.core.state.ComplexOpsuState;
|
import yugecin.opsudance.core.state.ComplexOpsuState;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.objects.curves.FakeCombinedCurve;
|
import yugecin.opsudance.objects.curves.FakeCombinedCurve;
|
||||||
import yugecin.opsudance.options.OptionGroups;
|
import yugecin.opsudance.options.OptionGroups;
|
||||||
import yugecin.opsudance.options.Options;
|
|
||||||
import yugecin.opsudance.sbv2.MoveStoryboard;
|
import yugecin.opsudance.sbv2.MoveStoryboard;
|
||||||
import yugecin.opsudance.skinning.SkinService;
|
import yugecin.opsudance.skinning.SkinService;
|
||||||
import yugecin.opsudance.ui.OptionsOverlay;
|
import yugecin.opsudance.ui.OptionsOverlay;
|
||||||
|
@ -337,7 +334,9 @@ public class Game extends ComplexOpsuState {
|
||||||
gOffscreen.setBackground(Color.black);
|
gOffscreen.setBackground(Color.black);
|
||||||
} catch (SlickException e) {
|
} catch (SlickException e) {
|
||||||
Log.error("could not create offscreen graphics", e);
|
Log.error("could not create offscreen graphics", e);
|
||||||
EventBus.post(new BubbleNotificationEvent("Exception while creating offscreen graphics. See logfile for details.", BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(
|
||||||
|
"Exception while creating offscreen graphics. See logfile for details.",
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize music position bar location
|
// initialize music position bar location
|
||||||
|
@ -1172,7 +1171,7 @@ public class Game extends ComplexOpsuState {
|
||||||
if (0 <= time && time < 3600) {
|
if (0 <= time && time < 3600) {
|
||||||
OPTION_CHECKPOINT.setValue(time);
|
OPTION_CHECKPOINT.setValue(time);
|
||||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||||
EventBus.post(new BarNotificationEvent("Checkpoint saved."));
|
BarNotifListener.EVENT.make().onBarNotif("Checkpoint saved.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1184,7 +1183,7 @@ public class Game extends ComplexOpsuState {
|
||||||
break; // invalid checkpoint
|
break; // invalid checkpoint
|
||||||
loadCheckpoint(checkpoint);
|
loadCheckpoint(checkpoint);
|
||||||
SoundController.playSound(SoundEffect.MENUHIT);
|
SoundController.playSound(SoundEffect.MENUHIT);
|
||||||
EventBus.post(new BarNotificationEvent("Checkpoint loaded."));
|
BarNotifListener.EVENT.make().onBarNotif("Checkpoint loaded.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Input.KEY_F:
|
case Input.KEY_F:
|
||||||
|
@ -1227,12 +1226,12 @@ public class Game extends ComplexOpsuState {
|
||||||
break;
|
break;
|
||||||
case Input.KEY_MINUS:
|
case Input.KEY_MINUS:
|
||||||
currentMapMusicOffset += 5;
|
currentMapMusicOffset += 5;
|
||||||
EventBus.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
|
BarNotifListener.EVENT.make().onBarNotif("Current map offset: " + currentMapMusicOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (key == Input.KEY_ADD || c == '+') {
|
if (key == Input.KEY_ADD || c == '+') {
|
||||||
currentMapMusicOffset -= 5;
|
currentMapMusicOffset -= 5;
|
||||||
EventBus.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
|
BarNotifListener.EVENT.make().onBarNotif("Current map offset: " + currentMapMusicOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1454,7 +1453,8 @@ public class Game extends ComplexOpsuState {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (beatmap == null || beatmap.objects == null) {
|
if (beatmap == null || beatmap.objects == null) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Game was running without a beatmap", BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif("Game was running without a beatmap",
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
displayContainer.switchStateInstantly(songMenuState);
|
displayContainer.switchStateInstantly(songMenuState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1561,7 +1561,8 @@ public class Game extends ComplexOpsuState {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
|
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
|
||||||
Log.error(message, e);
|
Log.error(message, e);
|
||||||
EventBus.post(new BubbleNotificationEvent(message, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(message,
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
gameObjects[i] = new DummyObject(hitObject);
|
gameObjects[i] = new DummyObject(hitObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2147,7 +2148,8 @@ public class Game extends ComplexOpsuState {
|
||||||
this.replay = null;
|
this.replay = null;
|
||||||
} else {
|
} else {
|
||||||
if (replay.frames == null) {
|
if (replay.frames == null) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Attempting to set a replay with no frames.", BubbleNotificationEvent.COLOR_ORANGE));
|
BubNotifListener.EVENT.make().onBubNotif("Attempting to set a replay with no frames.",
|
||||||
|
BubNotifListener.COLOR_ORANGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isReplay = true;
|
this.isReplay = true;
|
||||||
|
|
|
@ -36,9 +36,8 @@ import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
import org.newdawn.slick.Input;
|
import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
|
||||||
import yugecin.opsudance.core.state.BaseOpsuState;
|
import yugecin.opsudance.core.state.BaseOpsuState;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
|
@ -157,13 +156,14 @@ public class GameRanking extends BaseOpsuState {
|
||||||
gameState.setRestart((data.isGameplay()) ? Game.Restart.REPLAY : Game.Restart.NEW);
|
gameState.setRestart((data.isGameplay()) ? Game.Restart.REPLAY : Game.Restart.NEW);
|
||||||
returnToGame = true;
|
returnToGame = true;
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
EventBus.post(new BarNotificationEvent("Replay file not found."));
|
BarNotifListener.EVENT.make().onBarNotif("Replay file not found.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.error("Failed to load replay data.", e);
|
Log.error("Failed to load replay data.", e);
|
||||||
EventBus.post(new BarNotificationEvent("Failed to load replay data. See log for details."));
|
BarNotifListener.EVENT.make().onBarNotif(
|
||||||
|
"Failed to load replay data. See log for details.");
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
EventBus.post(new BarNotificationEvent("Replay file not found."));
|
BarNotifListener.EVENT.make().onBarNotif("Replay file not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// retry
|
// retry
|
||||||
|
|
|
@ -46,11 +46,10 @@ import org.newdawn.slick.Image;
|
||||||
import org.newdawn.slick.Input;
|
import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.Constants;
|
import yugecin.opsudance.core.Constants;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
|
||||||
import yugecin.opsudance.core.state.BaseOpsuState;
|
import yugecin.opsudance.core.state.BaseOpsuState;
|
||||||
import yugecin.opsudance.core.state.OpsuState;
|
import yugecin.opsudance.core.state.OpsuState;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
|
@ -466,12 +465,11 @@ public class MainMenu extends BaseOpsuState {
|
||||||
UI.enter();
|
UI.enter();
|
||||||
if (!enterNotification) {
|
if (!enterNotification) {
|
||||||
if (updater.getStatus() == Updater.Status.UPDATE_AVAILABLE) {
|
if (updater.getStatus() == Updater.Status.UPDATE_AVAILABLE) {
|
||||||
EventBus.post(new BarNotificationEvent("An opsu! update is available."));
|
BarNotifListener.EVENT.make().onBarNotif("An opsu! update is available.");
|
||||||
enterNotification = true;
|
|
||||||
} else if (updater.justUpdated()) {
|
} else if (updater.justUpdated()) {
|
||||||
EventBus.post(new BarNotificationEvent("opsu! is now up to date!"));
|
BarNotifListener.EVENT.make().onBarNotif("opsu! is now up to date!");
|
||||||
enterNotification = true;
|
|
||||||
}
|
}
|
||||||
|
enterNotification = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset measure info
|
// reset measure info
|
||||||
|
@ -532,15 +530,15 @@ public class MainMenu extends BaseOpsuState {
|
||||||
if (musicPlay.contains(x, y)) {
|
if (musicPlay.contains(x, y)) {
|
||||||
if (MusicController.isPlaying()) {
|
if (MusicController.isPlaying()) {
|
||||||
MusicController.pause();
|
MusicController.pause();
|
||||||
EventBus.post(new BarNotificationEvent("Pause"));
|
BarNotifListener.EVENT.make().onBarNotif("Pause");
|
||||||
} else if (!MusicController.isTrackLoading()) {
|
} else if (!MusicController.isTrackLoading()) {
|
||||||
MusicController.resume();
|
MusicController.resume();
|
||||||
EventBus.post(new BarNotificationEvent("Play"));
|
BarNotifListener.EVENT.make().onBarNotif("Play");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (musicNext.contains(x, y)) {
|
} else if (musicNext.contains(x, y)) {
|
||||||
nextTrack(true);
|
nextTrack(true);
|
||||||
EventBus.post(new BarNotificationEvent(">> Next"));
|
BarNotifListener.EVENT.make().onBarNotif(">> Next");
|
||||||
return true;
|
return true;
|
||||||
} else if (musicPrevious.contains(x, y)) {
|
} else if (musicPrevious.contains(x, y)) {
|
||||||
lastMeasureProgress = 0f;
|
lastMeasureProgress = 0f;
|
||||||
|
@ -552,7 +550,7 @@ public class MainMenu extends BaseOpsuState {
|
||||||
} else {
|
} else {
|
||||||
MusicController.setPosition(0);
|
MusicController.setPosition(0);
|
||||||
}
|
}
|
||||||
EventBus.post(new BarNotificationEvent("<< Previous"));
|
BarNotifListener.EVENT.make().onBarNotif("<< Previous");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,10 +566,12 @@ public class MainMenu extends BaseOpsuState {
|
||||||
try {
|
try {
|
||||||
Desktop.getDesktop().browse(Constants.REPOSITORY_URI);
|
Desktop.getDesktop().browse(Constants.REPOSITORY_URI);
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
EventBus.post(new BarNotificationEvent("The repository web page could not be opened."));
|
BarNotifListener.EVENT.make().onBarNotif(
|
||||||
|
"The repository web page could not be opened.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.error("could not browse to repo", e);
|
Log.error("could not browse to repo", e);
|
||||||
EventBus.post(new BubbleNotificationEvent("Could not browse to repo", BubbleNotificationEvent.COLOR_ORANGE));
|
BubNotifListener.EVENT.make().onBubNotif("Could not browse to repo",
|
||||||
|
BubNotifListener.COLOR_ORANGE);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -580,10 +580,12 @@ public class MainMenu extends BaseOpsuState {
|
||||||
try {
|
try {
|
||||||
Desktop.getDesktop().browse(Constants.DANCE_REPOSITORY_URI);
|
Desktop.getDesktop().browse(Constants.DANCE_REPOSITORY_URI);
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
EventBus.post(new BarNotificationEvent("The repository web page could not be opened."));
|
BarNotifListener.EVENT.make().onBarNotif(
|
||||||
|
"The repository web page could not be opened.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.error("could not browse to repo", e);
|
Log.error("could not browse to repo", e);
|
||||||
EventBus.post(new BubbleNotificationEvent("Could not browse to repo", BubbleNotificationEvent.COLOR_ORANGE));
|
BubNotifListener.EVENT.make().onBubNotif("Could not browse to repo",
|
||||||
|
BubNotifListener.COLOR_ORANGE);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ import itdelatrisu.opsu.beatmap.BeatmapSortOrder;
|
||||||
import itdelatrisu.opsu.beatmap.BeatmapWatchService;
|
import itdelatrisu.opsu.beatmap.BeatmapWatchService;
|
||||||
import itdelatrisu.opsu.beatmap.BeatmapWatchService.BeatmapWatchServiceListener;
|
import itdelatrisu.opsu.beatmap.BeatmapWatchService.BeatmapWatchServiceListener;
|
||||||
import itdelatrisu.opsu.beatmap.LRUCache;
|
import itdelatrisu.opsu.beatmap.LRUCache;
|
||||||
import itdelatrisu.opsu.beatmap.OszUnpacker;
|
|
||||||
import itdelatrisu.opsu.db.BeatmapDB;
|
import itdelatrisu.opsu.db.BeatmapDB;
|
||||||
import itdelatrisu.opsu.db.ScoreDB;
|
import itdelatrisu.opsu.db.ScoreDB;
|
||||||
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
||||||
|
@ -63,9 +62,8 @@ import org.newdawn.slick.Image;
|
||||||
import org.newdawn.slick.Input;
|
import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.SpriteSheet;
|
import org.newdawn.slick.SpriteSheet;
|
||||||
import org.newdawn.slick.gui.TextField;
|
import org.newdawn.slick.gui.TextField;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
|
||||||
import yugecin.opsudance.core.state.ComplexOpsuState;
|
import yugecin.opsudance.core.state.ComplexOpsuState;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.options.OptionGroups;
|
import yugecin.opsudance.options.OptionGroups;
|
||||||
import yugecin.opsudance.ui.OptionsOverlay;
|
import yugecin.opsudance.ui.OptionsOverlay;
|
||||||
|
|
||||||
|
@ -439,12 +437,15 @@ public class SongMenu extends ComplexOpsuState {
|
||||||
BeatmapWatchService.addListener(new BeatmapWatchServiceListener() {
|
BeatmapWatchService.addListener(new BeatmapWatchServiceListener() {
|
||||||
@Override
|
@Override
|
||||||
public void eventReceived(Kind<?> kind, Path child) {
|
public void eventReceived(Kind<?> kind, Path child) {
|
||||||
if (!songFolderChanged && kind != StandardWatchEventKinds.ENTRY_MODIFY) {
|
if (songFolderChanged || kind == StandardWatchEventKinds.ENTRY_MODIFY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
songFolderChanged = true;
|
songFolderChanged = true;
|
||||||
if (displayContainer.isInState(SongMenu.class)) {
|
if (!displayContainer.isInState(SongMenu.class)) {
|
||||||
EventBus.post(new BarNotificationEvent("Changed is Songs folder detected. Hit F5 to refresh."));
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
BarNotifListener.EVENT.make().onBarNotif(
|
||||||
|
"Changed is Songs folder detected. Hit F5 to refresh.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -929,8 +930,12 @@ public class SongMenu extends ComplexOpsuState {
|
||||||
|
|
||||||
// group tabs
|
// group tabs
|
||||||
for (BeatmapGroup group : BeatmapGroup.values()) {
|
for (BeatmapGroup group : BeatmapGroup.values()) {
|
||||||
if (group.contains(x, y)) {
|
if (!group.contains(x, y)) {
|
||||||
if (group != BeatmapGroup.current()) {
|
continue;
|
||||||
|
}
|
||||||
|
if (group == BeatmapGroup.current()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
BeatmapGroup.set(group);
|
BeatmapGroup.set(group);
|
||||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||||
startNode = focusNode = null;
|
startNode = focusNode = null;
|
||||||
|
@ -948,12 +953,10 @@ public class SongMenu extends ComplexOpsuState {
|
||||||
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
||||||
|
|
||||||
if (BeatmapSetList.get().size() < 1 && group.getEmptyMessage() != null) {
|
if (BeatmapSetList.get().size() < 1 && group.getEmptyMessage() != null) {
|
||||||
EventBus.post(new BarNotificationEvent(group.getEmptyMessage()));
|
BarNotifListener.EVENT.make().onBarNotif(group.getEmptyMessage());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (focusNode == null) {
|
if (focusNode == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1760,7 +1763,7 @@ public class SongMenu extends ComplexOpsuState {
|
||||||
|
|
||||||
Beatmap beatmap = MusicController.getBeatmap();
|
Beatmap beatmap = MusicController.getBeatmap();
|
||||||
if (focusNode == null || beatmap != focusNode.getSelectedBeatmap()) {
|
if (focusNode == null || beatmap != focusNode.getSelectedBeatmap()) {
|
||||||
EventBus.post(new BarNotificationEvent("Unable to load the beatmap audio."));
|
BarNotifListener.EVENT.make().onBarNotif("Unable to load the beatmap audio.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,15 +39,14 @@ import org.newdawn.slick.opengl.InternalTextureLoader;
|
||||||
import org.newdawn.slick.opengl.renderer.Renderer;
|
import org.newdawn.slick.opengl.renderer.Renderer;
|
||||||
import org.newdawn.slick.opengl.renderer.SGL;
|
import org.newdawn.slick.opengl.renderer.SGL;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorDumpable;
|
import yugecin.opsudance.core.errorhandling.ErrorDumpable;
|
||||||
import yugecin.opsudance.core.events.EventListener;
|
|
||||||
import yugecin.opsudance.core.state.OpsuState;
|
import yugecin.opsudance.core.state.OpsuState;
|
||||||
import yugecin.opsudance.core.state.specialstates.BarNotificationState;
|
import yugecin.opsudance.core.state.specialstates.BarNotificationState;
|
||||||
import yugecin.opsudance.core.state.specialstates.BubbleNotificationState;
|
import yugecin.opsudance.core.state.specialstates.BubNotifState;
|
||||||
import yugecin.opsudance.core.state.specialstates.FpsRenderState;
|
import yugecin.opsudance.core.state.specialstates.FpsRenderState;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
|
import yugecin.opsudance.events.ResolutionChangedListener;
|
||||||
|
import yugecin.opsudance.events.SkinChangedListener;
|
||||||
import yugecin.opsudance.utils.GLHelper;
|
import yugecin.opsudance.utils.GLHelper;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
@ -59,13 +58,13 @@ import static yugecin.opsudance.options.Options.*;
|
||||||
/**
|
/**
|
||||||
* based on org.newdawn.slick.AppGameContainer
|
* based on org.newdawn.slick.AppGameContainer
|
||||||
*/
|
*/
|
||||||
public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListener {
|
public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListener, ResolutionChangedListener, SkinChangedListener {
|
||||||
|
|
||||||
private static SGL GL = Renderer.get();
|
private static SGL GL = Renderer.get();
|
||||||
|
|
||||||
private FpsRenderState fpsState;
|
private FpsRenderState fpsState;
|
||||||
private BarNotificationState barNotifState;
|
private BarNotificationState barNotifState;
|
||||||
private BubbleNotificationState bubNotifState;
|
private BubNotifState bubNotifState;
|
||||||
|
|
||||||
private OpsuState state;
|
private OpsuState state;
|
||||||
|
|
||||||
|
@ -149,13 +148,8 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||||
this.cursor = new Cursor();
|
this.cursor = new Cursor();
|
||||||
drawCursor = true;
|
drawCursor = true;
|
||||||
|
|
||||||
EventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() {
|
ResolutionChangedListener.EVENT.addListener(this);
|
||||||
@Override
|
SkinChangedListener.EVENT.addListener(this);
|
||||||
public void onEvent(ResolutionOrSkinChangedEvent event) {
|
|
||||||
destroyImages();
|
|
||||||
reinit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.nativeDisplayMode = Display.getDisplayMode();
|
this.nativeDisplayMode = Display.getDisplayMode();
|
||||||
targetBackgroundRenderInterval = 41; // ~24 fps
|
targetBackgroundRenderInterval = 41; // ~24 fps
|
||||||
|
@ -164,6 +158,18 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||||
renderDelta = 1;
|
renderDelta = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResolutionChanged(int w, int h) {
|
||||||
|
destroyImages();
|
||||||
|
reinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSkinChanged(String stringName) {
|
||||||
|
destroyImages();
|
||||||
|
reinit();
|
||||||
|
}
|
||||||
|
|
||||||
private void reinit() {
|
private void reinit() {
|
||||||
// this used to be in Utils.init
|
// this used to be in Utils.init
|
||||||
// TODO find a better place for this?
|
// TODO find a better place for this?
|
||||||
|
@ -205,7 +211,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||||
state.enter();
|
state.enter();
|
||||||
|
|
||||||
fpsState = new FpsRenderState();
|
fpsState = new FpsRenderState();
|
||||||
bubNotifState = new BubbleNotificationState();
|
bubNotifState = new BubNotifState();
|
||||||
barNotifState = new BarNotificationState();
|
barNotifState = new BarNotificationState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,13 +340,15 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (DownloadList.get().hasActiveDownloads()) {
|
if (DownloadList.get().hasActiveDownloads()) {
|
||||||
EventBus.post(new BubbleNotificationEvent(DownloadList.EXIT_CONFIRMATION, BubbleNotificationEvent.COMMONCOLOR_PURPLE));
|
BubNotifListener.EVENT.make().onBubNotif(DownloadList.EXIT_CONFIRMATION,
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
exitRequested = false;
|
exitRequested = false;
|
||||||
exitconfirmation = System.currentTimeMillis();
|
exitconfirmation = System.currentTimeMillis();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (updater.getStatus() == Updater.Status.UPDATE_DOWNLOADING) {
|
if (updater.getStatus() == Updater.Status.UPDATE_DOWNLOADING) {
|
||||||
EventBus.post(new BubbleNotificationEvent(Updater.EXIT_CONFIRMATION, BubbleNotificationEvent.COMMONCOLOR_PURPLE));
|
BubNotifListener.EVENT.make().onBubNotif(Updater.EXIT_CONFIRMATION,
|
||||||
|
BubNotifListener.COMMONCOLOR_PURPLE);
|
||||||
exitRequested = false;
|
exitRequested = false;
|
||||||
exitconfirmation = System.currentTimeMillis();
|
exitconfirmation = System.currentTimeMillis();
|
||||||
return false;
|
return false;
|
||||||
|
@ -379,7 +387,8 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||||
try {
|
try {
|
||||||
setDisplayMode(width, height, OPTION_FULLSCREEN.state);
|
setDisplayMode(width, height, OPTION_FULLSCREEN.state);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Failed to change resolution", BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif("Failed to change resolution",
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
Log.error("Failed to set display mode.", e);
|
Log.error("Failed to set display mode.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,8 +408,9 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||||
displayMode = new DisplayMode(width, height);
|
displayMode = new DisplayMode(width, height);
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
fullscreen = false;
|
fullscreen = false;
|
||||||
Log.warn("could not find fullscreen displaymode for " + width + "x" + height);
|
String msg = String.format("Fullscreen mode is not supported for %sx%s", width, height);
|
||||||
EventBus.post(new BubbleNotificationEvent("Fullscreen mode is not supported for " + width + "x" + height, BubbleNotificationEvent.COLOR_ORANGE));
|
Log.warn(msg);
|
||||||
|
BubNotifListener.EVENT.make().onBubNotif(msg, BubNotifListener.COLOR_ORANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,7 +446,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||||
GameImage.init(width, height);
|
GameImage.init(width, height);
|
||||||
Fonts.init();
|
Fonts.init();
|
||||||
|
|
||||||
EventBus.post(new ResolutionOrSkinChangedEvent(null, width, height));
|
ResolutionChangedListener.EVENT.make().onResolutionChanged(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetCursor() {
|
public void resetCursor() {
|
||||||
|
|
|
@ -17,38 +17,37 @@
|
||||||
*/
|
*/
|
||||||
package yugecin.opsudance.core.events;
|
package yugecin.opsudance.core.events;
|
||||||
|
|
||||||
import java.util.*;
|
import java.lang.reflect.InvocationHandler;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Proxy;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class EventBus {
|
public class Event<T> {
|
||||||
|
|
||||||
private EventBus() {
|
private final Class<T> type;
|
||||||
|
private final LinkedList<T> listeners;
|
||||||
|
|
||||||
|
public Event(Class<T> type) {
|
||||||
|
this.type = type;
|
||||||
|
this.listeners = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final List<Subscriber> subscribers = new LinkedList<>();
|
public void addListener(T listener) {
|
||||||
|
this.listeners.add(listener);
|
||||||
public static <T> void subscribe(Class<T> eventType, EventListener<T> eventListener) {
|
|
||||||
subscribers.add(new Subscriber<>(eventType, eventListener));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void post(Object event) {
|
public T make() {
|
||||||
for (Subscriber s : subscribers) {
|
return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type},
|
||||||
if (s.eventType.isInstance(event)) {
|
new InvocationHandler() {
|
||||||
s.listener.onEvent(event);
|
@Override
|
||||||
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
|
for (T listener : listeners) {
|
||||||
|
method.invoke(listener, args);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
private static class Subscriber<T> {
|
|
||||||
|
|
||||||
private final Class<T> eventType;
|
|
||||||
private final EventListener<T> listener;
|
|
||||||
|
|
||||||
private Subscriber(Class<T> eventType, EventListener<T> listener) {
|
|
||||||
this.eventType = eventType;
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ import itdelatrisu.opsu.replay.ReplayImporter;
|
||||||
import itdelatrisu.opsu.states.*;
|
import itdelatrisu.opsu.states.*;
|
||||||
import yugecin.opsudance.core.DisplayContainer;
|
import yugecin.opsudance.core.DisplayContainer;
|
||||||
import yugecin.opsudance.core.state.specialstates.BarNotificationState;
|
import yugecin.opsudance.core.state.specialstates.BarNotificationState;
|
||||||
import yugecin.opsudance.core.state.specialstates.BubbleNotificationState;
|
import yugecin.opsudance.core.state.specialstates.BubNotifState;
|
||||||
import yugecin.opsudance.core.state.specialstates.FpsRenderState;
|
import yugecin.opsudance.core.state.specialstates.FpsRenderState;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
import yugecin.opsudance.options.Configuration;
|
import yugecin.opsudance.options.Configuration;
|
||||||
|
@ -52,7 +52,7 @@ public class OpsuDanceInjector extends Injector {
|
||||||
|
|
||||||
bind(FpsRenderState.class).asEagerSingleton();
|
bind(FpsRenderState.class).asEagerSingleton();
|
||||||
bind(BarNotificationState.class).asEagerSingleton();
|
bind(BarNotificationState.class).asEagerSingleton();
|
||||||
bind(BubbleNotificationState.class).asEagerSingleton();
|
bind(BubNotifState.class).asEagerSingleton();
|
||||||
|
|
||||||
bind(GameObjectRenderer.class).asEagerSingleton();
|
bind(GameObjectRenderer.class).asEagerSingleton();
|
||||||
|
|
||||||
|
|
|
@ -21,17 +21,15 @@ import itdelatrisu.opsu.states.Game;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Input;
|
import org.newdawn.slick.Input;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.core.events.EventListener;
|
import yugecin.opsudance.events.ResolutionChangedListener;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
|
||||||
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
|
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
public abstract class BaseOpsuState implements OpsuState, EventListener<ResolutionOrSkinChangedEvent> {
|
public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* state is dirty when resolution or skin changed but hasn't rendered yet
|
* state is dirty when resolution or skin changed but hasn't rendered yet
|
||||||
|
@ -40,7 +38,7 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
|
||||||
private boolean isCurrentState;
|
private boolean isCurrentState;
|
||||||
|
|
||||||
public BaseOpsuState() {
|
public BaseOpsuState() {
|
||||||
EventBus.subscribe(ResolutionOrSkinChangedEvent.class, this);
|
ResolutionChangedListener.EVENT.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void revalidate() {
|
protected void revalidate() {
|
||||||
|
@ -59,7 +57,7 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(ResolutionOrSkinChangedEvent event) {
|
public void onResolutionChanged(int w, int h) {
|
||||||
if (isCurrentState) {
|
if (isCurrentState) {
|
||||||
revalidate();
|
revalidate();
|
||||||
return;
|
return;
|
||||||
|
@ -95,7 +93,8 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
|
||||||
public boolean keyReleased(int key, char c) {
|
public boolean keyReleased(int key, char c) {
|
||||||
if (key == Input.KEY_F7) {
|
if (key == Input.KEY_F7) {
|
||||||
OPTION_TARGET_FPS.clickListItem((targetFPSIndex + 1) % targetFPS.length);
|
OPTION_TARGET_FPS.clickListItem((targetFPSIndex + 1) % targetFPS.length);
|
||||||
EventBus.post(new BarNotificationEvent(String.format("Frame limiter: %s", OPTION_TARGET_FPS.getValueString())));
|
BarNotifListener.EVENT.make().onBarNotif(String.format("Frame limiter: %s",
|
||||||
|
OPTION_TARGET_FPS.getValueString()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (key == Input.KEY_F10) {
|
if (key == Input.KEY_F10) {
|
||||||
|
|
|
@ -21,16 +21,14 @@ import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.core.events.EventListener;
|
import yugecin.opsudance.events.ResolutionChangedListener;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
|
||||||
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
|
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
|
||||||
|
|
||||||
public class BarNotificationState implements EventListener<BarNotificationEvent> {
|
public class BarNotificationState implements BarNotifListener, ResolutionChangedListener {
|
||||||
|
|
||||||
private final int IN_TIME = 200;
|
private final int IN_TIME = 200;
|
||||||
private final int DISPLAY_TIME = 5700 + IN_TIME;
|
private final int DISPLAY_TIME = 5700 + IN_TIME;
|
||||||
|
@ -53,16 +51,8 @@ public class BarNotificationState implements EventListener<BarNotificationEvent>
|
||||||
this.bgcol = new Color(Color.black);
|
this.bgcol = new Color(Color.black);
|
||||||
this.textCol = new Color(Color.white);
|
this.textCol = new Color(Color.white);
|
||||||
this.timeShown = TOTAL_TIME;
|
this.timeShown = TOTAL_TIME;
|
||||||
EventBus.subscribe(BarNotificationEvent.class, this);
|
BarNotifListener.EVENT.addListener(this);
|
||||||
EventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() {
|
ResolutionChangedListener.EVENT.addListener(this);
|
||||||
@Override
|
|
||||||
public void onEvent(ResolutionOrSkinChangedEvent event) {
|
|
||||||
if (timeShown >= TOTAL_TIME) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
calculatePosition();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(Graphics g) {
|
public void render(Graphics g) {
|
||||||
|
@ -107,10 +97,18 @@ public class BarNotificationState implements EventListener<BarNotificationEvent>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(BarNotificationEvent event) {
|
public void onBarNotif(String message) {
|
||||||
this.message = event.message;
|
this.message = message;
|
||||||
calculatePosition();
|
calculatePosition();
|
||||||
timeShown = 0;
|
timeShown = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResolutionChanged(int w, int h) {
|
||||||
|
if (timeShown >= TOTAL_TIME) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
calculatePosition();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,9 @@ import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.core.events.EventListener;
|
import yugecin.opsudance.events.ResolutionChangedListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
import yugecin.opsudance.events.SkinChangedListener;
|
||||||
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -32,7 +31,7 @@ import java.util.ListIterator;
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
|
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
|
||||||
|
|
||||||
public class BubbleNotificationState implements EventListener<BubbleNotificationEvent> {
|
public class BubNotifState implements BubNotifListener, ResolutionChangedListener, SkinChangedListener {
|
||||||
|
|
||||||
public static final int IN_TIME = 633;
|
public static final int IN_TIME = 633;
|
||||||
public static final int DISPLAY_TIME = 7000 + IN_TIME;
|
public static final int DISPLAY_TIME = 7000 + IN_TIME;
|
||||||
|
@ -44,16 +43,10 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
|
||||||
private int addAnimationTime;
|
private int addAnimationTime;
|
||||||
private int addAnimationHeight;
|
private int addAnimationHeight;
|
||||||
|
|
||||||
public BubbleNotificationState() {
|
public BubNotifState() {
|
||||||
this.bubbles = new LinkedList<>();
|
this.bubbles = new LinkedList<>();
|
||||||
this.addAnimationTime = IN_TIME;
|
this.addAnimationTime = IN_TIME;
|
||||||
EventBus.subscribe(BubbleNotificationEvent.class, this);
|
BubNotifListener.EVENT.addListener(this);
|
||||||
EventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() {
|
|
||||||
@Override
|
|
||||||
public void onEvent(ResolutionOrSkinChangedEvent event) {
|
|
||||||
calculatePositions();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(Graphics g) {
|
public void render(Graphics g) {
|
||||||
|
@ -129,9 +122,9 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(BubbleNotificationEvent event) {
|
public void onBubNotif(String message, Color borderColor) {
|
||||||
finishAddAnimation();
|
finishAddAnimation();
|
||||||
Notification newBubble = new Notification(event.message, event.borderColor);
|
Notification newBubble = new Notification(message, borderColor);
|
||||||
bubbles.add(0, newBubble);
|
bubbles.add(0, newBubble);
|
||||||
addAnimationTime = 0;
|
addAnimationTime = 0;
|
||||||
addAnimationHeight = newBubble.height + Notification.paddingY;
|
addAnimationHeight = newBubble.height + Notification.paddingY;
|
||||||
|
@ -143,6 +136,16 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResolutionChanged(int w, int h) {
|
||||||
|
calculatePositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSkinChanged(String stringName) {
|
||||||
|
calculatePositions();
|
||||||
|
}
|
||||||
|
|
||||||
private static class Notification {
|
private static class Notification {
|
||||||
|
|
||||||
private final static int HOVER_ANIM_TIME = 150;
|
private final static int HOVER_ANIM_TIME = 150;
|
||||||
|
@ -204,7 +207,7 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
|
||||||
Fonts.SMALLBOLD.drawString(x + fontPaddingX, y, line, textColor);
|
Fonts.SMALLBOLD.drawString(x + fontPaddingX, y, line, textColor);
|
||||||
y += lineHeight;
|
y += lineHeight;
|
||||||
}
|
}
|
||||||
return timeShown > BubbleNotificationState.TOTAL_TIME;
|
return timeShown > BubNotifState.TOTAL_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processAnimations(boolean mouseHovered, int delta) {
|
private void processAnimations(boolean mouseHovered, int delta) {
|
||||||
|
@ -217,17 +220,17 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
|
||||||
borderColor.r = targetBorderColor.r + (0.977f - targetBorderColor.r) * hoverProgress;
|
borderColor.r = targetBorderColor.r + (0.977f - targetBorderColor.r) * hoverProgress;
|
||||||
borderColor.g = targetBorderColor.g + (0.977f - targetBorderColor.g) * hoverProgress;
|
borderColor.g = targetBorderColor.g + (0.977f - targetBorderColor.g) * hoverProgress;
|
||||||
borderColor.b = targetBorderColor.b + (0.977f - targetBorderColor.b) * hoverProgress;
|
borderColor.b = targetBorderColor.b + (0.977f - targetBorderColor.b) * hoverProgress;
|
||||||
if (timeShown < BubbleNotificationState.IN_TIME) {
|
if (timeShown < BubNotifState.IN_TIME) {
|
||||||
float progress = (float) timeShown / BubbleNotificationState.IN_TIME;
|
float progress = (float) timeShown / BubNotifState.IN_TIME;
|
||||||
this.x = finalX + (int) ((1 - AnimationEquation.OUT_BACK.calc(progress)) * width / 2);
|
this.x = finalX + (int) ((1 - AnimationEquation.OUT_BACK.calc(progress)) * width / 2);
|
||||||
textColor.a = borderColor.a = bgcol.a = progress;
|
textColor.a = borderColor.a = bgcol.a = progress;
|
||||||
bgcol.a = borderColor.a * 0.8f;
|
bgcol.a = borderColor.a * 0.8f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
x = Notification.finalX;
|
x = Notification.finalX;
|
||||||
if (timeShown > BubbleNotificationState.DISPLAY_TIME) {
|
if (timeShown > BubNotifState.DISPLAY_TIME) {
|
||||||
isFading = true;
|
isFading = true;
|
||||||
float progress = (float) (timeShown - BubbleNotificationState.DISPLAY_TIME) / BubbleNotificationState.OUT_TIME;
|
float progress = (float) (timeShown - BubNotifState.DISPLAY_TIME) / BubNotifState.OUT_TIME;
|
||||||
textColor.a = borderColor.a = 1f - progress;
|
textColor.a = borderColor.a = 1f - progress;
|
||||||
bgcol.a = borderColor.a * 0.8f;
|
bgcol.a = borderColor.a * 0.8f;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +238,7 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
|
||||||
|
|
||||||
private boolean mouseReleased(int x, int y) {
|
private boolean mouseReleased(int x, int y) {
|
||||||
if (!isFading && isMouseHovered(x, y)) {
|
if (!isFading && isMouseHovered(x, y)) {
|
||||||
timeShown = BubbleNotificationState.DISPLAY_TIME;
|
timeShown = BubNotifState.DISPLAY_TIME;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
|
@ -20,15 +20,13 @@ package yugecin.opsudance.core.state.specialstates;
|
||||||
import itdelatrisu.opsu.ui.Fonts;
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.ResolutionChangedListener;
|
||||||
import yugecin.opsudance.core.events.EventListener;
|
|
||||||
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
|
|
||||||
import yugecin.opsudance.utils.FPSMeter;
|
import yugecin.opsudance.utils.FPSMeter;
|
||||||
|
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
|
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
|
||||||
|
|
||||||
public class FpsRenderState implements EventListener<ResolutionOrSkinChangedEvent> {
|
public class FpsRenderState implements ResolutionChangedListener {
|
||||||
|
|
||||||
private final static Color GREEN = new Color(171, 218, 25);
|
private final static Color GREEN = new Color(171, 218, 25);
|
||||||
private final static Color ORANGE = new Color(255, 204, 34);
|
private final static Color ORANGE = new Color(255, 204, 34);
|
||||||
|
@ -44,7 +42,7 @@ public class FpsRenderState implements EventListener<ResolutionOrSkinChangedEven
|
||||||
public FpsRenderState() {
|
public FpsRenderState() {
|
||||||
fpsMeter = new FPSMeter(10);
|
fpsMeter = new FPSMeter(10);
|
||||||
upsMeter = new FPSMeter(10);
|
upsMeter = new FPSMeter(10);
|
||||||
EventBus.subscribe(ResolutionOrSkinChangedEvent.class, this);
|
ResolutionChangedListener.EVENT.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
@ -91,7 +89,7 @@ public class FpsRenderState implements EventListener<ResolutionOrSkinChangedEven
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(ResolutionOrSkinChangedEvent event) {
|
public void onResolutionChanged(int w, int h) {
|
||||||
singleHeight = Fonts.SMALL.getLineHeight();
|
singleHeight = Fonts.SMALL.getLineHeight();
|
||||||
x = displayContainer.width - 3;
|
x = displayContainer.width - 3;
|
||||||
y = displayContainer.height - 3 - singleHeight - 10;
|
y = displayContainer.height - 3 - singleHeight - 10;
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
*/
|
*/
|
||||||
package yugecin.opsudance.events;
|
package yugecin.opsudance.events;
|
||||||
|
|
||||||
public class BarNotificationEvent {
|
import yugecin.opsudance.core.events.Event;
|
||||||
|
|
||||||
public final String message;
|
public interface BarNotifListener {
|
||||||
|
|
||||||
public BarNotificationEvent(String message) {
|
Event<BarNotifListener> EVENT = new Event<>(BarNotifListener.class);
|
||||||
this.message = message;
|
|
||||||
}
|
void onBarNotif(String message);
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,8 +18,12 @@
|
||||||
package yugecin.opsudance.events;
|
package yugecin.opsudance.events;
|
||||||
|
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
|
import yugecin.opsudance.core.events.Event;
|
||||||
|
|
||||||
public class BubbleNotificationEvent {
|
@SuppressWarnings({"UnnecessaryInterfaceModifier", "unused"})
|
||||||
|
public interface BubNotifListener {
|
||||||
|
|
||||||
|
Event<BubNotifListener> EVENT = new Event<>(BubNotifListener.class);
|
||||||
|
|
||||||
public static final Color COMMONCOLOR_GREEN = new Color(98, 131, 59);
|
public static final Color COMMONCOLOR_GREEN = new Color(98, 131, 59);
|
||||||
public static final Color COMMONCOLOR_WHITE = new Color(220, 220, 220);
|
public static final Color COMMONCOLOR_WHITE = new Color(220, 220, 220);
|
||||||
|
@ -27,12 +31,6 @@ public class BubbleNotificationEvent {
|
||||||
public static final Color COMMONCOLOR_RED = new Color(141, 49, 16);
|
public static final Color COMMONCOLOR_RED = new Color(141, 49, 16);
|
||||||
public static final Color COLOR_ORANGE = new Color(138, 72, 51);
|
public static final Color COLOR_ORANGE = new Color(138, 72, 51);
|
||||||
|
|
||||||
public final String message;
|
void onBubNotif(String message, Color borderColor);
|
||||||
public final Color borderColor;
|
|
||||||
|
|
||||||
public BubbleNotificationEvent(String message, Color borderColor) {
|
|
||||||
this.message = message;
|
|
||||||
this.borderColor = borderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,16 +17,12 @@
|
||||||
*/
|
*/
|
||||||
package yugecin.opsudance.events;
|
package yugecin.opsudance.events;
|
||||||
|
|
||||||
public class ResolutionOrSkinChangedEvent {
|
import yugecin.opsudance.core.events.Event;
|
||||||
|
|
||||||
public final String skin;
|
public interface ResolutionChangedListener {
|
||||||
public final int width;
|
|
||||||
public final int height;
|
|
||||||
|
|
||||||
public ResolutionOrSkinChangedEvent(String skin, int width, int height) {
|
Event<ResolutionChangedListener> EVENT = new Event<>(ResolutionChangedListener.class);
|
||||||
this.skin = skin;
|
|
||||||
this.width = width;
|
void onResolutionChanged(int w, int h);
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,10 +15,14 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
|
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package yugecin.opsudance.core.events;
|
package yugecin.opsudance.events;
|
||||||
|
|
||||||
public interface EventListener<T> {
|
import yugecin.opsudance.core.events.Event;
|
||||||
|
|
||||||
void onEvent(T event);
|
public interface SkinChangedListener {
|
||||||
|
|
||||||
|
Event<SkinChangedListener> EVENT = new Event<>(SkinChangedListener.class);
|
||||||
|
|
||||||
|
void onSkinChanged(String stringName);
|
||||||
|
|
||||||
}
|
}
|
|
@ -28,8 +28,7 @@ import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
import yugecin.opsudance.utils.ManifestWrapper;
|
import yugecin.opsudance.utils.ManifestWrapper;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
@ -154,7 +153,7 @@ public class Configuration {
|
||||||
}
|
}
|
||||||
if (!defaultDir.isDirectory() && !defaultDir.mkdir()) {
|
if (!defaultDir.isDirectory() && !defaultDir.mkdir()) {
|
||||||
String msg = String.format("Failed to create %s directory at '%s'.", kind, defaultDir.getAbsolutePath());
|
String msg = String.format("Failed to create %s directory at '%s'.", kind, defaultDir.getAbsolutePath());
|
||||||
EventBus.post(new BubbleNotificationEvent(msg, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(msg, BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
return defaultDir;
|
return defaultDir;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +212,10 @@ public class Configuration {
|
||||||
// TODO: get a decent place for this
|
// TODO: get a decent place for this
|
||||||
// create the screenshot directory
|
// create the screenshot directory
|
||||||
if (!screenshotDir.isDirectory() && !screenshotDir.mkdir()) {
|
if (!screenshotDir.isDirectory() && !screenshotDir.mkdir()) {
|
||||||
EventBus.post(new BubbleNotificationEvent(String.format("Failed to create screenshot directory at '%s'.", screenshotDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(
|
||||||
|
String.format( "Failed to create screenshot directory at '%s'.",
|
||||||
|
screenshotDir.getAbsolutePath()),
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +249,8 @@ public class Configuration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImageIO.write(image, OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase(), file);
|
ImageIO.write(image, OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase(), file);
|
||||||
EventBus.post(new BubbleNotificationEvent("Created " + fileName, BubbleNotificationEvent.COMMONCOLOR_PURPLE));
|
BubNotifListener.EVENT.make().onBubNotif("Created " + fileName,
|
||||||
|
BubNotifListener.COMMONCOLOR_PURPLE);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorHandler.error("Failed to take a screenshot.", e).show();
|
ErrorHandler.error("Failed to take a screenshot.", e).show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
package yugecin.opsudance.options;
|
package yugecin.opsudance.options;
|
||||||
|
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
public class NumericOption extends Option {
|
public class NumericOption extends Option {
|
||||||
|
|
||||||
|
@ -53,7 +52,8 @@ public class NumericOption extends Option {
|
||||||
try {
|
try {
|
||||||
val = Utils.clamp(Integer.parseInt(s), min, max);
|
val = Utils.clamp(Integer.parseInt(s), min, max);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
EventBus.post(new BubbleNotificationEvent("Failed to parse " + configurationName + " option", BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif("Failed to parse " + configurationName + " option",
|
||||||
|
BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,7 @@ import org.newdawn.slick.SlickException;
|
||||||
import org.newdawn.slick.openal.SoundStore;
|
import org.newdawn.slick.openal.SoundStore;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.*;
|
import yugecin.opsudance.*;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
|
||||||
import yugecin.opsudance.movers.factories.ExgonMoverFactory;
|
import yugecin.opsudance.movers.factories.ExgonMoverFactory;
|
||||||
import yugecin.opsudance.movers.factories.QuadraticBezierMoverFactory;
|
import yugecin.opsudance.movers.factories.QuadraticBezierMoverFactory;
|
||||||
import yugecin.opsudance.movers.slidermovers.DefaultSliderMoverController;
|
import yugecin.opsudance.movers.slidermovers.DefaultSliderMoverController;
|
||||||
|
@ -439,7 +438,8 @@ public class Options {
|
||||||
public static final ToggleOption OPTION_DISABLE_MOUSE_BUTTONS = new ToggleOption("Disable mouse buttons in play mode", "MouseDisableButtons", "This option will disable all mouse buttons. Specifically for people who use their keyboard to click.", false) {
|
public static final ToggleOption OPTION_DISABLE_MOUSE_BUTTONS = new ToggleOption("Disable mouse buttons in play mode", "MouseDisableButtons", "This option will disable all mouse buttons. Specifically for people who use their keyboard to click.", false) {
|
||||||
@Override
|
@Override
|
||||||
public void toggle() {
|
public void toggle() {
|
||||||
EventBus.post(new BarNotificationEvent(state ? "Mouse buttons are disabled." : "Mouse buttons are enabled."));
|
BarNotifListener.EVENT.make().onBarNotif(state ?
|
||||||
|
"Mouse buttons are disabled." : "Mouse buttons are enabled.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final ToggleOption OPTION_DISABLE_CURSOR = new ToggleOption("Disable Cursor", "DisableCursor", "Hide the cursor sprite.", false);
|
public static final ToggleOption OPTION_DISABLE_CURSOR = new ToggleOption("Disable Cursor", "DisableCursor", "Hide the cursor sprite.", false);
|
||||||
|
@ -608,7 +608,7 @@ public class Options {
|
||||||
public void clickListItem(int index){
|
public void clickListItem(int index){
|
||||||
if (Game.isInGame && Dancer.moverFactories[index] instanceof PolyMoverFactory) {
|
if (Game.isInGame && Dancer.moverFactories[index] instanceof PolyMoverFactory) {
|
||||||
// TODO remove this when #79 is fixed
|
// TODO remove this when #79 is fixed
|
||||||
EventBus.post(new BarNotificationEvent("This mover is disabled in the storyboard right now"));
|
BarNotifListener.EVENT.make().onBarNotif("This mover is disabled in the storyboard right now");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Dancer.instance.setMoverFactoryIndex(index);
|
Dancer.instance.setMoverFactoryIndex(index);
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
package yugecin.opsudance.options;
|
package yugecin.opsudance.options;
|
||||||
|
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -80,7 +79,7 @@ public class OptionsService {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String err = String.format("Failed to read option file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
|
String err = String.format("Failed to read option file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
|
||||||
Log.error(err, e);
|
Log.error(err, e);
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
config.loadDirectories();
|
config.loadDirectories();
|
||||||
}
|
}
|
||||||
|
@ -109,7 +108,7 @@ public class OptionsService {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String err = String.format("Failed to write to file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
|
String err = String.format("Failed to write to file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
|
||||||
Log.error(err, e);
|
Log.error(err, e);
|
||||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,8 @@ import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.core.DisplayContainer;
|
import yugecin.opsudance.core.DisplayContainer;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
|
||||||
import yugecin.opsudance.core.state.OverlayOpsuState;
|
import yugecin.opsudance.core.state.OverlayOpsuState;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.sbv2.movers.CubicStoryboardMover;
|
import yugecin.opsudance.sbv2.movers.CubicStoryboardMover;
|
||||||
import yugecin.opsudance.sbv2.movers.LinearStoryboardMover;
|
import yugecin.opsudance.sbv2.movers.LinearStoryboardMover;
|
||||||
import yugecin.opsudance.sbv2.movers.QuadraticStoryboardMover;
|
import yugecin.opsudance.sbv2.movers.QuadraticStoryboardMover;
|
||||||
|
@ -186,7 +185,7 @@ public class MoveStoryboard extends OverlayOpsuState{
|
||||||
|
|
||||||
private StoryboardMove getCurrentMoveOrCreateNew() {
|
private StoryboardMove getCurrentMoveOrCreateNew() {
|
||||||
if (gameObjects[objectIndex].isSlider() && trackPosition > gameObjects[objectIndex].getTime() && trackPosition < gameObjects[objectIndex].getEndTime()) {
|
if (gameObjects[objectIndex].isSlider() && trackPosition > gameObjects[objectIndex].getTime() && trackPosition < gameObjects[objectIndex].getEndTime()) {
|
||||||
EventBus.post(new BarNotificationEvent("Wait until the slider ended"));
|
BarNotifListener.EVENT.make().onBarNotif("Wait until the slider ended");
|
||||||
return dummyMove;
|
return dummyMove;
|
||||||
}
|
}
|
||||||
if (moves[objectIndex] == null) {
|
if (moves[objectIndex] == null) {
|
||||||
|
|
|
@ -23,8 +23,7 @@ import itdelatrisu.opsu.skins.SkinLoader;
|
||||||
import org.newdawn.slick.util.ClasspathLocation;
|
import org.newdawn.slick.util.ClasspathLocation;
|
||||||
import org.newdawn.slick.util.FileSystemLocation;
|
import org.newdawn.slick.util.FileSystemLocation;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
import yugecin.opsudance.core.events.EventBus;
|
import yugecin.opsudance.events.SkinChangedListener;
|
||||||
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ public class SkinService {
|
||||||
public void reloadSkin() {
|
public void reloadSkin() {
|
||||||
loadSkin();
|
loadSkin();
|
||||||
SoundController.init();
|
SoundController.init();
|
||||||
EventBus.post(new ResolutionOrSkinChangedEvent(usedSkinName, -1, -1));
|
SkinChangedListener.EVENT.make().onSkinChanged(usedSkinName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user