Commit Graph

448 Commits (41f2eed4258546ba4cbc4870d72db1fc5bac0cc6)

Author SHA1 Message Date
Tyler Trahan 41f2eed425
Feature: Settings to scale cargo production of towns and industries (#10606) 4 months ago
frosch 68c64d2511 Codechange: Remove TKM string codes by duplicating strings. 4 months ago
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.
5 months ago
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.
5 months ago
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.
5 months ago
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.
5 months ago
Peter Nelson 313ee13e5f Codechange: Add Rect version of FillDrawPixelInfo().
This simplifies most callers as they longer have to split out a rect.
6 months ago
Finn Willard 3a42340db3 Add: Hotkey to focus industry directory filter box
Co-authored-by: Tyler Trahan <tyler@tylertrahan.com>
6 months ago
Peter Nelson 12bb750128
Codechange: Cargo filters no longer take an index. (#11582)
Update naming of functions to reflect that parameter is now a cargoid.
6 months ago
Peter Nelson 8186182e4c Codechange: Set displayed plane earlier to avoid ReInit. 6 months ago
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.
6 months ago
Peter Nelson 1aedea8eda Feature: Place cargo icon on cargo filter dropdowns.
Reveal the pixel art.
6 months ago
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.
6 months ago
Peter Nelson 09d01bd015
Fix: Restore original cargo legend 'blob' dimensions. (#11480)
An off-by-one in a previous life made the 'blob' too narrow.
7 months ago
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(...)`.
7 months ago
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.
7 months ago
Peter Nelson badce415ea Change: Add horizontal scrollbar to Industry Directory window.
This list could be very wide depending on industries and language.
7 months ago
Peter Nelson 8ff6562b2f Codechange: Reduce variable scope. 7 months ago
Peter Nelson 6b9dc8cfcf Codechange: Don't filter industry list by cargo type every 3-sec refresh.
The 3-sec refresh is to update the list sorting. The filter only needs to
be applied once rebuilding the list.
7 months ago
Peter Nelson 4033750968 Codechange: Remove redundant NWID_VERTICAL in Industry Directory layout. 7 months ago
Peter Nelson 18fb8e153f Codechange: Add __FILE__/__LINE__ of WindowDesc to WindowDesc.
This is to allow unit-tests to produce more useful output.
7 months ago
Peter Nelson ff5e8bb9a3 Fix #11413: Incorrect sorting by industry production.
Error caused by single character mistake. However this algorithm was inefficent if a filter was specified, and clearly the flow was error-prone.

Now using separately-scoped loops to avoid similar.
7 months ago
Rubidium c9276c2959 Codechange: replace x.size() == 0 with x.empty() 8 months ago
Peter Nelson fd6f1e844a
Codechange: Avoid emplace_back(new()) into a unique_ptr. (#11384)
This could theoretically leave an unmanaged pointer in certain circumstances, and directly using
make_unique shows intent.
8 months ago
Peter Nelson e4f94747f3 Codechange: Use comparator struct to sort cargo ID by predefined sort order.
This allows reuse of the comparator where a typename is used instead.
8 months ago
Peter Nelson 9602de474d Codechange: Use iterators and/or range-for on cargo related loops. 8 months ago
PeterN a0c6259e33
Codechange: Don't access cargo filter before it is initialized. (#11321)
The cargo filter list is initialized during window OnInit, but the first
build of the filtered list occurred before this.
9 months ago
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 9 months ago
Peter Nelson 6fb89b189f Fix #11315: Sort industries and cargoes by name* in industry chain window.
*Cargo types are sorted by the normal method so it's not strictly alphabetical.
9 months ago
Peter Nelson 106f29f761 Codechange: Use iteration to copy cargo list into CFT_CARGO. 9 months ago
Peter Nelson 4f8d06ff73 Codechange: Use uint8_t instead of byte for numeric values. 9 months ago
Peter Nelson 9457bda614 Codechange: Use std::fill instead of memset when initializing GUI cargo fields. 9 months ago
Peter Nelson 9d1b131c44 Codechange: Use correct constant for invalid cargo type. 9 months ago
Rubidium 7ef22af2bb Codechange: introduce and use function to raise and dirty a set of widgets when they are lowered 9 months ago
Peter Nelson e8015e497d Codechange: Use begin/end of nwidget parts of begin/length.
This simplifies processing nwidget parts as, unlike the remaining length, the pointer to the end of the list never changes. This is the same principle as we use(d) for tracking end instead of length for C-style strings.

And this removes 160~ instances of the lengthof() macro.
9 months ago
Rubidium eaae0bb5e7 Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
11 months ago
Rubidium 836541b41c Codechange: use SetDParam and CopyOutDParam for tooltips 12 months ago
Rubidium d4c2043294 Codechange: remove a number of unneeded c_str() calls 12 months ago
PeterN 584faaf064
Change: Reorganise industry accept/produce arrays. (#10853)
Use a array of struct for each cargo instead of an array for each statistic.
This makes iterating for acceptance and production much simpler.
pct_transported is now calculated when needed.
1 year ago
Peter Nelson 09408e8e46 Codechange: Add IsCargoAccepted/Produced() helpers. 1 year ago
Peter Nelson 76516d7f70 Codechange: Use IsValidCargoID/IsValidCargoType.
IsValidCargoType() is used only for unmapped IDs.
1 year ago
Peter Nelson c4ca6a0f74 Codechange: Rename IsCargo..Valid to IsValidCargo..
This better fits our naming pattern for this type of function.
1 year ago
Rubidium 63d9bb93b8 Codechange: migrate from C-style GetString to C++-style GetString 1 year ago
Peter Nelson 941dbadf9e Codechange: Add and use GetScrolledItemFromWidget to get a list item.
This function returns an iterator, either to the selected item or the
container's end.

This makes handling the result more robust as indices are not used.
1 year ago
Henry Wilson 3a03a12a9c Feature: Show the number of industries already built in the Fund New Industry window. 1 year ago
Peter Nelson d68c4bbd2f Change: Use iterator when drawing industry cargo window. 1 year ago
Peter Nelson cccf4953f7 Fix: Incorrect padding on industry cargo window. 1 year ago
Peter Nelson d2034d9c38 Codechange: Scrollbar methods now accept size_t.
This clears up a lot of casts from size_t to int.
1 year ago
PeterN 8bf62dac81
Codechange: Clean up build industry window. (#10779)
* Remove left-over code that treated an invalid list selection as 'fund
many', which is actually implemented as a separate button.
* Manual list management replaced with std::vector.
* Enabled state is only needed for the current selection.
* Selected index is not required only selected type.
1 year ago
Rubidium fb856e16c1 Codechange: replace some min/clamp constructs to ClampTo 1 year ago