Skip to content

Commit

Permalink
menus done
Browse files Browse the repository at this point in the history
  • Loading branch information
elahemrtz committed Feb 3, 2021
1 parent 822067c commit fbbab9c
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 179 deletions.
2 changes: 1 addition & 1 deletion src/com/plato/Controller/Menus/EventPageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void initialize (URL location, ResourceBundle resources) {
}

public void joinEvent (String eventID) throws IOException {
dataOutputStream.writeUTF("participateInEvent");
dataOutputStream.writeUTF("participateInEvent_" + eventID);
dataOutputStream.flush();
//EventController.getInstance().participateInEvent(eventID);
}
Expand Down
89 changes: 22 additions & 67 deletions src/com/plato/Controller/Menus/EventSettingsController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package Controller.Menus;

import Controller.MainController;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.event.ActionEvent;
Expand All @@ -10,7 +9,8 @@
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

import java.awt.event.MouseEvent;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.URL;
import java.util.ResourceBundle;

Expand All @@ -21,31 +21,8 @@ public class EventSettingsController implements Initializable {
public MenuButton eventTypeMenu, gameMenu, minReqMenu;
public GridPane gridPane;
private StringProperty eventSettings;
private MouseEvent mouseEvent;
private ActionEvent actionEvent;



public EventSettingsController() {
this.mouseEvent = null;
this.actionEvent = null;
}

public MouseEvent getMouseEvent() {
return mouseEvent;
}

public void setMouseEvent(MouseEvent mouseEvent) {
this.mouseEvent = mouseEvent;
}

public void setActionEvent(ActionEvent actionEvent) {
this.actionEvent = actionEvent;
}

public ActionEvent getActionEvent() {
return actionEvent;
}
private DataInputStream dataInputStream;
private DataOutputStream dataOutputStream;

public static void setStage (Stage stage) {
EventSettingsController.stage = stage;
Expand Down Expand Up @@ -99,7 +76,7 @@ private String getEventSettingsAsString () {
return "%s|%s|%s".formatted(eventTypeMenu.getText(), gameMenu.getText(), minReqMenu.getText());
}

public void isLoginTimes () {
public void isLoginTimes (ActionEvent actionEvent) {
gameMenu.setVisible(false);
minReqMenu.setVisible(true);

Expand All @@ -113,39 +90,27 @@ public void isLoginTimes () {
}});
}

resetPageWrite(getActionEvent());
}
public void isLoginTimesWrite(ActionEvent actionEvent) {
setActionEvent(actionEvent);
MainController.write("EventSettings.isLoginTimes");
resetPage(actionEvent);
}
public void resetPage () {

public void resetPage (ActionEvent actionEvent) {
minReqMenu.setText("Minimum Requirement");
gameMenu.setText("Game name");
eventTypeMenu.setText(((MenuItem) actionEvent.getSource()).getText());
}
public void resetPageWrite(ActionEvent actionEvent) {
setActionEvent(actionEvent);
MainController.write("EventSettings.resetPage");
}
public void closeStage () {

public void closeStage (ActionEvent actionEvent) {
stage.close();
}
public void closeStageWrite(ActionEvent actionEvent) {
setActionEvent(actionEvent);
MainController.write("EventSettings.closeStage");
}
public void isMVPInGame () {

public void isMVPInGame (ActionEvent actionEvent) {
gameMenu.setVisible(true);
minReqMenu.setVisible(false);

resetPageWrite(getActionEvent());
}
public void isMVPInGameWrite(ActionEvent actionEvent) {
setActionEvent(actionEvent);
MainController.write("EventSettings.isMVPInGame");
resetPage(actionEvent);
}
public void isPlayTimes () {

public void isPlayTimes (ActionEvent actionEvent) {
minReqMenu.setVisible(true);
gameMenu.setVisible(true);

Expand All @@ -159,13 +124,10 @@ public void isPlayTimes () {
}});
}

resetPageWrite(getActionEvent());
}
public void isPlayTimeWrite(ActionEvent actionEvent) {
setActionEvent(actionEvent);
MainController.write("EventSettings.isPlayTimes");
resetPage(actionEvent);
}
public void isWinTimes () {

public void isWinTimes (ActionEvent actionEvent) {
minReqMenu.setVisible(true);
gameMenu.setVisible(true);

Expand All @@ -179,13 +141,10 @@ public void isWinTimes () {
}});
}

