-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathunsilent-attendant.au3
More file actions
718 lines (648 loc) · 28.9 KB
/
Copy pathunsilent-attendant.au3
File metadata and controls
718 lines (648 loc) · 28.9 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
; We need admin on Vista / Windows 7 because otherwise we can't interact with other windows
#RequireAdmin
#CS
Unsilent Attendant
Copyright 2009-2011 Michael Janssen. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY MICHAEL JANSSEN ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of Michael Janssen.
INSTRUCTIONS:
With MTGO launched, run the script.
** The buttons are, from left to right and top to bottom:
- Set Chat position: Use this to set the position of the two chat windows (normal and tourney)
- Set DCI-R postion: Use this to set the location fo the TOP player box in the Player Entry window of DCI-R
- Paste pairings: Paste from DCI-R (copy them first!) pairings into the chat channel.
- The countdown window! This box counts down to the next registration announcement.
- Enter Into DCI-R. If the DCI-R position is set, this will enter all of the registered players into DCI-R
- Paste Results: Paste from DCI-R (copy them first!) results (by table) into the chat channel.
- Start/Stop Pre-Registration. This starts and stops the pre-registration!
- Start/Stop Registration. This Starts and stops the registration!
- Auto Chk - If this is checked, the registration channel will be checked every 10 seconds for new registrants.
- Tourney NAME - this is the name which is used in some announcements.
- Matches Counter - This is the matches left counter. Set it to the number of matches left in the current round.
- Round Counter - This is the round number counter. Set it to the round number.
- Ann Matches - This will announce how many matches are left in the round to both the chat and registration channels.
- Random player - picks a random player who is still left in the tournament. Useful for door prizes.
** GLOBAL KEY CODES:
- F13: Check the registration room for registrations.
- F14: Copy the list of players to your clipboard (comma separated)
TODO LIST (ideas list):
- Make the copy/paste code a litle bit better, since it sometimes fucks up
- Activate the windows with windows calls instead of a click, wait, click sequence.
- In the same vein, switch back to the window that was active before an announcement was made.
- Only process the registrations that haven't been processed yet (hash and match?)
- Automatically start the registration at the end of the pre-reg period
- Use the actual clock to tell how many minutes are left in the pre-reg and reg instead of timers we have now
- Put all of the configuration stuff on a separate window
- Save the players in the tourney + window locations, etc. to a config file so if we crash we can start up again
- Use log files to scan for registrations instead of using the windows. (No good - log files are not updated until window is closed)
- Register the players to gatherling using HTTP calls
- Invert the colors of the Pre-reg, reg boxes when the pre-reg or registration is running
- "Quick Click" chat window - for automatically chatting things like
Revision History (Date, Initials, Description)
2009-06-18 - MDJ Added support for pasting into the chat window the Matches and the Results.
- Copy them into the clipboard first, and make sure the chat position is set on the window you want to paste into.
2009-08-06 - Added support for on-demand scanning. Hit F13 to scan the chat window for registrations.
- Removed automated scanning so that you have more of a chance to chat between ads.
- Added counter for Ad, when it hits zero it will do the Ad
- Added support to set up DCI-R. Make sure to set the DCI-R point first.
2009-08-20 - Added ability to drop players by clicking on their names in the list
- Consolidated "Start Registration" and "Stop Registration" into one button which changes modes based on whether reg is running
- Added count of players to the advertisement
- Added RED warning color to the countdown when there is < 10 seconds.
2009-09-03 - Added support for auto-polling of channel. Click the checkbox to poll every 10 seconds.
2010-01-22 - Added support for two channels in normal operation.
- Added support to announce matches left in both channels
- Bump default value to SPDC 11.xx
- Added some text at the end of Pairings and Results announcements.
2010-01-28 - Added more text to the paste results and pairings based on the round clicker
- Switched all text to the right windows, you can coordinate the windows once.
- Added some more documentation at the top.
2010-02-02 - Made the round clicker automatically tick up after posting results
2010-03-25 - Sped up Channel text.
- Added "normal" channel spammage every 5 minutes.
2010-04-01 - Fixed the ability to drop players by clicking, and announce when players are dropped
- Refactor some of the code to make it cleaner
- You can now manually add players on the bottom
- Mouse speed is SUPER fast now when it doesn't break
2010-04-08 - Player name is cleared after an add
- Reg sensing mouse doesn't double-click anymore and open PM boxes
- Remove a ton of variables that we aren't using (leftover from bot)
- Make chat pos variables arrays to reduce var count
- Make DCI-R entering faster
2010-04-22 - Addded "Paste slowly" for pasting rules at the start of tourneys.
2010-05-?? - Tweaks to the timing so that the paste buffer isn't messed up.
2010-06-10 - Alphabetize names (case insensitive) in the player list to make it easier to find them
- Add randomly pick a player from remaining (for door prizes, etc)
- Count down minutes left in registration (new counter on GUI)
- Automatically announce when registration is over
2010-07-08 - Increased the time for the pasting, because sometimes it wasn't waiting long enough
for windows to update the clipboard.
- Added the ability to copy the list of players registered to your clipboard with F14
- Number of matches left will round down now
2010-07-15 - Added pre-reg countdown, every 5 minutes before the reg starts it will announce that reg is coming up.
2010-12-02 - Keep track of how many players there are - announce when there will be more rounds and/or more top 8
- (use the morePlayersAnnouncements array.)
2011-02-12 - Refined GUI. Made it a bit smaller and buttons are more gridded out now.
- Red and Green button colors for Registration / Pre-Registration running.
- Check that the positions are set before actually doing things.
- Other minor code changes.
- Bump version to v1. First public release.
#CE
;;;; CONFIGURATION VARIABLES FOR TOURNAMENT CUSTOMIZATION ;;;;
; Announcement threshholds and announcements.
Dim $morePlayersAnnouncements[3]
$morePlayersAnnouncements[0] = "18,[sSET ALA R] WE NOW HAVE 18 REGISTERED PLAYERS AND WILL PLAY **TOP 8 FINALS** [sSET ALA R]"
$morePlayersAnnouncements[1] = "24,[sSET ALA R] WE NOW HAVE 24 REGISTERED PLAYERS AND WILL PLAY **4 ROUNDS OF SWISS** AND **TOP 8 FINALS** [sSET ALA R]"
$morePlayersAnnouncements[2] = "40,[sSET ALA R] WE NOW HAVE 40 REGISTERED PLAYERS AND WILL PLAY **5 ROUNDS OF SWISS** AND **TOP 8 FINALS** [sSET ALA R]"
; Channel names, used in announcements
$comChannelName = "spdccom"
$normalChannelName = "pdc"
$defaultTourneyName = "SPDC 19."
; How long to wait when pasting into chat from the clipboard, in milliseconds.
$clipboardChatDelay = 500
;;;; CONFIG ENDS HERE ;;;;
#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <ListboxConstants.au3>
#include <ScreenCapture.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
$dll = DllOpen("user32.dll")
Dim $guimsg
Dim $RegisteredPlayerArray[999]
Dim $registeredplayers ; valid entries in RegisteredPlayerArray
Dim $NewRegisteredPlayerArray[99]
Dim $newregisteredplayers ; new registrants since the last time we announced.
Dim $registeredplayersannounced ; set to 1 when we want to announce a registration
Dim $maxRegisteredPlayers ; the maximum number of players to be announced yet.
; Positions on the screen
Dim $chatpos[2]
$chatpos[0] = -1
$chatpos[1] = -1
Dim $comchatpos[2]
$comchatpos[0] = -1
$comchatpos[1] = -1
Dim $dcirpos[2]
$dcirpos[0] = -1
$dcirpos[1] = -1
Global $chatLocationSet = False
Dim $comChannelName
Dim $normalChannelName
Dim $manualAddPlayer
Dim $preRegTimer
$maxtime = 600000
$registeredplayers = 0
$maxRegisteredPlayers = 0
$lastregisterednotice = -1
$notRunningColor = 0xff1111
$runningColor = 0x11ff11
Global $regRunning = False
Global $preRegRunning = False
ShowMainWindow()
GuiWait()
Func ShowMainWindow()
$guiwidth = 270
$guiheight = 700
$cellSpacing = 5
$margins = 10
$rowheight = 20
$rowTopOffset = $rowheight + $cellSpacing
$oneThirdWidth = ($guiwidth - ($cellSpacing * 2) - ($margins * 2)) / 3
$halfThirdWidth = ($oneThirdWidth - $cellSpacing) / 2
Dim $columnLeft[3]
$columnLeft[0] = $margins
$columnLeft[1] = $columnLeft[0] + $oneThirdWidth + $cellSpacing
$columnLeft[2] = $columnLeft[1] + $oneThirdWidth + $cellSpacing
Global $gui = GUICreate ( "Unsilent Attendant v1 - by Michael Janssen", $guiwidth, $guiheight, @DesktopWidth-$guiwidth, 0)
$row = 0
Global $getchatposbtn = GUICtrlCreateButton( "Set Chat Pos" , $columnLeft[0], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
Global $getdcirposbtn = GUICtrlCreateButton( "Set DCIR Pos" , $columnLeft[1], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
Global $chatPairingsBtn = GUICtrlCreateButton( "Paste Pairings", $columnLeft[2], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
$row = 1
Global $timeleftannedit = GUICtrlCreateInput( "None", $columnLeft[0], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
Global $dcirenterbtn = GUICtrlCreateButton( "Reg into DCIR", $columnLeft[1], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
Global $chatResultsBtn = GUICtrlCreateButton( "Paste Results", $columnLeft[2], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
$row = 2
Global $preRegButton = GUICtrlCreateButton ( "Pre", $columnLeft[0], $margins + ($row * $rowTopOffset), $halfThirdWidth, $rowheight)
Global $registBtn = GUICtrlCreateButton ( "Reg", $columnLeft[0] + $cellSpacing + $halfThirdWidth, $margins + ($row * $rowTopOffset), $halfThirdWidth, $rowheight)
Global $autoRunRegBtn = GUICtrlCreateCheckbox( "Auto Reg", $columnLeft[1], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
Global $tourneynameEdit = GuiCtrlCreateInput( $defaultTourneyName, $columnLeft[2], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
GUICtrlSetBkColor( $preRegButton, $notRunningColor )
GUICtrlSetBkColor( $registBtn, $notRunningColor )
$row = 3
Global $matchesLeftClicker = GUICtrlCreateInput( "10", $columnLeft[0], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
GUICtrlCreateUpdown($matchesLeftClicker)
Global $roundLeftClicker = GUICtrlCreateInput( "1", $columnLeft[1], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
GUICtrlCreateUpdown($roundLeftClicker)
Global $roundLeftBtn = GUICtrlCreateButton( "Ann. Matches", $columnLeft[2], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
$row = 4
Global $pasteSlowlyBtn = GUICtrlCreateButton("Paste to chat", $columnLeft[0], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
Global $regMinsLeftClicker = GUICtrlCreateInput( "30", $columnLeft[1], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
GUICtrlCreateUpdown($regMinsLeftClicker)
Global $randomPlayerBtn = GUICtrlCreateButton("Random Player", $columnLeft[2], $margins + ($row * $rowTopOffset), $oneThirdWidth, $rowheight)
$row = 5
Global $regGUIlist = GUICtrlCreateList("", $columnLeft[0], $margins + ($row * $rowTopOffset), $guiwidth - ($margins * 2), $guiheight - $margins - ($row * $rowTopOffset) - ($rowheight + $cellSpacing) - $cellSpacing, $LBS_NOSEL + $WS_VSCROLL + $WS_BORDER)
$row = 9999
; Spans 2 columns
Global $manualAddPlayer = GUICtrlCreateInput( "", $columnLeft[0], $guiheight - ($rowheight + $margins), ($oneThirdWidth * 2) + $cellSpacing, $rowheight)
Global $manualAddPlayerBtn = GUICtrlCreateButton("Add Player", $columnLeft[2], $guiheight - ($rowheight + $margins), $oneThirdWidth, $rowheight)
GUISetState ()
EndFunc
Func GuiWait() ;Wait for user to select something.
While 1
$guimsg = GUIGetMsg()
Select
Case $guimsg = $getchatposbtn
getChatPos()
Case $guimsg = $getdcirposbtn
getDciPos()
Case $guimsg = $dcirenterbtn
If $dcirpos[0] = -1 Then
MsgBox( 0x10, "Position missing", "Please set the DCI-R registrant field position")
Else
enterRegistrantsToDciR()
EndIf
Case $guimsg = $chatPairingsBtn
chatPairingsFromClipboard()
Case $guimsg = $chatResultsBtn
chatResultsFromClipboard()
Case $guimsg = $pasteSlowlyBtn
chatFromClipboardSlowly()
Case $guimsg = $roundLeftBtn
chatMatchesLeft()
Case $guimsg = $registBtn
If $chatpos[0] = -1 Then
MsgBox( 0x10, "Position missing", "Please set the chat positions before starting registration")
Else
$tourneyName = GUICtrlRead($tourneynameEdit)
channelText($tourneyName & " Registration is NOW open! Register by typing 'reg' in /join " & $comChannelName)
comChannelText($tourneyName & " Registration is NOW open! Register by typing 'reg' in this channel!")
$regRunning = True
runRegistration()
comChannelText("[sSET ROE R] Registration is NOW CLOSED for " & $tourneyName & " - Any more registrations are at the discretion of the organizer (that's me).[sSET ROE R]")
channelText("[sSET ROE R] Registration is NOW CLOSED for " & $tourneyName & " - Any more registrations are at the discretion of the organizer (that's me).[sSET ROE R]")
$regRunning = False
EndIf
Case $guimsg = $randomPlayerBtn
RandomlyPickPlayer()
Case $guimsg = $preRegButton
If $chatpos[0] = -1 Then
MsgBox( 0x10, "Position missing", "Please set the chat positions before starting registration")
Else
If $preRegRunning Then
$preRegRunning = False
GUICtrlSetBkColor( $preRegButton, $notRunningColor )
Else
$preRegRunning = True
GUICtrlSetBkColor( $preRegButton, $runningColor )
$preRegTimer = TimerInit() - 60000
EndIf
EndIf
Case _IsPressed("7D", $dll) ; F14
ClipPutPlayerList()
Case Else
GuiAlwaysOnCheck($guimsg)
EndSelect
sleep(20)
WEnd
EndFunc
Func Close() ;close gui and terminate script
Exit
EndFunc
Func GuiAlwaysOnCheck($guimsg = False)
If not $guimsg Then
$guimsg = GUIGetMsg()
EndIf
Select
Case $guimsg = $manualAddPlayerBtn
$newplayer = GUICtrlRead($manualAddPlayer)
If $newplayer <> "" Then
addRegistrant($newplayer)
If $chatLocationSet Then
comChannelText("Host added registrant: " & $newplayer)
EndIf
GUICtrlSetData($manualAddPlayer, "")
EndIf
Case $guimsg = $regGUIlist
unregisterClickedPlayerList()
Case $guimsg = -3
Close()
EndSelect
If $preRegRunning And TimerDiff($preRegTimer) > 60000 Then ; 1 minute
$minsLeft = GuiCtrlRead($regMinsLeftClicker)
$minsLeft = $minsLeft - 1
if Mod($minsLeft, 5) == 0 Then
$tourneyName = GUICtrlRead($tourneynameEdit)
channelText("Registration for " & $tourneyName & " is in " & $minsLeft & " minutes! Stay tuned!");
EndIf
GUICtrlSetData($regMinsLeftClicker, $minsLeft)
$preRegTimer = TimerInit()
EndIf
Return
EndFunc
; Type something into a channel box at position x, y
Func chatAtChannel($saythis, $chatx, $chaty)
$prevmousepos = MouseGetPos()
$prevclip = ClipGet()
; Type the text into the channel at the default opening location.
MouseClick("left", $chatx, $chaty, 1, 0)
sleep(20)
MouseClick("left", $chatx, $chaty, 1, 0)
sleep(100)
ClipPut($saythis)
sleep(200)
Send("^v{ENTER}")
ClipPut($prevclip)
MouseMove($prevmousepos[0], $prevmousepos[1], 0)
EndFunc
Func channelText($saythis) ;Type something into the main channel
chatAtChannel($saythis, $chatpos[0], $chatpos[1])
EndFunc
Func comChannelText($saythis) ;Type something into the registration / results channel
chatAtChannel($saythis, $comchatpos[0], $comchatpos[1])
EndFunc
Func waitForSpaceBarPos() ; Waits for a spacebar hit, and returns the location of the mouse.
While 1
If _IsPressed("20", $dll) Then
Return MouseGetPos()
EndIf
Sleep(20) ; Don't take up all CPU
WEnd
EndFunc
Func getChatPos() ; Query the user for the chat window positions
MsgBox(262144, "Get Chat Position", "Move the mouse to the position that the chat window is, and hit the SPACEBAR");
$chatpos = waitForSpaceBarPos()
MsgBox(262144, "Chat Position Set", "Chat Position Set to " & $chatpos[0] & ", " & $chatpos[1]);
MsgBox(262144, "Get Com Chat Position", "Move the mouse to the position that the registration chat window is, and hit the SPACEBAR");
$comchatpos = waitForSpaceBarPos()
MsgBox(262144, "Tourney Chat Position Set", "Tourney Chat Position Set to " & $comchatpos[0] & ", " & $comchatpos[1]);
$chatLocationSet = True
EndFunc
Func getDciPos() ; Query the user for the DCI-R Registration positions
MsgBox(262144, "Get DCI-R Position", "Move the mouse to the position that the DCI-R player entry is, and hit the SPACEBAR");
$dcirpos = waitForSpaceBarPos()
MsgBox(262144, "DCI-R Position Set", "DCI-R Position Set to " & $dcirpos[0] & ", " & $dcirpos[1]);
EndFunc
Func enterRegistrantsToDciR() ; Enter the registrants into the DCI-R
For $i = 0 to ($registeredplayers - 1)
MouseClick("left", $dcirpos[0], $dcirpos[1], 1, 0)
Sleep(50)
Send("x{TAB}")
Sleep(50)
Send($RegisteredPlayerArray[$i], 1)
Sleep(50)
Send("{ENTER}")
Sleep(50)
Next
EndFunc
Func runRegistration() ; Start the tournament!
GuiCtrlSetBkColor( $registBtn, $runningColor )
$startTime = TimerInit() - 60000
$checkTime = TimerInit() - 10000
$chatSpamTime = TimerInit() - 300000
$backisred = False
while 1
$secondsBeforeAd = 60 - Int(TimerDiff($startTime) / 1000)
GUICtrlSetData( $timeleftannedit, String($secondsBeforeAd))
if ($secondsBeforeAd <= 10 And not $backisred) Then
GUICtrlSetBkColor( $timeleftannedit, 0xff0000)
$backisred = true
ElseIf ($backisred and $secondsBeforeAd > 10) Then
GUICtrlSetBkColor( $timeleftannedit, 0xffffff)
$backisred = false
EndIf
; run an ad in the CHAT channel every 5 minutes
if TimerDiff($chatSpamTime) > 300000 then
$tourneyName = GUICtrlRead($tourneynameEdit)
$minsLeft = GUICtrlRead($regMinsLeftClicker)
channelText($tourneyName & " Registration is OPEN for " & $minsLeft & " more minutes! To register, type REG in /join " & $comChannelName)
$chatSpamTime = TimerInit()
EndIf
; run an ad in COM if it's been idle more than 60 seconds
if TimerDiff($startTime) > 60000 then
$minsLeft = GUICtrlRead($regMinsLeftClicker)
$minsLeft -= 1
comChannelText($minsLeft & " minutes left in registration - To register, type REG in this channel")
GUICtrlSetData($regMinsLeftClicker, $minsLeft)
If $registeredplayers > 0 Then
$registeredNow = $registeredplayers & " Currently Registered: "
For $i = 0 to ($registeredplayers - 1)
$registeredNow = $registeredNow & $RegisteredPlayerArray[$i] & " "
Next
comChannelText($registeredNow)
EndIf
$startTime = TimerInit() ; reset the timer
endif
;If _IsPressed("1B", $dll) Then ; Pressing escape stops registration
; Return
;EndIf
$timeCheckNow = (TimerDiff($checkTime) > 10000) and (GUICtrlRead($autoRunRegBtn) = $GUI_CHECKED)
If _IsPressed("7C", $dll) or $timeCheckNow Then ; Pressing F13 = scan players
processNewRegistrants()
$checkTime = TimerInit()
EndIf
$guimsg = GUIGetMsg()
Select
Case $guimsg = $registBtn
GuiCtrlSetBkColor( $registBtn, $notRunningColor )
Return
Case Else
GuiAlwaysOnCheck($guimsg)
EndSelect
Sleep(50)
WEnd
EndFunc
Func processNewRegistrants() ; Process the New registrants in the channel
$newlines = getAllLines()
For $linenum = 0 to 6
$matches = StringRegExp( $newlines[$linenum] , "\[b\](.+)\[\/b\]: *[Rr][Ee][Gg]", 1)
If @error = 0 Then
addRegistrant($matches[0])
ElseIf @error = 2 Then
MsgBox(0, "Debug", "Regexp Error at char " & String(@extended))
EndIf
Next
if $registeredplayersannounced <> $registeredplayers Then
if $newregisteredplayers > 0 Then
Local $registeredList
$registeredList = String($registeredplayers) & " Players Registered - just added " & $NewRegisteredPlayerArray[0] ; Always at least one here now
For $i = 2 to $newregisteredplayers
$registeredList = $registeredList & ", " & $NewRegisteredPlayerArray[($i - 1)]
Next
$newregisteredplayers = 0
ElseIf $registeredplayers > 0 Then
$registeredList = String($registeredplayers) & " Players Registered! " & $RegisteredPlayerArray[$registeredplayers - 1] & " was the last to register."
Else
$registeredList = "No players registered! Be the first to register!"
EndIf
comChannelText($registeredList)
$registeredplayersannounced = $registeredplayers
EndIf
EndFunc
; player clicked on for droppage in list.
Func unregisterClickedPlayerList()
; Unregister the player that was clicked on
$playerGone = GUICtrlRead($regGUIlist)
If delRegistrant($playerGone) Then
If $regRunning Then
comChannelText("Host has dropped " & $playerGone & " from the tournament. Please type 'reg' again if you change your mind, " & $playerGone & "!")
Else
$tourneyName = GUICtrlRead($tourneynameEdit)
comChannelText("Host has dropped " & $playerGone & " from the tournament. Thanks for playing "& $tourneyName & "!")
EndIf
EndIf
EndFunc
Func refreshPlayerListCtrl()
$RegisteredPlayerArray = ArraySortInsensitive($RegisteredPlayerArray, $registeredplayers)
$regListString = "|"
For $i = 0 to ($registeredplayers - 1)
$regListString = $regListString & $RegisteredPlayerArray[$i] & "|"
Next
GUICtrlSetData( $regGUIlist, $regListString )
EndFunc
Func isRegistered($player)
For $i = 0 to ($registeredplayers - 1)
If StringCompare($player, $RegisteredPlayerArray[$i]) = 0 Then
return $i
ExitLoop
EndIf
Next
return -1
EndFunc
Func addRegistrant($newRegistrant)
; Check to see if they are in the registrants already
if isRegistered($newRegistrant) == -1 Then
$RegisteredPlayerArray[$registeredplayers] = $newRegistrant
$NewRegisteredPlayerArray[$newregisteredplayers] = $newRegistrant
$registeredplayers += 1
$newregisteredplayers += 1
refreshPlayerListCtrl()
EndIf
if $maxRegisteredPlayers < $registeredplayers Then
morePlayersAnnouncements($registeredplayers)
$maxRegisteredPlayers = $registeredplayers
EndIf
EndFunc
Func delRegistrant($oldRegistrant)
$regplace = isRegistered($oldregistrant)
If $regplace <> -1 Then
For $i = $regplace to ($registeredplayers - 2)
$RegisteredPlayerArray[$i] = $RegisteredPlayerArray[$i + 1]
Next
$registeredplayers -= 1
refreshPlayerListCtrl()
EndIf
Return $regplace <> -1
EndFunc
Func morePlayersAnnouncements($playerAmt)
For $i = 0 to UBound($morePlayersAnnouncements) - 1
$tmpAr = StringSplit($morePlayersAnnouncements[$i], ",")
$announcementAmt = Int($tmpAr[1])
$announcementText = $tmpAr[2]
If $playerAmt == $announcementAmt Then
channelText($announcementText)
comChannelText($announcementText)
EndIf
Next
EndFunc
Func getAllLines() ; Returns lines in reverse chronological
$prevmousepos = MouseGetPos()
Local $thelines[7], $channelliney
$channelliney = $comchatpos[1] - 30;
MouseClick("left", $comchatpos[0], $channelliney, 1, 2)
Sleep(50)
For $line = 6 to 0 Step -1
Send("{CTRLDOWN}c{CTRLUP}") ; Copy the text
Sleep(100)
$thelines[$line] = ClipGet()
Send("{UP}")
Sleep(100)
Next
MouseMove($prevmousepos[0], $prevmousepos[1], 0)
return $thelines
EndFunc
Func chatPairingsFromClipboard() ; Enter the pairings which should be in the clipboard.
$cliptext = ClipGet()
If @error == 1 then
MsgBox(262144, "Error", "No text on clipboard!")
EndIf
$roundNum = GUICtrlRead($roundLeftClicker)
channelText("/me [sSET ZEN R] [sLizard]Pairings for Round " & $roundNum & ":[sSET ZEN R]" )
$array = StringSplit($cliptext, @CR, 1)
For $linenum = 1 to $array[0]
$line = $array[$linenum]
If StringInStr($line, "* BYE *") <> 0 Then
$regexp = StringRegExp($line, "^\s*\d*\s*(.+?)\,.*$", 1)
if @error = 0 Then
channelText("/me : " & $regexp[0] & " has a BYE")
EndIf
Else
; 30 redxny, x 13 Throoper, x
$regexp = StringRegExp($line, "^\s*\d*\s*(.+?)\,\s*(x|New Player|NP|OP|LE)?\s+[-\d]*\s*\d+\s+(.+?)\,.*$", 1)
if @error = 0 Then
channelText("/me : " & $regexp[0] & " vs. " & $regexp[2] )
EndIf
EndIf
Next
channelText("/me [sSET ALA R] [sLizard]Good luck everyone![sLizard] [sSET ALA R]")
comChannelText("/me [sSET ALA R] ROUND " & $roundNum & " RESULTS [sSET ALA R]")
EndFunc
Func chatResultsFromClipboard() ; Enter the pairings which should be in the clipboard.
$cliptext = ClipGet()
If @error == 1 then
MsgBox(262144, "Error", "No text on clipboard!")
EndIf
$array = StringSplit($cliptext, @CR, 1)
$roundNum = GUICtrlRead($roundLeftClicker)
comChannelText("/me [sSET ZEN R] [sLizard] Round " & $roundNum & " complete. Check your results in /join " & $normalChannelName)
channelText("/me [sSET ZEN R] [sLizard] Results for Round " & $roundNum & ":[sSET ZEN R]" )
For $linenum = 1 to $array[0]
$line = $array[$linenum]
If StringInStr($line, "* BYE *") <> 0 Then
$regexp = StringRegExp($line, "^\s*\d*\s*(.+?)\,.*$", 1)
if @error = 0 Then
channelText("/me : " & $regexp[0] & " had a BYE")
EndIf
Else
; 30 redxny, x 13 Throoper, x
$regexp = StringRegExp($line, "^\s*(.+?)\,\s*(x|New Player|NP|OP|LE)?\s+(.+?)\,\s*(x|New Player|NP|OP|LE)?\D*(\d)-(\d)\s*$", 1)
if @error = 0 Then
$winner = $regexp[0]
$loser = $regexp[2]
$winnerscore = $regexp[4]
$loserscore = $regexp[5]
if Int( $regexp[4] ) < Int( $regexp[5]) Then
$tmp = $winner
$winner = $loser
$loser = $tmp
$tmp = $winnerscore
$winnerscore = $loserscore
$loserscore = $tmp
EndIf
channelText("/me : " & $winner & " defeated " & $loser & ", " & $winnerscore & "-" & $loserscore)
EndIf
EndIf
Next
channelText("/me [sSET ZEN R] [sLizard]Please check your results for errors. The next round starts in 2 minutes![sSET ZEN R]")
$roundNum = $roundNum + 1
GUICtrlSetData($roundLeftClicker, $roundNum)
$matchesInNextRound = Floor($registeredplayers / 2)
GUICtrlSetData($matchesLeftClicker, $matchesInNextRound)
EndFunc
Func chatFromClipboardSlowly() ; Enter the text slowly.
$cliptext = ClipGet()
If @error == 1 then
MsgBox(262144, "Error", "No text on clipboard!")
EndIf
$array = StringSplit($cliptext, @CR, 1)
For $linenum = 1 to $array[0]
$line = $array[$linenum]
$line = StringStripWS($line, 3)
channelText($line)
Sleep($clipboardChatDelay)
Next
EndFunc
Func chatMatchesLeft() ; Chat the number of matches left to the channel
$roundNum = GUICtrlRead($roundLeftClicker)
$matchesLeft = GUICtrlRead($matchesLeftClicker)
$annText = "/me [sSET CHK C] " & $matchesLeft & " matches remaining in round " & $roundNum
if $matchesLeft = 1 Then
$annText = "/me [sSET CHK R] 1 match remaining in round " & $roundNum & ".."
ElseIf $matchesLeft = 2 Then
$annText = "/me [sSET CHK U] 2 matches remaining in round " & $roundNum & "."
EndIf
channelText($annText)
comChannelText($annText)
EndFunc
Func RandomlyPickPlayer()
SRandom(@MSEC)
$playerNum = Random(0, $registeredplayers - 1, 1)
MsgBox(262144, "Random Player", "The Player Chosen is: " & $RegisteredPlayerArray[$playerNum])
EndFunc
Func ClipPutPlayerList()
If $registeredPlayers == 0 Then
Return
EndIf
$playerListText = $RegisteredPlayerArray[0]
For $i = 1 to ($registeredplayers - 1)
$playerListText = $playerListText & ", " & $RegisteredPlayerArray[$i]
Next
ClipPut($playerListText)
EndFunc
Func ArraySortInsensitive($origList, $numElements)
Local $newList[UBound($origList)+1]
Local $minPos
For $insertPos = 0 to $numElements-1
$minPos = -1
For $arPos = 0 to $numElements-1
If $minPos == -1 and Not ($origList[$arPos] == "") Then
$minPos = $arPos
ElseIf Not ($origList[$arPos] == "") And (StringCompare($origList[$arPos], $origList[$minPos], 2) < 0) Then
$minPos = $arPos
EndIf
Next
$newList[$insertPos] = $origList[$minPos]
$origList[$minPos] = ""
Next
Return $newList
EndFunc