forked from lemasato/POE-Trades-Companion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
POE Trades Companion.ahk
7076 lines (6118 loc) · 272 KB
/
POE Trades Companion.ahk
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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* POE Trades Companion *
* See all the information about the trade request upon receiving a poe.trade whisper *
* *
* https://github.com/lemasato/POE-Trades-Companion/ *
* https://www.reddit.com/r/pathofexile/comments/57oo3h/ *
* https://www.pathofexile.com/forum/view-thread/1755148/ *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#Warn LocalSameAsGlobal, StdOut
OnExit("Exit_Func")
#SingleInstance Off
#Persistent
#NoEnv
SetWorkingDir, %A_ScriptDir%
FileEncoding, UTF-8 ; Required for cyrillic characters
#KeyHistory 0
SetWinDelay, 0
DetectHiddenWindows, Off
ListLines, Off
Menu,Tray,Tip,POE Trades Companion
Menu,Tray,NoStandard
Menu,Tray,Add,Close,Exit_Func
; Creating Window Switch Detect
Gui +LastFound
Hwnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,Hwnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage")
Start_Script()
Return
Start_Script() {
/*
*/
; Global objects declaration
global DebugValues := {} ; Debug values
global ProgramValues := {} ; Specific to the program's informations
global ProgramFonts := {} ; Fonts private to the program
global ProgramSettings := {} ; Settings from the local .ini
global RunParameters := {} ; Run-time parameters
global GameSettings := {} ; Settings from the game .ini
global TradesGUI_Values := {} ; TradesGUI various infos
global TradesGUI_Controls := {} ; TradesGUI controls handlers
global Stats_TradeCurrencyNames := {} ; Abridged currency names from poe.trade
global Stats_RealCurrencyNames := {} ; All currency full names
global Trading_Leagues := [] ; Contains trading leagues
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; ProgramValues.Keep_Backup := 1 ; Keep Trades_Backup.ini instead of deleting it on load.
ProgramSettings.Screen_DPI := Get_DPI_Factor()
Handle_CommandLine_Parameters()
MyDocuments := (RunParameters.MyDocuments)?(RunParameters.MyDocuments):(A_MyDocuments)
ProgramValues.Name := "POE Trades Companion"
ProgramValues.Version := "1.12.BETA_5"
ProgramValues.Updater_File := "POE-TC-Updater.exe"
ProgramValues.Updater_Link := "https://raw.githubusercontent.com/lemasato/POE-Trades-Companion/master/Updater_v2.exe"
ProgramValues.Updater_Link_Beta := "https://raw.githubusercontent.com/lemasato/POE-Trades-Companion/dev/Updater_v2.exe"
ProgramValues.Version_Link := "https://raw.githubusercontent.com/lemasato/POE-Trades-Companion/master/version.txt"
ProgramValues.Version_Link_Beta := "https://raw.githubusercontent.com/lemasato/POE-Trades-Companion/dev/version.txt"
ProgramValues.NewVersion_File := "POE-TC-NewVersion.exe"
ProgramValues.NewVersion_Link := "https://raw.githubusercontent.com/lemasato/POE-Trades-Companion/master/POE Trades Companion.exe"
ProgramValues.NewVersion_Link_Beta := "https://raw.githubusercontent.com/lemasato/POE-Trades-Companion/dev/POE Trades Companion.exe"
ProgramValues.Changelogs_Link := "https://raw.githubusercontent.com/lemasato/POE-Trades-Companion/master/changelogs.txt"
ProgramValues.Changelogs_Link_Beta := "https://raw.githubusercontent.com/lemasato/POE-Trades-Companion/dev/changelogs.txt"
ProgramValues.Reddit := "https://redd.it/57oo3h"
ProgramValues.GGG := "https://www.pathofexile.com/forum/view-thread/1755148/"
ProgramValues.GitHub := "https://github.com/lemasato/POE-Trades-Companion"
ProgramValues.Paypal := "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BSWU76BLQBMCU"
ProgramValues.Local_Folder := MyDocuments "\AutoHotkey\" ProgramValues.Name
ProgramValues.SFX_Folder := ProgramValues.Local_Folder "\SFX"
ProgramValues.Logs_Folder := ProgramValues.Local_Folder "\Logs"
ProgramValues.Skins_Folder := ProgramValues.Local_Folder "\Skins"
ProgramValues.Fonts_Folder := ProgramValues.Local_Folder "\Fonts"
ProgramValues.Data_Folder := ProgramValues.Local_Folder "\Data"
ProgramValues.Others_Folder := ProgramValues.Local_Folder "\Others"
ProgramValues.Fonts_Settings_File := ProgramValues.Fonts_Folder "\Settings.ini"
ProgramValues.Ini_File := ProgramValues.Local_Folder "\Preferences.ini"
ProgramValues.Logs_File := ProgramValues.Logs_Folder "\" A_YYYY "-" A_MM "-" A_DD "_" A_Hour "-" A_Min "-" A_Sec ".txt"
ProgramValues.Changelogs_File := ProgramValues.Logs_Folder "\changelogs.txt"
ProgramValues.Trades_History_File := ProgramValues.Local_Folder "\Trades_History.ini"
ProgramValues.Trades_Backup_File := ProgramValues.Local_Folder "\Trades_Backup.ini"
ProgramValues.Game_Folder := MyDocuments "\my games\Path of Exile"
ProgramValues.Game_Ini_File := ProgramValues.Game_Folder "\production_Config.ini"
ProgramValues.Game_Ini_File_Copy := ProgramValues.Local_Folder "\production_Config.ini"
ProgramSettings.Support_Message := "@%buyerName% " ProgramValues.Name ": view-thread/1755148"
ProgramValues.PID := DllCall("GetCurrentProcessId")
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GroupAdd, POEGame, ahk_exe PathOfExile.exe
GroupAdd, POEGame, ahk_exe PathOfExile_x64.exe
GroupAdd, POEGame, ahk_exe PathOfExileSteam.exe
GroupAdd, POEGame, ahk_exe PathOfExile_x64Steam.exe
global POEGameArray := ["PathOfExile.exe", "PathOfExile_x64.exe", "PathOfExileSteam.exe", "PathOfExile_x64Steam.exe"]
global POEGameList := "PathOfExile.exe,PathOfExile_x64.exe,PathOfExileSteam.exe,PathOfExile_x64Steam.exe"
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Debug options
Load_Debug_JSON()
; Data currency
FileRead, allCurrency,% ProgramValues.Data_Folder "\Resources\Data\Currency_All.txt"
Loop, Parse, allCurrency, `n`r
{
if ( A_LoopField ) {
Stats_RealCurrencyNames .= A_LoopField ","
}
}
StringTrimRight, Stats_RealCurrencyNames, Stats_RealCurrencyNames, 1 ; Remove last comma
; Data currency names converter
FileRead, JSONFile,% ProgramValues.Data_Folder "\Resources\Data\currencyTradeNames.json"
parsedJSON := JSON.Load(JSONFile)
Stats_TradeCurrencyNames := parsedJSON.currencyNames.eng
; Directories Creation
directories := ProgramValues.Local_Folder
. "`n" ProgramValues.SFX_Folder
. "`n" ProgramValues.Logs_Folder
. "`n" ProgramValues.Skins_Folder
. "`n" ProgramValues.Fonts_Folder
. "`n" ProgramValues.Others_Folder
. "`n" ProgramValues.Data_Folder
Loop, Parse, directories,% "`r`n"
{
if (!InStr(FileExist(A_LoopField), "D")) {
FileCreateDir, % A_LoopField
}
}
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Run_As_Admin()
Close_Previous_Program_Instance()
Tray_Refresh()
Update_Local_Settings() ; Updating local settings between versions
; Extracting assets
Extract_Assets()
Install_Font_Files()
Manage_Font_Resources("LOAD")
Update_Skin_Preset()
Set_Local_Settings() ; Reset broken settings
localSettings := Get_Local_Settings()
Declare_Local_Settings(localSettings)
settings := Get_Game_Settings()
Declare_Game_Settings(settings)
Create_Tray_Menu()
Delete_Old_Logs_Files(10)
Load_Skin_Assets()
Check_Update()
Enable_Hotkeys()
Get_Active_Trading_Leagues()
; Opening different GUIs
if (DebugValues.settings.open_stats)
Gui_Stats()
if (DebugValues.settings.open_settings)
Gui_Settings()
if (DebugValues.settings.open_about)
Gui_About()
; Pre-rendering Trades-GUI
if !( DebugValues.settings.no_prerender)
Gui_Trades("CREATE")
; Parse debug msgs
if (DebugValues.settings.use_chat_logs) {
Loop % DebugValues.chatlogs.MaxIndex()
Filter_Logs_Message(DebugValues.chatlogs[A_Index])
}
Gui_Trades_Load_Pending_Backup()
Logs_Append("DUMP", localSettings)
Monitor_Game_Logs()
}
Load_Debug_JSON() {
global DebugValues
if !(A_IsCompiled) {
FileRead, debugJSON,% A_ScriptDir "\Debug.json"
parsed_debugJSON := JSON.Load(debugJSON)
DebugValues.settings := parsed_debugJSON.settings
DebugValues.chatlogs := parsed_debugJSON.chat_logs
}
}
Update_Skin_Preset() {
/* Temporary solution (?)
Retrieve the current preset and update the .ini file with the new settings
*/
global ProgramValues
IniRead, activePreset,% ProgramValues.Ini_File,CUSTOMIZATION_APPEARANCE,Active_Preset
if (activePreset = "User Defined")
Return
; Applying font settings
iniFile := ProgramValues.Ini_File
skinSettingsFile := ProgramValues.Skins_Folder "\" activePreset "\Settings.ini"
iniSect := "CUSTOMIZATION_APPEARANCE"
iniKeys := ["Font","Font_Size_Custom","Font_Quality_Custom"]
skinSect := "FONT"
skinKeys := ["Name","Size","Quality"]
for id, key in skinKeys {
IniRead, value,% skinSettingsFile,% skinSect,% key
IniWrite,% value,% iniFile,% iniSect,% iniKeys[id]
}
IniWrite,% "Automatic",% iniFile,% iniSect,% "Font_Size_Mode"
IniWrite,% "Automatic",% iniFile,% iniSect,% "Font_Quality_Mode"
; Applying colour settings
iniSect := "CUSTOMIZATION_APPEARANCE"
iniKeys := ["Color_Title_Active","Color_Title_Inactive","Color_Trades_Infos_1","Color_Trades_Infos_2","Color_Border"
,"Color_Tab_Active","Color_Tab_Inactive","Color_Tab_Hover","Color_Tab_Press"
,"Color_Tab_Joined_Active","Color_Tab_Joined_Inactive","Color_Tab_Joined_Hover","Color_Tab_Joined_Press"
,"Color_Tab_Whisper_Active","Color_Tab_Whisper_Inactive","Color_Tab_Whisper_Hover","Color_Tab_Whisper_Press"
,"Color_Button_Normal","Color_Button_Hover","Color_Button_Press"]
skinSect := "COLORS"
skinKeys := ["Title_Trades","Title_No_Trades","Trade_Info_1","Trade_Info_2","Border"
,"Tab_Active","Tab_Inactive","Tab_Hover","Tab_Press"
,"Tab_Joined_Active","Tab_Joined_Inactive","Tab_Joined_Hover","Tab_Joined_Press"
,"Tab_Whisper_Active","Tab_Whisper_Inactive","Tab_Whisper_Hover","Tab_Whisper_Press"
,"Button_Normal","Button_Hover","Button_Press"]
for id, key in skinKeys {
IniRead, value,% skinSettingsFile,% skinSect,% key
IniWrite,% value,% iniFile,% iniSect,% iniKeys[id]
}
}
;==================================================================================================================
;
; LOGS MONITORING
;
;==================================================================================================================
Filter_Logs_Message(message) {
/* Filter the logs message to retrieve the required informations we need
and send them to the Trades GUI if it is a trade whisper.
*/
global ProgramSettings, TradesGUI_Values, Trading_Leagues, programValues
static poeTradeRegexStr := "(.*)Hi, I would like to buy your (.*) listed for (.*) in (.*)" ; 1: Other, 2: Item, 3: Price, 4: League + Tab + Other
static poeTradeUnpricedRegexStr := "(.*)Hi, I would like to buy your (.*) in (.*)" ; 1: Other, 2: Item, 3: League + Tab + Other
static poeTradeCurrencyRegexStr := "(.*)Hi, I'd like to buy your (.*) for my (.*) in (.*)" ; 1: Other, 2: Currency, 3: Price, 4: League + Tab + Other
static poeTradeStashRegexStr := "\(stash tab ""(.*)""; position: left (.*), top (.*)\)(.*)" ; 1: Tab, 2: Left, 3: Top, 4: Other
static poTradeQualityRegExStr := "level (.*) (.*)% (.*)" ; 1: Item level, 2: Item quality, 3: Item name
static poeAppRegExStr := "(.*)wtb (.*) listed for (.*) in (.*)" ; 1: Other, 2: Item, 3: Price, 4: League + Tab + Other
static poeAppUnpricedRegexStr := "(.*)wtb (.*) in (.*)" ; 1: Other, 2: Item, 3: League + Tab + Other
static poeAppStashRegexStr := "\(stash ""(.*); left (.*), top(.*)\)(.*)" ; 1: Tab, 2: Left, 3: Top, 4: Other
static poeAppQualityRegExStr := "(.*) \((.*)/(.*)%\)" ; 1: Item name, 2: Item level, 3: Item quality
static allRegexStr := {"poeTradeRegexStr":poeTradeRegexStr
,"poeTradeUnpricedRegexStr":poeTradeUnpricedRegexStr
,"poeTradeCurrencyRegexStr":poeTradeCurrencyRegexStr
,"poeAppRegExStr":poeAppRegExStr
,"poeAppUnpricedRegexStr":poeAppUnpricedRegexStr}
static areaRegexStr := ("^(?:[^ ]+ ){6}(\d+)\] : (.*?) (?:has) (joined|left) (?:the area.*)")
Loop, Parse, message, `n ; For each new individual line since last check
{
; New RegEx pattern matches the trading message, but only from whispers and local chat (for debugging), and specifically ignores global/trade/guild/party chats
if ( RegExMatch( A_LoopField, "S)^(?:[^ ]+ ){6}(\d+)\] (?=[^#$&%]).*@(?:From|De|От кого) (.*?): (.*)", subPat ) )
{
; Assigning the sub pattern variables
gamePID := subPat1, whispNameFull := subPat2, whispMsg := subPat3
whispNameFull := Gui_Trades_RemoveGuildPrefix(whispNameFull)
whispName := whispNameFull.Name, whispGuild := whispNameFull.Guild
TradesGUI_Values.Last_Whisper := whispName
if !WinActive("ahk_pid " gamePID) {
if ( ProgramSettings.Whisper_Tray ) {
Tray_Notifications_Show("Whisper from " whispName, whispMsg)
}
if ( ProgramSettings.Whisper_Flash ) {
gameHwnd := WinExist("ahk_pid " gamePID)
DllCall("FlashWindow", UInt, gameHwnd, Int, 1)
}
}
whisp := whispName ": " whispMsg "`n"
for regExName, regExStr in allRegExStr {
if RegExMatch(whisp, "iS).*: " regExStr) {
Break
}
}
if RegExMatch(whisp, "iS).*: " regExStr, whispPat ) ; Matching pattern found
{
timeSinceLastTrade := 0
if ( regExName = "poeTradeRegexStr" ) {
whispOther := whispPat1
whispItem := whispPat2
whispPrice := whispPat3
endOfWhisper := whispPat4
whispPat1 := "", whispPat2 := "", whispPat3 := "", whispPat4 := ""
for id, leagueName in Trading_Leagues {
if RegExMatch(endOfWhisper, "S)" leagueName "(.*)", endOfWhisperPat) {
whispLeague := leagueName
endOfWhisper := endOfWhisperPat1
endOfWhisperPat1 := ""
Break
}
}
if RegExMatch(endOfWhisper, "S)" poeTradeStashRegexStr, stashPat) {
whispStash := stashPat1
whispStashLeft := stashPat2
whispStashTop := stashPat3
whispOther2 := stashPat4
stashPat1 := "", stashPat2 := "", stashPat3 := "", stashPat4 := ""
}
else {
whispOther2 := endOfWhisper
}
if RegExMatch(whispItem, "S)" poTradeQualityRegExStr, itemQualPat) {
whispItemLevel := itemQualPat1
whispItemQual := itemQualPat2
whispItemName := itemQualPat3
itemQualPat1 := "", itemQualPat2 := "", itemQualPat3 := ""
}
newTradeItem := (whispItemName)?(whispItemName " Lvl:" whispItemLevel " / Qual:" whispItemQual "%"):(whispItem)
newTradePrice := whispPrice
newTradeLocation := (whispStash)?(whispLeague " (Tab:" whispStash " / Pos:" whispStashLeft ";" whispStashTop ")"):(whispLeague)
newTradeOther := (whispOther && whispOther2)?(whispOther " " whispOther2):(whispOther . whispOther2)
}
else if ( regExName = "poeTradeUnpricedRegexStr") {
whispOther := whispPat1
whispItem := whispPat2
endOfWhisper := whispPat3
whispPat1 := "", whispPat2 := "", whispPat3 := ""
for id, leagueName in Trading_Leagues {
if RegExMatch(endOfWhisper, "S)" leagueName "(.*)", endOfWhisperPat) {
whispLeague := leagueName
endOfWhisper := endOfWhisperPat1
endOfWhisperPat1 := ""
Break
}
}
if RegExMatch(endOfWhisper, "S)" poeTradeStashRegexStr, stashPat) {
whispStash := stashPat1
whispStashLeft := stashPat2
whispStashTop := stashPat3
whispOther2 := stashPat4
stashPat1 := "", stashPat2 := "", stashPat3 := "", stashPat4 := ""
}
else {
whispOther2 := endOfWhisper
}
if RegExMatch(whispItem, "S)" poTradeQualityRegExStr, itemQualPat) {
whispItemLevel := itemQualPat1
whispItemQual := itemQualPat2
whispItemName := itemQualPat3
itemQualPat1 := "", itemQualPat2 := "", itemQualPat3 := ""
}
newTradeItem := (whispItemName)?(whispItemName " (Lvl:" whispItemLevel " / Qual:" whispItemQual "%)"):(whispItem)
newTradePrice := "Unpriced Item (See Offer)"
newTradeLocation := (whispStash)?(whispLeague " (Tab:" whispStash " / Pos:" whispStashLeft ";" whispStashTop ")"):(whispLeague)
newTradeOther := (whispOther && whispOther2)?(whispOther " " whispOther2):(whispOther . whispOther2)
}
else if ( regExName = "poeTradeCurrencyRegexStr" ) {
whispOther := whispPat1
whispItem := whispPat2
whispPrice := whispPat3
endOfWhisper := whispPat4
whispPat1 := "", whispPat2 := "", whispPat3 := "", whispPat4 := ""
for id, leagueName in Trading_Leagues {
if RegExMatch(endOfWhisper, "S)" leagueName "(.*)", endOfWhisperPat) {
whispLeague := leagueName
endOfWhisper := endOfWhisperPat1
endOfWhisperPat1 := ""
Break
}
}
if RegExMatch(endOfWhisper, "S)" poeTradeStashRegexStr, stashPat) {
whispStash := stashPat1
whispStashLeft := stashPat2
whispStashTop := stashPat3
whispOther2 := stashPat4
stashPat1 := "", stashPat2 := "", stashPat3 := "", stashPat4 := ""
}
else {
whispOther2 := endOfWhisper
}
newTradeItem := whispItem
newTradePrice := whispPrice
newTradeLocation := whispLeague
newTradeOther := (whispOther && whispOther2)?(whispOther " " whispOther2):(whispOther . whispOther2)
}
else if ( regExName = "poeAppRegExStr" ) {
whispOther := whispPat1
whispItem := whispPat2
whispPrice := whispPat3
endOfWhisper := whispPat4
whispPat1 := "", whispPat2 := "", whispPat3 := "", whispPat4 := ""
for id, leagueName in Trading_Leagues {
if RegExMatch(endOfWhisper, "S)" leagueName "(.*)", endOfWhisperPat) {
whispLeague := leagueName
endOfWhisper := endOfWhisperPat1
endOfWhisperPat1 := ""
Break
}
}
if RegExMatch(endOfWhisper, "S)" poeAppStashRegexStr, stashPat) {
whispStash := stashPat1
whispStashLeft := stashPat2
whispStashTop := stashPat3
whispOther2 := stashPat4
stashPat1 := "", stashPat2 := "", stashPat3 := "", stashPat4 := ""
}
else {
whispOther2 := endOfWhisper
}
if RegExMatch(whispItem, "S)" poeAppQualityRegExStr, itemQualPat) {
whispItemName := itemQualPat1
whispItemLevel := itemQualPat2
whispItemQual := itemQualPat3
itemQualPat1 := "", itemQualPat2 := "", itemQualPat3 := ""
}
newTradeItem := (whispItemName)?(whispItemName " (Lvl:" whispItemLevel " / Qual:" whispItemQual "%)"):(whispItem)
newTradePrice := whispPrice
newTradeLocation := (whispStash)?(whispLeague " (Tab:" whispStash " / Pos:" whispStashLeft ";" whispStashTop ")"):(whispLeague)
newTradeOther := (whispOther && whispOther2)?(whispOther " " whispOther2):(whispOther . whispOther2)
}
else if ( regExName = "poeAppUnpricedRegexStr") {
whispOther := whispPat1
whispItem := whispPat2
endOfWhisper := whispPat3
whispPat1 := "", whispPat2 := "", whispPat3 := ""
for id, leagueName in Trading_Leagues {
if RegExMatch(endOfWhisper, "S)" leagueName "(.*)", endOfWhisperPat) {
whispLeague := leagueName
endOfWhisper := endOfWhisperPat1
endOfWhisperPat1 := ""
Break
}
}
if RegExMatch(endOfWhisper, "S)" poeAppStashRegexStr, stashPat) {
whispStash := stashPat1
whispStashLeft := stashPat2
whispStashTop := stashPat3
whispOther2 := stashPat4
stashPat1 := "", stashPat2 := "", stashPat3 := "", stashPat4 := ""
}
else {
whispOther2 := endOfWhisper
}
if RegExMatch(whispItem, "S)" poeAppQualityRegExStr, itemQualPat) {
whispItemName := itemQualPat1
whispItemLevel := itemQualPat2
whispItemQual := itemQualPat3
itemQualPat1 := "", itemQualPat2 := "", itemQualPat3 := ""
}
newTradeItem := (whispItemName)?(whispItemName " (Lvl:" whispItemLevel " / Qual:" whispItemQual "%)"):(whispItem)
newTradePrice := "Unpriced Item (See Offer)"
newTradeLocation := (whispStash)?(whispLeague " (Tab:" whispStash " / Pos:" whispStashLeft ";" whispStashTop ")"):(whispLeague)
newTradeOther := (whispOther && whispOther2)?(whispOther " " whispOther2):(whispOther . whispOther2)
}
newTradeItem = %newTradeItem%
newTradePrice = %newTradePrice%
newTradeLocation = %newTradeLocation%
newTradeOther = %newTradeOther%
newTradeOther := StrReplace(newTradeOther, "`n", "")
newTradeOther := ( newTradeOther && (newTradeOther = "." || newTradeOther = "`n" || newTradeOther = " ") )?("-"):(!newTradeOther)?("-"):(newTradeOther)
; Do not add the trade if the same is already in queue
tradesExists := 0
tradesInfos := Gui_Trades_Manage_Trades("GET_ALL")
Loop % tradesInfos.Max_Index {
buyerContent := tradesInfos[A_Index "_Buyer"], itemContent := tradesInfos[A_Index "_Item"], priceContent := tradesInfos[A_Index "_Price"], locationContent := tradesInfos[A_Index "_Location"], otherContent = tradesInfos[A_Index "_Other"]
if (buyerContent=whispName && itemContent=newTradeItem && priceContent=newTradePrice && locationContent=newTradeLocation) {
tradesExists := 1
}
}
; Trade does not already exist
if (tradesExists = 0) {
newTradesInfos := {Buyer:whispName
,Item:newTradeItem
,Price:newTradePrice
,Location:newTradeLocation
,PID:gamePID
,Time:A_Hour ":" A_Min
,Other:newTradeOther
,Date:A_YYYY "-" A_MM "-" A_DD
,Guild:whispGuild
,InArea:0
,NewMsg:0}
messagesArray := Gui_Trades_Manage_Trades("ADD_NEW", newTradesInfos)
Gui_Trades("UPDATE", messagesArray)
if ( ProgramSettings.Trade_Toggle = 1 ) && FileExist(ProgramSettings.Trade_Sound_Path) { ; Play the sound set for trades
SoundPlay,% ProgramSettings.Trade_Sound_Path
}
else if ( ProgramSettings.Whisper_Toggle = 1 ) && FileExist(ProgramSettings.Whisper_Sound_Path) { ; Play the sound set for whispers{
SoundPlay,% ProgramSettings.Whisper_Sound_Path
}
}
whispName := "", whispGuild := "", newTradeItem := "", newTradePrice := "", newTradeLocation := "", newTradeOther := "", gamePID := ""
}
else {
; Check existing tabs for same buyer, and add to the "Other:" slot
tradesInfos := Gui_Trades_Manage_Trades("GET_ALL")
Loop % tradesInfos.Max_Index {
if (whispName = tradesInfos[A_Index "_Buyer"]) {
otherContent := tradesInfos[A_Index "_Other"]
if (otherContent != "-" && otherContent != "`n") { ; Already contains text, include previous text
if otherContent not contains (Hover to see all messages) ; Only one message in the Other slot.
{
StringReplace, otherContent, otherContent,% "`n",% "",1 ; Remove blank lines
otherContent := "[" tradesInfos[A_Index "_Time"] "] " otherContent ; Add timestamp
}
StringReplace, otherContent, otherContent,% "(Hover to see all messages)`n",% "",1
otherText := "(Hover to see all messages)`n" otherContent "`n[" A_Hour ":" A_Min "] " whispMsg
}
else { ; Does not contains text, do not include previous text
otherText := "(Hover to see all messages)`n" "[" A_Hour ":" A_Min "] " whispMsg
}
setInfos := { OTHER:otherText, TabID:A_Index }
Gui_Trades_Set_Trades_Infos(setInfos)
GUI_Trades_Set_NewMsg(A_Index)
GUI_Trades_Update_Tab_Style(A_Index)
}
}
if ( ProgramSettings.Whisper_Toggle = 1 ) && FileExist(ProgramSettings.Whisper_Sound_Path) { ; Play the sound set for whispers
SoundPlay,% ProgramSettings.Whisper_Sound_Path
}
}
}
; Check if a buyer has joined or left the area
if ( RegExMatch( A_LoopField, "S)" areaRegexStr, subPat ) ) {
gamePID := subPat1, whispName := subPat2, areaStatus := subPat3
TradesGUI_Values.Last_Whisper := whispName
; Check if player has pending trade
tradesInfos := Gui_Trades_Manage_Trades("GET_ALL")
updateCount := 0
Loop % tradesInfos.Max_Index {
if (whispName = tradesInfos[A_Index "_Buyer"]) {
; Check if the player is already in the area
if ( areaStatus = "joined" && !tradesInfos[A_Index "_InArea"]) {
GUI_Trades_Set_InArea(A_Index)
GUI_Trades_Update_Tab_Style(A_Index)
; Play sound and alert
; if ( ProgramSettings.Joined_Toggle = 1 ) && FileExist(ProgramSettings.Joined_Sound_Path) {
; SoundPlay,% ProgramSettings.Joined_Sound_Path
; }
; if ( ProgramSettings.Trade_Toggle = 1 ) && FileExist(ProgramSettings.Trade_Sound_Path) { ; Play the sound set for trades
; SoundPlay,% ProgramSettings.Trade_Sound_Path
; }
if !WinActive("ahk_pid " gamePID) {
if ( ProgramSettings.Whisper_Flash ) {
gameHwnd := WinExist("ahk_pid " gamePID)
DllCall("FlashWindow", UInt, gameHwnd, Int, 1)
}
}
} else if (areaStatus = "left" && tradesInfos[A_Index "_InArea"] = 1) {
GUI_Trades_Set_InArea(A_Index, 0)
GUI_Trades_Update_Tab_Style(A_Index)
}
}
}
}
; End of area joined
}
}
Restart_Monitor_Game_Logs() {
Gui_Trades_Save_Position()
Monitor_Game_Logs("CLOSE")
Monitor_Game_Logs()
}
Monitor_Game_Logs(mode="") {
; Retrieve the logs file location by adding \Logs\Client.txt to the PoE executable path
; Monitor the logs file, waiting for new whispers
; Upon receiving a poe.trade whisper, pass the trades infos to Gui_Trades()
global RunParameters, POEGameArray, TradesGUI_Values
static logsFile, fileObj, sleepTime, timeSinceLastTrade, timer
; Close file obj when an error occured
if (mode = "CLOSE") {
fileObj.Close()
Return
}
; logsFile has not been created yet
if (!logsFile || !FileExist(logsFile)) {
if ( RunParameters.GamePath ) {
WinGet, tempExeLocation, ProcessPath,% "ahk_id " element
SplitPath,% RunParameters.GamePath, ,directory
logsFile := directory "\logs\Client.txt"
}
else {
r := Get_All_Games_Instances()
if ( r = "EXE_NOT_FOUND" ) {
Gui_Trades_Redraw("EXE_NOT_FOUND", {noSplash:1})
}
else {
logsFile := r
try Gui_Trades_Set_Position()
}
}
Logs_Append(A_ThisFunc, {File:logsFile})
fileObj := FileOpen(logsFile, "r")
fileObj.Read()
}
; new line appeared
if ( fileObj.pos < fileObj.length ) {
newLogs := fileObj.Read()
Filter_Logs_Message(newLogs)
}
; error occured with logs file
else if ( !FileExist(logsFile) || (fileObj.pos > fileObj.length) || (fileObj.pos = -1) ) {
Logs_Append("Monitor_Game_Logs_Break", {Pos:fileObj.pos, Length:fileObj.length})
Tray_Notifications_Show("An issue with the logs file occured!", "It could be one of the following reasons: "
. "`n- The file doesn't exist anymore."
. "`n- Content from the file was deleted."
. "`n- The file object used by the program was closed."
. "`n`nThe logs monitoring function will be restarting in 5 seconds.")
SetTimer, Restart_Monitor_Game_Logs, -5000
}
; set clever timer, based on when the latest trade whisper was received
timeSinceLastTrade := A_Now
EnvSub, timeSinceLastTrade,% TradesGUI_Values.Last_Trade_Time, Seconds
timer := (!timer)?(400) ; Start at this value
:( IsBetween(timeSinceLastTrade, 300, 3600) )?(400) ; when no trade received for 5mins
:( timeSinceLastTrade > 3600 )?(600) ; when no trade received for over an hour
:(200) ; Otherwise, this value
SetTimer,% A_ThisFunc, -%timer%
Return
}
;==================================================================================================================
;
; TRADES GUI
;
;==================================================================================================================
Gui_Trades(mode="", tradeInfos="") {
; Trades GUI. Each new item will be added in a new tab
; Clicking on a button will do its corresponding action
; Switching tab will clipboard the item's infos if the user enabled
; Is transparent and click-through when there is no trade on queue
static
global ProgramValues, TradesGUI_Values, TradesGUI_Controls, ProgramSettings, SkinAssets
activeSkin := ProgramSettings.Active_Skin
scaleMult := ProgramSettings.Scale_Multiplier
IniRead, fontSizeAuto,% ProgramValues.Fonts_Settings_File,SIZE,% ProgramSettings.Font
if !IsNum(fontSizeAuto)
IniRead, fontSizeAuto,% ProgramValues.Fonts_Settings_File,SIZE,Default
fontName := (ProgramSettings.Font="System")?(""):(ProgramSettings.Font)
fontSize := (ProgramSettings.Font_Size_Mode="Custom")?(ProgramSettings.Font_Size_Custom)
:(fontSizeAuto*scaleMult)
IniRead, fontQualAuto,% ProgramValues.Fonts_Settings_File,QUALITY,% ProgramSettings.Font
if !IsNum(fontQualAuto)
IniRead, fontQualAuto,% ProgramValues.Fonts_Settings_File,QUALITY,Default
fontQual := (ProgramSettings.Font_Quality_Mode="Custom")?(ProgramSettings.Font_Quality_Custom)
:(fontQualAuto)
maxTabsRow := 8
maxTabsStage1 := 25
maxTabsStage2 := 50
maxTabsStage3 := 75
maxTabsStage4 := 100
maxTabsStage5 := 250
TradesGUI_Values["Max_Tabs_Per_Row"] := maxTabsRow
Loop {
local btnUnicodePos := ProgramSettings["Button_Unicode_" A_Index "_Position"]
local useSmallerButtons := (btnUnicodePos != "Disabled")?(true):(false)
if ( useSmallerButtons = true || btnUnicodePos = "ERROR" )
Break
}
TradesGUI_Values.Use_Smaller_Buttons := useSmallerButtons
btnUnicodePos := "", useSmallerButtons := ""
if ( mode = "CREATE" ) {
TradesGUI_Values.Created := false
colorTitleActive := (ProgramSettings.Color_Title_Active = "000000")?("Black"):("0x" ProgramSettings.Color_Title_Active)
colorTitleInactive := (ProgramSettings.Color_Title_Inactive = "000000")?("Black"):("0x" ProgramSettings.Color_Title_Inactive)
colorTradesInfos1 := (ProgramSettings.Color_Trades_Infos_1 = "000000")?("Black"):("0x" ProgramSettings.Color_Trades_Infos_1)
colorTradesInfos2 := (ProgramSettings.Color_Trades_Infos_2 = "000000")?("Black"):("0x" ProgramSettings.Color_Trades_Infos_2)
colorBorder := (ProgramSettings.Color_Border = "000000")?("Black"):("0x" ProgramSettings.Color_Border)
colorButtonNormal := (ProgramSettings.Color_Button_Normal = "000000")?("Black"):("0x" ProgramSettings.Color_Button_Normal)
colorButtonHover := (ProgramSettings.Color_Button_Hover = "000000")?("Black"):("0x" ProgramSettings.Color_Button_Hover)
colorButtonPress := (ProgramSettings.Color_Button_Press = "000000")?("Black"):("0x" ProgramSettings.Color_Button_Press)
colorTabActive := (ProgramSettings.Color_Tab_Active = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Active)
colorTabInactive := (ProgramSettings.Color_Tab_Inactive = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Inactive)
colorTabHover := (ProgramSettings.Color_Tab_Hover = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Hover)
colorTabPress := (ProgramSettings.Color_Tab_Press = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Press)
colorTabJoinedActive := (ProgramSettings.Color_Tab_Joined_Active = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Joined_Active)
colorTabJoinedInactive := (ProgramSettings.Color_Tab_Joined_Inactive = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Joined_Inactive)
colorTabJoinedHover := (ProgramSettings.Color_Tab_Joined_Hover = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Joined_Hover)
colorTabJoinedPress := (ProgramSettings.Color_Tab_Joined_Press = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Joined_Press)
colorTabWhisperActive := (ProgramSettings.Color_Tab_Whisper_Active = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Whisper_Active)
colorTabWhisperInactive := (ProgramSettings.Color_Tab_Whisper_Inactive = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Whisper_Inactive)
colorTabWhisperHover := (ProgramSettings.Color_Tab_Whisper_Hover = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Whisper_Hover)
colorTabWhisperPress := (ProgramSettings.Color_Tab_Whisper_Press = "000000")?("Black"):("0x" ProgramSettings.Color_Tab_Whisper_Press)
pngTransColor := (SkinAssets.Misc_Transparency_Color = "000000")?("Black"):("0x" SkinAssets.Misc_Transparency_Color)
IBStyle_Tab := [ [0, SkinAssets.Tab_Inactive, "", colorTabInactive, "", pngTransColor] ; normal
, [0, SkinAssets.Tab_Hover, "", colorTabHover, "", pngTransColor] ; hover
, [0, SkinAssets.Tab_Press, "", colorTabPress, "", pngTransColor] ; pressed
, [0, SkinAssets.Tab_Active, "", colorTabActive, "", pngTransColor] ] ; disabled (defaulted)
IBStyle_Tab_Joined := [ [0, SkinAssets.Tab_Joined_Inactive, "", colorTabJoinedInactive, "", pngTransColor]
, [0, SkinAssets.Tab_Joined_Hover, "", colorTabJoinedHover, "", pngTransColor]
, [0, SkinAssets.Tab_Joined_Press, "", colorTabJoinedPress, "", pngTransColor]
, [0, SkinAssets.Tab_Joined_Active, "", colorTabJoinedActive, "", pngTransColor] ]
IBStyle_Tab_Whisper := [ [0, SkinAssets.Tab_Whisper_Inactive, "", colorTabWhisperInactive, "", pngTransColor]
, [0, SkinAssets.Tab_Whisper_Hover, "", colorTabWhisperHover, "", pngTransColor]
, [0, SkinAssets.Tab_Whisper_Press, "", colorTabWhisperPress, "", pngTransColor]
, [0, SkinAssets.Tab_Whisper_Active, "", colorTabWhisperActive, "", pngTransColor] ]
IBStyle_Arrow_Left := [ [0, SkinAssets.Arrow_Left_Normal, "", colorButtonNormal, "", pngTransColor]
, [0, SkinAssets.Arrow_Left_Hover, "", colorButtonHover, "", pngTransColor]
, [0, SkinAssets.Arrow_Left_Press, "", colorButtonPress, "", pngTransColor] ]
IBStyle_Arrow_Right := [ [0, SkinAssets.Arrow_Right_Normal, "", colorButtonNormal, "", pngTransColor]
, [0, SkinAssets.Arrow_Right_Hover, "", colorButtonHover, "", pngTransColor]
, [0, SkinAssets.Arrow_Right_Press, "", colorButtonPress, "", pngTransColor] ]
IBStyle_Button_OneThird := [ [0, SkinAssets.Button_OneThird_Normal, "", colorButtonNormal, "", pngTransColor]
, [0, SkinAssets.Button_OneThird_Hover, "", colorButtonHover, "", pngTransColor]
, [0, SkinAssets.Button_OneThird_Press, "", colorButtonPress, "", pngTransColor] ]
IBStyle_Button_TwoThird := [ [0, SkinAssets.Button_TwoThird_Normal, "", colorButtonNormal, "", pngTransColor]
, [0, SkinAssets.Button_TwoThird_Hover, "", colorButtonHover, "", pngTransColor]
, [0, SkinAssets.Button_TwoThird_Press, "", colorButtonPress, "", pngTransColor] ]
IBStyle_Button_ThreeThird := [ [0, SkinAssets.Button_ThreeThird_Normal, "", colorButtonNormal, "", pngTransColor]
, [0, SkinAssets.Button_ThreeThird_Hover, "", colorButtonHover, "", pngTransColor]
, [0, SkinAssets.Button_ThreeThird_Press, "", colorButtonPress, "", pngTransColor] ]
IBStyle_Button_Special := [ [0, SkinAssets.Button_Special_Normal, "", colorButtonNormal, "", pngTransColor]
, [0, SkinAssets.Button_Special_Hover, "", colorButtonHover, "", pngTransColor]
, [0, SkinAssets.Button_Special_Press, "", colorButtonPress, "", pngTransColor] ]
IBStyle_Close_Tab := [ [0, SkinAssets.Close_Tab_Normal, "", colorButtonNormal, "", pngTransColor]
, [0, SkinAssets.Close_Tab_Hover, "", colorButtonHover, "", pngTransColor]
, [0, SkinAssets.Close_Tab_Press, "", colorButtonPress, "", pngTransColor] ]
; Add Tab Styles to ProgramValues for later use
ProgramValues.IBStyle_Tab := IBStyle_Tab
ProgramValues.IBStyle_Tab_Whisper := IBStyle_Tab_Whisper
ProgramValues.IBStyle_Tab_Joined := IBStyle_Tab_Joined
Gui, Trades:Destroy
Gui, Trades:New, +ToolWindow +AlwaysOnTop -Border +hwndGuiTradesHandler +LabelGui_Trades_ +LastFound -SysMenu -Caption
Gui, Trades:Default
Gui, Color, %pngTransColor%
Gui, Margin, 0, 0
Gui, +OwnDialogs
TradesGUI_Values.Handler := GuiTradesHandler
tabHeight := Gui_Trades_Get_Tab_Height(), tabWidth := 390*scaleMult
guiWidth := 401*scaleMult, guiHeight := Floor((tabHeight+39)*scaleMult), guiHeightMin := 30*scaleMult ; 30 = banner size
borderSize := 1
TradesGUI_Values.Insert("Height_Full", guiHeight)
TradesGUI_Values.Insert("Height_Minimized", guiHeightMin)
maxTabsRendered := (!maxTabsRendered)?(maxTabsStage1):(maxTabsRendered)
if ( maxTabsRendered > maxTabsStage2 ) {
Tray_Notifications_Show(ProgramValues.Name, "Current tabs limit reached." . "`nRendering more tabs")
}
TradesGUI_Values["Max_Tabs_Rendered"] := maxTabsRendered
txtCtrlSize := Get_Text_Control_Size("WW:WW", fontName, fontSize)
timeSlotWidth := txtCtrlSize.W*scaleMult, txtCtrlSize := ""
Gui, Font,S%fontSize% Q%fontQual%,% fontName
Gui, Add, Tab2, x0 y0 w0 h0 -Wrap vTabCtrl hWndhTabCtrl,% ""
TradesGUI_Controls["Tab"] := hTabCtrl
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * S K I N N I N G * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
; - - - - - Background and title bar
Gui, Tab
Gui, Add, Picture,% "x0 y0 hWndhBackground BackgroundTrans",% SkinAssets.Misc_Background
Tile_Picture("Trades", hBackground, guiWidth, guiHeight) ; Fill the background
Gui, Add, Picture,% "x0 y0 w" guiWidth-borderSize " h" 30*scaleMult " BackgroundTrans Section",% SkinAssets.Misc_Header
Gui, Add, Picture,% "x" borderSize+(2*scaleMult) " y" borderSize+(2*scaleMult) " w" 24*scaleMult " h" 24*scaleMult " +BackgroundTrans",% SkinAssets.Misc_Icon
Gui, Add, Text,% "x" borderSize+(35*scaleMult) . " y" borderSize+(2*scaleMult) . " w" guiWidth-(100*scaleMult) " h" (30-(2*scaleMult))*scaleMult " hWndhHeaderTitle gGui_Trades_Move c" colorTitleInactive . " BackgroundTrans +0x200",% ProgramValues.Name " - Queued Trades: 0"
Gui, Add, Text,% "x" guiWidth-(65*scaleMult) . " yp" . " w" 65*scaleMult " h" (30-(2*scaleMult))*scaleMult " hWndhHeaderMinimize gGui_Trades_Minimize c" colorTitleInactive . " BackgroundTrans +0x200",% "MINIMIZE"
TradesGUI_Controls["Header_Title"] := hHeaderTitle
TradesGUI_Controls["Header_Minimize"] := hHeaderMinimize
; - - - - - Borders
Gui, Tab
Gui, Add, Progress,% "x" 0 . " y" 0 . " w" guiWidth . " h" borderSize . " hWndhBorderTop Background" colorBorder ; Top
Gui, Add, Progress,% "x" 0 . " y" 0 . " w" borderSize . " h" guiHeight . " hWndhBorderLeft Background" colorBorder ; Left
Gui, Add, Progress,% "x" guiWidth-borderSize . " y" 0 . " w" borderSize . " h" guiHeight . " hWndhBorderRight Background" colorBorder ; Right
Gui, Add, Progress,% "x" 0 . " y" guiHeight-borderSize . " w" guiWidth . " h" borderSize . " hWndhBorderBottom Background" colorBorder ; Bottom
TradesGUI_Controls["Border_Top"] := hBorderTop
TradesGUI_Controls["Border_Left"] := hBorderLeft
TradesGUI_Controls["Border_Right"] := hBorderRight
TradesGUI_Controls["Border_Bottom"] := hBorderBottom
; - - - - - Tabs Background
Gui, Add, Picture,% "x" borderSize*scaleMult " ys+" 30*scaleMult " w" (40*scaleMult)*maxTabsRow " h" 25*scaleMult " hwndhTabsBackground Hidden",% SkinAssets.Misc_Tabs_Background
TradesGUI_Controls.Tabs_Background := hTabsBackground
; - - - - - Tabs
Loop %maxTabsRendered% {
btnPos := (A_Index=1)?("x" borderSize*scaleMult " ys+" 30*scaleMult " w" 40*scaleMult " h" 25*scaleMult):(A_Index > maxTabsRow)?("xp yp wp hp"):("xp+40 yp wp hp")
; Default Tab
Gui, Add, Button,%btnPos% gGui_Trades_SetActiveTab vTab%A_Index% hWndhTab%A_Index% Section,% A_Index
if !ImageButton.Create(hTab%A_Index%, IBStyle_Tab*)
MsgBox, 0, ImageButton Error Tab%A_Index% Default, % ImageButton.LastError
GuiControl,Trades:Hide,% hTab%A_Index%
TradesGUI_Controls["TabDefault_" A_Index] := hTab%A_Index%
; Joined Tab
btnPos := "xp yp wp hp"
Gui, Add, Button,%btnPos% gGui_Trades_SetActiveTab vTabJoined%A_Index% hWndhTabJoined%A_Index% Section,% A_Index
if !ImageButton.Create(hTabJoined%A_Index%, IBStyle_Tab_Joined*)
MsgBox, 0, ImageButton Error Tab%A_Index% Joined, % ImageButton.LastError
GuiControl,Trades:Hide,% hTabJoined%A_Index%
TradesGUI_Controls["TabJoined_" A_Index] := hTabJoined%A_Index%
; Whisper tab
Gui, Add, Button,%btnPos% gGui_Trades_SetActiveTab vTabMsg%A_Index% hWndhTabMsg%A_Index% Section,% A_Index
if !ImageButton.Create(hTabMsg%A_Index%, IBStyle_Tab_Whisper*)
MsgBox, 0, ImageButton Error Tab%A_Index% Whisper, % ImageButton.LastError
GuiControl,Trades:Hide,% hTabMsg%A_Index%
TradesGUI_Controls["TabMsg_" A_Index] := hTabMsg%A_Index%
TradesGUI_Controls["Tab_" A_Index] := hTab%A_Index%
}
Loop % maxTabsRow {
btnPos := (A_Index=1)?("x" borderSize*scaleMult " yp w0 h0"):(A_Index > maxTabsRow)?("xp yp wp hp"):("xp+" 40*scaleMult " yp wp hp")
Gui, Add, Text,%btnPos% hWndhTabSlot%A_Index%,% ""
TradesGUI_Controls["Tab_Slot_" A_Index] := hTabSlot%A_Index%
}
; - - - - - Left / Right arrows and Close
Gui, Add, Button,% "xp+" 40*scaleMult " yp w" 25*scaleMult " h" 25*scaleMult " hWndhArrowLeft gGui_Trades_Skinned_Arrow_Left BackgroundTrans",% (SkinAssets.Arrow_Left_Use_Character)?("<"):("")
if !ImageButton.Create(hArrowLeft, IBStyle_Arrow_Left*)
MsgBox, 0, ImageButton Error Left Arrow, % ImageButton.LastError
Gui, Add, Button,% "xp+" 25*scaleMult " yp w" 25*scaleMult " h" 25*scaleMult " hWndhArrowRight gGui_Trades_Skinned_Arrow_Right BackgroundTrans",% (SkinAssets.Arrow_Right_Use_Character)?(">"):("")
if !ImageButton.Create(hArrowRight, IBStyle_Arrow_Right*)
MsgBox, 0, ImageButton Error Right Arrow, % ImageButton.LastError
Gui, Add, Button,% "xp+" 26*scaleMult " yp w" 27*scaleMult " h" 25*scaleMult " hWndhBtnCloseTab gGui_Trades_Close_Tab_Label Section",% (SkinAssets.Close_Tab_Use_Character)?("X"):("")
if !ImageButton.Create(hBtnCloseTab, IBStyle_Close_Tab*)
MsgBox, 0, ImageButton Error Close Tab, % ImageButton.LastError
TradesGUI_Controls["Arrow_Left"] := hArrowLeft
TradesGUI_Controls["Arrow_Right"] := hArrowRight
TradesGUI_Controls["Close_Tab"] := hBtnCloseTab
; - - - - - Tab Underline
Gui, Add, Picture,% "x" borderSize*scaleMult " yp+" 25*scaleMult " w" ((guiWidth-borderSize)*scaleMult)-(borderSize*scaleMult) " h" 2*scaleMult " hWndhTabsUnderline",% SkinAssets.Misc_Tabs_Underline
TradesGUI_Controls["Tabs_Underline"] := hTabsUnderline
; - - - - - Tabs content
Loop %maxTabsRendered% {
GuiControl, Trades:, TabCtrl,% A_Index "|"
Gui, Tab,% A_Index,,Exact
; Text slots
controlParams := " BackgroundTrans c" colorTradesInfos1
Gui, Add, Text,% "x" 10 " ys+" 30*scaleMult " w80 R1 hwndBuyerText" A_Index "Handler " controlParams,% "Buyer:"
Gui, Add, Text,% "xp yp+" 15*scaleMult " w80 R1 hwndItemText" A_Index "Handler " controlParams,% "Item:"
Gui, Add, Text,% "xp yp+" 15*scaleMult " w80 R1 hwndPriceText" A_Index "Handler " controlParams,% "Price:"
Gui, Add, Text,% "xp yp+" 15*scaleMult " w80 R1 hwndLocationText" A_Index "Handler " controlParams,% "Location:"
Gui, Add, Text,% "xp yp+" 15*scaleMult " w80 R1 hwndOtherText" A_Index "Handler " controlParams,% "Other:"
; Infos slots
controlParams := " BackgroundTrans +0x0100 R1 c" colorTradesInfos2
Gui, Add, Text,% "xp+" 80*scaleMult " ys+" 30*scaleMult " w" 255*scaleMult " vBuyerSlot" A_Index " hwndBuyerSlot" A_Index "Handler " controlParams " R1",% ""
Gui, Add, Text,% "xp yp+" 15*scaleMult " w" 310*scaleMult " vItemSlot" A_Index " hwndItemSlot" A_Index "Handler " controlParams " R1",% ""
Gui, Add, Text,% "xp yp+" 15*scaleMult " wp vPriceSlot" A_Index . " hwndPriceSlot" A_Index "Handler " controlParams " R1",% ""
Gui, Add, Text,% "xp yp+" 15*scaleMult " wp vLocationSlot" A_Index . " hwndLocationSlot" A_Index "Handler " controlParams " R1",% ""
Gui, Add, Text,% "xp yp+" 15*scaleMult " wp vOtherSlot" A_Index . " hwndOtherSlot" A_Index "Handler " controlParams " R1",% ""
Gui, Add, Text,% "x" (guiWidth-timeSlotWidth)-((5*scaleMult)) " ys+" 28*scaleMult " w" timeSlotWidth . " h15 vTimeSlot" A_Index " hwndTimeSlot" A_Index "Handler " controlParams " R1",% ""
Gui, Add, Text,% "x0 y0 w0 h0 vPIDSlot" A_Index " hwndPIDSlot" A_Index "Handler",% ""
Gui, Add, Text,% "x0 y0 w0 h0 vDateSlot" A_Index " hwndDateSlot" A_Index "Handler",% ""
Gui, Add, Text,% "x0 y0 w0 h0 vGuildSlot" A_Index " hwndGuildSlot" A_Index "Handler",% ""
Gui, Add, Text,% "x0 y0 w0 h0 vInAreaSlot" A_Index " hwndInAreaSlot" A_Index "Handler",% ""
Gui, Add, Text,% "x0 y0 w0 h0 vNewMsgSlot" A_Index " hwndNewMsgSlot" A_Index "Handler",% ""
TradesGUI_Controls["Buyer_Slot_" A_Index] := BuyerSlot%A_Index%Handler
TradesGUI_Controls["Item_Slot_" A_Index] := ItemSlot%A_Index%Handler
TradesGUI_Controls["Price_Slot_" A_Index] := PriceSlot%A_Index%Handler
TradesGUI_Controls["Location_Slot_" A_Index] := LocationSlot%A_Index%Handler
TradesGUI_Controls["Other_Slot_" A_Index] := OtherSlot%A_Index%Handler
TradesGUI_Controls["Time_Slot_" A_Index] := TimeSlot%A_Index%Handler
TradesGUI_Controls["PID_Slot_" A_Index] := PIDSlot%A_Index%Handler
TradesGUI_Controls["Date_Slot_" A_Index] := DateSlot%A_Index%Handler
TradesGUI_Controls["Guild_Slot_" A_Index] := GuildSlot%A_Index%Handler
TradesGUI_Controls["InArea_Slot_" A_Index] := InAreaSlot%A_Index%Handler
TradesGUI_Controls["NewMsg_Slot_" A_Index] := NewMsgSlot%A_Index%Handler
}
; - - - - - TC_Symbols buttons
Gui, Tab
Gui, Font,% "S" 10*scaleMult,% "TC_Symbols"
fontChars := {Clipboard:"0", Whisper:"1", Invite:"2", Trade:"3", Kick:"4"}
fontCharsID := {1:"Clipboard",2:"Whisper",3:"Invite",4:"Trade",5:"Kick"}
for btnID, btnType in fontCharsID {
btnOrder := ProgramSettings["Button_Unicode_" btnID "_Position"]
if ( btnOrder != "Disabled" ) {
btnPos_X := ( (btnOrder-1)*(40)*scaleMult )+10, btnPos_Y := 140, btnPos_W := 35, btnPos_H := 25
btnOrnaLeftPos_X := btnPos_X, btnOrnaLeftPos_Y := btnPos_Y, btnOrnaLeftPos_W := 10, btnOrnaLeftPos_H := btnPos_H
btnOrnaRightPos_X := (btnPos_X+btnPos_W)-btnOrnaLeftPos_W, btnOrnaRightPos_Y := btnOrnaLeftPos_Y, btnOrnaRightPos_W :=btnOrnaLeftPos_W, btnOrnaRightPos_H := btnOrnaLeftPos_H
btnHandler := "UnicodeBtn" A_Index
Gui, Add, Button,% "x" btnPos_X " y" btnPos_Y*scaleMult " w" btnPos_W*scaleMult " h" btnPos_H*scaleMult " hWnd" btnHandler " BackgroundTrans gGui_Trades_Do_Action_Func",% fontChars[btnType]
if !ImageButton.Create(%btnHandler%, IBStyle_Button_Special*)
MsgBox, 0, ImageButton Error Special Buttons, % ImageButton.LastError
; Gui, Add, Picture,% "x" btnOrnaLeftPos_X " y" btnOrnaLeftPos_Y " w" btnOrnaLeftPos_W " h" btnOrnaLeftPos_H,% ""
; Gui, Add, Picture,% "x" btnOrnaRightPos_X " y" btnOrnaRightPos_Y " w" btnOrnaRightPos_W " h" btnOrnaRightPos_H,% ""