package gui;

import java.awt.Color;
import java.awt.Dimension;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.LinkedList;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JComboBox;
import java.awt.event.ItemEvent;
import java.util.Random;
import java.util.ArrayList;

import java.io.StringBufferInputStream;
//import java.io.ByteArrayInputStream;
import org.xml.sax.InputSource;
import java.util.Timer;
import java.util.TimerTask;

import controller.IllegalDirectionException;
import controller.Instruction;
import controller.InstructionList;
import controller.LabyrinthField;
import controller.LevelHandler;
import controller.Robot;
import controller.TuringMachine;
import controller.IntStringMap;
import controller.SqlCommunicator;

/*
 * JApplet.java
 *
 * Changed on 24.09. 2005, 15:53
 */

/**
 * The Top level class
 * @author user
 */
public class TUGLabyrinth extends javax.swing.JApplet implements Runnable {
	private static final int DELAY_TIME_ = 120000; //=30 sec;
    private javax.swing.JApplet mainframe_ = this; //?????
    private static final int height = 580;
    private static final int width = 950;
    protected RuleTreePanel rule_tree_panel_;
    private JScrollPane rule_tree_scrollpane_;
    protected MenuePanel menue_panel_;
    private HashMap brick_images_;
    private JButton start_button_, stop_button_, step_button_, help_button_, new_rule_button_, next_button_;
    private StatusPanel status_message_;
    private SpeedPanel speed_panel_;
    private StatisticsPanel statistics_panel_;
    private AktiveRulePanel aktive_rule_panel_;
    private BrickImages images_;
    private Thread th_;
	protected String level_xpert_source_;
    private boolean stopp_;
    private int current_selected_=0;

    private boolean running_=true;
    private boolean wait_step_;
    private boolean exam_, running_applet_;
    private String typ_;
    protected ControllerGuiCommunicator controller_gui_communicator_;
       /**
     * ADDED FROM PrintGame
     * *********************************************************
     */
    // derzeit nï¿½ig
    //number of cells in a row and a col
    private final static int ROWS = 20;
    private final static int COLS = 20;
    protected static LabyrinthField labyrinth_field_;
    private static LevelHandler level_handler_;
    protected static Robot robot_;
    private InstructionList instruct_list_;
    protected TuringMachine turing_machine_;
    private PrintLabyrinth print_labyrinth_;
    private String file_name_;
    protected IntStringMap mark_array_;
    protected IntStringMap state_array_;
    private	ArrayList levels_;
    private Timer timer_;
    /**
     * ADDED FROM PrintGame
     */

