Skip to content

Commit

Permalink
Rename events to suit the naming conventions
Browse files Browse the repository at this point in the history
- Events that provide a functional listener interface (with only one method) should begin with "on*"
  • Loading branch information
steffen-wilke committed Apr 10, 2020
1 parent 3af2988 commit 30093d7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/de/gurkenlabs/litiengine/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public final class Game {
private static boolean initialized;

static {
world.addLoadedListener(gameTime);
world.onLoaded(gameTime);
addGameListener(new InputGameAdapter());
}

Expand Down
8 changes: 4 additions & 4 deletions src/de/gurkenlabs/litiengine/environment/GameWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void removeListener(EnvironmentListener listener) {
* @param listener
* The listener to add.
*/
public void addLoadedListener(EnvironmentLoadedListener listener) {
public void onLoaded(EnvironmentLoadedListener listener) {
this.loadedListeners.add(listener);
}

Expand All @@ -131,7 +131,7 @@ public void removeLoadedListener(EnvironmentLoadedListener listener) {
* @param listener
* The listener to add.
*/
public void addUnloadedListener(EnvironmentUnloadedListener listener) {
public void onUnloaded(EnvironmentUnloadedListener listener) {
this.unloadedListeners.add(listener);
}

Expand All @@ -153,7 +153,7 @@ public void removeUnloadedListener(EnvironmentUnloadedListener listener) {
* @param listener
* The listener to add.
*/
public void addLoadedListener(String mapName, EnvironmentLoadedListener listener) {
public void onLoaded(String mapName, EnvironmentLoadedListener listener) {
add(this.environmentLoadedListeners, mapName, listener);
}

Expand All @@ -177,7 +177,7 @@ public void removeLoadedListener(String mapName, EnvironmentLoadedListener liste
* @param listener
* The listener to add.
*/
public void addUnloadedListener(String mapName, EnvironmentUnloadedListener listener) {
public void onUnloaded(String mapName, EnvironmentUnloadedListener listener) {
add(this.environmentUnloadedListeners, mapName, listener);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void loaded(Environment environment) {
public void testMapSpecificLoadedListeners() {
Status mapLoaded = new Status();

Game.world().addLoadedListener("test-map", e -> mapLoaded.wasCalled = true);
Game.world().onLoaded("test-map", e -> mapLoaded.wasCalled = true);

IMap map = Resources.maps().get("tests/de/gurkenlabs/litiengine/environment/tilemap/xml/test-map.tmx");

Expand All @@ -107,7 +107,7 @@ public void testMapSpecificLoadedListeners() {
public void testMapSpecificUnloadedListeners() {
Status mapUnloaded = new Status();

Game.world().addUnloadedListener("test-map", e -> mapUnloaded.wasCalled = true);
Game.world().onUnloaded("test-map", e -> mapUnloaded.wasCalled = true);

IMap map = Resources.maps().get("tests/de/gurkenlabs/litiengine/environment/tilemap/xml/test-map.tmx");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class LayerMenu extends JMenu {

public LayerMenu() {
super(Resources.strings().get("menu_move_to_layer"));
Game.world().addLoadedListener(e -> this.updateMenu(e.getMap()));
Game.world().onLoaded(e -> this.updateMenu(e.getMap()));

UI.getLayerController().onLayersChanged(this::updateMenu);
Editor.instance().getMapComponent().onSelectionChanged(this::updateMenuItemStates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class RenderMenu extends JMenu {
public RenderMenu() {
super(Resources.strings().get("menu_rendertype"));

Game.world().addLoadedListener(e -> this.setEnabled(false));
Game.world().onLoaded(e -> this.setEnabled(false));

UI.getLayerController().onLayersChanged(map -> this.updateMenu(Editor.instance().getMapComponent().getSelectedMapObjects()));
Editor.instance().getMapComponent().onSelectionChanged(this::updateMenu);
Expand Down

0 comments on commit 30093d7

Please sign in to comment.