<commit_before>package com.github.tiwindetea.dungeonoflegend;

import com.github.tiwindetea.dungeonoflegend.model.Game;
import com.github.tiwindetea.dungeonoflegend.view.GUI;
import com.github.tiwindetea.dungeonoflegend.view.ViewPackage;
import com.github.tiwindetea.oggplayer.Sound;
import com.github.tiwindetea.oggplayer.Sounds;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by maxime on 5/3/16.
 */
public class MainMenu extends Application {

	private final GUI GUI = new GUI();
	private static final String SAVE_FILE_NAME = "Save";
	private final Game game = new Game(SAVE_FILE_NAME);

	private final VBox buttonsVBox = new VBox();
	private final AnchorPane menuAnchorPane = new AnchorPane();
	private final Scene menuScene = new Scene(this.menuAnchorPane);
	private final Button soloButton = new Button("Solo");
	private final Button multiplayerButton = new Button("2 Players");
	private final Button loadButton = new Button("Load game");
	private final Button resumeButton = new Button("Resume game");
	private final Button exitButton = new Button("exit");
	private final String buttonsStyle = ViewPackage.BUTTONS_STYLE_FILE_PATH;
	private Stage primaryStage;

	private final ImageView soloImageView = new ImageView(ViewPackage.SOLO_IMAGE);
	private final ImageView multiplayerImageView = new ImageView(ViewPackage.MULTIPLAYER_IMAGE);
	private final ImageView loadImageView = new ImageView(ViewPackage.LOAD_IMAGE);
	private final ImageView resumeImageView = new ImageView(ViewPackage.RESUME_IMAGE);
	private final ImageView greenLogoImageView = new ImageView(ViewPackage.GREEN_LOGO_IMAGE);
	private final ImageView orangeLogoImageView = new ImageView(ViewPackage.ORANGE_LOGO_IMAGE);

	private static final Color BACK_GROUND_COLOR_1 = Color.rgb(43, 97, 169);
	private static final Color BACK_GROUND_COLOR_2 = Color.rgb(23, 110, 67);

	private static final int PICTURES_HEIGHT = 600;
	private static final int PICTURES_ESTIMATED_MAX_WIDTH = 700;
	private static final int BUTTONS_VBOX_MIN_WIDTH = 300;
	private static final int BUTTONS_WIDTH = 200;
	private static final int LOGOS_HEIGHT = 200;

	@Override
	public void start(Stage primaryStage) throws Exception {
		this.primaryStage = primaryStage;
		primaryStage.setTitle("Dungeon Of Legends");
		primaryStage.getIcons().add(ViewPackage.ICON_IMAGE);

		this.game.addGameListener(this.GUI);
		this.GUI.addRequestListener(this.game);
		this.GUI.getScene().addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
			@Override
			public void handle(KeyEvent event) {
				if(event.getCode() == KeyCode.ESCAPE) {
					updateButtons();
					primaryStage.setScene(MainMenu.this.menuScene);
					MainMenu.this.buttonsVBox.setAlignment(Pos.CENTER);
					MainMenu.this.game.pause();
				}
			}
		});

		this.menuAnchorPane.getChildren().addAll(this.soloImageView, this.multiplayerImageView, this.loadImageView, this.resumeImageView, this.greenLogoImageView, this.orangeLogoImageView);

		this.soloImageView.setPreserveRatio(true);
		this.soloImageView.setFitHeight(PICTURES_HEIGHT);
		AnchorPane.setRightAnchor(this.soloImageView, 0d);
		AnchorPane.setBottomAnchor(this.soloImageView, 0d);

		this.multiplayerImageView.setPreserveRatio(true);
		this.multiplayerImageView.setFitHeight(PICTURES_HEIGHT);
		AnchorPane.setRightAnchor(this.multiplayerImageView, 0d);
		AnchorPane.setBottomAnchor(this.multiplayerImageView, 0d);

		this.loadImageView.setPreserveRatio(true);
		this.loadImageView.setFitHeight(PICTURES_HEIGHT);
		AnchorPane.setRightAnchor(this.loadImageView, 0d);
		AnchorPane.setBottomAnchor(this.loadImageView, 0d);

		this.resumeImageView.setPreserveRatio(true);
		this.resumeImageView.setFitHeight(PICTURES_HEIGHT);
		AnchorPane.setRightAnchor(this.resumeImageView, 0d);
		AnchorPane.setBottomAnchor(this.resumeImageView, 0d);

		this.greenLogoImageView.setPreserveRatio(true);<commit_msg>MainMenu now have a min height and width so elements are not on top of each other<commit_after>package com.github.tiwindetea.dungeonoflegend;

