Peter Nelson
9a3db25e6c
Codechange: Make sort list function lists safer.
...
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 08:20:46 +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
frosch
b6c8f301be
Codechange: Silence warnings about intentionally unused parameters.
2023-09-19 22:49:59 +02:00
Rubidium
3a2509198f
Codechange: use better location for the "invalid" action sentinel value
...
It used to be a random sentinel for end-of-(widget-)list that was used to tell
that no action has taken place yet. Since the last action is practically the
widget that was pressed, add the sentinel to that enumeration.
2023-09-17 19:44:20 +02:00
PeterN
acd7d3c913
Codechange: Rename *Railtype* to *RailType* for consistency. ( #11287 )
2023-09-11 08:55:12 +00: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
glx22
46b504a700
Fix: ini_key issues reported by the script
2023-07-14 14:32:46 +02:00
PeterN
d42a78f3e8
Codechange: Make DropDownListStringItem preformat and remove other implementations. ( #11063 )
...
Having to choose between DropDownListStringItem, DropDownListCharStringItem, and DropDownListParamStringItem depending on whether to draw a StringID, a raw string, or a StringID with extra parameters was needlessly complex.
Instead, allow passing a StringID or raw string to DropDownListStringItem. This will preformat the StringID into a raw string, and can therefore accept parameters via the normal SetDParam mechanism.
This also means that strings no longer need to be formatted on every draw.
2023-06-23 08:30:13 +00:00