|
@@ -2,7 +2,9 @@ package view;
|
|
|
|
|
|
|
|
import util.GAMESTATE;
|
|
import util.GAMESTATE;
|
|
|
import view.components.Button;
|
|
import view.components.Button;
|
|
|
|
|
+import view.popUpMenu.PopupMenu;
|
|
|
import view.tile.interactive.InteractiveTile;
|
|
import view.tile.interactive.InteractiveTile;
|
|
|
|
|
+import view.tile.interactive.ONCLICKTYPE;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
import java.awt.*;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -36,10 +38,20 @@ public class UI {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
public void handleClick(int screenX, int screenY){
|
|
public void handleClick(int screenX, int screenY){
|
|
|
-
|
|
|
|
|
for (InteractiveTile tile : gp.tileManager.interactiveTiles) {
|
|
for (InteractiveTile tile : gp.tileManager.interactiveTiles) {
|
|
|
- if (tile.isClicked(screenX, screenY, gp.camera)) {
|
|
|
|
|
- tile.click();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if(tile.getClicked() && tile.getOnClickType() == ONCLICKTYPE.POPUP){
|
|
|
|
|
+ PopupMenu popupMenu = tile.getPopupMenu();
|
|
|
|
|
+ Button clickedButton = popupMenu.getClickedButton(screenX,screenY);
|
|
|
|
|
+ if(clickedButton != null){
|
|
|
|
|
+ clickedButton.click();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (tile.isClicked(screenX, screenY, gp.camera) && !tile.getClicked()) {
|
|
|
|
|
+ tile.click(screenX, screenY);
|
|
|
|
|
+ }else if(tile.getClicked()){
|
|
|
|
|
+ tile.unClick();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -75,17 +87,17 @@ public class UI {
|
|
|
int resumeY = boxY + 100;
|
|
int resumeY = boxY + 100;
|
|
|
int saveY = resumeY + buttonHeight + spacing;
|
|
int saveY = resumeY + buttonHeight + spacing;
|
|
|
int exitY = resumeY + buttonHeight + buttonHeight + spacing + spacing;
|
|
int exitY = resumeY + buttonHeight + buttonHeight + spacing + spacing;
|
|
|
- Button resumeButton = new Button(buttonHeight, buttonWidth, "Continue", () -> {
|
|
|
|
|
|
|
+ Button resumeButton = new Button(buttonWidth, buttonHeight, "Continue", () -> {
|
|
|
gp.gameState = GAMESTATE.PLAY;
|
|
gp.gameState = GAMESTATE.PLAY;
|
|
|
});
|
|
});
|
|
|
drawAndRegisterButton(resumeButton, buttonX, resumeY);
|
|
drawAndRegisterButton(resumeButton, buttonX, resumeY);
|
|
|
|
|
|
|
|
- Button exitButton = new Button(buttonHeight, buttonWidth, "Quit", () -> {
|
|
|
|
|
|
|
+ Button exitButton = new Button(buttonWidth, buttonHeight, "Quit", () -> {
|
|
|
gp.gameState = GAMESTATE.QUIT;
|
|
gp.gameState = GAMESTATE.QUIT;
|
|
|
});
|
|
});
|
|
|
drawAndRegisterButton(exitButton, buttonX, exitY);
|
|
drawAndRegisterButton(exitButton, buttonX, exitY);
|
|
|
|
|
|
|
|
- Button saveButton = new Button(buttonHeight, buttonWidth, "Save", () -> {
|
|
|
|
|
|
|
+ Button saveButton = new Button(buttonWidth, buttonHeight, "Save", () -> {
|
|
|
gp.gameState = GAMESTATE.SAVE;
|
|
gp.gameState = GAMESTATE.SAVE;
|
|
|
});
|
|
});
|
|
|
drawAndRegisterButton(saveButton, buttonX, saveY);
|
|
drawAndRegisterButton(saveButton, buttonX, saveY);
|
|
@@ -100,4 +112,10 @@ public class UI {
|
|
|
int length = (int)g2.getFontMetrics().getStringBounds(text, g2).getWidth();
|
|
int length = (int)g2.getFontMetrics().getStringBounds(text, g2).getWidth();
|
|
|
return gp.screenWidth/2 - length/2;
|
|
return gp.screenWidth/2 - length/2;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void closeMenus() {
|
|
|
|
|
+ for (InteractiveTile tile : gp.tileManager.interactiveTiles) {
|
|
|
|
|
+ tile.unClick();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|