Peter Nelson
b30fe0d7da
Feature: Ctrl-click to toggle favourites in build-pickers.
...
This allows ctrl-click on a type in a build-picker window to remember it
as a favourite. An new filter button to show only favourites makes it
simpler to use these types.
Favourite types are saved locally in favs.cfg, so are remembered between
games.
2024-05-11 02:12:41 +01:00
Peter Nelson
fde3b35a24
Feature: New filter to show only used types in build-pickers.
...
This filters the build-picker type lists to only show types that have
already been placed in the current game, making it simpler to get to
build matching features.
2024-05-11 02:12:41 +01:00
Peter Nelson
cdc356e7bf
Change: Unify station/waypoint/roadstop/object build-picker window code.
...
These windows now share a common code base for choosing and display class and types.
An additional text filter is added to search types by name instead of just classes.
2024-05-11 02:12:41 +01:00
Peter Nelson
d2c8b476b5
Codechange: Add functions to test if a station/roadstop class is a waypoint.
...
This is now checked by class label instead of by index.
2024-05-11 02:12:41 +01:00
Peter Nelson
cf94bd321d
Codechange: Remove redundant SetMinimalSize of preview buttons. ( #12622 )
...
These widgets are also sized in UpdateWidgetSize where the current bevel width is accounted for as well.
2024-05-05 12:38:00 +01: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
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
2a833a8968
Change: Use aspect ratio for rail station platforms/tracks buttons.
2024-04-19 22:11:16 +01:00
Peter Nelson
16eb17418b
Change: Use aspect ratios for some common widgets.
2024-04-19 22:11:16 +01:00
Rubidium
b2218e75d4
Codefix: missing space between close parenthesis and open curly brace
2024-04-16 19:28:09 +02:00
Peter Nelson
77f27e0804
Change: Expose NewGRF classes and specs as spans and simplify iteration.
...
This replaces some index-based loops with range loops.
2024-04-09 21:46:59 +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
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
Patric Stout
a3cfd23cf9
Codechange: rename byte to uint8_t ( #12308 )
2024-03-16 23:59:32 +01:00
Peter Nelson
b9ca3ead8b
Change: Use (at least) standard toolbar button size for signal selection buttons. ( #12265 )
...
Signal selection buttons could be very narrow, with a very wide spacer, depending on loaded signal types and fonts.
2024-03-11 14:19:01 +00:00
Rubidium
86cb184eb4
Codechange: use std::source_location over __FILE__ and __LINE__ for WindowDesc
2024-03-10 10:14:20 +01:00
Patric Stout
48e7dceb3c
Revert: Build signals to the next junction when dragging regardless of the Ctrl state ( #12034 )
...
This reverts commit b370ae1212
.
2024-02-09 19:34:03 +01:00
Peter Nelson
09a12f230f
Fix: Signals were incorrectly shifted by 1 pixel when selected. ( #12005 )
...
Most shifting when pressed was removed by 884b9e66
.
2024-02-05 17:55:04 +00:00
Loïc Guilloux
75015cdad2
Fix 6f6f099: Signals exist only on plain rail tiles ( #11977 )
2024-02-04 10:39:06 +01:00
frosch
b1718478c8
Codechange: Replace old non-standard attributes with C++17/20 standard attributes.
2024-02-02 22:29:28 +01:00
Tyler Trahan
f2db624e85
Change: Add dividers between signal groups ( #11897 )
2024-02-02 15:52:20 -05:00
Tyler Trahan
6f6f09910d
Fix #10118 : Cycle through current signal group, not just path signals ( #11798 )
2024-02-02 15:51:57 -05:00
dP
b370ae1212
Change: Build signals to the next junction when dragging regardless of the Ctrl state ( #9637 )
2024-01-30 19:14:26 +01:00
dP
acaceb45ba
Codechange: Make command constant names consistent with command proc ( #11920 )
2024-01-29 13:41:36 +01:00
Peter Nelson
a9a0bfffc1
Change: Disable building rail infrastructure if train build limit is zero. ( #11847 )
...
This matches the behaviour of road, ship and aircraft infrastructure.
2024-01-21 16:51:23 +00:00
Rubidium
aa5ba5bd7f
Codechange: allow certain enumeration to be added
...
Otherwise C++20 doesn't like it.
2024-01-16 23:30:23 +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
Tyler Trahan
68814bd912
Codechange: Rename SIGTYPE_NORMAL to SIGTYPE_BLOCK ( #11788 )
2024-01-15 15:27:48 -05:00
Peter Nelson
628092f133
Codechange: Use GetParentWidget to find widget's NWidgetMatrix container.
2023-12-30 22:02:37 +00:00
Peter Nelson
6215e9bf77
Fix #11655 : Crash due to NWidgetMatrix modifying widget->index. ( #11657 )
...
NWidgetMatrix modifies its child widget's index to indicate which element
is to be drawn, which now causes issues with code that does not know about
stuffing extra data into the index.
Instead, let NWidgetMatrix store the currently processing element, and
retrieve this information from the matrix widget while child widgets are
being drawn.
This means only widgets that are children of NWidgetMatrix need to know
anything about their extra data.
2023-12-30 18:24:26 +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
7466c3c39e
Fix: Draw unavailable mask over picker sprite instead of behind it.
...
This makes these disabled picker buttons consistent with other disabled buttons.
2023-12-20 09:29:28 +00:00
Peter Nelson
712a4bb40b
Fix: Prevent picker preview sprites from overflowing button bevel.
2023-12-20 09:29:28 +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
Peter Nelson
661e0cd82d
Fix: Make compact picker windows expand to fill if necessary. ( #11591 )
2023-12-16 23:08:42 +00:00
Peter Nelson
fb60f8f2f5
Codechange: Simplify BuildRailStationWindow initialization.
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
8db7c79e79
Codechange: Add DropDownIcon constructor to override dimension.
...
This avoids the need to construct a DropDownIcon and set the dimension after.
2023-12-02 15:23:05 +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
f58a7ef673
Codechange: Remove now-unnecessary containers in picker layouts. ( #11473 )
...
These are no longer necessary as the issue they work around was resolved by #11471
2023-11-20 00:14:06 +00:00
Peter Nelson
61deab08fc
Change: Improve layout of station picker.
2023-11-07 18:27:51 +00:00
Peter Nelson
d380f2f3a2
Codechange: Simplify layout of depot pickers.
2023-11-05 20:09:45 +00:00
Peter Nelson
ef385499c7
Codechange: Remove ineffective NWidgetParts. ( #11443 )
2023-11-05 14:09:47 +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
Rubidium
c9276c2959
Codechange: replace x.size() == 0 with x.empty()
2023-10-20 23:05:43 +02:00
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.
2023-10-20 18:40:48 +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
frosch
b5885295f0
Codechange: Use parameters, which should be used.
2023-09-19 22:49:59 +02:00