level=IDM_EASY;
BombsFrame =
- new BombsFrameClass(NULL, "wxBombs", wxPoint(155, 165), wxSize(300, 300), wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION);
+ new BombsFrameClass(NULL, _T("wxBombs"), wxPoint(155, 165), wxSize(300, 300), wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION);
int xmax=BombsFrame->BombsCanvas->field_width*BombsFrame->BombsCanvas->x_cell*X_UNIT;
int ymax=BombsFrame->BombsCanvas->field_height*BombsFrame->BombsCanvas->y_cell*Y_UNIT;
// Create a menu bar for the frame
wxMenuBar *menuBar1 = new wxMenuBar;
wxMenu *menu1 = new wxMenu;
- menu1->Append(IDM_EXIT, "E&xit"); // , "Quit the program");
+ menu1->Append(IDM_EXIT, _T("E&xit")); // , "Quit the program");
menu1->AppendSeparator();
- menu1->Append(IDM_ABOUT, "&About..."); // , "Infos on wxBombs");
- menuBar1->Append(menu1, "&File");
+ menu1->Append(IDM_ABOUT, _T("&About...")); // , "Infos on wxBombs");
+ menuBar1->Append(menu1, _T("&File"));
wxMenu *menu2 = new wxMenu;
- menu2->Append(IDM_RESTART, "&Restart"); // , "Clear the play field");
+ menu2->Append(IDM_RESTART, _T("&Restart")); // , "Clear the play field");
menu2->AppendSeparator();
- menu2->Append(IDM_EASY, "&Easy", wxEmptyString, TRUE); // "10x10 play field", TRUE);
- menu2->Append(IDM_MEDIUM, "&Medium", wxEmptyString, TRUE); // "15x15 play field", TRUE);
- menu2->Append(IDM_DIFFICULT, "&Difficult", wxEmptyString, TRUE); // "25x20 play field", TRUE);
- menuBar1->Append(menu2, "&Game");
+ menu2->Append(IDM_EASY, _T("&Easy"), wxEmptyString, TRUE); // "10x10 play field", TRUE);
+ menu2->Append(IDM_MEDIUM, _T("&Medium"), wxEmptyString, TRUE); // "15x15 play field", TRUE);
+ menu2->Append(IDM_DIFFICULT, _T("&Difficult"), wxEmptyString, TRUE); // "25x20 play field", TRUE);
+ menuBar1->Append(menu2, _T("&Game"));
SetMenuBar(menuBar1);
menuBar=menuBar1;
menuBar->Check(wxGetApp().level, TRUE);
void BombsFrameClass::OnAbout(wxCommandEvent& event)
{
- wxMessageBox("wxBombs (c) 1996 by P. Foggia\n<foggia@amalfi.dis.unina.it>", "About wxBombs");
+ wxMessageBox(_T("wxBombs (c) 1996 by P. Foggia\n<foggia@amalfi.dis.unina.it>"), _T("About wxBombs"));
}
void BombsFrameClass::OnEasy(wxCommandEvent& event)
dc.SetFont(font);
long chw, chh;
- char buf[]="M";
+ wxChar buf[]=_T("M");
dc.GetTextExtent(buf, &chw, &chh);
dc.SetFont(wxNullFont);
/*---------------------------------------------------------------------*/
void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
{ int x,y,xmax,ymax;
- char buf[2];
+ wxChar buf[2];
long chw, chh;
- wxColour *wxBlack = wxTheColourDatabase->FindColour("BLACK");
- wxColour *wxWhite = wxTheColourDatabase->FindColour("WHITE");
- wxColour *wxRed = wxTheColourDatabase->FindColour("RED");
- wxColour *wxBlue = wxTheColourDatabase->FindColour("BLUE");
- wxColour *wxGrey = wxTheColourDatabase->FindColour("LIGHT GREY");
- wxColour *wxGreen = wxTheColourDatabase->FindColour("GREEN");
+ wxColour *wxBlack = wxTheColourDatabase->FindColour(_T("BLACK"));
+ wxColour *wxWhite = wxTheColourDatabase->FindColour(_T("WHITE"));
+ wxColour *wxRed = wxTheColourDatabase->FindColour(_T("RED"));
+ wxColour *wxBlue = wxTheColourDatabase->FindColour(_T("BLUE"));
+ wxColour *wxGrey = wxTheColourDatabase->FindColour(_T("LIGHT GREY"));
+ wxColour *wxGreen = wxTheColourDatabase->FindColour(_T("GREEN"));
wxPen *blackPen = wxThePenList->FindOrCreatePen(*wxBlack, 1, wxSOLID);
wxPen *redPen = wxThePenList->FindOrCreatePen(*wxRed, 1, wxSOLID);
wxFont font= BOMBS_FONT;
dc->SetFont(font);
- buf[1]='\0';
+ buf[1]=_T('\0');
for(x=xc1; x<=xc2; x++)
for(y=yc1; y<=yc2; y++)
{ if (wxGetApp().Game.IsMarked(x,y))
dc->SetBrush(* greyBrush);
dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT,
x_cell*X_UNIT+1, y_cell*Y_UNIT+1);
- *buf='M';
+ *buf=_T('M');
if (!wxGetApp().Game.IsHidden(x,y) && wxGetApp().Game.IsBomb(x,y))
dc->SetTextForeground(*wxBlue);
else
dc->SetBrush(* redBrush);
dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT,
x_cell*X_UNIT+1, y_cell*Y_UNIT+1);
- *buf='B';
+ *buf=_T('B');
dc->SetTextForeground(* wxBlack);
dc->SetTextBackground(* wxRed);
dc->GetTextExtent(buf, &chw, &chh);
dc->SetBrush(* whiteBrush);
dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT,
x_cell*X_UNIT+1, y_cell*Y_UNIT+1);
- *buf = (wxGetApp().Game.Get(x,y) & BG_MASK) + '0';
+ *buf = (wxGetApp().Game.Get(x,y) & BG_MASK) + _T('0');
dc->GetTextExtent(buf, &chw, &chh);
switch(*buf)
- { case '0': dc->SetTextForeground(* wxGreen); break;
- case '1': dc->SetTextForeground(* wxBlue); break;
+ { case _T('0'): dc->SetTextForeground(* wxGreen); break;
+ case _T('1'): dc->SetTextForeground(* wxBlue); break;
default: dc->SetTextForeground(* wxBlack); break;
}
dc->SetTextBackground(* wxWhite);
dc->SetFont(wxNullFont);
if (wxGetApp().BombsFrame)
- { char buf[80];
- sprintf(buf, "%d bombs %d remaining cells",
- wxGetApp().Game.GetBombs(), wxGetApp().Game.GetRemainingCells());
+ { wxString buf;
+ buf.Printf(_T("%d bombs %d remaining cells"),
+ wxGetApp().Game.GetBombs(),
+ wxGetApp().Game.GetRemainingCells());
wxGetApp().BombsFrame->SetStatusText(buf, 0);
}
}
if (wxGetApp().Game.IsBomb(x,y) || wxGetApp().Game.GetRemainingCells()==0)
{ wxBell();
if (!wxGetApp().Game.IsBomb(x,y))
- { wxMessageBox("Nice! You found all the bombs!", "wxWin Bombs",
+ { wxMessageBox(_T("Nice! You found all the bombs!"), _T("wxWin Bombs"),
wxOK|wxCENTRE, wxGetApp().BombsFrame);
}
else // x,y is a bomb
m_arrowCursor = new wxCursor(wxCURSOR_ARROW);
wxString name = wxTheApp->GetAppName();
- if (name.Length() <= 0) name = "forty";
+ if (name.Length() <= 0) name = _T("forty");
m_scoreFile = new ScoreFile(name);
m_game = new Game(0, 0, 0);
m_game->Deal();
bool FortyCanvas::OnCloseCanvas()
{
if (m_game->InPlay() &&
- wxMessageBox("Are you sure you want to\nabandon the current game?",
- "Warning", wxYES_NO | wxICON_QUESTION) == wxNO)
+ wxMessageBox(_T("Are you sure you want to\nabandon the current game?"),
+ _T("Warning"), wxYES_NO | wxICON_QUESTION) == wxNO)
{
return FALSE;
}
if (!m_symbolBmap)
{
#ifdef __WXMSW__
- m_symbolBmap = new wxBitmap("CardSymbols", wxBITMAP_TYPE_BMP_RESOURCE);
+ m_symbolBmap = new wxBitmap(_T("CardSymbols"), wxBITMAP_TYPE_BMP_RESOURCE);
#else
m_symbolBmap = new wxBitmap(Symbols_bits, Symbols_width, Symbols_height);
#endif
if (!m_symbolBmap->Ok())
{
- ::wxMessageBox("Failed to load bitmap CardSymbols", "Error");
+ ::wxMessageBox(_T("Failed to load bitmap CardSymbols"), _T("Error"));
}
}
if (!m_pictureBmap)
{
#ifdef __WXMSW__
- m_pictureBmap = new wxBitmap("CardPictures", wxBITMAP_TYPE_BMP_RESOURCE);
+ m_pictureBmap = new wxBitmap(_T("CardPictures"), wxBITMAP_TYPE_BMP_RESOURCE);
#else
m_pictureBmap = new wxBitmap(Pictures);
#endif
if (!m_pictureBmap->Ok())
{
- ::wxMessageBox("Failed to load bitmap CardPictures", "Error");
+ ::wxMessageBox(_T("Failed to load bitmap CardPictures"), _T("Error"));
}
}
dc.SetBackground(* wxRED_BRUSH);
dc.SetBackgroundMode(wxSOLID);
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(
- "BLACK", wxCROSSDIAG_HATCH
+ _T("BLACK"), wxCROSSDIAG_HATCH
);
dc.SetBrush(* brush);
bool largecards = FALSE;
wxSize size(668,510);
- if ((argc > 1) && (!wxStrcmp(argv[1],"-L")))
+ if ((argc > 1) && (!wxStrcmp(argv[1],_T("-L"))))
{
largecards = TRUE;
size = wxSize(1000,750);
FortyFrame* frame = new FortyFrame(
0,
- "Forty Thieves",
+ _T("Forty Thieves"),
-1, -1, size.x, size.y,largecards
);
{
if (!m_textColour)
{
- m_textColour = new wxColour("BLACK");
+ m_textColour = new wxColour(_T("BLACK"));
}
return *m_textColour;
}
// My frame constructor
-FortyFrame::FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,bool largecards):
+FortyFrame::FortyFrame(wxFrame* frame, const wxString& title, int x, int y, int w, int h,bool largecards):
wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
{
#ifdef __WXMAC__
#endif
// set the icon
#ifdef __WXMSW__
- SetIcon(wxIcon("CardsIcon"));
+ SetIcon(wxIcon(_T("CardsIcon")));
#else
#ifdef GTK_TBD
SetIcon(wxIcon(Cards_bits, Cards_width, Cards_height));
// Make a menu bar
wxMenu* gameMenu = new wxMenu;
- gameMenu->Append(NEW_GAME, "&New", "Start a new game");
- gameMenu->Append(SCORES, "&Scores...", "Displays scores");
- gameMenu->Append(EXIT, "E&xit", "Exits Forty Thieves");
+ gameMenu->Append(NEW_GAME, _T("&New"), _T("Start a new game"));
+ gameMenu->Append(SCORES, _T("&Scores..."), _T("Displays scores"));
+ gameMenu->Append(EXIT, _T("E&xit"), _T("Exits Forty Thieves"));
wxMenu* editMenu = new wxMenu;
- editMenu->Append(UNDO, "&Undo", "Undo the last move");
- editMenu->Append(REDO, "&Redo", "Redo a move that has been undone");
+ editMenu->Append(UNDO, _T("&Undo"), _T("Undo the last move"));
+ editMenu->Append(REDO, _T("&Redo"), _T("Redo a move that has been undone"));
wxMenu* optionsMenu = new wxMenu;
optionsMenu->Append(RIGHT_BUTTON_UNDO,
- "&Right button undo",
- "Enables/disables right mouse button undo and redo",
+ _T("&Right button undo"),
+ _T("Enables/disables right mouse button undo and redo"),
TRUE
);
optionsMenu->Append(HELPING_HAND,
- "&Helping hand",
- "Enables/disables hand cursor when a card can be moved",
+ _T("&Helping hand"),
+ _T("Enables/disables hand cursor when a card can be moved"),
TRUE
);
optionsMenu->Append(LARGE_CARDS,
- "&Large cards",
- "Enables/disables large cards for high resolution displays",
+ _T("&Large cards"),
+ _T("Enables/disables large cards for high resolution displays"),
TRUE
);
optionsMenu->Check(HELPING_HAND, TRUE);
optionsMenu->Check(LARGE_CARDS, largecards ? TRUE : FALSE);
wxMenu* helpMenu = new wxMenu;
- helpMenu->Append(ABOUT, "&About...", "Displays information about the game");
+ helpMenu->Append(ABOUT, _T("&About..."), _T("Displays information about the game"));
m_menuBar = new wxMenuBar;
- m_menuBar->Append(gameMenu, "&Game");
- m_menuBar->Append(editMenu, "&Edit");
- m_menuBar->Append(optionsMenu, "&Options");
- m_menuBar->Append(helpMenu, "&Help");
+ m_menuBar->Append(gameMenu, _T("&Game"));
+ m_menuBar->Append(editMenu, _T("&Edit"));
+ m_menuBar->Append(optionsMenu, _T("&Options"));
+ m_menuBar->Append(helpMenu, _T("&Help"));
SetMenuBar(m_menuBar);
#endif
{
wxMessageBox(
- "Forty Thieves\n\n"
- "A freeware program using the wxWindows\n"
- "portable C++ GUI toolkit.\n"
- "http://www.wxwindows.org\n"
- "http://www.freiburg.linux.de/~wxxt\n\n"
- "Author: Chris Breeze (c) 1992-1998\n"
- "email: chris.breeze@iname.com",
- "About Forty Thieves",
+ _T("Forty Thieves\n\n")
+ _T("A freeware program using the wxWindows\n")
+ _T("portable C++ GUI toolkit.\n")
+ _T("http://www.wxwindows.org\n")
+ _T("http://www.freiburg.linux.de/~wxxt\n\n")
+ _T("Author: Chris Breeze (c) 1992-1998\n")
+ _T("email: chris.breeze@iname.com"),
+ _T("About Forty Thieves"),
wxOK, this
);
}
wxFile file;
file.Open(htmlFile, wxFile::read);
long len = file.Length();
- char* buf = htmlText.GetWriteBuf(len + 1);
+ wxChar* buf = htmlText.GetWriteBuf(len + 1);
file.Read(buf, len);
buf[len] = 0;
htmlText.UngetWriteBuf();
verString.Printf("%.2f", stVERSION_NUMBER);
htmlText.Replace(wxT("$VERSION$"), verString);
#endif
- htmlText.Replace(wxT("$DATE$"), __DATE__);
+ htmlText.Replace(wxT("$DATE$"), _T(__DATE__));
wxSize htmlSize(400, 290);
wxASSERT( item1 );
item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 );
- wxButton *item2 = new wxButton( parent, wxID_CANCEL, "&Close", wxDefaultPosition, wxDefaultSize, 0 );
+ wxButton *item2 = new wxButton( parent, wxID_CANCEL, _T("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
item2->SetDefault();
item2->SetFocus();
class FortyFrame: public wxFrame
{
public:
- FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,bool largecards);
+ FortyFrame(wxFrame* frame, const wxString& title, int x, int y, int w, int h,bool largecards);
virtual ~FortyFrame();
void OnCloseWindow(wxCloseEvent& event);
{
if (src == dest)
{
- wxMessageBox("Game::DoMove() src == dest", "Debug message",
+ wxMessageBox(_T("Game::DoMove() src == dest"), _T("Debug message"),
wxOK | wxICON_EXCLAMATION);
}
m_moves[m_moveIndex].src = src;
}
else
{
- wxMessageBox("Game::DoMove() Undo buffer full", "Debug message",
+ wxMessageBox(_T("Game::DoMove() Undo buffer full"), _T("Debug message"),
wxOK | wxICON_EXCLAMATION);
}
// Redraw the score box to update games won
DisplayScore(dc);
- if (wxMessageBox("Do you wish to play again?",
- "Well Done, You have won!", wxYES_NO | wxICON_QUESTION) == wxYES)
+ if (wxMessageBox(_T("Do you wish to play again?"),
+ _T("Well Done, You have won!"), wxYES_NO | wxICON_QUESTION) == wxYES)
{
Deal();
canvas->Refresh();
int w, h;
{
long width, height;
- dc.GetTextExtent("Average score:m_x", &width, &height);
+ dc.GetTextExtent(_T("Average score:m_x"), &width, &height);
w = width;
h = height;
}
dc.DrawRectangle(x + w, y, 20, 4 * h);
- char str[80];
- sprintf(str, "%d", m_currentScore);
- dc.DrawText("Score:", x, y);
+ wxString str;
+ str.Printf(_T("%d"), m_currentScore);
+ dc.DrawText(_T("Score:"), x, y);
dc.DrawText(str, x + w, y);
y += h;
- sprintf(str, "%d", m_numGames);
- dc.DrawText("Games played:", x, y);
+ str.Printf(_T("%d"), m_numGames);
+ dc.DrawText(_T("Games played:"), x, y);
dc.DrawText(str, x + w, y);
y += h;
- sprintf(str, "%d", m_numWins);
- dc.DrawText("Games won:", x, y);
+ str.Printf(_T("%d"), m_numWins);
+ dc.DrawText(_T("Games won:"), x, y);
dc.DrawText(str, x + w, y);
y += h;
{
average = (2 * (m_currentScore + m_totalScore) + m_numGames ) / (2 * m_numGames);
}
- sprintf(str, "%d", average);
- dc.DrawText("Average score:", x, y);
+ str.Printf(_T("%d"), average);
+ dc.DrawText(_T("Average score:"), x, y);
dc.DrawText(str, x + w, y);
}
{
Pile::Redraw(dc);
- char str[10];
- sprintf(str, "%d ", m_topCard + 1);
+ wxString str;
+ str.Printf(_T("%d "), m_topCard + 1);
dc.SetBackgroundMode( wxSOLID );
dc.SetTextBackground(FortyApp::BackgroundColour());
}
else
{
- wxMessageBox("Pack::AddCard() Undo error", "Forty Thieves: Warning",
+ wxMessageBox(_T("Pack::AddCard() Undo error"), _T("Forty Thieves: Warning"),
wxOK | wxICON_EXCLAMATION);
}
card->TurnCard(facedown);
wxWindow* parent,
ScoreFile* file
) :
- wxDialog(parent, -1, "Player Selection",
+ wxDialog(parent, -1, _T("Player Selection"),
wxDefaultPosition, wxSize(320, 200),
wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
m_scoreFile(file)
// enable constraints
SetAutoLayout (TRUE);
- wxStaticText* msg = new wxStaticText(this, -1, "Please select a name or type a new one:");
+ wxStaticText* msg = new wxStaticText(this, -1, _T("Please select a name or type a new one:"));
wxListBox* list = new wxListBox(
this, ID_LISTBOX,
list->Append(players[i]);
}
- m_textField = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, 0);
+ m_textField = new wxTextCtrl(this, -1, _T(""), wxDefaultPosition, wxDefaultSize, 0);
- m_OK = new wxButton(this, wxID_OK, "OK");
- m_cancel = new wxButton(this, wxID_CANCEL, "Cancel");
+ m_OK = new wxButton(this, wxID_OK, _T("OK"));
+ m_cancel = new wxButton(this, wxID_CANCEL, _T("Cancel"));
wxLayoutConstraints* layout;
void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& event)
{
- m_player = "";
+ m_player = _T("");
EndModal(wxID_CANCEL);
}
wxString name = m_textField->GetValue();
if (!name.IsNull() && name.Length() > 0)
{
- if (name.Contains('@'))
+ if (name.Contains(_T('@')))
{
- wxMessageBox("Names should not contain the '@' character", "Forty Thieves");
+ wxMessageBox(_T("Names should not contain the '@' character"), _T("Forty Thieves"));
}
else
{
}
else
{
- wxMessageBox("Please enter your name", "Forty Thieves");
+ wxMessageBox(_T("Please enter your name"), _T("Forty Thieves"));
}
}
else
{
- m_player = "";
+ m_player = _T("");
EndModal(wxID_CANCEL);
}
}
#include "wx/wx.h"
#endif
-#if wxUSE_IOSTREAMH
-#if defined(__WXMSW__) && !defined(__GNUWIN32__) && !defined(__MWERKS__)
-#include <strstrea.h>
-#else
-#include <strstream.h>
-#endif
-#else
-#include <strstream>
-//using namespace std;
-#endif
#include "scorefil.h"
#include "scoredg.h"
wxArrayString players;
scoreFile->GetPlayerList( players);
- ostrstream os;
+ wxString os;
- os << "Player\tWins\tGames\tScore\n";
+ os << _T("Player\tWins\tGames\tScore\n");
for (unsigned int i = 0; i < players.Count(); i++)
{
int wins, games, score;
average = (2 * score + games) / (2 * games);
}
- os << players[i] << '\t'
- << wins << '\t'
- << games << '\t'
- << average << '\n';
+ os << players[i] << _T('\t')
+ << wins << _T('\t')
+ << games << _T('\t')
+ << average << _T('\n');
}
- os << '\0';
- char* str = os.str();
- m_text = str;
- delete str;
+ os << _T('\0');
+ m_text = os;
}
ScoreCanvas::~ScoreCanvas()
{
dc.SetFont(* m_font);
- const char* str = m_text;
+ const wxChar* str = m_text;
unsigned int tab = 0;
unsigned int tabstops[] = { 5, 100, 150, 200 };
int lineSpacing;
{
long w, h;
- dc.GetTextExtent("Testing", &w, &h);
+ dc.GetTextExtent(_T("Testing"), &w, &h);
lineSpacing = (int)h;
}
int y = 0;
while (*str)
{
- char text[256];
- char* dest = text;
+ wxChar text[256];
+ wxChar* dest = text;
- while (*str && *str >= ' ') *dest++ = *str++;
- *dest = '\0';
+ while (*str && *str >= _T(' ')) *dest++ = *str++;
+ *dest = _T('\0');
dc.DrawText(text, tabstops[tab], y);
- if (*str == '\t')
+ if (*str == _T('\t'))
{
if (tab < sizeof(tabstops) / sizeof(tabstops[0]) - 1)
{
tab++;
}
}
- else if (*str == '\n')
+ else if (*str == _T('\n'))
{
tab = 0;
y += lineSpacing;
wxWindow* parent,
ScoreFile* file
) :
- wxDialog(parent, -1, "Scores",
+ wxDialog(parent, -1, _T("Scores"),
wxDefaultPosition, wxSize(310, 200),
wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
m_scoreFile(file)
SetAutoLayout (TRUE);
ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile);
- m_OK = new wxButton(this, wxID_OK, "OK");
+ m_OK = new wxButton(this, wxID_OK, _T("OK"));
wxLayoutConstraints* layout;
#include "scorefil.h"
-ScoreFile::ScoreFile(const char* appName)
+ScoreFile::ScoreFile(const wxString& appName)
{
#if 0
wxString filename;
}
#endif
- m_config = new wxConfig(appName, "wxWindows", appName, "", wxCONFIG_USE_LOCAL_FILE); // only local
+ m_config = new wxConfig(appName, _T("wxWindows"), appName, _T(""),
+ wxCONFIG_USE_LOCAL_FILE); // only local
}
ScoreFile::~ScoreFile()
void ScoreFile::GetPlayerList( wxArrayString &list )
{
- m_config->SetPath("/Players");
+ m_config->SetPath(_T("/Players"));
int length = m_config->GetNumberOfGroups();
if (length <= 0) return;
// Calculate an encrypted check number to prevent tampering with
// score file
-long ScoreFile::CalcCheck(const char* name, int p1, int p2, int p3)
+long ScoreFile::CalcCheck(const wxString& name, int p1, int p2, int p3)
{
long check = 0;
- while (*name)
+ size_t i, max = name.length();
+
+ for(i = 0; i < max; ++i )
{
- check = (check << 1) ^ (long)*name++;
+ check = (check << 1) ^ (long)name[i];
check = ((check >> 23) ^ check) & 0xFFFFFF;
}
check = (check << 1) ^ (long)p1;
wxString ScoreFile::GetPreviousPlayer() const
{
wxString result;
- m_config->SetPath("/General");
- m_config->Read("LastPlayer", &result);
+ m_config->SetPath(_T("/General"));
+ m_config->Read(_T("LastPlayer"), &result);
return result;
}
void ScoreFile::ReadPlayersScore(
- const char* player,
+ const wxString& player,
int& wins,
int& games,
int& score)
games = wins = score = 0;
- m_config->SetPath("/Players");
+ m_config->SetPath(_T("/Players"));
m_config->SetPath(player);
- if (m_config->Read("Score", &myScore, 0L) &&
- m_config->Read("Games", &myGames, 0L) &&
- m_config->Read("Wins", &myWins, 0L) &&
- m_config->Read("Check", &check, 0L))
+ if (m_config->Read(_T("Score"), &myScore, 0L) &&
+ m_config->Read(_T("Games"), &myGames, 0L) &&
+ m_config->Read(_T("Wins"), &myWins, 0L) &&
+ m_config->Read(_T("Check"), &check, 0L))
{
if (check != CalcCheck(player, myGames, myWins, myScore))
{
- wxMessageBox("Score file corrupted", "Warning",
- wxOK | wxICON_EXCLAMATION);
+ wxMessageBox(_T("Score file corrupted"), _T("Warning"),
+ wxOK | wxICON_EXCLAMATION);
}
else
{
}
-void ScoreFile::WritePlayersScore(const char* player, int wins, int games, int score)
+void ScoreFile::WritePlayersScore(const wxString& player, int wins, int games, int score)
{
if (player)
{
- m_config->SetPath("/General");
- m_config->Write("LastPlayer", wxString(player)); // Without wxString tmp, thinks it's bool in VC++
+ m_config->SetPath(_T("/General"));
+ m_config->Write(_T("LastPlayer"), wxString(player)); // Without wxString tmp, thinks it's bool in VC++
- m_config->SetPath("/Players");
+ m_config->SetPath(_T("/Players"));
m_config->SetPath(player);
- m_config->Write("Score", (long)score);
- m_config->Write("Games", (long)games);
- m_config->Write("Wins", (long)wins);
- m_config->Write("Check", CalcCheck(player, games, wins, score));
+ m_config->Write(_T("Score"), (long)score);
+ m_config->Write(_T("Games"), (long)games);
+ m_config->Write(_T("Wins"), (long)wins);
+ m_config->Write(_T("Check"), CalcCheck(player, games, wins, score));
}
}
class ScoreFile {
public:
- ScoreFile(const char* appName);
+ ScoreFile(const wxString& appName);
virtual ~ScoreFile();
void GetPlayerList( wxArrayString &list );
wxString GetPreviousPlayer() const;
- void ReadPlayersScore(const char* player, int& wins, int& games, int &score);
- void WritePlayersScore(const char* player, int wins, int games, int score);
+ void ReadPlayersScore(const wxString& player, int& wins, int& games, int &score);
+ void WritePlayersScore(const wxString& player, int wins, int games, int score);
private:
- long CalcCheck(const char* name, int p1, int p2, int p3);
+ long CalcCheck(const wxString& name, int p1, int p2, int p3);
wxString m_configFilename;
wxConfig* m_config;
};
bool MyApp::OnInit()
{
// Create the main frame window
- MyFrame *frame = new MyFrame(NULL, "Fractal Mountains for wxWindows", wxPoint(-1, -1), wxSize(640, 480));
+ MyFrame *frame = new MyFrame(NULL, _T("Fractal Mountains for wxWindows"), wxPoint(-1, -1), wxSize(640, 480));
// Make a menubar
wxMenu *file_menu = new wxMenu;
- file_menu->Append(wxID_EXIT, "E&xit");
+ file_menu->Append(wxID_EXIT, _T("E&xit"));
menuBar = new wxMenuBar;
- menuBar->Append(file_menu, "&File");
+ menuBar->Append(file_menu, _T("&File"));
frame->SetMenuBar(menuBar);
int width, height;
m_name = name;
m_description = description;
m_rules = _("");
- m_shape.Add( wxString::Format("%i %i", -width/2, -height/2) );
+ m_shape.Add( wxString::Format(_T("%i %i"), -width/2, -height/2) );
for(int j = 0; j < height; j++)
- m_shape.Add( wxString(shape + (j * width), (size_t) width) );
+ {
+ wxString tmp;
+
+ for(int i = 0; i < width; i++)
+ {
+ tmp += wxChar(shape[j * width + i]);
+ }
+
+ m_shape.Add( tmp );
+ }
};
wxString m_name;
SetIcon(wxICON(mondrian));
// menu bar
- wxMenu *menuFile = new wxMenu("", wxMENU_TEAROFF);
- wxMenu *menuView = new wxMenu("", wxMENU_TEAROFF);
- wxMenu *menuGame = new wxMenu("", wxMENU_TEAROFF);
+ wxMenu *menuFile = new wxMenu(_T(""), wxMENU_TEAROFF);
+ wxMenu *menuView = new wxMenu(_T(""), wxMENU_TEAROFF);
+ wxMenu *menuGame = new wxMenu(_T(""), wxMENU_TEAROFF);
menuFile->Append(ID_NEW, _("&New"), _("Start a new game"));
menuFile->Append(ID_OPEN, _("&Open..."), _("Open an existing Life pattern"));
dc->SetFont(* NormalFont);
long xx;
long yy;
- dc->GetTextExtent("X", &xx, &yy);
+ dc->GetTextExtent(_T("X"), &xx, &yy);
char_height = (int)yy;
if (current_page == 0)
// Read preferences
void ReadPreferences()
{
+#if wxUSE_RESOURCES
+#if wxUSE_RESOURCES
wxGetResource("wxPoem", "FontSize", &pointSize);
wxGetResource("wxPoem", "X", &XPos);
wxGetResource("wxPoem", "Y", &YPos);
+#endif
+#endif
}
// Write preferences to disk
{
#ifdef __WXMSW__
TheMainWindow->GetPosition(&XPos, &YPos);
+#if wxUSE_RESOURCES
+#if wxUSE_RESOURCES
wxWriteResource("wxPoem", "FontSize", pointSize);
wxWriteResource("wxPoem", "X", XPos);
wxWriteResource("wxPoem", "Y", YPos);
#endif
+#endif
+#endif
}
// Load a poem from given file, at given point in file.