@@ -34,11 +34,14 @@ partial class HUDManager {
34
34
35
35
////////////////
36
36
37
- private bool UpdateInteractionsWithinEntireUI_If ( HUDElement elem ) {
37
+ private bool UpdateInteractionsWithinEntireUI_If ( HUDElement elem , Vector2 mouseScrPos ) {
38
+ int mouseX = ( int ) mouseScrPos . X ;
39
+ int mouseY = ( int ) mouseScrPos . Y ;
40
+
38
41
if ( ! elem . IsEnabled ( ) ) {
39
42
return false ;
40
43
}
41
- if ( ! elem . GetHUDComputedArea ( true ) . Contains ( Main . mouseX , Main . mouseY ) ) {
44
+ if ( ! elem . GetHUDComputedArea ( true ) . Contains ( mouseX , mouseY ) ) {
42
45
return false ;
43
46
}
44
47
@@ -47,18 +50,21 @@ private bool UpdateInteractionsWithinEntireUI_If( HUDElement elem ) {
47
50
return false ;
48
51
}
49
52
53
+ //
54
+
50
55
this . _ClickDisabledMillisecondsRemaining = Math . Max (
51
56
0.0d ,
52
57
this . _ClickDisabledMillisecondsRemaining - time . ElapsedGameTime . TotalMilliseconds
53
58
) ;
54
59
60
+ //
61
+
55
62
if ( this . _ClickDisabledMillisecondsRemaining > 0.0d ) {
56
63
return true ;
57
64
}
58
65
59
66
//
60
67
61
- var mousePos = new Vector2 ( ( float ) Main . mouseX , ( float ) Main . mouseY ) ;
62
68
bool mouseLeftDown = Main . mouseLeft ; //&& Main.hasFocus;
63
69
bool mouseRightDown = Main . mouseRight ; //&& Main.hasFocus;
64
70
bool mouseMiddleDown = Main . mouseMiddle ; //&& Main.hasFocus;
@@ -69,10 +75,10 @@ private bool UpdateInteractionsWithinEntireUI_If( HUDElement elem ) {
69
75
70
76
if ( elem != this . _LastElementHover ) {
71
77
if ( this . _LastElementHover != null ) {
72
- this . _LastElementHover . MouseOut ( new UIMouseEvent ( this . _LastElementHover , mousePos ) ) ;
78
+ this . _LastElementHover . MouseOut ( new UIMouseEvent ( this . _LastElementHover , mouseScrPos ) ) ;
73
79
}
74
80
75
- elem . MouseOver ( new UIMouseEvent ( elem , mousePos ) ) ;
81
+ elem . MouseOver ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
76
82
77
83
this . _LastElementHover = elem ;
78
84
}
@@ -83,24 +89,24 @@ private bool UpdateInteractionsWithinEntireUI_If( HUDElement elem ) {
83
89
if ( mouseLeftDown && ! this . _WasMouseLeftDown ) {
84
90
this . _LastElementLeftDown = elem ;
85
91
86
- elem . MouseDown ( new UIMouseEvent ( elem , mousePos ) ) ;
92
+ elem . MouseDown ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
87
93
88
94
double milliSinceLastMouseDown = time . TotalGameTime . TotalMilliseconds - this . _LastMouseDownMilliseconds ;
89
95
90
96
if ( this . _LastElementLeftClicked == elem && milliSinceLastMouseDown < 500.0 ) {
91
- elem . DoubleClick ( new UIMouseEvent ( elem , mousePos ) ) ;
97
+ elem . DoubleClick ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
92
98
this . _LastElementLeftClicked = null ;
93
99
}
94
100
95
101
this . _LastMouseDownMilliseconds = time . TotalGameTime . TotalMilliseconds ;
96
102
} else if ( this . _LastElementLeftDown != null ) {
97
- if ( this . _LastElementLeftDown . GetHUDComputedArea ( true ) . Contains ( Main . mouseX , Main . mouseY ) ) {
98
- this . _LastElementLeftDown . Click ( new UIMouseEvent ( this . _LastElementLeftDown , mousePos ) ) ;
103
+ if ( this . _LastElementLeftDown . GetHUDComputedArea ( true ) . Contains ( mouseX , mouseY ) ) {
104
+ this . _LastElementLeftDown . Click ( new UIMouseEvent ( this . _LastElementLeftDown , mouseScrPos ) ) ;
99
105
100
106
this . _LastElementLeftClicked = this . _LastElementLeftDown ;
101
107
}
102
108
103
- this . _LastElementLeftDown . MouseUp ( new UIMouseEvent ( this . _LastElementLeftDown , mousePos ) ) ;
109
+ this . _LastElementLeftDown . MouseUp ( new UIMouseEvent ( this . _LastElementLeftDown , mouseScrPos ) ) ;
104
110
105
111
this . _LastElementLeftDown = null ;
106
112
}
@@ -111,24 +117,24 @@ private bool UpdateInteractionsWithinEntireUI_If( HUDElement elem ) {
111
117
if ( mouseRightDown && ! this . _WasMouseRightDown ) {
112
118
this . _LastElementRightDown = elem ;
113
119
114
- elem . RightMouseDown ( new UIMouseEvent ( elem , mousePos ) ) ;
120
+ elem . RightMouseDown ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
115
121
116
122
double milliSinceLastMouseRightDown = time . TotalGameTime . TotalMilliseconds - this . _LastMouseRightDownMilliseconds ;
117
123
118
124
if ( this . _LastElementRightClicked == elem && milliSinceLastMouseRightDown < 500.0 ) {
119
- elem . RightDoubleClick ( new UIMouseEvent ( elem , mousePos ) ) ;
125
+ elem . RightDoubleClick ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
120
126
this . _LastElementRightClicked = null ;
121
127
}
122
128
123
129
this . _LastMouseRightDownMilliseconds = time . TotalGameTime . TotalMilliseconds ;
124
130
} else if ( this . _LastElementRightDown != null ) {
125
- if ( this . _LastElementRightDown . GetHUDComputedArea ( true ) . Contains ( Main . mouseX , Main . mouseY ) ) {
126
- this . _LastElementRightDown . RightClick ( new UIMouseEvent ( this . _LastElementRightDown , mousePos ) ) ;
131
+ if ( this . _LastElementRightDown . GetHUDComputedArea ( true ) . Contains ( mouseX , mouseY ) ) {
132
+ this . _LastElementRightDown . RightClick ( new UIMouseEvent ( this . _LastElementRightDown , mouseScrPos ) ) ;
127
133
128
134
this . _LastElementRightClicked = this . _LastElementRightDown ;
129
135
}
130
136
131
- this . _LastElementRightDown . RightMouseUp ( new UIMouseEvent ( this . _LastElementRightDown , mousePos ) ) ;
137
+ this . _LastElementRightDown . RightMouseUp ( new UIMouseEvent ( this . _LastElementRightDown , mouseScrPos ) ) ;
132
138
133
139
this . _LastElementRightDown = null ;
134
140
}
@@ -138,25 +144,25 @@ private bool UpdateInteractionsWithinEntireUI_If( HUDElement elem ) {
138
144
if ( mouseMiddleDown && ! this . _WasMouseMiddleDown ) {
139
145
this . _LastElementMiddleDown = elem ;
140
146
141
- elem . MiddleMouseDown ( new UIMouseEvent ( elem , mousePos ) ) ;
147
+ elem . MiddleMouseDown ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
142
148
143
149
double milliSinceLastMouseMiddleDown = time . TotalGameTime . TotalMilliseconds - this . _LastMouseMiddleDownMilliseconds ;
144
150
145
151
if ( this . _LastElementMiddleClicked == elem && milliSinceLastMouseMiddleDown < 500.0 ) {
146
- elem . MiddleDoubleClick ( new UIMouseEvent ( elem , mousePos ) ) ;
152
+ elem . MiddleDoubleClick ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
147
153
148
154
this . _LastElementMiddleClicked = null ;
149
155
}
150
156
151
157
this . _LastMouseMiddleDownMilliseconds = time . TotalGameTime . TotalMilliseconds ;
152
158
} else if ( this . _LastElementMiddleDown != null ) {
153
- if ( this . _LastElementMiddleDown . GetHUDComputedArea ( true ) . Contains ( Main . mouseX , Main . mouseY ) ) {
154
- this . _LastElementMiddleDown . MiddleClick ( new UIMouseEvent ( this . _LastElementMiddleDown , mousePos ) ) ;
159
+ if ( this . _LastElementMiddleDown . GetHUDComputedArea ( true ) . Contains ( mouseX , mouseY ) ) {
160
+ this . _LastElementMiddleDown . MiddleClick ( new UIMouseEvent ( this . _LastElementMiddleDown , mouseScrPos ) ) ;
155
161
156
162
this . _LastElementMiddleClicked = this . _LastElementMiddleDown ;
157
163
}
158
164
159
- this . _LastElementMiddleDown . MiddleMouseUp ( new UIMouseEvent ( this . _LastElementMiddleDown , mousePos ) ) ;
165
+ this . _LastElementMiddleDown . MiddleMouseUp ( new UIMouseEvent ( this . _LastElementMiddleDown , mouseScrPos ) ) ;
160
166
161
167
this . _LastElementMiddleDown = null ;
162
168
}
@@ -166,25 +172,25 @@ private bool UpdateInteractionsWithinEntireUI_If( HUDElement elem ) {
166
172
if ( mouseXButton1Down && ! this . _WasMouseXButton1Down ) {
167
173
this . _LastElementXButton1Down = elem ;
168
174
169
- elem . XButton1MouseDown ( new UIMouseEvent ( elem , mousePos ) ) ;
175
+ elem . XButton1MouseDown ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
170
176
171
177
double milliSinceLastX1Down = time . TotalGameTime . TotalMilliseconds - this . _LastMouseXButton1DownMilliseconds ;
172
178
173
179
if ( this . _LastElementXButton1Clicked == elem && milliSinceLastX1Down < 500.0 ) {
174
- elem . XButton1DoubleClick ( new UIMouseEvent ( elem , mousePos ) ) ;
180
+ elem . XButton1DoubleClick ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
175
181
176
182
this . _LastElementXButton1Clicked = null ;
177
183
}
178
184
179
185
this . _LastMouseXButton1DownMilliseconds = time . TotalGameTime . TotalMilliseconds ;
180
186
} else if ( this . _LastElementXButton1Down != null ) {
181
- if ( this . _LastElementXButton1Down . GetHUDComputedArea ( true ) . Contains ( Main . mouseX , Main . mouseY ) ) {
182
- this . _LastElementXButton1Down . XButton1Click ( new UIMouseEvent ( this . _LastElementXButton1Down , mousePos ) ) ;
187
+ if ( this . _LastElementXButton1Down . GetHUDComputedArea ( true ) . Contains ( mouseX , mouseY ) ) {
188
+ this . _LastElementXButton1Down . XButton1Click ( new UIMouseEvent ( this . _LastElementXButton1Down , mouseScrPos ) ) ;
183
189
184
190
this . _LastElementXButton1Clicked = this . _LastElementXButton1Down ;
185
191
}
186
192
187
- this . _LastElementXButton1Down . XButton1MouseUp ( new UIMouseEvent ( this . _LastElementXButton1Down , mousePos ) ) ;
193
+ this . _LastElementXButton1Down . XButton1MouseUp ( new UIMouseEvent ( this . _LastElementXButton1Down , mouseScrPos ) ) ;
188
194
189
195
this . _LastElementXButton1Down = null ;
190
196
}
@@ -194,33 +200,33 @@ private bool UpdateInteractionsWithinEntireUI_If( HUDElement elem ) {
194
200
if ( mouseXButton2Down && ! this . _WasMouseXButton2Down ) {
195
201
this . _LastElementXButton2Down = elem ;
196
202
197
- elem . XButton2MouseDown ( new UIMouseEvent ( elem , mousePos ) ) ;
203
+ elem . XButton2MouseDown ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
198
204
199
205
double millisSinceLastX2Down = time . TotalGameTime . TotalMilliseconds - this . _LastMouseXButton2DownMilliseconds ;
200
206
201
207
if ( this . _LastElementXButton2Clicked == elem && millisSinceLastX2Down < 500.0 ) {
202
208
203
- elem . XButton2DoubleClick ( new UIMouseEvent ( elem , mousePos ) ) ;
209
+ elem . XButton2DoubleClick ( new UIMouseEvent ( elem , mouseScrPos ) ) ;
204
210
this . _LastElementXButton2Clicked = null ;
205
211
}
206
212
207
213
this . _LastMouseXButton2DownMilliseconds = time . TotalGameTime . TotalMilliseconds ;
208
214
} else if ( this . _LastElementXButton2Down != null ) {
209
- if ( this . _LastElementXButton2Down . GetHUDComputedArea ( true ) . Contains ( Main . mouseX , Main . mouseY ) ) {
210
- this . _LastElementXButton2Down . XButton2Click ( new UIMouseEvent ( this . _LastElementXButton2Down , mousePos ) ) ;
215
+ if ( this . _LastElementXButton2Down . GetHUDComputedArea ( true ) . Contains ( mouseX , mouseY ) ) {
216
+ this . _LastElementXButton2Down . XButton2Click ( new UIMouseEvent ( this . _LastElementXButton2Down , mouseScrPos ) ) ;
211
217
212
218
this . _LastElementXButton2Clicked = this . _LastElementXButton2Down ;
213
219
}
214
220
215
- this . _LastElementXButton2Down . XButton2MouseUp ( new UIMouseEvent ( this . _LastElementXButton2Down , mousePos ) ) ;
221
+ this . _LastElementXButton2Down . XButton2MouseUp ( new UIMouseEvent ( this . _LastElementXButton2Down , mouseScrPos ) ) ;
216
222
217
223
this . _LastElementXButton2Down = null ;
218
224
}
219
225
220
226
//
221
227
222
228
if ( PlayerInput . ScrollWheelDeltaForUI != 0 ) {
223
- elem . ScrollWheel ( new UIScrollWheelEvent ( elem , mousePos , PlayerInput . ScrollWheelDeltaForUI ) ) ;
229
+ elem . ScrollWheel ( new UIScrollWheelEvent ( elem , mouseScrPos , PlayerInput . ScrollWheelDeltaForUI ) ) ;
224
230
// PlayerInput.ScrollWheelDeltaForUI = 0; Moved after ModHooks.UpdateUI(gameTime);
225
231
}
226
232
@@ -238,13 +244,9 @@ private bool UpdateInteractionsWithinEntireUI_If( HUDElement elem ) {
238
244
239
245
////
240
246
241
- private void ClearInteractionsIfAny ( ) {
242
- var mousePos = new Vector2 ( ( float ) Main . mouseX , ( float ) Main . mouseY ) ;
243
-
244
- //
245
-
247
+ private void ClearInteractionsIfAny ( Vector2 mouseScrPos ) {
246
248
if ( this . _LastElementHover != null ) {
247
- this . _LastElementHover . MouseOut ( new UIMouseEvent ( this . _LastElementHover , mousePos ) ) ;
249
+ this . _LastElementHover . MouseOut ( new UIMouseEvent ( this . _LastElementHover , mouseScrPos ) ) ;
248
250
249
251
this . _LastElementHover = null ;
250
252
}
0 commit comments