Repository navigation
ZH TW API UO GetGumpInfo
LIHACHTETAN edited this page Nov 28, 2026
·
3 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
家 · C# · IDE · UO API · A–Z · 範例 · Languages
dynamic UO.GetGumpInfo(object? gumpIndex);傳回單一伺服器口令的識別碼和元素的一致快照。
-
gumpIndex— 強制 int — 活動伺服器口令的索引,從 0 到 GetGumpsCount()-1。這不是 GumpID/serial。負數和列表外的索引無效。開啟、關閉和重新排序視窗可以更改索引;行動前檢查GetGumpID/GetGumpSerial。
陣列 - 正好五個元素: [0] int serial; [1] int GumpID; [2] Array 非空文本; [3] Array 常規按鈕的描述; [4] Array 所有生命元素的描述,包括嵌套的元素。此腳本無效/關閉或忽略的 Gump 會產生一個空數組 []. ID 最高有效位元表示為負數 int。空文本數組本身並不意味著沒有視窗。
- 與活動伺服器 Gump 一起使用。背包、地圖、設定等本地視窗不包含在此列表中。一次呼叫讀取遊戲執行緒中的資料;不同的呼叫可能會看到列表的不同狀態。
- 整個快照在一個遊戲執行緒請求中複製。返回後更改/關閉視窗不會更改已儲存的陣列。
- 控制描述指示類型、頁碼、ID、X/Y、尺寸。按鈕還包含 ButtonID、action、toPage 和 graphic;開關 - ID,選中,非活動/活動。文字可以包含空格和=;字串不能無條件地被空格解析。
- AddGumpIgnoreByID/AddGumpIgnoreBySerial隱藏目前腳本中僅此一次讀取的結果; ClearGumpsIgnore 刪除這些過濾器。 GetGumpsCount不減少。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
object? result = UO.GetGumpInfo(0);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));參數與執行流程:
- GumpIndex=0 — 第一台伺服器阿甘。長度檢查可保護對缺失視窗欄位的存取。
- 訊息[0] — serial,訊息[1] — GumpID;兩者屬於同一錄音。
var info = UO.GetGumpInfo(0);
if (Truth(ArrayLength(info) == 5))
{
UO.Print("Serial=" + Hex(info[0]));
UO.Print("GumpID=" + Hex(info[1]));
}
int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
string Hex(object? value) => Convert.ToInt64(value).ToString("X");
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- info[3] — 按鈕描述陣列;該行中的 ButtonID 欄位指定回應的 ID。 i 只是行索引,而不是 ButtonID。
- 單選按鈕是單選按鈕,出現在 info[4] 中,而不是出現在常規按鈕清單中。
return RunScenario();
object? RunScenario()
{
var info = UO.GetGumpInfo(0);
if (Truth(ArrayLength(info) == 5))
{
var buttons = info[3];
var i = 0;
while (Truth(i < ArrayLength(buttons)))
{
UO.Print(buttons[i]);
i = i + 1;
}
}
return null;
}
int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- info[2] - 文字副本。僅允許關閉非抑制視窗NoClose。
- 關閉不會清除已儲存的文字;對於現有視窗來說,空白文字陣列也是可以接受的。
return new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenario();
class ScriptScenario
{
private readonly global::ClassicUO.CSharp.CSharpGameApi UO;
private readonly Func<int, Task> WaitAsync;
private readonly string[] Args;
private readonly CancellationToken Cancellation;
private readonly Action Checkpoint;
public ScriptScenario(global::ClassicUO.CSharp.CSharpGameApi api, Func<int, Task> wait, string[] args, CancellationToken cancellation, Action checkpoint)
{
UO = api;
WaitAsync = wait;
Args = args;
Cancellation = cancellation;
Checkpoint = checkpoint;
}
public object? RunScenario()
{
var info = UO.GetGumpInfo(0);
if (Truth(ArrayLength(info) == 5))
{
var texts = info[2];
UO.CloseSimpleGump(0);
if (Truth(ArrayLength(texts) > 0))
{
UO.Print(texts[0]);
}
}
return null;
}
int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: gumpIndex (Any)
結果: dynamic / Array.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetGumpId:bridge.GetGumpId(index). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetGumpSerial:bridge.GetGumpSerial(index). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetGumpTextLines:bridge.GetGumpTextLines(index). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetGumpButtonsDescription:bridge.GetGumpButtonsDescription(index). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetGumpFullLines:bridge.GetGumpFullLines(index). -
InjectionScript.Runtime.InjectionApiUO.StringArray:StringArray(snapshot.Text).
內部實作程式碼,不能作為獨立腳本執行。
case "getgumpinfo":
{
int index = Arg(0);
GumpSnapshot snapshot;
if (bridge is IApiGumpAccess reader)
snapshot = reader.ReadGump(index);
else
{
int id = bridge.GetGumpId(index);
snapshot = id == 0 ? null : new GumpSnapshot(bridge.GetGumpSerial(index), id,
bridge.GetGumpTextLines(index), bridge.GetGumpButtonsDescription(index), bridge.GetGumpFullLines(index));
}
if (snapshot == null || state.IgnoredGumpIds.Contains(snapshot.Id)
|| state.IgnoredGumpSerials.Contains(snapshot.Serial))
return new InjectionValue(Array.Empty<InjectionValue>());
return new InjectionValue(new[]
{
new InjectionValue(snapshot.Serial), new InjectionValue(snapshot.Id), StringArray(snapshot.Text),
StringArray(snapshot.Buttons), StringArray(snapshot.Controls)
});
}ClassicUO — Bad Newbie & C# Scripts IDE