-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cs
33 lines (30 loc) · 1.09 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace SmartUI;
public sealed class UIManager : RocketPlugin
{
protected override void Unload()
{
EffectManager.onEffectTextCommitted -= EffectTextCommittedHandler;
EffectManager.onEffectButtonClicked -= EffectButtonClickedHandler;
}
protected override void Load()
{
EffectManager.onEffectTextCommitted += EffectTextCommittedHandler;
EffectManager.onEffectButtonClicked += EffectButtonClickedHandler;
}
public static void EffectButtonClickedHandler(Player player, string buttonName)
{
player.ControllersAction<UIController>(x =>
{
x.ElementsList.ElementComponentAction<Button>(buttonName, btn => btn.Click());
return x.OnButtonClicked(buttonName);
});
}
public static void EffectTextCommittedHandler(Player player, string fieldName, string text)
{
player.ControllersAction<UIController>(x =>
{
x.ElementsList.ElementComponentAction<Field>(fieldName, field => field.Commit(text));
return x.OnTextFieldCommited(fieldName, text);
});
}
}