Reduced reflection usage / Improved event system

This commit is contained in:
Anuken
2018-08-31 16:14:14 -04:00
parent 522e19d4bf
commit 5cb50d57ec
24 changed files with 95 additions and 85 deletions

View File

@@ -34,7 +34,7 @@ public class FloatingDialog extends Dialog{
}
protected void onResize(Runnable run){
Events.on(ResizeEvent.class, () -> {
Events.on(ResizeEvent.class, event -> {
if(isShown()){
run.run();
}

View File

@@ -89,14 +89,12 @@ public class BlocksFragment extends Fragment{
}).bottom().right().get();
});
Events.on(WorldLoadEvent.class, this::rebuild);
Events.on(WorldLoadEvent.class, event -> rebuild());
rebuild();
}
/**
* Rebuilds the whole placement menu, attempting to preserve previous state.
*/
/**Rebuilds the whole placement menu, attempting to preserve previous state.*/
void rebuild(){
selectTable.clear();

View File

@@ -138,8 +138,8 @@ public class HudFragment extends Fragment{
parent.fill(t -> {
float notifDuration = 240f;
Events.on(StateChangeEvent.class, (from, to) -> {
if(to == State.menu || from == State.menu){
Events.on(StateChangeEvent.class, event -> {
if(event.to == State.menu || event.from == State.menu){
coreAttackTime = 0f;
lastCoreHP = Float.NaN;
}

View File

@@ -27,7 +27,7 @@ public class MenuFragment extends Fragment{
buildDesktop();
}else{
buildMobile();
Events.on(ResizeEvent.class, this::buildMobile);
Events.on(ResizeEvent.class, event -> buildMobile());
}
});