|
|
@@ -3,12 +3,12 @@ package view.ui;
|
|
|
import controller.InteractiveController;
|
|
|
import controller.entity.EntityController;
|
|
|
import controller.tiles.interactive.InteractiveTileController;
|
|
|
-import util.GAMESTATE;
|
|
|
import util.Translator;
|
|
|
import view.GamePanel;
|
|
|
import view.components.Button;
|
|
|
import view.popUpMenu.PopupMenu;
|
|
|
import view.tile.ONCLICKTYPE;
|
|
|
+import view.ui.menu.PauseMenu;
|
|
|
|
|
|
import java.awt.*;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -17,7 +17,7 @@ public class UI {
|
|
|
private GamePanel gp;
|
|
|
private Graphics2D g2;
|
|
|
private Font arial_40;
|
|
|
- private ArrayList<Button> activeButtons = new ArrayList<>();
|
|
|
+ private static ArrayList<Button> activeButtons = new ArrayList<>();
|
|
|
|
|
|
public UI(GamePanel gp){
|
|
|
this.gp = gp;
|
|
|
@@ -29,7 +29,6 @@ public class UI {
|
|
|
g2.setFont(arial_40);
|
|
|
g2.setColor(Color.white);
|
|
|
|
|
|
- drawPauseScreen(g2, Translator.translate("menu.pause"));
|
|
|
}
|
|
|
public void handleMenuClick(int screenX, int screenY) {
|
|
|
for (Button button : activeButtons) {
|
|
|
@@ -66,59 +65,7 @@ public class UI {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void drawPauseScreen(Graphics2D g2, String message) {
|
|
|
- // Background overlay
|
|
|
- g2.setColor(new Color(0, 0, 0, 150));
|
|
|
- g2.fillRect(0, 0, gp.screenWidth, gp.screenHeight);
|
|
|
-
|
|
|
- // Dialog box
|
|
|
- int boxWidth = gp.screenWidth / 2;
|
|
|
- int boxHeight = gp.screenHeight / 2;
|
|
|
- int boxX = gp.screenWidth / 2 - boxWidth / 2;
|
|
|
- int boxY = gp.screenHeight / 4;
|
|
|
-
|
|
|
- g2.setColor(Color.WHITE);
|
|
|
- g2.fillRoundRect(boxX, boxY, boxWidth, boxHeight, 25, 25);
|
|
|
-
|
|
|
- // Message text
|
|
|
- g2.setColor(Color.BLACK);
|
|
|
- g2.setFont(new Font("Arial", Font.BOLD, 28));
|
|
|
- FontMetrics fm = g2.getFontMetrics();
|
|
|
- int msgWidth = fm.stringWidth(message);
|
|
|
- g2.drawString(message, gp.screenWidth / 2 - msgWidth / 2, boxY + 50);
|
|
|
-
|
|
|
- // Buttons
|
|
|
- int buttonWidth = 260;
|
|
|
- int buttonHeight = 40;
|
|
|
- int spacing = 20;
|
|
|
-
|
|
|
- int buttonX = gp.screenWidth / 2 - buttonWidth / 2;
|
|
|
- int resumeY = boxY + 100;
|
|
|
- int saveY = resumeY + buttonHeight + spacing;
|
|
|
- int exitY = saveY + buttonHeight + spacing;
|
|
|
- int menuY = exitY + buttonHeight + spacing;
|
|
|
- Button resumeButton = new Button(buttonWidth, buttonHeight, Translator.translate("menu.resume"), () -> {
|
|
|
- gp.gameState = GAMESTATE.PLAY;
|
|
|
- });
|
|
|
- drawAndRegisterButton(resumeButton, buttonX, resumeY);
|
|
|
-
|
|
|
- Button exitButton = new Button(buttonWidth, buttonHeight, Translator.translate("menu.quit"), () -> {
|
|
|
- gp.gameState = GAMESTATE.QUIT;
|
|
|
- });
|
|
|
- drawAndRegisterButton(exitButton, buttonX, exitY);
|
|
|
-
|
|
|
- Button saveButton = new Button(buttonWidth, buttonHeight, Translator.translate("menu.save"), () -> {
|
|
|
- gp.gameState = GAMESTATE.SAVE;
|
|
|
- });
|
|
|
- drawAndRegisterButton(saveButton, buttonX, saveY);
|
|
|
-
|
|
|
- Button menuButton = new Button(buttonWidth, buttonHeight, Translator.translate("menu.main_menu"), () -> {
|
|
|
- gp.gameState = GAMESTATE.MAIN_MENU;
|
|
|
- });
|
|
|
- drawAndRegisterButton(menuButton, buttonX, menuY);
|
|
|
- }
|
|
|
-
|
|
|
- private void drawAndRegisterButton(Button button, int buttonX, int buttonY){
|
|
|
+ public static void drawAndRegisterButton(Graphics2D g2, Button button, int buttonX, int buttonY){
|
|
|
button.setScreenCoordinates(buttonX, buttonY);
|
|
|
button.draw(g2);
|
|
|
activeButtons.add(button);
|