  /*  private void AddCurrentProgramToLog()
    {
    	String current_program = "Current program:\n";
        LinkedList listi = rule_tree_panel_.getRuleList();
        for (int i = 0; i < listi.size(); i++)
        {
          Instruction dummy = ((ConditionRulePanel) listi.get(i)).getInstruction();
          current_program += "                                        " + dummy.toString();
        }
        SqlCommunicator.add_log(current_program);
    }*/
    /** Initializes the applet JApplet
	* Draws the applet and some of its buttons. Adds action listeners.
	* One of the object trees which may help you to understand the source is: Applet->LevelHandler->LoadLabyrinth->LabyrinthField
	*/
    public void init() {
    	// BEGIN OF WINDOW SETUP ****************************************************************
    	SqlCommunicator.add_log("Starting Applet");
    	if (getParameter("logging").equals("true"))
		{
    		SqlCommunicator.activate(true);
			System.out.println("logging == true");
		}
		else
			System.out.println("logging == false");

		if (getParameter("typ").equals("exam"))
		{
			typ_="exam";
			System.out.println("exam: ");
		}
		else if (getParameter("typ").equals("exercise"))
		{
			System.out.println("exercise: ");
			typ_="exercise";
		}
		else
		{
			System.out.println("normal: ");
			typ_="normal";
		}
		String abs_filename = getParameter("abs_filename");
		if(abs_filename==null)
		{
        	abs_filename = "Games/Game.xml";
			System.out.println("take default file: "+abs_filename);
		}
		else
			System.out.println("take file: "+abs_filename);
		URL new_url = null;
        try { new_url = new URL(getDocumentBase(), abs_filename);}
        catch (MalformedURLException ex){System.err.println(ex.getMessage());}
        file_name_ = new_url.toString(); // "Game.xml", Level-Info

	    instruct_list_= new InstructionList();
		levels_ = new ArrayList();
        mark_array_=new IntStringMap();
        state_array_=new IntStringMap();
        mark_array_.setString("0");
        mark_array_.setString("1");
        mark_array_.setString("2");
        mark_array_.setString("3");
//         state_array_.setString("NONE");
        state_array_.setString("grün");
        state_array_.setString("blau");
        state_array_.setString("rot");
        state_array_.setString("gelb");
        level_xpert_source_=null;
        getContentPane().setLayout(null);
        this.setSize(width, height);

        level_handler_ = new LevelHandler();
    	level_handler_.setDocumentBase(getDocumentBase());
		level_handler_.setMarkArray(mark_array_);
    	level_handler_.loadGameXmlFile(file_name_);

        status_message_= new StatusPanel();
        // Images -> HashMap "brick_images_"
        images_ =new BrickImages(getCodeBase());
        brick_images_=images_.loadImages();
        aktive_rule_panel_=new AktiveRulePanel(brick_images_ , this);
        rule_tree_panel_ = new RuleTreePanel(brick_images_,this, new Dimension(230, height - 39));

        //rule_tree_panel_.setPreferredSize(new Dimension(230, height - 10));
        rule_tree_scrollpane_ = new JScrollPane(rule_tree_panel_);
        print_labyrinth_ = new PrintLabyrinth(brick_images_, robot_, null, this);
        statistics_panel_ = new StatisticsPanel(this);
        speed_panel_= new SpeedPanel(this);

        start_button_ = new JButton();
        stop_button_ = new JButton();
        step_button_= new JButton();

        getContentPane().add(start_button_);
        getContentPane().add(stop_button_);
        getContentPane().add(step_button_);
        getContentPane().add(rule_tree_scrollpane_);
        getContentPane().add(print_labyrinth_);
        getContentPane().add(status_message_);
        getContentPane().add(statistics_panel_);
        getContentPane().add(speed_panel_);
        getContentPane().add(aktive_rule_panel_);

        print_labyrinth_.setBounds(265, 70, 400, 400);
		print_labyrinth_.setBackground(Color.ORANGE);

        status_message_.setBounds(265,490,400,65);
        status_message_.setBackground(Color.ORANGE);
        status_message_.setVisible(true);

        statistics_panel_.setBounds(677,62,265,150);
        speed_panel_.setBounds(677,230,265,100);
        aktive_rule_panel_.setBounds(677,348,265,125);

		this.getContentPane().setBackground(Color.ORANGE);

		if(typ_=="exam")
 		{
	 	rule_tree_scrollpane_.setBounds(5, 35, 248, height - 40 + 1);
	 	help_button_= new JButton();
        new_rule_button_= new JButton();
        next_button_=new JButton();
        getContentPane().add(help_button_);
		getContentPane().add(new_rule_button_);
	 	getContentPane().add(next_button_);
	 	drawNextButton();
 		drawNewRuleButton();
 		drawHelpButton();


		}
		else if (typ_=="exercise")
		{
		rule_tree_scrollpane_.setBounds(5, 35, 248, height - 40 + 1);
		help_button_= new JButton();
        new_rule_button_= new JButton();
        getContentPane().add(help_button_);
		getContentPane().add(new_rule_button_);
		drawNewRuleButton();
		drawHelpButton();
		drawLevelOfDifficulty();
		drawNewLabyrinth();
		}
		else
		{
			rule_tree_scrollpane_.setBounds(5, 10, 248, height - 40 + 1); // mit menue
			menue_panel_ = new MenuePanel(getCodeBase(),this);
			drawNewLabyrinth();
		}



		// END OF WINDOW SETUP ******************************************************************

		controller_gui_communicator_ = new ControllerGuiCommunicator(rule_tree_panel_, brick_images_, this);

    drawStepButton();
 	drawStopButton();
	drawStartButton();


	running_applet_=true;
  }

