]> git.saurik.com Git - wxWidgets.git/blobdiff - demos/forty/playerdg.cpp
Applied patch #825402 ("Fix for Unicode Open Watcom build of life demo"); Code cleanup.
[wxWidgets.git] / demos / forty / playerdg.cpp
index fa3ea03d046635a980e8bb183a87e0f594a8fe4c..32f72be25de3b59fbf1f404cbfed882bfb26e768 100644 (file)
@@ -44,7 +44,7 @@ PlayerSelectionDialog::PlayerSelectionDialog(
                                                        wxWindow* parent,
                                                        ScoreFile* file
                                                        ) :
                                                        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)
                        wxDefaultPosition, wxSize(320, 200),
                        wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
        m_scoreFile(file)
@@ -52,7 +52,7 @@ PlayerSelectionDialog::PlayerSelectionDialog(
        // enable constraints
        SetAutoLayout (TRUE);
 
        // enable constraints
        SetAutoLayout (TRUE);
 
-       wxStaticText* msg = new wxStaticText(this, -1, "Please select a name from the list");
+       wxStaticText* msg = new wxStaticText(this, -1, _T("Please select a name or type a new one:"));
 
        wxListBox* list = new wxListBox(
                                                this, ID_LISTBOX,
 
        wxListBox* list = new wxListBox(
                                                this, ID_LISTBOX,
@@ -68,10 +68,10 @@ PlayerSelectionDialog::PlayerSelectionDialog(
                list->Append(players[i]);
        }
 
                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;
 
 
        wxLayoutConstraints* layout;
 
@@ -116,13 +116,17 @@ PlayerSelectionDialog::PlayerSelectionDialog(
        list->SetConstraints(layout);
 
        wxString prevPlayer = m_scoreFile->GetPreviousPlayer();
        list->SetConstraints(layout);
 
        wxString prevPlayer = m_scoreFile->GetPreviousPlayer();
-       if (prevPlayer.Length() > 0)
+       if ((prevPlayer.Length() > 0) && (list->FindString(prevPlayer) != -1))
        {
                list->SetStringSelection(prevPlayer);
                m_textField->SetValue(prevPlayer);
        }
 
        {
                list->SetStringSelection(prevPlayer);
                m_textField->SetValue(prevPlayer);
        }
 
+    m_textField->SetFocus();
+
        Layout();
        Layout();
+    
+    CentreOnParent();
 }
 
 PlayerSelectionDialog::~PlayerSelectionDialog()
 }
 
 PlayerSelectionDialog::~PlayerSelectionDialog()
@@ -143,9 +147,9 @@ const wxString& PlayerSelectionDialog::GetPlayersName()
        return m_player;
 }
 
        return m_player;
 }
 
-void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& event)
+void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
 {
 {
-       m_player = "";
+       m_player = _T("");
     EndModal(wxID_CANCEL);
 }
 
     EndModal(wxID_CANCEL);
 }
 
@@ -165,9 +169,9 @@ void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event)
                wxString name = m_textField->GetValue();
                if (!name.IsNull() && name.Length() > 0)
                {
                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
                        {
@@ -177,12 +181,12 @@ void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event)
                }
                else
                {
                }
                else
                {
-                       wxMessageBox("Please enter your name", "Forty Thieves");
+                       wxMessageBox(_T("Please enter your name"), _T("Forty Thieves"));
                }
        }
        else
        {
                }
        }
        else
        {
-               m_player = "";
+               m_player = _T("");
                EndModal(wxID_CANCEL);
        }
 }
                EndModal(wxID_CANCEL);
        }
 }