changeset 2639 | 8a7342eb3a78 |
parent 2630 | 35249d2ded3e |
child 2669 | 2f69f91002ac |
2638:0c9b00251fce | 2639:8a7342eb3a78 |
---|---|
60 static FiosItem *_selected_map = NULL; // to highlight slected map |
60 static FiosItem *_selected_map = NULL; // to highlight slected map |
61 |
61 |
62 // called when a new server is found on the network |
62 // called when a new server is found on the network |
63 void UpdateNetworkGameWindow(bool unselect) |
63 void UpdateNetworkGameWindow(bool unselect) |
64 { |
64 { |
65 Window *w; |
65 Window* w = FindWindowById(WC_NETWORK_WINDOW, 0); |
66 w = FindWindowById(WC_NETWORK_WINDOW, 0); |
66 |
67 if (w != NULL) { |
67 if (w != NULL) { |
68 if (unselect) |
68 if (unselect) _selected_item = NULL; |
69 _selected_item = NULL; |
|
70 w->vscroll.count = _network_game_count; |
69 w->vscroll.count = _network_game_count; |
71 SetWindowDirty(w); |
70 SetWindowDirty(w); |
72 } |
71 } |
73 } |
72 } |
74 |
73 |
121 cur_item = cur_item->next; |
120 cur_item = cur_item->next; |
122 } |
121 } |
123 |
122 |
124 while (cur_item != NULL) { |
123 while (cur_item != NULL) { |
125 bool compatible = |
124 bool compatible = |
126 !strncmp(cur_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) || |
125 strncmp(cur_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) == 0 || |
127 !strncmp(cur_item->info.server_revision, NOREV_STRING, sizeof(cur_item->info.server_revision)); |
126 strncmp(cur_item->info.server_revision, NOREV_STRING, sizeof(cur_item->info.server_revision) == 0); |
128 |
127 |
129 if (cur_item == sel) |
128 if (cur_item == sel) |
130 GfxFillRect(11, y - 2, 218, y + 9, 10); // show highlighted item with a different colour |
129 GfxFillRect(11, y - 2, 218, y + 9, 10); // show highlighted item with a different colour |
131 |
130 |
132 SetDParamStr(0, cur_item->info.server_name); |
131 SetDParamStr(0, cur_item->info.server_name); |
136 SetDParam(1, cur_item->info.clients_max); |
135 SetDParam(1, cur_item->info.clients_max); |
137 DrawString(135, y, STR_NETWORK_CLIENTS_ONLINE, 2); |
136 DrawString(135, y, STR_NETWORK_CLIENTS_ONLINE, 2); |
138 |
137 |
139 // only draw icons if the server is online |
138 // only draw icons if the server is online |
140 if (cur_item->online) { |
139 if (cur_item->online) { |
141 |
|
142 // draw a lock if the server is password protected. |
140 // draw a lock if the server is password protected. |
143 if(cur_item->info.use_password) |
141 if (cur_item->info.use_password) DrawSprite(SPR_LOCK, 186, y - 1); |
144 DrawSprite(SPR_LOCK, 186, y-1); |
|
145 |
142 |
146 // draw red or green icon, depending on compatibility with server. |
143 // draw red or green icon, depending on compatibility with server. |
147 DrawSprite(SPR_BLOT | (compatible ? PALETTE_TO_GREEN : PALETTE_TO_RED), 195, y); |
144 DrawSprite(SPR_BLOT | (compatible ? PALETTE_TO_GREEN : PALETTE_TO_RED), 195, y); |
148 |
145 |
149 // draw flag according to server language |
146 // draw flag according to server language |
178 DrawStringCenteredTruncated(w->widget[16].left, w->widget[16].right, 54, STR_02BD, 16); // map name |
175 DrawStringCenteredTruncated(w->widget[16].left, w->widget[16].right, 54, STR_02BD, 16); // map name |
179 |
176 |
180 SetDParam(0, sel->info.clients_on); |
177 SetDParam(0, sel->info.clients_on); |
181 SetDParam(1, sel->info.clients_max); |
178 SetDParam(1, sel->info.clients_max); |
182 DrawString(260, y, STR_NETWORK_CLIENTS, 2); // clients on the server / maximum slots |
179 DrawString(260, y, STR_NETWORK_CLIENTS, 2); // clients on the server / maximum slots |
183 y+=10; |
180 y += 10; |
184 |
181 |
185 if (sel->info.server_lang < NETWORK_NUM_LANGUAGES) { |
182 if (sel->info.server_lang < NETWORK_NUM_LANGUAGES) { |
186 SetDParam(0, STR_NETWORK_LANG_ANY+sel->info.server_lang); |
183 SetDParam(0, STR_NETWORK_LANG_ANY + sel->info.server_lang); |
187 DrawString(260, y, STR_NETWORK_LANGUAGE, 2); // server language |
184 DrawString(260, y, STR_NETWORK_LANGUAGE, 2); // server language |
188 } |
185 } |
189 y+=10; |
186 y += 10; |
190 |
187 |
191 if (sel->info.map_set < NUM_LANDSCAPE ) { |
188 if (sel->info.map_set < NUM_LANDSCAPE ) { |
192 SetDParam(0, STR_TEMPERATE_LANDSCAPE+sel->info.map_set); |
189 SetDParam(0, STR_TEMPERATE_LANDSCAPE + sel->info.map_set); |
193 DrawString(260, y, STR_NETWORK_TILESET, 2); // tileset |
190 DrawString(260, y, STR_NETWORK_TILESET, 2); // tileset |
194 } |
191 } |
195 y+=10; |
192 y += 10; |
196 |
193 |
197 SetDParam(0, sel->info.map_width); |
194 SetDParam(0, sel->info.map_width); |
198 SetDParam(1, sel->info.map_height); |
195 SetDParam(1, sel->info.map_height); |
199 DrawString(260, y, STR_NETWORK_MAP_SIZE, 2); // map size |
196 DrawString(260, y, STR_NETWORK_MAP_SIZE, 2); // map size |
200 y+=10; |
197 y += 10; |
201 |
198 |
202 SetDParamStr(0, sel->info.server_revision); |
199 SetDParamStr(0, sel->info.server_revision); |
203 DrawString(260, y, STR_NETWORK_SERVER_VERSION, 2); // server version |
200 DrawString(260, y, STR_NETWORK_SERVER_VERSION, 2); // server version |
204 y+=10; |
201 y += 10; |
205 |
202 |
206 SetDParamStr(0, sel->info.hostname); |
203 SetDParamStr(0, sel->info.hostname); |
207 SetDParam(1, sel->port); |
204 SetDParam(1, sel->port); |
208 DrawString(260, y, STR_NETWORK_SERVER_ADDRESS, 2); // server address |
205 DrawString(260, y, STR_NETWORK_SERVER_ADDRESS, 2); // server address |
209 y+=10; |
206 y += 10; |
210 |
207 |
211 SetDParam(0, sel->info.start_date); |
208 SetDParam(0, sel->info.start_date); |
212 DrawString(260, y, STR_NETWORK_START_DATE, 2); // start date |
209 DrawString(260, y, STR_NETWORK_START_DATE, 2); // start date |
213 y+=10; |
210 y += 10; |
214 |
211 |
215 SetDParam(0, sel->info.game_date); |
212 SetDParam(0, sel->info.game_date); |
216 DrawString(260, y, STR_NETWORK_CURRENT_DATE, 2); // current date |
213 DrawString(260, y, STR_NETWORK_CURRENT_DATE, 2); // current date |
217 y+=10; |
214 y += 10; |
218 |
215 |
219 y+=2; |
216 y += 2; |
220 |
217 |
221 if (strncmp(sel->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) { |
218 if (strncmp(sel->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) { |
222 if (strncmp(sel->info.server_revision, NOREV_STRING, sizeof(sel->info.server_revision)) != 0) |
219 if (strncmp(sel->info.server_revision, NOREV_STRING, sizeof(sel->info.server_revision)) != 0) |
223 DrawStringMultiCenter(365, y, STR_NETWORK_VERSION_MISMATCH, 2); // server mismatch |
220 DrawStringMultiCenter(365, y, STR_NETWORK_VERSION_MISMATCH, 2); // server mismatch |
224 } else if (sel->info.clients_on == sel->info.clients_max) { |
221 } else if (sel->info.clients_on == sel->info.clients_max) { |
225 // Show: server full, when clients_on == clients_max |
222 // Show: server full, when clients_on == clients_max |
226 DrawStringMultiCenter(365, y, STR_NETWORK_SERVER_FULL, 2); // server full |
223 DrawStringMultiCenter(365, y, STR_NETWORK_SERVER_FULL, 2); // server full |
227 } else if (sel->info.use_password) |
224 } else if (sel->info.use_password) { |
228 DrawStringMultiCenter(365, y, STR_NETWORK_PASSWORD, 2); // password warning |
225 DrawStringMultiCenter(365, y, STR_NETWORK_PASSWORD, 2); // password warning |
229 |
226 } |
230 y+=10; |
227 |
228 y += 10; |
|
231 } |
229 } |
232 } break; |
230 } break; |
233 |
231 |
234 case WE_CLICK: |
232 case WE_CLICK: |
235 _selected_field = e->click.widget; |
233 _selected_field = e->click.widget; |
304 |
302 |
305 SetWindowDirty(w); |
303 SetWindowDirty(w); |
306 break; |
304 break; |
307 |
305 |
308 case WE_MOUSELOOP: |
306 case WE_MOUSELOOP: |
309 if (_selected_field == 3) |
307 if (_selected_field == 3) HandleEditBox(w, 3); |
310 HandleEditBox(w, 3); |
|
311 |
|
312 break; |
308 break; |
313 |
309 |
314 case WE_KEYPRESS: |
310 case WE_KEYPRESS: |
315 if (_selected_field != 3) { |
311 if (_selected_field != 3) { |
316 if ( e->keypress.keycode == WKC_DELETE ) { // press 'delete' to remove servers |
312 if ( e->keypress.keycode == WKC_DELETE ) { // press 'delete' to remove servers |
329 } |
325 } |
330 |
326 |
331 if (HandleEditBoxKey(w, 3, e) == 1) break; // enter pressed |
327 if (HandleEditBoxKey(w, 3, e) == 1) break; // enter pressed |
332 |
328 |
333 // The name is only allowed when it starts with a letter! |
329 // The name is only allowed when it starts with a letter! |
334 if (_edit_str_buf[0] != '\0' && _edit_str_buf[0] != ' ') |
330 if (_edit_str_buf[0] != '\0' && _edit_str_buf[0] != ' ') { |
335 ttd_strlcpy(_network_player_name, _edit_str_buf, lengthof(_network_player_name)); |
331 ttd_strlcpy(_network_player_name, _edit_str_buf, lengthof(_network_player_name)); |
336 else |
332 } else { |
337 ttd_strlcpy(_network_player_name, "Player", lengthof(_network_player_name)); |
333 ttd_strlcpy(_network_player_name, "Player", lengthof(_network_player_name)); |
334 } |
|
338 |
335 |
339 break; |
336 break; |
340 |
337 |
341 case WE_ON_EDIT_TEXT: { |
338 case WE_ON_EDIT_TEXT: { |
342 NetworkAddServer(e->edittext.str); |
339 NetworkAddServer(e->edittext.str); |
394 |
391 |
395 /* Only show once */ |
392 /* Only show once */ |
396 if (_first_time_show_network_game_window) { |
393 if (_first_time_show_network_game_window) { |
397 _first_time_show_network_game_window = false; |
394 _first_time_show_network_game_window = false; |
398 // add all servers from the config file to our list |
395 // add all servers from the config file to our list |
399 for (i=0; i != lengthof(_network_host_list); i++) { |
396 for (i = 0; i != lengthof(_network_host_list); i++) { |
400 if (_network_host_list[i] == NULL) break; |
397 if (_network_host_list[i] == NULL) break; |
401 NetworkAddServer(_network_host_list[i]); |
398 NetworkAddServer(_network_host_list[i]); |
402 } |
399 } |
403 } |
400 } |
404 |
401 |
487 } |
484 } |
488 } break; |
485 } break; |
489 |
486 |
490 case WE_CLICK: |
487 case WE_CLICK: |
491 _selected_field = e->click.widget; |
488 _selected_field = e->click.widget; |
492 switch(e->click.widget) { |
489 switch (e->click.widget) { |
493 case 0: case 15: /* Close 'X' | Cancel button */ |
490 case 0: /* Close 'X' */ |
491 case 15: /* Cancel button */ |
|
494 ShowNetworkGameWindow(); |
492 ShowNetworkGameWindow(); |
495 break; |
493 break; |
496 case 4: { /* Set password button */ |
494 |
495 case 4: /* Set password button */ |
|
497 ShowQueryString(BindCString(_network_server_password), |
496 ShowQueryString(BindCString(_network_server_password), |
498 STR_NETWORK_SET_PASSWORD, 20, 250, w->window_class, w->window_number); |
497 STR_NETWORK_SET_PASSWORD, 20, 250, w->window_class, w->window_number); |
499 } break; |
498 break; |
499 |
|
500 case 5: { /* Select map */ |
500 case 5: { /* Select map */ |
501 int y = (e->click.pt.y - NSSWND_START) / NSSWND_ROWSIZE; |
501 int y = (e->click.pt.y - NSSWND_START) / NSSWND_ROWSIZE; |
502 if ((y += w->vscroll.pos) >= w->vscroll.count) |
502 |
503 return; |
503 y += w->vscroll.pos; |
504 if (y >= w->vscroll.count) return; |
|
504 |
505 |
505 _selected_map = (y == 0) ? NULL : _fios_list + y - 1; |
506 _selected_map = (y == 0) ? NULL : _fios_list + y - 1; |
506 SetWindowDirty(w); |
507 SetWindowDirty(w); |
507 } break; |
508 } break; |
508 case 7: case 8: /* Connection type */ |
509 case 7: case 8: /* Connection type */ |
559 |
560 |
560 SetWindowDirty(w); |
561 SetWindowDirty(w); |
561 break; |
562 break; |
562 |
563 |
563 case WE_MOUSELOOP: |
564 case WE_MOUSELOOP: |
564 if (_selected_field == 3) |
565 if (_selected_field == 3) HandleEditBox(w, 3); |
565 HandleEditBox(w, 3); |
|
566 break; |
566 break; |
567 |
567 |
568 case WE_KEYPRESS: |
568 case WE_KEYPRESS: |
569 if (_selected_field == 3) |
569 if (_selected_field == 3) HandleEditBoxKey(w, 3, e); |
570 HandleEditBoxKey(w, 3, e); |
|
571 break; |
570 break; |
572 |
571 |
573 case WE_ON_EDIT_TEXT: { |
572 case WE_ON_EDIT_TEXT: { |
574 const char *b = e->edittext.str; |
573 ttd_strlcpy(_network_server_password, e->edittext.str, lengthof(_network_server_password)); |
575 ttd_strlcpy(_network_server_password, b, sizeof(_network_server_password)); |
|
576 _network_game_info.use_password = (_network_server_password[0] != '\0'); |
574 _network_game_info.use_password = (_network_server_password[0] != '\0'); |
577 SetWindowDirty(w); |
575 SetWindowDirty(w); |
578 } break; |
576 } break; |
579 } |
577 } |
580 } |
578 } |
634 } |
632 } |
635 |
633 |
636 static byte NetworkLobbyFindCompanyIndex(byte pos) |
634 static byte NetworkLobbyFindCompanyIndex(byte pos) |
637 { |
635 { |
638 byte i; |
636 byte i; |
637 |
|
639 /* Scroll through all _network_player_info and get the 'pos' item |
638 /* Scroll through all _network_player_info and get the 'pos' item |
640 that is not empty */ |
639 that is not empty */ |
641 for (i = 0; i < MAX_PLAYERS; i++) { |
640 for (i = 0; i < MAX_PLAYERS; i++) { |
642 if (_network_player_info[i].company_name[0] != '\0') { |
641 if (_network_player_info[i].company_name[0] != '\0') { |
643 if (pos-- == 0) |
642 if (pos-- == 0) return i; |
644 return i; |
|
645 } |
643 } |
646 } |
644 } |
647 |
645 |
648 return 0; |
646 return 0; |
649 } |
647 } |
650 |
648 |
651 static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) |
649 static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) |
652 { |
650 { |
653 switch(e->event) { |
651 switch (e->event) { |
654 case WE_PAINT: { |
652 case WE_PAINT: { |
655 int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos; |
653 int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos; |
656 |
654 |
657 w->disabled_state = (_selected_company_item == -1) ? 1 << 7 : 0; |
655 w->disabled_state = (_selected_company_item == -1) ? 1 << 7 : 0; |
658 |
656 |
676 bool income = false; |
674 bool income = false; |
677 if (_selected_company_item == index) |
675 if (_selected_company_item == index) |
678 GfxFillRect(11, y - 1, 154, y + 10, 155); // show highlighted item with a different colour |
676 GfxFillRect(11, y - 1, 154, y + 10, 155); // show highlighted item with a different colour |
679 |
677 |
680 DoDrawString(_network_player_info[index].company_name, 13, y, 2); |
678 DoDrawString(_network_player_info[index].company_name, 13, y, 2); |
681 if(_network_player_info[index].use_password != 0) |
679 if (_network_player_info[index].use_password != 0) |
682 DrawSprite(SPR_LOCK, 135, y); |
680 DrawSprite(SPR_LOCK, 135, y); |
683 |
681 |
684 /* If the company's income was positive puts a green dot else a red dot */ |
682 /* If the company's income was positive puts a green dot else a red dot */ |
685 if ((_network_player_info[index].income) >= 0) |
683 if ((_network_player_info[index].income) >= 0) |
686 income = true; |
684 income = true; |
687 DrawSprite(SPR_BLOT | (income ? PALETTE_TO_GREEN : PALETTE_TO_RED), 145, y); |
685 DrawSprite(SPR_BLOT | (income ? PALETTE_TO_GREEN : PALETTE_TO_RED), 145, y); |
688 |
686 |
689 pos++; |
687 pos++; |
690 y += NET_PRC__SIZE_OF_ROW_COMPANY; |
688 y += NET_PRC__SIZE_OF_ROW_COMPANY; |
691 if (pos >= w->vscroll.cap) |
689 if (pos >= w->vscroll.cap) break; |
692 break; |
|
693 } |
690 } |
694 |
691 |
695 // draw info about selected company |
692 // draw info about selected company |
696 DrawStringMultiCenter(290, 48, STR_NETWORK_COMPANY_INFO, 0); |
693 DrawStringMultiCenter(290, 48, STR_NETWORK_COMPANY_INFO, 0); |
697 if (_selected_company_item != -1) { // if a company is selected... |
694 if (_selected_company_item != -1) { // if a company is selected... |
1085 } |
1082 } |
1086 |
1083 |
1087 // Main handle for the popup |
1084 // Main handle for the popup |
1088 static void ClientListPopupWndProc(Window *w, WindowEvent *e) |
1085 static void ClientListPopupWndProc(Window *w, WindowEvent *e) |
1089 { |
1086 { |
1090 switch(e->event) { |
1087 switch (e->event) { |
1091 case WE_PAINT: { |
1088 case WE_PAINT: { |
1092 int i, y, sel; |
1089 int i, y, sel; |
1093 byte colour; |
1090 byte colour; |
1094 DrawWindowWidgets(w); |
1091 DrawWindowWidgets(w); |
1095 |
1092 |
1139 } |
1136 } |
1140 |
1137 |
1141 // Main handle for clientlist |
1138 // Main handle for clientlist |
1142 static void ClientListWndProc(Window *w, WindowEvent *e) |
1139 static void ClientListWndProc(Window *w, WindowEvent *e) |
1143 { |
1140 { |
1144 switch(e->event) { |
1141 switch (e->event) { |
1145 case WE_PAINT: { |
1142 case WE_PAINT: { |
1146 NetworkClientInfo *ci; |
1143 NetworkClientInfo *ci; |
1147 int y, i = 0; |
1144 int y, i = 0; |
1148 byte colour; |
1145 byte colour; |
1149 |
1146 |
1164 } else |
1161 } else |
1165 colour = 0x10; |
1162 colour = 0x10; |
1166 |
1163 |
1167 if (ci->client_index == NETWORK_SERVER_INDEX) { |
1164 if (ci->client_index == NETWORK_SERVER_INDEX) { |
1168 DrawString(4, y, STR_NETWORK_SERVER, colour); |
1165 DrawString(4, y, STR_NETWORK_SERVER, colour); |
1169 } else |
1166 } else { |
1170 DrawString(4, y, STR_NETWORK_CLIENT, colour); |
1167 DrawString(4, y, STR_NETWORK_CLIENT, colour); |
1168 } |
|
1171 |
1169 |
1172 // Filter out spectators |
1170 // Filter out spectators |
1173 if (ci->client_playas > 0 && ci->client_playas <= MAX_PLAYERS) |
1171 if (ci->client_playas > 0 && ci->client_playas <= MAX_PLAYERS) |
1174 DrawPlayerIcon(ci->client_playas - 1, 44, y + 1); |
1172 DrawPlayerIcon(ci->client_playas - 1, 44, y + 1); |
1175 |
1173 |
1218 } |
1216 } |
1219 |
1217 |
1220 void ShowClientList(void) |
1218 void ShowClientList(void) |
1221 { |
1219 { |
1222 Window *w = AllocateWindowDescFront(&_client_list_desc, 0); |
1220 Window *w = AllocateWindowDescFront(&_client_list_desc, 0); |
1223 if (w) |
1221 if (w != NULL) w->window_number = 0; |
1224 w->window_number = 0; |
|
1225 } |
1222 } |
1226 |
1223 |
1227 extern void SwitchMode(int new_mode); |
1224 extern void SwitchMode(int new_mode); |
1228 |
1225 |
1229 static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) |
1226 static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) |
1230 { |
1227 { |
1231 switch(e->event) { |
1228 switch (e->event) { |
1232 case WE_PAINT: { |
1229 case WE_PAINT: { |
1233 uint8 progress; // used for progress bar |
1230 uint8 progress; // used for progress bar |
1234 DrawWindowWidgets(w); |
1231 DrawWindowWidgets(w); |
1235 |
1232 |
1236 DrawStringCentered(125, 35, STR_NETWORK_CONNECTING_1 + _network_join_status, 14); |
1233 DrawStringCentered(125, 35, STR_NETWORK_CONNECTING_1 + _network_join_status, 14); |
1256 /* Draw nice progress bar :) */ |
1253 /* Draw nice progress bar :) */ |
1257 DrawFrameRect(20, 18, (int)((w->width - 20) * progress / 100), 28, 10, 0); |
1254 DrawFrameRect(20, 18, (int)((w->width - 20) * progress / 100), 28, 10, 0); |
1258 } break; |
1255 } break; |
1259 |
1256 |
1260 case WE_CLICK: |
1257 case WE_CLICK: |
1261 switch(e->click.widget) { |
1258 switch (e->click.widget) { |
1262 case 0: case 3: /* Close 'X' | Disconnect button */ |
1259 case 0: /* Close 'X' */ |
1263 NetworkDisconnect(); |
1260 case 3: /* Disconnect button */ |
1264 DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); |
1261 NetworkDisconnect(); |
1265 SwitchMode(SM_MENU); |
1262 DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); |
1266 ShowNetworkGameWindow(); |
1263 SwitchMode(SM_MENU); |
1267 break; |
1264 ShowNetworkGameWindow(); |
1265 break; |
|
1268 } |
1266 } |
1269 break; |
1267 break; |
1270 |
1268 |
1271 } |
1269 } |
1272 } |
1270 } |
1309 #define MAX_QUERYSTR_LEN 64 |
1307 #define MAX_QUERYSTR_LEN 64 |
1310 |
1308 |
1311 static void ChatWindowWndProc(Window *w, WindowEvent *e) |
1309 static void ChatWindowWndProc(Window *w, WindowEvent *e) |
1312 { |
1310 { |
1313 static bool closed = false; |
1311 static bool closed = false; |
1312 |
|
1314 switch (e->event) { |
1313 switch (e->event) { |
1315 case WE_CREATE: |
1314 case WE_CREATE: |
1316 SendWindowMessage(WC_NEWS_WINDOW, 0, WE_CREATE, w->height, 0); |
1315 SendWindowMessage(WC_NEWS_WINDOW, 0, WE_CREATE, w->height, 0); |
1317 SETBIT(_no_scroll, SCROLL_CHAT); // do not scroll the game with the arrow-keys |
1316 SETBIT(_no_scroll, SCROLL_CHAT); // do not scroll the game with the arrow-keys |
1318 closed = false; |
1317 closed = false; |
1322 DrawWindowWidgets(w); |
1321 DrawWindowWidgets(w); |
1323 DrawEditBox(w, 1); |
1322 DrawEditBox(w, 1); |
1324 break; |
1323 break; |
1325 |
1324 |
1326 case WE_CLICK: |
1325 case WE_CLICK: |
1327 switch(e->click.widget) { |
1326 switch (e->click.widget) { |
1328 case 3: DeleteWindow(w); break; // Cancel |
1327 case 3: DeleteWindow(w); break; // Cancel |
1329 case 2: // Send |
1328 case 2: // Send |
1330 press_ok:; |
1329 press_ok:; |
1331 if (strcmp(WP(w, querystr_d).text.buf, WP(w, querystr_d).text.buf + MAX_QUERYSTR_LEN) == 0) { |
1330 if (strcmp(WP(w, querystr_d).text.buf, WP(w, querystr_d).text.buf + MAX_QUERYSTR_LEN) == 0) { |
1332 DeleteWindow(w); |
1331 DeleteWindow(w); |