From 17787cfc438484dfbb0c13e9a9e6a224127e2038 Mon Sep 17 00:00:00 2001
From: Kovax <Kovax@Kovax-PC>
Date: Mon, 11 Nov 2013 13:32:31 +0100
Subject: [PATCH] Menuzeleles javitva

---
 src/GUI/menu/Controller.java | 47 ++++++++++++++--------------
 src/GUI/menu/Menu.java       | 22 +++++++++-----
 src/GUI/menu/Model.java      |  5 ++-
 src/GUI/menu/View.java       | 14 ++++++---
 src/GUI/window/GUIMSG.java   | 52 +++++++++++++++++++++++++++++++
 src/Program/Game.java        | 59 ++++++++++++++++++++++++++++++++++++
 src/Program/Program.java     | 17 +++--------
 7 files changed, 168 insertions(+), 48 deletions(-)
 create mode 100644 src/GUI/window/GUIMSG.java
 create mode 100644 src/Program/Game.java

diff --git a/src/GUI/menu/Controller.java b/src/GUI/menu/Controller.java
index 0b5b274..7378b00 100644
--- a/src/GUI/menu/Controller.java
+++ b/src/GUI/menu/Controller.java
@@ -6,41 +6,42 @@
 
 package GUI.menu;
 
+import GUI.window.GUIMSG;
+
 /**
  *
  * @author Kovax
  */
 public class Controller 
 {
+    private Boolean isNewGameButtonPressed = false;
+    
     private View view;
     private Model model;
+
     
-    public String pressedButton;
-    
-    public Controller(View view, Model model)
+    public Controller()
     {
-       this.view        = view;
-       this.model       = model;
-
+        this.view   = null;
+        this.model  = null;
+        this.isNewGameButtonPressed = false;
+    }
+    public void registerView(View view)
+    {
+        this.view = view;
+    }
+    public void registerModel(Model model)
+    {
+        this.model = model;
+    }
+    protected void newGameButtonPressed()
+    {
+        isNewGameButtonPressed = true;
+        //throw new GUIMSG("kakispite");
     }
-    public String getPressedButton()
+    public Boolean getButtonState()
     {
-       
-        while( true )
-       {
-           if( view.aboutButtonPresses )
-           {
-               return "about";
-           }
-           else if( view.newGameButtonPressed )
-           {
-               return "newgame";
-           }
-           else if( view.settingsButtonPressed )
-           {
-               return "settings";
-           }
-       }
+        return isNewGameButtonPressed;
     }
     
     
diff --git a/src/GUI/menu/Menu.java b/src/GUI/menu/Menu.java
index e3329a2..1c9b0e5 100644
--- a/src/GUI/menu/Menu.java
+++ b/src/GUI/menu/Menu.java
@@ -6,24 +6,30 @@
 
 package GUI.menu;
 
+
+
 /**
  *
  * @author Kovax
  */
-public class Menu {
+public class Menu  
+{
+    public Controller controller;
     
     public Menu()
     {
-        System.out.println("asdasd");
-        //View view = new View();
+        this.startGUI();
     }
-    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.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;
     }
-    
 }
diff --git a/src/GUI/menu/Model.java b/src/GUI/menu/Model.java
index 02af12e..5c94bd6 100644
--- a/src/GUI/menu/Model.java
+++ b/src/GUI/menu/Model.java
@@ -10,8 +10,9 @@ package GUI.menu;
  *
  * @author Kovax
  */
-public class Model 
+public class Model
 {
+    
     private String newGameButtonText;
     private String settingsButtonText;
     private String aboutButtonText;
@@ -19,4 +20,6 @@ public class Model
     public String getNewGameButtonText() { return this.newGameButtonText; }
     public String getSettingsButtonText() { return this.settingsButtonText; }
     public String getAboutButtonText() { return this.aboutButtonText; }
+    
+   
 }
diff --git a/src/GUI/menu/View.java b/src/GUI/menu/View.java
index c129e81..573a26a 100644
--- a/src/GUI/menu/View.java
+++ b/src/GUI/menu/View.java
@@ -8,19 +8,24 @@ package GUI.menu;
 
 import GUI.Window.Window;
 
+
 /**
  *
  * @author Kovax
  */
 public class View extends Window 
 {
+    Controller controller;
+    Model model;
+    
     Boolean newGameButtonPressed    = false;
     Boolean settingsButtonPressed   = false;
     Boolean aboutButtonPresses      = false;
     
-    public View() 
+    public View(Controller controller, Model model) 
     {
-        
+        this.controller = controller;
+        this.model = model;
         initComponents();
         //this.setSize(windowWidth,windowHeight);
         this.setVisible(true);
@@ -28,6 +33,8 @@ public class View extends Window
         this.createWindow();
         this.frame.setResizable( false );
     }
+
+
     
 
     /**
@@ -159,8 +166,7 @@ public class View extends Window
     }// </editor-fold>//GEN-END:initComponents
 
     private void newGameBTNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newGameBTNActionPerformed
-        this.newGameButtonPressed = true;
-        
+        controller.newGameButtonPressed();
     }//GEN-LAST:event_newGameBTNActionPerformed
 
     private void settingsBTNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsBTNActionPerformed
diff --git a/src/GUI/window/GUIMSG.java b/src/GUI/window/GUIMSG.java
new file mode 100644
index 0000000..320d1f3
--- /dev/null
+++ b/src/GUI/window/GUIMSG.java
@@ -0,0 +1,52 @@
+/*
+ * 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;
+    }
+}
diff --git a/src/Program/Game.java b/src/Program/Game.java
new file mode 100644
index 0000000..b314c6b
--- /dev/null
+++ b/src/Program/Game.java
@@ -0,0 +1,59 @@
+/*
+ * 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
diff --git a/src/Program/Program.java b/src/Program/Program.java
index 92024b9..3ecac79 100644
--- a/src/Program/Program.java
+++ b/src/Program/Program.java
@@ -6,11 +6,12 @@
 
 package Program;
 
-import GUI.game.Game;
+import Program.Game;
 import GUI.menu.Controller;
 import GUI.menu.Menu;
 import GUI.menu.Model;
 import GUI.menu.View;
+import GUI.window.GUIMSG;
 import java.util.ArrayList;
 
 /**
@@ -19,19 +20,11 @@ import java.util.ArrayList;
  */
 public class Program 
 {
-    public static void main(String[] args)
+    public static void main(String[] args)  
     {
        
-        GUI.menu.Menu menu = new Menu();
-        
-        if( menu.show() == "newgame" )
-        {
-            GUI.game.Game game = new Game();
-        }
-       
-        
-        
-        
+       Game game = new Game();
+ 
     }
      
 }
-- 
GitLab