/**********************************************************************
 *
 *   FreeDoko a Doppelkopf-Game
 *    
 *   Copyright (C) 2001-2005  by Diether Knof and Borg Enders
 *
 *   This program is free software; you can redistribute it and/or 
 *   modify it under the terms of the GNU General Public License as 
 *   published by the Free Software Foundation; either version 2 of 
 *   the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details. 
 *   You can find this license in the file 'gpl.txt'.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *   MA  02111-1307  USA
 *
 *  Contact:
 *    Diether Knof dknof@gmx.de
 *    Borg Enders  borg@borgsoft.de
 *
 *********************************************************************/

#include "constants.h"

#ifdef USE_UI_GTKMM

#include "ui.h"

#include "main_window.h"
#include "menu.h"
#include "party_settings.h"
#include "players_db.h"
#include "players.h"
#include "rules.h"
#include "table.h"
#include "party_points.h"

#include "../../basistypes.h"
#include "../../party/party.h"

#include <gtkmm/main.h>

namespace UI_GTKMM_NS {

  /**
   **
   ** start a new party
   **
   ** @param	-
   **
   ** @return	-
   **
   ** @version	0.5.4
   **
   ** @author	Diether Knof
   **
   **/
  void
    UI_GTKMM::start_new_party()
    {
      this->thrower(GAMESTATUS::PARTY_NEW);
      this->main_quit();

      return ;
    } // void UI_GTKMM::start_new_party()

  /**
   **
   ** end a party
   **
   ** @param	-
   **
   ** @return	-
   **
   ** @version	0.6.8
   **
   ** @author	Diether Knof
   **
   **/
  void
    UI_GTKMM::end_party()
    {
      this->thrower(GAMESTATUS::PARTY_FINISHED);
      this->main_quit();

      return ;
    } // void UI_GTKMM::end_party()

  /**
   **
   ** the party is opened
   **
   ** @param	party	party that is opened
   **
   ** @return	-
   **
   ** @version	0.6.7
   **
   ** @author	Diether Knof
   **
   **/
  void
    UI_GTKMM::party_open(Party& party)
    {
      this->UI::party_open(party);

      this->main_window->menu->party_open();
      this->table->party_open();
      this->players_db->party_open();

      this->thrower.throw_it();

      return ;
    } // void UI_GTKMM::party_open()

  /**
   **
   ** gets and sets the settings of the party:
   **   names, types and configuration of the players,
   **   rules,
   **   starting seed
   **   startplayer
   **
   ** @param	-
   **
   ** @return	-
   **
   ** @version	0.5.2
   **
   ** @author	Diether Knof
   **
   **/
  void
    UI_GTKMM::party_get_settings()
    {
      if (!FAST_PLAY)
	this->party_settings->get();

      this->thrower.throw_it();

      return ;
    } // void UI_GTKMM::party_get_Settings()

  /**
   **
   ** the party is started:
   ** the gametype and announcements of the other players are shown
   **
   ** @param	-
   **
   ** @return	-
   **
   ** @version	0.6.1
   **
   ** @author	Diether Knof
   **
   **/
  void
    UI_GTKMM::party_start()
    { 
      // the order is important:
      // first the party points window is created,
      // then the menu item can send signals to it
      this->table->party_start();
      this->main_window->menu->party_start();
      this->party_settings->players->sensitivity_update();
      this->party_settings->rules->sensitivity_update();

      this->thrower.throw_it();

      return ;
    } // void UI_GTKMM::party_start()

  /**
   **
   ** a new round is started in the party
   **
   ** @param	round	number of the round
   **
   ** @return	-
   **
   ** @version	0.6.7
   **
   ** @author	Diether Knof
   **
   **/
  void
    UI_GTKMM::party_start_round(unsigned const round)
    { 
      this->table->party_points_->party_start_round(round);

      this->thrower.throw_it();

      return ;
    } // void UI_GTKMM::party_start_round(unsigned const round)

  /**
   **
   ** the party is finished
   **
   ** @param	-
   **
   ** @return	-
   **
   ** @version	0.6.8
   **
   ** @author	Diether Knof
   **
   ** @todo	show the points and the winner
   **
   **/
  void
    UI_GTKMM::party_finish()
    {
      this->main_window->menu->party_finish();
      this->table->party_finish();

      this->thrower.throw_it();

      return ;
    } // void UI_GTKMM::party_end()

  /**
   **
   ** the party is closed
   **
   ** @param	-
   **
   ** @return	-
   **
   ** @version	0.6.7
   **
   ** @author	Diether Knof
   **
   **/
  void
    UI_GTKMM::party_close()
    {
      this->UI::party_close();

      this->players_db->party_close();
      this->main_window->menu->party_close();
      this->table->party_close();

      this->thrower.throw_it();

      return ;
    } // void UI_GTKMM::party_close()


} // namespace UI_GTKMM_NS

#endif // #ifdef USE_UI_GTKMM
