Subversion Repositories Games.Chess Giants

Rev

Rev 124 | Details | Compare with Previous | Last modification | View Log | RSS feed

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