Commit Graph

357 Commits

Author SHA1 Message Date
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 fc7f184dbd Codechange: move knowledge about 'packed' orders to the saveload code 2024-04-20 11:58:07 +02:00
Peter Nelson 6cbb8d02cf Change: Use aspect ratio for shared order list button. 2024-04-19 22:11:16 +01:00
Rubidium 4f2412a272 Codechange: range based for loops instead of C-style for loops 2024-04-11 07:05:04 +02: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
Rubidium d09b5aaeba Codechange: use int32_t instead of uint16_t for scroll bar position/size/capacity 2024-03-24 08:30:38 +01:00
Tyler Trahan 2732b3d6c6
Change: Show unbunching action in timetable window (#12351) 2024-03-23 08:23:13 -04: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
Loïc Guilloux 82430a1086
Fix ab315d0: Don't show "insert order" errors in the console (#12245) 2024-03-09 16:33:44 +00:00
Tyler Trahan ab315d0dc9
Fix #12118: When adding an unbunching order, properly check for unsafe conditions (#12136) 2024-03-09 08:28:05 -05:00
Peter Nelson 912d7bd80e Codechange: Give ColourShade values names instead of numbers. 2024-02-25 12:38:07 +00:00
Peter Nelson ae3390fe48 Codechange: Add ColourShade enum. 2024-02-25 12:38:07 +00:00
Peter Nelson 0463d4c198 Codechange: Remove direct access to _colour_gradient.
Access is now through GetColourGradient, which ensures parameters are in range.
2024-02-25 12:38:07 +00:00
Tyler Trahan 87a80c7ff2
Change: When adding orders, Ctrl+Click on a depot to unbunch, instead of service if required (#12023) 2024-02-18 10:43:44 -05:00
Tyler Trahan 7b32d9cff5 Fix #12019: Correctly highlight depot unbunch action in dropdown 2024-02-10 15:11:24 -05:00
Peter Nelson e9ea837311
Fix #12012: Crash when opening orders of another company. (#12013)
Orders window changes tooltip depending on vehicle type but did check if widget exists.
2024-02-06 12:53:23 +00:00
Tyler Trahan d5e936c9d4
Fix #11968: Always set string parameters to avoid undefined behavior (#11973) 2024-02-04 07:07:47 +01:00
Tyler Trahan 80a704ba11 Fix f6dd505: Split depot action tooltip by vehicle type 2024-02-03 17:32:25 -05:00
Tyler Trahan f6dd5053a3
Feature: Order flag to unbunch vehicles at depot (#11945) 2024-02-03 08:04:24 -05: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 86981c0983
Fix: Extra refit button when train/RV is in a depot (#11904) 2024-01-28 08:01:09 -05: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 400ae65ff2 Codechange: Redefine some cargo-related values in terms of CargoID instead of CargoType.
Values used as special filter types are now defined as offsets from NUM_CARGO instead of confusingly reusing CARGO_NO_REFIT/CARGO_AUTO_REFIT types.
2024-01-09 18:56: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 938c8339d2 Codechange: Ensure space between `for`/`if` and `(`. 2023-11-09 20:15:38 +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
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
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +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
Tyler Trahan f57296a033
Change: Only show platform stopping location in orders when other than default (#11102) 2023-07-29 17:59:02 -04: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 2511649938 Codechange: Use window parent association for dropdowns.
This replaces the separate window class and number properties, and
allows the window system to close dropdowns automatically.
2023-06-03 14:17:05 +01:00
PeterN 9eb0cca93a
Fix #10823, Fix #10811: Order list has end marker row. (#10825) 2023-05-14 13:04:59 +01:00
Peter Nelson 531d1ae8bc Codechange: Use GetScrolled(Row/Item)FromWidget in more places.
In many instances the clicked row position is 'manually' calculated
instead of using the GetScrolledRowFromWidget helper function, with
variations on checks. Replace with the two helpers where possible.
2023-05-12 21:45:32 +01:00
Peter Nelson e18f688db5 Codechange: Remove various COMMA strings. 2023-05-05 07:07:54 +01: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
Rubidium a409e4b026 Add: documention to large functions that have too little documentation according to CodeQL 2023-02-25 23:57:36 +01:00
Rubidium 90f1768006 Codechange: add non-nullptr asserts in cases where it should never be nullptr
Though where similar calls are checked for nullptr as in those instances of
the use of that function it can actually return nullptr. In other words, write
down the assumption that the function never returns nullptr in an assert.
2023-01-14 21:15:23 +01:00
Bernard Teo 8a78fa7121
Feature: Contextual actions for vehicles grouped by shared orders (#8425) 2022-11-26 18:03:21 +01: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 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
Nicolas Chappe a9a21e784d Codechange: Always set the ODATFB_NEAREST_DEPOT flag for 'any depot' orders 2022-10-22 14:19:08 +02:00
Michael Lutz 211c630cbe Codechange: Un-bitstuff order 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