Sections: plugin windows' barMenu (v94), parsed and capped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2225b90b2c
commit
4cca800a26
4 changed files with 122 additions and 2 deletions
|
|
@ -33,6 +33,7 @@ internal static class Program
|
|||
WindowPlanChoices();
|
||||
WindowTakeOver();
|
||||
WindowFrameless();
|
||||
ManifestBarMenu();
|
||||
StackCheckAfterPluginDraw();
|
||||
|
||||
Console.WriteLine();
|
||||
|
|
@ -585,6 +586,66 @@ internal static class Program
|
|||
"chrome and fitHeight are in the signature (a change re-registers)");
|
||||
}
|
||||
|
||||
// -- Bar icon dropdown (v94) --──────
|
||||
|
||||
private static string BarMenuManifest(string windowExtra) =>
|
||||
"{ \"version\": 1, \"windows\": [ { \"id\": \"server\", \"title\": \"DreamWeave\", \"surface\": \"window:server\", \"bar\": true"
|
||||
+ windowExtra + " } ] }";
|
||||
|
||||
private static void ManifestBarMenu()
|
||||
{
|
||||
Case("plugin windows: barMenu (v94)");
|
||||
string storefront = ((char)0xE470).ToString(), shield = ((char)0xE40A).ToString(), sparkle = ((char)0xE6A2).ToString();
|
||||
string longTip = new string('T', 60);
|
||||
string longCommand = "/" + new string('c', 250);
|
||||
string items = """
|
||||
[
|
||||
{ "id": "market", "tooltip": "Market", "icon": "@STORE@", "command": "/rserver market" },
|
||||
{ "id": "nocmdslash", "tooltip": "No slash", "icon": "@STORE@", "command": "rserver x" },
|
||||
{ "id": "multiline", "tooltip": "Two lines", "icon": "@STORE@", "command": "/rserver a\n/rserver b" },
|
||||
{ "id": "toolong", "tooltip": "Too long", "icon": "@STORE@", "command": "@LONGCMD@" },
|
||||
{ "id": "", "tooltip": "No id", "icon": "@STORE@", "command": "/rserver x" },
|
||||
{ "id": "market", "tooltip": "Duplicate", "icon": "@STORE@", "command": "/rserver market" },
|
||||
{ "id": "notip", "tooltip": "", "icon": "@STORE@", "command": "/rserver x" },
|
||||
{ "id": "suit", "tooltip": "Suit Builder", "icon": "@SHIELD@", "command": "/rserver suit" },
|
||||
{ "id": "noicon", "tooltip": "No icon", "icon": "", "command": "/rserver x" },
|
||||
{ "id": "abilities", "tooltip": "Ability Planner", "icon": "@SPARKLE@", "command": "/rserver abilities" },
|
||||
{ "id": "longtip", "tooltip": "@LONGTIP@", "icon": "@STORE@", "command": "/rserver x" }
|
||||
]
|
||||
"""
|
||||
.Replace("@STORE@", storefront).Replace("@SHIELD@", shield).Replace("@SPARKLE@", sparkle)
|
||||
.Replace("@LONGCMD@", longCommand).Replace("@LONGTIP@", longTip);
|
||||
|
||||
SectionManifest m = SectionManifestParser.Parse("DW", BarMenuManifest(", \"barMenu\": " + items), out string err);
|
||||
Check(err.Length == 0 && m.Windows.Length == 1, "parses and the window is kept: " + err);
|
||||
SectionBarMenuItem[] menu = m.Windows[0].Menu;
|
||||
string[] ids = menu.Select(i => i.Id).ToArray();
|
||||
Check(ids.SequenceEqual(new[] { "market", "suit", "noicon", "abilities", "longtip" }),
|
||||
"bad items dropped, order kept: " + string.Join(",", ids));
|
||||
Check(menu[0] == new SectionBarMenuItem("market", "Market", storefront, "/rserver market"), "market: fields exactly equal");
|
||||
Check(menu[1] == new SectionBarMenuItem("suit", "Suit Builder", shield, "/rserver suit"), "suit: fields exactly equal");
|
||||
Check(menu[3] == new SectionBarMenuItem("abilities", "Ability Planner", sparkle, "/rserver abilities"), "abilities: fields exactly equal");
|
||||
Check(menu[2].Icon == "" && menu[2].Tooltip == "No icon", "an empty icon is kept as \"\"");
|
||||
Check(menu[4].Tooltip.Length == SectionManifestParser.MaxLabelLength && menu[4].Tooltip == longTip[..48],
|
||||
"an over-long tooltip is cut to 48: " + menu[4].Tooltip.Length);
|
||||
Check(SectionManifestParser.Command("/rserver a\n/rserver b").Length == 0 && SectionManifestParser.Command("rserver x").Length == 0
|
||||
&& SectionManifestParser.Command(longCommand).Length == 0, "(the rejected commands are ones Command() rejects)");
|
||||
|
||||
var many = new System.Text.StringBuilder("[");
|
||||
for (int i = 0; i < 20; i++)
|
||||
many.Append(i > 0 ? "," : "").Append($"{{ \"id\": \"item{i}\", \"tooltip\": \"Item {i}\", \"icon\": \"\", \"command\": \"/rserver x{i}\" }}");
|
||||
many.Append(']');
|
||||
m = SectionManifestParser.Parse("DW", BarMenuManifest(", \"barMenu\": " + many), out err);
|
||||
Check(SectionManifestParser.MaxBarMenuItems == 6 && m.Windows[0].Menu.Length == SectionManifestParser.MaxBarMenuItems,
|
||||
"twenty valid items give exactly MaxBarMenuItems: " + m.Windows[0].Menu.Length);
|
||||
Check(m.Windows[0].Menu[0].Id == "item0" && m.Windows[0].Menu[5].Id == "item5", "the first six are the ones kept");
|
||||
|
||||
m = SectionManifestParser.Parse("DW", BarMenuManifest(", \"barMenu\": \"nope\""), out err);
|
||||
Check(err.Length == 0 && m.Windows.Length == 1 && m.Windows[0].Menu.Length == 0, "barMenu not an array: window kept, no menu");
|
||||
m = SectionManifestParser.Parse("DW", BarMenuManifest(""), out err);
|
||||
Check(err.Length == 0 && m.Windows.Length == 1 && m.Windows[0].Menu.Length == 0, "no barMenu key: no menu");
|
||||
}
|
||||
|
||||
// ImGui 1.91.6's ImGuiErrorRecoveryState, in field order: windows, IDs, tree nodes, colours,
|
||||
// style vars, fonts, focus scopes, groups, item flags, popups, disabled. The base values are
|
||||
// the ones a 32-bit probe of our cimgui.dll read inside a panel's body child (2026-10-21).
|
||||
|
|
|
|||
Loading…
Reference in a new issue