// ============================================================================ // RynthAi - CommandButtons/CommandButtonsWindow.cs // The Command Buttons window (2026-11-26): a grid of buttons, each sending one // chat line, and an edit view to make them. RynthCore hosts the window (the // sections manifest's "commandbuttons" window, plugin API v89: header, // pop-out, resize, remembered place; no bar button: the dashboard's options // menu, /ra buttons and Find a Feature open it) and calls Draw through // RynthPluginRenderEmbed. // // Grid: this character's buttons, then this server's, then every character's, // as many columns as set (Auto: as many as fit). A click sends the line (asks // first for a button with "Ask" ticked); a right-click opens the edit view on // that button's list. The pencil in the header opens the edit view. // // Edit view: the three lists as tabs; per button: move up / down, label, // command (with a mark saying what it is, or why it can't be sent), colour, // Ask, Send now and Remove; Add button; Copy from another character (this // character's tab); the grid's columns and button size. // // AC's render thread. Edits go straight into the lists under the set's lock and // mark them changed (the tick saves them a moment later); presses are queued // for the tick. Looks: Shared/RynthUi (the player's theme). // ============================================================================ using System; using System.Collections.Generic; using System.Globalization; using System.Numerics; using System.Threading; using ImGuiNET; using RynthCore.Plugin.Shared; using RynthCore.Plugin.Shared.RynthUi; using RynthCore.PluginSdk; using static RynthCore.Plugin.Shared.RynthUi.RynthUi; namespace RynthCore.Plugin.RynthAi.CommandButtons; internal sealed class CommandButtonsWindow { private readonly CommandButtonSet _set; private readonly Action _press; // queued for the tick private bool _edit; private ButtonScope _scope = ButtonScope.Character; private int _focusRow = -1; // a row just added: focus its label box // A button that asks first: which, and the line it will send. private ButtonScope _confirmScope; private int _confirmIndex = -1; private string _confirmLine = string.Empty; private bool _openConfirm; // Copy from another character (read when the edit view opens and when the list is opened). private List _others = new(); private int _copyPick; // The header's note: the last press, or a problem (set from the tick). private volatile string _note = string.Empty; private long _noteAtMs; private const long NoteMs = 5000; private float _k = 1f; private float Px(float v) => v * _k; private const string ConfirmId = "##cb_confirm"; private const string HelpText = "Buttons that each send one chat line, as if you typed it in the chat box: a command (/ra start, " + "/lua start threads, /rdef weapons, /loc), an emote (*wave*, *snow angel*), a server command (@home) " + "or plain text (said aloud).\n\n" + "The pencil opens the edit view: a label and a command for each button, its colour, and Ask (it asks " + "before it sends: for commands that are hard to take back). Columns and the button size are there too.\n\n" + "Three lists: This character, This server (every character on this server) and All characters; the " + "grid shows all three. Copy from takes another character's buttons.\n\n" + "/ra buttons opens this window; /ra buttons list | add