/************************************************************************* * ModernUO * * Copyright 2019-2026 - ModernUO Development Team * * Email: hi@modernuo.com * * File: GridEntryExtensions.cs * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * *************************************************************************/ using System; using System.Runtime.CompilerServices; using Server.Buffers; namespace Server.Gumps; /// /// Extension methods for DynamicGumpBuilder that provide BaseGridGump-style entry methods. /// These combine a tiled background with content, matching the AddEntry* pattern. /// public static class GridEntryExtensions { extension(ref DynamicGumpBuilder builder) { /// /// Adds an entry with label (EntryGumpID background + cropped label). /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryLabel( in GridCell cell, in GridEntryStyle style, ReadOnlySpan text ) { builder.AddImageTiled(cell, style.EntryGumpID); builder.AddLabelCropped(cell, style.TextHue, text, style.TextOffsetX); } /// /// Adds an entry with label using interpolated string. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryLabel( in GridCell cell, in GridEntryStyle style, ref RawInterpolatedStringHandler handler ) { builder.AddImageTiled(cell, style.EntryGumpID); builder.AddLabelCropped(cell, style.TextHue, ref handler, style.TextOffsetX); } /// /// Adds an entry with HTML (EntryGumpID background + HTML text). /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryHtml( in GridCell cell, in GridEntryStyle style, ReadOnlySpan text ) { builder.AddImageTiled(cell, style.EntryGumpID); builder.AddHtml(cell, text, style.TextOffsetX, 0); } /// /// Adds an entry with HTML using interpolated string. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryHtml( in GridCell cell, in GridEntryStyle style, ref RawInterpolatedStringHandler handler ) { builder.AddImageTiled(cell, style.EntryGumpID); builder.AddHtml(cell, ref handler, style.TextOffsetX, 0); } /// /// Adds a header entry (HeaderGumpID background only). /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryHeader( in GridCell cell, in GridEntryStyle style ) { builder.AddImageTiled(cell, style.HeaderGumpID); } /// /// Adds an entry with a centered button (HeaderGumpID background + centered button). /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryButton( in GridCell cell, in GridEntryStyle style, int normalId, int pressedId, int buttonId, int buttonWidth, int buttonHeight ) { builder.AddImageTiled(cell, style.HeaderGumpID); builder.AddButton( cell, normalId, pressedId, buttonId, offsetX: (cell.Width - buttonWidth) / 2, offsetY: (cell.Height - buttonHeight) / 2 ); } /// /// Adds an entry with arrow left button. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryArrowLeft( in GridCell cell, in GridEntryStyle style, int buttonId ) { builder.AddEntryButton( cell, style, GridEntryStyle.ArrowLeftID1, GridEntryStyle.ArrowLeftID2, buttonId, GridEntryStyle.ArrowWidth, GridEntryStyle.ArrowHeight ); } /// /// Adds an entry with arrow right button. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryArrowRight( in GridCell cell, in GridEntryStyle style, int buttonId ) { builder.AddEntryButton( cell, style, GridEntryStyle.ArrowRightID1, GridEntryStyle.ArrowRightID2, buttonId, GridEntryStyle.ArrowWidth, GridEntryStyle.ArrowHeight ); } /// /// Adds an entry with text input (EntryGumpID background + text entry). /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryText( in GridCell cell, in GridEntryStyle style, int entryId, ReadOnlySpan initialText = default ) { builder.AddImageTiled(cell, style.EntryGumpID); builder.AddTextEntry(cell, style.TextHue, entryId, style.TextOffsetX, 0, initialText); } /// /// Adds an entry with text input using interpolated string. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryText( in GridCell cell, in GridEntryStyle style, int entryId, ref RawInterpolatedStringHandler handler ) { builder.AddImageTiled(cell, style.EntryGumpID); builder.AddTextEntry(cell, style.TextHue, entryId, style.TextOffsetX, 0, ref handler); } /// /// Adds a blank line (BackGumpID + 4 background across full width). /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddEntryBlank( in GridCell cell, in GridEntryStyle style ) { builder.AddImageTiled(cell, style.BackGumpID + 4); } /// /// Adds the standard grid background (outer background + inner offset region). /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddGridBackground( int width, int height, in GridEntryStyle style ) { builder.AddBackground(0, 0, width, height, style.BackGumpID); builder.AddImageTiled( style.BorderSize, style.BorderSize, width - style.BorderSize * 2, height - style.BorderSize * 2, style.OffsetGumpID ); } } }