Commit Graph

693 Commits

Author SHA1 Message Date
PeterN 6d675c8acf
Fix: #11329: Don't assert vehicle list length is non-zero when only asked to set string parameter. (#11330)
Since #11321, the vehicle list is not yet initialized when SetStringParameters is called, so a test that the vehicle list size is zero is triggered. However, doing this check in the SetStringParameters function is a bit out of its remit, so just remove it.
2023-09-21 13:24:53 +01:00
PeterN a0c6259e33
Codechange: Don't access cargo filter before it is initialized. (#11321)
The cargo filter list is initialized during window OnInit, but the first
build of the filtered list occurred before this.
2023-09-20 08:58:08 +01:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
Rubidium 09a7902d36 Fix 8ab0936: missed WIDGET_LIST_END removals 2023-09-17 19:44:20 +02:00
PeterN 6580ff1adb
Fix #11230: Widget layout also failed for group-less vehicle list window. (#11310) 2023-09-17 10:03:24 +00:00
Rubidium 8ab0936491 Codechange: use parameter pack/folding instead of va_arg macros for widget states 2023-09-16 23:09:53 +02:00
Patric Stout 39ef4b503f
Fix: also apply cargo filters on shared groups in vehicle listing (#11294) 2023-09-15 21:22:58 +02:00
Tyler Trahan 77173a6a10 Codechange: Move date consts and functions to CalendarTime and TimerGameCalendar classes 2023-09-10 08:40:25 -04:00
Tyler Trahan fca2b37726 Codechange: Move Ticks into their own class 2023-09-10 08:40:25 -04: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
Patric Stout 0238a2b567
Codechange: use std::variant instead of using bitflags in the value (#11191) 2023-08-12 16:05:00 +00:00
Patric Stout b7acf9e50e
Codechange: use TimerGameCalendar::Year and friends when working with years (#11188) 2023-08-12 16:02:31 +02:00
Tyler Trahan 6190f48df0
Codechange: Add a DateToYear function instead of dividing each time (#11173) 2023-08-11 08:19:54 -04:00
Tyler Trahan 93069066f9
Codechange: Use auto type when sorting dates (#11175) 2023-08-11 08:18:32 -04: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
PeterN 2a2443dd01
Feature: Create group of vehicles from manage vehicle list button. (#10890) 2023-06-18 20:48:04 +01: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
Rubidium f29606fd14 Codechange: use std::string to cache engine/group/vehicle names 2023-05-31 19:31:09 +02:00
Peter Nelson f177ce7c9a Codechange: Base CargoArray off std::array.
This avoids needing to define array accessors and allows use of
default value initialization.
2023-05-23 19:07:36 +01:00
Rubidium 3323402aaa Codechange: rename smallvec_type to container_func and use only when needed 2023-05-20 16:53:10 +02: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 bf9caa425b Change: Units-system can convert from N to kN, don't preconvert.
This allows force to passed as is and avoid premature rounding.

The AI function "GetMaxTractiveEffort" still needs to return kN to avoid breaking the API.
2023-05-09 23:02:51 +02: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
Rubidium 19ec4e8beb Codechange: replace ClampToI32/U16 with ClampTo<int32_t/uint16_t> 2023-05-06 21:26:13 +02:00
glx22 045a99dd23 Codechange: Remove STR_TINY_RIGHT_ARROW 2023-05-05 07:07:54 +01:00
glx22 222e37d319 Codechange: Remove TINY_BLACK_STATION 2023-05-05 07:07:54 +01:00
glx22 b2a36ff3cc Codechange: Remove STR_TINY_GROUP and STR_TINY_BLACK_VEHICLE 2023-05-05 07:07:54 +01:00
Peter Nelson 0880616851 Codechange: Remove various STRING strings. 2023-05-05 07:07:54 +01:00
Peter Nelson e18f688db5 Codechange: Remove various COMMA strings. 2023-05-05 07:07:54 +01:00
Rubidium c829930440 Codechange: replace strnatcmp with C++ string capable version 2023-04-29 12:07:45 +02:00
Tyler Trahan 930f0a16d8 Codechange: Define Date/Year/Month/Day within TimerGameCalendar class 2023-04-26 07:14:03 -04:00
Peter Nelson 06b78a7299 Fix: Don't double-pad existing size when adding widget padding.
UpdateWidgetSize's size parameter already includes padding.
2023-04-12 18:43:15 +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
rubidium42 6ba55e663e Codechange: do not hide variables with other variables 2023-01-29 07:21:34 +01:00
Rubidium bcfe0fb076 Codechange: introduce GetMainWindow() to properly account for nullptr checks
Some nullptr checks have been removed as they were not triggered with nullptr
with the null video driver and in dedicated server mode.
2023-01-14 21:15:23 +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
PeterN f7e2b6ef12
Change: Make vehicle list dropdown buttons resize to fit strings. (#10286) 2022-12-27 18:39:37 +00:00
PeterN 7b5edba76c
Change: Support flipping shorter engines without NewGRF support. (#10262)
* Change: Support flipping shorter engines without NewGRF support.
* Cleanup: Remove write-only prop27_set temporary flag.
2022-12-23 21:02:14 +00:00
PeterN 03c1b5169c
Fix #10260: Incorrect rect height drawing image in vehicle details. (#10261) 2022-12-19 21:01:17 +00:00
PeterN 1eecbd39ed
Change: Use lowered not disabled widget for current tab. (#10252)
While tab-buttons are not often used, all other similar occurences use
lowered rather than disabled widgets, so use them for train detail
window too.
2022-12-17 18:04:39 +00:00
PeterN a7ffd47c64
Fix #10191: Incorrect refit highlight position. (#10195)
Refit highlight was not correct for non-power-of-2 interface scale.
2022-11-27 15:13:09 +00:00
Bernard Teo 8a78fa7121
Feature: Contextual actions for vehicles grouped by shared orders (#8425) 2022-11-26 18:03:21 +01:00
stormcone e29547a3a2
Feature: Show the cargoes the vehicles can carry in the vehicle list window (#8304) 2022-11-24 20:58:10 +00:00
PeterN 53682b4b6b
Fix #10114: Wonky depot layout. (#10191)
Depot lists internal layout was not handled well. This is improved by
throwing more Rects at it:
- Vehicle images are now be vertically centred in the rect.
- Image clipping is relaxed to cover the rect, improving larger sprites.
- Outline highlight is now aware of bevel thickness.
2022-11-23 21:01:09 +00:00
Peter Nelson 60404c3aea Fix #8770: Centre vehicle status bar icon.
The icon is now centred within its scaled bounding box, which intentionally
leaves a little space around the icon when not at 1/2/4x scale.
2022-11-17 09:12:07 +00: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
Peter Nelson c9a81fd67b Change: Use Rect for drawing vehicle details. 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
Peter Nelson f5f035a22b Codechange: Make use of Rect Width/Height helpers. 2022-11-12 18:28:39 +00:00
Peter Nelson eb4ba1991b Change: Use CenterBounds function in more places.
CenterBounds may have a 1 pixel difference so the result is not exactly
the same.
2022-11-12 18:28:39 +00:00
Artin Alavi fd4f148c62
Feature: Hotkey to honk a vehicle's horn (#10110) 2022-11-10 21:36:18 +01:00
stormcone 0d303d6c3f
Feature: Add cargo filter support to vehicle list. (#8308) 2022-11-08 21:11:16 +01:00
Henry Wilson 59dbcdb5ba Feature: Display power-to-weight ratio in ground vehicle details GUI 2022-11-08 21:02:08 +01:00
Nicolas Chappe a9a21e784d Codechange: Always set the ODATFB_NEAREST_DEPOT flag for 'any depot' orders 2022-10-22 14:19:08 +02:00
Bouke Haarsma 93d2d4590f Fix #9995: Adjust viewport zoom level for HiDPI displays
On HiDPI screens the zoom level is increased for detailed rendering. This causes hard-coded zoom levels to be off by this adjustment. To fix these default zoom levels, we scale the zoom level based on `_gui_zoom` to get the scaled zoom level.
2022-10-18 22:03:21 +02:00
Tyler Trahan 164ec3ac07
Fix: Disable "turn around" button for other companies' road vehicles (#10033) 2022-09-21 12:39:56 +02:00
Niels Martin Hansen e68bf58989 Codechange: Use anonymous union for vehicle orders/old orders list 2022-02-15 20:01:10 +01:00
frosch 8028794bee
Fix #9811, 9156d7b: Use the NewGRF-defined vehicle center when dragging ships and aircraft. (#9812)
The alignment using the total-width of the vehicle-chain was meant for articulated trains and road vehicles only.
2022-02-08 23:08:03 +01:00
Michael Lutz 41fa16f325 Codechange: Don't use globals for return values from vehicle command procs. 2021-12-16 22:28:32 +01:00
Michael Lutz 8503854655 Codechange: Pass unpacked command arguments to command callbacks (except Script). 2021-12-16 22:28:32 +01:00
Michael Lutz 21675ec7e2 Codechange: Un-bitstuff vehicle/engine commands. 2021-12-16 22:28:32 +01:00
Michael Lutz 211c630cbe Codechange: Un-bitstuff order commands. 2021-12-16 22:28:32 +01:00
Michael Lutz eab18f06a4 Codechange: Pass additional data as byte stream to command callbacks. 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 e740c24eb7 Codechange: Template DoCommand 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 4fc055d6e9 Codechange: Align parameter order of command callbacks to command handlers. 2021-12-16 22:28:32 +01:00
Michael Lutz 123c7f99c3 Codechange: Move command callback declarations to the cmd header files. 2021-12-16 22:28:32 +01:00
Michael Lutz a38bbefe1b Codechange: Untangle command code, flags and error string for DoCommand*. 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
Michael Lutz b6933a2ebd Codechange: Move command arguments to the back of the DoCommand function call. 2021-12-16 22:28:32 +01:00
frosch bc984d9af5 Codechange: remove redundant 'info_view' parameter, it can be derived from 'image_type'. 2021-10-23 14:45:08 +02:00
Joan Josep b2e83b4da6
Fix: Draw rotor in cursor when dragging helicopters. (#9612) 2021-10-22 19:39:47 +02:00
Bernard Teo 20717ededf Feature: Button to open order window from VL_SHARED_ORDERS window 2021-09-18 11:17:49 +02:00
Bernard Teo 6a6dbbaad2 Feature: Ctrl-Clicking GB_SHARED_ORDERS vehicle list opens order window 2021-09-18 11:17:49 +02:00
SamuXarick a57c2b073a
Feature: Display icon/text whether vehicle is lost in vehicle (list) window (#9543) 2021-09-14 22:10:00 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
glx22 5799402f7a Codechange: Rename window related DeleteXXX to match new behaviour 2021-05-29 21:08:25 +02:00
glx22 994bf19aef Fix f6d5c01: Delay deletion when closing windows 2021-05-29 21:08:25 +02:00
PeterN 330a305c99
Fix: Apply unscaled padding to Viewport inside WWT_INSET. (#9219)
Since pixel dimensions in SetPadding() are scaled by GUI size, padding for inset viewports was excessive.

Instead, automatically apply padding for WWT_INSET at widget level. This applies to all widgets inside a WWT_INSET, which in all instances is a NWID_VIEWPORT.
2021-05-08 21:01:16 +01:00
Peter Nelson 20ac0b4148 Cleanup: Replace FOR_ALL_SORTED_CARGOSPECS macro with range iterator. 2021-04-28 23:54:31 +01:00
PeterN f158957a4e
Fix: Use width of tiny arrow string instead of scaled pixels in ship/aircraft list. (#9102) 2021-04-25 17:51:03 +01:00
Bernard Teo f0a24e98f5
Fix #8922: Show vehicle window for single vehicle in shared order grouping (#8926) 2021-04-06 19:30:35 +01:00
Charles Pigott 6b8f9b50b9 Fix: Vehicle list windows did not update when this year's profit changed
Remove caching from vehicle group object. and recalculate it whenever
required instead.
2021-02-28 11:24:09 +00:00
frosch d236c57600 Fix: yet another place where the vehicle-cursor did not account for the interface zoom level. 2021-02-27 14:52:11 +01:00
frosch 79c2b81ffd Fix: vehicle-cursor size-limit did not account for the interface zoom level. 2021-02-24 08:00:42 +00:00
SamuXarick a4035af337
Codechange: Apply coding style (#8640)
* Fix: Missing or needed spaces

* Codechange: Remove space

* Codechange: Remove space

* Codechange: More missing spaces

* Codechange: Missing spaces

* Codechange: Remove space

* Codechange: Remove space
2021-02-05 11:00:36 +01:00
dP b17177bd20 Fix: Center text and image in vehicle statusbar vertically 2021-01-22 22:18:17 +01:00
frosch 589feba0eb Change: Relocate vehicle rename and location buttons. 2021-01-11 22:15:58 +01:00
Patric Stout 5f1154e076
Fix #8272: vehicle destination text colour when mousing over (#8543)
Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>
2021-01-09 23:43:06 +01:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
Charles Pigott 860c270c73 Codechange: Replace assert_compile macro with static_assert 2020-12-27 10:55:42 +00:00
Bernard Teo 61fb1cac54 Cleanup: Move EndContainer() for empty WWT_PANEL to the same line 2020-12-21 23:15:53 +01:00
Bernard Teo e59c400ca6 Feature: Option to group vehicle lists by shared orders
This applies to all kinds of vehicle lists, as well as the "vehicle groups" window.
2020-12-21 23:15:53 +01:00
Bernard Teo 584df548f1 Codechange: Make vehicle lists internally support grouping of vehicles
This is in preparation for the new UI feature that allows grouping by shared orders.
2020-12-21 23:15:53 +01:00
Abdurrahmaan Iqbal 7d2db99bfd Fix #7772: Show destination on mouseover when vehicle stopped (and not in depot) 2020-07-10 14:48:22 +01:00
Michael Lutz 63ccb36ef3 Codechange: Use std::string for most of the user-settable custom names. 2020-05-21 20:02:34 +02:00
stormcone fea5151ee1 Feature: Control + clicking on a vehicle in the vehicle list window opens the vehicle group window focused on the vehicle's group. 2019-12-23 18:04:10 +00:00
stormcone cc1d72c3a3 Feature: Control + click on the vehicle details button in the vehicle view window opens the vehicle group window, then selects and scrolls to the vehicle's group. 2019-12-23 18:04:10 +00:00