Commit Graph

41 Commits

Author SHA1 Message Date
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 86cb184eb4 Codechange: use std::source_location over __FILE__ and __LINE__ for WindowDesc 2024-03-10 10:14:20 +01:00
Loïc Guilloux 845b894fd8
Remove: [Script] random_deviation from setting description table (#12221) 2024-03-05 12:41:04 +01:00
Loïc Guilloux 4e26e33805
Change: Improve ScriptSettings windows (#11958) 2024-02-02 18:08:05 +00: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 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 6e8c27b8e5
Change: Hide bevel for resizeable sparse layout windows. (#11572)
When clicked, the button is still highlighted to show that it is active.

The bevel is controlled with widget_data by RWV_SHOW_BEVEL or RWV_HIDE_BEVEL values.
2023-12-10 17:25:36 +00:00
Peter Nelson 2272e8fe0e Add: Website button for Game Script settings window. 2023-12-03 18:52:33 +00:00
Peter Nelson 9a92e02fa7
Change: Add tooltips for text file buttons, and shorten Website / Readme buttons. (#11534) 2023-12-03 16:54: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 cdb4e98a15
Change: Use sparse padding for AI/GS settings windows. (#11466) 2023-11-16 20:02:07 +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
Peter Nelson f379b31e28 Add: data parameter in Window::Close method.
This allows passing data when closing a window, e.g. to indicate how it was closed.
2023-10-13 20:47:28 +01:00
frosch f40816503f Codechange: Add enum items for dynmically created setting dropdowns. 2023-09-20 22:35:32 +02:00
frosch b5885295f0 Codechange: Use parameters, which should be used. 2023-09-19 22:49:59 +02: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
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 d42a78f3e8
Codechange: Make DropDownListStringItem preformat and remove other implementations. (#11063)
Having to choose between DropDownListStringItem, DropDownListCharStringItem, and DropDownListParamStringItem depending on whether to draw a StringID, a raw string, or a StringID with extra parameters was needlessly complex.

Instead, allow passing a StringID or raw string to DropDownListStringItem. This will preformat the StringID into a raw string, and can therefore accept parameters via the normal SetDParam mechanism.

This also means that strings no longer need to be formatted on every draw.
2023-06-23 08:30:13 +00:00
Rubidium 7c37dcb8e3 Fix: do not use {STRING} when {STRING1} or {STRING2} is needed 2023-06-14 09:44:06 +02: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
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
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 68782f951b Cleanup: Vector supports random access. 2023-05-11 07:58:55 +01:00
Rubidium 1ae7eb1594 Codechange: use std::map over SmallMap and std::string of stredup(char*) 2023-05-09 23:14:48 +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 877349c13d Codechange: use std::string for text file name resolution 2023-05-05 08:54:29 +02:00
Patric Stout 1ba4dcc924 Codechange: migrate all Window-related timers to the new framework
This means we also say goodbye to GUITimers.
2023-04-15 13:58:55 +02:00
Peter Nelson e5af5907ec Change: Make all dropdown lists extend width if necessary.
This removes the auto_width parameter from ShowDropDown(At).
2023-04-13 20:57:47 +01:00
Loïc Guilloux e4c511d403
Fix #10578: Allow to select any version of AI/GS from GUI (#10604) 2023-04-07 19:33:07 +02:00
SamuXarick fde7028a95 Fix #10059: [Script] Let custom values on a config item be up to 10 digits + 1 for sign 2023-02-21 00:28:21 +01:00
glx22 b080f24bd8 Codechange: move windows common to AI and GS out of ai_gui 2023-02-05 19:27:25 +01:00
glx22 cef9931e53 Cleanup: GS don't have "start_date" 2023-02-05 19:27:25 +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
Artin Alavi 5d6cdf4385
Feature: Allow AI/GS to be fully modified in scenario editor (#10152) 2022-11-11 23:48:07 +01:00
Artin Alavi cbac243216
Feature: [UI] Split AI/Game Script configuration windows and add them to world gen window (#10058) 2022-11-10 21:39:09 +01:00