ModernUO/Projects/UOContent
Kamron Batman 65532ea887
feat: Adds optimized dynamic/static layout gumps (#1652)
# New Gump API
We are pleased to release a new API that is faster, allocates nearly zero memory, and still feels very similar to the original API. The API is broken into 3 types of gumps, dynamic, static with placeholders, and static without placeholders. 

### Dynamic Gumps
These gumps will inherit `DynamicGump` and are meant for gumps that have a dynamic layout. This includes specifying dynamic arguments to HtmlLocalized entries.

## Static Gumps 
Static gumps are those where the function to the build the layout is called only once and cached forever. They can optionally have placeholders. These placeholders allow the developer to specify the string values later, dynamically in a `BuildStrings` method on the gump. If a gump does not have any placeholders, the string entries will also be cached forever.

## Benchmarks
To make sure we were going in the right direction and not wasting time, we took copious benchmarks. Here are the final benchmarks for a really simple gump. 

Note:
* The majority of creating a gump is compressing the layout and the strings. Compressing each section takes ~6,000ns (12us total).

```cs
| Method                         | Mean         | Error        | StdDev       | Median       | Ratio | RatioSD | Gen0   | Allocated | Alloc Ratio |
|------------------------------- |-------------:|-------------:|-------------:|-------------:|------:|--------:|-------:|----------:|------------:|
| OldGump                        | 13,308.29 ns | 1,059.695 ns | 1,883.608 ns | 14,330.72 ns | 1.000 |    0.00 | 0.1526 |    2400 B |        1.00 |
| DynamicLayoutGump              | 13,357.86 ns |   129.144 ns |   226.185 ns | 13,323.60 ns | 1.029 |    0.17 |      - |      48 B |        0.02 |
| StaticLayoutDynamicStringsGump |  6,653.10 ns |    81.815 ns |   143.292 ns |  6,617.45 ns | 0.514 |    0.09 |      - |      40 B |        0.02 |
| StaticLayoutGump               |     86.33 ns |     0.760 ns |     1.350 ns |     86.07 ns | 0.007 |    0.00 | 0.0020 |      32 B |        0.01 |
```

# Non-Breaking Changes
* All gump components in the core have been moved to `Gumps/Legacy`.
* All legacy gumps will still inherit `Gump`, which now inherits `BaseGump`

# Special Thanks

Thank you to @stefanomerotta for considerable contributions/benchmarking/testing to make this effort a reality! We collectively went through over 10 iterations, but it is finally ready.
2024-04-25 22:40:30 -07:00
..
Accounting fix: Adds command help, webpage, and fixes issues with other commands (#1669) 2024-02-10 00:19:19 -08:00
Assistants fix: Fixes thread guard and cleans up incoming packet reader (#1641) 2023-12-19 17:04:09 -08:00
Commands fix: Change Decorate FindItem range from 0 to 1 (#1725) 2024-04-07 14:56:39 -07:00
Compression fix: Fixes directory copying (#1668) 2024-02-09 23:25:20 -08:00
Configuration chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Console feat: Adds console commands (#1714) 2024-03-30 09:40:43 -07:00
Context Menus cleanup: Fixes bugs and cleans up code (#660) 2021-07-19 20:49:59 -07:00
Engines feat: Adds optimized dynamic/static layout gumps (#1652) 2024-04-25 22:40:30 -07:00
Gumps feat: Adds optimized dynamic/static layout gumps (#1652) 2024-04-25 22:40:30 -07:00
Holiday Stuff fix: Optimizes gump relay info (Prep for Static Gumps) (#1698) 2024-03-07 20:54:53 -08:00
Items fix: Fixes champion drop logic (#1731) 2024-04-14 16:40:09 -07:00
Migrations fix: Fixes spawn entry migration (#1696) 2024-03-04 21:09:58 -08:00
Misc fix: Fixes mount stamina, adds Pub46+ Ethereal stamina (#1716) 2024-04-05 21:05:16 -07:00
Mobiles fix: BaseEscortable Destination not returned properly. (#1727) 2024-04-08 09:12:38 -07:00
Multis fix: Optimizes gump relay info (Prep for Static Gumps) (#1698) 2024-03-07 20:54:53 -08:00
Network feat: Adds optimized dynamic/static layout gumps (#1652) 2024-04-25 22:40:30 -07:00
Regions fix: Adds command help, webpage, and fixes issues with other commands (#1669) 2024-02-10 00:19:19 -08:00
Skills feat: Adds leather/metal food, fixes weapons/armors with wrong materials (#1718) 2024-04-04 19:43:02 -07:00
Special Systems fix: Optimizes gump relay info (Prep for Static Gumps) (#1698) 2024-03-07 20:54:53 -08:00
Spells feat: Adds optimized dynamic/static layout gumps (#1652) 2024-04-25 22:40:30 -07:00
Targets fix: Fixes the limitation on static tiles for harvesting (#1396) 2023-04-22 09:14:42 -07:00
Utilities fix: Fixes various mobile packets and setting serials (#1618) 2023-11-26 00:42:15 -08:00
World Saves fix: Archive locally is not an async function (#1735) 2024-04-21 08:08:12 -07:00
Module.cs fix: Fixes sending packets and sidesteps a major issue with stackalloc and PGO in .NET 8 (#1607) 2023-11-21 12:18:20 -08:00
UOContent.csproj chore(deps): Bump MailKit from 4.4.0 to 4.5.0 (#1732) 2024-04-15 18:31:16 -07:00