Create PoC of Equipment window
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.bartlomiejpluta.demo.gui;
|
||||
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
import com.bartlomiejpluta.base.api.gui.*;
|
||||
import com.bartlomiejpluta.base.lib.gui.*;
|
||||
|
||||
|
||||
public class EquipmentWindow extends DecoratedWindow {
|
||||
|
||||
public EquipmentWindow(Context context, GUI gui) {
|
||||
super(context, gui);
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,10 @@ public abstract class BaseMapHandler implements MapHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if(runner.openedWindows() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(input.isKeyPressed(Key.KEY_SPACE)) {
|
||||
player.attack();
|
||||
}
|
||||
@@ -71,7 +75,7 @@ public abstract class BaseMapHandler implements MapHandler {
|
||||
player.setFaceDirection(Direction.LEFT);
|
||||
} else if(input.isKeyPressed(Key.KEY_RIGHT)) {
|
||||
player.setFaceDirection(Direction.RIGHT);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(input.isKeyPressed(Key.KEY_DOWN)) {
|
||||
player.getLayer().pushMovement(player.prepareMovement(Direction.DOWN));
|
||||
@@ -123,7 +127,7 @@ public abstract class BaseMapHandler implements MapHandler {
|
||||
layer.addEntity(icon);
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
public Warp warp(ObjectLayer layer, int x, int y, String targetMap, String targetLayer, int targetX, int targetY) {
|
||||
var warp = new Warp(A.maps.get(targetMap).uid, A.maps.getLayer(targetMap, targetLayer), targetX, targetY);
|
||||
warp.setEntity(player);
|
||||
|
||||
@@ -21,6 +21,7 @@ public class MenuManager {
|
||||
|
||||
private final StartMenuWindow startMenu;
|
||||
private final GameMenuWindow gameMenu;
|
||||
private final EquipmentWindow equipment;
|
||||
|
||||
private final Consumer<KeyEvent> gameMenuHandler = this::handleGameMenuKeyEvent;
|
||||
|
||||
@@ -40,9 +41,21 @@ public class MenuManager {
|
||||
this.gameMenu.getResumeGameBtn().setAction(this::resumeGame);
|
||||
this.gameMenu.getStartMenuBtn().setAction(runner::returnToStartMenu);
|
||||
this.gameMenu.getExitBtn().setAction(runner::exit);
|
||||
|
||||
this.equipment = (EquipmentWindow) gui.inflateWindow(A.widgets.equipment.uid);
|
||||
}
|
||||
|
||||
private void handleGameMenuKeyEvent(KeyEvent event) {
|
||||
if (event.getKey() == Key.KEY_E && event.getAction() == KeyAction.PRESS) {
|
||||
if(manager.isEmpty()) {
|
||||
manager.open(equipment);
|
||||
} else if (manager.top() == equipment) {
|
||||
manager.close();
|
||||
}
|
||||
|
||||
event.consume();
|
||||
}
|
||||
|
||||
if (event.getKey() == Key.KEY_ESCAPE && event.getAction() == KeyAction.PRESS) {
|
||||
if(manager.size() > 0) {
|
||||
manager.close();
|
||||
@@ -60,6 +73,10 @@ public class MenuManager {
|
||||
}
|
||||
}
|
||||
|
||||
public int openedWindows() {
|
||||
return manager.size();
|
||||
}
|
||||
|
||||
public void showStartMenu() {
|
||||
manager.closeAll();
|
||||
manager.open(startMenu);
|
||||
|
||||
@@ -54,6 +54,10 @@ public class DemoRunner implements GameRunner {
|
||||
private void initMenu() {
|
||||
this.menu = new MenuManager(this, context);
|
||||
}
|
||||
|
||||
public int openedWindows() {
|
||||
return this.menu.openedWindows();
|
||||
}
|
||||
|
||||
private void initHUD() {
|
||||
hud = context.newGUI();
|
||||
|
||||
Reference in New Issue
Block a user