import com.github.tiwindetea.dungeonoflegend.model.Game;
import com.github.tiwindetea.dungeonoflegend.view.GUI;
import com.github.tiwindetea.dungeonoflegend.view.ViewPackage;
import com.github.tiwindetea.oggplayer.Sound;
import com.github.tiwindetea.oggplayer.Sounds;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by maxime on 5/3/16.
 */
public class MainMenu extends Application {

	private final GUI GUI = new GUI();
	private static final String SAVE_FILE_NAME = "Save";
	private final Game game = new Game(SAVE_FILE_NAME);

	private final VBox buttonsVBox = new VBox();
	private final AnchorPane menuAnchorPane = new AnchorPane();
	private final Scene menuScene = new Scene(this.menuAnchorPane);
	private final Button soloButton = new Button("Solo");
	private final Button multiplayerButton = new Button("2 Players");
	private final Button loadButton = new Button("Load game");
	private final Button resumeButton = new Button("Resume game");
	private final Button exitButton = new Button("exit");
	private final String buttonsStyle = ViewPackage.BUTTONS_STYLE_FILE_PATH;
	private Stage primaryStage;

	private final ImageView soloImageView = new ImageView(ViewPackage.SOLO_IMAGE);
	private final ImageView multiplayerImageView = new ImageView(ViewPackage.MULTIPLAYER_IMAGE);
	private final ImageView loadImageView = new ImageView(ViewPackage.LOAD_IMAGE);
	private final ImageView resumeImageView = new ImageView(ViewPackage.RESUME_IMAGE);
	private final ImageView greenLogoImageView = new ImageView(ViewPackage.GREEN_LOGO_IMAGE);
	private final ImageView orangeLogoImageView = new ImageView(ViewPackage.ORANGE_LOGO_IMAGE);

	private static final Color BACK_GROUND_COLOR_1 = Color.rgb(43, 97, 169);
	private static final Color BACK_GROUND_COLOR_2 = Color.rgb(23, 110, 67);

	private static final int PICTURES_HEIGHT = 600;
	private static final int PICTURES_ESTIMATED_MAX_WIDTH = 700;
	private static final int BUTTONS_VBOX_MIN_WIDTH = 300;
	private static final int BUTTONS_WIDTH = 200;
	private static final int LOGOS_HEIGHT = 200;

	@Override
	public void start(Stage primaryStage) throws Exception {
		this.primaryStage = primaryStage;
		primaryStage.setTitle("Dungeon Of Legends");
		primaryStage.getIcons().add(ViewPackage.ICON_IMAGE);

		this.game.addGameListener(this.GUI);
		this.GUI.addRequestListener(this.game);
		this.GUI.getScene().addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
			@Override
			public void handle(KeyEvent event) {
				if(event.getCode() == KeyCode.ESCAPE) {
					updateButtons();
					primaryStage.setScene(MainMenu.this.menuScene);
					MainMenu.this.buttonsVBox.setAlignment(Pos.CENTER);
					MainMenu.this.game.pause();
				}
			}
		});

		this.menuAnchorPane.getChildren().addAll(this.soloImageView, this.multiplayerImageView, this.loadImageView, this.resumeImageView, this.greenLogoImageView, this.orangeLogoImageView);
		this.menuAnchorPane.setMinWidth(BUTTONS_VBOX_MIN_WIDTH + PICTURES_ESTIMATED_MAX_WIDTH);
		this.menuAnchorPane.setMinHeight(PICTURES_HEIGHT + LOGOS_HEIGHT);

		this.soloImageView.setPreserveRatio(true);
		this.soloImageView.setFitHeight(PICTURES_HEIGHT);
		AnchorPane.setRightAnchor(this.soloImageView, 0d);
		AnchorPane.setBottomAnchor(this.soloImageView, 0d);

		this.multiplayerImageView.setPreserveRatio(true);
		this.multiplayerImageView.setFitHeight(PICTURES_HEIGHT);
		AnchorPane.setRightAnchor(this.multiplayerImageView, 0d);
		AnchorPane.setBottomAnchor(this.multiplayerImageView, 0d);

		this.loadImageView.setPreserveRatio(true);
		this.loadImageView.setFitHeight(PICTURES_HEIGHT);
		AnchorPane.setRightAnchor(this.loadImageView, 0d);
		AnchorPane.setBottomAnchor(this.loadImageView, 0d);

		this.resumeImageView.setPreserveRatio(true);
		this.resumeImageView.setFitHeight(PICTURES_HEIGHT);
		AnchorPane.setRightAnchor(this.resumeImageView, 0d);
		AnchorPane.setBottomAnchor(this.resumeImageView, 0d);

		this.greenLogoImageView.setPreserveRatio(true);
{'fraction_non_alphanumeric': 0.09368421052631579, 'fraction_numerical': 0.009263157894736843, 'mean_word_length': 6.382284382284382, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4939915', 'n_tokens_mistral': 3211, 'n_tokens_neox': 2895, 'n_words': 593}