mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-02-06 08:48:21 +01:00
- use of History class
- mainframe modification to include debug window (Game)
This commit is contained in:
parent
4c56636aef
commit
e3309cc183
6 changed files with 428 additions and 377 deletions
|
@ -377,7 +377,6 @@ Plus1Frame::refresh()
|
||||||
std::string rack;
|
std::string rack;
|
||||||
//debug(" Plus1Frame::refresh start\n");
|
//debug(" Plus1Frame::refresh start\n");
|
||||||
rack = game->getCurrentPlayer().getCurrentRack().toString();
|
rack = game->getCurrentPlayer().getCurrentRack().toString();
|
||||||
assert(0);
|
|
||||||
//debug(" CurrentPlayer -> rack : %s\n",rack.c_str());
|
//debug(" CurrentPlayer -> rack : %s\n",rack.c_str());
|
||||||
|
|
||||||
if (savedword == rack)
|
if (savedword == rack)
|
||||||
|
@ -527,10 +526,10 @@ GameFrame::Refresh(refresh_t force)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mos << std::string(30,'-') << std::endl;
|
mos << std::string(30,'-') << std::endl;
|
||||||
mos << "Player History\n";
|
mos << "Player History\n";
|
||||||
//FIXME1 mos << m_game.getPlayer(0).getHistory().toString();
|
mos << m_game.getPlayer(0).toString();
|
||||||
mos << std::string(30,'-') << std::endl;
|
mos << std::string(30,'-') << std::endl;
|
||||||
mos << "Game History\n";
|
mos << "Game History\n";
|
||||||
//FIXME1 mos << m_game.getHistory().toString();
|
mos << m_game.getHistory().toString();
|
||||||
#endif
|
#endif
|
||||||
textbox->Clear();
|
textbox->Clear();
|
||||||
textbox->AppendText( wxU( mos.str().c_str() ) );
|
textbox->AppendText( wxU( mos.str().c_str() ) );
|
||||||
|
|
|
@ -112,20 +112,20 @@ GfxResult::Refresh()
|
||||||
if (game == NULL)
|
if (game == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//debug(" GfxResult::Refresh : ");
|
debug(" GfxResult::Refresh : ");
|
||||||
std::string rack = game->getCurrentPlayer().getCurrentRack().toString();
|
std::string rack = game->getCurrentPlayer().getCurrentRack().toString();
|
||||||
|
|
||||||
if (savedrack != rack)
|
if (savedrack != rack)
|
||||||
{
|
{
|
||||||
//debug("changed (%s -> %s)",savedrack.c_str(),rack.c_str());
|
debug("changed (%s -> %s)",savedrack.c_str(),rack.c_str());
|
||||||
savedrack = rack;
|
savedrack = rack;
|
||||||
results->DeleteAllItems();
|
results->DeleteAllItems();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//debug("unchanged");
|
debug("unchanged");
|
||||||
}
|
}
|
||||||
//debug("\n");
|
debug("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************** */
|
/* ************************************************** */
|
||||||
|
@ -134,7 +134,7 @@ GfxResult::Refresh()
|
||||||
void
|
void
|
||||||
GfxResult::Search()
|
GfxResult::Search()
|
||||||
{
|
{
|
||||||
//debug("GfxResult::Search()\n");
|
debug("GfxResult::Search()\n");
|
||||||
if (game == NULL)
|
if (game == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ GfxResult::Search()
|
||||||
results->SetFont(config.getFont(LISTFONT));
|
results->SetFont(config.getFont(LISTFONT));
|
||||||
|
|
||||||
const Results &res = ((Training*)game)->getResults();
|
const Results &res = ((Training*)game)->getResults();
|
||||||
//debug(" GfxResult::Search size = %d\n",res.size());
|
debug(" GfxResult::Search size = %d\n",res.size());
|
||||||
for (int i = 0; i < res.size(); i++)
|
for (int i = 0; i < res.size(); i++)
|
||||||
{
|
{
|
||||||
Round r = res.get(i);
|
Round r = res.get(i);
|
||||||
|
@ -165,7 +165,7 @@ GfxResult::Search()
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
results->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
results->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
||||||
|
|
||||||
// results->Show();
|
//results->Show();
|
||||||
|
|
||||||
if (res.size() > 0)
|
if (res.size() > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,13 +90,15 @@ enum
|
||||||
Menu_Conf_Aspect_BoardColour_Default = 2211,
|
Menu_Conf_Aspect_BoardColour_Default = 2211,
|
||||||
|
|
||||||
#define IDBASE 3300
|
#define IDBASE 3300
|
||||||
Menu_ShowBoard = (IDBASE + ID_Frame_Board),
|
|
||||||
Menu_ShowVerif = (IDBASE + ID_Frame_Verif),
|
Menu_ShowVerif = (IDBASE + ID_Frame_Verif),
|
||||||
Menu_ShowSearch = (IDBASE + ID_Frame_Search),
|
Menu_ShowSearch = (IDBASE + ID_Frame_Search),
|
||||||
Menu_ShowPlus1 = (IDBASE + ID_Frame_Plus1),
|
Menu_ShowPlus1 = (IDBASE + ID_Frame_Plus1),
|
||||||
Menu_ShowRacc = (IDBASE + ID_Frame_Racc),
|
Menu_ShowRacc = (IDBASE + ID_Frame_Racc),
|
||||||
Menu_ShowBenj = (IDBASE + ID_Frame_Benj),
|
Menu_ShowBenj = (IDBASE + ID_Frame_Benj),
|
||||||
Menu_ShowBag = (IDBASE + ID_Frame_Bag),
|
Menu_ShowBag = (IDBASE + ID_Frame_Bag),
|
||||||
|
Menu_ShowBoard = (IDBASE + ID_Frame_Board),
|
||||||
|
Menu_ShowGame = (IDBASE + ID_Frame_Game),
|
||||||
|
Menu_ShowResult = (IDBASE + ID_Frame_Result),
|
||||||
|
|
||||||
Menu_Quit_Apropos = 4000,
|
Menu_Quit_Apropos = 4000,
|
||||||
Menu_Quit_Confirm,
|
Menu_Quit_Confirm,
|
||||||
|
@ -129,7 +131,7 @@ BEGIN_EVENT_TABLE(MainFrame, wxFrame)
|
||||||
//
|
//
|
||||||
EVT_MENU_RANGE(Menu_Conf_Aspect_Font_Search, Menu_Conf_Aspect_Font_Default, MainFrame::OnMenuConfAspectFont)
|
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)
|
EVT_MENU_RANGE(Menu_Conf_Aspect_BoardColour_Lines, Menu_Conf_Aspect_BoardColour_Default, MainFrame::OnMenuConfAspectBoardColour)
|
||||||
EVT_MENU_RANGE(Menu_ShowVerif, Menu_ShowBoard, MainFrame::OnMenuShowFrame)
|
EVT_MENU_RANGE(Menu_ShowVerif, Menu_ShowResult, MainFrame::OnMenuShowFrame)
|
||||||
//
|
//
|
||||||
EVT_MENU(Menu_Quit_Apropos, MainFrame::OnMenuQuitApropos)
|
EVT_MENU(Menu_Quit_Apropos, MainFrame::OnMenuQuitApropos)
|
||||||
EVT_MENU(Menu_Quit_Confirm, MainFrame::OnMenuQuitConfirm)
|
EVT_MENU(Menu_Quit_Confirm, MainFrame::OnMenuQuitConfirm)
|
||||||
|
@ -142,45 +144,46 @@ BEGIN_EVENT_TABLE(MainFrame, wxFrame)
|
||||||
//
|
//
|
||||||
EVT_TEXT_ENTER(Rack_ID, MainFrame::OnSearch)
|
EVT_TEXT_ENTER(Rack_ID, MainFrame::OnSearch)
|
||||||
//
|
//
|
||||||
EVT_LIST_ITEM_SELECTED (ListCtrl_ID, MainFrame::OnListCtrlSelected)
|
|
||||||
EVT_LIST_ITEM_ACTIVATED (ListCtrl_ID, MainFrame::OnListCtrlActivated)
|
|
||||||
//
|
|
||||||
EVT_CLOSE(MainFrame::OnCloseWindow)
|
EVT_CLOSE(MainFrame::OnCloseWindow)
|
||||||
//
|
//
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
/** ******************************
|
// ******************************
|
||||||
*
|
//
|
||||||
*
|
// ******************************
|
||||||
******************************* */
|
|
||||||
|
|
||||||
MainFrame::MainFrame(wxPoint pos_, wxSize size_)
|
MainFrame::MainFrame(wxPoint pos_, wxSize size_)
|
||||||
: wxFrame((wxFrame *) NULL, -1, wxT("Eliot"), wxPoint(-1, -1),
|
: wxFrame((wxFrame *) NULL, -1, wxT("Eliot"), wxPoint(-1, -1),
|
||||||
size_, wxDEFAULT_FRAME_STYLE, wxT("Eliot")),
|
size_, wxDEFAULT_FRAME_STYLE, wxT("Eliot")),
|
||||||
m_dic(NULL), m_game(NULL)
|
m_dic(NULL), m_game(NULL)
|
||||||
{
|
{
|
||||||
wxSysColourChangedEvent event;
|
reslist = NULL;
|
||||||
|
statusbar = NULL;
|
||||||
for(int i=0 ; i < MAX_FRAME_ID; i++)
|
for(int i=0 ; i < MAX_FRAME_ID; i++)
|
||||||
auxframes_ptr[i] = NULL;
|
auxframes_ptr[i] = NULL;
|
||||||
|
|
||||||
|
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);
|
||||||
rack = new wxTextCtrl(this, Rack_ID, wxU(""), wxPoint(-1, -1), wxSize(-1, -1), wxTE_PROCESS_ENTER);
|
rack = new wxTextCtrl(this, Rack_ID, wxU(""), wxPoint(-1, -1), wxSize(-1, -1), wxTE_PROCESS_ENTER);
|
||||||
|
listsizer->Add(rack , 0 , wxEXPAND | wxALL, 1);
|
||||||
rack->SetToolTip(wxT("Tirage"));
|
rack->SetToolTip(wxT("Tirage"));
|
||||||
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
||||||
results = new wxListCtrl(this, ListCtrl_ID);
|
reslist = new GfxResult(this,(MainFrame*)this,m_game);
|
||||||
#if defined(ENABLE_LC_NO_HEADER)
|
listsizer->Add(reslist, 1, wxEXPAND | wxLEFT | wxRIGHT, 1);
|
||||||
results->SetSingleStyle(wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL);
|
|
||||||
#else
|
|
||||||
results->SetSingleStyle(wxLC_REPORT | wxLC_SINGLE_SEL);
|
|
||||||
#endif
|
#endif
|
||||||
results->InsertColumn(0, wxT("Sol"));
|
|
||||||
results->InsertColumn(1, wxT("*"));
|
|
||||||
results->InsertColumn(2, wxT("Pos"));
|
|
||||||
results->InsertColumn(3, wxT("Pts"));
|
|
||||||
// XXX: results->SetToolTip(wxT("Résultats de la recherche"));
|
|
||||||
results->SetToolTip(wxT("Resultats de la recherche"));
|
|
||||||
|
|
||||||
InitFrames();
|
|
||||||
InitMenu();
|
InitMenu();
|
||||||
|
|
||||||
statusbar = CreateStatusBar(2, 0, Status_ID);
|
statusbar = CreateStatusBar(2, 0, Status_ID);
|
||||||
|
@ -207,10 +210,6 @@ MainFrame::MainFrame(wxPoint pos_, wxSize size_)
|
||||||
buttonsizer->Add(b_back, 1, wxEXPAND | wxTOP | wxBOTTOM , 1);
|
buttonsizer->Add(b_back, 1, wxEXPAND | wxTOP | wxBOTTOM , 1);
|
||||||
buttonsizer->Add(b_play, 1, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, 1);
|
buttonsizer->Add(b_play, 1, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, 1);
|
||||||
|
|
||||||
wxBoxSizer *listsizer = new wxBoxSizer(wxVERTICAL);
|
|
||||||
listsizer->Add(rack , 0 , wxEXPAND | wxALL, 1);
|
|
||||||
listsizer->Add(results , 1 , wxEXPAND | wxLEFT | wxRIGHT, 1);
|
|
||||||
|
|
||||||
wxBoxSizer *mainsizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *mainsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
mainsizer->Add(listsizer , 1, wxEXPAND | wxVERTICAL, 0);
|
mainsizer->Add(listsizer , 1, wxEXPAND | wxVERTICAL, 0);
|
||||||
mainsizer->Add(buttonsizer, 0, wxEXPAND , 0);
|
mainsizer->Add(buttonsizer, 0, wxEXPAND , 0);
|
||||||
|
@ -223,27 +222,12 @@ MainFrame::MainFrame(wxPoint pos_, wxSize size_)
|
||||||
SetClientSize(size_);
|
SetClientSize(size_);
|
||||||
Move(config.getFramePos(wxT(APPNAME)));
|
Move(config.getFramePos(wxT(APPNAME)));
|
||||||
|
|
||||||
wxString dicpath = config.getDicPath();
|
|
||||||
Dic_load(&m_dic, dicpath.mb_str());
|
|
||||||
if (m_dic)
|
|
||||||
{
|
|
||||||
// dictionary already selected
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxCommandEvent event;
|
|
||||||
OnMenuConfGameDic(event);
|
|
||||||
m_game = NULL;
|
|
||||||
}
|
|
||||||
m_game = GameFactory::Instance()->createTraining(m_dic);
|
|
||||||
m_game->start();
|
|
||||||
InitFrames();
|
InitFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************
|
// ******************************
|
||||||
*
|
//
|
||||||
*
|
// ******************************
|
||||||
******************************* */
|
|
||||||
|
|
||||||
MainFrame::~MainFrame()
|
MainFrame::~MainFrame()
|
||||||
{
|
{
|
||||||
|
@ -262,10 +246,9 @@ MainFrame::~MainFrame()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************
|
// ******************************
|
||||||
*
|
//
|
||||||
*
|
// ******************************
|
||||||
******************************* */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::InitMenu()
|
MainFrame::InitMenu()
|
||||||
|
@ -337,6 +320,11 @@ MainFrame::InitMenu()
|
||||||
menu_frame->Append(Menu_ShowBenj, wxT("Benjamins"), wxT("Benjamins sur un mot de la recherche"));
|
menu_frame->Append(Menu_ShowBenj, wxT("Benjamins"), wxT("Benjamins sur un mot de la recherche"));
|
||||||
menu_frame->AppendSeparator();
|
menu_frame->AppendSeparator();
|
||||||
menu_frame->Append(Menu_ShowBag, wxT("Sac"), wxT("Lettres restantes dans le sac"));
|
menu_frame->Append(Menu_ShowBag, wxT("Sac"), wxT("Lettres restantes dans le sac"));
|
||||||
|
menu_frame->AppendSeparator();
|
||||||
|
menu_frame->Append(Menu_ShowGame, wxT("Partie"), wxT("Partie"));
|
||||||
|
#ifndef ENABLE_RESLIST_IN_MAIN
|
||||||
|
menu_frame->Append(Menu_ShowResult, wxT("Resultats"), wxT("Resultats"));
|
||||||
|
#endif
|
||||||
//
|
//
|
||||||
wxMenu *menu_quit = new wxMenu;
|
wxMenu *menu_quit = new wxMenu;
|
||||||
menu_quit->Append(Menu_Quit_Apropos, wxT("A propos..."), wxT("A propos d'Eliot"));
|
menu_quit->Append(Menu_Quit_Apropos, wxT("A propos..."), wxT("A propos d'Eliot"));
|
||||||
|
@ -352,10 +340,9 @@ MainFrame::InitMenu()
|
||||||
SetMenuBar(menu_bar);
|
SetMenuBar(menu_bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************
|
// *******************
|
||||||
*
|
//
|
||||||
*
|
// *******************
|
||||||
******************************* */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnCloseWindow(wxCloseEvent&)
|
MainFrame::OnCloseWindow(wxCloseEvent&)
|
||||||
|
@ -363,32 +350,9 @@ MainFrame::OnCloseWindow(wxCloseEvent&)
|
||||||
this->Destroy();
|
this->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *******************
|
||||||
void
|
// NEW
|
||||||
MainFrame::UpdateStatusBar()
|
// *******************
|
||||||
{
|
|
||||||
wxString text;
|
|
||||||
|
|
||||||
text << config.getDicName();
|
|
||||||
text << wxT(" ");
|
|
||||||
text << config.getTileName();
|
|
||||||
if (statusbar)
|
|
||||||
statusbar->SetStatusText(text, 0);
|
|
||||||
|
|
||||||
text = wxT("");
|
|
||||||
if (m_game)
|
|
||||||
{
|
|
||||||
text << wxT("coup:") << (m_game->getNTurns() + 1)
|
|
||||||
<< wxT(" ")
|
|
||||||
<< wxT("points:") << m_game->getPlayer(0).getPoints();
|
|
||||||
}
|
|
||||||
if (statusbar)
|
|
||||||
statusbar->SetStatusText(text, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//*****************************************************************************
|
|
||||||
// MENU GAME
|
|
||||||
//*****************************************************************************
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnMenuGameNew(wxCommandEvent&)
|
MainFrame::OnMenuGameNew(wxCommandEvent&)
|
||||||
|
@ -402,6 +366,7 @@ MainFrame::OnMenuGameNew(wxCommandEvent&)
|
||||||
}
|
}
|
||||||
|
|
||||||
TODO("selection du type de partie dans OnMenuGameNew\n");
|
TODO("selection du type de partie dans OnMenuGameNew\n");
|
||||||
|
|
||||||
if (m_game != NULL)
|
if (m_game != NULL)
|
||||||
{
|
{
|
||||||
GameFactory::Instance()->releaseGame(*m_game);
|
GameFactory::Instance()->releaseGame(*m_game);
|
||||||
|
@ -411,15 +376,17 @@ MainFrame::OnMenuGameNew(wxCommandEvent&)
|
||||||
m_game = GameFactory::Instance()->createTraining(m_dic);
|
m_game = GameFactory::Instance()->createTraining(m_dic);
|
||||||
m_game->start();
|
m_game->start();
|
||||||
rack->SetValue(wxU(""));
|
rack->SetValue(wxU(""));
|
||||||
results->DeleteAllItems();
|
InitFrames();
|
||||||
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
||||||
|
reslist->SetGame(m_game);
|
||||||
|
#endif
|
||||||
UpdateStatusBar();
|
UpdateStatusBar();
|
||||||
UpdateFrames();
|
UpdateFrames(AuxFrame::FORCE_REFRESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************
|
// *******************
|
||||||
*
|
// OPEN
|
||||||
*
|
// *******************
|
||||||
******************************* */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnMenuGameOpen(wxCommandEvent&)
|
MainFrame::OnMenuGameOpen(wxCommandEvent&)
|
||||||
|
@ -433,38 +400,74 @@ MainFrame::OnMenuGameOpen(wxCommandEvent&)
|
||||||
wxICON_INFORMATION | wxOK);
|
wxICON_INFORMATION | wxOK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dialog.ShowModal() == wxID_OK)
|
if (dialog.ShowModal() != wxID_OK)
|
||||||
{
|
{
|
||||||
FILE* fin;
|
return;
|
||||||
if ((fin = fopen(dialog.GetPath().mb_str(), "r")) == NULL)
|
}
|
||||||
|
|
||||||
|
if (m_game != NULL)
|
||||||
|
{
|
||||||
|
GameFactory::Instance()->releaseGame(*m_game);
|
||||||
|
m_game = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* fin;
|
||||||
|
|
||||||
|
if ((fin = fopen(dialog.GetPath().mb_str(), "r")) == NULL)
|
||||||
{
|
{
|
||||||
txt << wxT("Impossible d'ouvrir") << dialog.GetPath();
|
txt << wxT("Impossible d'ouvrir") << dialog.GetPath();
|
||||||
wxMessageDialog msg(this, txt, wxT("Ouverture d'une partie"));
|
wxMessageDialog msg(this, txt, wxT("Ouverture d'une partie"));
|
||||||
msg.ShowModal();
|
msg.ShowModal();
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
m_game = Game::load(fin, m_dic);
|
|
||||||
fclose(fin);
|
m_game = Game::load(fin, m_dic);
|
||||||
if (m_game == NULL)
|
fclose(fin);
|
||||||
|
|
||||||
|
if (m_game == NULL)
|
||||||
{
|
{
|
||||||
wxMessageDialog msg(this,
|
wxMessageDialog msg(this,
|
||||||
wxT("Erreur pendant la lecture de la partie"),
|
wxT("Erreur pendant la lecture de la partie"),
|
||||||
wxT("chargement de partie"));
|
wxT("chargement de partie"));
|
||||||
msg.ShowModal();
|
msg.ShowModal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
string r = m_game->getPlayedRack(m_game->getNTurns());
|
#if 0
|
||||||
|
// FIXME
|
||||||
|
if (m_game->getHistory().getSize() == 0)
|
||||||
|
{
|
||||||
|
wxMessageDialog msg(this,
|
||||||
|
wxT("Erreur pendant la lecture de la partie"),
|
||||||
|
wxT("La partie est vide"));
|
||||||
|
msg.ShowModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::string r = "";
|
||||||
|
#if 0
|
||||||
|
// FIXME
|
||||||
|
if (m_game->getHistory().getSize() >= 0)
|
||||||
|
{
|
||||||
|
r = m_game->getCurrentPlayer().getCurrentRack().toString();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
rack->SetValue(wxU(r.c_str()));
|
rack->SetValue(wxU(r.c_str()));
|
||||||
results->DeleteAllItems();
|
// update gfxboard and all frames
|
||||||
|
InitFrames();
|
||||||
|
// update status bar
|
||||||
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
||||||
|
reslist->SetGame(m_game);
|
||||||
|
#endif
|
||||||
UpdateStatusBar();
|
UpdateStatusBar();
|
||||||
UpdateFrames();
|
UpdateFrames(AuxFrame::FORCE_REFRESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************
|
// *******************
|
||||||
*
|
// SAVE
|
||||||
*
|
// *******************
|
||||||
******************************* */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnMenuGameSave(wxCommandEvent& WXUNUSED(event))
|
MainFrame::OnMenuGameSave(wxCommandEvent& WXUNUSED(event))
|
||||||
|
@ -487,10 +490,9 @@ MainFrame::OnMenuGameSave(wxCommandEvent& WXUNUSED(event))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************
|
// *******************
|
||||||
*
|
// PRINT
|
||||||
*
|
// *******************
|
||||||
******************************* */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnMenuGamePrint(wxCommandEvent& WXUNUSED(event))
|
MainFrame::OnMenuGamePrint(wxCommandEvent& WXUNUSED(event))
|
||||||
|
@ -510,11 +512,6 @@ MainFrame::OnMenuGamePrint(wxCommandEvent& WXUNUSED(event))
|
||||||
wxMessageBox(wxT("Impression non effectuee."));
|
wxMessageBox(wxT("Impression non effectuee."));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************
|
|
||||||
*
|
|
||||||
*
|
|
||||||
******************************* */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnMenuGamePrintPreview(wxCommandEvent& WXUNUSED(event))
|
MainFrame::OnMenuGamePrintPreview(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
@ -548,11 +545,6 @@ MainFrame::OnMenuGamePrintPreview(wxCommandEvent& WXUNUSED(event))
|
||||||
frame->Show(TRUE);
|
frame->Show(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************
|
|
||||||
*
|
|
||||||
*
|
|
||||||
******************************* */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnMenuGamePrintPS(wxCommandEvent& WXUNUSED(event))
|
MainFrame::OnMenuGamePrintPS(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
@ -604,14 +596,10 @@ MainFrame::OnMenuGamePrintPS(wxCommandEvent& WXUNUSED(event))
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// MENU CONFIG
|
|
||||||
//
|
|
||||||
|
|
||||||
/** ******************************
|
// *******************
|
||||||
*
|
// Dictionnary Loading
|
||||||
*
|
// *******************
|
||||||
******************************* */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnMenuConfGameDic(wxCommandEvent& WXUNUSED(event))
|
MainFrame::OnMenuConfGameDic(wxCommandEvent& WXUNUSED(event))
|
||||||
|
@ -659,10 +647,9 @@ MainFrame::OnMenuConfGameDic(wxCommandEvent& WXUNUSED(event))
|
||||||
UpdateFrames();
|
UpdateFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************
|
// ****************
|
||||||
*
|
// MENU CONF SEARCH
|
||||||
*
|
// ****************
|
||||||
******************************* */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnMenuConfGameSearch(wxCommandEvent& WXUNUSED(event))
|
MainFrame::OnMenuConfGameSearch(wxCommandEvent& WXUNUSED(event))
|
||||||
|
@ -702,8 +689,8 @@ MainFrame::OnMenuConfAspectFont(wxCommandEvent& event)
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case Menu_Conf_Aspect_Font_Search: attr = wxString(LISTFONT); break;
|
case Menu_Conf_Aspect_Font_Search: attr = wxString(LISTFONT); break;
|
||||||
case Menu_Conf_Aspect_Font_Board: attr = wxString(BOARDFONT); break;
|
case Menu_Conf_Aspect_Font_Board: attr = wxString(BOARDFONT); break;
|
||||||
case Menu_Conf_Aspect_Font_Default: attr = wxU("Default"); break;
|
case Menu_Conf_Aspect_Font_Default: attr = wxU("Default"); break;
|
||||||
default: INCOMPLETE; break;
|
default: INCOMPLETE; break;
|
||||||
}
|
}
|
||||||
|
@ -713,7 +700,7 @@ MainFrame::OnMenuConfAspectFont(wxCommandEvent& event)
|
||||||
else
|
else
|
||||||
config.setFont(attr, config.ChooseFont(this, config.getFont(attr)));
|
config.setFont(attr, config.ChooseFont(this, config.getFont(attr)));
|
||||||
|
|
||||||
UpdateFrames(FORCE_REFRESH);
|
UpdateFrames(AuxFrame::FORCE_REFRESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************
|
// ************************
|
||||||
|
@ -751,7 +738,7 @@ MainFrame::OnMenuConfAspectBoardColour(wxCommandEvent& event)
|
||||||
else
|
else
|
||||||
config.setColour(attr, config.ChooseColour(this, config.getColour(attr)));
|
config.setColour(attr, config.ChooseColour(this, config.getColour(attr)));
|
||||||
|
|
||||||
UpdateFrames(FORCE_REFRESH);
|
UpdateFrames(AuxFrame::FORCE_REFRESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************
|
//**************************************************************************************
|
||||||
|
@ -786,202 +773,61 @@ MainFrame::OnMenuQuitConfirm(wxCommandEvent& WXUNUSED(event))
|
||||||
void
|
void
|
||||||
MainFrame::OnSetRack(wxCommandEvent& event)
|
MainFrame::OnSetRack(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
if (m_dic == NULL)
|
|
||||||
{
|
|
||||||
// XXX: wxMessageBox(wxT("Il n'y a pas de dictionnaire sélectionné"), wxT("Eliot: erreur"),
|
|
||||||
wxMessageBox(wxT("Il n'y a pas de dictionnaire selectionne"), wxT("Eliot: erreur"),
|
|
||||||
wxICON_INFORMATION | wxOK);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
// TODO Game::set_rack_mode -> PlayedRack::set_rack_mode
|
||||||
Game::set_rack_mode mode = Game::RACK_NEW;
|
Game::set_rack_mode mode = Game::RACK_NEW;
|
||||||
bool check = config.getRackChecking();
|
debug("OnSetRack ");
|
||||||
wxString msg;
|
|
||||||
|
|
||||||
switch ((id = event.GetId()))
|
switch ((id = event.GetId()))
|
||||||
{
|
{
|
||||||
case Button_SetRack: mode = Game::RACK_ALL; break;
|
case Button_SetRack:
|
||||||
case Button_SetNew: mode = Game::RACK_NEW; break;
|
mode = Game::RACK_ALL;
|
||||||
case Button_SetManual: break;
|
debug("PlayedRack::RACK_ALL\n");
|
||||||
default: return;
|
break;
|
||||||
}
|
case Button_SetNew:
|
||||||
|
mode = Game::RACK_NEW;
|
||||||
int res = m_game->setRackRandom(0, check, mode);
|
debug("PlayedRack::RACK_NEW\n");
|
||||||
|
break;
|
||||||
switch (res)
|
case Button_SetManual:
|
||||||
{
|
mode = Game::RACK_MANUAL;
|
||||||
case 0x00: /* ok */
|
debug("PlayedRack::RACK_MANUAL\n");
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
|
||||||
msg << wxT("Le sac ne contient plus assez de lettres.") << wxT("\n");
|
|
||||||
wxMessageBox(msg, wxT("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
|
||||||
break;
|
|
||||||
case 0x02:
|
|
||||||
{
|
|
||||||
msg << wxT("Le tirage doit contenir au moins 2 consonnes et 2 voyelles") << wxT("\n");
|
|
||||||
wxMessageDialog dlg(this, msg, wxT("Correction du tirage"));
|
|
||||||
dlg.ShowModal();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 0x03:
|
|
||||||
{
|
|
||||||
msg << wxT("Le tirage doit contenir au moins 2 consonnes et 2 voyelles") << wxT("\n")
|
|
||||||
<< wxT("mais le sac ne contient plus assez de lettres") << wxT("\n") << wxT("\n");
|
|
||||||
wxMessageDialog dlg(this, msg, wxT("Correction du tirage"));
|
|
||||||
dlg.ShowModal();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
INCOMPLETE;
|
return;
|
||||||
break;
|
}
|
||||||
}
|
SetRack(mode);
|
||||||
|
|
||||||
string r = m_game->getPlayerRack(0,true);
|
|
||||||
rack->SetValue(wxU(r.c_str()));
|
|
||||||
((Training*)m_game)->removeTestPlay();
|
|
||||||
results->DeleteAllItems();
|
|
||||||
UpdateFrames();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MainFrame::Search()
|
|
||||||
{
|
|
||||||
((Training*)m_game)->search();
|
|
||||||
|
|
||||||
// to speed up inserting we hide the control temporarily
|
|
||||||
// but this is not good on slow machines as it shows an empty
|
|
||||||
// square instead of the list
|
|
||||||
//results->Hide();
|
|
||||||
results->DeleteAllItems();
|
|
||||||
results->SetFont(config.getFont(LISTFONT));
|
|
||||||
|
|
||||||
for (int i = 0; i < ((Training*)m_game)->getNResults(); i++)
|
|
||||||
{
|
|
||||||
wxString word = wxU(((Training*)m_game)->getSearchedWord(i).c_str());
|
|
||||||
wxString coords = wxU(((Training*)m_game)->getSearchedCoords(i).c_str());
|
|
||||||
wxChar bonus = ((Training*)m_game)->getSearchedBonus(i) ? '*' : ' ';
|
|
||||||
wxString pts;
|
|
||||||
pts << ((Training*)m_game)->getSearchedPoints(i);
|
|
||||||
|
|
||||||
long tmp = results->InsertItem(i, word);
|
|
||||||
results->SetItemData(tmp, i);
|
|
||||||
tmp = results->SetItem(i, 1, bonus);
|
|
||||||
tmp = results->SetItem(i, 2, coords);
|
|
||||||
tmp = results->SetItem(i, 3, pts);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
results->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
|
||||||
|
|
||||||
results->Show();
|
|
||||||
|
|
||||||
if (((Training*)m_game)->getNResults() > 0)
|
|
||||||
{
|
|
||||||
results->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED | wxLIST_MASK_STATE);
|
|
||||||
((Training*)m_game)->testPlay(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnSearch(wxCommandEvent& WXUNUSED(event))
|
MainFrame::OnSearch(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxString msg;
|
|
||||||
if (m_dic == NULL)
|
|
||||||
{
|
|
||||||
wxMessageBox(wxT("Vous devez choisir un dictionnaire"), wxT("Eliot: erreur"), wxICON_INFORMATION | wxOK);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
((Training*)m_game)->removeTestPlay();
|
|
||||||
|
|
||||||
switch (((Training*)m_game)->setRackManual(config.getRackChecking(), (const char*)rack->GetValue().mb_str()))
|
|
||||||
{
|
|
||||||
case 0x00: break;
|
|
||||||
case 0x01:
|
|
||||||
msg << wxT("Le sac ne contient pas assez de lettres") << wxT("\n")
|
|
||||||
<< wxT("pour assurer le tirage.");
|
|
||||||
wxMessageBox(msg, wxT("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
|
||||||
return;
|
|
||||||
case 0x02:
|
|
||||||
msg << wxT("Le tirage doit contenir au moins 2 consonnes et 2 voyelles") << wxT("\n");
|
|
||||||
wxMessageBox(msg, wxT("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
|
||||||
return;
|
|
||||||
// XXX: default: statusbar->SetStatusText(wxT("Le tirage a été modifié manuellement"), 0); break;
|
|
||||||
default: statusbar->SetStatusText(wxT("Le tirage a ete modifie manuellement"), 0); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
string r = m_game->getPlayerRack(0,true);
|
|
||||||
rack->SetValue(wxU(r.c_str()));
|
|
||||||
|
|
||||||
Search();
|
Search();
|
||||||
|
|
||||||
UpdateStatusBar();
|
|
||||||
UpdateFrames();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::Play(int n)
|
MainFrame::OnTextEnter(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
((Training*)m_game)->removeTestPlay();
|
debug("MainFrame::OnTextEnter -> %s\n",(const char*)rack->GetValue().mb_str());
|
||||||
|
SetRack(Game::RACK_MANUAL,rack->GetValue());
|
||||||
if (n == -1)
|
Search();
|
||||||
{
|
|
||||||
m_game->back(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
((Training*)m_game)->playResult(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_game->getNTurns() >= 0)
|
|
||||||
{
|
|
||||||
string r = m_game->getPlayerRack(0,true);
|
|
||||||
rack->SetValue(wxU(r.c_str()));
|
|
||||||
results->DeleteAllItems();
|
|
||||||
UpdateStatusBar();
|
|
||||||
UpdateFrames();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::OnPlay(wxCommandEvent& event)
|
MainFrame::OnPlay(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
if (m_dic == NULL)
|
int dir = 1;
|
||||||
{
|
|
||||||
// XXX: wxMessageBox(wxT("Il n'y a pas de dictionnaire sélectionné"), wxT("Eliot: erreur"),
|
|
||||||
wxMessageBox(wxT("Il n'y a pas de dictionnaire selectionne"), wxT("Eliot: erreur"),
|
|
||||||
wxICON_INFORMATION | wxOK);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long item = -1;
|
|
||||||
|
|
||||||
int id = event.GetId();
|
int id = event.GetId();
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case Button_Play:
|
case Button_Play:
|
||||||
item = results->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
dir = 1;
|
||||||
if (item > -1) Play(item);
|
|
||||||
break;
|
break;
|
||||||
case Button_PlayBack: Play(-1); break;
|
case Button_PlayBack:
|
||||||
default: return; break;
|
dir = -1;
|
||||||
}
|
break;
|
||||||
}
|
default:
|
||||||
|
break;
|
||||||
void
|
}
|
||||||
MainFrame::OnListCtrlSelected(wxListEvent& event)
|
Play(dir);
|
||||||
{
|
|
||||||
((Training*)m_game)->removeTestPlay();
|
|
||||||
((Training*)m_game)->testPlay(event.m_itemIndex);
|
|
||||||
UpdateFrames();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MainFrame::OnListCtrlActivated(wxListEvent& event)
|
|
||||||
{
|
|
||||||
if (event.m_itemIndex > -1)
|
|
||||||
Play(event.m_itemIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*********************************
|
//*********************************
|
||||||
|
@ -991,31 +837,52 @@ MainFrame::OnListCtrlActivated(wxListEvent& event)
|
||||||
void
|
void
|
||||||
MainFrame::InitFrames()
|
MainFrame::InitFrames()
|
||||||
{
|
{
|
||||||
if (m_game == NULL)
|
debug("InitFrames start : \n");
|
||||||
{
|
if (m_game == NULL)
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0 ; i < MAX_FRAME_ID; i++)
|
|
||||||
{
|
|
||||||
if (auxframes_ptr[i] != NULL)
|
|
||||||
{
|
{
|
||||||
delete auxframes_ptr[i];
|
debug("m_game == NULL\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
if (auxframes_ptr[i] != NULL)
|
||||||
|
{
|
||||||
|
auxframes_ptr[i]->Reload();
|
||||||
|
debug("reload %d\n",i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
debug("InitFrames end ok.\n");
|
||||||
auxframes_ptr[ ID_Frame_Verif ] = new VerifFrame (this, m_game->getDic());
|
|
||||||
auxframes_ptr[ ID_Frame_Search ] = new SearchFrame(this, m_game->getDic());
|
|
||||||
auxframes_ptr[ ID_Frame_Plus1 ] = new Plus1Frame (this, *m_game);
|
|
||||||
auxframes_ptr[ ID_Frame_Racc ] = new RaccFrame (this, *m_game, results);
|
|
||||||
auxframes_ptr[ ID_Frame_Benj ] = new BenjFrame (this, *m_game, results);
|
|
||||||
auxframes_ptr[ ID_Frame_Bag ] = new BagFrame (this, *m_game);
|
|
||||||
auxframes_ptr[ ID_Frame_Board ] = new BoardFrame (this, *m_game);
|
|
||||||
|
|
||||||
for (int i = MIN_FRAME_ID; i < MAX_FRAME_ID; i++)
|
|
||||||
{
|
|
||||||
auxframes_ptr[i]->Reload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1023,34 +890,177 @@ MainFrame::OnMenuShowFrame(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
id = event.GetId();
|
id = event.GetId();
|
||||||
|
|
||||||
if (!GetMenuBar()->FindItem(id))
|
if (!GetMenuBar()->FindItem(id))
|
||||||
return;
|
return;
|
||||||
id -= IDBASE;
|
id -= IDBASE;
|
||||||
|
|
||||||
if ((id < 0) || (id >= MAX_FRAME_ID))
|
if ((id < 0) || (id >= MAX_FRAME_ID))
|
||||||
{
|
{
|
||||||
INCOMPLETE;
|
INCOMPLETE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auxframes_ptr[id] == NULL)
|
if (auxframes_ptr[id] == NULL)
|
||||||
{
|
{
|
||||||
debug("ShowFrame: auxframes_ptr[%d] == NULL\n", id);
|
debug("ShowFrame: auxframes_ptr[%d] == NULL\n", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auxframes_ptr[id]->SwitchDisplay();
|
auxframes_ptr[id]->SwitchDisplay();
|
||||||
|
debug("ShowFrame: SwitchDisplay frame %d\n",id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *********************************
|
||||||
|
// UPDATES
|
||||||
|
// *********************************
|
||||||
|
|
||||||
void
|
void
|
||||||
MainFrame::UpdateFrames(refresh_t force)
|
MainFrame::UpdateFrames(AuxFrame::refresh_t force)
|
||||||
{
|
{
|
||||||
for (int id = 0; id < MAX_FRAME_ID; id++)
|
for (int id = 0; id < MAX_FRAME_ID; id++)
|
||||||
{
|
{
|
||||||
if (auxframes_ptr[id])
|
if (auxframes_ptr[id])
|
||||||
{
|
{
|
||||||
// debug("UpdateFrames %d\n",id);
|
auxframes_ptr[id]->Refresh(force);
|
||||||
auxframes_ptr[id]->Refresh(force);
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
||||||
|
if (reslist)
|
||||||
|
{
|
||||||
|
reslist->Refresh();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainFrame::UpdateStatusBar()
|
||||||
|
{
|
||||||
|
wxString text;
|
||||||
|
if (statusbar)
|
||||||
|
{
|
||||||
|
text = config.getDicName() + wxT(" ") + config.getTileName();
|
||||||
|
statusbar->SetStatusText(text, 0);
|
||||||
|
|
||||||
|
if (m_game)
|
||||||
|
{
|
||||||
|
text = wxT("");
|
||||||
|
text << wxT("coup:") << (m_game->getHistory().getSize()) << wxT(" ");
|
||||||
|
text << wxT("points:") << (m_game->getCurrentPlayer().getPoints());
|
||||||
|
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;
|
||||||
|
std::string str;
|
||||||
|
wxString msg;
|
||||||
|
bool check = config.getRackChecking();
|
||||||
|
|
||||||
|
str = (const char*)srack.mb_str();
|
||||||
|
res = ((Training*)m_game)->setRack(mode, check, str);
|
||||||
|
|
||||||
|
switch (res)
|
||||||
|
{
|
||||||
|
case 0x00: /* ok */
|
||||||
|
debug("SetRack Ok :: ");
|
||||||
|
break;
|
||||||
|
case 0x01:
|
||||||
|
msg = wxT("Le sac ne contient pas assez de lettres\npour assurer le tirage.");
|
||||||
|
wxMessageBox(msg, wxT("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
||||||
|
return;
|
||||||
|
case 0x02:
|
||||||
|
msg = wxT("Le tirage doit contenir au moins 2 consonnes et 2 voyelles.\n");
|
||||||
|
wxMessageBox(msg, wxT("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
||||||
|
return;
|
||||||
|
case 0x03:
|
||||||
|
msg = wxT("Le tirage doit contenir au moins 2 consonnes et 2 voyelles\n");
|
||||||
|
msg += wxT("mais le sac ne contient plus assez de lettres.\n\n");
|
||||||
|
wxMessageBox(msg, wxT("Correction du tirage"), wxICON_INFORMATION | wxOK);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
statusbar->SetStatusText(wxT("Le tirage a ete modifie manuellement"), 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string r = m_game->getCurrentPlayer().getCurrentRack().toString();
|
||||||
|
debug("MainFrame::SetRack : setvalue %s\n",r.c_str());
|
||||||
|
rack->SetValue(wxU(r.c_str()));
|
||||||
|
UpdateFrames();
|
||||||
|
UpdateStatusBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainFrame::Search()
|
||||||
|
{
|
||||||
|
((Training*)m_game)->removeTestPlay();
|
||||||
|
#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)
|
||||||
|
{
|
||||||
|
((Training*)m_game)->removeTestPlay();
|
||||||
|
if (n < 0)
|
||||||
|
{
|
||||||
|
debug("MainFrame::Play back %d\n",n);
|
||||||
|
m_game->back(- n);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
debug("MainFrame::Play +%d\n",n);
|
||||||
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
||||||
|
n = reslist->GetSelected();
|
||||||
|
#else
|
||||||
|
n = auxframes_ptr[ ID_Frame_Result ]->GetSelected();
|
||||||
|
#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)
|
||||||
|
{
|
||||||
|
((Training*)m_game)->removeTestPlay();
|
||||||
|
((Training*)m_game)->testPlay(n);
|
||||||
|
UpdateFrames();
|
||||||
|
UpdateStatusBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************/
|
||||||
|
/****************************************************************/
|
||||||
|
|
||||||
|
/// Local Variables:
|
||||||
|
/// mode: c++
|
||||||
|
/// mode: hs-minor
|
||||||
|
/// c-basic-offset: 4
|
||||||
|
/// End:
|
||||||
|
|
|
@ -34,26 +34,36 @@ private:
|
||||||
AuxFrame *auxframes_ptr[MAX_FRAME_ID];
|
AuxFrame *auxframes_ptr[MAX_FRAME_ID];
|
||||||
|
|
||||||
wxTextCtrl *rack;
|
wxTextCtrl *rack;
|
||||||
wxListCtrl *results;
|
#ifdef ENABLE_RESLIST_IN_MAIN
|
||||||
|
GfxResult *reslist;
|
||||||
|
#endif
|
||||||
|
|
||||||
wxButton *b_play;
|
wxButton *b_play;
|
||||||
wxButton *b_rackrandomset;
|
wxButton *b_rackrandomset;
|
||||||
wxButton *b_rackrandomnew;
|
wxButton *b_rackrandomnew;
|
||||||
wxButton *b_search;
|
wxButton *b_search;
|
||||||
wxButton *b_back;
|
wxButton *b_back;
|
||||||
wxStatusBar *statusbar;
|
|
||||||
|
|
||||||
void Play(int);
|
wxStatusBar *statusbar;
|
||||||
void Search();
|
|
||||||
|
|
||||||
void InitFrames();
|
void InitFrames();
|
||||||
void InitMenu();
|
void InitMenu();
|
||||||
void UpdateStatusBar();
|
void UpdateStatusBar();
|
||||||
void UpdateFrames(refresh_t force = REFRESH);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainFrame(wxPoint,wxSize);
|
MainFrame(wxPoint,wxSize);
|
||||||
virtual ~MainFrame();
|
virtual ~MainFrame();
|
||||||
|
|
||||||
|
// *******
|
||||||
|
// Actions
|
||||||
|
// *******
|
||||||
|
void SetRack(Game::set_rack_mode, wxString = wxT(""));
|
||||||
|
void Search();
|
||||||
|
void Play(int);
|
||||||
|
void TestPlay(int);
|
||||||
|
|
||||||
|
void UpdateFrames(AuxFrame::refresh_t force = AuxFrame::REFRESH);
|
||||||
|
|
||||||
// *****
|
// *****
|
||||||
// Menus
|
// Menus
|
||||||
// *****
|
// *****
|
||||||
|
@ -84,7 +94,7 @@ public:
|
||||||
void OnSetRack (wxCommandEvent& event);
|
void OnSetRack (wxCommandEvent& event);
|
||||||
void OnSearch (wxCommandEvent& event);
|
void OnSearch (wxCommandEvent& event);
|
||||||
void OnPlayBack (wxCommandEvent& event);
|
void OnPlayBack (wxCommandEvent& event);
|
||||||
|
void OnTextEnter(wxCommandEvent& event);
|
||||||
|
|
||||||
// *******
|
// *******
|
||||||
// Objects
|
// Objects
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/* Eliot */
|
/* Eliot */
|
||||||
/* Copyright (C) 1999 Antoine Fraboulet */
|
/* Copyright (C) 1999 Antoine Fraboulet */
|
||||||
/* Antoine.Fraboulet@free.fr */
|
|
||||||
/* */
|
/* */
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
/* This file is part of Eliot. */
|
||||||
|
/* */
|
||||||
|
/* Eliot is free software; you can redistribute it and/or modify */
|
||||||
/* it under the terms of the GNU General Public License as published by */
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
/* the Free Software Foundation; either version 2 of the License, or */
|
/* the Free Software Foundation; either version 2 of the License, or */
|
||||||
/* (at your option) any later version. */
|
/* (at your option) any later version. */
|
||||||
/* */
|
/* */
|
||||||
/* This program is distributed in the hope that it will be useful, */
|
/* Eliot is distributed in the hope that it will be useful, */
|
||||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
/* GNU General Public License for more details. */
|
/* GNU General Public License for more details. */
|
||||||
|
@ -23,8 +24,12 @@
|
||||||
#include "ewx.h"
|
#include "ewx.h"
|
||||||
|
|
||||||
#include "dic.h"
|
#include "dic.h"
|
||||||
#include "game.h"
|
#include "pldrack.h"
|
||||||
|
#include "round.h"
|
||||||
|
#include "turn.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
#include "turn.h"
|
||||||
|
#include "game.h"
|
||||||
|
|
||||||
#include "configdb.h"
|
#include "configdb.h"
|
||||||
#include "printout.h"
|
#include "printout.h"
|
||||||
|
@ -150,43 +155,49 @@ GamePrintout::DrawTextLine(wxDC *dc, int numline, long basey, long heightT, floa
|
||||||
+ numline * (config.getDyT1() + heightT + config.getDyT2());
|
+ numline * (config.getDyT1() + heightT + config.getDyT2());
|
||||||
w = config.getDxText(0);
|
w = config.getDxText(0);
|
||||||
str = wxT("");
|
str = wxT("");
|
||||||
|
|
||||||
|
int NRounds = m_game.getHistory().getSize();
|
||||||
|
|
||||||
// num
|
// num
|
||||||
if (numline < m_game.getNTurns())
|
if (numline < NRounds)
|
||||||
{
|
{
|
||||||
|
str = wxT("");
|
||||||
str << (numline + 1);
|
str << (numline + 1);
|
||||||
DRW(0);
|
DRW(0);
|
||||||
}
|
}
|
||||||
// rack
|
// rack
|
||||||
DIM(1);
|
DIM(1);
|
||||||
if (numline < m_game.getNTurns())
|
if (numline < NRounds)
|
||||||
{
|
{
|
||||||
str = wxU(m_game.getPlayedRack(numline).c_str());
|
str = wxU(m_game.getHistory().getTurn(numline).getPlayedRack().toString().c_str());
|
||||||
DRW(1);
|
DRW(1);
|
||||||
}
|
}
|
||||||
// word
|
// word
|
||||||
DIM(2);
|
DIM(2);
|
||||||
if ((numline > 0) && (numline <= m_game.getNTurns()))
|
if ((numline > 0) && (numline <= NRounds))
|
||||||
{
|
{
|
||||||
str = wxU(m_game.getPlayedWord(numline - 1).c_str());
|
str = wxU(m_game.getHistory().getTurn(numline - 1).getRound().getWord().c_str());
|
||||||
DRW(2);
|
DRW(2);
|
||||||
}
|
}
|
||||||
// pos
|
// pos
|
||||||
DIM(3);
|
DIM(3);
|
||||||
if ((numline > 0) && (numline <= m_game.getNTurns()))
|
if ((numline > 0) && (numline <= NRounds))
|
||||||
{
|
{
|
||||||
str = wxU(m_game.getPlayedCoords(numline - 1).c_str());
|
str = wxU(m_game.getHistory().getTurn(numline - 1).getRound().getCoord().toString().c_str());
|
||||||
DRW(3);
|
DRW(3);
|
||||||
}
|
}
|
||||||
// pts
|
// pts
|
||||||
DIM(4);
|
DIM(4);
|
||||||
if ((numline > 0) && (numline <= m_game.getNTurns()))
|
if ((numline > 0) && (numline <= NRounds))
|
||||||
{
|
{
|
||||||
str << m_game.getPlayedPoints(numline - 1);
|
str = wxT("");
|
||||||
|
str << m_game.getHistory().getTurn(numline - 1).getRound().getPoints();
|
||||||
DRW(4);
|
DRW(4);
|
||||||
}
|
}
|
||||||
// total points
|
// total points
|
||||||
if (numline == m_game.getNTurns() + 1)
|
if (numline == NRounds + 1)
|
||||||
{
|
{
|
||||||
|
str = wxT("");
|
||||||
str << m_game.getPlayer(0).getPoints();
|
str << m_game.getPlayer(0).getPoints();
|
||||||
DRW(4);
|
DRW(4);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +264,8 @@ GamePrintout::DrawPage(wxDC *dc)
|
||||||
basey = config.getMarginY() + config.getDyH1() + heightH + config.getDyH2();
|
basey = config.getMarginY() + config.getDyH1() + heightH + config.getDyH2();
|
||||||
dc->SetFont(Tfont);
|
dc->SetFont(Tfont);
|
||||||
heightT = (long) (dc->GetCharHeight() / mmToLogical);
|
heightT = (long) (dc->GetCharHeight() / mmToLogical);
|
||||||
for(i=0; i < (m_game.getNTurns()+3);i++)
|
int NRounds = m_game.getHistory().getSize();
|
||||||
|
for(i=0; i < (NRounds+3);i++)
|
||||||
{
|
{
|
||||||
DrawTextLine(dc,i,basey,heightT,mmToLogical);
|
DrawTextLine(dc,i,basey,heightT,mmToLogical);
|
||||||
}
|
}
|
||||||
|
@ -274,7 +286,8 @@ GamePrintout::DrawGameLines(wxDC *dc, long heightH, long heightT,
|
||||||
float SCALE = config.getPrintLineScale();
|
float SCALE = config.getPrintLineScale();
|
||||||
dc->SetUserScale(SCALE,SCALE);
|
dc->SetUserScale(SCALE,SCALE);
|
||||||
|
|
||||||
nTextLines = m_game.getNTurns() + 2;
|
int NRounds = m_game.getHistory().getSize();
|
||||||
|
nTextLines = NRounds + 2;
|
||||||
StartX = config.getMarginX();
|
StartX = config.getMarginX();
|
||||||
StartY = config.getMarginY();
|
StartY = config.getMarginY();
|
||||||
|
|
||||||
|
@ -313,3 +326,13 @@ GamePrintout::DrawGameLines(wxDC *dc, long heightH, long heightT,
|
||||||
lin = StartY + HeadHeight + i * LineHeight;
|
lin = StartY + HeadHeight + i * LineHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************/
|
||||||
|
/****************************************************************/
|
||||||
|
|
||||||
|
/// Local Variables:
|
||||||
|
/// mode: c++
|
||||||
|
/// mode: hs-minor
|
||||||
|
/// c-basic-offset: 4
|
||||||
|
/// End:
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/* Eliot */
|
/* Eliot */
|
||||||
/* Copyright (C) 1999 Antoine Fraboulet */
|
/* Copyright (C) 1999 Antoine Fraboulet */
|
||||||
/* Antoine.Fraboulet@free.fr */
|
|
||||||
/* */
|
/* */
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
/* This file is part of Eliot. */
|
||||||
|
/* */
|
||||||
|
/* Eliot is free software; you can redistribute it and/or modify */
|
||||||
/* it under the terms of the GNU General Public License as published by */
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
/* the Free Software Foundation; either version 2 of the License, or */
|
/* the Free Software Foundation; either version 2 of the License, or */
|
||||||
/* (at your option) any later version. */
|
/* (at your option) any later version. */
|
||||||
/* */
|
/* */
|
||||||
/* This program is distributed in the hope that it will be useful, */
|
/* Eliot is distributed in the hope that it will be useful, */
|
||||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
/* GNU General Public License for more details. */
|
/* GNU General Public License for more details. */
|
||||||
|
@ -16,7 +17,6 @@
|
||||||
/* along with this program; if not, write to the Free Software */
|
/* along with this program; if not, write to the Free Software */
|
||||||
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
// -*- C++ -*-
|
|
||||||
#ifndef _PRINTOUT_H
|
#ifndef _PRINTOUT_H
|
||||||
#define _PRINTOUT_H
|
#define _PRINTOUT_H
|
||||||
|
|
||||||
|
@ -47,3 +47,12 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************/
|
||||||
|
/****************************************************************/
|
||||||
|
|
||||||
|
/// Local Variables:
|
||||||
|
/// mode: c++
|
||||||
|
/// mode: hs-minor
|
||||||
|
/// c-basic-offset: 4
|
||||||
|
/// End:
|
||||||
|
|
Loading…
Add table
Reference in a new issue