Commit Graph

52 Commits (86cb184eb4401b2cd77fa2404cac8dcec6b9a7cf)

Author SHA1 Message Date
Rubidium 86cb184eb4 Codechange: use std::source_location over __FILE__ and __LINE__ for WindowDesc 3 months ago
Loïc Guilloux 845b894fd8
Remove: [Script] random_deviation from setting description table (#12221) 3 months ago
Peter Nelson d4f0f0e2c5
Codechange: Use `GetVisibleRangeIterators()` in more places. (#12190)
This replaces more first/last index calculation, along with indexed array/vector access, with iterator access instead.
3 months ago
Loïc Guilloux 977aba73be
Change: Store running AI config inside Company (#12003) 4 months ago
Loïc Guilloux 4e26e33805
Change: Improve ScriptSettings windows (#11958) 4 months ago
Peter Nelson fef0bfcfd3
Fix: TextfileWindow called virtual methods before constructor completed. (#11889)
SetStringParameters() was called during widget tree init in the constructor.

Calls within a constructor cannot call the derived classes methods. This would result in invalid data being passed to the string system, which could then crash.
4 months ago
Rubidium aa5ba5bd7f Codechange: allow certain enumeration to be added
Otherwise C++20 doesn't like it.
5 months ago
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.
5 months ago
Loïc Guilloux b18e78e21d
Change: Redesign script debug window (#11782) 5 months ago
Loïc Guilloux f56a2d0f82
Fix: Missing invalidations on gui.ai_developer_tools change (#11664) 5 months ago
Peter Nelson 7124b4eef1 Codechange: Use std::unique_ptr for all NWidgets. 5 months ago
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.
5 months ago
Peter Nelson b86182ab84 Codechange: Use std::map to provide indexed widget access.
This removes the need to determine the biggest widget index and replaces C-style memory handling.
5 months ago
Loïc Guilloux 6c5a4aa2cb
Fix 2d3af14: Don't draw script log over panel borders (#11621) 5 months ago
Loïc Guilloux af8b8c2cfc
Fix 4a2038e301: fully restore script break filter on reopen (#11622) 5 months ago
Loïc Guilloux 2d3af14181
Add: Horizontal scroll for script debug log (#11597) 6 months ago
Peter Nelson 0ca4b4e146 Change: Allow opening multiple script debug windows by holding Ctrl. 6 months ago
Peter Nelson 4a2038e301 Codechange: Make script debug window filter state per-window. 6 months ago
Peter Nelson 58c252b81a Cleanup: Remove unnecessary pressed button offset code. 6 months ago
Peter Nelson aae6e0481e
Codechange: Rearrange AI/GS debug window following invalidate/set state/draw pattern. (#11483)
The AI/GS window updated its state as it was drawn, and would redraw again if some state had changed.

Instead, update state either during OnInvalidateData or before any drawing commences.
6 months ago
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(...)`.
6 months ago
Michael Lutz 86e28e79fb Fix #11402: Make string filter locale-aware. 7 months ago
Peter Nelson 18fb8e153f Codechange: Add __FILE__/__LINE__ of WindowDesc to WindowDesc.
This is to allow unit-tests to produce more useful output.
7 months ago
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.
8 months ago
frosch f40816503f Codechange: Add enum items for dynmically created setting dropdowns. 9 months ago
frosch b5885295f0 Codechange: Use parameters, which should be used. 9 months ago
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 9 months ago
Rubidium 8ab0936491 Codechange: use parameter pack/folding instead of va_arg macros for widget states 9 months ago
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.
9 months ago
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
11 months ago
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.
12 months ago
Rubidium 7c37dcb8e3 Fix: do not use {STRING} when {STRING1} or {STRING2} is needed 12 months ago
PeterN f814c86389
Codechange: Reorganise hotkey initialisation. (#10951)
Hotkeys are now initialized inline, and use std::vector instead of
separate static C-arrays and std::string instead of char *. The list end
marker is no longer required.
1 year ago
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.
1 year ago
Rubidium ab51175db2 Codechange: use std::string for script config 1 year ago
Rubidium 20ff0bccd7 Codechange: use std::string to store script GUI's break string 1 year ago
Rubidium 9f2fc860ad Codechange: use std::optional<std::string> for changing the script over char * 1 year ago
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.
1 year ago
Peter Nelson a8c0d16371 Cleanup: Use std::advance instead of for-loop. 1 year ago
Peter Nelson 68782f951b Cleanup: Vector supports random access. 1 year ago
Rubidium 1ae7eb1594 Codechange: use std::map over SmallMap and std::string of stredup(char*) 1 year ago
Peter Nelson 6202eae9d5 Codechange: Rely on Scrollbar::SetPosition to clamp.
Manually clamping scrollbar bounds before calling `SetPosition()` is doubling up work that the function already does.
1 year ago
Peter Nelson d2034d9c38 Codechange: Scrollbar methods now accept size_t.
This clears up a lot of casts from size_t to int.
1 year ago
PeterN b67cf7f94a
Change: Replace ScriptLog data array with std::deque. (#10770)
Due to cyclic header dependency this requires moving the data types used
by ScriptLog out of the ScriptLog class.
1 year ago
Rubidium 877349c13d Codechange: use std::string for text file name resolution 1 year ago
Patric Stout ed83c4b0da
Change: replace per-AI "start_date" with a global "competitors_interval" (#10653)
The per-AI "start_date" is a lot of custom code, and was rarely
used in the way it was meant.

While at it, also ported this part over to the new timer system.
1 year ago
Patric Stout 1ba4dcc924 Codechange: migrate all Window-related timers to the new framework
This means we also say goodbye to GUITimers.
1 year ago
Peter Nelson e5af5907ec Change: Make all dropdown lists extend width if necessary.
This removes the auto_width parameter from ShowDropDown(At).
1 year ago
Loïc Guilloux e4c511d403
Fix #10578: Allow to select any version of AI/GS from GUI (#10604) 1 year ago
PeterN 2d3250923c
Fix #10554: Let Scrollbar::SetPosition clamp instead of assert. (#10555) 1 year ago