   // BEGIN OF START BUTTON  ***************************************************************
   protected void drawStartButton()
        {
        start_button_.setVisible(true);
        stop_button_.setVisible(false);
        step_button_.setVisible(false);
        start_button_.setBounds(730,500, 150, 30);
        start_button_.setBackground(new Color(127,127,127));
        start_button_.setForeground(Color.ORANGE);
        start_button_.setText("Neustart !");

         if(start_button_.getActionListeners().length==0)
         {
        start_button_.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) { // START BUTTON PRESSED
              System.out.println("\n START BUTTON PRESSED, Rule Tree -->");

  			  instruct_list_.removeAllInstructions();
              instruct_list_=controller_gui_communicator_.getInstructionListFromRuleTree();
              	SqlCommunicator.add_log("Start button pressed");
              	//if(typ_=="exam")
		    		//AddCurrentProgramToLog();
		    	URL logger_url;
		    	String user_id = getParameter("userid");
		    	try
		    	{
		    		logger_url = new URL(getCodeBase(),"logger.php");
// 		    		SqlCommunicator.flush_log(logger_url, user_id, menue_panel_.getCurrentSelectedLevel());
					SqlCommunicator.flush_log(logger_url, user_id, current_selected_);
		    	}
		    	catch(Exception e)
		    	{
		    		System.out.println("Log writing failed! (Could not get code base)");
		    	}
    // ------------------------------------------------------------------------------------------
            labyrinth_field_ = level_handler_.getLabyrinthField();
             drawStopButton();

             running_=false;
			 aktive_rule_panel_.removeAktiveRule();

             String text;
            Integer tmp,tmp2;
            if(th_==null)
              text="1";
            else
            {
              tmp = new Integer(Integer.parseInt(th_.getName()));
              text=Integer.toString(tmp.intValue()+1);
              th_.stop();
             }
            th_ = new Thread(TUGLabyrinth.this,text);
            System.out.println(th_.getName()+"new Thread");
            th_.start();// => Calls run()
            System.out.println(th_.getName()+"Thread.start()");
// //  		if(th_==null)
// // 		{
// // 			th_ = new Thread(TUGLabyrinth.this);
// // 			 th_.start();
// // 		}


            }
        });
     }
      }
   // END OF START BUTTON ***************************************************************

  protected void drawStopButton()
  {
    start_button_.setVisible(false);
    stop_button_.setVisible(true);
    step_button_.setVisible(false);
    stop_button_.setBounds(730,500, 150, 30);
    stop_button_.setBackground(new Color(127,127,127));
    stop_button_.setForeground(Color.ORANGE);
    stop_button_.setText("Stopp !");

    stopp_=false;
	if(stop_button_.getActionListeners().length==0)
    {
    stop_button_.addActionListener(new java.awt.event.ActionListener() {
     public void actionPerformed(java.awt.event.ActionEvent evt)
      {
	   SqlCommunicator.add_log("Stop button pressed");
       if(turing_machine_!=null)
       {
         start_button_.setVisible(true);
         stop_button_.setVisible(false);
         stopp_=true;
        }
       }
     });
 	}
    }

  protected void drawStepButton()
  {
	wait_step_=true;
	stopp_=false;
    start_button_.setVisible(false);
    stop_button_.setVisible(false);
    step_button_.setVisible(true);
    step_button_.setBounds(730,500, 150, 30);
    step_button_.setBackground(new Color(127,127,127));
    step_button_.setForeground(Color.ORANGE);
    step_button_.setText("Schritt!");
    if(step_button_.getActionListeners().length==0)
    {
    step_button_.addActionListener(new java.awt.event.ActionListener() {
     public void actionPerformed(java.awt.event.ActionEvent evt)
      {
	   SqlCommunicator.add_log("Step button pressed");
       if(turing_machine_!=null)
       {
        instruct_list_.removeAllInstructions();
        instruct_list_=controller_gui_communicator_.getInstructionListFromRuleTree();
        wait_step_=false;
        }
       }
     });
 	}
  }


private void drawHelpButton()
{
// BEGIN OF HELP BUTTON  ***********************************************
        help_button_.setBounds(682,5,255,28);
        help_button_.setBackground(new Color(127,127,127));
        help_button_.setForeground(Color.ORANGE);
        help_button_.setText("Hilfe");
        if(help_button_.getActionListeners().length==0)
    	{
        help_button_.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
	          SqlCommunicator.add_log("Help button pressed");
              HelpWindow help_window=new HelpWindow(getCodeBase());
              help_window.showHelpWindow();
            }
        });
    }
