Peter Nelson
7116f143d5
Codefix: Hole in vehicle list window if dimensions are not as expected. ( #12803 )
...
The layouts for these windows assume that push buttons and dropdowns are the same height.
2024-06-23 08:14:06 +01:00
Peter Nelson
55314513ce
Codechange: Pass NWidgetParts as span instead of begin/end pointers. ( #12779 )
2024-06-12 23:08:35 +01:00
Peter Nelson
4cf6d1dd79
Codechange: Pass WindowDesc by reference instead of pointer. ( #12771 )
...
WindowDesc as passed to Windows is not optional so don't allow to it to be nullptr.
2024-06-11 08:58:03 +01:00
Peter Nelson
9c19cf06e4
Change: [UI] Use SetMinimalTextLines to set label height correctly. ( #12734 )
...
SetMinimalSize does not know about font size, so these labels were incorrectly sized if the font height is different from normal.
2024-05-30 12:31:21 +01:00
Tyler Trahan
37f68a65ee
Fix #12283 : Vehicle group dropdown shouldn't have default action ( #12727 )
2024-05-27 16:26:07 -04:00
Peter Nelson
9008d793ab
Change: Use per-company group numbers. ( #12297 )
...
This is used by the default group name, replacing the use of group index.
2024-05-07 19:01:28 +00:00
Rubidium
546a996d95
Codechange: pass options to ShowDropDownMenu using a span
2024-04-28 18:47:31 +02:00
Peter Nelson
33aedc43a5
Codechange: Shrink GUIList vectors less often, reserve before use.
...
After sorting and filter lists for GUI, we often shirnk them to reduce size. However this has very little benefit:
1) The memory has already been allocated, so it doesn't prevent that memory being required.
2) It causes a new allocation and copy when the vector is shrunk, actually using more memory.
3) The list is in window state, so the lifetime is only while the window is open.
4) When a filter is clearer, the original size will be needed again, which will cause another allocation.
In fact it is beneficial to reserve to the known maximum in most cases, so do that instead.
2024-04-27 19:25:34 +01:00
Peter Nelson
16eb17418b
Change: Use aspect ratios for some common widgets.
2024-04-19 22:11:16 +01:00
Peter Nelson
6458980413
Change: Draw group hierarchy tree lines. ( #12522 )
2024-04-17 21:55:19 +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
74e09abf76
Codechange: Use dynamic_cast instead of C-cast after FindWindowById. ( #12448 )
...
dynamic_cast was used in most places, but not all.
2024-04-08 13:26:19 +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
Peter Nelson
107c208d87
Codechange: Use single list for hierarchical group lists. ( #12330 )
...
Replace both group list implementations (vehicle group list and company colour group list) with a single implementation, using a struct to hold the group and indentation level instead of two separate lists. Parts that were previously duplicated are now shared.
2024-03-18 17:49:51 +00:00
Rubidium
86cb184eb4
Codechange: use std::source_location over __FILE__ and __LINE__ for WindowDesc
2024-03-10 10:14:20 +01:00
Peter Nelson
d4f0f0e2c5
Codechange: Use `GetVisibleRangeIterators()` in more places. ( #12190 )
...
This replaces more first/last index calculation, along with indexed array/vector access, with iterator access instead.
2024-02-27 20:10:06 +00: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
frosch
68c64d2511
Codechange: Remove TKM string codes by duplicating strings.
2024-01-28 14:44:24 +01:00
frosch
69f47caf3f
Codechange: Remove TKM from vehicle list sorting dropdowns.
2024-01-28 14:44:24 +01: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
Rubidium
e3f49ee7a0
Codechange: coding style fixes
2024-01-04 16:23:54 +01: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
12bb750128
Codechange: Cargo filters no longer take an index. ( #11582 )
...
Update naming of functions to reflect that parameter is now a cargoid.
2023-12-14 01:48:45 +00:00
Peter Nelson
7ba89b946e
Change: Hide unused cargos from vehicle cargo filter. ( #11533 )
...
The list of used cargo types is updated when the list is invalidated.
2023-12-03 18:11:08 +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
7cfcf65f95
Codechange: Simplify cargo filter lists, building only when required.
...
Some cargo filter lists were built in advance, and used as lookups to test which cargo type to filter.
Instead, use the Cargo ID directly as the filter parameter, and build the lists only when the drop down list is used.
2023-11-13 21:30:46 +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
Rubidium
c9276c2959
Codechange: replace x.size() == 0 with x.empty()
2023-10-20 23:05:43 +02: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
8ab0936491
Codechange: use parameter pack/folding instead of va_arg macros for widget states
2023-09-16 23:09:53 +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
frosch
236ec41fa2
Fix #11230 : Group list widget layout failed, if dropdown widgets were higher than the font height. ( #11231 )
2023-09-02 12:45:19 +02: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
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
Rubidium
3323402aaa
Codechange: rename smallvec_type to container_func and use only when needed
2023-05-20 16:53:10 +02:00
PeterN
e4fd9d41d3
Codechange: Use std::any_of() ( #10830 )
...
When the result of std::find_if is compared only with end()
then '!= end()' is replaced with any_of().
Just... there's only one.
2023-05-14 23:18:52 +01: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
Rubidium
4a5a9f57c4
Fix: conversion to smaller type warnings
2023-05-06 21:26:13 +02: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