resetPageWrite(getActionEvent());
resetPage(actionEvent);
}
public void isWinTimesWrite(ActionEvent actionEvent) {
setActionEvent(actionEvent);
MainController.write("EventSettings.isWinTimes");
}
public void isWinTimesNonStop () {

public void isWinTimesNonStop (ActionEvent actionEvent) {
minReqMenu.setVisible(true);
gameMenu.setVisible(true);

Expand All @@ -199,10 +158,6 @@ public void isWinTimesNonStop () {
}});
}

resetPageWrite(getActionEvent());
}
public void isWinTimesNonStopWrite(ActionEvent actionEvent) {
setActionEvent(actionEvent);
MainController.write("EventSettings.isWinTimesNonStop");
resetPage(actionEvent);
}
}
88 changes: 28 additions & 60 deletions src/com/plato/Controller/Menus/EventsTabController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Controller.AccountRelated.AccountController;
import Controller.AccountRelated.EventController;
import Controller.MainController;
import Model.AccountRelated.Account;
import Model.AccountRelated.Event;
import Model.AccountRelated.Gamer;
import com.google.gson.Gson;
Expand Down Expand Up @@ -46,42 +47,21 @@ public class EventsTabController implements Initializable {
public ListView<GridPane> eventsList;
public Pane eventInfo;
public GridPane gridPane;
private MouseEvent mouseEvent;
private ActionEvent actionEvent;
private static DataOutputStream dataOutputStream;
private static DataInputStream dataInputStream;
private static Socket socket;
private Object Account;


public EventsTabController() {
this.mouseEvent = null;
this.actionEvent = null;
}

public MouseEvent getMouseEvent() {
return mouseEvent;
}

public ActionEvent getActionEvent() {
return actionEvent;
}

public void setMouseEvent(MouseEvent mouseEvent) {
this.mouseEvent = mouseEvent;
}

public void setActionEvent(ActionEvent actionEvent) {
this.actionEvent = actionEvent;
}

public static void setGamerOrAdmin (boolean gamerOrAdmin) {
EventsTabController.gamerOrAdmin = gamerOrAdmin;
}

public void filter (ActionEvent actionEvent) {
public void filter (ActionEvent actionEvent) throws IOException {
LinkedList<Event> eventsToShow;
// TODO: 2/3/2021
Gamer gamer = (Gamer) AccountController.getInstance().getCurrentAccLoggedIn();
dataOutputStream.writeUTF("getCurrentAccLoggedIn_");
dataOutputStream.flush();
Gamer gamer = (Gamer) new Gson().fromJson(dataInputStream.readUTF() , (Type) Account);

String showWhich = (showInSession.isSelected() ? "y" : "n") + (showUpcoming.isSelected() ? "y" : "n") + (showParticipatingIn.isSelected() ? "y" : "n");

Expand All @@ -97,10 +77,8 @@ public void filter (ActionEvent actionEvent) {

updateList(Event.getSortedEvents(eventsToShow));
}
public void filterWrite(ActionEvent actionEvent) {
MainController.write("EventsTab.filter");
}
public void createEvent () {

public void createEvent (ActionEvent actionEvent) {
try {
EventCreateOrEditPageController.setIsForCreateOrInfo(true);
Stage stage = MainController.getInstance().createAndReturnNewStage(
Expand All @@ -115,10 +93,7 @@ public void createEvent () {
e.printStackTrace();
}
}
public void createEventWrite(ActionEvent actionEvent) {
setActionEvent(actionEvent);
MainController.write("EventsTab.createEvent");
}

@Override
public void initialize (URL location, ResourceBundle resources) {
if (gamerOrAdmin)
Expand Down Expand Up @@ -195,51 +170,51 @@ public void updateList (LinkedList<Event> eventsToShow) {
new Button() {{
try {
dataOutputStream.writeUTF("getCurrentAccLoggedIn");
} catch (IOException e) {
e.printStackTrace();
}
try {
dataOutputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}
Gamer currentLoggedIn = null;
// TODO: 2/3/2021
// currentLoggedIn = (Gamer) new Gson().fromJson(dataInputStream.readUTF(), (Type) Account);
try {
currentLoggedIn = (Gamer) new Gson().fromJson(dataInputStream.readUTF(), (Type) Account);
} catch (IOException exception) {
exception.printStackTrace();
}
;
// is already participating in event
if (event.participantExists(currentLoggedIn.getUsername())) {
setText("Drop-out");
setOnAction(e -> {
try {
dataOutputStream.writeUTF("stopParticipatingInEvent");
dataOutputStream.writeUTF("stopParticipatingInEvent_" + event.getEventID());
dataOutputStream.flush();
} catch (IOException exception) {
exception.printStackTrace();
}
//EventController.getInstance().stopParticipatingInEvent(event.getEventID());
try {
dataOutputStream.flush();
filter(new ActionEvent());
} catch (IOException exception) {
exception.printStackTrace();
}
EventController.getInstance().stopParticipatingInEvent(event.getEventID());
filter(new ActionEvent());
});
}
else {
setText("Join");
setOnAction(e -> {
try {
dataOutputStream.writeUTF("participateInEvent");
dataOutputStream.writeUTF("participateInEvent_");
dataOutputStream.flush();
} catch (IOException exception) {
exception.printStackTrace();
}
//EventController.getInstance().participateInEvent(event.getEventID());
try {
dataOutputStream.flush();
filter(new ActionEvent());
} catch (IOException exception) {
exception.printStackTrace();
}
//EventController.getInstance().participateInEvent(event.getEventID());
filter(new ActionEvent());
});
}

Expand Down Expand Up @@ -311,8 +286,9 @@ public void updateList (LinkedList<Event> eventsToShow) {
}

private void removeEvent (Event event) throws IOException {

Event.removeEvent(event.getEventID());
dataOutputStream.writeUTF("removeEvent_" + event.getEventID());
dataOutputStream.flush();
// Event.removeEvent(event.getEventID());
filter(new ActionEvent());
}

Expand Down Expand Up @@ -342,20 +318,12 @@ private void displayEventInfo (Event event) {
}
}

public void mouseIsOut () {
public void mouseIsOut (MouseEvent mouseEvent) {
((Button) mouseEvent.getSource()).setOpacity(0.8);
}
public void mouseIsOutWrite(MouseEvent mouseEvent) {
setMouseEvent(mouseEvent);
MainController.write("EventsTab.mouseIsOut");
}
public void mouseIsOver () {
((Button) getMouseEvent().getSource()).setOpacity(1);
}

public void mouseIsOverWrite(MouseEvent mouseEvent) {
setMouseEvent(mouseEvent);
MainController.write("EventsTab.mouseIsOver");
public void mouseIsOver (MouseEvent mouseEvent) {
((Button) mouseEvent.getSource()).setOpacity(1);
}
}

Expand Down
23 changes: 0 additions & 23 deletions src/com/plato/Controller/Menus/FriendProfileController.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,11 @@ public class FriendProfileController implements Initializable {
public Label reversiDraws, reversiScore, reversiWins, reversiLosses;
public Label battleseaScore, battleseaWins, battleseaLosses, battleseaDraws;
public ImageView pfp;
private MouseEvent mouseEvent;
private ActionEvent actionEvent;
private static DataOutputStream dataOutputStream;
private static DataInputStream dataInputStream;
private static Socket socket;


public FriendProfileController() {
this.mouseEvent = null;
this.actionEvent = null;
}

public MouseEvent getMouseEvent() {
return mouseEvent;
}

public ActionEvent getActionEvent() {
return actionEvent;
}

public void setMouseEvent(MouseEvent mouseEvent) {
this.mouseEvent = mouseEvent;
}

public void setActionEvent(ActionEvent actionEvent) {
this.actionEvent = actionEvent;
}

public static Gamer getFrnd () {
return frnd;
}
Expand Down
Loading

0 comments on commit fbbab9c

Please sign in to comment.