2004-04-08 09:43:06 +00:00
|
|
|
|
/* Eliot */
|
|
|
|
|
/* Copyright (C) 1999 Antoine Fraboulet */
|
|
|
|
|
/* */
|
2005-12-26 15:28:57 +00:00
|
|
|
|
/* This file is part of Eliot. */
|
|
|
|
|
/* */
|
|
|
|
|
/* Eliot is free software; you can redistribute it and/or modify */
|
2004-04-08 09:43:06 +00:00
|
|
|
|
/* 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. */
|
|
|
|
|
/* */
|
2005-12-26 15:28:57 +00:00
|
|
|
|
/* Eliot is distributed in the hope that it will be useful, */
|
2004-04-08 09:43:06 +00:00
|
|
|
|
/* 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 should have received a copy of the GNU General Public License */
|
|
|
|
|
/* along with this program; if not, write to the Free Software */
|
2005-10-23 14:53:42 +00:00
|
|
|
|
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-12-26 15:28:57 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file mainframe.cc
|
|
|
|
|
* \brief Main frame for the Eliot GUI
|
|
|
|
|
* \author Antoine Fraboulet
|
|
|
|
|
* \date 2005
|
|
|
|
|
*/
|
|
|
|
|
|
2004-04-08 09:43:06 +00:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <iostream>
|
2005-02-05 11:14:56 +00:00
|
|
|
|
#include <fstream>
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
2005-01-01 15:42:55 +00:00
|
|
|
|
#include "wx/intl.h"
|
|
|
|
|
#include "wx/menu.h"
|
|
|
|
|
#include "wx/statusbr.h"
|
|
|
|
|
#include "wx/sizer.h"
|
|
|
|
|
#include "wx/filedlg.h"
|
|
|
|
|
#include "wx/msgdlg.h"
|
|
|
|
|
|
2004-04-08 09:43:06 +00:00
|
|
|
|
#include "ewx.h"
|
|
|
|
|
|
|
|
|
|
#include "dic.h"
|
2005-03-29 07:00:39 +00:00
|
|
|
|
#include "game.h"
|
|
|
|
|
#include "game_factory.h"
|
2005-11-05 15:48:59 +00:00
|
|
|
|
#include "player.h"
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
#include "configdb.h"
|
|
|
|
|
#include "confdimdlg.h"
|
|
|
|
|
#include "confsearch.h"
|
|
|
|
|
#include "printout.h"
|
|
|
|
|
#include "mainframe.h"
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_SAVE_POSTSCRIPT
|
|
|
|
|
#include "wx/dcps.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
Menu_Game_New = 1000,
|
|
|
|
|
Menu_Game_Open,
|
|
|
|
|
Menu_Game_Save,
|
|
|
|
|
Menu_Game_Print,
|
|
|
|
|
Menu_Game_PrintPreview,
|
|
|
|
|
Menu_Game_PrintPS,
|
|
|
|
|
|
|
|
|
|
Menu_Conf_Game = 2000,
|
|
|
|
|
Menu_Conf_Game_Dic,
|
|
|
|
|
Menu_Conf_Game_Tiles,
|
|
|
|
|
Menu_Conf_Game_Search,
|
|
|
|
|
Menu_Conf_Print,
|
|
|
|
|
Menu_Conf_Aspect = 2100,
|
2005-12-26 15:28:57 +00:00
|
|
|
|
Menu_Conf_Tile,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_DrawTiles,
|
2005-02-05 11:14:56 +00:00
|
|
|
|
Menu_Conf_Aspect_Font,
|
|
|
|
|
Menu_Conf_Aspect_Font_Search = 2110,
|
|
|
|
|
Menu_Conf_Aspect_Font_Board = 2111,
|
|
|
|
|
Menu_Conf_Aspect_Font_Default = 2112,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour = 2200,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Lines = 2201,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Wx2 = 2202,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Wx3 = 2203,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Lx2 = 2204,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Lx3 = 2205,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Background = 2206,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Letters = 2207,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_TestLetters = 2208,
|
2005-12-26 15:28:57 +00:00
|
|
|
|
Menu_Conf_Aspect_BoardColour_TileBack = 2209,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_TestTileBack = 2210,
|
|
|
|
|
Menu_Conf_Aspect_BoardColour_Default = 2211,
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
#define IDBASE 3300
|
2005-02-05 11:14:56 +00:00
|
|
|
|
Menu_ShowVerif = (IDBASE + ID_Frame_Verif),
|
|
|
|
|
Menu_ShowSearch = (IDBASE + ID_Frame_Search),
|
|
|
|
|
Menu_ShowPlus1 = (IDBASE + ID_Frame_Plus1),
|
|
|
|
|
Menu_ShowRacc = (IDBASE + ID_Frame_Racc),
|
|
|
|
|
Menu_ShowBenj = (IDBASE + ID_Frame_Benj),
|
|
|
|
|
Menu_ShowBag = (IDBASE + ID_Frame_Bag),
|
2005-12-26 22:59:57 +00:00
|
|
|
|
Menu_ShowBoard = (IDBASE + ID_Frame_Board),
|
|
|
|
|
Menu_ShowGame = (IDBASE + ID_Frame_Game),
|
|
|
|
|
Menu_ShowResult = (IDBASE + ID_Frame_Result),
|
2005-02-05 11:14:56 +00:00
|
|
|
|
|
|
|
|
|
Menu_Quit_Apropos = 4000,
|
|
|
|
|
Menu_Quit_Confirm,
|
|
|
|
|
|
|
|
|
|
Button_SetRack = 10000,
|
|
|
|
|
Button_SetNew,
|
|
|
|
|
Button_SetManual,
|
|
|
|
|
Button_Search,
|
|
|
|
|
Button_Play,
|
|
|
|
|
Button_PlayBack,
|
|
|
|
|
|
|
|
|
|
ListCtrl_ID = 11000,
|
|
|
|
|
Rack_ID,
|
|
|
|
|
Status_ID,
|
2004-04-08 09:43:06 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
|
|
|
|
EVT_MENU(Menu_Game_New, MainFrame::OnMenuGameNew)
|
|
|
|
|
EVT_MENU(Menu_Game_Open, MainFrame::OnMenuGameOpen)
|
|
|
|
|
EVT_MENU(Menu_Game_Save, MainFrame::OnMenuGameSave)
|
|
|
|
|
EVT_MENU(Menu_Game_Print, MainFrame::OnMenuGamePrint)
|
|
|
|
|
EVT_MENU(Menu_Game_PrintPreview, MainFrame::OnMenuGamePrintPreview)
|
|
|
|
|
EVT_MENU(Menu_Game_PrintPS, MainFrame::OnMenuGamePrintPS)
|
|
|
|
|
//
|
|
|
|
|
EVT_MENU(Menu_Conf_Game_Dic, MainFrame::OnMenuConfGameDic)
|
|
|
|
|
EVT_MENU(Menu_Conf_Game_Search, MainFrame::OnMenuConfGameSearch)
|
|
|
|
|
//
|
|
|
|
|
EVT_MENU(Menu_Conf_Print, MainFrame::OnMenuConfPrint)
|
|
|
|
|
//
|
|
|
|
|
EVT_MENU_RANGE(Menu_Conf_Aspect_Font_Search, Menu_Conf_Aspect_Font_Default, MainFrame::OnMenuConfAspectFont)
|
|
|
|
|
EVT_MENU_RANGE(Menu_Conf_Aspect_BoardColour_Lines, Menu_Conf_Aspect_BoardColour_Default, MainFrame::OnMenuConfAspectBoardColour)
|
2005-12-26 22:59:57 +00:00
|
|
|
|
EVT_MENU_RANGE(Menu_ShowVerif, Menu_ShowResult, MainFrame::OnMenuShowFrame)
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
|
|
|
|
EVT_MENU(Menu_Quit_Apropos, MainFrame::OnMenuQuitApropos)
|
|
|
|
|
EVT_MENU(Menu_Quit_Confirm, MainFrame::OnMenuQuitConfirm)
|
|
|
|
|
//
|
|
|
|
|
EVT_BUTTON(Button_Play, MainFrame::OnPlay)
|
|
|
|
|
EVT_BUTTON(Button_SetRack, MainFrame::OnSetRack)
|
|
|
|
|
EVT_BUTTON(Button_SetNew, MainFrame::OnSetRack)
|
|
|
|
|
EVT_BUTTON(Button_Search, MainFrame::OnSearch)
|
|
|
|
|
EVT_BUTTON(Button_PlayBack, MainFrame::OnPlay)
|
|
|
|
|
//
|
2006-01-01 19:33:51 +00:00
|
|
|
|
EVT_TEXT_ENTER(Rack_ID, MainFrame::OnTextEnter)
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
|
|
|
|
EVT_CLOSE(MainFrame::OnCloseWindow)
|
|
|
|
|
//
|
2006-01-01 19:33:51 +00:00
|
|
|
|
//EVT_MENU(Menu_Help, MainFrame::OnMenuHelp)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// ******************************
|
|
|
|
|
//
|
|
|
|
|
// ******************************
|
|
|
|
|
|
2007-08-04 20:01:27 +00:00
|
|
|
|
MainFrame::MainFrame(wxPoint __UNUSED__ pos_, wxSize size_) :
|
|
|
|
|
wxFrame((wxFrame *) NULL, -1, wxT(APPNAME), wxPoint(-1, -1),
|
|
|
|
|
size_, wxDEFAULT_FRAME_STYLE, wxT(APPNAME)), m_dic(NULL), m_game(NULL)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2006-08-11 22:17:54 +00:00
|
|
|
|
#if defined(ENABLE_RESLIST_IN_MAIN)
|
2005-12-26 22:59:57 +00:00
|
|
|
|
reslist = NULL;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
#endif
|
2005-12-26 22:59:57 +00:00
|
|
|
|
statusbar = NULL;
|
2005-03-29 07:00:39 +00:00
|
|
|
|
for(int i=0 ; i < MAX_FRAME_ID; i++)
|
|
|
|
|
auxframes_ptr[i] = NULL;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
wxString dicpath = config.getDicPath();
|
|
|
|
|
Dic_load(&m_dic, dicpath.mb_str());
|
|
|
|
|
if (m_dic == NULL)
|
|
|
|
|
{
|
|
|
|
|
wxCommandEvent event;
|
|
|
|
|
OnMenuConfGameDic(event);
|
|
|
|
|
}
|
|
|
|
|
m_game = GameFactory::Instance()->createTraining(m_dic);
|
|
|
|
|
if (m_game)
|
|
|
|
|
{
|
|
|
|
|
m_game->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wxBoxSizer *listsizer = new wxBoxSizer(wxVERTICAL);
|
2005-02-05 11:14:56 +00:00
|
|
|
|
rack = new wxTextCtrl(this, Rack_ID, wxU(""), wxPoint(-1, -1), wxSize(-1, -1), wxTE_PROCESS_ENTER);
|
2005-12-26 22:59:57 +00:00
|
|
|
|
listsizer->Add(rack , 0 , wxEXPAND | wxALL, 1);
|
2006-08-11 22:17:54 +00:00
|
|
|
|
rack->SetToolTip(_("Tirage"));
|
2005-12-26 22:59:57 +00:00
|
|
|
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
|
|
|
|
reslist = new GfxResult(this,(MainFrame*)this,m_game);
|
|
|
|
|
listsizer->Add(reslist, 1, wxEXPAND | wxLEFT | wxRIGHT, 1);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
#endif
|
2005-02-05 11:14:56 +00:00
|
|
|
|
|
|
|
|
|
InitMenu();
|
|
|
|
|
|
|
|
|
|
statusbar = CreateStatusBar(2, 0, Status_ID);
|
|
|
|
|
int ww[2] = {-1, 160};
|
|
|
|
|
statusbar->SetStatusWidths(2, ww);
|
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
|
2006-08-11 22:17:54 +00:00
|
|
|
|
b_rackrandomset = new wxButton(this, Button_SetRack, _(" Tirage "));
|
|
|
|
|
b_rackrandomnew = new wxButton(this, Button_SetNew, _(" Complement "));
|
|
|
|
|
b_search = new wxButton(this, Button_Search, _(" Rechercher "));
|
|
|
|
|
b_back = new wxButton(this, Button_PlayBack, _(" Arriere "));
|
|
|
|
|
b_play = new wxButton(this, Button_Play, _(" Jouer "));
|
2005-12-26 15:28:57 +00:00
|
|
|
|
|
2006-08-11 22:17:54 +00:00
|
|
|
|
b_rackrandomset->SetToolTip(_("Tirage aleatoire"));
|
|
|
|
|
b_rackrandomnew->SetToolTip(_("Complement aleatoire du tirage"));
|
|
|
|
|
b_search->SetToolTip( _("Recherche sur le tirage courant"));
|
|
|
|
|
b_back->SetToolTip( _("Revenir un coup en arriere"));
|
|
|
|
|
b_play->SetToolTip( _("Jouer le mot selectionne"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
|
|
|
|
|
wxBoxSizer *buttonsizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
buttonsizer->Add(b_rackrandomset, 1, wxEXPAND | wxTOP | wxBOTTOM | wxLEFT , 1);
|
|
|
|
|
buttonsizer->Add(b_rackrandomnew, 1, wxEXPAND | wxTOP | wxBOTTOM , 1);
|
|
|
|
|
buttonsizer->Add(b_search, 1, wxEXPAND | wxTOP | wxBOTTOM , 1);
|
|
|
|
|
buttonsizer->Add(b_back, 1, wxEXPAND | wxTOP | wxBOTTOM , 1);
|
|
|
|
|
buttonsizer->Add(b_play, 1, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, 1);
|
|
|
|
|
|
|
|
|
|
wxBoxSizer *mainsizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
|
mainsizer->Add(listsizer , 1, wxEXPAND | wxVERTICAL, 0);
|
|
|
|
|
mainsizer->Add(buttonsizer, 0, wxEXPAND , 0);
|
|
|
|
|
|
|
|
|
|
SetAutoLayout(TRUE);
|
|
|
|
|
SetSizer(mainsizer);
|
|
|
|
|
mainsizer->Fit(this);
|
|
|
|
|
mainsizer->SetSizeHints(this);
|
|
|
|
|
|
|
|
|
|
SetClientSize(size_);
|
|
|
|
|
Move(config.getFramePos(wxT(APPNAME)));
|
2005-03-29 07:00:39 +00:00
|
|
|
|
|
|
|
|
|
InitFrames();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// ******************************
|
|
|
|
|
//
|
|
|
|
|
// ******************************
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
MainFrame::~MainFrame()
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
config.setFramePos(wxT(APPNAME), GetPosition());
|
|
|
|
|
config.setFrameSize(wxT(APPNAME), GetClientSize());
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-03-29 07:00:39 +00:00
|
|
|
|
if (m_game != NULL)
|
|
|
|
|
{
|
|
|
|
|
GameFactory::Instance()->releaseGame(*m_game);
|
|
|
|
|
m_game = NULL;
|
|
|
|
|
}
|
2005-11-04 20:00:05 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (m_dic)
|
2005-03-29 07:00:39 +00:00
|
|
|
|
{
|
|
|
|
|
Dic_destroy(m_dic);
|
|
|
|
|
}
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// ******************************
|
|
|
|
|
//
|
|
|
|
|
// ******************************
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::InitMenu()
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
// menus
|
|
|
|
|
wxMenu *menu_game = new wxMenu;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_game->Append(Menu_Game_New, _("Nouvelle"), _("Demarrer une nouvelle partie"));
|
|
|
|
|
menu_game->Append(Menu_Game_Open, _("Charger..."), _("Charger une partie"));
|
|
|
|
|
menu_game->Append(Menu_Game_Save, _("Sauver..."), _("Sauver cette partie"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
menu_game->AppendSeparator();
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_game->Append(Menu_Game_Print, _("Imprimer..."), _("Imprimer cette partie"));
|
|
|
|
|
menu_game->Append(Menu_Game_PrintPreview, _("Preimpression"), _("Preimpression de la partie"));
|
2004-04-08 09:43:06 +00:00
|
|
|
|
#ifdef ENABLE_SAVE_POSTSCRIPT
|
2005-02-05 11:14:56 +00:00
|
|
|
|
menu_game->AppendSeparator();
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_game->Append(Menu_Game_PrintPS, _("Imprimer du PostScript"), _("Imprimer dans un fichier PostScript"));
|
2004-04-08 09:43:06 +00:00
|
|
|
|
#endif
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_conf_game = new wxMenu;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_conf_game->Append(Menu_Conf_Game_Dic, _("Dictionnaire"), _("Choix du dictionnaire"));
|
|
|
|
|
menu_conf_game->Append(Menu_Conf_Game_Search, _("Recherche"), _("Options de recherche"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
2005-12-26 15:28:57 +00:00
|
|
|
|
wxMenu *menu_tileback = new wxMenu;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_tileback->Append(Menu_Conf_Aspect_BoardColour_Letters , _("Lettres jouees"), _("Lettres jouees sur la grille"));
|
|
|
|
|
menu_tileback->Append(Menu_Conf_Aspect_BoardColour_TestLetters , _("Lettres provisoires"), _("Lettres du mot a jouer"));
|
2005-12-26 15:28:57 +00:00
|
|
|
|
menu_tileback->AppendSeparator();
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_tileback->Append(Menu_Conf_Aspect_BoardColour_TileBack , _("Fonds lettres jouees"), _("Fonds des pions sur la grille"));
|
|
|
|
|
menu_tileback->Append(Menu_Conf_Aspect_BoardColour_TestTileBack, _("Fonds lettres provisoires"), _("Fonds des pions sur la grille"));
|
2005-12-26 15:28:57 +00:00
|
|
|
|
//
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxMenu *menu_conf_board_colour = new wxMenu;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Background, _("Fond"), _("Couleur du fond"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Lines, _("Lignes"), _("Couleur des lignes"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Tile, _("Pions et lettres"), menu_tileback, _("Pions et lettres"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
menu_conf_board_colour->AppendSeparator();
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Letters, _("Lettres jouees"), _("Lettres jouees sur la grille"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_TestLetters, _("Lettres provisoires"), _("Lettres du mot a jouer"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
menu_conf_board_colour->AppendSeparator();
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Wx2, _("Mot compte double"), _("Mot compte double"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Wx3, _("Mot compte triple"), _("Mot compte triple"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Lx2, _("Lettre compte double"), _("Lettre compte double"));
|
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Lx3, _("Lettre compte triple"), _("Lettre compte triple"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
menu_conf_board_colour->AppendSeparator();
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_conf_board_colour->Append(Menu_Conf_Aspect_BoardColour_Default, _("Couleurs d'origine"), _("Retrouver les couleurs d'origine"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_conf_board_font = new wxMenu;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
// XXX: menu_conf_board_font->Append(Menu_Conf_Aspect_Font_Search, _("Lettres de recherche"), _("Police de caract<63>res pour les recherches"));
|
|
|
|
|
menu_conf_board_font->Append(Menu_Conf_Aspect_Font_Search, _("Lettres de recherche"), _("Police de caracteres pour les recherches"));
|
|
|
|
|
// XXX: menu_conf_board_font->Append(Menu_Conf_Aspect_Font_Board, _("Lettres de la grille"), _("Police de caract<63>res de la grille"));
|
|
|
|
|
menu_conf_board_font->Append(Menu_Conf_Aspect_Font_Board, _("Lettres de la grille"), _("Police de caracteres de la grille"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_conf = new wxMenu;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_conf->Append(Menu_Conf_Game, _("Jeu"), menu_conf_game, _("Configuration du jeu"));
|
|
|
|
|
menu_conf->Append(Menu_Conf_Aspect_Font, _("Fonte des lettres"), menu_conf_board_font, _("Modification des fontes"));
|
|
|
|
|
menu_conf->Append(Menu_Conf_Aspect_BoardColour, _("Couleurs de la grille"), menu_conf_board_colour, _("Modification des couleurs"));
|
|
|
|
|
menu_conf->Append(Menu_Conf_Print, _("Impression"), _("Dimensions de la partie"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_frame = new wxMenu;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_frame->Append(Menu_ShowBoard, _("Grille"), _("Grille de jeu"));
|
|
|
|
|
// XXX: menu_frame->Append(Menu_ShowVerif, _("V<>rification"), _("V<>rification d'un mot dans le dictionnaire"));
|
|
|
|
|
menu_frame->Append(Menu_ShowVerif, _("Verification"), _("Verification d'un mot dans le dictionnaire"));
|
|
|
|
|
menu_frame->Append(Menu_ShowSearch, _("Recherche"), _("Recherche dans le dictionnaire"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
menu_frame->AppendSeparator();
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_frame->Append(Menu_ShowPlus1, _("Tirage + 1"), _("Lettres du tirage plus une"));
|
|
|
|
|
menu_frame->Append(Menu_ShowRacc, _("Raccords"), _("Raccords sur un mot de la recherche"));
|
|
|
|
|
menu_frame->Append(Menu_ShowBenj, _("Benjamins"), _("Benjamins sur un mot de la recherche"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
menu_frame->AppendSeparator();
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_frame->Append(Menu_ShowBag, _("Sac"), _("Lettres restantes dans le sac"));
|
2005-12-26 22:59:57 +00:00
|
|
|
|
menu_frame->AppendSeparator();
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_frame->Append(Menu_ShowGame, _("Partie"), _("Partie"));
|
2005-12-26 22:59:57 +00:00
|
|
|
|
#ifndef ENABLE_RESLIST_IN_MAIN
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_frame->Append(Menu_ShowResult, _("Resultats"), _("Resultats"));
|
2005-12-26 22:59:57 +00:00
|
|
|
|
#endif
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
|
|
|
|
wxMenu *menu_quit = new wxMenu;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_quit->Append(Menu_Quit_Apropos, _("A propos..."), _("A propos d'Eliot"));
|
|
|
|
|
menu_quit->Append(Menu_Quit_Confirm, _("Quitter"), _("Quitter"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
//
|
|
|
|
|
wxMenuBar *menu_bar = new wxMenuBar;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
menu_bar->Append(menu_game, _("Partie"));
|
|
|
|
|
menu_bar->Append(menu_conf, _("Configuration"));
|
|
|
|
|
// XXX: menu_bar->Append(menu_frame, _("Fen<65>tres"));
|
|
|
|
|
menu_bar->Append(menu_frame, _("Fenetres"));
|
|
|
|
|
menu_bar->Append(menu_quit, _("Quitter"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
|
|
|
|
|
SetMenuBar(menu_bar);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// *******************
|
|
|
|
|
//
|
|
|
|
|
// *******************
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnCloseWindow(wxCloseEvent&)
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
this->Destroy();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// *******************
|
|
|
|
|
// NEW
|
|
|
|
|
// *******************
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGameNew(wxCommandEvent&)
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (m_dic == NULL)
|
2005-03-29 07:00:39 +00:00
|
|
|
|
{
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxMessageBox(_("Il n'y a pas de dictionnaire selectionne"), _("Eliot: erreur"),
|
2005-03-29 07:00:39 +00:00
|
|
|
|
wxICON_INFORMATION | wxOK);
|
2005-02-05 11:14:56 +00:00
|
|
|
|
return;
|
2005-03-29 07:00:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-08-11 22:17:54 +00:00
|
|
|
|
// TODO("selection du type de partie dans OnMenuGameNew\n");
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
2005-03-29 07:00:39 +00:00
|
|
|
|
if (m_game != NULL)
|
|
|
|
|
{
|
|
|
|
|
GameFactory::Instance()->releaseGame(*m_game);
|
|
|
|
|
m_game = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_game = GameFactory::Instance()->createTraining(m_dic);
|
2005-02-05 11:14:56 +00:00
|
|
|
|
m_game->start();
|
|
|
|
|
rack->SetValue(wxU(""));
|
2005-12-26 22:59:57 +00:00
|
|
|
|
InitFrames();
|
|
|
|
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
|
|
|
|
reslist->SetGame(m_game);
|
|
|
|
|
#endif
|
2005-02-05 11:14:56 +00:00
|
|
|
|
UpdateStatusBar();
|
2005-12-26 22:59:57 +00:00
|
|
|
|
UpdateFrames(AuxFrame::FORCE_REFRESH);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// *******************
|
|
|
|
|
// OPEN
|
|
|
|
|
// *******************
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGameOpen(wxCommandEvent&)
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxString txt;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxFileDialog dialog(this, _("Ouvrir une partie"), wxT(""), wxT(""), wxT("*"), wxOPEN);
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (m_dic == NULL)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxMessageBox(_("Il n'y a pas de dictionnaire selectionne"), _("Eliot: erreur"),
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxICON_INFORMATION | wxOK);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-12-26 22:59:57 +00:00
|
|
|
|
if (dialog.ShowModal() != wxID_OK)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_game != NULL)
|
|
|
|
|
{
|
|
|
|
|
GameFactory::Instance()->releaseGame(*m_game);
|
|
|
|
|
m_game = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FILE* fin;
|
|
|
|
|
|
2006-01-01 19:33:51 +00:00
|
|
|
|
if ((fin = fopen(dialog.GetPath().mb_str(), "rb")) == NULL)
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2006-08-11 22:17:54 +00:00
|
|
|
|
txt << _("Impossible d'ouvrir") << dialog.GetPath();
|
|
|
|
|
wxMessageDialog msg(this, txt, _("Ouverture d'une partie"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
msg.ShowModal();
|
|
|
|
|
return ;
|
2004-08-07 18:10:42 +00:00
|
|
|
|
}
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
|
|
|
|
m_game = Game::load(fin, m_dic);
|
|
|
|
|
fclose(fin);
|
|
|
|
|
|
|
|
|
|
if (m_game == NULL)
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2005-11-05 17:33:06 +00:00
|
|
|
|
wxMessageDialog msg(this,
|
2006-08-11 22:17:54 +00:00
|
|
|
|
_("Erreur pendant la lecture de la partie"),
|
|
|
|
|
_("chargement de partie"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
msg.ShowModal();
|
|
|
|
|
return;
|
2004-08-07 18:10:42 +00:00
|
|
|
|
}
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
|
|
|
|
if (m_game->getHistory().getSize() == 0)
|
|
|
|
|
{
|
|
|
|
|
wxMessageDialog msg(this,
|
2006-08-11 22:17:54 +00:00
|
|
|
|
_("Erreur pendant la lecture de la partie"),
|
|
|
|
|
_("La partie est vide"));
|
2005-12-26 22:59:57 +00:00
|
|
|
|
msg.ShowModal();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 12:23:52 +00:00
|
|
|
|
std::wstring r;
|
2006-01-01 19:33:51 +00:00
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
if (m_game->getHistory().getSize() >= 0)
|
2006-01-22 12:23:52 +00:00
|
|
|
|
{
|
|
|
|
|
r = m_game->getCurrentPlayer().getCurrentRack().toString();
|
|
|
|
|
}
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
rack->SetValue(wxU(r.c_str()));
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// update gfxboard and all frames
|
|
|
|
|
InitFrames();
|
|
|
|
|
// update status bar
|
|
|
|
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
|
|
|
|
reslist->SetGame(m_game);
|
|
|
|
|
#endif
|
2005-02-05 11:14:56 +00:00
|
|
|
|
UpdateStatusBar();
|
2005-12-26 22:59:57 +00:00
|
|
|
|
UpdateFrames(AuxFrame::FORCE_REFRESH);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// *******************
|
|
|
|
|
// SAVE
|
|
|
|
|
// *******************
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGameSave(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxFileDialog dialog(this, _("Sauver une partie"), wxT(""), wxT(""), wxT("*"), wxSAVE|wxOVERWRITE_PROMPT);
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
ofstream fout(dialog.GetPath().mb_str());
|
|
|
|
|
if (fout.rdstate() == ios::failbit)
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxString txt;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
// XXX: txt << _("Impossible de cr<63>er ") << dialog.GetPath();
|
|
|
|
|
txt << _("Impossible de creer ") << dialog.GetPath();
|
|
|
|
|
wxMessageDialog msg(this, txt, _("Sauvegarde de la partie"));
|
2005-02-05 11:14:56 +00:00
|
|
|
|
msg.ShowModal();
|
|
|
|
|
return ;
|
2004-08-07 18:10:42 +00:00
|
|
|
|
}
|
2005-02-05 11:14:56 +00:00
|
|
|
|
m_game->save(fout);
|
|
|
|
|
fout.close();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// *******************
|
|
|
|
|
// PRINT
|
|
|
|
|
// *******************
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGamePrint(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
// TODO: gray out the menu instead...
|
|
|
|
|
if (m_game == NULL)
|
|
|
|
|
{
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxMessageBox(_("Pas de partie en cours"), _("Eliot: erreur"),
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxICON_INFORMATION | wxOK);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
wxPrintDialogData printDialogData(config.getPrintData());
|
|
|
|
|
wxPrinter printer(&printDialogData);
|
|
|
|
|
GamePrintout printout(*m_game);
|
|
|
|
|
if (!printer.Print(this, &printout, TRUE))
|
2005-11-05 17:33:06 +00:00
|
|
|
|
// XXX: wxMessageBox(wxT("Impression non effectu<74>e."));
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxMessageBox(_("Impression non effectuee."));
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGamePrintPreview(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
// TODO: gray out the menu instead...
|
|
|
|
|
if (m_game == NULL)
|
|
|
|
|
{
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxMessageBox(_("Pas de partie en cours"), _("Eliot: erreur"),
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxICON_INFORMATION | wxOK);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
wxPrintData printdata = config.getPrintData();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxString msg;
|
|
|
|
|
wxPrintPreview *preview = new wxPrintPreview(new GamePrintout(*m_game),
|
|
|
|
|
new GamePrintout(*m_game), & printdata);
|
|
|
|
|
if (!preview->Ok())
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
delete preview;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
// XXX: msg << _("Probl<62>me de pr<70>visualisation.\n")
|
|
|
|
|
msg << _("Probleme de previsualisation.\n")
|
|
|
|
|
// XXX: << _("Il se peut que l'imprimante par d<>faut soit mal initialis<69>e");
|
|
|
|
|
<< _("Il se peut que l'imprimante par defaut soit mal initialisee");
|
|
|
|
|
// XXX: wxMessageBox(msg, _("Impression (pr<70>visualisation)"), wxOK);
|
|
|
|
|
wxMessageBox(msg, _("Impression (previsualisation)"), wxOK);
|
2005-02-05 11:14:56 +00:00
|
|
|
|
return;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, _("Impression"),
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxPoint(-1, -1), wxSize(600, 550));
|
|
|
|
|
frame->Centre(wxBOTH);
|
|
|
|
|
frame->Initialize();
|
|
|
|
|
frame->Show(TRUE);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuGamePrintPS(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
#ifdef ENABLE_SAVE_POSTSCRIPT
|
2005-02-05 11:14:56 +00:00
|
|
|
|
// TODO: gray out the menu instead...
|
|
|
|
|
if (m_game == NULL)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxMessageBox(_("Pas de partie en cours"), _("Eliot: erreur"),
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxICON_INFORMATION | wxOK);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
wxString txt;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxFileDialog dialog(this, _("Imprimer dans un fichier PostScript"), wxT(""), wxT(""), wxT("*.ps"), wxSAVE|wxOVERWRITE_PROMPT);
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
|
{
|
|
|
|
|
wxPrintData printdataPS;
|
|
|
|
|
printdataPS.SetPrintMode(wxPRINT_MODE_FILE);
|
|
|
|
|
printdataPS.SetFilename(dialog.GetPath());
|
|
|
|
|
printdataPS.SetPaperId(wxPAPER_A4);
|
|
|
|
|
printdataPS.SetQuality(wxPRINT_QUALITY_HIGH);
|
|
|
|
|
printdataPS.SetOrientation(wxPORTRAIT);
|
|
|
|
|
|
|
|
|
|
wxPostScriptDC printps(printdataPS);
|
|
|
|
|
if (printps.Ok())
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxPrintDialogData printDialogData(printdataPS);
|
|
|
|
|
wxPostScriptPrinter printer(&printDialogData);
|
|
|
|
|
GamePrintout printout(*m_game);
|
|
|
|
|
if (!printer.Print(this, &printout, FALSE))
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2006-08-11 22:17:54 +00:00
|
|
|
|
// XXX: wxMessageBox(_("Impression non effectu<74>e."));
|
|
|
|
|
wxMessageBox(_("Impression non effectuee."));
|
2004-08-07 18:10:42 +00:00
|
|
|
|
}
|
2005-02-05 11:14:56 +00:00
|
|
|
|
else
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxString msg;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
// XXX: msg << _("Dessin effectu<74> dans ") << dialog.GetPath() << _("\n");
|
|
|
|
|
msg << _("Dessin effectue dans ") << dialog.GetPath() << _("\n");
|
|
|
|
|
wxMessageBox(msg, _("Sauvegarde PostScript"), wxOK);
|
2004-08-07 18:10:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-02-05 11:14:56 +00:00
|
|
|
|
else
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxString msg;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
msg << _("impossible d'initialiser le traitement PostScript.\n");
|
|
|
|
|
wxMessageBox(msg, _("Sauvegarde PostScript"), wxOK);
|
2004-08-07 18:10:42 +00:00
|
|
|
|
}
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// *******************
|
|
|
|
|
// Dictionnary Loading
|
|
|
|
|
// *******************
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfGameDic(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxString txt, msg, dicpath;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxFileDialog dialog(this, _("Choisir un dictionnaire"), wxT(""), wxT("*.dawg"), wxT("*.dawg"), wxOPEN);
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxString dicpath = dialog.GetPath();
|
|
|
|
|
Dictionary dic;
|
|
|
|
|
int res = Dic_load(&dic, dicpath.mb_str());
|
|
|
|
|
if (res == 0)
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (m_dic)
|
2005-03-29 07:00:39 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
Dic_destroy(m_dic);
|
2005-03-29 07:00:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
m_dic = dic;
|
|
|
|
|
config.setDicPath(dialog.GetPath(), ::wxFileNameFromPath(dialog.GetPath()));
|
2004-08-07 18:10:42 +00:00
|
|
|
|
}
|
2005-02-05 11:14:56 +00:00
|
|
|
|
else
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
switch (res)
|
2004-08-07 18:10:42 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
case 0: /* cas normal */ break;
|
2006-08-11 22:17:54 +00:00
|
|
|
|
// XXX: case 1: msg << _("chargement: probl<62>me d'ouverture de ") << dicpath << _("\n"); break;
|
|
|
|
|
case 1: msg << _("chargement: probleme d'ouverture de ") << dicpath << _("\n"); break;
|
|
|
|
|
// XXX: case 2: msg << _("chargement: mauvais en-t<>te de dictionnaire\n"); break;
|
|
|
|
|
case 2: msg << _("chargement: mauvais en-tete de dictionnaire\n"); break;
|
|
|
|
|
// XXX: case 3: msg << _("chargement: probl<62>me 3 d'allocation m<>moire\n"); break;
|
|
|
|
|
case 3: msg << _("chargement: probleme 3 d'allocation memoire\n"); break;
|
|
|
|
|
// XXX: case 4: msg << _("chargement: probl<62>me 4 d'allocation m<>moire\n"); break;
|
|
|
|
|
case 4: msg << _("chargement: probleme 4 d'allocation memoire\n"); break;
|
|
|
|
|
// XXX: case 5: msg << _("chargement: probl<62>me de lecture des arcs du dictionnaire\n"); break;
|
|
|
|
|
case 5: msg << _("chargement: probleme de lecture des arcs du dictionnaire\n"); break;
|
|
|
|
|
// XXX: default: msg << _("chargement: probl<62>me non-r<>pertori<72>\n"); break;
|
|
|
|
|
default: msg << _("chargement: probleme non-repertorie\n"); break;
|
2004-08-07 18:10:42 +00:00
|
|
|
|
}
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxMessageDialog dlg(NULL, msg, wxT(APPNAME));
|
|
|
|
|
dlg.ShowModal();
|
2004-08-07 18:10:42 +00:00
|
|
|
|
}
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
2005-02-05 11:14:56 +00:00
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
UpdateFrames();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// ****************
|
|
|
|
|
// MENU CONF SEARCH
|
|
|
|
|
// ****************
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfGameSearch(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
ConfSearchDlg dlg(this);
|
|
|
|
|
dlg.ShowModal();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ****************
|
|
|
|
|
// MENU CONF PRINT
|
|
|
|
|
// ****************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfPrint(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
ConfDimDlg dlg(this, config.getPrintData(), config.getPageSetupData());
|
|
|
|
|
if (dlg.ShowModal() == wxID_OK)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
config.setPrintData(dlg.getPrintData());
|
|
|
|
|
config.setPageSetupData(dlg.getPageSetupData());
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ****************
|
|
|
|
|
// MENU CONF FONTS
|
|
|
|
|
// ****************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfAspectFont(wxCommandEvent& event)
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
int id;
|
|
|
|
|
wxString attr;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
id = event.GetId();
|
|
|
|
|
if (! GetMenuBar()->FindItem(id))
|
|
|
|
|
return;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
switch (id)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-12-26 22:59:57 +00:00
|
|
|
|
case Menu_Conf_Aspect_Font_Search: attr = wxString(LISTFONT); break;
|
|
|
|
|
case Menu_Conf_Aspect_Font_Board: attr = wxString(BOARDFONT); break;
|
2005-02-05 11:14:56 +00:00
|
|
|
|
case Menu_Conf_Aspect_Font_Default: attr = wxU("Default"); break;
|
|
|
|
|
default: INCOMPLETE; break;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (attr == wxU("Default"))
|
|
|
|
|
config.setFontDefault();
|
|
|
|
|
else
|
|
|
|
|
config.setFont(attr, config.ChooseFont(this, config.getFont(attr)));
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
UpdateFrames(AuxFrame::FORCE_REFRESH);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ************************
|
|
|
|
|
// MENU CONF BOARD COLOURS
|
|
|
|
|
// ************************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuConfAspectBoardColour(wxCommandEvent& event)
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
int id;
|
|
|
|
|
wxString attr;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
id = event.GetId();
|
|
|
|
|
if (! GetMenuBar()->FindItem(id))
|
|
|
|
|
return;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
switch (id)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-12-26 15:28:57 +00:00
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Lines: attr = wxString(BCOLOURLINES); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Wx2: attr = wxString(BCOLOURWX2); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Wx3: attr = wxString(BCOLOURWX3); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Lx2: attr = wxString(BCOLOURLX2); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Lx3: attr = wxString(BCOLOURLX3); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Background: attr = wxString(BCOLOURBACKGROUND); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Letters: attr = wxString(BCOLOURLETTERS); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_TestLetters: attr = wxString(BCOLOURTSTLETTERS); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_TileBack: attr = wxString(BTILEBACKGROUND); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_TestTileBack: attr = wxString(BTSTTILEBACKGROUND); break;
|
|
|
|
|
case Menu_Conf_Aspect_BoardColour_Default: attr = wxU("Default"); break;
|
2005-02-05 11:14:56 +00:00
|
|
|
|
default: INCOMPLETE; break;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (attr == wxU("Default"))
|
|
|
|
|
config.setColourDefault();
|
|
|
|
|
else
|
|
|
|
|
config.setColour(attr, config.ChooseColour(this, config.getColour(attr)));
|
2004-04-08 09:43:06 +00:00
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
UpdateFrames(AuxFrame::FORCE_REFRESH);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//**************************************************************************************
|
|
|
|
|
// MENU QUIT
|
|
|
|
|
//**************************************************************************************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuQuitApropos(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
wxString msg;
|
2005-12-26 15:28:57 +00:00
|
|
|
|
// XXX: msg << wxT("Eliot\n<> Antoine Fraboulet 1999-2004\n\n");
|
2006-01-01 19:33:51 +00:00
|
|
|
|
msg << wxT("Eliot\nCopyright Antoine Fraboulet 1999-2006\n\n");
|
2005-02-05 11:14:56 +00:00
|
|
|
|
msg << wxT("This program is free software; you can redistribute it and/or modify\n");
|
|
|
|
|
msg << wxT("it under the terms of the GNU General Public License as published by\n");
|
|
|
|
|
msg << wxT("the Free Software Foundation; either version 2 of the License, or\n");
|
|
|
|
|
msg << wxT("(at your option) any later version.\n\n");
|
|
|
|
|
msg << wxT("Version ") << wxT(VERSION) << wxT("\n");
|
2006-08-11 22:17:54 +00:00
|
|
|
|
wxMessageBox(msg, _("A propos d'Eliot"), wxICON_INFORMATION | wxOK);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuQuitConfirm(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
Close(TRUE);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//**************************************************************************************
|
|
|
|
|
// BUTTONS
|
|
|
|
|
//**************************************************************************************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnSetRack(wxCommandEvent& event)
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
int id;
|
2006-01-01 19:33:51 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
Game::set_rack_mode mode = Game::RACK_NEW;
|
2005-12-26 22:59:57 +00:00
|
|
|
|
debug("OnSetRack ");
|
2005-02-05 11:14:56 +00:00
|
|
|
|
switch ((id = event.GetId()))
|
2005-12-26 22:59:57 +00:00
|
|
|
|
{
|
|
|
|
|
case Button_SetRack:
|
|
|
|
|
mode = Game::RACK_ALL;
|
|
|
|
|
debug("PlayedRack::RACK_ALL\n");
|
|
|
|
|
break;
|
|
|
|
|
case Button_SetNew:
|
|
|
|
|
mode = Game::RACK_NEW;
|
|
|
|
|
debug("PlayedRack::RACK_NEW\n");
|
|
|
|
|
break;
|
|
|
|
|
case Button_SetManual:
|
|
|
|
|
mode = Game::RACK_MANUAL;
|
|
|
|
|
debug("PlayedRack::RACK_MANUAL\n");
|
|
|
|
|
break;
|
2005-02-05 11:14:56 +00:00
|
|
|
|
default:
|
2005-12-26 22:59:57 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SetRack(mode);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnSearch(wxCommandEvent& WXUNUSED(event))
|
|
|
|
|
{
|
2006-01-01 19:33:51 +00:00
|
|
|
|
debug("MainFrame::OnSearch\n");
|
2006-08-11 22:17:54 +00:00
|
|
|
|
// check if rack has been set manually
|
|
|
|
|
SetRack(Game::RACK_MANUAL,rack->GetValue());
|
2005-02-05 11:14:56 +00:00
|
|
|
|
Search();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2005-12-26 22:59:57 +00:00
|
|
|
|
MainFrame::OnTextEnter(wxCommandEvent& WXUNUSED(event))
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-12-26 22:59:57 +00:00
|
|
|
|
debug("MainFrame::OnTextEnter -> %s\n",(const char*)rack->GetValue().mb_str());
|
|
|
|
|
SetRack(Game::RACK_MANUAL,rack->GetValue());
|
|
|
|
|
Search();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnPlay(wxCommandEvent& event)
|
|
|
|
|
{
|
2005-12-26 22:59:57 +00:00
|
|
|
|
int dir = 1;
|
2005-02-05 11:14:56 +00:00
|
|
|
|
int id = event.GetId();
|
|
|
|
|
switch (id)
|
2005-12-26 22:59:57 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
case Button_Play:
|
2005-12-26 22:59:57 +00:00
|
|
|
|
dir = 1;
|
2005-02-05 11:14:56 +00:00
|
|
|
|
break;
|
2005-12-26 22:59:57 +00:00
|
|
|
|
case Button_PlayBack:
|
|
|
|
|
dir = -1;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Play(dir);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//*********************************
|
|
|
|
|
// SPECIAL FRAMES
|
|
|
|
|
//*********************************
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::InitFrames()
|
|
|
|
|
{
|
2005-12-26 22:59:57 +00:00
|
|
|
|
debug("InitFrames start : \n");
|
|
|
|
|
if (m_game == NULL)
|
2005-03-29 07:00:39 +00:00
|
|
|
|
{
|
2005-12-26 22:59:57 +00:00
|
|
|
|
debug("m_game == NULL\n");
|
|
|
|
|
return;
|
2005-03-29 07:00:39 +00:00
|
|
|
|
}
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
|
|
|
|
for(int i=0 ; i < MAX_FRAME_ID; i++)
|
|
|
|
|
{
|
|
|
|
|
if (auxframes_ptr[i] != NULL)
|
|
|
|
|
{
|
|
|
|
|
debug(" delete frame %d\n",i);
|
|
|
|
|
delete auxframes_ptr[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auxframes_ptr[ ID_Frame_Verif ] = new VerifFrame (this, m_game->getDic());
|
|
|
|
|
debug("0 : Verif\n");
|
|
|
|
|
auxframes_ptr[ ID_Frame_Search ] = new SearchFrame(this, m_game->getDic());
|
|
|
|
|
debug("1 : Search\n");
|
|
|
|
|
auxframes_ptr[ ID_Frame_Plus1 ] = new Plus1Frame (this, m_game);
|
|
|
|
|
debug("2 : Plus1\n");
|
|
|
|
|
auxframes_ptr[ ID_Frame_Racc ] = new RaccFrame (this, m_game);
|
|
|
|
|
debug("3 : Racc\n");
|
|
|
|
|
auxframes_ptr[ ID_Frame_Benj ] = new BenjFrame (this, m_game);
|
|
|
|
|
debug("4 : Benj\n");
|
|
|
|
|
auxframes_ptr[ ID_Frame_Bag ] = new BagFrame (this, *m_game);
|
|
|
|
|
debug("5 : Bag\n");
|
|
|
|
|
auxframes_ptr[ ID_Frame_Board ] = new BoardFrame (this, *m_game);
|
|
|
|
|
debug("6 : Board\n");
|
|
|
|
|
auxframes_ptr[ ID_Frame_Game ] = new GameFrame (this, *m_game);
|
|
|
|
|
debug("7 : Game\n");
|
|
|
|
|
#ifndef ENABLE_RESLIST_IN_MAIN
|
|
|
|
|
auxframes_ptr[ ID_Frame_Result ] = new ResultFrame(this, m_game);
|
|
|
|
|
debug("8 : Result\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
for (int i = MIN_FRAME_ID; i < MAX_FRAME_ID; i++)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-12-26 22:59:57 +00:00
|
|
|
|
if (auxframes_ptr[i] != NULL)
|
|
|
|
|
{
|
|
|
|
|
auxframes_ptr[i]->Reload();
|
|
|
|
|
debug("reload %d\n",i);
|
|
|
|
|
}
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
2005-12-26 22:59:57 +00:00
|
|
|
|
debug("InitFrames end ok.\n");
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::OnMenuShowFrame(wxCommandEvent& event)
|
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
int id;
|
|
|
|
|
id = event.GetId();
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (!GetMenuBar()->FindItem(id))
|
|
|
|
|
return;
|
|
|
|
|
id -= IDBASE;
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if ((id < 0) || (id >= MAX_FRAME_ID))
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-12-26 22:59:57 +00:00
|
|
|
|
INCOMPLETE;
|
|
|
|
|
return;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
2005-02-05 11:14:56 +00:00
|
|
|
|
if (auxframes_ptr[id] == NULL)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-12-26 22:59:57 +00:00
|
|
|
|
debug("ShowFrame: auxframes_ptr[%d] == NULL\n", id);
|
|
|
|
|
return;
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
2005-02-05 11:14:56 +00:00
|
|
|
|
auxframes_ptr[id]->SwitchDisplay();
|
2005-12-26 22:59:57 +00:00
|
|
|
|
debug("ShowFrame: SwitchDisplay frame %d\n",id);
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-26 22:59:57 +00:00
|
|
|
|
// *********************************
|
|
|
|
|
// UPDATES
|
|
|
|
|
// *********************************
|
|
|
|
|
|
2004-04-08 09:43:06 +00:00
|
|
|
|
void
|
2005-12-26 22:59:57 +00:00
|
|
|
|
MainFrame::UpdateFrames(AuxFrame::refresh_t force)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-02-05 11:14:56 +00:00
|
|
|
|
for (int id = 0; id < MAX_FRAME_ID; id++)
|
2004-04-08 09:43:06 +00:00
|
|
|
|
{
|
2005-12-26 22:59:57 +00:00
|
|
|
|
if (auxframes_ptr[id])
|
|
|
|
|
{
|
|
|
|
|
auxframes_ptr[id]->Refresh(force);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
|
|
|
|
if (reslist)
|
|
|
|
|
{
|
|
|
|
|
reslist->Refresh();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
2005-12-26 22:59:57 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::UpdateStatusBar()
|
|
|
|
|
{
|
|
|
|
|
wxString text;
|
|
|
|
|
if (statusbar)
|
|
|
|
|
{
|
|
|
|
|
text = config.getDicName() + wxT(" ") + config.getTileName();
|
|
|
|
|
statusbar->SetStatusText(text, 0);
|
|
|
|
|
|
|
|
|
|
if (m_game)
|
|
|
|
|
{
|
|
|
|
|
text = wxT("");
|
2006-08-11 22:17:54 +00:00
|
|
|
|
text << _("coup:") << (m_game->getHistory().getSize() + 1) << wxT(" ");
|
|
|
|
|
text << _("points:") << (m_game->getCurrentPlayer().getPoints());
|
2005-12-26 22:59:57 +00:00
|
|
|
|
statusbar->SetStatusText(text, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// *********************************
|
|
|
|
|
// ACTIONS
|
|
|
|
|
// *********************************
|
|
|
|
|
|
|
|
|
|
// Can come from a
|
|
|
|
|
// BUTTON ALL -> mode = Game::RACK_ALL, srack = empty
|
|
|
|
|
// BUTTON NEW -> mode = Game::RACK_NEW, srack = empty
|
|
|
|
|
// TEXT_ENTER -> mode = Game::RACK_MANUAL, srack = letters
|
|
|
|
|
// Play -> mode = Game::RACK_MANUAL, srack = letters
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::SetRack(Game::set_rack_mode mode, wxString srack)
|
|
|
|
|
{
|
|
|
|
|
int res = 0;
|
|
|
|
|
wxString msg;
|
|
|
|
|
bool check = config.getRackChecking();
|
|
|
|
|
|
2006-01-22 12:23:52 +00:00
|
|
|
|
static_cast<Training*>(m_game)->removeTestPlay();
|
|
|
|
|
std::wstring str = srack.c_str();
|
|
|
|
|
res = static_cast<Training*>(m_game)->setRack(mode, check, str);
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
|
|
|
|
switch (res)
|
|
|
|
|
{
|
|
|
|
|
case 0x00: /* ok */
|
|
|
|
|
debug("SetRack Ok :: ");
|
|
|
|
|
break;
|
|
|
|
|
case 0x01:
|
2006-08-11 22:17:54 +00:00
|
|
|
|
msg = _("Le sac ne contient pas assez de lettres\npour assurer le tirage.");
|
|
|
|
|
wxMessageBox(msg, _("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
2005-12-26 22:59:57 +00:00
|
|
|
|
return;
|
|
|
|
|
case 0x02:
|
2006-08-11 22:17:54 +00:00
|
|
|
|
msg = _("Le tirage doit contenir au moins 2 consonnes et 2 voyelles.\n");
|
|
|
|
|
wxMessageBox(msg, _("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
2005-12-26 22:59:57 +00:00
|
|
|
|
return;
|
|
|
|
|
case 0x03:
|
2006-08-11 22:17:54 +00:00
|
|
|
|
msg = _("Le tirage doit contenir au moins 2 consonnes et 2 voyelles\n");
|
|
|
|
|
msg += _("mais le sac ne contient plus assez de lettres.\n\n");
|
|
|
|
|
wxMessageBox(msg, _("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
2005-12-26 22:59:57 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2006-08-11 22:17:54 +00:00
|
|
|
|
statusbar->SetStatusText(_("Le tirage a ete modifie manuellement"), 0);
|
2005-12-26 22:59:57 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 12:23:52 +00:00
|
|
|
|
std::wstring r = m_game->getCurrentPlayer().getCurrentRack().toString();
|
|
|
|
|
debug("MainFrame::SetRack : setvalue %ls\n",r.c_str());
|
2005-12-26 22:59:57 +00:00
|
|
|
|
rack->SetValue(wxU(r.c_str()));
|
|
|
|
|
UpdateFrames();
|
|
|
|
|
UpdateStatusBar();
|
2004-04-08 09:43:06 +00:00
|
|
|
|
}
|
2005-12-26 22:59:57 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::Search()
|
|
|
|
|
{
|
2006-10-08 12:39:13 +00:00
|
|
|
|
if (m_game == NULL || m_game->getDic() == NULL)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
static_cast<Training*>(m_game)->removeTestPlay();
|
2005-12-26 22:59:57 +00:00
|
|
|
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
|
|
|
|
reslist->Search();
|
|
|
|
|
#else
|
|
|
|
|
if (auxframes_ptr[ ID_Frame_Result ])
|
|
|
|
|
{
|
|
|
|
|
((ResultFrame*)(auxframes_ptr[ ID_Frame_Result ]))->Search();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
UpdateFrames();
|
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::Play(int n)
|
|
|
|
|
{
|
2006-10-08 12:39:13 +00:00
|
|
|
|
if (m_game == NULL)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
static_cast<Training*>(m_game)->removeTestPlay();
|
2005-12-26 22:59:57 +00:00
|
|
|
|
if (n < 0)
|
|
|
|
|
{
|
|
|
|
|
debug("MainFrame::Play back %d\n",n);
|
|
|
|
|
m_game->back(- n);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-12-27 01:06:12 +00:00
|
|
|
|
int n=0;
|
2005-12-26 22:59:57 +00:00
|
|
|
|
debug("MainFrame::Play +%d\n",n);
|
|
|
|
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
|
|
|
|
n = reslist->GetSelected();
|
|
|
|
|
#else
|
2006-08-11 22:17:54 +00:00
|
|
|
|
n = ((ResultFrame*)auxframes_ptr[ ID_Frame_Result ])->GetSelected();
|
2005-12-26 22:59:57 +00:00
|
|
|
|
#endif
|
|
|
|
|
if (n > -1)
|
|
|
|
|
{
|
|
|
|
|
((Training*)m_game)->playResult(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wxString r = wxU(m_game->getCurrentPlayer().getCurrentRack().toString().c_str());
|
|
|
|
|
rack->SetValue(r);
|
|
|
|
|
UpdateFrames();
|
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MainFrame::TestPlay(int n)
|
|
|
|
|
{
|
2006-10-08 12:39:13 +00:00
|
|
|
|
if (m_game == NULL)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
static_cast<Training*>(m_game)->removeTestPlay();
|
|
|
|
|
static_cast<Training*>(m_game)->testPlay(n);
|
2005-12-26 22:59:57 +00:00
|
|
|
|
UpdateFrames();
|
|
|
|
|
UpdateStatusBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
|
|
/// Local Variables:
|
|
|
|
|
/// mode: c++
|
|
|
|
|
/// mode: hs-minor
|
|
|
|
|
/// c-basic-offset: 4
|
2006-01-01 19:33:51 +00:00
|
|
|
|
/// indent-tabs-mode: nil
|
2005-12-26 22:59:57 +00:00
|
|
|
|
/// End:
|