Rubidium
d183d8e587
Codechange: remove INVALID_STRING_ID now drop down uses spans
2024-04-28 18:47:31 +02:00
Rubidium
37a03b513f
Codechange: refactor string list dimension finding into a separate function
2024-04-28 18:47:31 +02:00
Rubidium
ad50c4f298
Codechange: inline sorter name definitions and use proper static accessor instead of (implying) this->
2024-04-28 18:47:31 +02:00
Peter 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 Nelson
f44d8fa2e4
Codechange: Remove CDECL from filter functions. ( #12578 )
...
These functions are not passed to qsort()...
2024-04-25 22:13:23 +01:00
Peter Nelson
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 Nelson
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 Nelson
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
Rubidium
c377c4740d
Codechange: replace cpp_lengthof with safe alternatives
2024-04-20 13:36:19 +02:00
Rubidium
e441033d68
Codechange: use std::array instead of C-style array for produced/accepts cargo
2024-04-20 11:29:55 +02:00
Peter Nelson
16eb17418b
Change: Use aspect ratios for some common widgets.
2024-04-19 22:11:16 +01:00
Peter Nelson
e83e2df023
Fix: Build industry window did not take width of count into account. ( #12476 )
2024-04-12 23:07:31 +01:00
Rubidium
ff27b9e76a
Codechange: use std::any_of instead of custom loop
2024-04-11 07:05:04 +02:00
Peter Nelson
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 Nelson
144bcbbaf1
Fix: Use clear() to clear std::string. ( #12471 )
2024-04-10 17:27:30 +00:00
Rubidium
883d3e7a9f
Codechange: use std::span instead of pointer + length
2024-04-09 10:11:50 +02:00
Peter Nelson
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 Nelson
995fca58a2
Codechange: Use begin/end instead of endof for some industry arrays. ( #12447 )
2024-04-07 22:01:46 +01:00
Peter Nelson
56cac21086
Codechange: Use functions to create common drop down list items.
2024-04-01 22:33:16 +01:00
Peter Nelson
f6b38e8e06
Codechange: Remove optional MakeCargo() parameters that are never changed.
...
Default values are always used, so don't need to be parameters.
2024-04-01 18:46:29 +01:00
Peter Nelson
e4fc8ef595
Codechange: Use std::span for industry cargo window instead of pointer + length.
2024-04-01 18:46:29 +01:00
Peter Nelson
d683ec0183
Codechange: Move dropdown and slider out of widgets directory. ( #12403 )
...
Also shuffle headers to place widget includes near end.
This leaves the widgets directory solely for defining Widget IDs.
2024-03-31 19:37:16 +01:00
Peter Nelson
e16b982b6a
Codechange: Use iteration when dealing with all HouseSpecs.
2024-03-28 23:23:00 +01:00
Peter Nelson
4751179dc5
Codefix: Remove unused class member and extraneous spaces. ( #12378 )
2024-03-25 21:35:31 +00:00
Peter Nelson
97c1738541
Fix #12368 : Incorrect offset for click position within industry chain window. ( #12370 )
2024-03-24 18:35:33 +00:00
Patric Stout
a3cfd23cf9
Codechange: rename byte to uint8_t ( #12308 )
2024-03-16 23:59:32 +01:00
Rubidium
86cb184eb4
Codechange: use std::source_location over __FILE__ and __LINE__ for WindowDesc
2024-03-10 10:14:20 +01:00
Rubidium
bab5a8a787
Codechange: use std::source_location over __FILE__ and __LINE__ for Backup
2024-03-10 10:14:20 +01:00
Peter Nelson
d4f0f0e2c5
Codechange: Use `GetVisibleRangeIterators()` in more places. ( #12190 )
...
This replaces more first/last index calculation, along with indexed array/vector access, with iterator access instead.
2024-02-27 20:10:06 +00:00
Peter Nelson
481fa7dbb5
Change: Show cargo icons on Industry View window. ( #12071 )
2024-02-12 00:50:58 +00:00
Peter Nelson
d6f34a21e8
Codefix: Incorrect storage type in cargo field of industry cargo chains window. ( #12051 )
...
`supp_cargoes` and `cust_cargoes` actually contains a column index, however this index is always stored at the indexed position...
Replace with a bitmask instead, which stores if the column indices are linked.
2024-02-11 23:05:29 +00:00
frosch
b1718478c8
Codechange: Replace old non-standard attributes with C++17/20 standard attributes.
2024-02-02 22:29:28 +01:00
Peter Nelson
2e6c6b719f
Change: Link houses production on industry chain graph by TPE_PASSENGERS or TPE_MAIL cargo.
2024-02-02 20:37:49 +00:00
Tyler Trahan
41f2eed425
Feature: Settings to scale cargo production of towns and industries ( #10606 )
2024-01-30 15:11:46 -05:00
frosch
68c64d2511
Codechange: Remove TKM string codes by duplicating strings.
2024-01-28 14:44:24 +01:00
Peter Nelson
7737aa6640
Codechange: Make all NWidgetPart arrays constexpr.
...
This ensures that the arrays are not created at runtime and prevents using non-constexpr values.
2024-01-16 21:57:05 +00:00
Peter Nelson
400ae65ff2
Codechange: Redefine some cargo-related values in terms of CargoID instead of CargoType.
...
Values used as special filter types are now defined as offsets from NUM_CARGO instead of confusingly reusing CARGO_NO_REFIT/CARGO_AUTO_REFIT types.
2024-01-09 18:56:05 +00:00
Peter Nelson
952d111b94
Codechange: Split CT_INVALID into CT_INVALID and INVALID_CARGO.
...
INVALID_CARGO is a CargoID and should be used for most purposes in game.
CT_INVALID is a CargoType used for defining default properties.
2024-01-09 18:56:05 +00:00
Peter Nelson
a0dfb76e34
Codechange: Replace mishmash of types for widget index with WidgetID.
...
Indices were stored as int, but often passed around as uint/uint8_t and casts.
Now they should all use WidgetID.
2023-12-30 00:23:57 +00:00
Peter Nelson
313ee13e5f
Codechange: Add Rect version of FillDrawPixelInfo().
...
This simplifies most callers as they longer have to split out a rect.
2023-12-20 09:29:28 +00:00
Finn Willard
3a42340db3
Add: Hotkey to focus industry directory filter box
...
Co-authored-by: Tyler Trahan <tyler@tylertrahan.com>
2023-12-19 11:23:37 -05:00
Peter Nelson
12bb750128
Codechange: Cargo filters no longer take an index. ( #11582 )
...
Update naming of functions to reflect that parameter is now a cargoid.
2023-12-14 01:48:45 +00:00
Peter Nelson
8186182e4c
Codechange: Set displayed plane earlier to avoid ReInit.
2023-12-10 12:01:55 +00:00
Peter Nelson
dcf730f1f6
Codechange: Optionally allow passing state to GUIList sorter function.
...
GUIList sorter functions can currently only use global state, which makes per-window-instance sorting difficult.
2023-12-04 08:24:39 +00:00
Peter Nelson
1aedea8eda
Feature: Place cargo icon on cargo filter dropdowns.
...
Reveal the pixel art.
2023-12-02 15:23:05 +00:00
Peter Nelson
6f7153bf71
Codechange: Make a generic DrawRectOutline function from DrawOutline. ( #11524 )
...
This allows drawing an outline from Rect, not just constrained to a Widget's Rect. And reduces duplication a little.
2023-11-30 18:10:07 +00:00
Peter Nelson
09d01bd015
Fix: Restore original cargo legend 'blob' dimensions. ( #11480 )
...
An off-by-one in a previous life made the 'blob' too narrow.
2023-11-21 19:51:24 +00:00
Peter Nelson
c18a1494b7
Codechange: Remove FONT_HEIGHT_... macros. ( #11481 )
...
These make it look like we're dealing with a constant, but actually each is a call to `GetCharacterHeight(...)`.
2023-11-21 19:04:24 +00:00
Peter Nelson
7cfcf65f95
Codechange: Simplify cargo filter lists, building only when required.
...
Some cargo filter lists were built in advance, and used as lookups to test which cargo type to filter.
Instead, use the Cargo ID directly as the filter parameter, and build the lists only when the drop down list is used.
2023-11-13 21:30:46 +00:00
Peter Nelson
badce415ea
Change: Add horizontal scrollbar to Industry Directory window.
...
This list could be very wide depending on industries and language.
2023-11-05 22:22:32 +00:00