Jonathan G Rennison
ef14d3e361
Fix #12166 : Crash when opening tram road stop build window ( #12168 )
2024-03-23 15:32:22 +01:00
Peter Nelson
adb796a21a
Change: Show 6 or 2 orientation buttons in NewGRF road stop picker as appropriate.
...
This replaces the normal method of masking unusable buttons.
2024-02-15 22:28:58 +00:00
dP
e2d36f626b
Fix: Focus hotkey in road/tram stop building window ( #12008 )
2024-02-05 18:14:21 -05: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
Rubidium
e3f49ee7a0
Codechange: coding style fixes
2024-01-04 16:23:54 +01: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
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
d4008850e3
Codechange: Ensure function opening `{` is on new line.
2023-11-09 20:15:38 +00:00
Peter Nelson
db18f60beb
Change: Improve layout of road/tram stop pickers.
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
Loïc Guilloux
ab805c4e9e
Fix #11375 , 7c37dcb: Use STRING2 when the passed string can have 2 parameters ( #11376 )
2023-10-16 17:49:44 +00: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
Rubidium
8ab0936491
Codechange: use parameter pack/folding instead of va_arg macros for widget states
2023-09-16 23:09:53 +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
arikover
5d3f7939e2
Fix d42a78f: Show correct road speed in construction dropdowns ( #11196 )
2023-08-15 10:34:36 +02: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
3ac663e619
Fix: Build road/tram stop windows did not set WindowDesc::ini_key ( #11126 )
...
Saved default window sizes were not persisted in the configuration file
2023-07-12 22:07:31 +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
Rubidium
7c37dcb8e3
Fix: do not use {STRING} when {STRING1} or {STRING2} is needed
2023-06-14 09:44:06 +02:00
PeterN
f814c86389
Codechange: Reorganise hotkey initialisation. ( #10951 )
...
Hotkeys are now initialized inline, and use std::vector instead of
separate static C-arrays and std::string instead of char *. The list end
marker is no longer required.
2023-06-05 18:12:30 +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
0513a6ccb0
Change: Use separate names for default stations/roadstops.
2023-05-09 23:03:14 +02:00
PeterN
882f06bf14
Fix: Support more than 256 stations/waypoints/roadstops per class. ( #10793 )
...
It was already possible to define more than 256 per class, but not possible
to use them as the index used in GUI and passed through commands was limited
to a byte.
2023-05-08 18:09:33 +00: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
Peter Nelson
0880616851
Codechange: Remove various STRING strings.
2023-05-05 07:07:54 +01:00
Tyler Trahan
ba3de0383a
Codechange: Pass more std::string to StringFilter::AddLine() ( #10743 )
2023-04-30 10:23:05 +02:00
Patric Stout
7aa2b9ab0a
Codechange: move all date-related variables inside the timer ( #10706 )
2023-04-24 15:56:01 +00:00
Patric Stout
3ebc7ad16e
Codechange: migrate all game-time-related timers to the new framework
2023-04-15 13:58:55 +02:00
PeterN
f1144de509
Feature: Separate rail/road and sea/air velocity units, and add knots. ( #10594 )
...
This is achieved by packing vehicle type along with the velocity so that
the string system can decode and pick the appropriate unit.
2023-04-08 12:26:13 -04:00
Jonathan G Rennison
4c1406a4b5
Add: NewGRF road stops
2023-02-26 21:28:30 +01:00
Rubidium
f001e84e5e
Codechange: use RAII to automatically restore _cur_dpi after use
2023-01-28 20:33:02 +01:00
Peter Nelson
ed60c88b0a
Change: Use power-of-2 scaling for some dimensions in GUI.
...
These are related to drawing sprites that are normally drawn on the
landscape, and should therefore still follow power-of-2 scaling to fit
correctly.
2022-11-12 18:28:39 +00:00
Peter Nelson
890b2666d3
Change: Use scaled WidgetDimensions.
2022-11-12 18:28:39 +00:00