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
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
16eb17418b
Change: Use aspect ratios for some common widgets.
2024-04-19 22:11:16 +01: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
2047c27445
Codechange: Move drop down list item definitions to separate header.
...
This reduces the scope of the definitions which are no longer needed to create the common lists.
2024-04-01 22:33:16 +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
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
Rubidium
e904122441
Codefix: follow coding style
2024-03-22 22:24:17 +01:00
raddari
5751da7809
Fix #7982 : Show existing coverage with unambiguous adjacent station ( #12346 )
...
When hovering a tile containing a station, show existing coverage for
that station even when adjacent to a different station.
Co-authored-by: Peter Nelson <peter@fuzzle.org>
2024-03-22 09:33:16 -04:00
Patric Stout
a3cfd23cf9
Codechange: rename byte to uint8_t ( #12308 )
2024-03-16 23:59:32 +01:00
Peter Nelson
0058ebe472
Codechange: Check cheap station-facility-filter before expensive in-use-filter. ( #12317 )
2024-03-16 19:37:32 +00:00
Rubidium
27eadc13ec
Codechange: rename TILE_ADD(XY) to TileAdd(XY)
2024-03-10 15:50:24 +01:00
Rubidium
86cb184eb4
Codechange: use std::source_location over __FILE__ and __LINE__ for WindowDesc
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
2c78146da5
Change: Limit cargo types in station cargo filter, with "More..." option to show all.
2024-02-07 17:13:37 +00:00
Peter Nelson
e517e55620
Change: Include count of stations per cargo type in station cargo filter.
...
Cargo types with no stations are shaded to make the list clearer.
2024-02-07 17:13:37 +00:00
Peter Nelson
46da56b191
Change: Replace long list of cargo filter buttons with a multi-select dropdown list.
...
As before, hold ctrl while clicking on an item to toggle selections.
2024-02-07 17:13:37 +00: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
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
7124b4eef1
Codechange: Use std::unique_ptr for all NWidgets.
2023-12-31 15:33:56 +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
b86182ab84
Codechange: Use std::map to provide indexed widget access.
...
This removes the need to determine the biggest widget index and replaces C-style memory handling.
2023-12-29 18:45:43 +00:00
Peter Nelson
58c252b81a
Cleanup: Remove unnecessary pressed button offset code.
2023-12-05 21:12:35 +00:00
Peter Nelson
e749bbefe5
Change: Show rating in station list even with no cargo waiting. ( #11540 )
...
e745bd9
(r21144) changed the filter from cargo waiting to rating, which makes the station list display appear inconsistent with the cargo filter selection.
2023-12-04 18:16:09 +00:00
Peter Nelson
07a8bd21e4
Fix: Make station list filters use per-window state instead of global state.
...
Changing filters with multiple windows open would have unexpected effects leading to inconsistent state.
Now state is loaded and saved when the window is opened and closed, so state is still persistent.
2023-12-04 08:24:39 +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
9122b4eb47
Codechange: SetMinimalTextLines(1, 0) is implied for widgets with text. ( #11536 )
2023-12-03 22:42:50 +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
18fb8e153f
Codechange: Add __FILE__/__LINE__ of WindowDesc to WindowDesc.
...
This is to allow unit-tests to produce more useful output.
2023-11-02 22:25:01 +00:00
Peter Nelson
9602de474d
Codechange: Use iterators and/or range-for on cargo related loops.
2023-10-19 17:03:25 +01:00
Peter Nelson
f379b31e28
Add: data parameter in Window::Close method.
...
This allows passing data when closing a window, e.g. to indicate how it was closed.
2023-10-13 20:47:28 +01:00
Peter Nelson
69ee38bd43
Codechange: Use GetAcceptanceMask() instead of duplicating it.
2023-09-21 18:29:02 +01:00
frosch
b5885295f0
Codechange: Use parameters, which should be used.
2023-09-19 22:49:59 +02:00
frosch
b6c8f301be
Codechange: Silence warnings about intentionally unused parameters.
2023-09-19 22:49:59 +02:00
Patric Stout
30172fc037
Codechange: cleanup CargoPacket in terms of variable/function names ( #11278 )
...
Over the years, things got reused and changed, making the current
names somewhat unclear in what they actually mean and do.
2023-09-09 23:21:21 +02:00
Jonathan G Rennison
0316940fe8
Fix: Inaccurate waiting cargo total in station window when using cargodist ( #11213 )
...
For stations with many flows and/or small cargo packets,
due to accumulated inaccuracies in DivideApprox.
The displayed total should match GoodsEntry::TotalCount().
2023-09-06 21:36:26 +02:00
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.
2023-09-04 10:20:45 +01:00
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
2023-07-19 19:30:14 +02:00
Jonathan G Rennison
d7bf6b2c07
Feature: Highlight waypoint tiles when adjacent or distant joining
2023-06-04 16:54:48 +01:00
Peter Nelson
56085be9bd
Codechange: Move includes for common STL headers to stdafx.
2023-05-17 10:14:41 +01:00
Peter Nelson
a92755de81
Codechange: Use iterator erase pattern.
2023-05-13 19:18:01 +01:00
Peter Nelson
4a64064c57
Codechange: Make NEW_STATION an actual item in join station list.
...
Add NEW_STATION to the nearby station list to indicate that a new
station should be built. This removes special-casing for a non-existant
list item and keeps the list count and scrollbar count the same.
2023-05-13 19:18:01 +01:00
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.
2023-05-12 21:45:32 +01:00
Peter Nelson
e6740046ee
Codechange: Use range-for iteration.
2023-05-11 07:58:55 +01:00
Rubidium
68ff3fd062
Change: include fmt.h C++ headers in stdafx.h
...
This to prevent compilation issues between runs with and without precompiled
headers. Also remove the headers from the rest of the code base as they are
not needed there anymore, although they do relatively little harm.
2023-05-08 16:49:23 +02:00
Peter Nelson
d2034d9c38
Codechange: Scrollbar methods now accept size_t.
...
This clears up a lot of casts from size_t to int.
2023-05-07 20:25:44 +01:00