<commit_before>/*
 * Copyright (c) 2015 JBYoshi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jbyoshi.blockdodge.gui;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

final class InputMainMenu extends Input {
	public InputMainMenu(BlockDodgePanel panel) {
		super(panel);
	}

	@Override
	public void keyPressed(KeyEvent e) {
		switch (e.getKeyCode()) {
		case KeyEvent.VK_ENTER:
		case KeyEvent.VK_SPACE:
			game.addTask(game::stop);
			break;
		case KeyEvent.VK_F11:
			JFrame frame = panel.frame;
			GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
			if (device.isFullScreenSupported() && device.getFullScreenWindow() != frame) {
				frame.dispose();
				frame.setUndecorated(true);
				device.setFullScreenWindow(frame);
			} else {
				frame.dispose();
				device.setFullScreenWindow(null);
				frame.setUndecorated(false);
				frame.setVisible(true);
			}
			frame.revalidate();
			break;
		case KeyEvent.VK_DELETE:
			// The End
			System.exit(0);
			break;
		}
	}

	@Override
	Component createDisplay() {
		Box info = Box.createVerticalBox();
		info.add(Box.createVerticalGlue());
		info.add(UI.label("Block Dodge", 32));
		info.add(Box.createVerticalStrut(32));
		info.add(UI.label("You are the white box in the center of the screen."));
		info.add(UI.label("Use your mouse or the arrow keys to move."));
		info.add(UI.label("Avoid the colored blocks flying at you."));
		info.add(Box.createVerticalStrut(32));
		info.add(UI.button("Start (Enter)", Color.GREEN, e -> game.stop()));
		info.add(Box.createVerticalGlue());
		info.add(UI.label(BlockDodge.COPYRIGHT_TEXT, 10));
		info.add(Box.createVerticalStrut(50));
		return info;
	}

}<commit_msg>Add a Quit button to the main menu.<commit_after>/*
 * Copyright (c) 2015 JBYoshi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jbyoshi.blockdodge.gui;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

final class InputMainMenu extends Input {
	public InputMainMenu(BlockDodgePanel panel) {
		super(panel);
	}

	@Override
	public void keyPressed(KeyEvent e) {
		switch (e.getKeyCode()) {
		case KeyEvent.VK_ENTER:
		case KeyEvent.VK_SPACE:
			game.addTask(game::stop);
			break;
		case KeyEvent.VK_F11:
			JFrame frame = panel.frame;
			GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
			if (device.isFullScreenSupported() && device.getFullScreenWindow() != frame) {
				frame.dispose();
				frame.setUndecorated(true);
				device.setFullScreenWindow(frame);
			} else {
				frame.dispose();
				device.setFullScreenWindow(null);
				frame.setUndecorated(false);
				frame.setVisible(true);
			}
			frame.revalidate();
			break;
		case KeyEvent.VK_DELETE:
			// The End
			System.exit(0);
			break;
		}
	}

	@Override
	Component createDisplay() {
		Box info = Box.createVerticalBox();
		info.add(Box.createVerticalGlue());
		info.add(UI.label("Block Dodge", 32));
		info.add(Box.createVerticalStrut(32));
		info.add(UI.label("You are the white box in the center of the screen."));
		info.add(UI.label("Use your mouse or the arrow keys to move."));
		info.add(UI.label("Avoid the colored blocks flying at you."));
		info.add(Box.createVerticalStrut(32));
		info.add(UI.button("Start (Enter)", Color.GREEN, e -> game.stop()));
		info.add(UI.button("Quit (Delete)", Color.RED, e -> System.exit(0)));
		info.add(Box.createVerticalGlue());
		info.add(UI.label(BlockDodge.COPYRIGHT_TEXT, 10));
		info.add(Box.createVerticalStrut(50));
		return info;
	}

}
{'fraction_non_alphanumeric': 0.1274812527569475, 'fraction_numerical': 0.009483899426554919, 'mean_word_length': 4.072706935123042, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5559851', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1422, 'n_words': 394}