97 case WE_CREATE: /* focus input box */ |
97 case WE_CREATE: /* focus input box */ |
98 _selected_field = 3; |
98 _selected_field = 3; |
99 _selected_item = NULL; |
99 _selected_item = NULL; |
100 break; |
100 break; |
101 case WE_PAINT: { |
101 case WE_PAINT: { |
|
102 NetworkGameList *sel = _selected_item; |
|
103 |
102 w->disabled_state = 0; |
104 w->disabled_state = 0; |
103 |
105 |
104 if (_selected_item == NULL) { |
106 if (sel == NULL) { |
105 SETBIT(w->disabled_state, 17); SETBIT(w->disabled_state, 18); |
107 SETBIT(w->disabled_state, 17); SETBIT(w->disabled_state, 18); |
106 } else if (!_selected_item->online) { |
108 } else if (!sel->online) { |
107 SETBIT(w->disabled_state, 17); // Server offline, join button disabled |
109 SETBIT(w->disabled_state, 17); // Server offline, join button disabled |
108 } else if (_selected_item->info.clients_on == _selected_item->info.clients_max) { |
110 } else if (sel->info.clients_on == sel->info.clients_max) { |
109 SETBIT(w->disabled_state, 17); // Server full, join button disabled |
111 SETBIT(w->disabled_state, 17); // Server full, join button disabled |
110 |
112 |
111 // revisions don't match, check if server has no revision; then allow connection |
113 // revisions don't match, check if server has no revision; then allow connection |
112 } else if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) { |
114 } else if (strncmp(sel->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) { |
113 if (strncmp(_selected_item->info.server_revision, NOREV_STRING, sizeof(_selected_item->info.server_revision)) != 0) |
115 if (strncmp(sel->info.server_revision, NOREV_STRING, sizeof(sel->info.server_revision)) != 0) |
114 SETBIT(w->disabled_state, 17); // Revision mismatch, join button disabled |
116 SETBIT(w->disabled_state, 17); // Revision mismatch, join button disabled |
115 } |
117 } |
116 |
118 |
117 SetDParam(0, 0x00); |
119 SetDParam(0, 0x00); |
118 SetDParam(7, _lan_internet_types_dropdown[_network_lan_internet]); |
120 SetDParam(7, _lan_internet_types_dropdown[_network_lan_internet]); |
137 pos--; |
139 pos--; |
138 cur_item = cur_item->next; |
140 cur_item = cur_item->next; |
139 } |
141 } |
140 |
142 |
141 while (cur_item != NULL) { |
143 while (cur_item != NULL) { |
142 bool compatible = (strncmp(cur_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) == 0); |
144 bool compatible = |
143 if (strncmp(cur_item->info.server_revision, NOREV_STRING, sizeof(cur_item->info.server_revision)) == 0) |
145 !strncmp(cur_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) || |
144 compatible = true; |
146 !strncmp(cur_item->info.server_revision, NOREV_STRING, sizeof(cur_item->info.server_revision)); |
145 |
147 |
146 if (cur_item == _selected_item) |
148 if (cur_item == sel) |
147 GfxFillRect(11, y - 2, 218, y + 9, 10); // show highlighted item with a different colour |
149 GfxFillRect(11, y - 2, 218, y + 9, 10); // show highlighted item with a different colour |
148 |
150 |
149 snprintf(servername, sizeof(servername), "%s", cur_item->info.server_name); |
151 snprintf(servername, sizeof(servername), "%s", cur_item->info.server_name); |
150 NetworkTruncateString(servername, 110); |
152 NetworkTruncateString(servername, 110); |
151 DoDrawString(servername, 15, y, 16); // server name |
153 DoDrawString(servername, 15, y, 16); // server name |
174 } |
176 } |
175 } |
177 } |
176 |
178 |
177 // right menu |
179 // right menu |
178 GfxFillRect(252, 23, 478, 65, 157); |
180 GfxFillRect(252, 23, 478, 65, 157); |
179 if (_selected_item == NULL) { |
181 if (sel == NULL) { |
180 DrawStringMultiCenter(365, 40, STR_NETWORK_GAME_INFO, 0); |
182 DrawStringMultiCenter(365, 40, STR_NETWORK_GAME_INFO, 0); |
181 } else if (!_selected_item->online) { |
183 } else if (!sel->online) { |
182 SetDParamStr(0, _selected_item->info.server_name); |
184 SetDParamStr(0, sel->info.server_name); |
183 DrawStringMultiCenter(365, 42, STR_ORANGE, 2); // game name |
185 DrawStringMultiCenter(365, 42, STR_ORANGE, 2); // game name |
184 |
186 |
185 DrawStringMultiCenter(365, 110, STR_NETWORK_SERVER_OFFLINE, 2); // server offline |
187 DrawStringMultiCenter(365, 110, STR_NETWORK_SERVER_OFFLINE, 2); // server offline |
186 } else { // show game info |
188 } else { // show game info |
187 uint16 y = 70; |
189 uint16 y = 70; |
188 |
190 |
189 DrawStringMultiCenter(365, 30, STR_NETWORK_GAME_INFO, 0); |
191 DrawStringMultiCenter(365, 30, STR_NETWORK_GAME_INFO, 0); |
190 |
192 |
191 |
193 |
192 SetDParamStr(0, _selected_item->info.server_name); |
194 SetDParamStr(0, sel->info.server_name); |
193 DrawStringMultiCenter(365, 42, STR_ORANGE, 2); // game name |
195 DrawStringMultiCenter(365, 42, STR_ORANGE, 2); // game name |
194 |
196 |
195 SetDParamStr(0, _selected_item->info.map_name); |
197 SetDParamStr(0, sel->info.map_name); |
196 DrawStringMultiCenter(365, 54, STR_02BD, 2); // map name |
198 DrawStringMultiCenter(365, 54, STR_02BD, 2); // map name |
197 |
199 |
198 SetDParam(0, _selected_item->info.clients_on); |
200 SetDParam(0, sel->info.clients_on); |
199 SetDParam(1, _selected_item->info.clients_max); |
201 SetDParam(1, sel->info.clients_max); |
200 DrawString(260, y, STR_NETWORK_CLIENTS, 2); // clients on the server / maximum slots |
202 DrawString(260, y, STR_NETWORK_CLIENTS, 2); // clients on the server / maximum slots |
201 y+=10; |
203 y+=10; |
202 |
204 |
203 SetDParam(0, STR_NETWORK_LANG_ANY+_selected_item->info.server_lang); |
205 if (sel->info.server_lang < NETWORK_NUM_LANGUAGES) { |
204 DrawString(260, y, STR_NETWORK_LANGUAGE, 2); // server language |
206 SetDParam(0, STR_NETWORK_LANG_ANY+sel->info.server_lang); |
|
207 DrawString(260, y, STR_NETWORK_LANGUAGE, 2); // server language |
|
208 } |
205 y+=10; |
209 y+=10; |
206 |
210 |
207 SetDParam(0, STR_TEMPERATE_LANDSCAPE+_selected_item->info.map_set); |
211 if (sel->info.map_set < NUM_LANDSCAPE ) { |
208 DrawString(260, y, STR_NETWORK_TILESET, 2); // tileset |
212 SetDParam(0, STR_TEMPERATE_LANDSCAPE+sel->info.map_set); |
|
213 DrawString(260, y, STR_NETWORK_TILESET, 2); // tileset |
|
214 } |
209 y+=10; |
215 y+=10; |
210 |
216 |
211 SetDParam(0, _selected_item->info.map_width); |
217 SetDParam(0, sel->info.map_width); |
212 SetDParam(1, _selected_item->info.map_height); |
218 SetDParam(1, sel->info.map_height); |
213 DrawString(260, y, STR_NETWORK_MAP_SIZE, 2); // map size |
219 DrawString(260, y, STR_NETWORK_MAP_SIZE, 2); // map size |
214 y+=10; |
220 y+=10; |
215 |
221 |
216 SetDParamStr(0, _selected_item->info.server_revision); |
222 SetDParamStr(0, sel->info.server_revision); |
217 DrawString(260, y, STR_NETWORK_SERVER_VERSION, 2); // server version |
223 DrawString(260, y, STR_NETWORK_SERVER_VERSION, 2); // server version |
218 y+=10; |
224 y+=10; |
219 |
225 |
220 SetDParamStr(0, _selected_item->info.hostname); |
226 SetDParamStr(0, sel->info.hostname); |
221 SetDParam(1, _selected_item->port); |
227 SetDParam(1, sel->port); |
222 DrawString(260, y, STR_NETWORK_SERVER_ADDRESS, 2); // server address |
228 DrawString(260, y, STR_NETWORK_SERVER_ADDRESS, 2); // server address |
223 y+=10; |
229 y+=10; |
224 |
230 |
225 SetDParam(0, _selected_item->info.start_date); |
231 SetDParam(0, sel->info.start_date); |
226 DrawString(260, y, STR_NETWORK_START_DATE, 2); // start date |
232 DrawString(260, y, STR_NETWORK_START_DATE, 2); // start date |
227 y+=10; |
233 y+=10; |
228 |
234 |
229 SetDParam(0, _selected_item->info.game_date); |
235 SetDParam(0, sel->info.game_date); |
230 DrawString(260, y, STR_NETWORK_CURRENT_DATE, 2); // current date |
236 DrawString(260, y, STR_NETWORK_CURRENT_DATE, 2); // current date |
231 y+=10; |
237 y+=10; |
232 |
238 |
233 y+=2; |
239 y+=2; |
234 |
240 |
235 if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) { |
241 if (strncmp(sel->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) { |
236 if (strncmp(_selected_item->info.server_revision, NOREV_STRING, sizeof(_selected_item->info.server_revision)) != 0) |
242 if (strncmp(sel->info.server_revision, NOREV_STRING, sizeof(sel->info.server_revision)) != 0) |
237 DrawStringMultiCenter(365, y, STR_NETWORK_VERSION_MISMATCH, 2); // server mismatch |
243 DrawStringMultiCenter(365, y, STR_NETWORK_VERSION_MISMATCH, 2); // server mismatch |
238 } else if (_selected_item->info.clients_on == _selected_item->info.clients_max) { |
244 } else if (sel->info.clients_on == sel->info.clients_max) { |
239 // Show: server full, when clients_on == clients_max |
245 // Show: server full, when clients_on == clients_max |
240 DrawStringMultiCenter(365, y, STR_NETWORK_SERVER_FULL, 2); // server full |
246 DrawStringMultiCenter(365, y, STR_NETWORK_SERVER_FULL, 2); // server full |
241 } else if (_selected_item->info.use_password) |
247 } else if (sel->info.use_password) |
242 DrawStringMultiCenter(365, y, STR_NETWORK_PASSWORD, 2); // password warning |
248 DrawStringMultiCenter(365, y, STR_NETWORK_PASSWORD, 2); // password warning |
243 |
249 |
244 y+=10; |
250 y+=10; |
245 } |
251 } |
246 } break; |
252 } break; |