Commit Graph

243 Commits

Author SHA1 Message Date
rubidium42 fd4cf699e5
Codefix 37a03b5: the return value of maxdim should always be assigned (#12590) 2024-04-28 17:42:58 +00:00
Rubidium d183d8e587 Codechange: remove INVALID_STRING_ID now drop down uses spans 2024-04-28 18:47:31 +02:00
Rubidium 37a03b513f Codechange: refactor string list dimension finding into a separate function 2024-04-28 18:47:31 +02:00
Rubidium 546a996d95 Codechange: pass options to ShowDropDownMenu using a span 2024-04-28 18:47:31 +02:00
Peter Nelson dc7c2bb30d
Fix: Draw continuation lines for engine variant hierarchy tree. (#12434) 2024-04-09 08:35:12 +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
Rubidium 86cb184eb4 Codechange: use std::source_location over __FILE__ and __LINE__ for WindowDesc 2024-03-10 10:14:20 +01:00
Peter Nelson a61311fcb0 Codefix: DrawEngineList does not accept EngineID.
Replace min/max parameters of DrawEngineList with scrollbar reference, and use iterators instead of indices.
2024-02-27 17:18:53 +00: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
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 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 c877494f7a
Codechange: Simplify autoreplace rail/road types by using separate widget. (#11457)
This avoids needing to determine which type of list to deal with by additionally checking the window number for VEH_TRAIN/VEH_ROAD.
2023-11-13 12:32:34 +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 37f84b7372 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 2fd3d943aa
Fix 94167dfd: Don't shade the currently selected engine in autoreplace window. (#11354)
This breaks #7729 which specifically allows autoreplace of same engine types, and also did not work properly if the engine had been built during the current game session.
2023-10-06 21:09:24 +01:00
merni-ns c794676928
Fix #10763, Fix #11168: Display variant groups that consist only of unavailable sub-groups (#11342) 2023-10-03 12:43:15 +00:00
PeterN cef6a5f79c
Fix #11326: Update autoreplace scrollbar count after clearing engine list. (#11327) 2023-09-21 07:42:49 +01:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +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
Rubidium 836541b41c Codechange: use SetDParam and CopyOutDParam for tooltips 2023-06-17 10:01:19 +02:00
PeterN 64930c343a
Codechange: Pass reference instead of pointer to GUI*Lists. (#10822)
Pointer-avoidance.
2023-05-14 09:17:44 +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 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
PeterN 1697dff744
Change: Hide all variants from UI when (display) parent is hidden. (#10708) 2023-04-25 20:34:10 +01:00
Michael Lutz 05ed9f56fd Feature: [NewGRF] Engine name callback. 2023-01-30 22:00:56 +01:00
Jonathan G Rennison 10e76b2788 Fix #10032: Capacities of articulated vehicles in build window
See also: #9954
2023-01-14 18:52:01 +01:00
Peter Nelson 85814b29d4 Feature: Vehicle add-ons can now group engines in purchase list.
Grouped engines are collapsed by default but can be expanded. This allows
similar engines to be grouped together to avoid cluttering the list.

Suggested uses for this are e.g.:
* Liveries; same stats but different paint job.
* Re-gearing; engine design is mostly the same but different stats.

... but avoiding complex hidden cargo subtype refit systems.

Grouped engines are otherwise separate, so can be independently
autoreplaced, even between variants.
2022-12-25 16:41:58 +00:00
peter1138 94167dfd34 Change: Add variant hierarchy to build vehicle window list. 2022-12-25 16:41:58 +00:00
Peter Nelson 890b2666d3 Change: Use scaled WidgetDimensions. 2022-11-12 18:28:39 +00:00
Peter Nelson b6ed595176 Codechange: Prefer suggested widget padding. 2022-11-12 18:28:39 +00:00
Peter Nelson 5786d49143 Change: Use Rect when drawing build engine list. 2022-11-12 18:28:39 +00:00
Peter Nelson 6f95e04005 Change: Use Rect helpers for widget drawing.
This replaces repetitive and sometimes unwieldy use of constants.
2022-11-12 18:28:39 +00:00
Michael Lutz 13528bfcd0 Codechange: Un-bitstuff all remaining commands. 2021-12-16 22:28:32 +01:00
Michael Lutz e08b3abe7f Codechange: Un-bitstuff group and autoreplace commands. 2021-12-16 22:28:32 +01:00
Michael Lutz 0f64ee5ce1 Codechange: Template DoCommandP to automagically reflect the parameters of the command proc.
When finished, this will allow each command handler to take individually
different parameters, obliviating the need for bit-packing.
2021-12-16 22:28:32 +01:00
Michael Lutz 549caca39c Codechange: Move command arguments to the back of the networked command function calls. 2021-12-16 22:28:32 +01:00
Tyler Trahan b4bd7b367e
Feature: Ctrl-click to remove fully autoreplaced vehicles from list (#9639) 2021-11-07 19:53:54 +01:00
Patric Stout d70fb74ac6
Codechange: use setting name instead of index for CmdChange(Company)Setting (#9306)
This is mostly done as there are now constraints on settings.ini you might not
expected. For example, conditional settings always have to come last, as otherwise
they would influence the index.
2021-05-29 23:27:01 +02:00
glx22 5799402f7a Codechange: Rename window related DeleteXXX to match new behaviour 2021-05-29 21:08:25 +02:00
glx22 7c0762da65 Change: Show what is affected by "wagon removal" toggle 2021-05-23 21:51:58 +02:00
PeterN 224625942c
Fix: Count engine details text in lines rather than pixels. (#9107)
This allows the details panel to scale correctly for different zoom levels.
2021-04-25 19:34:16 +01:00
peter1138 a05bc04b63 Feature: Per-group wagon removal flag. 2021-04-22 22:57:00 +02:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00