// END OF HELP BUTTON **************************************************
}

private void drawNewRuleButton()
{
// BEGIN OF NEW RULE BUTTON  *******************************************
		new_rule_button_.setBounds(5,5,248,28);
        new_rule_button_.setBackground(new Color(127,127,127));
        new_rule_button_.setForeground(Color.ORANGE);
        new_rule_button_.setText("Regel hinzufügen");
        if(new_rule_button_.getActionListeners().length==0)
    	{
        new_rule_button_.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) { // Load rules button pressed
                SqlCommunicator.add_log("New rule added");
                controller_gui_communicator_.addEmptyRule();
            }
        });
    }
        // END OF NEW RULE BUTTON **************************************************
}

private void drawLevelOfDifficulty()
{
        //Create the combo box, select the item at index 4.
        JLabel info_= new JLabel();
        info_.setOpaque(true);
        info_.setBackground(new Color(127,127,127));
        info_.setForeground(Color.ORANGE);
        info_.setText("        Schwierigkeitsgrad   ");
        info_.setBounds(290,5,350,28);
      	if (current_selected_==0)
      		current_selected_=1;
        if(level_handler_!=null)
		{
			final LinkedList level_name_list_ = level_handler_.getLevelNameList();
			String[] level_list_ = new String[level_name_list_.size()];
			int tmp=1;
        	for(int count=1; count<level_name_list_.size()+1;count++)
			{
				level_list_[count-1]=(String)level_name_list_.get(count-1);
				if(current_selected_==count )
				{
					tmp=count-1;
				}
			}
			final JComboBox level_of_difficulty_ = new JComboBox(level_list_);
			level_of_difficulty_.setBounds(465,8,155,20);
        	getContentPane().add(level_of_difficulty_);
        	getContentPane().add(info_);
			level_of_difficulty_.setSelectedIndex(tmp);
			if(level_of_difficulty_.getActionListeners().length==0)
			{
			level_of_difficulty_.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) { // Load rules button pressed
                JComboBox cb = (JComboBox)evt.getSource();
        		String name = (String)cb.getSelectedItem();
        		current_selected_= cb.getSelectedIndex()+1;
        		drawNewLabyrinth();
            }
        });
    }
	}
}

private void drawNextButton()
{
        next_button_.setBackground(new Color(127,127,127));
        next_button_.setForeground(Color.ORANGE);
        next_button_.setText("Weiter");
        next_button_.setBounds(290,5,350,28);

        if(level_handler_!=null)
		{
			//HACK -----drawNextButton darf nur 1 mal aufgerufen werden!!!
			int num_levels=level_handler_.getNumLevels();
			if(num_levels>=3)
			{
			levels_.add((Object)1);
			levels_.add((Object)2);
			ArrayList tmp=new ArrayList();
			final Random random_generator_ = new Random();
			for (int i=3; i <= num_levels; i++)
				tmp.add((Object)i);
			for (int i=3; i <= num_levels; i++)
				levels_.add(tmp.remove(random_generator_.nextInt(tmp.size())));
			if(levels_.size()>0)
	        {

			current_selected_=(Integer)levels_.remove(0);
			drawNewLabyrinth();
			}
			}
			else
				System.err.println("More than 3 Levels requested");
			//-----------------------------------------------------------
			if(next_button_.getActionListeners().length==0)
			{
				performNextButton(DELAY_TIME_);
    		}
		}
}

