This repository has been archived by the owner on Dec 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
PoE-HarvestVendor.ahk
2747 lines (2444 loc) · 89.8 KB
/
PoE-HarvestVendor.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
#NoEnv
#SingleInstance Force
SetBatchLines -1
SetWorkingDir %A_ScriptDir%
global version := "0.8.2"
; === some global variables ===
global outArray := {}
global outArrayCount := 0
global rescan := ""
global x_start := 0
global y_start := 0
global x_end := 0
global y_end := 0
global firstGuiOpen := True
global outString := ""
global outStyle := 1
global MaxLen
global maxLengths := {}
global seenInstructions := 0
global sessionLoading := False
global MaxRowsCraftTable := 20
global PID := DllCall("Kernel32\GetCurrentProcessId")
EnvGet, dir, USERPROFILE
global RoamingDir := dir . "\AppData\Roaming\PoE-HarvestVendor"
if !FileExist(RoamingDir) {
FileCreateDir, %RoamingDir%
}
global SettingsPath := RoamingDir . "\settings.ini"
global PricesPath := RoamingDir . "\prices.ini"
global LogPath := RoamingDir . "\log.csv"
global TempPath := RoamingDir . "\temp.txt"
global tftPrices := RoamingDir . "\tftprices.json"
global CraftNames := {"Augment" : "Augment ", "Remove" : "Remove "
, "Reforge" : "Reforge ", "Enchant" : "Enchant "
, "Attempt" : "Attempt ", "Change" : "Change "
, "Sacrifice" : "Sacrifice a|Sacrifice up", "Improves" : "Improves "
, "Fracture" : "Fracture ", "Reroll" : "Reroll "
, "Randomise" : "Randomise ", "Add" : "Add a random "
, "Set" : "Set(a|ai|ta|ca)*? ", "Synthesise" : "Synthesise "
, "Corrupt" : "Corrupt ", "Exchange" : "Exchange "
, "Upgrade" : "Upgrade ", "Split" : "Split "}
global RegexpTemplateForCraft := "("
for k, v in CraftNames {
RegexpTemplateForCraft .= v . "|"
}
RegexpTemplateForCraft := RTrim(RegexpTemplateForCraft, "|") . ")"
; detecting mouse button swap
;swapped := DllCall("GetSystemMetrics",UInt,"23")
; if (swapped) {
; global primaryButton := "RButton"
; } else {
; global primaryButton := "LButton"
; }
OnExit("ExitFunc")
tooltip, loading... Initializing Settings
sleep, 250
; == init settings ==
iniRead, seenInstructions, %SettingsPath%, Other, seenInstructions
if (seenInstructions == "ERROR" or seenInstructions == "") {
IniWrite, 0, %SettingsPath%, Other, seenInstructions
IniRead, seenInstructions, %SettingsPath%, Other, seenInstructions
}
IniRead, GuiKey, %SettingsPath%, Other, GuiKey
checkValidChars := RegExMatch(GuiKey, "[a-zA-Z0-9]") > 0
if (GuiKey == "ERROR" or GuiKey == "" or !checkValidChars) {
IniWrite, ^+g, %SettingsPath%, Other, GuiKey
sleep, 250
IniRead, GuiKey, %SettingsPath%, Other, GuiKey
if (!checkValidChars) {
msgBox, Open GUI hotkey was set to a non latin letter or number, it was reset to ctrl+shift+g
}
}
hotkey, %GuiKey%, OpenGui
IniRead, ScanKey, %SettingsPath%, Other, ScanKey
checkValidChars := RegExMatch(ScanKey, "[a-zA-Z0-9]") > 0
if (ScanKey == "ERROR" or ScanKey == "" or !checkValidChars) {
IniWrite, ^g, %SettingsPath%, Other, ScanKey
sleep, 250
IniRead, ScanKey, %SettingsPath%, Other, ScanKey
;ScanKey == "^g"
if (!checkValidChars) {
msgBox, Scan hotkey was set to a non latin letter or number, it was reset to ctrl+g
}
}
hotkey, %ScanKey%, Scan
IniRead, outStyle, %SettingsPath%, Other, outStyle
if (outStyle == "ERROR") {
IniWrite, 1, %SettingsPath%, Other, outStyle
outStyle := 1
}
iniRead tempMon, %SettingsPath%, Other, mon
if (tempMon == "ERROR") {
tempMon := 1
iniWrite, %tempMon%, %SettingsPath%, Other, mon
}
iniRead, sc, %SettingsPath%, Other, scale
if (sc == "ERROR") {
iniWrite, 1, %SettingsPath%, Other, scale
}
checkfiles()
winCheck()
tooltip, loading... Checking AHK version
sleep, 250
; == check for ahk version ==
if (A_AhkVersion < 1.1.27.00) {
MsgBox, Please update your AHK `r`nYour version: %A_AhkVersion%`r`nRequired: 1.1.27.00 or more
}
tooltip, loading... Grabbing active leagues
getLeagues()
menu, Tray, Icon, resources\Vivid_Scalefruit_inventory_icon.png
;Menu, MySubmenu, Add, testLabel
;Menu, Tray, Add, Harvest Vendor, OpenGui
Menu, Tray, NoStandard
Menu, Tray, Add, Harvest Vendor, OpenGui
Menu, Tray, Default, Harvest Vendor
Menu, Tray, Standard
; == preload pictures that are used more than once, for performance
count_pic := LoadPicture("resources\count.png")
up_pic := LoadPicture("resources\up.png")
dn_pic := LoadPicture("resources\dn.png")
craft_pic := LoadPicture("resources\craft.png")
lvl_pic := LoadPicture("resources\lvl.png")
price_pic := LoadPicture("resources\price.png")
del_pic := LoadPicture("resources\del.png")
; =================================================================
tooltip, loading... building GUI
sleep, 250
newGUI()
tooltip, ready
sleep, 500
Tooltip
if (seenInstructions == 0) {
goto help
}
return
ExitFunc(ExitReason, ExitCode) {
saveWindowPosition()
return 0
}
WinGetPosPlus(winTitle, ByRef xPos, ByRef yPos) {
hwnd := WinExist(winTitle)
VarSetCapacity(WP, 44, 0), NumPut(44, WP, "UInt")
DllCall("User32.dll\GetWindowPlacement", "Ptr", hwnd, "Ptr", &WP)
xPos := NumGet(WP, 28, "Int") ; X coordinate of the upper-left corner of the window in its original restored state
yPos := NumGet(WP, 32, "Int") ; Y coordinate of the upper-left corner of the window in its original restored state
}
saveWindowPosition() {
if (firstGuiOpen) { ;wrong window pos(0,0) if dont show gui before
return
}
winTitle := "PoE-HarvestVendor v" . version
DetectHiddenWindows, On
if WinExist(winTitle) {
;save window position
WinGetPosPlus(winTitle, gui_x, gui_y)
;WinGetPos, gui_x, gui_y,,, %WinTitle%
IniWrite, %gui_x%, %SettingsPath%, window position, gui_position_x
IniWrite, %gui_y%, %SettingsPath%, window position, gui_position_y
}
DetectHiddenWindows, Off
}
showGUI() {
if (firstGuiOpen) {
IniRead, newX, %SettingsPath%, window position, gui_position_x
IniRead, newY, %SettingsPath%, window position, gui_position_y
if (newX == "ERROR" or newY == "ERROR")
or (newX == -32000 or newY == -32000) {
Gui, HarvestUI:Show, w650 h585
return
} else {
DetectHiddenWindows, On
Gui, HarvestUI:Show, w650 h585 Hide ; Hide window before move
winTitle := "PoE-HarvestVendor v" . version
WinMove, %winTitle%,, %newX%, %newY%
DetectHiddenWindows, Off
}
firstGuiOpen := False
}
Gui, HarvestUI:Show
}
OpenGui: ;ctrl+shift+g opens the gui, yo go from there
if (firstGuiOpen) {
loadLastSession()
}
if (version != getVersion()) {
guicontrol, HarvestUI:Show, versionText
guicontrol, HarvestUI:Show, versionLink
}
showGUI()
OnMessage(0x200, "WM_MOUSEMOVE")
Return
Scan: ;ctrl+g launches straight into the capture, opens gui afterwards
rescan := ""
_wasVisible := IsGuiVisible("HarvestUI")
if (processCrafts(TempPath)) {
showGUI()
if (firstGuiOpen) {
loadLastSession()
firstGuiOpen := False
}
OnMessage(0x200, "WM_MOUSEMOVE") ;activates tooltip function
updateCraftTable(outArray)
rememberSession()
} else {
; If processCrafts failed (e.g. the user pressed Escape), we should show the
; HarvestUI only if it was visible to the user before they pressed Ctrl+G
if (_wasVisible)
showGUI()
}
return
HarvestUIGuiEscape:
HarvestUIGuiClose:
rememberSession()
saveWindowPosition()
Gui, HarvestUI:Hide
return
newGUI() {
Global
Gui, HarvestUI:New,, PoE-HarvestVendor v%version%
;Gui -DPIScale ;this will turn off scaling on big screens, which is nice for keeping layout but doesn't solve the font size, and fact that it would be tiny on big screens
Gui, Color, 0x0d0d0d, 0x1A1B1B
gui, Font, s11 cFFC555
xColumn1 := 10
xColumn2 := xColumn1 + 65
xColumn3 := xColumn2 + 33 + 5
xColumn4 := xColumn3 + 300 + 5
xColumn5 := xColumn4 + 25 + 5
xColumn6 := xColumn5 + 50 + 5
xColumn7 := xColumn6 + 15 + 5
xcolumn8 := xColumn7 + 111 + 5
xColumnUpDn := xColumn2 + 23
xEditOffset2 := xColumn2 + 1
xEditOffset3 := xColumn3 + 3
xEditOffset4 := xColumn4 + 1
xEditOffset5 := xColumn5 + 1
xEditOffset6 := xColumn6 + 1
xEditOffset7 := xColumn7 + 1
row := 90
; === Title and icon ===
title_icon := getImgWidth(A_ScriptDir . "\resources\Vivid_Scalefruit_inventory_icon.png")
gui add, picture, x10 y10 w%title_icon% h-1, resources\Vivid_Scalefruit_inventory_icon.png
title := getImgWidth(A_ScriptDir . "\resources\title.png")
gui add, picture, x%xColumn3% y10 w%title% h-1, resources\title.png
gui add, text, x380 y15, v%version%
; ======================
; === Text stuff ===
gui, Font, s11 cA38D6D
gui add, text, x%xColumn3% y40 w70 vValue +BackgroundTrans, You have:
gui, Font, s11 cFFC555
gui add, text, xp+70 y40 w40 right +BackgroundTrans vsumEx, 0
gui, Font, s11 cA38D6D
gui add, text, xp+42 y40 w20 +BackgroundTrans, ex
gui, Font, s11 cFFC555
gui add, text, xp+20 y40 w40 right +BackgroundTrans vsumChaos, 0
gui, Font, s11 cA38D6D
gui add, text, xp+42 y40 +BackgroundTrans, c
gui add, text, x412 y40 w80 vcrafts +BackgroundTrans, Total Crafts:
gui, Font, s11 cFFC555
gui add, text, xp+80 y40 w30 vCraftsSum, 0
gui, Font, s11 cA38D6D
gui add, text, x%xColumn3% y64 w40 +BackgroundTrans, Augs:
gui, Font, s11 cFFC555
gui add, text, xp+40 y64 w50 +BackgroundTrans vAcount,0
gui, Font, s11 cA38D6D
gui add, text, xp+50 y64 w45 +BackgroundTrans, Rems:
gui, Font, s11 cFFC555
gui add, text, xp+45 y64 w50 +BackgroundTrans vRcount,0
gui, Font, s11 cA38D6D
gui add, text, xp+50 y64 w75 +BackgroundTrans, Rem/Adds:
gui, Font, s11 cFFC555
gui add, text, xp+75 y64 w50 +BackgroundTrans vRAcount,0
gui, Font, s11 cA38D6D
gui add, text, xp+50 y64 w40 +BackgroundTrans, Other:
gui, Font, s11 cFFC555
gui add, text, xp+40 y64 w50 +BackgroundTrans vOcount,0
gui, Font, s11 cA38D6D
; ==================
gui Font, s12
gui add, text, x460 y10 cGreen vversionText, ! New Version Available !
;gui, Font, s11 cFFC555
gui add, Link, x550 y30 vversionLink c0x0d0d0d, <a href="http://github.com/esge/PoE-HarvestVendor/releases/latest">Github Link</a>
GuiControl, Hide, versionText
GuiControl, Hide, versionLink
gui Font, s11
; === Right side ===
;y math: row + (23*rowNum)
gui add, checkbox, x%xColumn7% y90 valwaysOnTop gAlwaysOnTop, Always on top
iniRead tempOnTop, %SettingsPath%, Other, alwaysOnTop
if (tempOnTop == "ERROR") {
tempOnTop := 0
}
guicontrol,,alwaysOnTop, %tempOnTop%
setWindowState(tempOnTop)
addCrafts := getImgWidth(A_ScriptDir . "\resources\addCrafts.png")
gui add, picture, x%xColumn7% y114 w%addCrafts% h-1 gAdd_crafts vaddCrafts, resources\addCrafts.png
lastArea := getImgWidth(A_ScriptDir . "\resources\lastArea.png")
gui add, picture, x%xColumn7% y137 w%lastArea% h-1 gLast_Area vrescanButton, resources\lastArea.png
clear := getImgWidth(A_ScriptDir . "\resources\clear.png")
gui add, picture, x%xColumn7% y160 w%clear% h-1 gClear_All vclearAll, resources\clear.png
settings := getImgWidth(A_ScriptDir . "\resources\settings.png")
gui add, picture, x%xColumn7% y183 w%settings% h-1 gSettings vsettings, resources\settings.png
help := getImgWidth(A_ScriptDir . "\resources\help.png")
gui add, picture, x%xColumn7% y206 w%help% h-1 gHelp vhelp, resources\help.png
githubpriceupdate := getImgWidth(A_ScriptDir . "\resources\UpdatePrices.png")
gui add, picture, x%xColumn7% y229 w%githubpriceupdate% h-1 gGithubpriceupdate vgithubpriceupdate, resources\UpdatePrices.png
; === Post buttons ===
createPost := getImgWidth(A_ScriptDir . "\resources\createPost.png")
gui add, picture, x%xColumn7% y252 w%createPost% h-1 vpostAll gPost_all, resources\createPost.png
;gui add, picture, x%xColumn7% y251 gAug_post vaugPost, resources\postA.png
;gui add, picture, x%xColumn7% y274 gRem_post vremPost, resources\postR.png
;gui add, picture, x%xColumn7% y297 gRemAdd_post vremAddPost, resources\postRA.png
;gui add, picture, x%xColumn7% y320 gOther_post votherPost, resources\postO.png
;gui add, picture, x%xColumn7% y343 vpostAll gPost_all, resources\postAll.png
; postAll_TT := "WARNING: Don't use this for Temporary SC league on TFT Discord"
; === League dropdown ===
gui add, text, x%xColumn7% y370, League:
gui add, dropdownList, x%xColumn7% y389 w115 -E0x200 +BackgroundTrans vleague gLeague_dropdown
leagueList()
; === can stream ===
iniRead tempStream, %SettingsPath%, Other, canStream
if (tempStream == "ERROR") {
tempStream := 0
}
gui add, checkbox, x%xColumn7% y419 vcanStream gCan_stream, Can stream
guicontrol,,canStream, %tempStream%
; === IGN ===
IniRead, name, %SettingsPath%, IGN, n
if (name == "ERROR") {
name := ""
}
gui add, text, x%xColumn7% y440, IGN:
ign := getImgWidth(A_ScriptDir . "\resources\ign.png")
gui add, picture, x%xColumn7% y458 w%ign% h-1, resources\ign.png
gui, Font, s11 cA38D6D
Gui Add, Edit, x%xEditOffset7% y459 w113 h18 -E0x200 +BackgroundTrans vign gIGN, %name%
gui, Font, s11 cFFC555
; === custom text checkbox ===
iniRead tempCustomTextCB, %SettingsPath%, Other, customTextCB
if (tempCustomTextCB == "ERROR") {
tempCustomTextCB := 0
}
gui add, checkbox, x%xColumn7% y485 vcustomText_cb gCustom_text_cb, Custom Text:
guicontrol,,customText_cb, %tempCustomTextCB%
; ============================
; === custom text input ===
text := getImgWidth(A_ScriptDir . "\resources\text.png")
gui add, picture, x%xColumn7% y504 w%text% h-1, resources\text.png
iniRead tempCustomText, %SettingsPath%, Other, customText
if (tempCustomText == "ERROR") {
tempCustomText := ""
}
gui, Font, s11 cA38D6D
Gui Add, Edit, x%xEditOffset7% y505 w113 h65 -E0x200 +BackgroundTrans vcustomText gCustom_text -VScroll -WantReturn, %tempCustomText%
gui, Font, s11 cFFC555
custom_TT := "This will be a single line in the message"
; ============================
;gui add, picture, x%xColumn7% y366, resources\leagueHeader.png
; ===============================================================================
; === table headers ===
gui add, text, x%xColumn1% y%row% w60 +Right, Type
count_beautyOffset := xColumn2 + 5
gui add, text, x%count_beautyOffset% y%row%, #
gui add, text, x%xColumn3% y%row%, Crafts
gui add, text, x%xColumn4% y%row%, LvL
gui add, text, x%xColumn5% y%row%, Price
; === table ===
count_ := getImgWidth(A_ScriptDir . "\resources\count.png")
craft_ := getImgWidth(A_ScriptDir . "\resources\craft.png")
lvl_ := getImgWidth(A_ScriptDir . "\resources\lvl.png")
price_ := getImgWidth(A_ScriptDir . "\resources\price.png")
del_ := getImgWidth(A_ScriptDir . "\resources\del.png")
loop, %MaxRowsCraftTable% {
row2 := row + 23 * A_Index
row2p := row2 + 1
row2dn := row2 + 10
row2del := row2 + 5
;gui add, picture, x%xColumn1% y%row2%, resources\type.png
gui, Font, s11 cA38D6D
gui add, text, x%xColumn1% y%row2% vtype_%A_Index% gType w60 Right,
gui, Font, s11 cFFC555
gui add, picture, x%xColumn2% y%row2% w%count_% h-1 AltSubmit , % "HBITMAP:*" count_pic ;resources\count.png
Gui Add, Edit, x%xEditOffset2% y%row2p% w35 h18 vcount_%A_Index% gPrice -E0x200 +BackgroundTrans Center
Gui Add, UpDown, Range0-20 vupDown_%A_Index%, 0
guicontrol, hide, upDown_%A_Index%
gui add, picture, x%xColumnUpDn% y%row2p% gUp vUp_%A_Index%, % "HBITMAP:*" up_pic
gui add, picture, x%xColumnUpDn% y%row2dn% gDn vDn_%A_Index%, % "HBITMAP:*" dn_pic
gui add, picture, x%xColumn3% y%row2% w%craft_% h-1 AltSubmit , % "HBITMAP:*" craft_pic ;resources\craft.png
gui add, edit, x%xEditOffset3% y%row2p% w295 h18 -E0x200 +BackgroundTrans vcraft_%A_Index% gcraft
gui add, picture, x%xColumn4% y%row2% w%lvl_% h-1 AltSubmit , % "HBITMAP:*" lvl_pic ;resources\lvl.png
gui add, edit, x%xEditOffset4% y%row2p% w23 h18 -E0x200 +BackgroundTrans Center vlvl_%A_Index% glvl
gui add, picture, x%xColumn5% y%row2% w%price_% h-1 AltSubmit , % "HBITMAP:*" price_pic ; resources\price.png
gui add, edit, x%xEditOffset5% y%row2p% w44 h18 -E0x200 +BackgroundTrans Center vprice_%A_Index% gPrice
gui add, picture, x%xColumn6% y%row2del% w%del_% h-1 vdel_%A_Index% gclearRow AltSubmit , % "HBITMAP:*" del_pic ;resources\del.png
}
gui, font
gui temp:hide
}
; === Button actions ===
Githubpriceupdate:
MSGBox, 4100 , Notification, This will update all local prices with TFT discord prices(Only those which are high confidence, if there is no high confidence price for certain Harvest, they will be kept as it is in local file.), are you sure you want to continue?
IfMsgBox, Yes
{
iniRead, leagueCheck, %SettingsPath%, selectedLeague, s
ToolTip, Updating for %leagueCheck%
sleep, 1000
Tooltip
if InStr(leagueCheck, "Standard"){
UrlDownloadToFile, https://raw.githubusercontent.com/The-Forbidden-Trove/tft-data-prices/master/std/harvest.json, %tftPrices%
}
else if InStr(leagueCheck, "SC"){
UrlDownloadToFile, https://raw.githubusercontent.com/The-Forbidden-Trove/tft-pricing-data/master/lsc/harvest.json, %tftPrices%
}
else if InStr(leagueCheck, "Hardcore"){
UrlDownloadToFile, https://raw.githubusercontent.com/The-Forbidden-Trove/tft-data-prices/master/lhc/harvest.json, %tftPrices%
}
FileRead, tftData, %tftPrices%
tftData := StrReplace(tftData, "`n", "")
tftData := StrReplace(tftData, "`r", "")
tftData := StrReplace(tftData, """", "")
tftData := StrReplace(tftData, "name:", "`r`nname:")
tftData := StrReplace(tftData, " ", " ")
tftData := StrReplace(tftData, " ", " ")
tftData := StrReplace(tftData, " ", " ")
tftData := StrReplace(tftData, " ", " ")
tftData := StrReplace(tftData, " ", " ")
for index, color in StrSplit(tftData, "`n"){
If InStr(color, "lowConfidence: false") ;In scourge league there was a space before 'false'
{
color := StrReplace(color, ", exalt:", "^ exalt:")
color := StrReplace(color, ", chaos:", "^ chaos:")
color := StrReplace(color, ", lowConfidence:", "^ lowConfidence:")
exalt := StrReplace(StrSplit(color, "^")[2], " exalt: ", "")
chaos := StrReplace(StrSplit(color, "^")[3], " chaos: ", "")
if exalt >= 1
{
craftPrice := exalt . "ex"
craftName := StrReplace(StrSplit(color, "^")[1], "name: ", "")
iniRead, CheckLocalPrice, %PricesPath%, Prices, %craftName%
if CheckLocalPrice != %craftPrice%
{
iniWrite, %craftPrice%, %PricesPath%, Prices, %craftName%
}
}
else
{
craftPrice := chaos . "c"
craftName := StrReplace(StrSplit(color, "^")[1], "name: ", "")
iniRead, CheckLocalPrice, %PricesPath%, Prices, %craftName%
if CheckLocalPrice != %craftPrice%
{
iniWrite, %craftPrice%, %PricesPath%, Prices, %craftName%
}
}
}
If InStr(color, "lowConfidence:false") ;it seems there is no space before 'false' in current json so adding this as well to handle both variation. Just in case it changes back to old one.
{
color := StrReplace(color, ",exalt:", "^exalt:")
color := StrReplace(color, ",chaos:", "^chaos:")
color := StrReplace(color, ",lowConfidence:", "^ lowConfidence:")
exalt := StrReplace(StrSplit(color, "^")[2], "exalt:", "")
chaos := StrReplace(StrSplit(color, "^")[3], "chaos:", "")
if exalt >= 1
{
craftPrice := exalt . "ex"
craftName := StrReplace(StrSplit(color, "^")[1], "name:", "")
iniRead, CheckLocalPrice, %PricesPath%, Prices, %craftName%
if CheckLocalPrice != %craftPrice%
{
iniWrite, %craftPrice%, %PricesPath%, Prices, %craftName%
}
}
else
{
craftPrice := chaos . "c"
craftName := StrReplace(StrSplit(color, "^")[1], "name:", "")
iniRead, CheckLocalPrice, %PricesPath%, Prices, %craftName%
if CheckLocalPrice != %craftPrice%
{
iniWrite, %craftPrice%, %PricesPath%, Prices, %craftName%
}
}
}
}
FileDelete, %tftPrices%
ToolTip, Updated prices loading in UI now
sleep, 1000
Tooltip
Loop, 20
{
CraftLine := ""
tempP := ""
iniRead, CraftLine, %SettingsPath%, LastSession, craft_%A_Index%
if (CraftLine != "")
{
CraftSplit := StrSplit(CraftLine,"|")
craft := CraftSplit[1]
iniRead, tempP, %PricesPath%, Prices, %craft%
if (tempP == "ERROR") {
tempP := ""
}
GuiControl, harvestUI: , price_%A_Index% , %tempP%
}
}
}
IfMsgBox, No
{
ToolTip, Prices NOT Updated
sleep, 1000
Tooltip
}
return
Up:
GuiControlGet, cntrl, name, %A_GuiControl%
tempRow := getRow(cntrl)
GuiControlget, tempCount,, count_%tempRow%
tempCount += 1
GuiControl,, count_%tempRow%, %tempCount%
sumTypes()
rememberSession()
return
Dn:
GuiControlGet, cntrl, name, %A_GuiControl%
tempRow := getRow(cntrl)
GuiControlget, tempCount,, count_%tempRow%
if (tempCount > 0) {
tempCount -= 1
GuiControl,, count_%tempRow%, %tempCount%
}
sumTypes()
rememberSession()
return
Add_crafts:
buttonHold("addCrafts", "resources\addCrafts")
GuiControlGet, rescan, name, %A_GuiControl%
if (processCrafts(TempPath)) {
showGUI()
updateCraftTable(outArray)
rememberSession()
} else {
showGUI()
}
return
Last_area:
buttonHold("rescanButton", "resources\lastArea")
goto Add_crafts
return
Clear_all:
buttonHold("clearAll", "resources\clear")
clearAll()
rememberSession()
return
count:
;rememberSession()
return
craft:
GuiControlGet, cntrl, name, %A_GuiControl%
tempRow := getRow(cntrl)
guiControlGet, tempCraft,, craft_%tempRow%, value
detectType(tempCraft, tempRow)
sumTypes()
rememberSession()
return
lvl:
;rememberSession()
return
type:
sumTypes()
return
Price:
GuiControlGet, priceField, name, %A_GuiControl%
guiControlGet, craftPrice,, %priceField%, value
priceFieldArray := strsplit(priceField, "_")
if (priceFieldArray[1] == "price") {
r := priceFieldArray[2] ;row
guiControlGet, craftName,, craft_%r%, value
if (craftName != "") {
iniWrite, %craftPrice%, %PricesPath%, Prices, %craftName%
}
}
if (craftPrice != "") {
sumPrices()
}
;rememberSession()
return
Can_stream:
guiControlGet, strim,,canStream, value
iniWrite, %strim%, %SettingsPath%, Other, canStream
return
IGN:
guiControlGet, lastIGN,,IGN, value
iniWrite, %lastIGN%, %SettingsPath%, IGN, n
return
Custom_text:
guiControlGet, cust,,customText, value
iniWrite, %cust%, %SettingsPath%, Other, customText
guicontrol,, customText_cb, 1
;if (RegExMatch(cust, "not|remove|aug|add") > 0) {
; gui, Font, cRed Bold
; guiControl, font, customText
; tooltip, This message might get blocked by the discord bot because it containts not|remove|aug|add
;} else {
; gui, Font, s11 cA38D6D norm
; guicontrol, font, customText
; tooltip
;}
return
Custom_text_cb:
guiControlGet, custCB,,customText_cb, value
iniWrite, %custCB%, %SettingsPath%, Other, CustomTextCB
return
ClearRow:
GuiControlGet, cntrl, name, %A_GuiControl%
tempRow := getRow(cntrl)
IniRead selLeague, %SettingsPath%, selectedLeague, s
if GetKeyState("Shift") {
guiControlGet, craft,, craft_%tempRow%, value
guiControlGet, price,, price_%tempRow%, value
IniRead, league, %SettingsPath%, selectedLeague, s
guiControlGet, cnt,, count_%tempRow%, value
fileLine := A_YYYY . "-" . A_MM . "-" . A_DD . ";" . A_Hour . ":" . A_Min . ";" . league . ";" . craft . ";" . price . "`r`n"
FileAppend, %fileLine%, %LogPath%
if (cnt > 1) {
cnt -= 1
Guicontrol,, count_%tempRow%, %cnt%
} else {
GuiControl,, craft_%tempRow%
GuiControl,, count_%tempRow%, 0
GuiControl,, price_%tempRow%
GuiControl,, type_%tempRow%
guiControl,, lvl_%tempRow%
sortCraftTable()
}
} else {
GuiControl,, craft_%tempRow%
GuiControl,, count_%tempRow%, 0
GuiControl,, price_%tempRow%
GuiControl,, type_%tempRow%
guiControl,, lvl_%tempRow%
sortCraftTable()
}
sumTypes()
rememberSession()
return
Aug_Post:
buttonHold("augPost", "resources\postA")
createPost("Aug")
return
Rem_post:
buttonHold("remPost", "resources\postR")
createPost("Rem")
return
RemAdd_post:
buttonHold("remAddPost", "resources\postRA")
createPost("Rem/Add")
return
Other_post:
buttonHold("otherPost", "resources\postO")
createPost("Other")
return
Post_all:
;buttonHold("postAll", "resources\postAll")
buttonHold("postAll", "resources\createPost")
;guiControlGet, selectedLeague,, League, value
;if !(InStr(selectedLeague, "HC") > 0 or InStr(selectedLeague, "Hardcore") > 0 or InStr(selectedLeague, "Standard") > 0){
; msgbox, You are posting All for Temporary SC league `r`nTFT has split channels based on craft types`r`nThis message will get you timed out
;}
createPost("All")
return
League_dropdown:
guiControlGet, selectedLeague,,League, value
iniWrite, %selectedLeague%, %SettingsPath%, selectedLeague, s
;allowAll()
return
alwaysOnTop:
guiControlGet, onTop,,alwaysOnTop, value
iniWrite, %onTop%, %SettingsPath%, Other, alwaysOnTop
setWindowState(onTop)
return
setWindowState(onTop) {
mod := (onTop == 1) ? "+" : "-"
Gui, HarvestUI:%mod%AlwaysOnTop
}
;====================================================
; === Settings UI ===================================
settings:
iniRead tempMon, %SettingsPath%, Other, mon
buttonHold("settings", "resources\settings")
hotkey, %GuiKey%, off
hotkey, %ScanKey%, off
gui Settings:new,, PoE-HarvestVendor - Settings
gui, add, Groupbox, x5 y5 w400 h90, Message formatting
Gui, add, text, x10 y25, Output message style:
Gui, add, dropdownList, x120 y20 w30 voutStyle goutStyle, 1|2
iniRead, tstyle, %SettingsPath%, Other, outStyle
guicontrol, choose, outStyle, %tstyle%
Gui, add, text, x20 y50, 1 - No Colors, No codeblock = Words are highlighted when using discord search
Gui, add, text, x20 y70, 2 - Codeblock, Colors = Words aren't highlighetd when using discord search
gui, add, Groupbox, x5 y110 w400 h100, Monitor Settings
monitors := getMonCount()
Gui add, text, x10 y130, Select monitor:
Gui add, dropdownList, x85 y125 w30 vMonitors_v gMonitors, %monitors%
global Monitors_v_TT := "For when you aren't running PoE on main monitor"
guicontrol, choose, Monitors_v, %tempMon%
gui, add, text, x10 y150, Scale
iniRead, tScale, %SettingsPath%, Other, scale
gui, add, edit, x85 y150 w30 vScale gScale, %tScale%
Gui, add, text, x20 y175, - use this when you are using Other than 100`% scale in windows display settings
Gui, add, text, x20 y195, - 100`% = 1, 150`% = 1.5 and so on
gui, add, groupbox, x5 y215 w400 h75, Hotkeys
Gui, add, text, x10 y235, Open Harvest vendor:
iniRead, GuiKey, %SettingsPath%, Other, GuiKey
gui,add, hotkey, x120 y230 vGuiKey_v gGuiKey_l, %GuiKey%
Gui, add, text, x10 y260, Add crafts:
iniRead, ScanKey, %SettingsPath%, Other, ScanKey
gui, add, hotkey, x120 y255 vScanKey_v gScanKey_l, %ScanKey%
gui, add, button, x10 y295 h30 w390 gOpenRoaming vSettingsFolder, Open Settings Folder
gui, add, button, x10 y335 h30 w390 gSettingsOK, Save
gui, Settings:Show, w410 h370
return
SettingsGuiClose:
hotkey, %GuiKey%, on
hotkey, %ScanKey%, on
Gui, Settings:Destroy
Gui, HarvestUI:Default
return
GuiKey_l:
return
ScanKey_l:
return
OpenRoaming:
explorerpath := "explorer " RoamingDir
Run, %explorerpath%
return
outStyle:
guiControlGet, os,,outStyle, value
iniWrite, %os%, %SettingsPath%, Other, outStyle
return
Monitors:
guiControlGet, mon,,Monitors_v, value
iniWrite, %mon%, %SettingsPath%, Other, mon
return
Scale:
guiControlGet, sc,,Scale, value
iniWrite, %sc%, %SettingsPath%, Other, scale
return
SettingsOK:
iniRead, GuiKey, %SettingsPath%, Other, GuiKey
iniRead, ScanKey, %SettingsPath%, Other, ScanKey
guiControlGet, gk,, GuiKey_v, value
guiControlGet, sk,, ScanKey_v, value
if (GuiKey != gk and gk != "ERROR" and gk != "") {
hotkey, %GuiKey%, off
iniWrite, %gk%, %SettingsPath%, Other, GuiKey
hotkey, %gk%, OpenGui
}
if (ScanKey != sk and sk != "ERROR" and sk != "") {
hotkey, %ScanKey%, off
iniWrite, %sk%, %SettingsPath%, Other, ScanKey
hotkey, %sk%, Scan
}
if (gk != "ERROR" and gk != "") {
hotkey, %gk%, on
} else {
hotkey, %GuiKey%, on
}
if (sk != "ERROR" and sk != "") {
hotkey, %sk%, on
} else {
hotkey, %ScanKey%, on
}
Gui, Settings:Destroy
Gui, HarvestUI:Default
return
;====================================================
; === Help UI =======================================
help:
buttonHold("help", "resources\help")
IniWrite, 1, %SettingsPath%, Other, seenInstructions
gui Help:new,, PoE-HarvestVendor Help
gui, font, s14
Gui, add, text, x5 y5, Step 1
gui, add, text, x5 y80, Step 2
gui, add, text, x5 y380, Step 3
Gui, add, text, x5 y450, Step 4
gui, font
gui, font, s10
;step 1
gui, add, text, x15 y30, Default Hotkey to open the UI = Ctrl + Shift + G`r`nDefault Hotkey to start capture = Ctrl + G`r`nHotkeys can be changed in settings
;step 2
gui, add, text, x15 y110, Start the capture by either clicking Add Crafts button, `r`nor pressing the Capture hotkey.`r`nSelect the area with crafts:
Gui, Add, ActiveX, x5 y120 w290 h240 vArea, Shell2.Explorer
Area.document.body.style.overflow := "hidden"
Edit := WebPic(Area, "https://github.com/esge/PoE-HarvestVendor/blob/master/examples/snapshotArea_s.png?raw=true", "w250 h233 cFFFFFF")
gui, add, text, x15 y365, this can be done repeatedly to add crafts to the list
;step 3
gui, add, text, x15 y410, Fill in the prices (they will be remembered)`r`nand other info like: Can stream, IGN and so on if you wish to
;Gui, Add, ActiveX, x5 y430 w350 h100 vPricepic, Shell2.Explorer
;Pricepic.document.body.style.overflow := "hidden"
;Edit := WebPic(Pricepic, "https://github.com/esge/PoE-HarvestVendor/blob/master/examples/price.png?raw=true", "w298 h94 cFFFFFF")
;step 4
gui, add, text, x15 y480 w390, click: Post Augments/Removes... for the set you want to post`r`nNow your message is in clipboard`r`nCareful about Post All on TFT discord, it has separate channels for different craft types.
gui, add, text, x400 y10 h590 0x11 ;Vertical Line > Etched Gray
gui, font, s14 cRed
Gui, Add, text, x410 y10 w380, Important:
gui, font, s10
gui, add, text, x420 y30 w370, If you are using Big resolution (more than 1080p) and have scaling for display set in windows to more than 100`% (in Display settings)`r`nYou need to go into Settings in HarvestVendor and set Scale to match whats set in windows
gui, font, s14 cBlack
gui, add, text, x410 y110 w380, Hidden features
gui, font, s10
gui, add, text, x420 y130 w370, - Holding shift while clicking the X in a row will reduce the count by 1 and also write the craft and price into log.csv (you can find it through the Settings folder button in Settings)
gui, font
Gui, Help:Show, w800 h610
return
HelpGuiClose:
Gui, Help:Destroy
Gui, HarvestUI:Default
return
; === my functions ===
Handle_Augment(craftText, ByRef out) {
if (inStr(craftText, "Influenced") > 0) {
augments := ["Caster", "Physical", "Fire", "Attack", "Life", "Cold"
, "Speed", "Defence", "Lightning", "Chaos", "Critical", "a new modifier"]
for k, v in augments {
if (InStr(craftText, v) > 0) {
if (InStr(craftText, "Lucky") > 0) {
out.push(["Augment " . v . " Lucky"
, getLVL(craftText)
, "Aug"])
} else {
out.push(["Augment " . v
, getLVL(craftText)
, "Aug"])
}
return
}
}
return
}
if (InStr(craftText, "Lucky") > 0) {
out.push(["Augment Influence Lucky"
, getLVL(craftText)
, "Aug"])
} else {
out.push(["Augment Influence"
, getLVL(craftText)
, "Aug"])
}
}
Handle_Remove(craftText, ByRef out) {
if (InStr(craftText, "Influenced") > 0 or InStr(craftText, "influenced") > 0) {
if InStr(craftText, "add") > 0 {
removes := ["Caster", "Physical", "Fire", "Attack", "Life", "Cold"
, "Speed", "Defence", "Lightning", "Chaos", "Critical"]