/
Menu.psc
137 lines (109 loc) · 3.26 KB
/
Menu.psc
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
ScriptName System:UI:Visor:Menu Extends System:UI:Visor:MenuType
{Provides an abstraction for interacting with the visor menu.}
import System:Debug
import System:UI:DynamicLoadEvent
import System:UI:MenuDynamic
import System:UI:Visor:AssetLoadedEvent
string ClientInstance
string AssetLoadedEvent = "System_UI_VisorMenu_AssetLoadedEvent" const
; Interfaces
;---------------------------------------------
; @overrides
IMenu Function IMenu()
IMenu this = new IMenu
this.Name = "SystemVisorMenu"
this.OpenClose = OpenClose
return this
EndFunction
; @overrides
ICustom Function ICustom()
ICustom this = new ICustom
this.File = "SystemVisorMenu"
this.MenuFlags = FlagDoNotPreventGameSave
this.ExtendedFlags = FlagNone
return this
EndFunction
; Properties
;---------------------------------------------
Group Events
System:UI:OpenCloseEvent Property OpenClose Auto Const Mandatory
{@IMenu}
System:UI:Visor:AssetLoadedEvent Property AssetLoaded Auto Const Mandatory
{Provides an event for when an asset is loaded.}
EndGroup
Group Properties
string Property Client Hidden
{The instance path of the client's display object.}
string Function Get()
return ClientInstance
EndFunction
EndProperty
EndGroup
; Events
;---------------------------------------------
Event OnInit()
RegisterForQuestInit(QUST)
EndEvent
Event OnQuestInit()
OnGameReload()
RegisterForGameReload(self)
EndEvent
Event OnGameReload()
If (Register())
RegisterForExternalEvent(AssetLoadedEvent, "OnAssetLoaded")
EndIf
WriteLine(self, "OnGameReload", ToString(), log="System")
EndEvent
Event OnAssetLoaded(bool success, string instance)
WriteLine(self, "OnAssetLoaded", ":(success:"+success+", instance:"+instance+")"+ToString(), log="System")
If (success)
ClientInstance = instance
Else
ClientInstance = ""
EndIf
AssetLoadedEventArgs e = new AssetLoadedEventArgs
e.Success = success
e.Instance = instance
AssetLoaded.Send(self, e)
EndEvent
; Methods
;---------------------------------------------
bool Function Load(string value)
If (IsOpen)
If (value)
var[] arguments = new var[1]
arguments[0] = value
string member = GetMember("Load")
bool success = UI.Invoke(Name, member, arguments) as bool
WriteLine(self, "Load", ToString()+":(value:"+value+", success:"+success+", member:"+member+")", log="System")
return success
Else
WriteUnexpectedValue(self, "Load", "value", ToString()+":The value cannot be none or empty.", log="System")
return false
EndIf
Else
WriteUnexpected(self, "Load", ToString()+":The menu is not open.", log="System")
return false
EndIf
EndFunction
bool Function SetAlpha(float value)
If (IsOpen)
return UI.Set(Name, GetMember("Alpha"), value)
Else
WriteUnexpected(self, "SetAlpha", ToString()+":The menu is not open.", log="System")
return false
EndIf
EndFunction
bool Function AlphaTo(float value, float duration)
If (IsOpen)
var[] arguments = new var[2]
arguments[0] = value
arguments[1] = duration
bool success = UI.Invoke(Name, GetMember("AlphaTo"), arguments) as bool
WriteLine(self, "AlphaTo", ToString()+":(value:"+value+", duration:"+duration+", success:"+success+")", log="System")
return success
Else
WriteUnexpected(self, "AlphaTo", ToString()+":The menu is not open.", log="System")
return false
EndIf
EndFunction