Commit Graph

19 Commits

Author SHA1 Message Date
Rubidium 87dbd4a833 Codechange: use ranged for loop to determine widest title 2024-04-28 19:42:44 +02:00
Peter Nelson 33aedc43a5 Codechange: Shrink GUIList vectors less often, reserve before use.
After sorting and filter lists for GUI, we often shirnk them to reduce size. However this has very little benefit:

1) The memory has already been allocated, so it doesn't prevent that memory being required.
2) It causes a new allocation and copy when the vector is shrunk, actually using more memory.
3) The list is in window state, so the lifetime is only while the window is open.
4) When a filter is clearer, the original size will be needed again, which will cause another allocation.

In fact it is beneficial to reserve to the known maximum in most cases, so do that instead.
2024-04-27 19:25:34 +01:00
Peter Nelson 40fa45a76a Codechange: Emplace std::pair into vectors.
This creates the pair in the vector, instead of creating it then copying it in.
2024-04-20 10:25:20 +01:00
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 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
dP 9a2f247de9 Fix: Display rank correcly with more than 15 companies in a league table 2024-02-01 20:17:31 +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 8510f7bd00
Fix: NWidgetParts must use unscaled dimensions. (#11794) 2024-01-15 23:02:25 +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 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 938c8339d2 Codechange: Ensure space between `for`/`if` and `(`. 2023-11-09 20:15:38 +00:00
Peter Nelson d4a77411a5
Fix: Some NWidget lists were not properly closed. (#11425) 2023-11-03 08:17:26 +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 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
glx22 46b504a700 Fix: ini_key issues reported by the script 2023-07-14 14:32:46 +02:00
Peter Nelson 61407840c6 Codechange: Remove STR_BLACK_RAW_STRING. 2023-05-05 07:07:54 +01:00
dP 5e14a20b3b
Feature: [GS] Scriptable league tables (#10001) 2022-11-26 18:03:03 +01:00