// dialog_playercard.cpp
 
 
 
#include "../common.h"
 
 
 
 
 
// dialog template
 
#define THIS_DIALOG DIALOG_PLAYERCARD
 
 
 
 
 
// local definitions
 
#define TIMER_REFRESHDIALOG 1
 
 
 
 
 
// list view column definition
 
typedef struct listviewcolumn_s
 
{
 
   int width;
 
   int alignment;
 
   wchar_t *text;
 
} listviewcolumn_t;
 
 
 
 
 
// global variables used in this module only
 
static int listviewicons[sizeof (handlestatus) / sizeof (handlestatus_t)]; // as big as the handlestatus global array
 
static listviewcolumn_t listviewcolumns[] =
 
{
 
   { 80, LVCFMT_LEFT, NULL /*LOCALIZE (L"PlayerCard_GameStyle")*/}, // text address needs to be set at runtime, because it's mallocated
 
   { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Rating")*/},
 
   { 40, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_RD")*/},
 
   { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Wins")*/},
 
   { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Losses")*/},
 
   { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Draws")*/},
 
   { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Totals")*/},
 
};
 
static wchar_t personalmessage_text[1024];
 
static wchar_t invitee_nickname[32];
 
 
 
 
 
// prototypes of local functions
 
static void StartThread_PlayerCard (void *thread_parms);
 
static int CALLBACK DialogProc_PlayerCard (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam);
 
 
 
 
 
void DialogBox_PlayerCard (int playercard_index)
 
{
 
   // helper function to fire up the modeless dialog box
 
 
 
   is_dialogbox_displayed = true;
 
   _beginthread (StartThread_PlayerCard, 0, (void *) playercard_index); // fire up the thread
 
   return; // return as soon as the thread is fired up
 
}
 
 
 
 
 
void DialogBox_PlayerCard_Validated (void)
 
{
 
   // callback function called by the main game thread when the dialog box is validated
 
 
 
   challenge_t *challenge;
 
 
 
   // remember this callback is no longer to be called
 
   is_dialogbox_playercard_validated = false;
 
 
 
   // TODO: verify if not ourselves
 
 
 
   // player is available for an invitation. Is he already inviting us ?
 
   challenge = Challenge_Find (invitee_nickname);
 
   if ((challenge != NULL) && challenge->is_active && IsWindow (challenge->hWnd))
 
      EndDialog (challenge->hWnd, 0); // if so, close the challenge dialog box (this will also make us decline it properly)
 
 
 
   Interlocutor_FindOrCreate (invitee_nickname); // fire up the chat window with this player
 
   return; // finished, a new chat window has been opened with this player
 
}
 
 
 
 
 
static void StartThread_PlayerCard (void *thread_parms)
 
{
 
   // this function runs in a separate thread, for that's the only way (seemingly)
 
   // to implement a non-modal message box using the Common Controls library.
 
 
 
   int playercard_index;
 
   playercard_t *playercard;
 
 
 
   playercard_index = (int) thread_parms;
 
   if (playercard_index >= playercard_count)
 
      return; // consistency check; _endthread() implied
 
   playercard = &playercards[playercard_index]; // quick access to player card structure
 
 
 
   // display the dialog box and attach this playercard to it
 
   if (DialogBoxParam (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), NULL, DialogProc_PlayerCard, (LPARAM) playercard_index) == 1)
 
      is_dialogbox_playercard_validated = true;
 
   is_dialogbox_displayed = false;
 
 
 
   // now that we're sure the window disappeared...
 
   playercard = &playercards[playercard_index]; // quick access to player card structure (it may have relocated)
 
   playercard->is_active = false; // remember interlocutor has gone away
 
   SAFE_free ((void **) &playercard->fingertext); // free its text
 
   playercard->fingertext_length = 0; // and reset its text length
 
   SAFE_free ((void **) &playercard->gamestyleratings); // free its game style ratings
 
   playercard->gamestylerating_count = 0; // and reset its count
 
 
 
   the_board.reevaluate = true; // refresh the GUI buttons if needed
 
   return; // _endthread() implied
 
}
 
 
 
 
 
static int CALLBACK DialogProc_PlayerCard (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam)
 
{
 
   // message handler for the dialog box
 
 
 
   unsigned short wParam_hiword;
 
   unsigned short wParam_loword;
 
   gamestylerating_t *gamestylerating;
 
   onlineplayer_t *onlineplayer;
 
   playercard_t *playercard;
 
   wchar_t text_to_send[256];
 
   wchar_t *current_line;
 
   wchar_t *wcstok_context;
 
   player_t *network_player;
 
   HIMAGELIST imagelist;
 
   HWND hListWnd;
 
   LVCOLUMN lvc;
 
   LVITEM lvi;
 
   int insert_index;
 
   int column_index;
 
   int player_index;
 
   int gsr_index;
 
 
 
   // filter out the commonly used message values
 
   wParam_hiword = HIWORD (wParam);
 
   wParam_loword = LOWORD (wParam);
 
 
 
   // have we just fired up this window ?
 
   if (message == WM_INITDIALOG)
 
   {
 
      playercard = &playercards[lParam]; // quick access to player card
 
      SetWindowLongPtr (hWnd, DWLP_USER, lParam); // attach player card
 
      playercard->hWnd = hWnd; // and save window handle
 
 
 
      // center the window
 
      CenterWindow (hWnd, hMainWnd);
 
 
 
      // set dialog icons (small one for title bar & big one for task manager)
 
      SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_CARD)));
 
      SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_CARD)));
 
 
 
      // find the remote player
 
      network_player = Player_FindByType (PLAYER_INTERNET);
 
 
 
      // make network player ask an update from the server
 
      if (network_player != NULL)
 
      {
 
         if (lastonlineplayers_time + 5.0f < current_time)
 
            Player_SendBuffer_Add (network_player, 1000, L"who\n"); // finger requests need an updated player list
 
         Player_SendBuffer_Add (network_player, 1000, L"finger %s\n", playercard->nickname); // send the finger request
 
      }
 
 
 
      // set the finger data text area font
 
      SendMessage (GetDlgItem (hWnd, EDITBOX_PLAYERCARD_FINGERDATA), WM_SETFONT, (WPARAM) hFontChat, false);
 
 
 
      // set the dialog text editable if it's ours, and read-only if it's not
 
      Edit_SetReadOnly (GetDlgItem (hWnd, EDITBOX_PLAYERCARD_FINGERDATA), !playercard->is_own);
 
 
 
      // prepare the list view : do it before anything that could trigger a fill
 
 
 
      // get a quick access to the list control
 
      hListWnd = GetDlgItem (hWnd, COMBOBOX_GAMESTYLES);
 
 
 
      // tell Windows which members of the LVCOLUMN structure we're filling
 
      memset (&lvc, 0, sizeof (lvc));
 
      lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; 
 
      for (column_index = 0; column_index < sizeof (listviewcolumns) / sizeof (listviewcolumn_t); column_index++)
 
      {
 
         lvc.iSubItem = column_index;
 
         if (column_index == 0) lvc.pszText = LOCALIZE (L"PlayerCard_GameStyle");
 
         else if (column_index == 1) lvc.pszText = LOCALIZE (L"PlayerCard_Rating");
 
         else if (column_index == 2) lvc.pszText = LOCALIZE (L"PlayerCard_RD");
 
         else if (column_index == 3) lvc.pszText = LOCALIZE (L"PlayerCard_Wins");
 
         else if (column_index == 4) lvc.pszText = LOCALIZE (L"PlayerCard_Losses");
 
         else if (column_index == 5) lvc.pszText = LOCALIZE (L"PlayerCard_Draws");
 
         else if (column_index == 6) lvc.pszText = LOCALIZE (L"PlayerCard_Totals");
 
         lvc.cx = listviewcolumns[column_index].width;
 
         lvc.fmt = listviewcolumns[column_index].alignment;
 
         ListView_InsertColumn (hListWnd, column_index, &lvc); // add each column to list view
 
      }
 
 
 
      // create the listview image list
 
      imagelist = ImageList_Create (16, 16, ILC_COLOR32, sizeof (handlestatus) / sizeof (handlestatus_t), 1); // create an imagelist holding N 32-bit images
 
      for (insert_index = 1; insert_index < sizeof (handlestatus) / sizeof (handlestatus_t); insert_index++)
 
         listviewicons[insert_index] = ImageList_AddIcon (imagelist, handlestatus[insert_index].icon); // add our icons in the image list
 
      ListView_SetImageList (hListWnd, imagelist, LVSIL_SMALL); // associate it with the listview
 
 
 
      // set window title and control texts
 
      swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_TitleBuildingCard"), playercard->nickname);
 
      SetWindowText (hWnd, text_to_send);
 
      if (playercard->is_own)
 
         wcscpy_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_YourStats"));
 
      else
 
         swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_Stats"), playercard->nickname);
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_STATSTEXT, text_to_send);
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORKEY, LOCALIZE (L"PlayerCard_OnlineForKey"));
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORVALUE, L"");
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSKEY, LOCALIZE (L"PlayerCard_CurrentStatusKey"));
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSVALUE, L"");
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDKEY, LOCALIZE (L"PlayerCard_GamePlayedKey"));
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE, L"");
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYKEY, LOCALIZE (L"PlayerCard_LastActivityKey"));
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYVALUE, L"");
 
      SetDlgItemText (hWnd, BUTTON_CLOSE, LOCALIZE (L"Button_Close"));
 
      SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_STATUSBAR, LOCALIZE (L"PlayerCard_StatusBar"));
 
 
 
      // refresh the server message area every second
 
      SetTimer (hWnd, TIMER_REFRESHDIALOG, 1000, NULL);
 
      SendMessage (hWnd, WM_TIMER, TIMER_REFRESHDIALOG, 0); // but call it now
 
 
 
      // convert the game played and status bar message to a hyperlink
 
      ConvertStaticToHyperlink (GetDlgItem (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE));
 
      ConvertStaticToHyperlink (GetDlgItem (hWnd, STATICTEXT_PLAYERCARD_STATUSBAR));
 
   }
 
 
 
   // else did we click the close button on the title bar ?
 
   else if (message == WM_CLOSE)
 
   {
 
      playercard = &playercards[GetWindowLongPtr (hWnd, DWLP_USER)]; // quick access to player card
 
 
 
      // was it our own card ? if so, update our personal info
 
      if (playercard->is_own)
 
      {
 
         // find the remote player
 
         network_player = Player_FindByType (PLAYER_INTERNET);
 
         if (network_player != NULL)
 
         {
 
            // retrieve the personal message text from the control
 
            GetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, personalmessage_text, WCHAR_SIZEOF (personalmessage_text));
 
 
 
            // is it NOT the default text ?
 
            if (wcscmp (personalmessage_text, LOCALIZE (L"PlayerCard_TypeYourPersonalMessageHere")) != NULL)
 
            {
 
               // set finger variables 1 to 10 (max 10 lines)
 
               current_line = wcstok_s (personalmessage_text, L"\r\n", &wcstok_context);
 
               for (insert_index = 1; insert_index < 10; insert_index++)
 
               {
 
                  Player_SendBuffer_Add (network_player, 1000, L"set %d %s\n", insert_index, (current_line != NULL ? current_line : L""));
 
                  current_line = wcstok_s (NULL, L"\r\n", &wcstok_context);
 
               }
 
            }
 
         }
 
      }
 
 
 
      KillTimer (hWnd, TIMER_REFRESHDIALOG); // destroy the timer we used to refresh the dialog text
 
      EndDialog (hWnd, 0); // close the dialog box
 
   }
 
 
 
   // else did we take action on one of the controls ?
 
   else if (message == WM_COMMAND)
 
   {
 
      // did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key)
 
      if (wParam_loword == IDCANCEL)
 
      {
 
         KillTimer (hWnd, TIMER_REFRESHDIALOG); // destroy the timer we used to refresh the dialog text
 
         EndDialog (hWnd, 0); // close the dialog box
 
      }
 
 
 
      // else was it the game played hyperlink ?
 
      else if (wParam_loword == STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE)
 
      {
 
         playercard = &playercards[GetWindowLongPtr (hWnd, DWLP_USER)]; // quick access to player card
 
 
 
         // see which player it is
 
         for (player_index = 0; player_index < onlineplayer_count; player_index++)
 
            if (wcscmp (onlineplayers[player_index].nickname, playercard->nickname) == 0)
 
               break; // stop searching as soon as player is found
 
 
 
         // have we found it ?
 
         if (player_index < onlineplayer_count)
 
         {
 
            onlineplayer = &onlineplayers[player_index]; // quick access to online player
 
 
 
            // is player actually playing a game ?
 
            if (playercard->game_played != 0)
 
               ; // yes, so watch it as spectator (TODO)
 
 
 
            // else is player invitable ?
 
            else if ((playercard->minutes_online > 0) && !playercard->is_own
 
                     && (onlineplayer->handlestatus != HANDLESTATUS_NOTOPENFORAMATCH))
 
            {
 
               // save concerned nickname before destroying window
 
               wcscpy_s (invitee_nickname, WCHAR_SIZEOF (invitee_nickname), playercard->nickname);
 
 
 
               KillTimer (hWnd, TIMER_REFRESHDIALOG); // destroy the timer we used to refresh the dialog text
 
               EndDialog (hWnd, 1); // close the dialog box and return a success value
 
            }
 
         }
 
      }
 
 
 
      // else was it the status bar hyperlink ?
 
      else if (wParam_loword == STATICTEXT_PLAYERCARD_STATUSBAR)
 
         ShellExecute (NULL, L"open", PROGRAM_URL, NULL, NULL, SW_MAXIMIZE); // open the donation page in the default browser, maximized
 
   }
 
 
 
   // else is it a timer event AND is it our refresh timer ?
 
   else if ((message == WM_TIMER) && (wParam == TIMER_REFRESHDIALOG))
 
   {
 
      playercard = &playercards[GetWindowLongPtr (hWnd, DWLP_USER)]; // quick access to player card
 
 
 
      // do we need to update dialog ?
 
      if (playercard->update_dialog)
 
      {
 
         swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_Title"), playercard->nickname);
 
         SetWindowText (hWnd, text_to_send); // set window title
 
 
 
         // does this player NOT exist ?
 
         if (playercard->doesnt_exist)
 
         {
 
            // set personal message
 
            SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, L"");
 
 
 
            // set statistics phrase
 
            swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_DoesNotExist"), playercard->nickname);
 
            SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_STATSTEXT, text_to_send);
 
 
 
            // set current activity stats
 
            SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORVALUE, L"-");
 
            SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSVALUE, L"-");
 
            SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE, L"-");
 
            SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYVALUE, L"-");
 
         }
 
         else
 
         {
 
            // set personal message
 
            if (playercard->fingertext_length > 0)
 
               SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, playercard->fingertext);
 
            else if (playercard->got_reply)
 
            {
 
               // if it's our card, invite player to write a personal message; else tell this player has none
 
               if (playercard->is_own)
 
                  SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, LOCALIZE (L"PlayerCard_TypeYourPersonalMessageHere"));
 
               else
 
                  SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, LOCALIZE (L"PlayerCard_NoPersonalMessage"));
 
            }
 
            else
 
               SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, L"");
 
 
 
            // if it's our card, select all the personal message text
 
            if (playercard->is_own)
 
               SendMessage (GetDlgItem (hWnd, EDITBOX_PLAYERCARD_FINGERDATA), EM_SETSEL, 0, -1); // select all text
 
 
 
            // set statistics phrase
 
            if (playercard->gamestylerating_count > 0)
 
            {
 
               if (playercard->is_own)
 
                  wcscpy_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_YourStats"));
 
               else
 
                  swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_Stats"), playercard->nickname);
 
            }
 
            else if (playercard->got_reply)
 
            {
 
               if (playercard->is_own)
 
                  wcscpy_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_NoStatsYetForYou"));
 
               else
 
                  swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_NoStatsYet"), playercard->nickname);
 
            }
 
            else
 
               text_to_send[0] = 0;
 
            SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_STATSTEXT, text_to_send);
 
 
 
            // set statistics
 
            hListWnd = GetDlgItem (hWnd, COMBOBOX_GAMESTYLES); // get a quick access to the list control
 
            ListView_DeleteAllItems (hListWnd); // start by emptying it first
 
            memset (&lvi, 0, sizeof (lvi)); // tell Windows which members of the LVCOLUMN structure we're filling
 
            lvi.mask = LVIF_IMAGE | LVIF_PARAM; // we want to set the image and the item's pointer
 
            for (gsr_index = 0; gsr_index < playercard->gamestylerating_count; gsr_index++)
 
            {
 
               gamestylerating = &playercard->gamestyleratings[gsr_index]; // quick access to game style rating
 
 
 
               // set item's image and name
 
               lvi.iItem = gsr_index;
 
               lvi.iImage = listviewicons[HANDLESTATUS_INGAME]; 
 
               insert_index = ListView_InsertItem (hListWnd, &lvi); // add each item to list view
 
 
 
               // set item's substrings
 
               ListView_SetItemText (hListWnd, insert_index, 0, gamestylerating->name); // game style name
 
               swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->rating);
 
               ListView_SetItemText (hListWnd, insert_index, 1, text_to_send); // rating
 
               swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%.1f", gamestylerating->rd);
 
               ListView_SetItemText (hListWnd, insert_index, 2, text_to_send); // RD
 
               swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->win_count);
 
               ListView_SetItemText (hListWnd, insert_index, 3, text_to_send); // wins
 
               swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->loss_count);
 
               ListView_SetItemText (hListWnd, insert_index, 4, text_to_send); // losses
 
               swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->draw_count);
 
               ListView_SetItemText (hListWnd, insert_index, 5, text_to_send); // draws
 
               swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->total_matches);
 
               ListView_SetItemText (hListWnd, insert_index, 6, text_to_send); // totals
 
            }
 
 
 
            // set status
 
            swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"Opponents_StatusOffline")); // assume offline until found
 
 
 
            // cycle through all online players and see if this one is online
 
            for (player_index = 0; player_index < onlineplayer_count; player_index++)
 
               if (wcscmp (onlineplayers[player_index].nickname, playercard->nickname) == 0)
 
                  break; // break as soon as we find it
 
 
 
            // have we found it ?
 
            if (player_index < onlineplayer_count)
 
               onlineplayer = &onlineplayers[player_index]; // quick access to online player
 
            else
 
               onlineplayer = NULL; // else this player is not online
 
 
 
            // is player online ?
 
            if (onlineplayer != NULL)
 
            {
 
               // verify status before setting it
 
               if (((onlineplayer->handlestatus == HANDLESTATUS_INGAME) || (onlineplayer->handlestatus == HANDLESTATUS_EXAMININGAGAME))
 
                     && (playercard->game_played == 0))
 
                  onlineplayer->handlestatus = HANDLESTATUS_AVAILABLE; // if player was reported playing but no game, mark it free
 
 
 
               SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSVALUE, handlestatus[onlineplayer->handlestatus].text);
 
            }
 
            else
 
               SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSVALUE, handlestatus[HANDLESTATUS_OFFLINE].text);
 
 
 
            // set played game name
 
            if (playercard->game_played != 0)
 
               swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d - %s", playercard->game_played, playercard->game_name);
 
            else if ((playercard->minutes_online > 0) && !playercard->is_own
 
                     && (onlineplayer != NULL) && (onlineplayer->handlestatus != HANDLESTATUS_NOTOPENFORAMATCH))
 
               swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_ChatOrInvite")); // no game ; if online, we can invite him
 
            else
 
               text_to_send[0] = 0;
 
            SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE, text_to_send);
 
 
 
            // only set online time and idle time if player is not offline (if we have found him, then he's online)
 
            if (onlineplayer != NULL)
 
            {
 
               MinutesToWideCharString (text_to_send, WCHAR_SIZEOF (text_to_send), playercard->minutes_online);
 
               SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORVALUE, text_to_send); // set online time value
 
 
 
               SecondsToWideCharString (text_to_send, WCHAR_SIZEOF (text_to_send), playercard->seconds_idle);
 
               SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYVALUE, text_to_send); // set idle time value
 
            }
 
            else
 
            {
 
               SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORVALUE, L"-"); // player is offline
 
 
 
               if (playercard->disconnection_month == 1) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_January"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 2) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_February"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 3) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_March"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 4) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_April"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 5) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_May"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 6) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_June"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 7) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_July"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 8) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_August"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 9) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_September"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 10) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_October"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 11) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_November"), playercard->disconnection_year);
 
               else if (playercard->disconnection_month == 12) swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d %s %d", playercard->disconnection_day, LOCALIZE (L"Month_December"), playercard->disconnection_year);
 
               else swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"Never"));
 
               SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYVALUE, text_to_send); // print last disconnection date
 
            }
 
         }
 
 
 
         playercard->update_dialog = false; // remember we refreshed dialog text
 
      }
 
   }
 
 
 
   // call the default dialog message processing function to keep things going
 
   return (false);
 
}