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
36 changed files with 227 additions and 330 deletions

View File

@@ -1,6 +1,6 @@
/*
* 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
* 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.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.TimingPoint;
import itdelatrisu.opsu.ui.Colors;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BubNotifListener;
import yugecin.opsudance.utils.ManifestWrapper;
import javax.imageio.ImageIO;
@@ -42,6 +40,7 @@ import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*;
@@ -155,7 +154,7 @@ public class Configuration {
}
if (!defaultDir.isDirectory() && !defaultDir.mkdir()) {
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;
}
@@ -215,9 +214,11 @@ public class Configuration {
// TODO: get a decent place for this
// create the screenshot directory
if (!screenshotDir.isDirectory() && !screenshotDir.mkdir()) {
BubNotifListener.EVENT.make().onBubNotif(
String.format( "Failed to create screenshot directory at '%s'.",
screenshotDir.getAbsolutePath()), Colors.BUB_RED);
bubNotifs.sendf(
BUB_RED,
"Failed to create screenshot directory at '%s'.",
screenshotDir.getAbsolutePath()
);
return;
}
@@ -251,13 +252,13 @@ public class Configuration {
}
}
ImageIO.write(image, OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase(), file);
BubNotifListener.EVENT.make().onBubNotif("Created " + fileName,
Colors.BUB_PURPLE);
bubNotifs.send(BUB_PURPLE, "Created " + fileName);
} catch (Exception e) {
Log.error("Could not take screenshot", e);
BubNotifListener.EVENT.make().onBubNotif(
"Failed to take a screenshot. See log file for details",
Colors.BUB_PURPLE);
bubNotifs.send(
BUB_PURPLE,
"Failed to take a screenshot. See log file for details"
);
}
}
}.start();

View File

@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU General Public License as published by
@@ -18,8 +18,9 @@
package yugecin.opsudance.options;
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 {
@@ -53,8 +54,7 @@ public class NumericOption extends Option {
try {
val = Utils.clamp(Integer.parseInt(s), min, max);
} catch (Exception ignored) {
BubNotifListener.EVENT.make().onBubNotif("Failed to parse " + configurationName + " option",
Colors.BUB_RED);
bubNotifs.send(BUB_RED, "Failed to parse '" + configurationName + "' option");
}
}

View File

@@ -1,6 +1,6 @@
/*
* 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
* 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.util.Log;
import yugecin.opsudance.*;
import yugecin.opsudance.events.BarNotifListener;
import yugecin.opsudance.movers.factories.ExgonMoverFactory;
import yugecin.opsudance.movers.factories.QuadraticBezierMoverFactory;
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) {
@Override
public void toggle() {
BarNotifListener.EVENT.make().onBarNotif(state ?
barNotifs.send(state ?
"Mouse buttons are disabled." : "Mouse buttons are enabled.");
}
};
@@ -608,7 +607,7 @@ public class Options {
public void clickListItem(int index){
if (Game.isInGame && Dancer.moverFactories[index] instanceof PolyMoverFactory) {
// 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;
}
Dancer.instance.setMoverFactoryIndex(index);

View File

@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU General Public License as published by
@@ -17,15 +17,14 @@
*/
package yugecin.opsudance.options;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BubNotifListener;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import static itdelatrisu.opsu.ui.Colors.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
@@ -80,7 +79,7 @@ public class OptionsService {
} catch (IOException e) {
String err = String.format("Failed to read option file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
Log.error(err, e);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
bubNotifs.send(BUB_RED, err);
}
config.loadDirectories();
}
@@ -109,7 +108,7 @@ public class OptionsService {
} catch (IOException e) {
String err = String.format("Failed to write to file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
Log.error(err, e);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
bubNotifs.send(BUB_RED, err);
}
}