1. Add some UI,
2. For while remove excessive files
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
package org.main.client;
|
||||
|
||||
public interface GameConnectable{
|
||||
void Connect();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package org.main.client;
|
||||
|
||||
public class LocalGame implements GameConnectable{
|
||||
public void Connect(){
|
||||
//TODO: implement game starting code
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,39 @@
|
||||
package org.main.client;
|
||||
import javax.swing.*;
|
||||
import java.io.Console;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main{
|
||||
public static void main(String[] args){
|
||||
static int runningMode;
|
||||
|
||||
static enum runningModes{
|
||||
graphical(0), console(1);
|
||||
final int mode;
|
||||
|
||||
runningModes(int mode){
|
||||
this.mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
Scanner userInput = null;
|
||||
runningMode = runningModes.graphical.mode;
|
||||
|
||||
for(String execArgs : args){
|
||||
if(execArgs.equals("console")){
|
||||
runningMode = runningModes.console.mode;
|
||||
}
|
||||
}
|
||||
|
||||
if(runningMode == runningModes.graphical.mode){
|
||||
|
||||
}
|
||||
else{
|
||||
Console console = System.console();
|
||||
userInput = new Scanner(new InputStreamReader(System.in, console.charset()));
|
||||
}
|
||||
|
||||
Menu menu = new Menu(userInput);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,61 @@
|
||||
package org.main.client;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import javax.swing.*;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static org.main.client.Main.runningMode;
|
||||
import static org.main.client.Main.runningModes;
|
||||
|
||||
public class Menu{
|
||||
|
||||
enum menuCats{
|
||||
main(0), play(1), settings(2);
|
||||
int cat;
|
||||
|
||||
void DisplayMenu(char menuEntry){
|
||||
if(menuEntry == 0){
|
||||
System.out.println("1. ");
|
||||
}
|
||||
}
|
||||
menuCats(int cat){
|
||||
this.cat = cat;
|
||||
}
|
||||
}
|
||||
int choice = 0;
|
||||
|
||||
void RotateEntries(BufferedReader br){
|
||||
char choice = 0;
|
||||
while(choice != 5){
|
||||
try{
|
||||
choice = br.readLine().charAt(0);
|
||||
} catch(IOException e){
|
||||
System.out.println("Input/output error while reading symbol from console");
|
||||
}
|
||||
Menu(Scanner userInput) {
|
||||
if (runningMode == runningModes.console.mode) {
|
||||
System.out.println("---------------------------------");
|
||||
System.out.println("Добро пожаловать в игру Кузнечик!");
|
||||
System.out.println("---------------------------------");
|
||||
System.out.println();
|
||||
|
||||
this.DisplayMenu(choice);
|
||||
}
|
||||
}
|
||||
while(choice != 3){
|
||||
textMenuShow(choice);
|
||||
System.out.println("Выберите пункт меню:");
|
||||
choice = Integer.parseInt(userInput.nextLine());
|
||||
while(choice <= 0 || choice > 3){
|
||||
System.out.println("Неопознанный выбор!");
|
||||
choice = Integer.parseInt(userInput.nextLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() { new Swing(); }
|
||||
});
|
||||
|
||||
// while(choice != 3){
|
||||
// //TODO
|
||||
// }
|
||||
}
|
||||
}
|
||||
void textMenuShow(int cat){
|
||||
if(cat == menuCats.main.cat){
|
||||
System.out.println("/-------------МЕНЮ-------------\\");
|
||||
System.out.println("1. Начать игру");
|
||||
System.out.println("2. Настройки");
|
||||
System.out.println("3. Выход");
|
||||
}
|
||||
if(cat == menuCats.play.cat){
|
||||
//TODO
|
||||
}
|
||||
if(cat == menuCats.settings.cat){
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
package org.main.client;
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomCube{
|
||||
|
||||
int throwAndGetResult(){
|
||||
return (new Random().nextInt(0, 5));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package org.main.client;
|
||||
|
||||
public class RemoteGame implements GameConnectable{
|
||||
public void Connect(){
|
||||
//TODO: implement game starting code
|
||||
;
|
||||
}
|
||||
}
|
||||
46
app/src/main/java/org/main/client/Swing.java
Normal file
46
app/src/main/java/org/main/client/Swing.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package org.main.client;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class Swing{
|
||||
Swing(){
|
||||
JFrame swingContainerHL = new JFrame("Kuznechik");
|
||||
|
||||
swingContainerHL.setLayout(new FlowLayout());
|
||||
|
||||
swingContainerHL.setSize(1280, 720);
|
||||
|
||||
swingContainerHL.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JButton startButton = new JButton("Начать игру!");
|
||||
JButton settingsButton = new JButton("Настройки");
|
||||
JButton exitButton = new JButton("Выход");
|
||||
|
||||
startButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
|
||||
}
|
||||
});
|
||||
settingsButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
|
||||
}
|
||||
});
|
||||
exitButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
swingContainerHL.add(startButton);
|
||||
swingContainerHL.add(settingsButton);
|
||||
swingContainerHL.add(exitButton);
|
||||
|
||||
swingContainerHL.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user