Commit Graph
302 Commits
Author SHA1 Message Date
Rubidiumandrubidium42 aa5ba5bd7f Codechange: allow certain enumeration to be added
Otherwise C++20 doesn't like it.
2024-01-16 23:30:23 +01:00
Peter NelsonandPeter 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
Rubidiumandrubidium42 e3f49ee7a0 Codechange: coding style fixes 2024-01-04 16:23:54 +01:00
Peter NelsonandPeter Nelson 628092f133 Codechange: Use GetParentWidget to find widget's NWidgetMatrix container. 2023-12-30 22:02:37 +00:00
Peter NelsonandGitHub 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 NelsonandPeter 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 NelsonandPeter 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 NelsonandPeter Nelson 712a4bb40b Fix: Prevent picker preview sprites from overflowing button bevel. 2023-12-20 09:29:28 +00:00
Peter NelsonandPeter 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 NelsonandGitHub 661e0cd82d Fix: Make compact picker windows expand to fill if necessary. (#11591) 2023-12-16 23:08:42 +00:00
Peter NelsonandPeter 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 NelsonandPeter 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 NelsonandGitHub 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 NelsonandGitHub 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 NelsonandPeter Nelson d4008850e3 Codechange: Ensure function opening { is on new line. 2023-11-09 20:15:38 +00:00
Peter NelsonandPeter Nelson db18f60beb Change: Improve layout of road/tram stop pickers. 2023-11-07 18:27:51 +00:00
Peter NelsonandPeter Nelson d380f2f3a2 Codechange: Simplify layout of depot pickers. 2023-11-05 20:09:45 +00:00
Peter NelsonandGitHub ef385499c7 Codechange: Remove ineffective NWidgetParts. (#11443) 2023-11-05 14:09:47 +00:00
Peter NelsonandPeter 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
Rubidiumandrubidium42 c9276c2959 Codechange: replace x.size() == 0 with x.empty() 2023-10-20 23:05:43 +02:00
Peter NelsonandGitHub 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 GuillouxandGitHub ab805c4e9e Fix #11375, 7c37dcb: Use STRING2 when the passed string can have 2 parameters (#11376) 2023-10-16 17:49:44 +00:00
Peter NelsonandPeter 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
froschandfrosch b5885295f0 Codechange: Use parameters, which should be used. 2023-09-19 22:49:59 +02:00
froschandfrosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
Rubidiumandrubidium42 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
Rubidiumandrubidium42 8ab0936491 Codechange: use parameter pack/folding instead of va_arg macros for widget states 2023-09-16 23:09:53 +02:00
Peter NelsonandPeterN 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
arikoverandGitHub 5d3f7939e2 Fix d42a78f: Show correct road speed in construction dropdowns (#11196) 2023-08-15 10:34:36 +02:00
Rubidiumandrubidium42 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 RennisonandGitHub 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
PeterNandGitHub 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
Rubidiumandrubidium42 7c37dcb8e3 Fix: do not use {STRING} when {STRING1} or {STRING2} is needed 2023-06-14 09:44:06 +02:00
PeterNandGitHub 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 NelsonandPeterN 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 NelsonandMichael Lutz 0513a6ccb0 Change: Use separate names for default stations/roadstops. 2023-05-09 23:03:14 +02:00
PeterNandGitHub 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 NelsonandPeterN 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 NelsonandPeterN 0880616851 Codechange: Remove various STRING strings. 2023-05-05 07:07:54 +01:00
Tyler TrahanandGitHub ba3de0383a Codechange: Pass more std::string to StringFilter::AddLine() (#10743) 2023-04-30 10:23:05 +02:00
Patric StoutandGitHub 7aa2b9ab0a Codechange: move all date-related variables inside the timer (#10706) 2023-04-24 15:56:01 +00:00
Patric StoutandPatric Stout 3ebc7ad16e Codechange: migrate all game-time-related timers to the new framework 2023-04-15 13:58:55 +02:00
PeterNandGitHub 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 Rennisonandrubidium42 4c1406a4b5 Add: NewGRF road stops 2023-02-26 21:28:30 +01:00
Rubidiumandrubidium42 f001e84e5e Codechange: use RAII to automatically restore _cur_dpi after use 2023-01-28 20:33:02 +01:00
Peter NelsonandPeterN 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 NelsonandPeterN 890b2666d3 Change: Use scaled WidgetDimensions. 2022-11-12 18:28:39 +00:00
Peter NelsonandPeterN 1f1378c129 Change: Align picker previews to button centre. 2022-11-12 18:28:39 +00:00
Peter NelsonandPeterN ab55d3e1fa Change: Rearrange layouts of station/depot picker windows. 2022-11-12 18:28:39 +00:00
Tyler TrahanandMichael Lutz db98cedb7e Fix #9883: Show cost/income float over end tile of rail or road construction 2022-10-16 14:15:31 +02:00