feat: Consolidates staff gump layouts (#2404)
## Summary - Creates `PropsLayoutExtensions.cs` with reusable extension methods for both legacy `Gump` and `DynamicGumpBuilder` that encapsulate the repeating PropsConfig-style layout patterns (frame, header navigation, entry rows) - Converts all 12 standardized staff gumps to use the new extensions, reducing ~570 lines of duplicated layout code - Adds Type and Serial display to PropsGump and SkillsGump headers (e.g. `PlayerMobile (0x1)`) ### Extension methods provided | Method | Pattern | |--------|---------| | `AddPropsFrame` | Background + offset region + origin coordinates | | `AddPropsHeader` | 3-column: [Prev] [Title] [Next] | | `AddPropsHeaderWithBack` | 4-column: [Back] [Title] [Prev] [Next] | | `AddPropsEntryButton` | Label + action button | | `AddPropsEntryNameValue` | Name + Value + action button | | `AddPropsEntryTextInput` | Text input + action button | | `AddPropsEntryLabel` | Label only (no button) | | `AddPropsEntryType` | Full-width type label | | `AddPropsEntryBlank` | Separator row | ### Gumps converted PropsGump, GoGump, WhoGump, SkillsGump (frame+header), EditSkillGump, SetGump, SetObjectGump, SetPoint2DGump, SetPoint3DGump, SetTimeSpanGump (frame), SetListOptionGump (frame+header), CategorizedAddGump (frame+header) ## Test plan - [x] Verify `[props` gump displays correctly with type + serial in header - [x] Verify `[skills` gump displays correctly with type + serial in header - [x] Verify `[go` navigation gump works (prev/next/back) - [x] Verify property editing gumps (Set, SetObject, SetPoint2D, SetPoint3D, SetTimeSpan, SetListOption) - [x] Verify `[categorizedadd` gump works - [x] Verify `[who` gump works with pagination
This commit is contained in:
parent
c0d75562be
commit
8a34903326
13 changed files with 786 additions and 570 deletions
|
|
@ -21,8 +21,6 @@ namespace Server.Gumps
|
|||
|
||||
private const int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
|
||||
private const int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
|
||||
private readonly CAGCategory m_Category;
|
||||
|
||||
private readonly Mobile m_Owner;
|
||||
|
|
@ -50,64 +48,21 @@ namespace Server.Gumps
|
|||
|
||||
var count = Math.Clamp(nodes.Length - page * EntryCount, 0, EntryCount);
|
||||
|
||||
var totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID);
|
||||
AddImageTiled(
|
||||
BorderSize,
|
||||
BorderSize,
|
||||
TotalWidth,
|
||||
totalHeight,
|
||||
OffsetGumpID
|
||||
this.AddPropsFrame(TotalWidth, count + 1, out var x, out var y, EntryHeight);
|
||||
this.AddPropsHeaderWithBack(
|
||||
TotalWidth, ref x, ref y, m_Category.Title,
|
||||
m_Category.Parent != null, 1,
|
||||
page > 0, 2,
|
||||
(page + 1) * EntryCount < nodes.Length, 3,
|
||||
nextType: GumpButtonType.Reply, nextParam: 1,
|
||||
entryHeight: EntryHeight
|
||||
);
|
||||
|
||||
var x = BorderSize + OffsetSize;
|
||||
var y = BorderSize + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
|
||||
|
||||
if (m_Category.Parent != null)
|
||||
{
|
||||
AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1);
|
||||
}
|
||||
|
||||
x += PrevWidth + OffsetSize;
|
||||
|
||||
const int emptyWidth = TotalWidth - PrevWidth * 2 - NextWidth - OffsetSize * 5;
|
||||
AddImageTiled(x, y, emptyWidth, EntryHeight, EntryGumpID);
|
||||
|
||||
AddHtml(
|
||||
x + TextOffsetX,
|
||||
y + (EntryHeight - 20) / 2,
|
||||
emptyWidth - TextOffsetX,
|
||||
EntryHeight,
|
||||
$"<center>{m_Category.Title}</center>"
|
||||
);
|
||||
|
||||
x += emptyWidth + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
|
||||
|
||||
if (page > 0)
|
||||
{
|
||||
AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2);
|
||||
}
|
||||
|
||||
x += PrevWidth + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID);
|
||||
|
||||
if ((page + 1) * EntryCount < nodes.Length)
|
||||
{
|
||||
AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 3, GumpButtonType.Reply, 1);
|
||||
}
|
||||
|
||||
for (int i = 0, index = page * EntryCount; i < EntryCount && index < nodes.Length; ++i, ++index)
|
||||
{
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
PropsLayout.NextRow(ref x, ref y, EntryHeight);
|
||||
|
||||
var node = nodes[index];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue