remove unnecessary events pattern and replace it with something more simple

This commit is contained in:
yugecin 2018-06-25 22:18:26 +02:00
parent a2edb8a1c1
commit ab19b53d63
No known key found for this signature in database
GPG Key ID: 2C5AC035A7068E44
36 changed files with 227 additions and 330 deletions

View File

@ -31,10 +31,11 @@ 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.events.BubNotifListener;
import yugecin.opsudance.skinning.SkinService; import yugecin.opsudance.skinning.SkinService;
import yugecin.opsudance.utils.SlickUtil; import yugecin.opsudance.utils.SlickUtil;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
/** /**
@ -743,7 +744,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);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED); bubNotifs.send(BUB_RED, err);
} }
/** /**
@ -806,8 +807,7 @@ 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) {
BubNotifListener.EVENT.make().onBubNotif( bubNotifs.sendf(BUB_RED, "Failed to set image '%s'.", name);
String.format("Failed to set image '%s'.", name), Colors.BUB_RED);
break; break;
} }
} }
@ -834,8 +834,7 @@ public enum GameImage {
img = img.getScaledCopy(0.5f); img = img.getScaledCopy(0.5f);
return img; return img;
} catch (SlickException e) { } catch (SlickException e) {
BubNotifListener.EVENT.make().onBubNotif( bubNotifs.sendf(BUB_RED, "Failed to set image '%s'.", filename);
String.format("Failed to set image '%s'.", filename), Colors.BUB_RED);
} }
} }
return null; return null;

View File

@ -33,7 +33,6 @@ import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
import itdelatrisu.opsu.ui.Colors;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL; import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10; import org.lwjgl.openal.AL10;
@ -45,10 +44,10 @@ import org.newdawn.slick.openal.SoundStore;
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 org.tritonus.share.sampled.file.TAudioFileFormat; import org.tritonus.share.sampled.file.TAudioFileFormat;
import yugecin.opsudance.events.BarNotifListener;
import yugecin.opsudance.events.BubNotifListener;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*; import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
/** /**
@ -103,8 +102,7 @@ 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())) {
BarNotifListener.EVENT.make().onBarNotif(String.format("Could not find track '%s'.", barNotifs.sendf("Could not find track '%s'.", audioFile.getName());
audioFile.getName()));
return; return;
} }
@ -159,7 +157,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);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED); bubNotifs.send(BUB_RED, err);
} }
} }

View File

@ -36,15 +36,14 @@ import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineListener; import javax.sound.sampled.LineListener;
import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.LineUnavailableException;
import itdelatrisu.opsu.ui.Colors;
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.events.BarNotifListener;
import yugecin.opsudance.events.BubNotifListener;
import yugecin.opsudance.options.Configuration; import yugecin.opsudance.options.Configuration;
import yugecin.opsudance.skinning.SkinService; import yugecin.opsudance.skinning.SkinService;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*; import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
/** /**
@ -220,8 +219,8 @@ 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) {
BubNotifListener.EVENT.make().onBubNotif( final String name = s.getFileName();
"Could not find sound file " + s.getFileName(), Colors.BUB_ORANGE); bubNotifs.send(BUB_ORANGE, "Could not find sound file " + name);
continue; continue;
} }
MultiClip newClip = loadClip(currentFileName, currentFileName.endsWith(".mp3")); MultiClip newClip = loadClip(currentFileName, currentFileName.endsWith(".mp3"));
@ -240,8 +239,10 @@ 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) {
BubNotifListener.EVENT.make().onBubNotif( bubNotifs.send(
"Could not find hit sound file " + filename, Colors.BUB_ORANGE); BUB_ORANGE,
"Could not find hit sound file " + filename
);
continue; continue;
} }
MultiClip newClip = loadClip(currentFileName, false); MultiClip newClip = loadClip(currentFileName, false);
@ -398,8 +399,7 @@ public class SoundController {
@Override @Override
public void error() { public void error() {
BarNotifListener.EVENT.make().onBarNotif( barNotifs.send("Failed to download track preview");
"Failed to download track preview");
} }
}); });
try { try {

View File

@ -31,13 +31,12 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import itdelatrisu.opsu.ui.Colors;
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.Nullable;
import yugecin.opsudance.events.BubNotifListener;
import yugecin.opsudance.skinning.SkinService; import yugecin.opsudance.skinning.SkinService;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*; import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
@ -890,7 +889,7 @@ public class BeatmapParser {
private static void logAndShowErrorNotification(Exception e, String message, Object... formatArgs) { private static void logAndShowErrorNotification(Exception e, String message, Object... formatArgs) {
message = String.format(message, formatArgs); message = String.format(message, formatArgs);
Log.error(message, e); Log.error(message, e);
BubNotifListener.EVENT.make().onBubNotif(message, Colors.BUB_RED); bubNotifs.send(BUB_RED, message);
} }
} }

View File

@ -21,8 +21,6 @@ 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 itdelatrisu.opsu.ui.Colors;
import yugecin.opsudance.events.BubNotifListener;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -36,6 +34,9 @@ import java.util.LinkedList;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/** /**
* Indexed, expanding, doubly-linked list data type for song groups. * Indexed, expanding, doubly-linked list data type for song groups.
*/ */
@ -215,7 +216,7 @@ public class BeatmapSetList {
try { try {
Utils.deleteToTrash(dir); Utils.deleteToTrash(dir);
} catch (IOException e) { } catch (IOException e) {
BubNotifListener.EVENT.make().onBubNotif("Could not delete song group", Colors.BUB_ORANGE); bubNotifs.send(BUB_ORANGE, "Could not delete song group");
} }
if (ws != null) if (ws != null)
ws.resume(); ws.resume();
@ -271,7 +272,7 @@ public class BeatmapSetList {
try { try {
Utils.deleteToTrash(file); Utils.deleteToTrash(file);
} catch (IOException e) { } catch (IOException e) {
BubNotifListener.EVENT.make().onBubNotif("Could not delete song", Colors.BUB_ORANGE); bubNotifs.send(BUB_ORANGE, "Could not delete song");
} }
if (ws != null) if (ws != null)
ws.resume(); ws.resume();

View File

@ -38,11 +38,9 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BarNotifListener;
import yugecin.opsudance.events.BubNotifListener;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
@ -101,7 +99,7 @@ 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);
BubNotifListener.EVENT.make().onBubNotif("Could not create watch service", Colors.BUB_RED); bubNotifs.send(BUB_RED, "Could not create watch service");
return; return;
} }
@ -124,7 +122,7 @@ public class BeatmapWatchService {
} catch (IOException e) { } catch (IOException e) {
String msg = "An I/O exception occurred while closing the previous watch service."; String msg = "An I/O exception occurred while closing the previous watch service.";
Log.error(msg, e); Log.error(msg, e);
BarNotifListener.EVENT.make().onBarNotif(msg); barNotifs.send(msg);
ws = null; ws = null;
} }
} }

View File

@ -23,12 +23,11 @@ import java.io.FilenameFilter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import itdelatrisu.opsu.ui.Colors;
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.events.BubNotifListener;
import static itdelatrisu.opsu.ui.Colors.*;
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);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED); bubNotifs.send(BUB_RED, err);
} }
} }

View File

@ -33,10 +33,10 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BubNotifListener;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*; import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/** /**
@ -220,7 +220,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) {
BubNotifListener.EVENT.make().onBubNotif(error, Colors.BUB_ORANGE); bubNotifs.send(BUB_ORANGE, error);
throw new IOException(); throw new IOException();
} }

View File

@ -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.events.BarNotifListener;
import yugecin.opsudance.events.BubNotifListener;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
@ -280,14 +279,12 @@ public class DownloadNode {
download.setListener(new DownloadListener() { download.setListener(new DownloadListener() {
@Override @Override
public void completed() { public void completed() {
BarNotifListener.EVENT.make().onBarNotif( barNotifs.sendf("Download complete: %s", getTitle());
String.format("Download complete: %s", getTitle()));
} }
@Override @Override
public void error() { public void error() {
BarNotifListener.EVENT.make().onBarNotif( barNotifs.send("Download failed due to a connection error.");
"Download failed due to a connection error.");
} }
}); });
this.download = download; this.download = download;
@ -409,9 +406,10 @@ 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) {
BubNotifListener.EVENT.make().onBubNotif( bubNotifs.send(
"Trying to draw download information for button without Download object", BUB_ORANGE,
Colors.BUB_ORANGE); "Trying to draw download information for button without Download object"
);
return; return;
} }

View File

@ -36,7 +36,6 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
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.Constants; import yugecin.opsudance.core.Constants;
import yugecin.opsudance.events.BarNotifListener;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*; import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
@ -241,14 +240,13 @@ public class Updater {
@Override @Override
public void completed() { public void completed() {
status = Status.UPDATE_DOWNLOADED; status = Status.UPDATE_DOWNLOADED;
BarNotifListener.EVENT.make().onBarNotif("Update has finished downloading"); barNotifs.send("Update has finished downloading");
} }
@Override @Override
public void error() { public void error() {
status = Status.CONNECTION_ERROR; status = Status.CONNECTION_ERROR;
BarNotifListener.EVENT.make().onBarNotif( barNotifs.send("Update failed due to a connection error.");
"Update failed due to a connection error.");
} }
}); });
} }

View File

@ -39,13 +39,12 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import itdelatrisu.opsu.ui.Colors;
import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream; import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import lzma.streams.LzmaOutputStream; import lzma.streams.LzmaOutputStream;
import yugecin.opsudance.events.BubNotifListener;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*; import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
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()) {
BubNotifListener.EVENT.make().onBubNotif("Failed to create replay directory", Colors.BUB_RED); bubNotifs.send(BUB_RED, "Failed to create replay directory");
return; return;
} }

View File

@ -28,10 +28,9 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BubNotifListener;
import static itdelatrisu.opsu.ui.Colors.*;
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);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED); bubNotifs.send(BUB_RED, err);
return; return;
} }
@ -83,7 +82,7 @@ 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);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED); bubNotifs.send(BUB_RED, err);
continue; continue;
} }
Beatmap beatmap = BeatmapSetList.get().getBeatmapFromHash(r.beatmapHash); Beatmap beatmap = BeatmapSetList.get().getBeatmapFromHash(r.beatmapHash);
@ -102,7 +101,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);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED); bubNotifs.send(BUB_RED, err);
} }
} }

View File

@ -29,10 +29,11 @@ import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import itdelatrisu.opsu.ui.Colors;
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.events.BubNotifListener;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/** /**
* Loads skin configuration files. * Loads skin configuration files.
@ -293,7 +294,7 @@ 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);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED); bubNotifs.send(BUB_RED, err);
} }
return skin; return skin;

View File

@ -53,7 +53,6 @@ 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.state.ComplexOpsuState; import yugecin.opsudance.core.state.ComplexOpsuState;
import yugecin.opsudance.events.BarNotifListener;
import static org.lwjgl.input.Keyboard.*; import static org.lwjgl.input.Keyboard.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
@ -273,13 +272,12 @@ public class DownloadsMenu extends ComplexOpsuState {
if (this.importedNode == null) { if (this.importedNode == null) {
return; return;
} }
String msg;
if (dirs.length == 1) { if (dirs.length == 1) {
msg = "Imported 1 new song."; barNotifs.send("Imported 1 new song.");
} else { return;
msg = String.format("Imported %d new songs.", dirs.length);
} }
BarNotifListener.EVENT.make().onBarNotif(msg); barNotifs.sendf("Imported %d new songs.", dirs.length);
} }
} }
@ -686,7 +684,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (playing) if (playing)
previewID = node.getID(); previewID = node.getID();
} catch (SlickException e) { } catch (SlickException e) {
BarNotifListener.EVENT.make().onBarNotif("Failed to load track preview. See log for details."); barNotifs.send("Failed to load track preview. See log for details.");
Log.error(e); Log.error(e);
} }
} }
@ -709,7 +707,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) {
BarNotifListener.EVENT.make().onBarNotif("The download could not be started"); barNotifs.send("The download could not be started");
} else { } else {
DownloadList.get().addNode(node); DownloadList.get().addNode(node);
node.getDownload().start(); node.getDownload().start();
@ -951,7 +949,7 @@ public class DownloadsMenu extends ComplexOpsuState {
pageDir = Page.RESET; pageDir = Page.RESET;
previewID = -1; previewID = -1;
if (barNotificationOnLoad != null) { if (barNotificationOnLoad != null) {
BarNotifListener.EVENT.make().onBarNotif(barNotificationOnLoad); barNotifs.send(barNotificationOnLoad);
barNotificationOnLoad = null; barNotificationOnLoad = null;
} }
} }

View File

@ -57,8 +57,6 @@ 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.state.ComplexOpsuState; import yugecin.opsudance.core.state.ComplexOpsuState;
import yugecin.opsudance.events.BarNotifListener;
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.sbv2.MoveStoryboard; import yugecin.opsudance.sbv2.MoveStoryboard;
@ -67,6 +65,7 @@ import yugecin.opsudance.ui.OptionsOverlay;
import yugecin.opsudance.ui.StoryboardOverlay; import yugecin.opsudance.ui.StoryboardOverlay;
import yugecin.opsudance.utils.GLHelper; import yugecin.opsudance.utils.GLHelper;
import static itdelatrisu.opsu.ui.Colors.*;
import static org.lwjgl.input.Keyboard.*; import static org.lwjgl.input.Keyboard.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
@ -335,9 +334,10 @@ 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);
BubNotifListener.EVENT.make().onBubNotif( bubNotifs.send(
"Exception while creating offscreen graphics. See logfile for details.", BUB_RED,
Colors.BUB_RED); "Exception while creating offscreen graphics. See logfile for details."
);
} }
// initialize music position bar location // initialize music position bar location
@ -1167,7 +1167,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);
BarNotifListener.EVENT.make().onBarNotif("Checkpoint saved."); barNotifs.send("Checkpoint saved.");
} }
} }
break; break;
@ -1179,7 +1179,7 @@ public class Game extends ComplexOpsuState {
break; // invalid checkpoint break; // invalid checkpoint
loadCheckpoint(checkpoint); loadCheckpoint(checkpoint);
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
BarNotifListener.EVENT.make().onBarNotif("Checkpoint loaded."); barNotifs.send("Checkpoint loaded.");
} }
break; break;
case KEY_F: case KEY_F:
@ -1222,12 +1222,12 @@ public class Game extends ComplexOpsuState {
break; break;
case KEY_MINUS: case KEY_MINUS:
currentMapMusicOffset += 5; currentMapMusicOffset += 5;
BarNotifListener.EVENT.make().onBarNotif("Current map offset: " + currentMapMusicOffset); barNotifs.send("Current map offset: " + currentMapMusicOffset);
break; break;
} }
if (key == KEY_ADD || c == '+') { if (key == KEY_ADD || c == '+') {
currentMapMusicOffset -= 5; currentMapMusicOffset -= 5;
BarNotifListener.EVENT.make().onBarNotif("Current map offset: " + currentMapMusicOffset); barNotifs.send("Current map offset: " + currentMapMusicOffset);
} }
return true; return true;
@ -1447,8 +1447,9 @@ public class Game extends ComplexOpsuState {
} }
if (beatmap == null || beatmap.objects == null) { if (beatmap == null || beatmap.objects == null) {
BubNotifListener.EVENT.make().onBubNotif("Game was running without a beatmap", Colors.BUB_RED); bubNotifs.send(BUB_RED, "Game was running without a beatmap");
displayContainer.switchStateInstantly(songMenuState); displayContainer.switchStateInstantly(songMenuState);
return;
} }
Dancer.instance.reset(); Dancer.instance.reset();
@ -1554,7 +1555,7 @@ 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);
BubNotifListener.EVENT.make().onBubNotif(message, Colors.BUB_RED); bubNotifs.send(BUB_RED, message);
gameObjects[i] = new DummyObject(hitObject); gameObjects[i] = new DummyObject(hitObject);
} }
} }
@ -2138,15 +2139,16 @@ public class Game extends ComplexOpsuState {
if (replay == null) { if (replay == null) {
this.isReplay = false; this.isReplay = false;
this.replay = null; this.replay = null;
} else { return;
if (replay.frames == null) {
BubNotifListener.EVENT.make().onBubNotif("Attempting to set a replay with no frames.",
Colors.BUB_ORANGE);
return;
}
this.isReplay = true;
this.replay = replay;
} }
if (replay.frames == null) {
bubNotifs.send(BUB_ORANGE, "Attempting to set a replay with no frames.");
return;
}
this.isReplay = true;
this.replay = replay;
} }
/** /**

View File

@ -38,7 +38,6 @@ 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.state.BaseOpsuState; import yugecin.opsudance.core.state.BaseOpsuState;
import yugecin.opsudance.events.BarNotifListener;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
@ -157,14 +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) {
BarNotifListener.EVENT.make().onBarNotif("Replay file not found."); barNotifs.send("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);
BarNotifListener.EVENT.make().onBarNotif( barNotifs.send("Failed to load replay data. See log for details.");
"Failed to load replay data. See log for details.");
} }
} else } else {
BarNotifListener.EVENT.make().onBarNotif("Replay file not found."); barNotifs.send("Replay file not found.");
}
} }
// retry // retry

View File

@ -48,9 +48,8 @@ import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.Constants; import yugecin.opsudance.core.Constants;
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.BarNotifListener;
import yugecin.opsudance.events.BubNotifListener;
import static itdelatrisu.opsu.ui.Colors.*;
import static org.lwjgl.input.Keyboard.*; import static org.lwjgl.input.Keyboard.*;
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,9 +465,9 @@ 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) {
BarNotifListener.EVENT.make().onBarNotif("An opsu! update is available."); barNotifs.send("An opsu! update is available.");
} else if (updater.justUpdated()) { } else if (updater.justUpdated()) {
BarNotifListener.EVENT.make().onBarNotif("opsu! is now up to date!"); barNotifs.send("opsu! is now up to date!");
} }
enterNotification = true; enterNotification = true;
} }
@ -531,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();
BarNotifListener.EVENT.make().onBarNotif("Pause"); barNotifs.send("Pause");
} else if (!MusicController.isTrackLoading()) { } else if (!MusicController.isTrackLoading()) {
MusicController.resume(); MusicController.resume();
BarNotifListener.EVENT.make().onBarNotif("Play"); barNotifs.send("Play");
} }
return true; return true;
} else if (musicNext.contains(x, y)) { } else if (musicNext.contains(x, y)) {
nextTrack(true); nextTrack(true);
BarNotifListener.EVENT.make().onBarNotif(">> Next"); barNotifs.send(">> Next");
return true; return true;
} else if (musicPrevious.contains(x, y)) { } else if (musicPrevious.contains(x, y)) {
lastMeasureProgress = 0f; lastMeasureProgress = 0f;
@ -551,7 +550,7 @@ public class MainMenu extends BaseOpsuState {
} else { } else {
MusicController.setPosition(0); MusicController.setPosition(0);
} }
BarNotifListener.EVENT.make().onBarNotif("<< Previous"); barNotifs.send("<< Previous");
return true; return true;
} }
@ -567,11 +566,10 @@ 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) {
BarNotifListener.EVENT.make().onBarNotif( barNotifs.send("The repository web page could not be opened.");
"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);
BubNotifListener.EVENT.make().onBubNotif("Could not browse to repo", Colors.BUB_ORANGE); bubNotifs.send(BUB_ORANGE, "Could not browse to repo");
} }
return true; return true;
} }
@ -580,11 +578,10 @@ 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) {
BarNotifListener.EVENT.make().onBarNotif( barNotifs.send("The repository web page could not be opened.");
"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);
BubNotifListener.EVENT.make().onBubNotif("Could not browse to repo", Colors.BUB_ORANGE); bubNotifs.send(BUB_ORANGE, "Could not browse to repo");
} }
return true; return true;
} }

View File

@ -64,7 +64,6 @@ 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.state.ComplexOpsuState; import yugecin.opsudance.core.state.ComplexOpsuState;
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;
@ -446,8 +445,7 @@ public class SongMenu extends ComplexOpsuState {
if (!displayContainer.isInState(SongMenu.class)) { if (!displayContainer.isInState(SongMenu.class)) {
return; return;
} }
BarNotifListener.EVENT.make().onBarNotif( barNotifs.send("Changes in Songs folder detected. Hit F5 to refresh.");
"Changed is Songs folder detected. Hit F5 to refresh.");
} }
}); });
@ -955,7 +953,7 @@ 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) {
BarNotifListener.EVENT.make().onBarNotif(group.getEmptyMessage()); barNotifs.send(group.getEmptyMessage());
} }
return true; return true;
} }
@ -1761,7 +1759,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()) {
BarNotifListener.EVENT.make().onBarNotif("Unable to load the beatmap audio."); barNotifs.send("Unable to load the beatmap audio.");
return; return;
} }

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,7 +26,6 @@ import itdelatrisu.opsu.downloads.DownloadNode;
import itdelatrisu.opsu.downloads.Updater; import itdelatrisu.opsu.downloads.Updater;
import itdelatrisu.opsu.render.CurveRenderState; import itdelatrisu.opsu.render.CurveRenderState;
import itdelatrisu.opsu.replay.PlaybackSpeed; import itdelatrisu.opsu.replay.PlaybackSpeed;
import itdelatrisu.opsu.ui.Colors;
import itdelatrisu.opsu.ui.Cursor; import itdelatrisu.opsu.ui.Cursor;
import itdelatrisu.opsu.ui.Fonts; import itdelatrisu.opsu.ui.Fonts;
import itdelatrisu.opsu.ui.UI; import itdelatrisu.opsu.ui.UI;
@ -43,16 +42,15 @@ import org.newdawn.slick.opengl.renderer.SGL;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.errorhandling.ErrorDumpable; import yugecin.opsudance.core.errorhandling.ErrorDumpable;
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.BubNotifState;
import yugecin.opsudance.core.state.specialstates.FpsRenderState;
import yugecin.opsudance.events.BubNotifListener;
import yugecin.opsudance.events.ResolutionChangedListener; import yugecin.opsudance.events.ResolutionChangedListener;
import yugecin.opsudance.events.SkinChangedListener; import yugecin.opsudance.events.SkinChangedListener;
import yugecin.opsudance.utils.GLHelper; import yugecin.opsudance.utils.GLHelper;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.Entrypoint.sout; import static yugecin.opsudance.core.Entrypoint.sout;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
@ -60,14 +58,10 @@ import static yugecin.opsudance.options.Options.*;
/** /**
* based on org.newdawn.slick.AppGameContainer * based on org.newdawn.slick.AppGameContainer
*/ */
public class DisplayContainer implements ErrorDumpable, ResolutionChangedListener, SkinChangedListener { public class DisplayContainer implements ErrorDumpable, SkinChangedListener {
private static SGL GL = Renderer.get(); private static SGL GL = Renderer.get();
private FpsRenderState fpsState;
private BarNotificationState barNotifState;
private BubNotifState bubNotifState;
private OpsuState state; private OpsuState state;
public final DisplayMode nativeDisplayMode; public final DisplayMode nativeDisplayMode;
@ -104,6 +98,8 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
public final Cursor cursor; public final Cursor cursor;
public boolean drawCursor; public boolean drawCursor;
private final List<ResolutionChangedListener> resolutionChangedListeners;
class Transition { class Transition {
int in; int in;
@ -145,12 +141,13 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
private final Transition transition = new Transition(); private final Transition transition = new Transition();
public DisplayContainer() { public DisplayContainer()
{
this.resolutionChangedListeners = new ArrayList<>();
this.cursor = new Cursor(); this.cursor = new Cursor();
drawCursor = true; drawCursor = true;
ResolutionChangedListener.EVENT.addListener(this); skinservice.addSkinChangedListener(this);
SkinChangedListener.EVENT.addListener(this);
this.nativeDisplayMode = Display.getDisplayMode(); this.nativeDisplayMode = Display.getDisplayMode();
targetBackgroundRenderInterval = 41; // ~24 fps targetBackgroundRenderInterval = 41; // ~24 fps
@ -159,10 +156,9 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
renderDelta = 1; renderDelta = 1;
} }
@Override public void addResolutionChangedListener(ResolutionChangedListener l)
public void onResolutionChanged(int w, int h) { {
destroyImages(); this.resolutionChangedListeners.add(l);
reinit();
} }
@Override @Override
@ -208,10 +204,6 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
setUPS(OPTION_TARGET_UPS.val); setUPS(OPTION_TARGET_UPS.val);
setFPS(targetFPS[targetFPSIndex]); setFPS(targetFPS[targetFPSIndex]);
fpsState = new FpsRenderState();
bubNotifState = new BubNotifState();
barNotifState = new BarNotificationState();
state = startingState; state = startingState;
state.enter(); state.enter();
} }
@ -229,7 +221,7 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
mouseY = input.getMouseY(); mouseY = input.getMouseY();
transition.update(); transition.update();
fpsState.update(); fpsDisplay.update();
state.update(); state.update();
if (drawCursor) { if (drawCursor) {
@ -257,9 +249,9 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
state.preRenderUpdate(); state.preRenderUpdate();
state.render(graphics); state.render(graphics);
fpsState.render(graphics); fpsDisplay.render(graphics);
bubNotifState.render(graphics); bubNotifs.render(graphics);
barNotifState.render(graphics); barNotifs.render(graphics);
cursor.updateAngle(renderDelta); cursor.updateAngle(renderDelta);
if (drawCursor) { if (drawCursor) {
@ -342,13 +334,13 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
return true; return true;
} }
if (DownloadList.get().hasActiveDownloads()) { if (DownloadList.get().hasActiveDownloads()) {
BubNotifListener.EVENT.make().onBubNotif(DownloadList.EXIT_CONFIRMATION, Colors.BUB_RED); bubNotifs.send(BUB_RED, DownloadList.EXIT_CONFIRMATION);
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) {
BubNotifListener.EVENT.make().onBubNotif(Updater.EXIT_CONFIRMATION, Colors.BUB_PURPLE); bubNotifs.send(BUB_PURPLE, Updater.EXIT_CONFIRMATION);
exitRequested = false; exitRequested = false;
exitconfirmation = System.currentTimeMillis(); exitconfirmation = System.currentTimeMillis();
return false; return false;
@ -387,7 +379,7 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
try { try {
setDisplayMode(width, height, OPTION_FULLSCREEN.state); setDisplayMode(width, height, OPTION_FULLSCREEN.state);
} catch (Exception e) { } catch (Exception e) {
BubNotifListener.EVENT.make().onBubNotif("Failed to change resolution", Colors.BUB_RED); bubNotifs.send(BUB_RED, "Failed to change resolution");
Log.error("Failed to set display mode.", e); Log.error("Failed to set display mode.", e);
} }
} }
@ -409,7 +401,7 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
fullscreen = false; fullscreen = false;
String msg = String.format("Fullscreen mode is not supported for %sx%s", width, height); String msg = String.format("Fullscreen mode is not supported for %sx%s", width, height);
Log.warn(msg); Log.warn(msg);
BubNotifListener.EVENT.make().onBubNotif(msg, Colors.BUB_ORANGE); bubNotifs.send(BUB_ORANGE, msg);
} }
} }
@ -439,7 +431,7 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
input = new Input(height); input = new Input(height);
input.enableKeyRepeat(); input.enableKeyRepeat();
input.addListener(new GlobalInputListener()); input.addListener(new GlobalInputListener());
input.addMouseListener(bubNotifState); input.addMouseListener(bubNotifs);
} }
input.addListener(state); input.addListener(state);
@ -448,7 +440,15 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
GameImage.init(width, height); GameImage.init(width, height);
Fonts.init(); Fonts.init();
ResolutionChangedListener.EVENT.make().onResolutionChanged(width, height); destroyImages();
reinit();
barNotifs.onResolutionChanged(width, height);
bubNotifs.onResolutionChanged(width, height);
fpsDisplay.onResolutionChanged(width, height);
for (ResolutionChangedListener l : this.resolutionChangedListeners) {
l.onResolutionChanged(width, height);
}
} }
public void resetCursor() { public void resetCursor() {

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,7 +21,6 @@ import itdelatrisu.opsu.states.Game;
import itdelatrisu.opsu.ui.UI; import itdelatrisu.opsu.ui.UI;
import org.newdawn.slick.Input; import org.newdawn.slick.Input;
import org.newdawn.slick.InputListener; import org.newdawn.slick.InputListener;
import yugecin.opsudance.events.BarNotifListener;
import static org.lwjgl.input.Keyboard.*; import static org.lwjgl.input.Keyboard.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
@ -38,8 +37,8 @@ public class GlobalInputListener implements InputListener {
public boolean keyReleased(int key, char c) { public boolean keyReleased(int key, char c) {
if (key == KEY_F7) { if (key == KEY_F7) {
OPTION_TARGET_FPS.clickListItem((targetFPSIndex + 1) % targetFPS.length); OPTION_TARGET_FPS.clickListItem((targetFPSIndex + 1) % targetFPS.length);
BarNotifListener.EVENT.make().onBarNotif(String.format("Frame limiter: %s", final String value = OPTION_TARGET_FPS.getValueString();
OPTION_TARGET_FPS.getValueString())); barNotifs.sendf("Frame limiter: %s", value);
return true; return true;
} }
if (key == KEY_F10) { if (key == KEY_F10) {

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,6 +26,10 @@ import itdelatrisu.opsu.states.*;
import org.newdawn.slick.Input; import org.newdawn.slick.Input;
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.state.specialstates.BarNotificationState;
import yugecin.opsudance.core.state.specialstates.BubNotifState;
import yugecin.opsudance.core.state.specialstates.FpsRenderState;
import yugecin.opsudance.options.Configuration; import yugecin.opsudance.options.Configuration;
import yugecin.opsudance.options.OptionsService; import yugecin.opsudance.options.OptionsService;
import yugecin.opsudance.render.GameObjectRenderer; import yugecin.opsudance.render.GameObjectRenderer;
@ -55,6 +59,10 @@ public class InstanceContainer {
public static Input input; public static Input input;
public static GameObjectRenderer gameObjectRenderer; public static GameObjectRenderer gameObjectRenderer;
public static BarNotificationState barNotifs;
public static BubNotifState bubNotifs;
public static FpsRenderState fpsDisplay;
public static Splash splashState; public static Splash splashState;
public static MainMenu mainmenuState; public static MainMenu mainmenuState;
@ -94,6 +102,10 @@ public class InstanceContainer {
updater = new Updater(); updater = new Updater();
displayContainer = new DisplayContainer(); displayContainer = new DisplayContainer();
barNotifs = new BarNotificationState();
bubNotifs = new BubNotifState();
fpsDisplay = new FpsRenderState();
gameObjectRenderer = new GameObjectRenderer(); gameObjectRenderer = new GameObjectRenderer();

View File

@ -1,53 +0,0 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core.events;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.LinkedList;
@SuppressWarnings("unchecked")
public class Event<T> {
private final Class<T> type;
private final LinkedList<T> listeners;
public Event(Class<T> type) {
this.type = type;
this.listeners = new LinkedList<>();
}
public void addListener(T listener) {
this.listeners.add(listener);
}
public T make() {
return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
for (T listener : listeners) {
method.invoke(listener, args);
}
return null;
}
});
}
}

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -22,6 +22,8 @@ import yugecin.opsudance.events.ResolutionChangedListener;
import java.io.StringWriter; import java.io.StringWriter;
import static yugecin.opsudance.core.InstanceContainer.*;
public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListener { public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListener {
/** /**
@ -31,7 +33,7 @@ public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListe
private boolean isCurrentState; private boolean isCurrentState;
public BaseOpsuState() { public BaseOpsuState() {
ResolutionChangedListener.EVENT.addListener(this); displayContainer.addResolutionChangedListener(this);
} }
protected void revalidate() { protected void revalidate() {

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,14 +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.events.BarNotifListener;
import yugecin.opsudance.events.ResolutionChangedListener; import yugecin.opsudance.events.ResolutionChangedListener;
import java.util.Formatter;
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 BarNotifListener, ResolutionChangedListener { public class BarNotificationState implements 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;
@ -51,8 +51,6 @@ public class BarNotificationState implements BarNotifListener, ResolutionChanged
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;
BarNotifListener.EVENT.addListener(this);
ResolutionChangedListener.EVENT.addListener(this);
} }
public void render(Graphics g) { public void render(Graphics g) {
@ -95,9 +93,13 @@ public class BarNotificationState implements BarNotifListener, ResolutionChanged
textY = (displayContainer.height - textHeight) / 2 + (int) (Fonts.LARGE.getLineHeight() / 5f); textY = (displayContainer.height - textHeight) / 2 + (int) (Fonts.LARGE.getLineHeight() / 5f);
barHalfTargetHeight = textHeight / 2; barHalfTargetHeight = textHeight / 2;
} }
@SuppressWarnings("resource")
public void sendf(String format, Object... args) {
this.send(new Formatter().format(format, args).toString());
}
@Override public void send(String message) {
public void onBarNotif(String message) {
this.message = message; this.message = message;
calculatePosition(); calculatePosition();
timeShown = 0; timeShown = 0;

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -22,16 +22,16 @@ 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 org.newdawn.slick.MouseListener; import org.newdawn.slick.MouseListener;
import yugecin.opsudance.events.BubNotifListener;
import yugecin.opsudance.events.ResolutionChangedListener; import yugecin.opsudance.events.ResolutionChangedListener;
import java.util.Formatter;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
public class BubNotifState implements MouseListener, BubNotifListener, ResolutionChangedListener { public class BubNotifState implements MouseListener, ResolutionChangedListener {
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;
@ -46,8 +46,6 @@ public class BubNotifState implements MouseListener, BubNotifListener, Resolutio
public BubNotifState() { public BubNotifState() {
this.bubbles = new LinkedList<>(); this.bubbles = new LinkedList<>();
this.addAnimationTime = IN_TIME; this.addAnimationTime = IN_TIME;
BubNotifListener.EVENT.addListener(this);
ResolutionChangedListener.EVENT.addListener(this);
} }
public void render(Graphics g) { public void render(Graphics g) {
@ -111,8 +109,12 @@ public class BubNotifState implements MouseListener, BubNotifListener, Resolutio
addAnimationTime = IN_TIME; addAnimationTime = IN_TIME;
} }
@Override @SuppressWarnings("resource")
public void onBubNotif(String message, Color borderColor) { public void sendf(Color borderColor, String format, Object... args) {
this.send(borderColor, new Formatter().format(format, args).toString());
}
public void send(Color borderColor, String message) {
finishAddAnimation(); finishAddAnimation();
Notification newBubble = new Notification(message, borderColor); Notification newBubble = new Notification(message, borderColor);
bubbles.add(0, newBubble); bubbles.add(0, newBubble);

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -42,7 +42,6 @@ public class FpsRenderState implements ResolutionChangedListener {
public FpsRenderState() { public FpsRenderState() {
fpsMeter = new FPSMeter(10); fpsMeter = new FPSMeter(10);
upsMeter = new FPSMeter(10); upsMeter = new FPSMeter(10);
ResolutionChangedListener.EVENT.addListener(this);
} }
public void update() { public void update() {

View File

@ -1,28 +0,0 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.events;
import yugecin.opsudance.core.events.Event;
public interface BarNotifListener {
Event<BarNotifListener> EVENT = new Event<>(BarNotifListener.class);
void onBarNotif(String message);
}

View File

@ -1,30 +0,0 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.events;
import org.newdawn.slick.Color;
import yugecin.opsudance.core.events.Event;
@SuppressWarnings({"UnnecessaryInterfaceModifier", "unused"})
public interface BubNotifListener {
Event<BubNotifListener> EVENT = new Event<>(BubNotifListener.class);
void onBubNotif(String message, Color borderColor);
}

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,12 +17,7 @@
*/ */
package yugecin.opsudance.events; package yugecin.opsudance.events;
import yugecin.opsudance.core.events.Event; public interface ResolutionChangedListener
{
public interface ResolutionChangedListener {
Event<ResolutionChangedListener> EVENT = new Event<>(ResolutionChangedListener.class);
void onResolutionChanged(int w, int h); void onResolutionChanged(int w, int h);
} }

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,12 +17,8 @@
*/ */
package yugecin.opsudance.events; package yugecin.opsudance.events;
import yugecin.opsudance.core.events.Event; public interface SkinChangedListener
{
public interface SkinChangedListener {
Event<SkinChangedListener> EVENT = new Event<>(SkinChangedListener.class);
void onSkinChanged(String stringName); void onSkinChanged(String stringName);
} }

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -24,12 +24,10 @@ 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.TimingPoint; import itdelatrisu.opsu.beatmap.TimingPoint;
import itdelatrisu.opsu.ui.Colors;
import org.lwjgl.BufferUtils; 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 org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BubNotifListener;
import yugecin.opsudance.utils.ManifestWrapper; import yugecin.opsudance.utils.ManifestWrapper;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -42,6 +40,7 @@ import java.util.Date;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*; import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
@ -155,7 +154,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());
BubNotifListener.EVENT.make().onBubNotif(msg, Colors.BUB_RED); bubNotifs.send(BUB_RED, msg);
} }
return defaultDir; return defaultDir;
} }
@ -215,9 +214,11 @@ 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()) {
BubNotifListener.EVENT.make().onBubNotif( bubNotifs.sendf(
String.format( "Failed to create screenshot directory at '%s'.", BUB_RED,
screenshotDir.getAbsolutePath()), Colors.BUB_RED); "Failed to create screenshot directory at '%s'.",
screenshotDir.getAbsolutePath()
);
return; return;
} }
@ -251,13 +252,13 @@ public class Configuration {
} }
} }
ImageIO.write(image, OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase(), file); ImageIO.write(image, OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase(), file);
BubNotifListener.EVENT.make().onBubNotif("Created " + fileName, bubNotifs.send(BUB_PURPLE, "Created " + fileName);
Colors.BUB_PURPLE);
} catch (Exception e) { } catch (Exception e) {
Log.error("Could not take screenshot", e); Log.error("Could not take screenshot", e);
BubNotifListener.EVENT.make().onBubNotif( bubNotifs.send(
"Failed to take a screenshot. See log file for details", BUB_PURPLE,
Colors.BUB_PURPLE); "Failed to take a screenshot. See log file for details"
);
} }
} }
}.start(); }.start();

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -18,8 +18,9 @@
package yugecin.opsudance.options; package yugecin.opsudance.options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.ui.Colors;
import yugecin.opsudance.events.BubNotifListener; import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.InstanceContainer.*;
public class NumericOption extends Option { public class NumericOption extends Option {
@ -53,8 +54,7 @@ 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) {
BubNotifListener.EVENT.make().onBubNotif("Failed to parse " + configurationName + " option", bubNotifs.send(BUB_RED, "Failed to parse '" + configurationName + "' option");
Colors.BUB_RED);
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -27,7 +27,6 @@ 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.events.BarNotifListener;
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,7 @@ 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() {
BarNotifListener.EVENT.make().onBarNotif(state ? barNotifs.send(state ?
"Mouse buttons are disabled." : "Mouse buttons are enabled."); "Mouse buttons are disabled." : "Mouse buttons are enabled.");
} }
}; };
@ -608,7 +607,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
BarNotifListener.EVENT.make().onBarNotif("This mover is disabled in the storyboard right now"); barNotifs.send("This mover is disabled in the storyboard right now");
return; return;
} }
Dancer.instance.setMoverFactoryIndex(index); Dancer.instance.setMoverFactoryIndex(index);

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,15 +17,14 @@
*/ */
package yugecin.opsudance.options; package yugecin.opsudance.options;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BubNotifListener;
import java.io.*; import java.io.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
/** /**
@ -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);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED); bubNotifs.send(BUB_RED, err);
} }
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);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED); bubNotifs.send(BUB_RED, err);
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin * Copyright (C) 2016-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,7 +25,6 @@ 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.state.OverlayOpsuState; import yugecin.opsudance.core.state.OverlayOpsuState;
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;
@ -35,6 +34,8 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import static yugecin.opsudance.core.InstanceContainer.*;
public class MoveStoryboard extends OverlayOpsuState{ public class MoveStoryboard extends OverlayOpsuState{
private final DisplayContainer displayContainer; private final DisplayContainer displayContainer;
@ -185,7 +186,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()) {
BarNotifListener.EVENT.make().onBarNotif("Wait until the slider ended"); barNotifs.send("Wait until the slider ended");
return dummyMove; return dummyMove;
} }
if (moves[objectIndex] == null) { if (moves[objectIndex] == null) {

View File

@ -1,6 +1,6 @@
/* /*
* opsu!dance - fork of opsu! with cursordance auto * opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin * Copyright (C) 2017-2018 yugecin
* *
* opsu!dance is free software: you can redistribute it and/or modify * opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,21 +26,39 @@ import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.events.SkinChangedListener; import yugecin.opsudance.events.SkinChangedListener;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.List;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
/** /**
* @author itdelatrisu (https://github.com/itdelatrisu) most functions are copied from itdelatrisu.opsu.Options.java * @author itdelatrisu (https://github.com/itdelatrisu) most functions are copied from itdelatrisu.opsu.Options.java
*/ */
public class SkinService { public class SkinService
{
private final List<SkinChangedListener> skinChangedListeners;
public String[] availableSkinDirectories; public String[] availableSkinDirectories;
public String usedSkinName = "Default"; public String usedSkinName = "Default";
public static Skin skin; public static Skin skin;
public SkinService()
{
this.skinChangedListeners = new ArrayList<>();
}
public void addSkinChangedListener(SkinChangedListener l)
{
this.skinChangedListeners.add(l);
}
public void reloadSkin() { public void reloadSkin()
{
loadSkin(); loadSkin();
SoundController.init(); SoundController.init();
SkinChangedListener.EVENT.make().onSkinChanged(usedSkinName); for (SkinChangedListener l : this.skinChangedListeners) {
l.onSkinChanged(this.usedSkinName);
}
} }
/** /**