4 |
4 |
5 #include "stdafx.h" |
5 #include "stdafx.h" |
6 #include "openttd.h" |
6 #include "openttd.h" |
7 #include "heightmap.h" |
7 #include "heightmap.h" |
8 #include "debug.h" |
8 #include "debug.h" |
9 #include "functions.h" |
|
10 #include "landscape.h" |
9 #include "landscape.h" |
11 #include "newgrf.h" |
10 #include "newgrf.h" |
12 #include "newgrf_text.h" |
11 #include "newgrf_text.h" |
13 #include "saveload.h" |
12 #include "saveload.h" |
14 #include "strings.h" |
13 #include "tile_map.h" |
|
14 #include "gui.h" |
|
15 #include "window_gui.h" |
|
16 #include "station_gui.h" |
|
17 #include "textbuf_gui.h" |
|
18 #include "viewport_func.h" |
|
19 #include "gfx_func.h" |
|
20 #include "station.h" |
|
21 #include "command_func.h" |
|
22 #include "player_func.h" |
|
23 #include "player_base.h" |
|
24 #include "town.h" |
|
25 #include "network/network.h" |
|
26 #include "variables.h" |
|
27 #include "train.h" |
|
28 #include "tgp.h" |
|
29 #include "cargotype.h" |
|
30 #include "player_face.h" |
|
31 #include "strings_func.h" |
|
32 #include "fileio.h" |
|
33 #include "fios.h" |
|
34 #include "tile_cmd.h" |
|
35 #include "zoom_func.h" |
|
36 #include "functions.h" |
|
37 #include "window_func.h" |
|
38 #include "date_func.h" |
|
39 #include "sound_func.h" |
|
40 #include "string_func.h" |
|
41 #include "player_gui.h" |
|
42 #include "settings_type.h" |
|
43 |
15 #include "table/sprites.h" |
44 #include "table/sprites.h" |
16 #include "table/strings.h" |
45 #include "table/strings.h" |
17 #include "strings.h" |
|
18 #include "table/tree_land.h" |
46 #include "table/tree_land.h" |
19 #include "map.h" |
47 |
20 #include "window.h" |
|
21 #include "gui.h" |
|
22 #include "viewport.h" |
|
23 #include "gfx.h" |
|
24 #include "station.h" |
|
25 #include "command.h" |
|
26 #include "player.h" |
|
27 #include "town.h" |
|
28 #include "sound.h" |
|
29 #include "network/network.h" |
|
30 #include "string.h" |
|
31 #include "variables.h" |
|
32 #include "vehicle.h" |
|
33 #include "train.h" |
|
34 #include "tgp.h" |
|
35 #include "settings.h" |
|
36 #include "date.h" |
|
37 #include "cargotype.h" |
|
38 #include "player_face.h" |
|
39 #include "fileio.h" |
|
40 |
|
41 #include "fileio.h" |
|
42 #include "fios.h" |
|
43 /* Variables to display file lists */ |
48 /* Variables to display file lists */ |
44 FiosItem *_fios_list; |
49 FiosItem *_fios_list; |
45 int _saveload_mode; |
50 SaveLoadDialogMode _saveload_mode; |
46 |
51 |
47 |
52 |
48 static bool _fios_path_changed; |
53 static bool _fios_path_changed; |
49 static bool _savegame_sort_dirty; |
54 static bool _savegame_sort_dirty; |
50 |
55 |
208 * maximum length of string which fits in window -^*/ |
213 * maximum length of string which fits in window -^*/ |
209 "Original design by Chris Sawyer", |
214 "Original design by Chris Sawyer", |
210 "Original graphics by Simon Foster", |
215 "Original graphics by Simon Foster", |
211 "", |
216 "", |
212 "The OpenTTD team (in alphabetical order):", |
217 "The OpenTTD team (in alphabetical order):", |
213 " Jean-Francois Claeys (Belugas) - In training, not yet specialized", |
218 " Jean-Francois Claeys (Belugas) - GUI, newindustries and more", |
214 " Bjarni Corfitzen (Bjarni) - MacOSX port, coder", |
219 " Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles", |
215 " Matthijs Kooijman (blathijs) - Pathfinder-guru", |
220 " Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework", |
216 " Victor Fischer (Celestar) - Programming everywhere you need him to", |
221 " Loïc Guilloux (glx) - General coding", |
217 " Tamás Faragó (Darkvater) - Lead coder", |
|
218 " Loïc Guilloux (glx) - In training, not yet specialized", |
|
219 " Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)", |
222 " Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)", |
220 " Jonathan Coome (Maedhros) - High priest of the newGRF Temple", |
223 " Jonathan Coome (Maedhros) - High priest of the newGRF Temple", |
221 " Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host", |
224 " Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host", |
222 " Owen Rudge (orudge) - Forum host, OS/2 port", |
225 " Owen Rudge (orudge) - Forum host, OS/2 port", |
223 " Peter Nelson (peter1138) - Spiritual descendant from newgrf gods", |
226 " Peter Nelson (peter1138) - Spiritual descendant from newGRF gods", |
224 " Remko Bijker (Rubidium) - THE desync hunter", |
227 " Remko Bijker (Rubidium) - Lead coder and way more", |
|
228 " Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker", |
|
229 " Zdenek Sojka (SmatZ) - Bug finder and fixer", |
|
230 "", |
|
231 "Inactive Developers:", |
|
232 " Victor Fischer (Celestar) - Programming everywhere you need him to", |
|
233 " Tamás Faragó (Darkvater) - Ex-Lead coder", |
225 " Christoph Mallon (Tron) - Programmer, code correctness police", |
234 " Christoph Mallon (Tron) - Programmer, code correctness police", |
226 "", |
235 "", |
227 "Retired Developers:", |
236 "Retired Developers:", |
228 " Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)", |
237 " Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)", |
229 " Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)", |
238 " Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)", |
231 " Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)", |
240 " Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)", |
232 "", |
241 "", |
233 "Special thanks go out to:", |
242 "Special thanks go out to:", |
234 " Josef Drexler - For his great work on TTDPatch", |
243 " Josef Drexler - For his great work on TTDPatch", |
235 " Marcin Grzegorczyk - For his documentation of TTD internals", |
244 " Marcin Grzegorczyk - For his documentation of TTD internals", |
236 " Petr Baudis (pasky) - Many patches, newgrf support", |
245 " Petr Baudis (pasky) - Many patches, newGRF support", |
237 " Stefan Meißner (sign_de) - For his work on the console", |
246 " Stefan Meißner (sign_de) - For his work on the console", |
238 " Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with (and PBS)", |
247 " Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with", |
239 " Cian Duffy (MYOB) - BeOS port / manual writing", |
248 " Cian Duffy (MYOB) - BeOS port / manual writing", |
240 " Christian Rosentreter (tokai) - MorphOS / AmigaOS port", |
249 " Christian Rosentreter (tokai) - MorphOS / AmigaOS port", |
241 " Richard Kempton (richK) - additional airports, initial TGP implementation", |
250 " Richard Kempton (richK) - additional airports, initial TGP implementation", |
242 "", |
251 "", |
243 " Michael Blunck - Pre-Signals and Semaphores © 2003", |
252 " Michael Blunck - Pre-Signals and Semaphores © 2003", |
280 if (y < 50) WP(w, scroller_d).height = w->height - 40; |
289 if (y < 50) WP(w, scroller_d).height = w->height - 40; |
281 |
290 |
282 DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", TC_BLACK); |
291 DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", TC_BLACK); |
283 DrawStringCentered(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING); |
292 DrawStringCentered(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING); |
284 } break; |
293 } break; |
285 case WE_MOUSELOOP: // Timer to scroll the text and adjust the new top |
294 case WE_TICK: // Timer to scroll the text and adjust the new top |
286 if (WP(w, scroller_d).counter++ % 3 == 0) { |
295 if (--WP(w, scroller_d).counter == 0) { |
|
296 WP(w, scroller_d).counter = 5; |
287 WP(w, scroller_d).height--; |
297 WP(w, scroller_d).height--; |
288 SetWindowDirty(w); |
298 SetWindowDirty(w); |
289 } |
299 } |
290 break; |
300 break; |
291 } |
301 } |
362 break; |
372 break; |
363 |
373 |
364 case 3: case 4: case 5: case 6: |
374 case 3: case 4: case 5: case 6: |
365 case 7: case 8: case 9: case 10: |
375 case 7: case 8: case 9: case 10: |
366 case 11:case 12: case 13: case 14: |
376 case 11:case 12: case 13: case 14: |
367 if (wid - 3 >= WP(w,tree_d).count) break; |
377 if (wid - 3 >= WP(w, tree_d).count) break; |
368 |
378 |
369 if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, VHM_RECT, NULL)) |
379 if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, VHM_RECT, NULL)) |
370 _tree_to_plant = WP(w,tree_d).base + wid - 3; |
380 _tree_to_plant = WP(w, tree_d).base + wid - 3; |
371 break; |
381 break; |
372 |
382 |
373 case 15: // tree of random type. |
383 case 15: // tree of random type. |
374 if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, VHM_RECT, NULL)) |
384 if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, VHM_RECT, NULL)) |
375 _tree_to_plant = -1; |
385 _tree_to_plant = -1; |
770 bool first = true; |
780 bool first = true; |
771 |
781 |
772 b = InlineString(b, STR_000D_ACCEPTS); |
782 b = InlineString(b, STR_000D_ACCEPTS); |
773 |
783 |
774 for (CargoID i = 0; i < NUM_CARGO; i++) { |
784 for (CargoID i = 0; i < NUM_CARGO; i++) { |
775 if (b >= lastof(_userstring) - 5) break; |
785 if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode() |
776 switch (sct) { |
786 switch (sct) { |
777 case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
787 case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
778 case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
788 case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
779 case SCT_ALL: break; |
789 case SCT_ALL: break; |
780 default: NOT_REACHED(); |
790 default: NOT_REACHED(); |
793 |
803 |
794 /* If first is still true then no cargo is accepted */ |
804 /* If first is still true then no cargo is accepted */ |
795 if (first) b = InlineString(b, STR_00D0_NOTHING); |
805 if (first) b = InlineString(b, STR_00D0_NOTHING); |
796 |
806 |
797 *b = '\0'; |
807 *b = '\0'; |
|
808 |
|
809 /* Make sure we detect any buffer overflow */ |
|
810 assert(b < endof(_userstring)); |
|
811 |
798 DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); |
812 DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); |
799 } |
813 } |
800 |
814 |
801 void DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad) |
815 void DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad) |
802 { |
816 { |
1014 switch (e->we.keypress.keycode) { |
1028 switch (e->we.keypress.keycode) { |
1015 case WKC_ESC: return 2; |
1029 case WKC_ESC: return 2; |
1016 case WKC_RETURN: case WKC_NUM_ENTER: return 1; |
1030 case WKC_RETURN: case WKC_NUM_ENTER: return 1; |
1017 case (WKC_CTRL | 'V'): |
1031 case (WKC_CTRL | 'V'): |
1018 if (InsertTextBufferClipboard(&string->text)) |
1032 if (InsertTextBufferClipboard(&string->text)) |
1019 InvalidateWidget(w, wid); |
1033 w->InvalidateWidget(wid); |
1020 break; |
1034 break; |
1021 case (WKC_CTRL | 'U'): |
1035 case (WKC_CTRL | 'U'): |
1022 DeleteTextBufferAll(&string->text); |
1036 DeleteTextBufferAll(&string->text); |
1023 InvalidateWidget(w, wid); |
1037 w->InvalidateWidget(wid); |
1024 break; |
1038 break; |
1025 case WKC_BACKSPACE: case WKC_DELETE: |
1039 case WKC_BACKSPACE: case WKC_DELETE: |
1026 if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode)) |
1040 if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode)) |
1027 InvalidateWidget(w, wid); |
1041 w->InvalidateWidget(wid); |
1028 break; |
1042 break; |
1029 case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME: |
1043 case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME: |
1030 if (MoveTextBufferPos(&string->text, e->we.keypress.keycode)) |
1044 if (MoveTextBufferPos(&string->text, e->we.keypress.keycode)) |
1031 InvalidateWidget(w, wid); |
1045 w->InvalidateWidget(wid); |
1032 break; |
1046 break; |
1033 default: |
1047 default: |
1034 if (IsValidChar(e->we.keypress.key, string->afilter)) { |
1048 if (IsValidChar(e->we.keypress.key, string->afilter)) { |
1035 if (InsertTextBufferChar(&string->text, e->we.keypress.key)) { |
1049 if (InsertTextBufferChar(&string->text, e->we.keypress.key)) { |
1036 InvalidateWidget(w, wid); |
1050 w->InvalidateWidget(wid); |
1037 } |
1051 } |
1038 } else { // key wasn't caught. Continue only if standard entry specified |
1052 } else { // key wasn't caught. Continue only if standard entry specified |
1039 e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL); |
1053 e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL); |
1040 } |
1054 } |
1041 } |
1055 } |
1489 _savegame_sort_dirty = false; |
1503 _savegame_sort_dirty = false; |
1490 MakeSortedSaveGameList(); |
1504 MakeSortedSaveGameList(); |
1491 } |
1505 } |
1492 |
1506 |
1493 GfxFillRect(w->widget[7].left + 1, w->widget[7].top + 1, w->widget[7].right, w->widget[7].bottom, 0xD7); |
1507 GfxFillRect(w->widget[7].left + 1, w->widget[7].top + 1, w->widget[7].right, w->widget[7].bottom, 0xD7); |
1494 DoDrawString( |
1508 DrawSortButtonState(w, _savegame_sort_order & SORT_BY_NAME ? 2 : 3, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP); |
1495 _savegame_sort_order & SORT_DESCENDING ? DOWNARROW : UPARROW, |
|
1496 _savegame_sort_order & SORT_BY_NAME ? w->widget[2].right - 9 : w->widget[3].right - 9, |
|
1497 15, TC_BLACK |
|
1498 ); |
|
1499 |
1509 |
1500 y = w->widget[7].top + 1; |
1510 y = w->widget[7].top + 1; |
1501 for (pos = w->vscroll.pos; pos < _fios_num; pos++) { |
1511 for (pos = w->vscroll.pos; pos < _fios_num; pos++) { |
1502 const FiosItem *item = _fios_list + pos; |
1512 const FiosItem *item = _fios_list + pos; |
1503 |
1513 |
1562 ShowHeightmapLoad(); |
1572 ShowHeightmapLoad(); |
1563 } else { |
1573 } else { |
1564 /* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */ |
1574 /* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */ |
1565 ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength); |
1575 ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength); |
1566 UpdateTextBufferSize(&WP(w, querystr_d).text); |
1576 UpdateTextBufferSize(&WP(w, querystr_d).text); |
1567 InvalidateWidget(w, 10); |
1577 w->InvalidateWidget(10); |
1568 } |
1578 } |
1569 } else { |
1579 } else { |
1570 /* Changed directory, need repaint. */ |
1580 /* Changed directory, need repaint. */ |
1571 SetWindowDirty(w); |
1581 SetWindowDirty(w); |
1572 BuildFileList(); |
1582 BuildFileList(); |
1659 WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
1669 WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
1660 _save_dialog_widgets, |
1670 _save_dialog_widgets, |
1661 SaveLoadDlgWndProc, |
1671 SaveLoadDlgWndProc, |
1662 }; |
1672 }; |
1663 |
1673 |
1664 void ShowSaveLoadDialog(int mode) |
1674 /** These values are used to convert the file/operations mode into a corresponding file type. |
|
1675 * So each entry, as expressed by the related comment, is based on the enum */ |
|
1676 static const FileType _file_modetotype[] = { |
|
1677 FT_SAVEGAME, ///< used for SLD_LOAD_GAME |
|
1678 FT_SCENARIO, ///< used for SLD_LOAD_SCENARIO |
|
1679 FT_SAVEGAME, ///< used for SLD_SAVE_GAME |
|
1680 FT_SCENARIO, ///< used for SLD_SAVE_SCENARIO |
|
1681 FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP |
|
1682 FT_SAVEGAME, ///< SLD_NEW_GAME |
|
1683 }; |
|
1684 |
|
1685 void ShowSaveLoadDialog(SaveLoadDialogMode mode) |
1665 { |
1686 { |
1666 static const StringID saveload_captions[] = { |
1687 static const StringID saveload_captions[] = { |
1667 STR_4001_LOAD_GAME, |
1688 STR_4001_LOAD_GAME, |
1668 STR_0298_LOAD_SCENARIO, |
1689 STR_0298_LOAD_SCENARIO, |
1669 STR_4000_SAVE_GAME, |
1690 STR_4000_SAVE_GAME, |
1680 DeleteWindowById(WC_SAVELOAD, 0); |
1701 DeleteWindowById(WC_SAVELOAD, 0); |
1681 |
1702 |
1682 _saveload_mode = mode; |
1703 _saveload_mode = mode; |
1683 SetBit(_no_scroll, SCROLL_SAVE); |
1704 SetBit(_no_scroll, SCROLL_SAVE); |
1684 |
1705 |
|
1706 /* Use an array to define what will be the current file type being handled |
|
1707 * by current file mode */ |
|
1708 _file_to_saveload.filetype = _file_modetotype[mode]; |
1685 switch (mode) { |
1709 switch (mode) { |
1686 case SLD_SAVE_GAME: GenerateFileName(); break; |
1710 case SLD_SAVE_GAME: GenerateFileName(); break; |
1687 case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); break; |
1711 case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); break; |
1688 default: sld = &_load_dialog_desc; break; |
1712 default: sld = &_load_dialog_desc; break; |
1689 } |
1713 } |