Commit Graph

322 Commits

Author SHA1 Message Date
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
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Rubidium 86cb184eb4 Codechange: use std::source_location over __FILE__ and __LINE__ for WindowDesc 2024-03-10 10:14:20 +01: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
Tyler Trahan 1e8aa9ce22 Add: Use more tooltips in World Generation GUI 2023-12-15 09:57:44 -05: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
Peter Nelson 4a5ab331e2
Change: Add extra padding to climate buttons to match pre-#11464. (#11525)
Padding used to be included in the SetMinimalSize() part which was removed, but also made it require specific sprite sizes.

This now adds padding on the already determined size, removing the need for hardcoding pixel dimensions and allowing the sprites to be any size.
2023-11-30 19:18:28 +00:00
Peter Nelson 7bee955a4b
Change: Set height of larger heightmap/scenario worldgen buttons by text height. (#11496)
This allows the button height to scale properly by font size.
2023-11-26 17:56:51 +00:00
Peter Nelson c2f19fed24
Fix: Widget without tooltip should use STR_NULL not STR_EMPTY. (#11482) 2023-11-21 19:35:47 +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 a58a043402
Fix 6065122: Missing SetFill on worldgen spacer. (#11477) 2023-11-20 19:31:26 +00:00
Peter Nelson 60651227a0
Change: Simplify world gen widgets and use sparse padding. (#11464) 2023-11-16 18:58:59 +00:00
Peter Nelson ab535c0a86
Codechange: Add base() method to StrongType to allow access to the base type without casting. (#11445)
This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
2023-11-06 20:29:35 +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
Rubidium adad078b55 Fix #11367, 7c37dcb: use STRING1 when the passed string can have a parameter 2023-10-14 12:15:25 +02:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
Rubidium 7ef22af2bb Codechange: introduce and use function to raise and dirty a set of widgets when they are lowered 2023-09-17 16:03:01 +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
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
Patric Stout 299570b2c1
Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761) 2023-08-12 18:14:21 +00:00
Patric Stout b7acf9e50e
Codechange: use TimerGameCalendar::Year and friends when working with years (#11188) 2023-08-12 16:02:31 +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
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
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 0880616851 Codechange: Remove various STRING strings. 2023-05-05 07:07:54 +01:00
Peter Nelson 4767641c8c Codechange: Remove various INT strings. 2023-05-05 07:07:54 +01:00
Peter Nelson d5fb9e7dc6 Codechange: Remove various DATE_LONG strings. 2023-05-05 07:07:54 +01:00
Tyler Trahan 6501f84b4a
Codechange: Move calendar date functions inside TimerGameCalendar (#10753) 2023-05-04 13:14:12 +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
Rubidium ee723f26ba Codechange: Make FileToSaveLoad's title std::string and simplify assignments 2023-04-29 13:23:34 +02:00
Peter Nelson 06b78a7299 Fix: Don't double-pad existing size when adding widget padding.
UpdateWidgetSize's size parameter already includes padding.
2023-04-12 18:43:15 +01:00
Tyler Trahan 2206c73156
Feature: Set a custom number of industries in map generation window (#10340) 2023-01-14 05:12:29 -05:00
Tyler Trahan 5a2907a99f
Change: Remove land generator setting from World Generation GUI (#10093) 2023-01-12 13:26:18 -05: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 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 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
Tyler Trahan 62a15734fe Codechange: Rename mapgen Sea Level string 2022-11-08 11:12:14 -07:00
Rubidium d5aafaee15 Codechange: rename and move some strings to make them more consistent with the rest of the strings 2022-11-02 17:58:44 +01:00
Peter Nelson dc1b84aa1e Cleanup: Text widgets are capable of drawing text without assistance.
Remove custom text drawing of some widgets in favour of standard text
widgets.
2022-10-16 14:24:51 +02:00
Peter Nelson fc944829e1 Change: Don't use zero-sized plane for World Generation window.
Use of zero-sized plane causes the window size calculation to change
depending on which plane is displayed. Instead use an empty plane so
that largest of the planes is taken into account for sizing.
2022-10-11 08:36:59 +01:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
glx22 5799402f7a Codechange: Rename window related DeleteXXX to match new behaviour 2021-05-29 21:08:25 +02:00
Patric Stout b136e65cf9
Change: reworked the debug levels for network facility (#9251)
It now follows very simple rules:
0 - Fatal, user should know about this
1 - Error, but we are recovering
2 - Warning, wrong but okay if you don't know
3 - Info, information you might care about
4 -
5 - Debug #1 - High level debug messages
6 - Debug #2 - Low level debug messages
7 - Trace information
2021-05-12 16:34:02 +02:00