Commit Graph

658 Commits

Author SHA1 Message Date
Peter Nelson 58c252b81a Cleanup: Remove unnecessary pressed button offset code. 2023-12-05 21:12:35 +00:00
Peter Nelson 1084ab4b66 Add: Website button to Game Options window for basesets.
This links to the optional "url" item in the baseset's [metadata] section.
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 49532914dd Change: Use CRTP-mixins to compose dropdown list items.
This allows list items to built from component parts as required, and additional
functionality is added:

* Icons and text can be positioned at the start or end of the space (templated.)
* Font size of text can be changed (templated.)
* Palette of sprites can be set (runtime.)
2023-12-02 15:23:05 +00:00
rubidium42 27082f9efa Codechange: pass std::string references to OpenBrowser 2023-11-29 02:02:30 +01: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 c80fa7d752
Codechange: Simplify setting minimum width for game options dropdown lists. (#11474)
Height isn't necessary as drop down controls already have sufficient height, so we can use GetDropDownListDimension() to get the width.
2023-11-20 00:44:06 +00:00
Peter Nelson 293a26f248
Change: Use sparse padding and SETTING_BUTTON sizes for custom currency window. (#11472) 2023-11-19 21:12:55 +00:00
Peter Nelson 17ceed0241
Change: Use sparse padding for Game Options window. (#11463) 2023-11-16 17:06:38 +00:00
Peter Nelson bd2ddb07ca
Change: Move baseset missing/corrupted files label to list item. (#11455)
This allows any baseset error to be displayed in the drop down list so it is more easily visible, and avoids wasted space in the layout.
2023-11-10 12:25:56 +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
frosch e81313e93e Feature: Base graphics can offer parameters for additional settings. 2023-10-31 01:41:50 +01:00
frosch 0b7ecf6102 Codechange: use the shortname as unique id to identify the base graphics in openttd.cfg. 2023-10-31 01:41:50 +01:00
frosch 97df27e41f Codechange: Store base graphics settings in a separate section in openttd.cfg. 2023-10-31 01:41:50 +01:00
Bernhard Reutner-Fischer ac42dea7b2 Codechange: Remove unused parameter for Height()
DropDownListItem::Height does not need to take an argument so remove it

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2023-10-21 18:53:35 +02: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
Peter Nelson 49dae08a3b Codechange: Add missing override specifiers. 2023-09-25 21:27:45 +01:00
frosch f40816503f Codechange: Add enum items for dynmically created setting dropdowns. 2023-09-20 22:35:32 +02: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
Tyler Trahan 77173a6a10 Codechange: Move date consts and functions to CalendarTime and TimerGameCalendar classes 2023-09-10 08:40:25 -04:00
Patric Stout 337b7b0c63
Fix 8c9ecde9: actually remove autosave_interval from setting window (#11260) 2023-09-04 11:18:47 +00: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
mrmbernardi a5c8365aa4
Feature: Setting to disallow level crossings with competitors (#10755) 2023-09-02 12:46:24 +02:00
Tyler Trahan c7b51a8c3a
Codechange: Use proper date types in various places (#11177) 2023-08-11 13:32:42 +00:00
Henry Wilson a9c65a69d0 Feature: Add config option to set default company secondary colour for new games
This does duplicate translation strings for the colours
2023-07-26 16:22:30 +02:00
MasonGulu 0be27778af
Add: alternative setting for right-click close window option to exclude pinned windows (#10204) 2023-07-19 23:24:22 +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 4f4810dc28 Fix: store autosave settings under the new names 2023-07-19 13:17:50 +02:00
glx22 46b504a700 Fix: ini_key issues reported by the script 2023-07-14 14:32:46 +02:00
merni-ns 161cc04b8a Fix #11087: Disable base graphics/sound dropdown outside main menu 2023-07-01 19:03:45 +02:00
PeterN d140acf34e
Fix: Setting tree lines drawn incorrectly for RTL languages. (#11070) 2023-06-25 19:32:53 +01:00
Peter Nelson 40a9b080aa Fix: Ensure settings page label is orange. 2023-06-25 17:22:02 +01:00
Peter Nelson 9dd9b8ec74 Fix #11054: Prevent translation of currency codes.
Most languages stick with the 3-letter latin currency codes in the name
string, however some translations are... clever... and use the currency
symbol instead. Whilst this may look nice, it can cause issues with fonts
as some scripts have a specific limited set of fonts which do not include
these symbols.

Instead, hard code the currency code list and add it when drawing the
currency name.
2023-06-23 16:47:32 +01: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 74924c8186 Codechange: includes must be before 'safeguards.h' 2023-06-18 21:22:14 +02:00
Rubidium 7c37dcb8e3 Fix: do not use {STRING} when {STRING1} or {STRING2} is needed 2023-06-14 09:44:06 +02:00
Patric Stout 772729cc7d
Fix: when syncing width of GUI items, take padding into account (#10915) 2023-06-05 10:27:04 +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 199e41c762
Codechange: use default dtor instead of empty (#10826) 2023-05-14 23:31:03 +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
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
Peter Nelson e6740046ee Codechange: Use range-for iteration. 2023-05-11 07:58:55 +01:00
Rubidium 68ff3fd062 Change: include fmt.h C++ headers in stdafx.h
This to prevent compilation issues between runs with and without precompiled
headers. Also remove the headers from the rest of the code base as they are
not needed there anymore, although they do relatively little harm.
2023-05-08 16:49:23 +02:00
Rubidium 19ec4e8beb Codechange: replace ClampToI32/U16 with ClampTo<int32_t/uint16_t> 2023-05-06 21:26:13 +02:00
Rubidium 877349c13d Codechange: use std::string for text file name resolution 2023-05-05 08:54:29 +02:00
glx22 49eb638563 Codechange: Remove STR_ORANGE_STRING1_WHITE and STR_ORANGE_STRING1_LTBLUE. 2023-05-05 07:07:54 +01:00
Peter Nelson 61407840c6 Codechange: Remove STR_BLACK_RAW_STRING. 2023-05-05 07:07:54 +01:00
Peter Nelson 0880616851 Codechange: Remove various STRING strings. 2023-05-05 07:07:54 +01:00
PeterN cc44aa7438
Change: Split Game options into General, Graphics and Sound tabs. (#10674) 2023-05-01 12:58:22 +01:00
Patric Stout 36a0818bc5
Remove: buying/selling/owning company shares (#10709) 2023-04-29 10:16:49 +02:00
Patric Stout f5fad88723
Change: base autosaves intervals on real time (instead of game time) (#10655)
There are two fundamental issues with autosave:
- When fast-forwarding, it saves way too often
- When paused, it never saves

Both makes no sense. Autosaves are meant to prevent you from
accidentally losing your work. The emphasis on "your" work.

To solve both issues, the autosave now works on real time. You
can select every 10 / 30 / 60 / 120 minutes, which are similar to
what the setting was in game-months.

When you pause, autosaving will stop. Unless you make any change
to the game; then it will continue to make autosaves, even so
the game is paused. Unpausing / pausing resets this mechanism.
2023-04-27 15:21:29 +00:00
Peter Nelson b8f0513a72 Change: Draw and size video driver info like base set info.
This allows very long video driver information strings to wrap instead
of making the game options window very wide.
2023-04-25 13:27:22 +01:00
Peter Nelson 9aee502838 Change: Size Game Options description widgets after initial sizing.
Trying to update text widgets with free flowing multiline text during
UpdateWidgetSize(), as the final width is not yet known and so the
calculated height being incorrect, usually resulting in one or more
empty text lines.

The solution is to update the widget heights afterwards during
OnResize(), at which point the final widths are known. The window is
then resized if needed.

(Note this technique needs more attention if width can also change.)
2023-04-25 13:27:22 +01: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
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
PeterN daacde4496
Fix #10147: Sound effect volume slider no longer set volume. (#10228) 2022-12-10 15:51:45 +00: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
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 920e588334 Change: Use standard dimensions instead of custom widths. 2022-11-12 18:28:39 +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 dd90d79e7b Add: Setting to toggle thin vs chunky (scaled) bevels. 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 61da064b82 Fix: Settings GUI sprite size. 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
Peter Nelson 1180c95372 Codechange: Add parameters to change range of slider widget. 2022-11-12 18:28:39 +00:00
Peter Nelson d35f1d3d06 Codechange: Rename slider widget functions to be less specific. 2022-11-12 18:28:39 +00:00
Peter Nelson fea7247072 Change: Use standard 'frametext' padding for settings window. 2022-11-12 18:28:39 +00:00
Aaron Kofsky ede0560f9b
Feature: Add buttons to toggle music in the Game Options menu (#9727) 2022-11-08 18:21:52 +00:00
hallonsoda79 0d51460f27
Fix #10023: Allow negative input in text fields when needed (#10112) 2022-11-02 20:54:07 +01:00
Peter Nelson 33704269bd Change: Simplify widget layout of settings window. 2022-10-11 08:36:59 +01:00
Niels Martin Hansen 345dcd3c7b Add: Show current video driver info in Options window 2022-05-03 21:03:30 +02:00
Tyler Trahan 41de69c5b7 Feature: Improved Finance window 2022-04-25 21:51:51 +02:00
Tyler Trahan e79724ea22
Feature: Alternative linkgraph colour schemes (#9866) 2022-04-25 19:32:55 +02:00
Guillaume Renoult c38af72978
Update: add setting to hide news about competitors vehicle crash (#9653) 2021-11-07 19:54:50 +01:00
Charles Pigott e09f251fc6 Fix #9614: Refresh rate dropdown was still active when vsync was enabled 2021-10-17 19:25:03 +01:00
Tyler Trahan 7469f00c5b
Feature: Hide block signals in GUI by default (#8688) 2021-09-05 20:22:27 +02:00
Patric Stout fa1e27994d Feature: allow the use of TURN to connect client and server together
TURN is a last resort, used only if all other methods failed.
TURN is a relay approach to connect client and server together, where
openttd.org (by default) is the middleman.

It is very unlikely either the client or server cannot connect to
the STUN server, as they are both already connected to the Game
Coordinator. But in the odd case it does fail, estabilishing the
connection fails without any further possibility to recover.
2021-07-20 19:57:23 +02:00
Rubidium 281a65b3e1 Cleanup: simplify some boolean expressions 2021-06-17 16:18:30 +02:00
Tyler Trahan d09210e1c6 Feature: Configurable subsidy duration 2021-06-10 23:26:16 +02:00
Patric Stout feb2ddbefa
Codechange: rename SettingGuiFlag to SettingFlag (#9332)
It is a lovely organicly grown enum, where it started off with
GUI-only flags, and after that a few flags got added that can be
considered GUI-only (the GUI disables/enables based on them), to
only have flags added that has nothing to do with the GUI.

So be less confusing, and rename them to what they do.

Additionally, I took this opportunity to rename 0ISDISABLED to
reflect what it really does.
2021-06-03 21:18:29 +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
rubidium42 8372c679e3 Codechange: add helper functions to read an int setting value 2021-05-27 18:49:43 +02:00
rubidium42 86c9ef8134 Codechange: remove SettingDescType in lieu of the actual classes 2021-05-27 18:49:43 +02:00
rubidium42 0d6597a9e6 Codechange: move bits of SettingDesc down to the appropriate sub classes
And by doing so remove the hack where ints were put into pointers so "def" could either be an int or a string
2021-05-27 18:49:43 +02:00
rubidium42 f58611298e Codechange: use IntSettingDesc in the settings GUI 2021-05-27 18:49:43 +02:00
rubidium42 cf6b91f30f Codechange: do not use SettingDescBase directly when not needed 2021-05-27 18:49:43 +02:00
rubidium42 425d50372f Codechange: let SettingDesc extend SettingDescBase 2021-05-27 18:49:43 +02:00
rubidium42 8ffb4122df Codechange: just pass the SettingDesc to SetSettingValue and remove distinction between (non)company 2021-05-27 18:49:43 +02:00
rubidium42 65cbde4b30 Codechange: move currency settings to std::string 2021-05-13 23:13:17 +02:00
Peter Nelson 8321ef0061 Codechange: Set specific widgets dirty instead of window. 2021-05-08 09:52:54 +01:00
rubidium42 6bca9e090d Codechange: add SetDParamStr that accepts std::string& 2021-05-06 21:45:36 +02:00
Peter Nelson d32df00b5c Codechange: No longer necessary to manually resize volume sliders. 2021-04-30 17:08:15 +01: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
rubidium42 b54d8a49fb Feature: allow non-ASCII currency separators 2021-04-27 19:41:51 +02:00
frosch 37222c3fa2 Change: treat languages as finished, if translations are 75% completed.
Unfinished translations are not auto-picked from the locale.
In release builds, unfinished translations are not offered in the GUI.
Unfinished translations are available in non-release builds, or by editing openttd.cfg.
2021-04-22 22:16:56 +02:00
frosch a9740cef82 Add: show completion progress of languages in the language dropdown for non-release builds. 2021-04-22 22:16:56 +02:00
Patric Stout d50b934bb4 Change: reworked how the Game Option display options are drawn
"Hardware acceleration" was not aligned with its checkbox. So instead
of drawing the labels left and the options right, now draw settings
one by one with a spacer between label and option to get the right
spacing.

Also, use SetPIP instead of repeating a SetPadding for all but
last element.
2021-04-11 14:26:00 +02:00