equal
deleted
inserted
replaced
275 /* If the last text has scrolled start anew from the start */ |
275 /* If the last text has scrolled start anew from the start */ |
276 if (y < 50) WP(w, scroller_d).height = w->Height() - 40; |
276 if (y < 50) WP(w, scroller_d).height = w->Height() - 40; |
277 |
277 |
278 DoDrawStringCentered(210, w->Height() - 25, "Website: http://www.openttd.org", 16); |
278 DoDrawStringCentered(210, w->Height() - 25, "Website: http://www.openttd.org", 16); |
279 DrawStringCentered(210, w->Height() - 15, STR_00BA_COPYRIGHT_OPENTTD, 0); |
279 DrawStringCentered(210, w->Height() - 15, STR_00BA_COPYRIGHT_OPENTTD, 0); |
280 } break; |
280 } break; |
281 case WE_MOUSELOOP: // Timer to scroll the text and adjust the new top |
281 case WE_MOUSELOOP: // Timer to scroll the text and adjust the new top |
282 if (WP(w, scroller_d).counter++ % 3 == 0) { |
282 if (WP(w, scroller_d).counter++ % 3 == 0) { |
283 WP(w, scroller_d).height--; |
283 WP(w, scroller_d).height--; |
284 w->SetDirty(); |
284 w->SetDirty(); |
285 } |
285 } |
675 break; |
675 break; |
676 } |
676 } |
677 } |
677 } |
678 |
678 |
679 /** Shows a tooltip |
679 /** Shows a tooltip |
680 * @param str String to be displayed |
680 * @param str String to be displayed |
681 * @param params (optional) up to 5 pieces of additional information that may be |
681 * @param paramcount number of params to deal with |
682 * added to a tooltip; currently only supports parameters of {NUM} (integer) */ |
682 * @param params (optional) up to 5 pieces of additional information that may be |
|
683 * added to a tooltip; currently only supports parameters of {NUM} (integer) */ |
683 void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint32 params[]) |
684 void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint32 params[]) |
684 { |
685 { |
685 char buffer[512]; |
686 char buffer[512]; |
686 BoundingRect br; |
687 BoundingRect br; |
687 BaseWindow *w; |
688 BaseWindow *w; |
822 } |
823 } |
823 |
824 |
824 /** |
825 /** |
825 * Delete a character from a textbuffer, either with 'Delete' or 'Backspace' |
826 * Delete a character from a textbuffer, either with 'Delete' or 'Backspace' |
826 * The character is delete from the position the caret is at |
827 * The character is delete from the position the caret is at |
827 * @param tb @Textbuf type to be changed |
828 * @param tb Textbuf type to be changed |
828 * @param delmode Type of deletion, either @WKC_BACKSPACE or @WKC_DELETE |
829 * @param delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE |
829 * @return Return true on successfull change of Textbuf, or false otherwise |
830 * @return Return true on successfull change of Textbuf, or false otherwise |
830 */ |
831 */ |
831 bool DeleteTextBufferChar(Textbuf *tb, int delmode) |
832 bool DeleteTextBufferChar(Textbuf *tb, int delmode) |
832 { |
833 { |
833 if (delmode == WKC_BACKSPACE && tb->caretpos != 0) { |
834 if (delmode == WKC_BACKSPACE && tb->caretpos != 0) { |
841 return false; |
842 return false; |
842 } |
843 } |
843 |
844 |
844 /** |
845 /** |
845 * Delete every character in the textbuffer |
846 * Delete every character in the textbuffer |
846 * @param tb @Textbuf buffer to be emptied |
847 * @param tb Textbuf buffer to be emptied |
847 */ |
848 */ |
848 void DeleteTextBufferAll(Textbuf *tb) |
849 void DeleteTextBufferAll(Textbuf *tb) |
849 { |
850 { |
850 memset(tb->buf, 0, tb->maxlength); |
851 memset(tb->buf, 0, tb->maxlength); |
851 tb->length = tb->width = 0; |
852 tb->length = tb->width = 0; |
854 |
855 |
855 /** |
856 /** |
856 * Insert a character to a textbuffer. If maxwidth of the Textbuf is zero, |
857 * Insert a character to a textbuffer. If maxwidth of the Textbuf is zero, |
857 * we don't care about the visual-length but only about the physical |
858 * we don't care about the visual-length but only about the physical |
858 * length of the string |
859 * length of the string |
859 * @param tb @Textbuf type to be changed |
860 * @param tb Textbuf type to be changed |
860 * @param key Character to be inserted |
861 * @param key Character to be inserted |
861 * @return Return true on successfull change of Textbuf, or false otherwise |
862 * @return Return true on successfull change of Textbuf, or false otherwise |
862 */ |
863 */ |
863 bool InsertTextBufferChar(Textbuf *tb, WChar key) |
864 bool InsertTextBufferChar(Textbuf *tb, WChar key) |
864 { |
865 { |
878 } |
879 } |
879 |
880 |
880 /** |
881 /** |
881 * Handle text navigation with arrow keys left/right. |
882 * Handle text navigation with arrow keys left/right. |
882 * This defines where the caret will blink and the next characer interaction will occur |
883 * This defines where the caret will blink and the next characer interaction will occur |
883 * @param tb @Textbuf type where navigation occurs |
884 * @param tb Textbuf type where navigation occurs |
884 * @param navmode Direction in which navigation occurs @WKC_LEFT, @WKC_RIGHT, @WKC_END, @WKC_HOME |
885 * @param navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME |
885 * @return Return true on successfull change of Textbuf, or false otherwise |
886 * @return Return true on successfull change of Textbuf, or false otherwise |
886 */ |
887 */ |
887 bool MoveTextBufferPos(Textbuf *tb, int navmode) |
888 bool MoveTextBufferPos(Textbuf *tb, int navmode) |
888 { |
889 { |
889 switch (navmode) { |
890 switch (navmode) { |
922 } |
923 } |
923 |
924 |
924 /** |
925 /** |
925 * Initialize the textbuffer by supplying it the buffer to write into |
926 * Initialize the textbuffer by supplying it the buffer to write into |
926 * and the maximum length of this buffer |
927 * and the maximum length of this buffer |
927 * @param tb @Textbuf type which is getting initialized |
928 * @param tb Textbuf type which is getting initialized |
928 * @param buf the buffer that will be holding the data for input |
929 * @param buf the buffer that will be holding the data for input |
929 * @param maxlength maximum length in characters of this buffer |
930 * @param maxlength maximum length in characters of this buffer |
930 * @param maxwidth maximum length in pixels of this buffer. If reached, buffer |
931 * @param maxwidth maximum length in pixels of this buffer. If reached, buffer |
931 * cannot grow, even if maxlength would allow because there is space. A length |
932 * cannot grow, even if maxlength would allow because there is space. A length |
932 * of zero '0' means the buffer is only restricted by maxlength */ |
933 * of zero '0' means the buffer is only restricted by maxlength */ |
938 tb->caret = true; |
939 tb->caret = true; |
939 UpdateTextBufferSize(tb); |
940 UpdateTextBufferSize(tb); |
940 } |
941 } |
941 |
942 |
942 /** |
943 /** |
943 * Update @Textbuf type with its actual physical character and screenlength |
944 * Update Textbuf type with its actual physical character and screenlength |
944 * Get the count of characters in the string as well as the width in pixels. |
945 * Get the count of characters in the string as well as the width in pixels. |
945 * Useful when copying in a larger amount of text at once |
946 * Useful when copying in a larger amount of text at once |
946 * @param tb @Textbuf type which length is calculated |
947 * @param tb Textbuf type which length is calculated |
947 */ |
948 */ |
948 void UpdateTextBufferSize(Textbuf *tb) |
949 void UpdateTextBufferSize(Textbuf *tb) |
949 { |
950 { |
950 const char *buf = tb->buf; |
951 const char *buf = tb->buf; |
951 WChar c = Utf8Consume(&buf); |
952 WChar c = Utf8Consume(&buf); |
1269 * NOTE: You cannot use BindCString as parameter for this window! |
1270 * NOTE: You cannot use BindCString as parameter for this window! |
1270 * @param caption string shown as window caption |
1271 * @param caption string shown as window caption |
1271 * @param message string that will be shown for the window |
1272 * @param message string that will be shown for the window |
1272 * @param parent pointer to parent window, if this pointer is NULL the parent becomes |
1273 * @param parent pointer to parent window, if this pointer is NULL the parent becomes |
1273 * the main window WC_MAIN_WINDOW |
1274 * the main window WC_MAIN_WINDOW |
1274 * @param x,y coordinates to show the window at |
1275 * @param callback callback function pointer to set in the window descriptor*/ |
1275 * @param yes_no_callback callback function called when window is closed through any button */ |
|
1276 void ShowQuery(StringID caption, StringID message, BaseWindow *parent, void (*callback)(BaseWindow*, bool)) |
1276 void ShowQuery(StringID caption, StringID message, BaseWindow *parent, void (*callback)(BaseWindow*, bool)) |
1277 { |
1277 { |
1278 BaseWindow *w = BaseWindow::Allocate(&_query_desc); |
1278 BaseWindow *w = BaseWindow::Allocate(&_query_desc); |
1279 if (w == NULL) return; |
1279 if (w == NULL) return; |
1280 |
1280 |
1456 y += 10; |
1456 y += 10; |
1457 if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break; |
1457 if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break; |
1458 } |
1458 } |
1459 |
1459 |
1460 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
1460 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
1461 DrawEditBox(w, &WP(w,querystr_d), 10); |
1461 DrawEditBox(w, &WP(w, querystr_d), 10); |
1462 } |
1462 } |
1463 break; |
1463 break; |
1464 } |
1464 } |
1465 |
1465 |
1466 case WE_CLICK: |
1466 case WE_CLICK: |
1549 /* This test protects against using widgets 11 and 12 which are only available |
1549 /* This test protects against using widgets 11 and 12 which are only available |
1550 * in those two saveload mode */ |
1550 * in those two saveload mode */ |
1551 if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) break; |
1551 if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) break; |
1552 |
1552 |
1553 if (w->IsWidgetLowered(11)) { // Delete button clicked |
1553 if (w->IsWidgetLowered(11)) { // Delete button clicked |
1554 if (!FiosDelete(WP(w,querystr_d).text.buf)) { |
1554 if (!FiosDelete(WP(w, querystr_d).text.buf)) { |
1555 ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0); |
1555 ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0); |
1556 } else { |
1556 } else { |
1557 BuildFileList(); |
1557 BuildFileList(); |
1558 /* Reset file name to current date on successfull delete */ |
1558 /* Reset file name to current date on successfull delete */ |
1559 if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName(); |
1559 if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName(); |
1561 |
1561 |
1562 UpdateTextBufferSize(&WP(w, querystr_d).text); |
1562 UpdateTextBufferSize(&WP(w, querystr_d).text); |
1563 w->SetDirty(); |
1563 w->SetDirty(); |
1564 } else if (w->IsWidgetLowered(12)) { // Save button clicked |
1564 } else if (w->IsWidgetLowered(12)) { // Save button clicked |
1565 _switch_mode = SM_SAVE; |
1565 _switch_mode = SM_SAVE; |
1566 FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).text.buf, sizeof(_file_to_saveload.name)); |
1566 FiosMakeSavegameName(_file_to_saveload.name, WP(w, querystr_d).text.buf, sizeof(_file_to_saveload.name)); |
1567 |
1567 |
1568 /* In the editor set up the vehicle engines correctly (date might have changed) */ |
1568 /* In the editor set up the vehicle engines correctly (date might have changed) */ |
1569 if (_game_mode == GM_EDITOR) StartupEngines(); |
1569 if (_game_mode == GM_EDITOR) StartupEngines(); |
1570 } |
1570 } |
1571 break; |
1571 break; |
1721 return _local_player; |
1721 return _local_player; |
1722 } |
1722 } |
1723 |
1723 |
1724 /** |
1724 /** |
1725 * @param p1 -1 or +1 (down/up) |
1725 * @param p1 -1 or +1 (down/up) |
|
1726 * @param p2 unused |
1726 */ |
1727 */ |
1727 static int32 ClickChangeClimateCheat(int32 p1, int32 p2) |
1728 static int32 ClickChangeClimateCheat(int32 p1, int32 p2) |
1728 { |
1729 { |
1729 if (p1 == -1) p1 = 3; |
1730 if (p1 == -1) p1 = 3; |
1730 if (p1 == 4) p1 = 0; |
1731 if (p1 == 4) p1 = 0; |
1734 } |
1735 } |
1735 |
1736 |
1736 extern void EnginesMonthlyLoop(); |
1737 extern void EnginesMonthlyLoop(); |
1737 |
1738 |
1738 /** |
1739 /** |
|
1740 * @param p1 unused |
1739 * @param p2 1 (increase) or -1 (decrease) |
1741 * @param p2 1 (increase) or -1 (decrease) |
1740 */ |
1742 */ |
1741 static int32 ClickChangeDateCheat(int32 p1, int32 p2) |
1743 static int32 ClickChangeDateCheat(int32 p1, int32 p2) |
1742 { |
1744 { |
1743 YearMonthDay ymd; |
1745 YearMonthDay ymd; |