Commit Graph
513 Commits
Author SHA1 Message Date
Peter NelsonandPeter Nelson d30e8dd1c1 Codechange: Use EnumBitSet for WindowDefaultFlags. 2025-01-30 08:40:42 +00:00
Peter NelsonandPeter Nelson efb05396a7 Codechange: Use EnumBitSet for WindowFlags. 2025-01-30 08:40:42 +00:00
Peter NelsonandGitHub afc0745aa2 Codechange: Specify underlying type for all enums excluding those exposed to scripts. (#13383) 2025-01-28 22:17:34 +00:00
Rubidiumandrubidium42 e894a5880c Codechange: rename CargoID to CargoType and amend related variables/comments 2025-01-26 18:07:10 +01:00
Rubidiumandrubidium42 4b2051a1c1 Codechange: use Textbuf::GetText() to access the buffer / hide Textbuf::buf 2025-01-19 23:01:35 +01:00
Loïc GuillouxandGitHub 46f181c8a6 Fix #13299: Merge IT_INVALID and INVALID_INDUSTRYTYPE (#13300)
* Fix #13299: Merge IT_INVALID and INVALID_INDUSTRYTYPE

* Codefix: Use NUM_INDUSTRYTILES where it's intended
2025-01-10 01:17:11 +01:00
Peter NelsonandGitHub f404f3154e Fix #13293: Incorrect GRFStringID used for industry cargo suffix text. (#13294)
Industry cargo suffix string should be mapped to 0xD000-0xD400 when the callback result is between 0x800-0xC00,
2025-01-08 19:37:38 +00:00
Rubidiumandrubidium42 ef87acc1ff Codechange: make STR_NULL the default for all widget construction functions 2025-01-03 23:25:27 +01:00
Rubidiumandrubidium42 b60101853c Codechange: add and use SetString over directly accessing widget_data 2025-01-03 12:14:55 +01:00
Rubidiumandrubidium42 9ac1bad480 Codechange: add and use GetString over directly accessing widget_data 2025-01-03 11:11:01 +01:00
Rubidiumandrubidium42 7c2668d10f Codechange: replace SetDataTip(0x0, with SetTooltip( 2025-01-02 23:28:43 +01:00
Rubidiumandrubidium42 d8d03212b8 Codechange: replace SetDataTip(SPR_ with SetSpriteTip(STR_ 2025-01-02 23:28:43 +01:00
Rubidiumandrubidium42 4bf36e3fa6 Codechange: replace SetDataTip(STR_ with SetStringTip(STR_ 2025-01-02 23:28:43 +01:00
Peter NelsonandPeter Nelson 2d372fa516 Codechange: NewGRF strings are not StringIDs.
Add GRFStringID type and use it when dealing with GRF-local string IDs.
2025-01-02 20:03:40 +00:00
Rubidiumandrubidium42 fd5f6caed4 Codechange: use explicit TileIndex constructor for tile 0 2025-01-01 08:26:54 +01:00
Peter NelsonandPeter Nelson 74087e6a2e Codechange: Use _TOOLTIP suffix for other tooltip StringIDs. 2025-01-01 02:28:08 +00:00
SamuXarickandrubidium42 10e2d1ca36 Codechange: Use Map::Iterate() to iterate tiles 2024-12-06 10:33:11 +10:00
Peter NelsonandPeter Nelson e73d6fcaac Codechange: Store grfid with entity grfprops.
This allows using the grfid without having to dereference the grffile pointer.

Uses no extra storage as it fits within otherwise wasted padding space.
2024-12-05 18:17:58 +00:00
Peter NelsonandPeter Nelson 059a4b22f7 Codechange: Use projection-based std::range::find where possible.
This simplifies matching by class members and avoids wordy lambdas.
2024-11-24 10:36:03 +00:00
Peter NelsonandPeter Nelson 876d53282e Codechange: Use std::ranges::count(_if). 2024-11-24 10:36:03 +00:00
Peter NelsonandGitHub 1f18894408 Change: Determine industry directory width only on visible rows. (#13097)
When rebuilding the industry directory list, the width of every item in the list is obtained to get the maximum width required for the horizontal scrollbar. This can take considerable time if there are a lot of industries.

Instead, calculate only for the visible rows, and grow as needed.
2024-11-24 06:51:58 +00:00
Jonathan G RennisonandGitHub 59c399c795 Codefix: Documentation comment in IndustryDirectoryWindow (#13059) 2024-11-06 18:52:30 +00:00
Anatoly EltsovandGitHub 3fca0cf3ee Feature: Industry production graph (#10541) 2024-10-31 22:35:04 +00:00
Peter NelsonandGitHub 14b986609b Add: AppendStringInPlace() to append translated string ID into an existing string. (#12969)
This allows avoiding a string copy when building strings.
2024-10-07 19:05:38 +01:00
Peter NelsonandGitHub 3cd1200668 Fix #12976: Incorrect widget rect scrolling for RTL languages. (#12978)
Industry directory, AS/GS and Textfile window did not consider RTL when applying horizontal scrolling.
2024-10-05 08:02:59 +01:00
Loïc GuillouxandGitHub 8ef3a3d463 Codefix: "maybe uninitialized" warnings for linux generic release build (#12838) 2024-07-02 11:04:07 +02:00
Rubidiumandrubidium42 14200212b7 Codechange: use std::optional<std::string> over char * for text query results 2024-06-29 16:33:16 +02:00
Steve Goldmanandrubidium42 a23ff227e7 Add: Industry window zoom with mouse wheel 2024-06-25 20:48:07 +02:00
Peter NelsonandGitHub e802c1a97f Add: Show count of towns and industries in their directory window captions. (#12800)
These windows now show "(<visible> of <total>)" in the caption.
2024-06-23 17:55:37 +01:00
Peter NelsonandGitHub 91fd082e93 Fix: Apply widget's internal padding to scrollbar capacity/position. (#12801)
For non-WWT_MATRIX widgets, scrollbars need to take account of the internal padding used for the widget.

This is not normally noticeable as framerect padding is only 2 extra pixels
2024-06-22 15:42:13 +00:00
Peter NelsonandGitHub 55314513ce Codechange: Pass NWidgetParts as span instead of begin/end pointers. (#12779) 2024-06-12 23:08:35 +01:00
Peter NelsonandGitHub 4cf6d1dd79 Codechange: Pass WindowDesc by reference instead of pointer. (#12771)
WindowDesc as passed to Windows is not optional so don't allow to it to be nullptr.
2024-06-11 08:58:03 +01:00
Rubidiumandrubidium42 d183d8e587 Codechange: remove INVALID_STRING_ID now drop down uses spans 2024-04-28 18:47:31 +02:00
Rubidiumandrubidium42 37a03b513f Codechange: refactor string list dimension finding into a separate function 2024-04-28 18:47:31 +02:00
Rubidiumandrubidium42 ad50c4f298 Codechange: inline sorter name definitions and use proper static accessor instead of (implying) this-> 2024-04-28 18:47:31 +02:00
Peter NelsonandPeter Nelson 33aedc43a5 Codechange: Shrink GUIList vectors less often, reserve before use.
After sorting and filter lists for GUI, we often shirnk them to reduce size. However this has very little benefit:

1) The memory has already been allocated, so it doesn't prevent that memory being required.
2) It causes a new allocation and copy when the vector is shrunk, actually using more memory.
3) The list is in window state, so the lifetime is only while the window is open.
4) When a filter is clearer, the original size will be needed again, which will cause another allocation.

In fact it is beneficial to reserve to the known maximum in most cases, so do that instead.
2024-04-27 19:25:34 +01:00
Peter NelsonandGitHub f44d8fa2e4 Codechange: Remove CDECL from filter functions. (#12578)
These functions are not passed to qsort()...
2024-04-25 22:13:23 +01:00
Peter NelsonandGitHub 0075a95278 Codefix: Make three _filter_funcs definitions distinct. (#12573)
Rename the GUIList function lists defined as the same symbol.
2024-04-25 21:01:15 +01:00
Peter NelsonandGitHub 5bc9854be2 Codechange: Make sort list function lists safer. (#12574)
GUIList has a pointer only to the start of each sort/filter func list, which has the potential for UB as it is unable to validate that the selected sort or filter type is in range.

Use a std::span instead and check if the selected type is in range before using it.
2024-04-25 21:00:49 +01:00
Peter NelsonandGitHub 959ced71bb Codechange: Add constants for original input/output cargo counts. (#12548)
This replaces some magic 3s and 2s.
2024-04-20 20:50:48 +01:00
Rubidiumandrubidium42 c377c4740d Codechange: replace cpp_lengthof with safe alternatives 2024-04-20 13:36:19 +02:00
Rubidiumandrubidium42 e441033d68 Codechange: use std::array instead of C-style array for produced/accepts cargo 2024-04-20 11:29:55 +02:00
Peter NelsonandPeter Nelson 16eb17418b Change: Use aspect ratios for some common widgets. 2024-04-19 22:11:16 +01:00
Peter NelsonandGitHub e83e2df023 Fix: Build industry window did not take width of count into account. (#12476) 2024-04-12 23:07:31 +01:00
Rubidiumandrubidium42 ff27b9e76a Codechange: use std::any_of instead of custom loop 2024-04-11 07:05:04 +02:00
Peter NelsonandGitHub a42aa1a086 Codechange: Remove cargo_suffix C-array from GetIndustryString. (#12472)
The information is pushed onto a vector, so string ownership can be moved there instead of using a pointer into to the CargoSuffix array.
2024-04-10 21:32:21 +01:00
Peter NelsonandGitHub 144bcbbaf1 Fix: Use clear() to clear std::string. (#12471) 2024-04-10 17:27:30 +00:00
Rubidiumandrubidium42 883d3e7a9f Codechange: use std::span instead of pointer + length 2024-04-09 10:11:50 +02:00
Peter NelsonandGitHub de4e00c93f Codechange: Pass by reference to UpdateWidgetSize. (#12457)
These parameters are always provided and not optional.
2024-04-09 08:34:45 +01:00
Peter NelsonandGitHub 995fca58a2 Codechange: Use begin/end instead of endof for some industry arrays. (#12447) 2024-04-07 22:01:46 +01:00