Commit Graph

167 Commits

Author SHA1 Message Date
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
6f35f3274f
Fix ab1a4c6c: Crash if the "No Music" set is loaded because there is no current set_index. (#11511)
Add a helper function to get the current set_index which which checks it is in range.
2023-11-29 02:30:10 +00:00
Peter Nelson
519fe33175
Fix ab1a4c6c: Changing baseset/playlist while shuffle is on does not change song. (#11510)
The change-playlist function relied on toggling shuffle to restart playing which is no longer the case, so always handle it when changing playlist instead.
2023-11-28 17:44:31 +00:00
Peter Nelson
ab1a4c6c80 Change: Don't restart playback when toggling playlist shuffle.
Instead update the selected playlist entry for the current song.
2023-11-27 23:16:41 +00:00
Peter Nelson
6c91c4b99d Fix: Invalidate playlist window when (un)shuffling playlist. 2023-11-27 23:16:41 +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
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
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
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
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
Rubidium
3323402aaa Codechange: rename smallvec_type to container_func and use only when needed 2023-05-20 16:53:10 +02: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
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
Peter Nelson
e999aa2923 Fix: Don't (briefly) switch from title-only playlist on menu screen.
Switching playlist while on the menu screen now only changes the playlist
that will be used when out of the menu screen.
2023-03-09 20:35:24 +00:00
Peter Nelson
3b90b85439 Change: Allow jukebox lists to fill window width. 2023-03-09 20:35:24 +00:00
Peter Nelson
0c4e2ce114 Change: Resize jukebox when changing music set. 2023-03-09 20:35:24 +00:00
Peter Nelson
1ec34acb51 Fix: Truncated music-set song names cause warning log.
The music-set does not need to be selected for this to occur.

Resolved by using std::string instead of fixed buffer for song names,
which avoids manual string copying and removes the length limit.
2023-03-09 20:35:24 +00:00
Peter Nelson
890b2666d3 Change: Use scaled WidgetDimensions. 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
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
Jonathan G Rennison
0fae0599b7 Fix: Data race on effect volume setting with mixer thread 2022-11-11 23:48:24 +01:00
PeterN
0bac74ec2b
Fix #10038: Missing upper bounds check when loading custom playlists (#10039) 2022-09-21 08:31:59 +01: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
Niels Martin Hansen
785e42a6f9 Feature: Volume sliders in Game Options window 2021-04-09 12:18:52 +02:00
Niels Martin Hansen
88c92f7b7c Codechange: Move volume control slider logic to separate functions 2021-04-09 12:18:52 +02:00
Charles Pigott
9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
Michael Lutz
a49fdb7ebb Codechange: Store base set related texts in std::strings. 2020-05-21 20:02:34 +02:00
Milek7
a411ce18c9 Fix: avoid using string pointer after scope end 2020-01-12 15:20:08 +01:00
Niels Martin Hansen
f02b643a44 Change: Show volume sliders with wedges instead of boxy slider 2020-01-07 18:13:58 +01:00
S. D. Cloudt
13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Michael Lutz
c7b9987d08 Codechange: Switch DropDownList to directly use std::vector, thus making AutoDeleteSmallVector obsolete.
DropDownListItem are strongly managed using std::unique_ptr to ensure leak-free handling. Appropriate use
of move-semantics make intent a lot clearer than parameter comments and allows the compiler to generate
copy-free code for most situations.
2019-04-09 22:45:15 +02:00
peter1138
317f69c152 Codechange: Use override specifier in Window-derived classes. 2019-03-24 16:10:04 +01:00
Peter Nelson
6dfe36b5cd Change: Make volume slider widget capture mouse when clicked.
This makes the slider continue to respond even when mouse cursor
is no longer over the widget.
2019-02-21 08:11:35 +00:00
Niels Martin Hansen
c618a7c093 Fix 6298b96: Changing music set did not save new setting 2018-11-25 00:47:56 +01:00
Charles Pigott
52ed3bcbaa Remove: A few bits of dead code 2018-10-31 12:41:49 +01:00
Niels Martin Hansen
336d6cab68 Fix 6298b96: Playlist window not drawing playlist
Copy-paste error in change to remove C++11 usage...
2018-06-25 00:00:56 +02:00
Niels Martin Hansen
6298b96571 Change: Modernise music control logic implementation (#6839)
Rewrite of almost the entire music control logic to a more modern style, hopefully also easier to understand. The old playlist handling made it look like arcane magic, which it doesn't have to be.

- Playlists are now stored in std::vector of objects instead of arrays of bytes with magic sentinel values, that need to be rotated around all the time. Position in playlist is stored as a simple index.
- The theme song is now reserved for the title screen, it doesn't play on any of the standard playlists, but is still available for use on custom playlists.
- When the player enters/leaves the game from the main menu, the music always restarts.
- Playback state (playing or not) is kept even if music becomes unavailable due to an empty playlist (or an empty music set), so it can restart immediately if music becomes available again.
- The shuffle algorithm was changed to a standard Fisher-Yates.
- Possibly better behavior when editing a custom playlist while it's playing.
- Custom playlists should be compatible.
- Framework for supporting custom playlists with songs from multiple music sets.
2018-06-24 20:06:05 +02:00
Niels Martin Hansen
a1b7812c7e Change: Improved looping of title song 2018-06-15 23:09:17 +02:00
Niels Martin Hansen
f946b3da56 Codechange: Pass a MusicSongInfo struct instead of bare filename to music drivers.
Preparation for later extending the info passed to music drivers.
2018-06-05 22:58:35 +02:00
Niels Martin Hansen
19f5a6cbb0 Feature #6090: Change music set during gameplay 2018-04-29 19:26:05 +02:00
Niels Martin Hansen
430e20f7e4 Fix: Clipping issues with volume sliders in Music GUI
Tested with various languages and GUI font sizes, should look good everywhere.

Also clamps near-end values to minimum and maximum so 0 and 127 are possible to achieve even on small GUI sizes (like the default.)
2018-04-29 19:26:05 +02:00