private void performNextButton(int delay)
{
	next_button_.setVisible(false);
	timer_=new Timer();
	timer_.schedule(new TimerTask(){public void run()
	{
		next_button_.setVisible(true);
		if (next_button_.getActionListeners().length==0)
		{
		next_button_.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
	    SqlCommunicator.add_log("Next button pressed");
	      if(levels_.size()>0)
	      {
	        current_selected_=(Integer)levels_.remove(0);
        	drawNewLabyrinth();
    	  }
    	  else
    	  {
	    	JLabel finish= new JLabel();
        	finish.setOpaque(true);
       	 	finish.setBackground(new Color(127,127,127));
        	finish.setForeground(Color.ORANGE);
        	finish.setText("                             Alle Labyrinthe bearbeitet...");
        	finish.setBounds(265, 70, 400, 400);
        	getContentPane().remove(print_labyrinth_);
        	getContentPane().remove(next_button_);
        	getContentPane().remove(start_button_);
        	getContentPane().remove(stop_button_);
        	getContentPane().remove(step_button_);

        	getContentPane().add(finish);
			aktive_rule_panel_.removeAktiveRule();
			statistics_panel_.clearPanel();

			status_message_.clear();
			status_message_.setNewFirstLine("   Danke für Ihre Teilnahme!");
        	rule_tree_panel_.deleteAllRules();
			repaint();
	      }
	       java.awt.event.ActionListener[] tmp =next_button_.getActionListeners();
           next_button_.removeActionListener(tmp[0]);
           }
        });
    }
    }} , delay);
}


//   public void updateRuleTreePanel()
//   {
//     if(aktive_rule_panel_.getInstruction()!=null)
//     {
//       int id=aktive_rule_panel_.getRuleId();
//       if(id > 0)
//       {
//         rule_tree_panel_.updateRule(aktive_rule_panel_.getInstruction(),id);
//       }
//     }
//   }

	/** This methods job is to generate a new labyrinth.
	* It is intended to be called from the action listener of the draw_button_ and from the action listener
	* of the MenuePanel.
	* @author Bernhard Kornberger
	*/
	public void drawNewLabyrinth()
	{
	running_=false;
	stopp_=false;
    start_button_.setVisible(true);
    stop_button_.setVisible(false);

    if(menue_panel_!=null)
    {
 	 menue_panel_.refreshList();
     if(menue_panel_.getCurrentSelectedLevel()==0)
     {
       if(level_xpert_source_!=null)
       {
       InputSource tmp=new InputSource(new StringBufferInputStream(level_xpert_source_));
       level_handler_.loadLevel(tmp);
       SqlCommunicator.add_log("Level: Expert Source" );
       }
       else
       System.err.println("Input Source == Null");
     }
     else
     {
       level_handler_.loadLevel(menue_panel_.getCurrentSelectedLevel());
       SqlCommunicator.add_log("Level: " +  menue_panel_.getCurrentSelectedLevel());
 	 }

     System.out.println("Level: " + menue_panel_.getCurrentSelectedLevel());
	}
	else
	{
		if (current_selected_==0)
		current_selected_=1;
		level_handler_.loadLevel(current_selected_);
		System.out.println("Level " + current_selected_);
		if (typ_=="exam")
			performNextButton(DELAY_TIME_);
		SqlCommunicator.add_log("Level " + current_selected_);
	}

	 rule_tree_panel_.deleteAllRules();
	 labyrinth_field_ = level_handler_.getLabyrinthField();
// 	 if(robot_==null)
		 robot_ = new Robot();
	 robot_.setPos(labyrinth_field_.getStartpointRow(), labyrinth_field_.getStartpointCol());
	try
	{
		robot_.setStartDirection(labyrinth_field_.getStartDirection());
	}
	catch (IllegalDirectionException ex)
	{
	        System.err.println(ex.getMessage());
	}

    print_labyrinth_.setLabyrinthField(labyrinth_field_);
	print_labyrinth_.setTUGLabyrinth(this);
 	print_labyrinth_.setRobot(robot_);
    aktive_rule_panel_.removeAktiveRule();

//_______________________________Achtung ! ________-1 Anzahl der Startpunkte____________________
    statistics_panel_.setFieldcountDiamondcount(labyrinth_field_.getNumWayCells()-1, labyrinth_field_.getNumDiamonds());
    statistics_panel_.resetPanel();
	status_message_.clear();
	status_message_.setNewFirstLine("   Marvin-10 programmieren...");
    aktive_rule_panel_.removeAktiveRule();
    repaint();
		}



	/**
	* Used to start a new thread and intended to be called from the start button's action listener defined in init()
	*/

public void  stop()
{
	SqlCommunicator.add_log("Stopping applet ");

	running_applet_= false;
	running_=false;
	try
	{
	if(th_!=null)
		th_.join();
	}
	catch (InterruptedException ex)
	{
	System.err.println(ex.getMessage());
	}
}

