overhaul event system
This commit is contained in:
@@ -21,17 +21,15 @@ import itdelatrisu.opsu.states.Game;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Input;
|
||||
import yugecin.opsudance.core.events.EventBus;
|
||||
import yugecin.opsudance.core.events.EventListener;
|
||||
import yugecin.opsudance.events.BarNotificationEvent;
|
||||
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
|
||||
import yugecin.opsudance.events.BarNotifListener;
|
||||
import yugecin.opsudance.events.ResolutionChangedListener;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
public abstract class BaseOpsuState implements OpsuState, EventListener<ResolutionOrSkinChangedEvent> {
|
||||
public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListener {
|
||||
|
||||
/**
|
||||
* state is dirty when resolution or skin changed but hasn't rendered yet
|
||||
@@ -40,7 +38,7 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
|
||||
private boolean isCurrentState;
|
||||
|
||||
public BaseOpsuState() {
|
||||
EventBus.subscribe(ResolutionOrSkinChangedEvent.class, this);
|
||||
ResolutionChangedListener.EVENT.addListener(this);
|
||||
}
|
||||
|
||||
protected void revalidate() {
|
||||
@@ -59,7 +57,7 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(ResolutionOrSkinChangedEvent event) {
|
||||
public void onResolutionChanged(int w, int h) {
|
||||
if (isCurrentState) {
|
||||
revalidate();
|
||||
return;
|
||||
@@ -95,7 +93,8 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
|
||||
public boolean keyReleased(int key, char c) {
|
||||
if (key == Input.KEY_F7) {
|
||||
OPTION_TARGET_FPS.clickListItem((targetFPSIndex + 1) % targetFPS.length);
|
||||
EventBus.post(new BarNotificationEvent(String.format("Frame limiter: %s", OPTION_TARGET_FPS.getValueString())));
|
||||
BarNotifListener.EVENT.make().onBarNotif(String.format("Frame limiter: %s",
|
||||
OPTION_TARGET_FPS.getValueString()));
|
||||
return true;
|
||||
}
|
||||
if (key == Input.KEY_F10) {
|
||||
|
||||
Reference in New Issue
Block a user