Subversion Repositories Games.Chess Giants

Rev

Rev 1 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. // dialog_playercard.cpp
  2.  
  3. #include "../common.h"
  4.  
  5.  
  6. // dialog template
  7. #define THIS_DIALOG DIALOG_PLAYERCARD
  8.  
  9.  
  10. // local definitions
  11. #define TIMER_REFRESHDIALOG 1
  12.  
  13.  
  14. // list view column definition
  15. typedef struct listviewcolumn_s
  16. {
  17.    int width;
  18.    int alignment;
  19.    wchar_t *text;
  20. } listviewcolumn_t;
  21.  
  22.  
  23. // global variables used in this module only
  24. static int listviewicons[sizeof (handlestatus) / sizeof (handlestatus_t)]; // as big as the handlestatus global array
  25. static listviewcolumn_t listviewcolumns[] =
  26. {
  27.    { 80, LVCFMT_LEFT, NULL /*LOCALIZE (L"PlayerCard_GameStyle")*/}, // text address needs to be set at runtime, because it's mallocated
  28.    { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Rating")*/},
  29.    { 40, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_RD")*/},
  30.    { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Wins")*/},
  31.    { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Losses")*/},
  32.    { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Draws")*/},
  33.    { 45, LVCFMT_CENTER, NULL /*LOCALIZE (L"PlayerCard_Totals")*/},
  34. };
  35. static wchar_t personalmessage_text[1024];
  36. static wchar_t invitee_nickname[32];
  37.  
  38.  
  39. // prototypes of local functions
  40. static void StartThread_PlayerCard (void *thread_parms);
  41. static int CALLBACK DialogProc_PlayerCard (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam);
  42.  
  43.  
  44. void DialogBox_PlayerCard (int playercard_index)
  45. {
  46.    // helper function to fire up the modeless dialog box
  47.  
  48.    _beginthread (StartThread_PlayerCard, 0, (void *) playercard_index); // fire up the thread
  49.    return; // return as soon as the thread is fired up
  50. }
  51.  
  52.  
  53. void DialogBox_PlayerCard_Validated (void)
  54. {
  55.    // callback function called by the main game thread when the dialog box is validated
  56.  
  57.    challenge_t *challenge;
  58.  
  59.    // remember this callback is no longer to be called
  60.    is_dialogbox_playercard_validated = false;
  61.  
  62.    // TODO: verify if not ourselves
  63.  
  64.    // player is available for an invitation. Is he already inviting us ?
  65.    challenge = Challenge_Find (invitee_nickname);
  66.    if ((challenge != NULL) && challenge->is_active && IsWindow (challenge->hWnd))
  67.       EndDialog (challenge->hWnd, 0); // if so, close the challenge dialog box (this will also make us decline it properly)
  68.  
  69.    Interlocutor_FindOrCreate (invitee_nickname); // fire up the chat window with this player
  70.    return; // finished, a new chat window has been opened with this player
  71. }
  72.  
  73.  
  74. static void StartThread_PlayerCard (void *thread_parms)
  75. {
  76.    // this function runs in a separate thread, for that's the only way (seemingly)
  77.    // to implement a non-modal message box using the Common Controls library.
  78.  
  79.    int playercard_index;
  80.    playercard_t *playercard;
  81.  
  82.    playercard_index = (int) thread_parms;
  83.    if (playercard_index >= playercard_count)
  84.       return; // consistency check; _endthread() implied
  85.    playercard = &playercards[playercard_index]; // quick access to player card structure
  86.  
  87.    // display the dialog box and attach this playercard to it
  88.    if (DialogBoxParam (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), NULL, DialogProc_PlayerCard, (LPARAM) playercard_index) == 1)
  89.       is_dialogbox_playercard_validated = true;
  90.  
  91.    // now that we're sure the window disappeared...
  92.    playercard = &playercards[playercard_index]; // quick access to player card structure (it may have relocated)
  93.    playercard->is_active = false; // remember interlocutor has gone away
  94.    SAFE_free ((void **) &playercard->fingertext); // free its text
  95.    playercard->fingertext_length = 0; // and reset its text length
  96.    SAFE_free ((void **) &playercard->gamestyleratings); // free its game style ratings
  97.    playercard->gamestylerating_count = 0; // and reset its count
  98.  
  99.    the_board.reevaluate = true; // refresh the GUI buttons if needed
  100.    return; // _endthread() implied
  101. }
  102.  
  103.  
  104. static int CALLBACK DialogProc_PlayerCard (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam)
  105. {
  106.    // message handler for the dialog box
  107.  
  108.    unsigned short wParam_hiword;
  109.    unsigned short wParam_loword;
  110.    gamestylerating_t *gamestylerating;
  111.    onlineplayer_t *onlineplayer;
  112.    playercard_t *playercard;
  113.    wchar_t text_to_send[256];
  114.    wchar_t *current_line;
  115.    wchar_t *wcstok_context;
  116.    player_t *network_player;
  117.    HIMAGELIST imagelist;
  118.    HWND hListWnd;
  119.    LVCOLUMN lvc;
  120.    LVITEM lvi;
  121.    int insert_index;
  122.    int column_index;
  123.    int player_index;
  124.    int gsr_index;
  125.  
  126.    // filter out the commonly used message values
  127.    wParam_hiword = HIWORD (wParam);
  128.    wParam_loword = LOWORD (wParam);
  129.  
  130.    // have we just fired up this window ?
  131.    if (message == WM_INITDIALOG)
  132.    {
  133.       playercard = &playercards[lParam]; // quick access to player card
  134.       SetWindowLongPtr (hWnd, DWLP_USER, lParam); // attach player card
  135.       playercard->hWnd = hWnd; // and save window handle
  136.  
  137.       // center the window
  138.       CenterWindow (hWnd, hMainWnd);
  139.  
  140.       // set dialog icons (small one for title bar & big one for task manager)
  141.       SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_CARD)));
  142.       SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_CARD)));
  143.  
  144.       // find the remote player
  145.       network_player = Player_FindByType (PLAYER_INTERNET);
  146.  
  147.       // make network player ask an update from the server
  148.       if (network_player != NULL)
  149.       {
  150.          if (lastonlineplayers_time + 5.0f < current_time)
  151.             Player_SendBuffer_Add (network_player, 1000, L"who\n"); // finger requests need an updated player list
  152.          Player_SendBuffer_Add (network_player, 1000, L"finger %s\n", playercard->nickname); // send the finger request
  153.       }
  154.  
  155.       // set the finger data text area font
  156.       SendMessage (GetDlgItem (hWnd, EDITBOX_PLAYERCARD_FINGERDATA), WM_SETFONT, (WPARAM) hFontChat, false);
  157.  
  158.       // set the dialog text editable if it's ours, and read-only if it's not
  159.       Edit_SetReadOnly (GetDlgItem (hWnd, EDITBOX_PLAYERCARD_FINGERDATA), !playercard->is_own);
  160.  
  161.       // prepare the list view : do it before anything that could trigger a fill
  162.  
  163.       // get a quick access to the list control
  164.       hListWnd = GetDlgItem (hWnd, COMBOBOX_GAMESTYLES);
  165.  
  166.       // tell Windows which members of the LVCOLUMN structure we're filling
  167.       memset (&lvc, 0, sizeof (lvc));
  168.       lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  169.       for (column_index = 0; column_index < sizeof (listviewcolumns) / sizeof (listviewcolumn_t); column_index++)
  170.       {
  171.          lvc.iSubItem = column_index;
  172.          if (column_index == 0) lvc.pszText = LOCALIZE (L"PlayerCard_GameStyle");
  173.          else if (column_index == 1) lvc.pszText = LOCALIZE (L"PlayerCard_Rating");
  174.          else if (column_index == 2) lvc.pszText = LOCALIZE (L"PlayerCard_RD");
  175.          else if (column_index == 3) lvc.pszText = LOCALIZE (L"PlayerCard_Wins");
  176.          else if (column_index == 4) lvc.pszText = LOCALIZE (L"PlayerCard_Losses");
  177.          else if (column_index == 5) lvc.pszText = LOCALIZE (L"PlayerCard_Draws");
  178.          else if (column_index == 6) lvc.pszText = LOCALIZE (L"PlayerCard_Totals");
  179.          lvc.cx = listviewcolumns[column_index].width;
  180.          lvc.fmt = listviewcolumns[column_index].alignment;
  181.          ListView_InsertColumn (hListWnd, column_index, &lvc); // add each column to list view
  182.       }
  183.  
  184.       // create the listview image list
  185.       imagelist = ImageList_Create (16, 16, ILC_COLOR32, sizeof (handlestatus) / sizeof (handlestatus_t), 1); // create an imagelist holding N 32-bit images
  186.       for (insert_index = 1; insert_index < sizeof (handlestatus) / sizeof (handlestatus_t); insert_index++)
  187.          listviewicons[insert_index] = ImageList_AddIcon (imagelist, handlestatus[insert_index].icon); // add our icons in the image list
  188.       ListView_SetImageList (hListWnd, imagelist, LVSIL_SMALL); // associate it with the listview
  189.  
  190.       // set window title and control texts
  191.       swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_TitleBuildingCard"), playercard->nickname);
  192.       SetWindowText (hWnd, text_to_send);
  193.       if (playercard->is_own)
  194.          wcscpy_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_YourStats"));
  195.       else
  196.          swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_Stats"), playercard->nickname);
  197.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_STATSTEXT, text_to_send);
  198.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORKEY, LOCALIZE (L"PlayerCard_OnlineForKey"));
  199.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORVALUE, L"");
  200.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSKEY, LOCALIZE (L"PlayerCard_CurrentStatusKey"));
  201.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSVALUE, L"");
  202.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDKEY, LOCALIZE (L"PlayerCard_GamePlayedKey"));
  203.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE, L"");
  204.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYKEY, LOCALIZE (L"PlayerCard_LastActivityKey"));
  205.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYVALUE, L"");
  206.       SetDlgItemText (hWnd, BUTTON_CLOSE, LOCALIZE (L"Button_Close"));
  207.       SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_STATUSBAR, LOCALIZE (L"PlayerCard_StatusBar"));
  208.  
  209.       // refresh the server message area every second
  210.       SetTimer (hWnd, TIMER_REFRESHDIALOG, 1000, NULL);
  211.       SendMessage (hWnd, WM_TIMER, TIMER_REFRESHDIALOG, 0); // but call it now
  212.  
  213.       // convert the game played and status bar message to a hyperlink
  214.       ConvertStaticToHyperlink (GetDlgItem (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE));
  215.       ConvertStaticToHyperlink (GetDlgItem (hWnd, STATICTEXT_PLAYERCARD_STATUSBAR));
  216.    }
  217.  
  218.    // else did we click the close button on the title bar ?
  219.    else if (message == WM_CLOSE)
  220.    {
  221.       playercard = &playercards[GetWindowLongPtr (hWnd, DWLP_USER)]; // quick access to player card
  222.  
  223.       // was it our own card ? if so, update our personal info
  224.       if (playercard->is_own)
  225.       {
  226.          // find the remote player
  227.          network_player = Player_FindByType (PLAYER_INTERNET);
  228.          if (network_player != NULL)
  229.          {
  230.             // retrieve the personal message text from the control
  231.             GetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, personalmessage_text, WCHAR_SIZEOF (personalmessage_text));
  232.  
  233.             // is it NOT the default text ?
  234.             if (wcscmp (personalmessage_text, LOCALIZE (L"PlayerCard_TypeYourPersonalMessageHere")) != NULL)
  235.             {
  236.                // set finger variables 1 to 10 (max 10 lines)
  237.                current_line = wcstok_s (personalmessage_text, L"\r\n", &wcstok_context);
  238.                for (insert_index = 1; insert_index < 10; insert_index++)
  239.                {
  240.                   Player_SendBuffer_Add (network_player, 1000, L"set %d %s\n", insert_index, (current_line != NULL ? current_line : L""));
  241.                   current_line = wcstok_s (NULL, L"\r\n", &wcstok_context);
  242.                }
  243.             }
  244.          }
  245.       }
  246.  
  247.       KillTimer (hWnd, TIMER_REFRESHDIALOG); // destroy the timer we used to refresh the dialog text
  248.       EndDialog (hWnd, 0); // close the dialog box
  249.    }
  250.  
  251.    // else did we take action on one of the controls ?
  252.    else if (message == WM_COMMAND)
  253.    {
  254.       // did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key)
  255.       if (wParam_loword == IDCANCEL)
  256.       {
  257.          KillTimer (hWnd, TIMER_REFRESHDIALOG); // destroy the timer we used to refresh the dialog text
  258.          EndDialog (hWnd, 0); // close the dialog box
  259.       }
  260.  
  261.       // else was it the game played hyperlink ?
  262.       else if (wParam_loword == STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE)
  263.       {
  264.          playercard = &playercards[GetWindowLongPtr (hWnd, DWLP_USER)]; // quick access to player card
  265.  
  266.          // see which player it is
  267.          for (player_index = 0; player_index < onlineplayer_count; player_index++)
  268.             if (wcscmp (onlineplayers[player_index].nickname, playercard->nickname) == 0)
  269.                break; // stop searching as soon as player is found
  270.  
  271.          // have we found it ?
  272.          if (player_index < onlineplayer_count)
  273.          {
  274.             onlineplayer = &onlineplayers[player_index]; // quick access to online player
  275.  
  276.             // is player actually playing a game ?
  277.             if (playercard->game_played != 0)
  278.                ; // yes, so watch it as spectator (TODO)
  279.  
  280.             // else is player invitable ?
  281.             else if ((playercard->minutes_online > 0) && !playercard->is_own
  282.                      && (onlineplayer->handlestatus != HANDLESTATUS_NOTOPENFORAMATCH))
  283.             {
  284.                // save concerned nickname before destroying window
  285.                wcscpy_s (invitee_nickname, WCHAR_SIZEOF (invitee_nickname), playercard->nickname);
  286.  
  287.                KillTimer (hWnd, TIMER_REFRESHDIALOG); // destroy the timer we used to refresh the dialog text
  288.                EndDialog (hWnd, 1); // close the dialog box and return a success value
  289.             }
  290.          }
  291.       }
  292.  
  293.       // else was it the status bar hyperlink ?
  294.       else if (wParam_loword == STATICTEXT_PLAYERCARD_STATUSBAR)
  295.          ShellExecute (NULL, L"open", PROGRAM_URL, NULL, NULL, SW_MAXIMIZE); // open the donation page in the default browser, maximized
  296.    }
  297.  
  298.    // else is it a timer event AND is it our refresh timer ?
  299.    else if ((message == WM_TIMER) && (wParam == TIMER_REFRESHDIALOG))
  300.    {
  301.       playercard = &playercards[GetWindowLongPtr (hWnd, DWLP_USER)]; // quick access to player card
  302.  
  303.       // do we need to update dialog ?
  304.       if (playercard->update_dialog)
  305.       {
  306.          swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_Title"), playercard->nickname);
  307.          SetWindowText (hWnd, text_to_send); // set window title
  308.  
  309.          // does this player NOT exist ?
  310.          if (playercard->doesnt_exist)
  311.          {
  312.             // set personal message
  313.             SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, L"");
  314.  
  315.             // set statistics phrase
  316.             swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_DoesNotExist"), playercard->nickname);
  317.             SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_STATSTEXT, text_to_send);
  318.  
  319.             // set current activity stats
  320.             SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORVALUE, L"-");
  321.             SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSVALUE, L"-");
  322.             SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE, L"-");
  323.             SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYVALUE, L"-");
  324.          }
  325.          else
  326.          {
  327.             // set personal message
  328.             if (playercard->fingertext_length > 0)
  329.                SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, playercard->fingertext);
  330.             else if (playercard->got_reply)
  331.             {
  332.                // if it's our card, invite player to write a personal message; else tell this player has none
  333.                if (playercard->is_own)
  334.                   SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, LOCALIZE (L"PlayerCard_TypeYourPersonalMessageHere"));
  335.                else
  336.                   SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, LOCALIZE (L"PlayerCard_NoPersonalMessage"));
  337.             }
  338.             else
  339.                SetDlgItemText (hWnd, EDITBOX_PLAYERCARD_FINGERDATA, L"");
  340.  
  341.             // if it's our card, select all the personal message text
  342.             if (playercard->is_own)
  343.                SendMessage (GetDlgItem (hWnd, EDITBOX_PLAYERCARD_FINGERDATA), EM_SETSEL, 0, -1); // select all text
  344.  
  345.             // set statistics phrase
  346.             if (playercard->gamestylerating_count > 0)
  347.             {
  348.                if (playercard->is_own)
  349.                   wcscpy_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_YourStats"));
  350.                else
  351.                   swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_Stats"), playercard->nickname);
  352.             }
  353.             else if (playercard->got_reply)
  354.             {
  355.                if (playercard->is_own)
  356.                   wcscpy_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_NoStatsYetForYou"));
  357.                else
  358.                   swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_NoStatsYet"), playercard->nickname);
  359.             }
  360.             else
  361.                text_to_send[0] = 0;
  362.             SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_STATSTEXT, text_to_send);
  363.  
  364.             // set statistics
  365.             hListWnd = GetDlgItem (hWnd, COMBOBOX_GAMESTYLES); // get a quick access to the list control
  366.             ListView_DeleteAllItems (hListWnd); // start by emptying it first
  367.             memset (&lvi, 0, sizeof (lvi)); // tell Windows which members of the LVCOLUMN structure we're filling
  368.             lvi.mask = LVIF_IMAGE | LVIF_PARAM; // we want to set the image and the item's pointer
  369.             for (gsr_index = 0; gsr_index < playercard->gamestylerating_count; gsr_index++)
  370.             {
  371.                gamestylerating = &playercard->gamestyleratings[gsr_index]; // quick access to game style rating
  372.  
  373.                // set item's image and name
  374.                lvi.iItem = gsr_index;
  375.                lvi.iImage = listviewicons[HANDLESTATUS_INGAME];
  376.                insert_index = ListView_InsertItem (hListWnd, &lvi); // add each item to list view
  377.  
  378.                // set item's substrings
  379.                ListView_SetItemText (hListWnd, insert_index, 0, gamestylerating->name); // game style name
  380.                swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->rating);
  381.                ListView_SetItemText (hListWnd, insert_index, 1, text_to_send); // rating
  382.                swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%.1f", gamestylerating->rd);
  383.                ListView_SetItemText (hListWnd, insert_index, 2, text_to_send); // RD
  384.                swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->win_count);
  385.                ListView_SetItemText (hListWnd, insert_index, 3, text_to_send); // wins
  386.                swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->loss_count);
  387.                ListView_SetItemText (hListWnd, insert_index, 4, text_to_send); // losses
  388.                swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->draw_count);
  389.                ListView_SetItemText (hListWnd, insert_index, 5, text_to_send); // draws
  390.                swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d", gamestylerating->total_matches);
  391.                ListView_SetItemText (hListWnd, insert_index, 6, text_to_send); // totals
  392.             }
  393.  
  394.             // set status
  395.             swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"Opponents_StatusOffline")); // assume offline until found
  396.  
  397.             // cycle through all online players and see if this one is online
  398.             for (player_index = 0; player_index < onlineplayer_count; player_index++)
  399.                if (wcscmp (onlineplayers[player_index].nickname, playercard->nickname) == 0)
  400.                   break; // break as soon as we find it
  401.  
  402.             // have we found it ?
  403.             if (player_index < onlineplayer_count)
  404.                onlineplayer = &onlineplayers[player_index]; // quick access to online player
  405.             else
  406.                onlineplayer = NULL; // else this player is not online
  407.  
  408.             // is player online ?
  409.             if (onlineplayer != NULL)
  410.             {
  411.                // verify status before setting it
  412.                if (((onlineplayer->handlestatus == HANDLESTATUS_INGAME) || (onlineplayer->handlestatus == HANDLESTATUS_EXAMININGAGAME))
  413.                      && (playercard->game_played == 0))
  414.                   onlineplayer->handlestatus = HANDLESTATUS_AVAILABLE; // if player was reported playing but no game, mark it free
  415.  
  416.                SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSVALUE, handlestatus[onlineplayer->handlestatus].text);
  417.             }
  418.             else
  419.                SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_CURRENTSTATUSVALUE, handlestatus[HANDLESTATUS_OFFLINE].text);
  420.  
  421.             // set played game name
  422.             if (playercard->game_played != 0)
  423.                swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), L"%d - %s", playercard->game_played, playercard->game_name);
  424.             else if ((playercard->minutes_online > 0) && !playercard->is_own
  425.                      && (onlineplayer != NULL) && (onlineplayer->handlestatus != HANDLESTATUS_NOTOPENFORAMATCH))
  426.                swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"PlayerCard_ChatOrInvite")); // no game ; if online, we can invite him
  427.             else
  428.                text_to_send[0] = 0;
  429.             SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_GAMEPLAYEDVALUE, text_to_send);
  430.  
  431.             // only set online time and idle time if player is not offline (if we have found him, then he's online)
  432.             if (onlineplayer != NULL)
  433.             {
  434.                MinutesToWideCharString (text_to_send, WCHAR_SIZEOF (text_to_send), playercard->minutes_online);
  435.                SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORVALUE, text_to_send); // set online time value
  436.  
  437.                SecondsToWideCharString (text_to_send, WCHAR_SIZEOF (text_to_send), playercard->seconds_idle);
  438.                SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYVALUE, text_to_send); // set idle time value
  439.             }
  440.             else
  441.             {
  442.                SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_ONLINEFORVALUE, L"-"); // player is offline
  443.  
  444.                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);
  445.                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);
  446.                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);
  447.                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);
  448.                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);
  449.                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);
  450.                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);
  451.                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);
  452.                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);
  453.                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);
  454.                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);
  455.                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);
  456.                else swprintf_s (text_to_send, WCHAR_SIZEOF (text_to_send), LOCALIZE (L"Never"));
  457.                SetDlgItemText (hWnd, STATICTEXT_PLAYERCARD_LASTACTIVITYVALUE, text_to_send); // print last disconnection date
  458.             }
  459.          }
  460.  
  461.          playercard->update_dialog = false; // remember we refreshed dialog text
  462.       }
  463.    }
  464.  
  465.    // call the default dialog message processing function to keep things going
  466.    return (false);
  467. }
  468.