public void  destroy()
{
	running_applet_= false;
	running_=false;
	try
	{
	if(th_!=null)
		th_.join();
	}
	catch (InterruptedException ex)
	{
	System.err.println(ex.getMessage());
	}
}

	public synchronized void  run()
	{
		try
		{
			if(level_handler_.getLabyrinthField()!=null)
			{
				robot_ = new Robot();
        		robot_.setPos(labyrinth_field_.getStartpointRow(), labyrinth_field_.getStartpointCol());
        		robot_.setStartDirection(labyrinth_field_.getStartDirection());
 				print_labyrinth_.setLabyrinthField(labyrinth_field_);
 				print_labyrinth_.setTUGLabyrinth(this);
         		print_labyrinth_.setRobot(robot_);
        		turing_machine_ = new TuringMachine(print_labyrinth_, labyrinth_field_, robot_);
    			}
			running_=true;
			while(running_==true && turing_machine_.checkStartPoint()==false)
			{
				boolean step_ok=false;
				int delay=speed_panel_.getDelay();
				turing_machine_.setInstructionList(instruct_list_);
				InstructionList possible= turing_machine_.getPossibleInstructions();
				if(possible.size()==0)
				{
					aktive_rule_panel_.removeAktiveRule();
					status_message_.clearSecondLine();
				}
				status_message_.setNewFirstLine(turing_machine_.getMessage());
				repaint();

				aktive_rule_panel_.setRuleList(controller_gui_communicator_.ruleListFromInstructionList(possible));

				if(delay==0)
        			{
	        			drawStepButton();
	        			Thread.sleep(50);
	        			wait_step_=true;
					while (wait_step_==true && speed_panel_.getDelay()==0 && running_==true)
					{
						Thread.sleep(50);
					}
					turing_machine_.setInstructionList(instruct_list_);
					turing_machine_.selectPossibleInstructions();
					step_ok =turing_machine_.makeSingleStepWithRandInstruction();
					if(step_ok==false)
						status_message_.setNewSecondLine(turing_machine_.getMessage());
					else
						status_message_.setNewSecondLine("   Warte auf nächsten Schritt");
					repaint();
				}
				else
				{
					step_ok =turing_machine_.makeSingleStepWithRandInstruction();
					status_message_.setNewSecondLine(turing_machine_.getMessage());
					repaint();
					if(stopp_==true && step_ok==true)
					{
						status_message_.setNewSecondLine("   Programm angehalten");
						repaint();
					}
					while(stopp_==true && running_==true)
					{
						Thread.sleep(50);
					}
					drawStopButton();
					repaint();
 					Thread.sleep(delay);
 					th_.yield();
				}

				if(step_ok==false && running_==true)
				{
					drawStartButton();
					stopp_=true;
					repaint();
				}
				else
					statistics_panel_.refreshPanel(robot_.getNumSteps(), robot_.getNumTakenThings(), turing_machine_.getNumVisited());
  			}
			if (turing_machine_.checkStartPoint()==true)
			{
				System.out.println("labyrinth_field_.getNumDiamonds()" + labyrinth_field_.getNumDiamonds() + "robot_.getNumTakenThings()" + robot_.getNumTakenThings());
				if(labyrinth_field_.getNumDiamonds() == 0 && typ_=="exam")
				{
				if (timer_!=null)
					timer_.cancel();
				performNextButton(5);
				}
				status_message_.setNewFirstLine("   Der Roboter hat das Labyrinth verlassen!");
				status_message_.clearSecondLine();
			}
			repaint();
			start_button_.setVisible(true);
			step_button_.setVisible(false);
			stop_button_.setVisible(false);
          	stopp_=false;
        	}
		catch (IllegalDirectionException ex)
		{
		System.err.println(ex.getMessage());
		}
		catch (InterruptedException ex)
		{
		System.err.println(ex.getMessage());
		}
}



    public LevelHandler getLevelHandler()
    {
    	return level_handler_;
	}

	public String getConfigFileName()
    {
    	return file_name_;
	}

    public void menuePanelRefreshList(int number)
    {
  	 menue_panel_.refreshList(number);
	}

	public void menuePanelRefreshList()
	{
        menue_panel_.refreshList();
    }

    public void menuePanelDecrementCount()
    {
       menue_panel_.decrementCount();
	}

}
