Commit Graph

437 Commits (aa5ba5bd7fe1ecd353fb67841478b88805e293b2)

Author SHA1 Message Date
Rubidium aa5ba5bd7f Codechange: allow certain enumeration to be added
Otherwise C++20 doesn't like it.
5 months ago
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.
5 months ago
Tyler Trahan 68814bd912
Codechange: Rename SIGTYPE_NORMAL to SIGTYPE_BLOCK (#11788) 5 months ago
Peter Nelson 628092f133 Codechange: Use GetParentWidget to find widget's NWidgetMatrix container. 5 months ago
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.
5 months ago
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.
5 months ago
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.
6 months ago
Peter Nelson 712a4bb40b Fix: Prevent picker preview sprites from overflowing button bevel. 6 months ago
Peter Nelson 313ee13e5f Codechange: Add Rect version of FillDrawPixelInfo().
This simplifies most callers as they longer have to split out a rect.
6 months ago
Peter Nelson 661e0cd82d
Fix: Make compact picker windows expand to fill if necessary. (#11591) 6 months ago
Peter Nelson fb60f8f2f5 Codechange: Simplify BuildRailStationWindow initialization. 6 months ago
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.
6 months ago
Peter Nelson 8db7c79e79 Codechange: Add DropDownIcon constructor to override dimension.
This avoids the need to construct a DropDownIcon and set the dimension after.
6 months ago
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(...)`.
7 months ago
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
7 months ago
Peter Nelson 61deab08fc Change: Improve layout of station picker. 7 months ago
Peter Nelson d380f2f3a2 Codechange: Simplify layout of depot pickers. 7 months ago
Peter Nelson ef385499c7
Codechange: Remove ineffective NWidgetParts. (#11443) 7 months ago
Peter Nelson 18fb8e153f Codechange: Add __FILE__/__LINE__ of WindowDesc to WindowDesc.
This is to allow unit-tests to produce more useful output.
7 months ago
Rubidium c9276c2959 Codechange: replace x.size() == 0 with x.empty() 8 months ago
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.
8 months ago
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.
8 months ago
frosch b5885295f0 Codechange: Use parameters, which should be used. 9 months ago
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 9 months ago
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.
9 months ago
PeterN acd7d3c913
Codechange: Rename *Railtype* to *RailType* for consistency. (#11287) 9 months ago
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.
9 months ago
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
11 months ago
glx22 46b504a700 Fix: ini_key issues reported by the script 11 months ago
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.
12 months ago
Rubidium 7c37dcb8e3 Fix: do not use {STRING} when {STRING1} or {STRING2} is needed 12 months ago
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.
1 year ago
PeterN 6ae6b65edb
Cleanup: Remove doubled statements. (#10944) 1 year ago
Jonathan G Rennison d7bf6b2c07 Feature: Highlight waypoint tiles when adjacent or distant joining 1 year ago
Jonathan G Rennison ba11467c02 Fix: Rail waypoint selection window not closed
When rail toolbar or rail waypoint build windows closed
1 year ago
PeterN bc45c3f66c
Change: Remember waypoint filter string. (#10857) 1 year ago
PeterN 07473bfd2e
Fix: Don't use a loop to test if classid is valid. (#10818)
Additionally the Object class test was broken.
1 year ago
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.
1 year ago
Peter Nelson f5158c8b79 Feature: Add search filter and name text to build waypoint window. 1 year ago
Peter Nelson dc50ff807c Change: Remove incorrect minimal size. 1 year ago
Peter Nelson b54d7f15ac Change: Reduce size of waypoint matrix to 3 x 2. 1 year ago
Peter Nelson 0513a6ccb0 Change: Use separate names for default stations/roadstops. 1 year ago
Peter Nelson 93d49fa8b3 Fix: Make scrollwheel work on panel behind waypoint matrix. 1 year ago
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.
1 year ago
Peter Nelson d2034d9c38 Codechange: Scrollbar methods now accept size_t.
This clears up a lot of casts from size_t to int.
1 year ago
Peter Nelson 0880616851 Codechange: Remove various STRING strings. 1 year ago
Peter Nelson 4767641c8c Codechange: Remove various INT strings. 1 year ago
Tyler Trahan ba3de0383a
Codechange: Pass more std::string to StringFilter::AddLine() (#10743) 1 year ago
Patric Stout 7aa2b9ab0a
Codechange: move all date-related variables inside the timer (#10706) 1 year ago
Patric Stout 3ebc7ad16e Codechange: migrate all game-time-related timers to the new framework 1 year ago