remove unnecessary events pattern and replace it with something more simple
This commit is contained in:
@@ -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
|
||||
@@ -26,7 +26,6 @@ import itdelatrisu.opsu.downloads.DownloadNode;
|
||||
import itdelatrisu.opsu.downloads.Updater;
|
||||
import itdelatrisu.opsu.render.CurveRenderState;
|
||||
import itdelatrisu.opsu.replay.PlaybackSpeed;
|
||||
import itdelatrisu.opsu.ui.Colors;
|
||||
import itdelatrisu.opsu.ui.Cursor;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
@@ -43,16 +42,15 @@ import org.newdawn.slick.opengl.renderer.SGL;
|
||||
import org.newdawn.slick.util.Log;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorDumpable;
|
||||
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.SkinChangedListener;
|
||||
import yugecin.opsudance.utils.GLHelper;
|
||||
|
||||
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.InstanceContainer.*;
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
@@ -60,14 +58,10 @@ import static yugecin.opsudance.options.Options.*;
|
||||
/**
|
||||
* 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 FpsRenderState fpsState;
|
||||
private BarNotificationState barNotifState;
|
||||
private BubNotifState bubNotifState;
|
||||
|
||||
private OpsuState state;
|
||||
|
||||
public final DisplayMode nativeDisplayMode;
|
||||
@@ -104,6 +98,8 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
|
||||
public final Cursor cursor;
|
||||
public boolean drawCursor;
|
||||
|
||||
private final List<ResolutionChangedListener> resolutionChangedListeners;
|
||||
|
||||
class Transition {
|
||||
int in;
|
||||
@@ -145,12 +141,13 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
|
||||
private final Transition transition = new Transition();
|
||||
|
||||
public DisplayContainer() {
|
||||
public DisplayContainer()
|
||||
{
|
||||
this.resolutionChangedListeners = new ArrayList<>();
|
||||
this.cursor = new Cursor();
|
||||
drawCursor = true;
|
||||
|
||||
ResolutionChangedListener.EVENT.addListener(this);
|
||||
SkinChangedListener.EVENT.addListener(this);
|
||||
skinservice.addSkinChangedListener(this);
|
||||
|
||||
this.nativeDisplayMode = Display.getDisplayMode();
|
||||
targetBackgroundRenderInterval = 41; // ~24 fps
|
||||
@@ -159,10 +156,9 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
renderDelta = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResolutionChanged(int w, int h) {
|
||||
destroyImages();
|
||||
reinit();
|
||||
public void addResolutionChangedListener(ResolutionChangedListener l)
|
||||
{
|
||||
this.resolutionChangedListeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,10 +204,6 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
setUPS(OPTION_TARGET_UPS.val);
|
||||
setFPS(targetFPS[targetFPSIndex]);
|
||||
|
||||
fpsState = new FpsRenderState();
|
||||
bubNotifState = new BubNotifState();
|
||||
barNotifState = new BarNotificationState();
|
||||
|
||||
state = startingState;
|
||||
state.enter();
|
||||
}
|
||||
@@ -229,7 +221,7 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
mouseY = input.getMouseY();
|
||||
|
||||
transition.update();
|
||||
fpsState.update();
|
||||
fpsDisplay.update();
|
||||
|
||||
state.update();
|
||||
if (drawCursor) {
|
||||
@@ -257,9 +249,9 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
|
||||
state.preRenderUpdate();
|
||||
state.render(graphics);
|
||||
fpsState.render(graphics);
|
||||
bubNotifState.render(graphics);
|
||||
barNotifState.render(graphics);
|
||||
fpsDisplay.render(graphics);
|
||||
bubNotifs.render(graphics);
|
||||
barNotifs.render(graphics);
|
||||
|
||||
cursor.updateAngle(renderDelta);
|
||||
if (drawCursor) {
|
||||
@@ -342,13 +334,13 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
return true;
|
||||
}
|
||||
if (DownloadList.get().hasActiveDownloads()) {
|
||||
BubNotifListener.EVENT.make().onBubNotif(DownloadList.EXIT_CONFIRMATION, Colors.BUB_RED);
|
||||
bubNotifs.send(BUB_RED, DownloadList.EXIT_CONFIRMATION);
|
||||
exitRequested = false;
|
||||
exitconfirmation = System.currentTimeMillis();
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
exitconfirmation = System.currentTimeMillis();
|
||||
return false;
|
||||
@@ -387,7 +379,7 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
try {
|
||||
setDisplayMode(width, height, OPTION_FULLSCREEN.state);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
@@ -409,7 +401,7 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
fullscreen = false;
|
||||
String msg = String.format("Fullscreen mode is not supported for %sx%s", width, height);
|
||||
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.enableKeyRepeat();
|
||||
input.addListener(new GlobalInputListener());
|
||||
input.addMouseListener(bubNotifState);
|
||||
input.addMouseListener(bubNotifs);
|
||||
}
|
||||
input.addListener(state);
|
||||
|
||||
@@ -448,7 +440,15 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||
GameImage.init(width, height);
|
||||
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() {
|
||||
|
||||
@@ -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
|
||||
@@ -21,7 +21,6 @@ import itdelatrisu.opsu.states.Game;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.InputListener;
|
||||
import yugecin.opsudance.events.BarNotifListener;
|
||||
|
||||
import static org.lwjgl.input.Keyboard.*;
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
@@ -38,8 +37,8 @@ public class GlobalInputListener implements InputListener {
|
||||
public boolean keyReleased(int key, char c) {
|
||||
if (key == KEY_F7) {
|
||||
OPTION_TARGET_FPS.clickListItem((targetFPSIndex + 1) % targetFPS.length);
|
||||
BarNotifListener.EVENT.make().onBarNotif(String.format("Frame limiter: %s",
|
||||
OPTION_TARGET_FPS.getValueString()));
|
||||
final String value = OPTION_TARGET_FPS.getValueString();
|
||||
barNotifs.sendf("Frame limiter: %s", value);
|
||||
return true;
|
||||
}
|
||||
if (key == KEY_F10) {
|
||||
|
||||
@@ -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
|
||||
@@ -26,6 +26,10 @@ import itdelatrisu.opsu.states.*;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.util.FileSystemLocation;
|
||||
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.OptionsService;
|
||||
import yugecin.opsudance.render.GameObjectRenderer;
|
||||
@@ -55,6 +59,10 @@ public class InstanceContainer {
|
||||
public static Input input;
|
||||
|
||||
public static GameObjectRenderer gameObjectRenderer;
|
||||
|
||||
public static BarNotificationState barNotifs;
|
||||
public static BubNotifState bubNotifs;
|
||||
public static FpsRenderState fpsDisplay;
|
||||
|
||||
public static Splash splashState;
|
||||
public static MainMenu mainmenuState;
|
||||
@@ -94,6 +102,10 @@ public class InstanceContainer {
|
||||
updater = new Updater();
|
||||
|
||||
displayContainer = new DisplayContainer();
|
||||
|
||||
barNotifs = new BarNotificationState();
|
||||
bubNotifs = new BubNotifState();
|
||||
fpsDisplay = new FpsRenderState();
|
||||
|
||||
gameObjectRenderer = new GameObjectRenderer();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
@@ -22,6 +22,8 @@ import yugecin.opsudance.events.ResolutionChangedListener;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListener {
|
||||
|
||||
/**
|
||||
@@ -31,7 +33,7 @@ public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListe
|
||||
private boolean isCurrentState;
|
||||
|
||||
public BaseOpsuState() {
|
||||
ResolutionChangedListener.EVENT.addListener(this);
|
||||
displayContainer.addResolutionChangedListener(this);
|
||||
}
|
||||
|
||||
protected void revalidate() {
|
||||
|
||||
@@ -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
|
||||
@@ -21,14 +21,14 @@ import itdelatrisu.opsu.ui.Fonts;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import yugecin.opsudance.events.BarNotifListener;
|
||||
import yugecin.opsudance.events.ResolutionChangedListener;
|
||||
|
||||
import java.util.Formatter;
|
||||
import java.util.List;
|
||||
|
||||
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 DISPLAY_TIME = 5700 + IN_TIME;
|
||||
@@ -51,8 +51,6 @@ public class BarNotificationState implements BarNotifListener, ResolutionChanged
|
||||
this.bgcol = new Color(Color.black);
|
||||
this.textCol = new Color(Color.white);
|
||||
this.timeShown = TOTAL_TIME;
|
||||
BarNotifListener.EVENT.addListener(this);
|
||||
ResolutionChangedListener.EVENT.addListener(this);
|
||||
}
|
||||
|
||||
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);
|
||||
barHalfTargetHeight = textHeight / 2;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public void sendf(String format, Object... args) {
|
||||
this.send(new Formatter().format(format, args).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBarNotif(String message) {
|
||||
public void send(String message) {
|
||||
this.message = message;
|
||||
calculatePosition();
|
||||
timeShown = 0;
|
||||
|
||||
@@ -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
|
||||
@@ -22,16 +22,16 @@ import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.MouseListener;
|
||||
import yugecin.opsudance.events.BubNotifListener;
|
||||
import yugecin.opsudance.events.ResolutionChangedListener;
|
||||
|
||||
import java.util.Formatter;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
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 DISPLAY_TIME = 7000 + IN_TIME;
|
||||
@@ -46,8 +46,6 @@ public class BubNotifState implements MouseListener, BubNotifListener, Resolutio
|
||||
public BubNotifState() {
|
||||
this.bubbles = new LinkedList<>();
|
||||
this.addAnimationTime = IN_TIME;
|
||||
BubNotifListener.EVENT.addListener(this);
|
||||
ResolutionChangedListener.EVENT.addListener(this);
|
||||
}
|
||||
|
||||
public void render(Graphics g) {
|
||||
@@ -111,8 +109,12 @@ public class BubNotifState implements MouseListener, BubNotifListener, Resolutio
|
||||
addAnimationTime = IN_TIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBubNotif(String message, Color borderColor) {
|
||||
@SuppressWarnings("resource")
|
||||
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();
|
||||
Notification newBubble = new Notification(message, borderColor);
|
||||
bubbles.add(0, newBubble);
|
||||
|
||||
@@ -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
|
||||
@@ -42,7 +42,6 @@ public class FpsRenderState implements ResolutionChangedListener {
|
||||
public FpsRenderState() {
|
||||
fpsMeter = new FPSMeter(10);
|
||||
upsMeter = new FPSMeter(10);
|
||||
ResolutionChangedListener.EVENT.addListener(this);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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,12 +17,7 @@
|
||||
*/
|
||||
package yugecin.opsudance.events;
|
||||
|
||||
import yugecin.opsudance.core.events.Event;
|
||||
|
||||
public interface ResolutionChangedListener {
|
||||
|
||||
Event<ResolutionChangedListener> EVENT = new Event<>(ResolutionChangedListener.class);
|
||||
|
||||
public interface ResolutionChangedListener
|
||||
{
|
||||
void onResolutionChanged(int w, int h);
|
||||
|
||||
}
|
||||
|
||||
@@ -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,12 +17,8 @@
|
||||
*/
|
||||
package yugecin.opsudance.events;
|
||||
|
||||
import yugecin.opsudance.core.events.Event;
|
||||
|
||||
public interface SkinChangedListener {
|
||||
|
||||
Event<SkinChangedListener> EVENT = new Event<>(SkinChangedListener.class);
|
||||
|
||||
public interface SkinChangedListener
|
||||
{
|
||||
void onSkinChanged(String stringName);
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
* 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 yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.core.state.OverlayOpsuState;
|
||||
import yugecin.opsudance.events.BarNotifListener;
|
||||
import yugecin.opsudance.sbv2.movers.CubicStoryboardMover;
|
||||
import yugecin.opsudance.sbv2.movers.LinearStoryboardMover;
|
||||
import yugecin.opsudance.sbv2.movers.QuadraticStoryboardMover;
|
||||
@@ -35,6 +34,8 @@ import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
public class MoveStoryboard extends OverlayOpsuState{
|
||||
|
||||
private final DisplayContainer displayContainer;
|
||||
@@ -185,7 +186,7 @@ public class MoveStoryboard extends OverlayOpsuState{
|
||||
|
||||
private StoryboardMove getCurrentMoveOrCreateNew() {
|
||||
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;
|
||||
}
|
||||
if (moves[objectIndex] == null) {
|
||||
|
||||
@@ -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
|
||||
@@ -26,21 +26,39 @@ import org.newdawn.slick.util.ResourceLoader;
|
||||
import yugecin.opsudance.events.SkinChangedListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
/**
|
||||
* @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 usedSkinName = "Default";
|
||||
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();
|
||||
SoundController.init();
|
||||
SkinChangedListener.EVENT.make().onSkinChanged(usedSkinName);
|
||||
for (SkinChangedListener l : this.skinChangedListeners) {
|
||||
l.onSkinChanged(this.usedSkinName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user