Skip to content
Snippets Groups Projects
Commit 17787cfc authored by Kovax's avatar Kovax
Browse files

Menuzeleles javitva

parent 37f211ac
No related branches found
No related tags found
No related merge requests found
...@@ -6,41 +6,42 @@ ...@@ -6,41 +6,42 @@
package GUI.menu; package GUI.menu;
import GUI.window.GUIMSG;
/** /**
* *
* @author Kovax * @author Kovax
*/ */
public class Controller public class Controller
{ {
private Boolean isNewGameButtonPressed = false;
private View view; private View view;
private Model model; private Model model;
public String pressedButton;
public Controller(View view, Model model) public Controller()
{ {
this.view = view; this.view = null;
this.model = model; this.model = null;
this.isNewGameButtonPressed = false;
} }
public String getPressedButton() public void registerView(View view)
{
while( true )
{
if( view.aboutButtonPresses )
{ {
return "about"; this.view = view;
} }
else if( view.newGameButtonPressed ) public void registerModel(Model model)
{ {
return "newgame"; this.model = model;
} }
else if( view.settingsButtonPressed ) protected void newGameButtonPressed()
{ {
return "settings"; isNewGameButtonPressed = true;
} //throw new GUIMSG("kakispite");
} }
public Boolean getButtonState()
{
return isNewGameButtonPressed;
} }
......
...@@ -6,24 +6,30 @@ ...@@ -6,24 +6,30 @@
package GUI.menu; package GUI.menu;
/** /**
* *
* @author Kovax * @author Kovax
*/ */
public class Menu { public class Menu
{
public Controller controller;
public Menu() public Menu()
{ {
System.out.println("asdasd"); this.startGUI();
//View view = new View();
} }
public String show()
public synchronized void startGUI()
{ {
GUI.menu.View menuView = new GUI.menu.View(); GUI.menu.Controller menu = new GUI.menu.Controller();
GUI.menu.Model menuModel = new GUI.menu.Model(); GUI.menu.Model menuModel = new GUI.menu.Model();
GUI.menu.Controller menu = new GUI.menu.Controller( menuView, menuModel ); GUI.menu.View menuView = new GUI.menu.View(menu,menuModel);
menu.registerModel(menuModel);
menu.registerView(menuView);
return menu.getPressedButton(); this.controller = menu;
} }
} }
...@@ -12,6 +12,7 @@ package GUI.menu; ...@@ -12,6 +12,7 @@ package GUI.menu;
*/ */
public class Model public class Model
{ {
private String newGameButtonText; private String newGameButtonText;
private String settingsButtonText; private String settingsButtonText;
private String aboutButtonText; private String aboutButtonText;
...@@ -19,4 +20,6 @@ public class Model ...@@ -19,4 +20,6 @@ public class Model
public String getNewGameButtonText() { return this.newGameButtonText; } public String getNewGameButtonText() { return this.newGameButtonText; }
public String getSettingsButtonText() { return this.settingsButtonText; } public String getSettingsButtonText() { return this.settingsButtonText; }
public String getAboutButtonText() { return this.aboutButtonText; } public String getAboutButtonText() { return this.aboutButtonText; }
} }
...@@ -8,19 +8,24 @@ package GUI.menu; ...@@ -8,19 +8,24 @@ package GUI.menu;
import GUI.Window.Window; import GUI.Window.Window;
/** /**
* *
* @author Kovax * @author Kovax
*/ */
public class View extends Window public class View extends Window
{ {
Controller controller;
Model model;
Boolean newGameButtonPressed = false; Boolean newGameButtonPressed = false;
Boolean settingsButtonPressed = false; Boolean settingsButtonPressed = false;
Boolean aboutButtonPresses = false; Boolean aboutButtonPresses = false;
public View() public View(Controller controller, Model model)
{ {
this.controller = controller;
this.model = model;
initComponents(); initComponents();
//this.setSize(windowWidth,windowHeight); //this.setSize(windowWidth,windowHeight);
this.setVisible(true); this.setVisible(true);
...@@ -30,6 +35,8 @@ public class View extends Window ...@@ -30,6 +35,8 @@ public class View extends Window
} }
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
...@@ -159,8 +166,7 @@ public class View extends Window ...@@ -159,8 +166,7 @@ public class View extends Window
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void newGameBTNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newGameBTNActionPerformed private void newGameBTNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newGameBTNActionPerformed
this.newGameButtonPressed = true; controller.newGameButtonPressed();
}//GEN-LAST:event_newGameBTNActionPerformed }//GEN-LAST:event_newGameBTNActionPerformed
private void settingsBTNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsBTNActionPerformed private void settingsBTNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsBTNActionPerformed
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package GUI.window;
/**
*
* @author Kovax
*/
public class GUIMSG extends Throwable
{
String msg_str;
int msg_int;
public GUIMSG()
{
msg_str = null;
msg_int = 0;
}
public GUIMSG(String test) {
this.msg_str = test;
}
public void setMsg(String msg_str)
{
this.msg_str = msg_str;
}
public void setMsg(int msg_int)
{
this.msg_int = msg_int;
}
@Override
public String toString()
{
if( msg_str != null )
return msg_str;
else
return Integer.toString(msg_int);
}
public Integer toInteger()
{
return msg_int;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Program;
import GUI.menu.Menu;
/**
*
* @author Kovax
*/
public class Game
{
Menu menu;
Thread BTNListener;
public Game()
{
Menu menu = new Menu();
this.menu = menu;
System.out.println(menuWaitForButton());
}
public int menuWaitForButton()
{
synchronized(menu)
{
while( true )
{
if( this.menu.controller.getButtonState() )
{
System.out.println("asdasdsadsasaddas");
return 1;
}
try
{
Thread.sleep(100);
}
catch(InterruptedException ex )
{
}
}
}
}
}
\ No newline at end of file
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
package Program; package Program;
import GUI.game.Game; import Program.Game;
import GUI.menu.Controller; import GUI.menu.Controller;
import GUI.menu.Menu; import GUI.menu.Menu;
import GUI.menu.Model; import GUI.menu.Model;
import GUI.menu.View; import GUI.menu.View;
import GUI.window.GUIMSG;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
...@@ -22,15 +23,7 @@ public class Program ...@@ -22,15 +23,7 @@ public class Program
public static void main(String[] args) public static void main(String[] args)
{ {
GUI.menu.Menu menu = new Menu(); Game game = new Game();
if( menu.show() == "newgame" )
{
GUI.game.Game game = new Game();
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment