-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
AzerothAuctionAssassin.py
2358 lines (1974 loc) · 93.6 KB
/
AzerothAuctionAssassin.py
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
# added the code at the beginning of the file
# to tell the script that is being invoked from the windows c# binary
# so it knows from where to load the pre-installed packages
# so it can locate them before doing the other imports
import sys
from datetime import datetime
AAA_VERSION = "1.2.5.2"
windowsApp_Path = None
try:
if sys.argv[1] == "run-from-windows-bin":
sys.path.append(f"{sys.argv[2]}")
sys.path.append(f"{sys.argv[3]}")
windowsApp_Path = f"{sys.argv[2]}"
else:
pass
except Exception as ex:
pass
# i hate the way that looks but if it isnt broken dont fix it
import breeze_resources
import ctypes
import pandas as pd
from mega_alerts import Alerts
import json
from sys import exit
import requests
import os
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import QThread, pyqtSignal, QFile, QTextStream
from PyQt5 import QtGui
from PyQt5.QtWidgets import (
QGridLayout,
QStackedWidget,
QMainWindow,
QApplication,
QLabel,
QLineEdit,
QPushButton,
QComboBox,
QListWidget,
QMessageBox,
QCheckBox,
QFileDialog,
QWidget,
QScrollArea,
QInputDialog,
)
if sys.platform == "win32":
myappid = "mycompany.myproduct.subproduct.version" # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
class Item_And_Pet_Statistics(QThread):
completed = pyqtSignal(pd.DataFrame, pd.DataFrame)
def __init__(self):
super(Item_And_Pet_Statistics, self).__init__()
def run(self):
item_statistics = pd.DataFrame(
data=requests.post(
f"http://api.saddlebagexchange.com/api/wow/megaitemnames",
headers={"Accept": "application/json"},
json={"region": "EU", "discount": 1},
).json()
)
pet_statistics = pd.DataFrame(
data=requests.post(
f"http://api.saddlebagexchange.com/api/wow/megaitemnames",
headers={"Accept": "application/json"},
json={"region": "EU", "discount": 1, "pets": True},
).json()
)
self.completed.emit(pet_statistics, item_statistics)
class App(QMainWindow):
def __init__(self):
super(App, self).__init__()
self.title = f"Azeroth Auction Assassin v{AAA_VERSION}"
self.left = 100
self.top = 100
self.width = 650
self.height = 750
icon_path = "icon.png"
# checking if the app is invoked from the windows binary and if yes then change the icon file path.
if windowsApp_Path is not None:
icon_path = f"{windowsApp_Path}\\{icon_path}"
icon = QIcon(icon_path)
self.setWindowIcon(icon)
self.token_auth_url = "http://api.saddlebagexchange.com/api/wow/checkmegatoken"
self.eu_connected_realms = os.path.join(
os.getcwd(), "AzerothAuctionAssassinData", "eu-wow-connected-realm-ids.json"
)
self.na_connected_realms = os.path.join(
os.getcwd(), "AzerothAuctionAssassinData", "na-wow-connected-realm-ids.json"
)
self.EUCLASSIC_connected_realms = os.path.join(
os.getcwd(),
"AzerothAuctionAssassinData",
"euclassic-wow-connected-realm-ids.json",
)
self.NACLASSIC_connected_realms = os.path.join(
os.getcwd(),
"AzerothAuctionAssassinData",
"naclassic-wow-connected-realm-ids.json",
)
self.NASODCLASSIC_connected_realms = os.path.join(
os.getcwd(),
"AzerothAuctionAssassinData",
"nasodclassic-wow-connected-realm-ids.json",
)
self.EUSODCLASSIC_connected_realms = os.path.join(
os.getcwd(),
"AzerothAuctionAssassinData",
"eusodclassic-wow-connected-realm-ids.json",
)
# default to 10% discount, just use EU for now for less data
self.api_data_thread = Item_And_Pet_Statistics()
self.api_data_thread.start()
self.api_data_thread.completed.connect(self.api_data_received)
self.pet_statistics = None
self.item_statistics = None
self.path_to_data = os.path.join(
os.getcwd(), "AzerothAuctionAssassinData", "mega_data.json"
)
self.path_to_desired_items = os.path.join(
os.getcwd(), "AzerothAuctionAssassinData", "desired_items.json"
)
self.path_to_desired_pets = os.path.join(
os.getcwd(), "AzerothAuctionAssassinData", "desired_pets.json"
)
self.path_to_desired_ilvl_items = os.path.join(
os.getcwd(), "AzerothAuctionAssassinData", "desired_ilvl.json"
)
self.path_to_desired_ilvl_list = os.path.join(
os.getcwd(), "AzerothAuctionAssassinData", "desired_ilvl_list.json"
)
self.pet_list = {}
self.items_list = {}
self.ilvl_list = []
self.ilvl_items = {}
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
central_widget = QWidget()
self.setCentralWidget(central_widget)
self.layout_area = QGridLayout(central_widget)
self.make_side_buttons()
self.stacked_widget = QStackedWidget(self)
home_page = QWidget()
self.home_page_layout = QGridLayout(home_page)
settings_page = QWidget()
self.settings_page_layout = QGridLayout(settings_page)
pet_page = QWidget()
self.pet_page_layout = QGridLayout(pet_page)
item_page = QWidget()
self.item_page_layout = QGridLayout(item_page)
ilvl_page = QWidget()
self.ilvl_page_layout = QGridLayout(ilvl_page)
realms_page = QWidget()
self.realms_page_layout = QGridLayout(realms_page)
self.stacked_widget.addWidget(home_page)
self.stacked_widget.addWidget(pet_page)
self.stacked_widget.addWidget(item_page)
self.stacked_widget.addWidget(ilvl_page)
self.stacked_widget.addWidget(settings_page)
self.stacked_widget.addWidget(realms_page)
self.layout_area.addWidget(self.stacked_widget, 0, 1, 17, 2)
self.make_home_page(home_page=home_page)
self.make_pet_page(pet_page=pet_page)
self.make_item_page(item_page=item_page)
self.make_ilvl_page(ilvl_page=ilvl_page)
self.make_settings_page(settings_page=settings_page)
self.make_realm_page(realm_page=realms_page)
self.check_for_settings()
# Create a QScrollArea and set its widget to be the container
scrollArea = QScrollArea()
scrollArea.setWidgetResizable(
True
) # Important to make the scroll area adapt to the content
scrollArea.setWidget(central_widget)
# Set the QScrollArea as the central widget of the main window
self.setCentralWidget(scrollArea)
self.show()
def make_realm_page(self, realm_page):
self.realm_region = QComboBox(realm_page)
self.realm_region_label = QLabel("WoW Region", realm_page)
self.realm_region_label.setToolTip("")
self.realm_region_label.setFixedHeight(10)
self.realm_region.addItems(
[
"Click this!!!",
"EU",
"NA",
"EUCLASSIC",
"NACLASSIC",
"NASODCLASSIC",
"EUSODCLASSIC",
]
)
self.realm_region.currentIndexChanged.connect(self.on_combo_box_region_changed)
self.realms_page_layout.addWidget(self.realm_region_label, 0, 0, 1, 1)
self.realms_page_layout.addWidget(self.realm_region, 1, 0, 1, 1)
self.realm_name_combobox = QComboBox(realm_page)
self.realm_name_combobox.setEnabled(False)
self.realm_realm_name_label = QLabel("Realm Name", realm_page)
self.realm_realm_name_label.setToolTip("")
self.realm_realm_name_label.setFixedHeight(10)
self.realms_page_layout.addWidget(self.realm_realm_name_label, 2, 0, 1, 1)
self.realms_page_layout.addWidget(self.realm_name_combobox, 3, 0, 1, 1)
self.realm_name_input = QLineEdit(realm_page)
self.realm_name_input_label = QLabel("Add Realm Name", realm_page)
self.realm_name_input_label.setToolTip("")
self.realm_name_input_label.setFixedHeight(10)
self.realms_page_layout.addWidget(self.realm_name_input_label, 4, 0, 1, 1)
self.realms_page_layout.addWidget(self.realm_name_input, 5, 0, 1, 1)
self.realm_id_input = QLineEdit(realm_page)
self.realm_id_input_label = QLabel("Add Realm ID", realm_page)
self.realm_id_input_label.setToolTip("")
self.realm_id_input_label.setFixedHeight(10)
self.realms_page_layout.addWidget(self.realm_id_input_label, 6, 0, 1, 1)
self.realms_page_layout.addWidget(self.realm_id_input, 7, 0, 1, 1)
self.add_realm_button = QPushButton("Add Realm")
self.add_realm_button.setToolTip("")
self.add_realm_button.clicked.connect(self.add_realm_to_list)
self.realms_page_layout.addWidget(self.add_realm_button, 8, 0, 1, 1)
self.reset_realm_button = QPushButton("Reset Realm List")
self.reset_realm_button.setToolTip("")
self.reset_realm_button.clicked.connect(self.reset_realm_list)
self.realms_page_layout.addWidget(self.reset_realm_button, 9, 0, 1, 1)
self.remove_realm_button = QPushButton("Remove Realm")
self.remove_realm_button.setToolTip("")
self.remove_realm_button.clicked.connect(self.remove_realm_to_list)
self.realms_page_layout.addWidget(self.remove_realm_button, 10, 0, 1, 1)
self.realm_list_display = QListWidget(realm_page)
self.realm_list_display.setSortingEnabled(True)
self.realm_list_display.itemClicked.connect(self.realm_list_clicked)
self.realms_page_layout.addWidget(self.realm_list_display, 0, 1, 11, 2)
def make_side_buttons(self):
self.go_to_home_button = QPushButton("Home Page")
self.go_to_home_button.setFixedSize(150, 25)
self.go_to_home_button.clicked.connect(self.go_to_home_page)
self.layout_area.addWidget(self.go_to_home_button, 0, 0)
self.go_to_pet_button = QPushButton("Pets")
self.go_to_pet_button.setFixedSize(150, 25)
self.go_to_pet_button.clicked.connect(self.go_to_pet_page)
self.layout_area.addWidget(self.go_to_pet_button, 1, 0)
self.go_to_item_button = QPushButton("Items")
self.go_to_item_button.setFixedSize(150, 25)
self.go_to_item_button.clicked.connect(self.go_to_item_page)
self.layout_area.addWidget(self.go_to_item_button, 2, 0)
self.go_to_ilvl_button = QPushButton("ILvl List")
self.go_to_ilvl_button.setFixedSize(150, 25)
self.go_to_ilvl_button.clicked.connect(self.go_to_ilvl_page)
self.layout_area.addWidget(self.go_to_ilvl_button, 3, 0)
self.go_to_settings_button = QPushButton("Application Settings")
self.go_to_settings_button.setFixedSize(150, 25)
self.go_to_settings_button.clicked.connect(self.go_to_settings_page)
self.layout_area.addWidget(self.go_to_settings_button, 4, 0)
self.go_to_realm_button = QPushButton("Realm Lists")
self.go_to_realm_button.setFixedSize(150, 25)
self.go_to_realm_button.clicked.connect(self.go_to_realms_page)
self.layout_area.addWidget(self.go_to_realm_button, 5, 0)
# add a line to separate the buttons from the rest of the UI
self.line = QLabel(self)
self.line.setStyleSheet("background-color: white")
self.line.setFixedSize(150, 25)
self.layout_area.addWidget(self.line, 6, 0)
# self.import_pbs_data_button = UIButtons(
# self, "Import PBS Data", 25, 400, 200, 50
# )
# self.import_pbs_data_button.clicked.connect(self.import_pbs_data)
# self.import_pbs_data_button.setToolTip(
# "Import your Point Blank Sniper text files"
# )
self.save_data_button = QPushButton("Save Data")
self.save_data_button.setFixedSize(150, 25)
self.save_data_button.clicked.connect(self.save_data_to_json)
self.save_data_button.setToolTip("Save data without starting a scan.")
self.layout_area.addWidget(self.save_data_button, 7, 0)
self.reset_data_button = QPushButton("Reset Data")
self.reset_data_button.setFixedSize(150, 25)
self.reset_data_button.clicked.connect(self.reset_app_data)
self.reset_data_button.setToolTip("Erase all data and reset the app.")
self.layout_area.addWidget(self.reset_data_button, 8, 0)
self.start_button = QPushButton("Start Alerts")
self.start_button.setFixedSize(150, 25)
self.start_button.clicked.connect(self.start_alerts)
self.start_button.setToolTip(
"Start the scan! Runs once on start and then waits for new data to send more alerts."
)
self.layout_area.addWidget(self.start_button, 9, 0)
self.stop_button = QPushButton("Stop Alerts")
self.stop_button.setFixedSize(150, 25)
self.stop_button.clicked.connect(self.stop_alerts)
self.stop_button.setEnabled(False)
self.stop_button.setToolTip(
"Gracefully stop the alerts.\nThis will not stop alerts in progress.\nYou may need to kill the process for a force stop."
)
self.layout_area.addWidget(self.stop_button, 10, 0)
self.mega_alerts_progress = QLabel("Waiting for user to Start!")
# this is important, if the messages from mega alerts status are too long, it will break the UI
self.mega_alerts_progress.setFixedSize(150, 100)
self.layout_area.addWidget(self.mega_alerts_progress, 11, 0)
def make_home_page(self, home_page):
# checking if the app is invoked from the windows binary and if yes then change the icon file path.
icon_path = "icon.ico"
if windowsApp_Path is not None:
icon_path = f"{windowsApp_Path}\\icon.ico"
# display the icon.ico
self.icon = QLabel(home_page)
self.icon.setPixmap(QtGui.QPixmap(icon_path))
self.home_page_layout.addWidget(self.icon, 0, 0)
# add the title
self.title = QLabel(home_page)
self.title.setText("Azeroth Auction Ace")
self.title.setFont((QtGui.QFont("Arial", 30, QtGui.QFont.Bold)))
self.home_page_layout.addWidget(self.title, 1, 0)
# add link to patreon
self.patreon_link = QLabel(home_page)
self.patreon_link.setText(
"<a href='https://www.patreon.com/indopan' style='color: white;'>Support the Project on Patreon</a>"
)
self.patreon_link.setFont((QtGui.QFont("Arial", 12, QtGui.QFont.Bold)))
self.patreon_link.setOpenExternalLinks(True)
self.home_page_layout.addWidget(self.patreon_link, 2, 0)
# add discord link
self.discord_link = QLabel(home_page)
self.discord_link.setText(
"<a href='https://discord.gg/9dHx2rEq9F' style='color: white;'>Join the Discord</a>"
)
self.discord_link.setFont((QtGui.QFont("Arial", 12, QtGui.QFont.Bold)))
self.discord_link.setOpenExternalLinks(True)
self.home_page_layout.addWidget(self.discord_link, 3, 0)
# add main website link
self.website_link = QLabel(home_page)
self.website_link.setText(
"<a href='https://saddlebagexchange.com' style='color: white;'>Check out our main website: Saddlebag Exchange</a>"
)
self.website_link.setFont((QtGui.QFont("Arial", 12, QtGui.QFont.Bold)))
self.website_link.setOpenExternalLinks(True)
self.home_page_layout.addWidget(self.website_link, 4, 0)
# add a guides link
self.guides_link = QLabel(home_page)
self.guides_link.setText(
"<a href='https://github.com/ff14-advanced-market-search/AzerothAuctionAssassin/wiki' style='color: white;'>Check out our guides</a>"
)
self.guides_link.setFont((QtGui.QFont("Arial", 12, QtGui.QFont.Bold)))
self.guides_link.setOpenExternalLinks(True)
self.home_page_layout.addWidget(self.guides_link, 5, 0)
def make_settings_page(self, settings_page):
self.discord_webhook_input = QLineEdit(settings_page)
self.discord_webhook_input_label = QLabel("Discord Webhook", settings_page)
self.discord_webhook_input_label.setToolTip(
"Setup a discord channel with a webhook url for sending the alert messages."
)
self.settings_page_layout.addWidget(
self.discord_webhook_input_label, 0, 0, 1, 2
)
self.settings_page_layout.addWidget(self.discord_webhook_input, 1, 0, 1, 2)
self.wow_client_id_input = QLineEdit(settings_page)
self.wow_client_id_input_label = QLabel("WoW Client ID", settings_page)
self.wow_client_id_input_label.setToolTip(
"Go to https://develop.battle.net/access/clients\nand create a client, get the blizzard oauth client and secret ids."
)
self.settings_page_layout.addWidget(self.wow_client_id_input_label, 2, 0, 1, 2)
self.settings_page_layout.addWidget(self.wow_client_id_input, 3, 0, 1, 2)
self.wow_client_secret_input = QLineEdit(settings_page)
self.wow_client_secret_input_label = QLabel("WoW Client Secret", settings_page)
self.wow_client_secret_input_label.setToolTip(
"Go to https://develop.battle.net/access/clients\nand create a client, get the blizzard oauth client and secret ids."
)
self.settings_page_layout.addWidget(
self.wow_client_secret_input_label, 4, 0, 1, 2
)
self.settings_page_layout.addWidget(self.wow_client_secret_input, 5, 0, 1, 2)
self.authentication_token = QLineEdit(settings_page)
self.authentication_token_label = QLabel(
"Auction Assassin Token", settings_page
)
self.authentication_token_label.setToolTip(
"Go to the Saddlebag Exchange Discord and generate a token with the bot command:\n/wow auctionassassintoken"
)
self.settings_page_layout.addWidget(self.authentication_token_label, 6, 0, 1, 2)
self.settings_page_layout.addWidget(self.authentication_token, 7, 0, 1, 2)
self.wow_region = QComboBox(settings_page)
self.wow_region.addItems(
["EU", "NA", "EUCLASSIC", "NACLASSIC", "NASODCLASSIC", "EUSODCLASSIC"]
)
self.wow_region_label = QLabel("Auction Assassin Token", settings_page)
self.wow_region_label.setToolTip(
"Pick your region, currently supporting: EU, NA, EU-Classic, NA-Classic, EU-SoD-Classic and NA-SoD-Classic."
)
self.settings_page_layout.addWidget(self.wow_region_label, 8, 0, 1, 1)
self.settings_page_layout.addWidget(self.wow_region, 9, 0, 1, 1)
self.number_of_mega_threads = QLineEdit(settings_page)
self.number_of_mega_threads.setText("10")
self.number_of_mega_threads_label = QLabel("Number of Threads", settings_page)
self.number_of_mega_threads_label.setToolTip(
"Change the thread count.\nDo 100 for the fastest scans, but RIP to ur CPU and MEM."
)
self.settings_page_layout.addWidget(
self.number_of_mega_threads_label, 8, 1, 1, 1
)
self.settings_page_layout.addWidget(self.number_of_mega_threads, 9, 1, 1, 1)
self.scan_time_min = QLineEdit(settings_page)
self.scan_time_min.setText("1")
self.scan_time_min_label = QLabel("Scan Time Min", settings_page)
self.scan_time_min_label.setToolTip(
"Increase or decrease the minutes before or after the data update to start timed scans."
)
self.settings_page_layout.addWidget(self.scan_time_min_label, 10, 1, 1, 1)
self.settings_page_layout.addWidget(self.scan_time_min, 11, 1, 1, 1)
self.scan_time_max = QLineEdit(settings_page)
self.scan_time_max.setText("3")
self.scan_time_max_label = QLabel("Scan Time Max", settings_page)
self.scan_time_max_label.setToolTip(
"Increase or decrease the minutes before or after the data update to stop running scans."
)
self.settings_page_layout.addWidget(self.scan_time_max_label, 12, 1, 1, 1)
self.settings_page_layout.addWidget(self.scan_time_max, 13, 1, 1, 1)
self.discount_percent = QLineEdit(settings_page)
self.discount_percent.setText("10")
self.discount_percent_label = QLabel("Discount vs Average", settings_page)
self.discount_percent_label.setToolTip(
"Set the price recommendation discount\n"
+ "1 to 100, smaller number means a better price.\n"
+ "ex: if you set 10 pecent and avg price is 100k, it recommends you snipe for 10k."
)
self.settings_page_layout.addWidget(self.discount_percent_label, 14, 1, 1, 1)
self.settings_page_layout.addWidget(self.discount_percent, 15, 1, 1, 1)
self.show_bid_prices = QCheckBox("Show Bid Prices", settings_page)
self.show_bid_prices.setToolTip(
"Show items with Bid prices below your price limit on Desired Items"
)
self.settings_page_layout.addWidget(self.show_bid_prices, 10, 0, 1, 1)
self.wow_head_link = QCheckBox("Show wowhead link", settings_page)
self.wow_head_link.setToolTip(
"Uses wowhead links instead of Undermine and shows pictures."
)
self.settings_page_layout.addWidget(self.wow_head_link, 11, 0, 1, 1)
self.no_links = QCheckBox("Disable Web Links", settings_page)
self.no_links.setToolTip(
"Disable all Wowhead, undemine and saddlebag links from discord messages."
)
self.settings_page_layout.addWidget(self.no_links, 12, 0, 1, 1)
self.russian_realms = QCheckBox("No Russian Realms", settings_page)
self.russian_realms.setChecked(True)
self.russian_realms.setToolTip("Removes alerts from Russian Realms.")
self.settings_page_layout.addWidget(self.russian_realms, 13, 0, 1, 1)
self.refresh_alerts = QCheckBox("Refresh Alerts", settings_page)
self.refresh_alerts.setToolTip("Set to true to refresh alerts every 1 hour.")
self.settings_page_layout.addWidget(self.refresh_alerts, 14, 0, 1, 1)
self.debug_mode = QCheckBox("Debug Mode", settings_page)
self.debug_mode.setToolTip(
"Trigger a scan on all realms once.\nUse this to test make sure your data is working."
)
self.settings_page_layout.addWidget(self.debug_mode, 15, 0, 1, 1)
self.faction = QComboBox(settings_page)
self.faction.addItems(["all", "horde", "alliance", "booty bay"])
self.faction_label = QLabel("Faction AH", settings_page)
self.faction_label.setToolTip(
"Pick your faction for classic or pick 'all' to see all auctionhouses, Retail uses 'all' by default for cross faction AH."
)
self.settings_page_layout.addWidget(self.faction_label, 16, 0, 1, 1)
self.settings_page_layout.addWidget(self.faction, 17, 0, 1, 1)
self.import_config_button = QPushButton("Import Config")
self.import_config_button.clicked.connect(self.import_configs)
self.import_config_button.setToolTip("Import your mega_data.json config.")
self.settings_page_layout.addWidget(self.import_config_button, 18, 0, 1, 1)
def make_pet_page(self, pet_page):
self.pet_id_input = QLineEdit(pet_page)
self.pet_id_input_label = QLabel("Pet ID", pet_page)
self.pet_id_input_label.setToolTip(
"Add the Pet ID that you want to snipe.\nYou can find that id at the end of the undermine exchange link for the item next to 82800 (which is the item id for pet cages)\nhttps://undermine.exchange/#us-suramar/82800-3390."
)
self.pet_page_layout.addWidget(self.pet_id_input_label, 0, 0, 1, 1)
self.pet_page_layout.addWidget(self.pet_id_input, 1, 0, 1, 1)
self.pet_price_input = QLineEdit(pet_page)
self.pet_price_input_label = QLabel("Price", pet_page)
self.pet_price_input_label.setToolTip(
"Pick a price you want to buy at or under."
)
self.pet_page_layout.addWidget(self.pet_price_input_label, 0, 1, 1, 1)
self.pet_page_layout.addWidget(self.pet_price_input, 1, 1, 1, 1)
self.pet_name_input = QComboBox(pet_page)
self.pet_name_input.setEnabled(False)
self.pet_page_layout.addWidget(self.pet_name_input, 2, 0, 1, 2)
self.add_pet_button = QPushButton("Add/Update Pet")
self.add_pet_button.setToolTip("Add/Update pet to your snipe list.")
self.add_pet_button.clicked.connect(self.add_pet_to_dict)
self.pet_page_layout.addWidget(self.add_pet_button, 3, 0, 1, 1)
self.remove_pet_button = QPushButton("Remove Pet")
self.remove_pet_button.setToolTip("Remove pet from your snipe list.")
self.remove_pet_button.clicked.connect(self.remove_pet_to_dict)
self.pet_page_layout.addWidget(self.remove_pet_button, 3, 1, 1, 1)
self.pet_list_display = QListWidget(pet_page)
self.pet_list_display.setSortingEnabled(True)
self.pet_list_display.itemClicked.connect(self.pet_list_double_clicked)
self.pet_page_layout.addWidget(self.pet_list_display, 4, 0, 13, 2)
self.import_pet_data_button = QPushButton("Import Pet Data")
self.import_pet_data_button.setToolTip("Import your desired_pets.json config")
self.import_pet_data_button.clicked.connect(self.import_pet_data)
self.pet_page_layout.addWidget(self.import_pet_data_button, 17, 0, 1, 2)
self.erase_pet_data_button = QPushButton("Erase Pet Data")
self.erase_pet_data_button.setToolTip("Erase your pet list")
self.erase_pet_data_button.clicked.connect(self.erase_pet_data)
self.pet_page_layout.addWidget(self.erase_pet_data_button, 18, 0, 1, 2)
def make_item_page(self, item_page):
self.item_id_input = QLineEdit(item_page)
self.item_id_input_label = QLabel("Item ID", item_page)
self.item_id_input_label.setToolTip(
"Add the item id of any item you want to buy.\n"
+ "You can search by name for them here with recommended prices\n"
+ "https://temp.saddlebagexchange.com/megaitemnames"
)
self.item_page_layout.addWidget(self.item_id_input_label, 0, 0, 1, 1)
self.item_page_layout.addWidget(self.item_id_input, 1, 0, 1, 1)
self.item_price_input = QLineEdit(item_page)
self.item_price_input_label = QLabel("Price", item_page)
self.item_price_input_label.setToolTip(
"Pick a price you want to buy at or under."
)
self.item_page_layout.addWidget(self.item_price_input_label, 0, 1, 1, 1)
self.item_page_layout.addWidget(self.item_price_input, 1, 1, 1, 1)
self.item_name_input = QComboBox(item_page)
self.item_name_input.setEnabled(False)
self.item_page_layout.addWidget(self.item_name_input, 2, 0, 1, 2)
self.add_item_button = QPushButton("Add/Update Item")
self.add_item_button.setToolTip("Add/Update item to your snipe list.")
self.add_item_button.clicked.connect(self.add_item_to_dict)
self.item_page_layout.addWidget(self.add_item_button, 3, 0, 1, 1)
self.remove_item_button = QPushButton("Remove Item")
self.remove_item_button.setToolTip("Remove item from your snipe list.")
self.remove_item_button.clicked.connect(self.remove_item_to_dict)
self.item_page_layout.addWidget(self.remove_item_button, 3, 1, 1, 1)
self.item_list_display = QListWidget(item_page)
self.item_list_display.setSortingEnabled(True)
self.item_list_display.itemClicked.connect(self.item_list_double_clicked)
self.item_page_layout.addWidget(self.item_list_display, 4, 0, 13, 2)
self.import_item_data_button = QPushButton("Import Item Data")
self.import_item_data_button.setToolTip("Import your desired_items.json config")
self.import_item_data_button.clicked.connect(self.import_item_data)
self.item_page_layout.addWidget(self.import_item_data_button, 17, 0, 1, 1)
self.import_pbs_data_button = QPushButton("Import PBS Data")
self.import_pbs_data_button.setToolTip(
"Import your Point Blank Sniper text files"
)
self.import_pbs_data_button.clicked.connect(self.import_pbs_data)
self.item_page_layout.addWidget(self.import_pbs_data_button, 17, 1, 1, 1)
self.erase_item_data_button = QPushButton("Erase Item Data")
self.erase_item_data_button.setToolTip("Erase your desired_items.json config")
self.erase_item_data_button.clicked.connect(self.erase_item_data)
self.item_page_layout.addWidget(self.erase_item_data_button, 18, 0, 1, 1)
# Add the button to convert AAA JSON to PBS
self.convert_to_pbs_button = QPushButton("Convert AAA to PBS")
self.convert_to_pbs_button.setToolTip(
"Convert your AAA JSON list to PBS format."
)
self.convert_to_pbs_button.clicked.connect(self.convert_to_pbs)
self.item_page_layout.addWidget(self.convert_to_pbs_button, 18, 1, 1, 1)
def make_ilvl_page(self, ilvl_page):
self.ilvl_item_input = QLineEdit(ilvl_page)
self.ilvl_item_input_label = QLabel("Item ID(s)", ilvl_page)
self.ilvl_item_input_label.setToolTip(
"Leave blank to snipe all items at this Ilvl.\n"
+ "Add the Item IDs of the BOE you want to snipe specific items separated by a comma\n"
+ "ex: 1,2,99,420420"
)
self.ilvl_item_input_label.setFixedSize(120, 15)
self.ilvl_item_input.setFixedSize(120, 25)
self.ilvl_page_layout.addWidget(self.ilvl_item_input_label, 0, 0, 1, 1)
self.ilvl_page_layout.addWidget(self.ilvl_item_input, 1, 0, 1, 1)
self.ilvl_input = QLineEdit(ilvl_page)
self.ilvl_input_label = QLabel("Item Level", ilvl_page)
self.ilvl_input_label.setToolTip(
"Set the minimum item level (ilvl) you want to snipe. Ex: 400 ilvl."
)
self.ilvl_input_label.setFixedSize(120, 15)
self.ilvl_input.setFixedSize(120, 25)
self.ilvl_page_layout.addWidget(self.ilvl_input_label, 2, 0, 1, 1)
self.ilvl_page_layout.addWidget(self.ilvl_input, 3, 0, 1, 1)
self.ilvl_price_input = QLineEdit(ilvl_page)
self.ilvl_price_input_label = QLabel("Buyout", ilvl_page)
self.ilvl_price_input_label.setToolTip(
"Set the maximum buyout you want to snipe."
)
self.ilvl_price_input_label.setFixedSize(120, 15)
self.ilvl_price_input.setFixedSize(120, 25)
self.ilvl_page_layout.addWidget(self.ilvl_price_input_label, 4, 0, 1, 1)
self.ilvl_page_layout.addWidget(self.ilvl_price_input, 5, 0, 1, 1)
self.ilvl_sockets = QCheckBox("Sockets", ilvl_page)
self.ilvl_sockets.setToolTip("Do you want the item to have Sockets?")
self.ilvl_page_layout.addWidget(self.ilvl_sockets, 6, 0, 1, 1)
self.ilvl_speed = QCheckBox("Speed", ilvl_page)
self.ilvl_speed.setToolTip("Do you want the item to have Speed?")
self.ilvl_page_layout.addWidget(self.ilvl_speed, 7, 0, 1, 1)
self.ilvl_leech = QCheckBox("Leech", ilvl_page)
self.ilvl_leech.setToolTip("Do you want the item to have Leech?")
self.ilvl_page_layout.addWidget(self.ilvl_leech, 8, 0, 1, 1)
self.ilvl_avoidance = QCheckBox("Avoidance", ilvl_page)
self.ilvl_avoidance.setToolTip("Do you want the item to have Avoidance?")
self.ilvl_page_layout.addWidget(self.ilvl_avoidance, 9, 0, 1, 1)
self.ilvl_min_required_lvl_input = QLineEdit(ilvl_page)
self.ilvl_min_required_lvl_input_label = QLabel("Min Player Level", ilvl_page)
self.ilvl_min_required_lvl_input_label.setToolTip(
"Set the minimum required character level to use gear.\n"
+ "Ex: required level 80 for TWW items, 70 for DF items, etc."
)
self.ilvl_min_required_lvl_input_label.setFixedSize(120, 15)
self.ilvl_min_required_lvl_input.setFixedSize(120, 25)
self.ilvl_page_layout.addWidget(
self.ilvl_min_required_lvl_input_label, 10, 0, 1, 1
)
self.ilvl_page_layout.addWidget(self.ilvl_min_required_lvl_input, 11, 0, 1, 1)
self.ilvl_max_required_lvl_input = QLineEdit(ilvl_page)
self.ilvl_max_required_lvl_input_label = QLabel("Max Player Level", ilvl_page)
self.ilvl_max_required_lvl_input_label.setToolTip(
"Set the maximum required character level to use gear.\n"
+ "Ex: required level 70 for TWW twink items, etc."
)
self.ilvl_max_required_lvl_input_label.setFixedSize(120, 15)
self.ilvl_max_required_lvl_input.setFixedSize(120, 25)
self.ilvl_page_layout.addWidget(
self.ilvl_max_required_lvl_input_label, 12, 0, 1, 1
)
self.ilvl_page_layout.addWidget(self.ilvl_max_required_lvl_input, 13, 0, 1, 1)
self.add_ilvl_button = QPushButton("Add/Update Item", ilvl_page)
self.add_ilvl_button.setToolTip("Add/Update item to your snipe list.")
self.add_ilvl_button.clicked.connect(self.add_ilvl_to_list)
self.ilvl_page_layout.addWidget(self.add_ilvl_button, 11, 1, 1, 1)
self.remove_ilvl_button = QPushButton("Remove Item", ilvl_page)
self.remove_ilvl_button.setToolTip("Remove item from your snipe list.")
self.remove_ilvl_button.clicked.connect(self.remove_ilvl_to_list)
self.ilvl_page_layout.addWidget(self.remove_ilvl_button, 12, 1, 1, 1)
self.import_ilvl_data_button = QPushButton("Import ILVL Data")
self.import_ilvl_data_button.setToolTip(
"Import your desired_ilvl_list.json config"
)
self.import_ilvl_data_button.clicked.connect(self.import_ilvl_data)
self.ilvl_page_layout.addWidget(self.import_ilvl_data_button, 13, 1, 1, 1)
self.erase_ilvl_data_button = QPushButton("Erase ILvl Data")
self.erase_ilvl_data_button.setToolTip(
"Erase your desired_ilvl_list.json config"
)
self.erase_ilvl_data_button.clicked.connect(self.erase_ilvl_data)
self.ilvl_page_layout.addWidget(self.erase_ilvl_data_button, 14, 1, 1, 1)
self.ilvl_list_display = QListWidget(ilvl_page)
self.ilvl_list_display.setSortingEnabled(True)
self.ilvl_list_display.itemClicked.connect(self.ilvl_list_double_clicked)
self.ilvl_page_layout.addWidget(self.ilvl_list_display, 0, 1, 11, 2)
def go_to_home_page(self):
self.stacked_widget.setCurrentIndex(0)
def go_to_pet_page(self):
self.stacked_widget.setCurrentIndex(1)
def go_to_item_page(self):
self.stacked_widget.setCurrentIndex(2)
def go_to_ilvl_page(self):
self.stacked_widget.setCurrentIndex(3)
def go_to_settings_page(self):
self.stacked_widget.setCurrentIndex(4)
def go_to_realms_page(self):
self.stacked_widget.setCurrentIndex(5)
def api_data_received(self, pet_statistics, item_statistics):
self.pet_statistics = pet_statistics
self.item_statistics = item_statistics
self.pet_name_input.addItems(
self.pet_statistics.sort_values(by="itemName")["itemName"].tolist()
)
self.pet_name_input.setEditable(True)
self.pet_name_input.setInsertPolicy(QComboBox.NoInsert)
self.pet_name_input.completer()
self.pet_name_input.currentIndexChanged.connect(self.on_combo_box_pet_changed)
self.item_name_input.addItems(
self.item_statistics.sort_values(by="itemName")["itemName"].tolist()
)
self.item_name_input.setEditable(True)
self.item_name_input.setInsertPolicy(QComboBox.NoInsert)
self.item_name_input.completer()
self.item_name_input.currentIndexChanged.connect(self.on_combo_box_item_changed)
self.item_name_input.setEnabled(True)
self.item_name_input.setStyleSheet(
"QComboBox { background-color: #1D2023; color: white; }"
"QComboBox::editable { background: #1D2023; color: white; }"
"QComboBox::drop-down { border: 0px; }"
)
self.pet_name_input.setEnabled(True)
self.pet_name_input.setStyleSheet(
"QComboBox { background-color: #1D2023; color: white; }"
"QComboBox::editable { background: #1D2023; color: white; }"
"QComboBox::drop-down { border: 0px; }"
)
def on_combo_box_item_changed(self, index):
# This function will be called whenever the user selects a different item
selected_item = self.item_name_input.currentText()
selected_item_stats = self.item_statistics[
self.item_statistics["itemName"] == selected_item
]
selected_item_id = selected_item_stats["itemID"].iloc[0]
if str(selected_item_id) in self.items_list.keys():
selected_item_price = self.items_list[str(selected_item_id)]
else:
selected_item_price = selected_item_stats["desiredPrice"].iloc[0]
# if the user has not set a price for the item, set the price from TSM stats
if (
not self.item_price_input.text()
or str(selected_item_id) not in self.items_list
):
try:
discount_percent = int(self.discount_percent.text()) / 100
recommended_price = str(
int(float(selected_item_price) * discount_percent)
)
self.item_price_input.setText(recommended_price)
except:
self.item_price_input.setText("10")
recommended_price = str(int(float(selected_item_price) * 0.1))
self.item_price_input.setText(recommended_price)
else:
self.item_price_input.setText(str(selected_item_price))
self.item_id_input.setText(str(selected_item_id))
def on_combo_box_pet_changed(self, index):
# This function will be called whenever the user selects a different item
selected_pet = self.pet_name_input.currentText()
selected_pet_stats = self.pet_statistics[
self.pet_statistics["itemName"] == selected_pet
]
selected_pet_id = selected_pet_stats["itemID"].iloc[0]
if str(selected_pet_id) in self.pet_list.keys():
selected_pet_price = self.pet_list[str(selected_pet_id)]
else:
selected_pet_price = selected_pet_stats["desiredPrice"].iloc[0]
# if the user has not set a price for the item, set the price from TSM stats
if not self.pet_price_input.text() or str(selected_pet_id) not in self.pet_list:
try:
discount_percent = int(self.discount_percent.text()) / 100
recommended_price = str(
int(float(selected_pet_price) * discount_percent)
)
self.pet_price_input.setText(recommended_price)
except:
self.pet_price_input.setText("10")
recommended_price = str(int(float(selected_pet_price) * 0.1))
self.pet_price_input.setText(recommended_price)
else:
self.pet_price_input.setText(str(selected_pet_price))
self.pet_id_input.setText(str(selected_pet_id))
def on_combo_box_region_changed(self, index):
self.realm_list_display.clear()
self.realm_name_combobox.clear()
selected_realm = self.realm_region.currentText()
match selected_realm:
case "EU":
from utils.realm_data import EU_CONNECTED_REALMS_IDS as realm_list
data_to_insert = self.eu_connected_realms
case "NA":
from utils.realm_data import NA_CONNECTED_REALMS_IDS as realm_list
data_to_insert = self.na_connected_realms
case "EUCLASSIC":
from utils.realm_data import (
EUCLASSIC_CONNECTED_REALMS_IDS as realm_list,
)
data_to_insert = self.EUCLASSIC_connected_realms
case "NACLASSIC":
from utils.realm_data import (
NACLASSIC_CONNECTED_REALMS_IDS as realm_list,
)
data_to_insert = self.NACLASSIC_connected_realms
case "NASODCLASSIC":
from utils.realm_data import (
NASODCLASSIC_CONNECTED_REALMS_IDS as realm_list,
)
data_to_insert = self.NASODCLASSIC_connected_realms
case "EUSODCLASSIC":
from utils.realm_data import (
EUSODCLASSIC_CONNECTED_REALMS_IDS as realm_list,
)
data_to_insert = self.EUSODCLASSIC_connected_realms
case _:
QMessageBox.critical(self, "Region List", "Select valid region.")
return False
with open(data_to_insert, "r") as f:
data = json.load(f)
self.realm_name_combobox.addItems(list(realm_list.keys()))
self.realm_name_combobox.setEditable(True)
self.realm_name_combobox.setInsertPolicy(QComboBox.NoInsert)
self.realm_name_combobox.completer()
self.realm_name_combobox.currentIndexChanged.connect(
self.on_combo_box_realm_name_changed
)
self.realm_name_combobox.setStyleSheet(
"QComboBox { background-color: #1D2023; color: white; }"
"QComboBox::editable { background: #1D2023; color: white; }"
"QComboBox::drop-down { border: 0px; }"
)
self.realm_name_combobox.setEnabled(True)
for key, value in data.items():
self.realm_list_display.insertItem(
self.realm_list_display.count(), f"Name: {key}; ID: {value};"
)
def on_combo_box_realm_name_changed(self, index):
selected_realm_name = self.realm_name_combobox.currentText()
if selected_realm_name == "":
return 0
selected_realm = self.realm_region.currentText()
match selected_realm:
case "EU":
from utils.realm_data import EU_CONNECTED_REALMS_IDS as realm_list
case "NA":
from utils.realm_data import NA_CONNECTED_REALMS_IDS as realm_list
case "EUCLASSIC":
from utils.realm_data import (
EUCLASSIC_CONNECTED_REALMS_IDS as realm_list,
)
case "NACLASSIC":
from utils.realm_data import (
NACLASSIC_CONNECTED_REALMS_IDS as realm_list,
)
case "NASODCLASSIC":
from utils.realm_data import (
NASODCLASSIC_CONNECTED_REALMS_IDS as realm_list,
)
case "EUSODCLASSIC":
from utils.realm_data import (
EUSODCLASSIC_CONNECTED_REALMS_IDS as realm_list,
)
case _:
QMessageBox.critical(self, "Region List", "Select valid region.")
return False