Commit Graph

349 Commits

Author SHA1 Message Date
Peter Nelson ae575a7a5b Codechange: Store text run positions in vector of points.
This simplifies the interlaced vector of x/y positions.
2024-01-19 00:08:31 +00:00
Patric Stout 302ba93471
Fix: [SDL2] only resolutions of the first display were shown (#11778) 2024-01-14 22:25:54 +00:00
Peter Nelson a6873ef7dd
Codechange: Avoid repeatedly calling virtual methods in text drawing loop. (#11774) 2024-01-14 19:06:50 +00:00
Peter Nelson 9ce1626bb4 Change: Support custom transparency remaps with 32bpp blitters.
This closes a 15 year old TODO...
2023-12-25 11:22:52 +00:00
Peter Nelson daec0e2ca4 Codechange: Split palette handling to separate file. 2023-12-25 11:22:52 +00:00
Peter Nelson 4ecc107d30 Codechange: Perform simpler comparison first when checking for palette updates.
This avoids unnecessarily comparing contents of an array.
2023-12-25 11:22:52 +00:00
Peter Nelson fd0aa3dd19
Fix #11515: Zoom level could wrap around when changing interface scale. (#11615)
This happened due to converting the new value to unsigned before clamping instead of after.
2023-12-22 15:23:42 +00:00
Peter Nelson c1afbc9415
Fix: Update widget dimensions before updating viewport signs. (#11611)
Viewport signs used fullbevel WidgetDimensions before it was updated for the new interface scale.
2023-12-20 22:10:05 +00:00
Peter Nelson b19a6c3b81
Fix: Window width/height was doubly-scaled with automatic DPI switch. (#11598) 2023-12-18 13:05:06 +00:00
Peter Nelson d6515d6c98
Fix 0a8bcdd: Scaling non-sprite fonts does not depend on _font_zoom changing. (#11579) 2023-12-13 19:51:44 +00:00
Peter Nelson 0a8bcdd344
Change: Be selective about clearing sprite/font caches on interface scale change. (#11576)
Sprite cache contains all zoom levels anyway, so does not need to be reloaded.

Font cache does not need to be clear if the font zoom hasn't changed, i.e. when changing the max sprite zoom level setting.
2023-12-11 21:03:54 +00:00
Peter Nelson dc27f1649a Fix e2425b7: Sprites no longer refreshed if max zoom level changed.
Handle this via AdjustGUIZoom() instead.
2023-12-11 14:16:49 +00:00
Peter Nelson e2425b72c1 Fix: Don't implicitly ReInit all windows after updating the character width cache.
This caused duplicate ReInit when changing interface scale.
2023-12-07 23:58:32 +00:00
Peter Nelson 6f7153bf71
Codechange: Make a generic DrawRectOutline function from DrawOutline. (#11524)
This allows drawing an outline from Rect, not just constrained to a Widget's Rect. And reduces duplication a little.
2023-11-30 18:10:07 +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 d04fd4602d Codechange: Assert that max width passed to GetStringHeight is non-zero.
Max width of zero will cause text layouters to crash, potentially after exhausting memory first.
2023-11-20 23:09:20 +00:00
Peter Nelson 58c037fba0 Change: Increase finance window lines (and underlines) with interface scale. 2023-11-15 12:43:44 +00:00
Peter Nelson d19832569e
Cleanup: No need to cast `const Font *` to itself. (#11395) 2023-10-25 13:08:07 +00:00
Rubidium c9276c2959 Codechange: replace x.size() == 0 with x.empty() 2023-10-20 23:05:43 +02:00
Niels Martin Hansen 4765d0f8c2 Change: Text Layouter support querying all lines for character at pixel 2023-09-13 16:11:08 +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
Patric Stout 0d840b4570 Codechange: remove queue_wrap / last_position from mouse movement
No backend uses it anymore, so also no longer any need to support
it.
2023-06-04 00:40:56 +02:00
Patric Stout e83f244750 Codechange: simplify UpdateCursorPositionRelative
The function is only called with fix_at=true, so don't support
the other cases.
2023-06-04 00:40:56 +02:00
Rubidium 63d9bb93b8 Codechange: migrate from C-style GetString to C++-style GetString 2023-05-21 21:17:12 +02:00
Rubidium 3323402aaa Codechange: rename smallvec_type to container_func and use only when needed 2023-05-20 16:53:10 +02: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
Patric Stout 60399e17bd Codechange: C++-ify the Layouter and related functions
They all now access a std::string_view, instead of a "const char *"
or std::string (in some cases).

Additionally, GetCharAtPosition and friends now return an index
instead of a "const char *", as it makes for a more clear interface.
2023-05-08 19:21:42 +02:00
PeterN db573c8742
Fix #10660: Sprite Font scale affected by viewport zoom level limits. (#10668) 2023-04-17 00:14:03 +02:00
PeterN e97bf271dc
Codechange: Make SpriteType, CargoSortType, SourceType and ScriptType enum classes. (#10663)
This avoids a (soft) namespace conflict between the four ST_* enums.
2023-04-16 20:00:55 +01:00
rubidium42 6ba55e663e Codechange: do not hide variables with other variables 2023-01-29 07:21:34 +01:00
Patric Stout 1fb101eabb
Codechange: address CodeQL issue "Multiplication result converted to larger type" (#10306)
Most are very unlikely to ever be triggered in our codebase; two
stand out: linkgraph and money cheat. Those, potentially, could
wrap earlier than expected.
2023-01-02 20:30:02 +00:00
PeterN f7e2b6ef12
Change: Make vehicle list dropdown buttons resize to fit strings. (#10286) 2022-12-27 18:39:37 +00:00
Peter Nelson 9666e46739 Feature: Variable GUI scale.
GUI scale is now variable from 100% to 500%, and no longer restricted to
powers-of-2.
2022-11-12 18:28:39 +00:00
Peter Nelson 062ea68422 Change: Scale position of font shadow. 2022-11-12 18:28:39 +00:00
Peter Nelson 123983743f Change: Add optional text labels to slider widget. 2022-11-12 18:28:39 +00:00
Bouke Haarsma 45d98f689a Fix #9993: Handle DPI changes on macOS and Windows 2022-10-16 16:52:14 +02:00
PeterN f279fc5772
Fix: DrawStringMultiLine() could overdraw (#10014)
This function did not take the line height into account when checking text will fit before the bottom bounds.
2022-09-10 17:48:38 +01:00
Michael Lutz 57b992717b Codechange: Extend DrawSpriteToRgbaBuffer to work with 8bpp blitters. 2022-01-01 12:19:30 +01:00
Michael Lutz f40e82a19d Fix #9743: [OSX] Don't try to render touchbar sprites with invalid zoom level. 2022-01-01 12:19:30 +01:00
Danny de Bruijne 753b1d7e15 Feature: Add selected toolbar buttons to MacBook Pro Touch Bar 2021-09-23 21:03:00 +02:00
Patric Stout 0013673faf Change: prevent palette updates during copying to the video driver
ThreadSanitizer rightfully notices that the game-thread could
update the palette while the draw-thread is copying it for local
use. The odds of this are very small, but nevertheless, it does
carry a very good point.

It wouldn't hurt the application in any way, but it might cause
visual glitches on the screen.
2021-06-26 20:28:05 +02:00
Patric Stout 74186998a2 Codechange: use _cur_palette the same in all the drivers
It was a bit of a mixed bag. With this change, gfx.cpp is in
control who accesses _cur_palette from the video-drivers.
2021-06-26 20:28:05 +02:00
Patric Stout c12a152ec9
Fix: thread safety issue during exiting the game (#9380)
_exit_game is read by the draw-thread to know when to exit, but
most of the time written by the game-thread.
2021-06-17 18:58:59 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
Michael Lutz 418e0ea85f Codechange: Use dynamic string list for contents of land info window. 2021-06-12 22:30:38 +02:00
rubidium42 cb89d22cf2 Codechange: add DrawString(Multiline) that accepts std::string& 2021-05-06 21:45:36 +02:00
Peter Nelson 4791ff2862 Fix: Recalculate padding and minimum sizes when GUI or Font zoom is changed. 2021-04-30 17:08:15 +01:00
Peter Nelson 2efa390a7d Codechange: Simplify calling of DrawCharCentered() 2021-04-30 17:08:15 +01:00
Patric Stout 4866e43862
Codechange: rework codeflow introduced in 098d5b22 (#8837)
It didn't sit well to me, how I wrote the commit initially. First
casting a variable into another, only to write it back into the
originally feels wrong.

This flow makes a bit more sense to me.
2021-03-10 13:57:52 +01:00
Patric Stout 970fedd78c Add: make modal windows update more smooth
Basically, modal windows had their own thread-locking for what
drawing was possible. This is a bit nonsense now we have a
game-thread. And it makes much more sense to do things like
NewGRFScan and GenerateWorld in the game-thread, and not in a
thread next to the game-thread.

This commit changes that: it removes the threads for NewGRFScan
and GenerateWorld, and just runs the code in the game-thread.
On regular intervals it allows the draw-thread to do a tick,
which gives a much smoother look and feel.

It does slow down NewGRFScan and GenerateWorld ever so slightly
as it spends more time on drawing. But the slowdown is not
measureable on my machines (with 700+ NewGRFs / 4kx4k map and
a Debug build).

Running without a game-thread means NewGRFScan and GenerateWorld
are now blocking.
2021-03-10 13:41:18 +01:00