Peter Nelson
62d4fd0572
Codechange: Add method to guess the width/height required for a multiline string.
...
This is necessary for widget layouts where a minimum width is not yet known during UpdateWidgetSize().
2023-11-20 23:09:20 +00:00
Peter Nelson
f281525492
Codechange: Add method to resize both width and height of a widget.
2023-11-20 23:09:20 +00:00
Peter Nelson
05b55c4d43
Fix: Extra space allocated to container-within-container may not get allocated to children. ( #11471 )
...
Always derive additional length from contained widgets instead of from the container, as the container's minimal length may have been adjusted by an NC_EQUALSIZE parent container.
2023-11-19 00:36:53 +00:00
Peter Nelson
f93711838f
Fix 6317967: Missing exception for SetPipRatio(). ( #11465 )
2023-11-16 19:22:02 +00:00
Peter Nelson
e2e0753916
Codechange: Use GetCurrentRect() where feasible. ( #11460 )
2023-11-16 17:06:57 +00:00
Peter Nelson
55adbe10b7
Add: WidgetDimensions for 'sparse' widget windows.
...
These are for windows that have space between widgets instead of being clumped together.
2023-11-07 23:09:05 +00:00
Peter Nelson
665902f5ba
Codechange: Add widget dimensions to standardise picker winodws.
2023-11-05 20:09:45 +00:00
Peter Nelson
3cab980b30
Codechange: Skip invisible (zero-size) widgets in PIP Containers.
...
This gets rid of doubled-up spacing where an invisible child widget would be.
2023-11-05 20:09:45 +00:00
Peter Nelson
6317967dba
Codechange: Add ability to allocate PIP-space dynamically by ratio.
...
This can be used to space out, centre, start-align, or end-align widgets without additional spacers.
2023-11-05 20:09:45 +00:00
Peter Nelson
ac54bd7e58
Codechange: Apply PIP during AssignSizePosition() instead of SetupSmallestSize().
2023-11-05 20:09:45 +00:00
Peter Nelson
a9aaa2a183
Codechange: Don't be lenient with invalid NWidgetPart lists.
...
Some NWidgetPart combinations were ignored but it was not clear that they do nothing. Instead, assert if NWidgetPart is incorrectly applied.
2023-11-05 19:24:59 +00:00
Peter Nelson
e8db137135
Codechange: Move test for Container WidgetType to helper function.
2023-11-03 09:38:41 +00:00
Peter Nelson
bb50cbb772
Codechange: Assign/StoreSizePosition x/y can be negative. ( #11416 )
...
AssignSizePosition is used with negative values when an NWidgetMatrix is
scrolled, but they were passed as unsigned and then stored as signed.
Widget pos_x/pos_y were already made signed.
2023-11-01 18:44:23 +00:00
Peter Nelson
c0aa9a5f87
Add: Debug tool to draw widget outlines. ( #11401 )
...
This is considered a developer tool and is controlled from the help menu (or default hotkey Ctrl-O).
This draws a white dashed outline around widgets. NWidgetSpacer and (unused) WWT_EMPTY widgets are also filled with check pattern to highlight them, as they usually indicate a design issue.
2023-10-28 19:07:50 +01:00
Peter Nelson
59a2abd298
Codechange: Use unified NWidgetContainer methods instead of duplicating.
...
Most NWidgetContainer derivatives implemented Draw() and GetWidgetFromPos()
the same way. Move this these to NWidgetContainer itself to avoid repeating.
2023-10-21 14:26:36 +01:00
frosch
b6c8f301be
Codechange: Silence warnings about intentionally unused parameters.
2023-09-19 22:49:59 +02:00
Peter Nelson
152b0cac34
Codechange: Return update nwid_begin instead of count.
...
This avoids needing to keep track of how many widget parts have been consumed, instead we only to ensure nwid_begin < nwid_end.
2023-09-04 10:20:45 +01: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
Richard Wheeler
96fdfb941a
Feature: Transparency option for cost and income indicators ( #11001 )
2023-08-25 16:04:40 +02:00
Patric Stout
0238a2b567
Codechange: use std::variant instead of using bitflags in the value ( #11191 )
2023-08-12 16:05:00 +00: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
43ddf19df3
Change: Allow text shadow on WWT_EMPTY/WWT_TEXT to extend horizontally. ( #11065 )
...
This alleviates text shadows of truetype fonts being cropped in some
window layouts.
2023-06-25 11:58:39 +01:00
PeterN
40f567d464
Fix #10811 : Crash getting row from non-resizable widget. ( #10833 )
...
GetScrolled*FromWidget took line height from the widget's resize_y value,
however not all widgets are resizable, resulting in a division-by-zero.
Allow passing line height explicitly in cases where a widget is not
resizable.
2023-05-15 18:57:50 +01:00
Patric Stout
7634553d22
Feature: opt-in survey when exiting a game
...
On first start-up, the game will ask if you want to participate
in our automated survey. You have to opt-in, and can easily opt-out
(via the Options) at any time.
When opt-in, whenever you exit a game, a JSON blob will be send
to the survey server hosted by OpenTTD. This JSON blob contains
information that gives a global picture of the game just played:
- What settings were used
- How many humans vs AIs
- How long the game has been played
- Basic information about the OS / CPU
All this information is kept very generic, so there is no
chance we send private information to our survey server.
Nothing in the JSON blob could identify you as a person; it
mostly tells about the game played. At any time you can see
what the JSON blob includes, by pressing the "Preview Survey
Results" button in-game.
2023-05-14 23:22:02 +02:00
PeterN
da7f431812
Cleanup: widget pos_x/y are already int. ( #10809 )
...
Remove old casts left over from when pos_x/y were unsigned.
2023-05-12 18:02:51 +01:00
PeterN
6998fbf71d
Fix: WWT_TEXT with SetTextStyle did not work. ( #10797 )
...
FontSize was passed to incorrect parameter of DrawString function.
2023-05-09 17:23:37 +00:00
Peter Nelson
35ba49bfb4
Change: Rename text colour NWidgetPart to SetTextStyle and add font size.
...
This allows to set both text colour and size for any widget with default
drawing.
2023-04-30 11:47:53 +01:00
Peter Nelson
55d981aec3
Add: Helper to update widget vertical size.
...
This avoids directly setting min_y outside widget code.
2023-04-25 13:27:22 +01:00
Peter Nelson
d93f96a442
Fix: Account for extra dropdown list padding.
2023-04-12 18:43:15 +01:00
rubidium42
6ba55e663e
Codechange: do not hide variables with other variables
2023-01-29 07:21:34 +01:00
Rubidium
f001e84e5e
Codechange: use RAII to automatically restore _cur_dpi after use
2023-01-28 20:33:02 +01:00
PeterN
c448eb04d8
Fix #10242 : Allow a space for text shadow when clipping WWT_EMPTY/WWT_TEXT. ( #10243 )
2022-12-15 23:21:10 +00:00
Peter Nelson
9bf24ec56f
Codechange: Reorder and properly declare DrawSpriteIgnorePadding().
...
Parameters have been rearranged to be closer to those of the standard
DrawSprite() function, and PaletteID can now be set.
2022-11-17 09:12:07 +00:00
Peter Nelson
ecb5393c55
Change: Standardize progress bar layout.
...
Progress bars are drawn differently depending on when it was added, with
different layouts and sizes.
This change adds a standard padding size to use, and makes all progress
bars visually similar, with scaled padding.
2022-11-12 18:28:39 +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
dd90d79e7b
Add: Setting to toggle thin vs chunky (scaled) bevels.
2022-11-12 18:28:39 +00:00
Peter Nelson
e554fd7808
Change: Hide WidgetDrawDistances from general use.
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
23a8222200
Change: Split vscroll and hscroll padding.
...
Vertical and horizontal scrollbars are different sizes, this allows
different padding for each type.
2022-11-12 18:28:39 +00:00
Peter Nelson
90ce704366
Change: Use scaled WidgetDimensions for core widgets.
2022-11-12 18:28:39 +00:00
Peter Nelson
0bb9a45785
Change: Simplify drawing widget image buttons.
2022-11-12 18:28:39 +00:00
Peter Nelson
d0add1e07f
Change: Ignore offsets when drawing GUI sprite.
2022-11-12 18:28:39 +00:00
Peter Nelson
b5693becdc
Add: Define scaled WidgetDimensions.
...
Includes RectPadding container.
2022-11-12 18:28:39 +00:00
Peter Nelson
0108e9f387
Change: Set up suggested widget padding for panel, frame and inset.
...
Window handlers are free to ignore the suggested padding, however some
handlers have logic that assumes this information was already provided.
2022-11-12 18:28:39 +00:00
Peter Nelson
68423c40c5
Fix: Off-by-one in GetAlignedPosition().
2022-11-12 18:28:39 +00:00
Peter Nelson
dd9f6bc803
Change: Use RectPadding Horizontal()/Vertical() helpers.
2022-11-12 18:28:39 +00:00
Peter Nelson
04cbe57d2a
Change: Use RectPadding for widget padding/uz_padding.
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
PeterN
f24286a1ae
Fix: Ensure 31-bit shifts are unsigned. ( #10128 )
...
Shifting a signed 32-bit integer by 31 bits is undefined behaviour.
A few more than necessary are switched to unsigned for consistentency.
2022-11-04 07:15:59 +00:00
Peter Nelson
ba94efba87
Change: Add flag to apply resize to largest resize step first.
...
Resize step is normally allocated equally amongst all resizable widgets.
With this flag, we allocate as much as possible from the largest
resize step first.
2022-10-16 14:56:34 +02:00