-
Notifications
You must be signed in to change notification settings - Fork 8
/
AH_Helper.lua
executable file
·1712 lines (1573 loc) · 62.7 KB
/
AH_Helper.lua
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
------------------------------------------------------
-- #模块名:交易行模块
-- #模块说明:交易行各类功能的增强
------------------------------------------------------
local L = AH_Library.LoadLangPack()
_G["AH_Helper_Loaded"] = true
local ipairs = ipairs
local pairs = pairs
local tonumber = tonumber
--------------------------------------------------------
-- 插件配置
--------------------------------------------------------
AH_Helper = {
szDefaultValue = "Btn_Min",
szDefaultTime = L("STR_HELPER_24HOUR"),
nVersion = 0,
nPricePercentage = 0.95,
nDefaultPrices = 1,
nMaxHistory = 10,
--nMultiple = 1.5,
bShowQualityLevel = true,
bRealTime = true,
bBidderName = true,
bFastBid = true,
bFastBuy = true,
bFastCancel = true,
bDBClickFastBuy = false,
bDBClickFastCancel = false,
--bNoAllPrompt = false,
bPricePercentage = false,
bLowestPrices = true,
bFilterRecipe = false,
bFilterBook = false,
bAutoSearch = true,
--bSellNotice = false,
bFormatMoney = false,
bDBCtrlSell = false,
--bGuard = true,
bExVersion = false,
tItemFavorite = {},
tBlackList = {},
tSellerList = {},
tItemHistory = {},
tItemPrice = {},
tCDiamondPrice = {},
tRealTimeColor = {255, 0, 0},
tBidderNameColor = {0, 200, 0},
szDataPath = "\\Interface\\AH\\AH_Base\\data\\ah.jx3dat",
szDataPathCDiamond = "\\Interface\\AH\\AH_Base\\data\\ahcdiamond.jx3dat",
szVersion = "3.6.5",
}
--------------------------------------------------------
-- 交易行数据缓存
--------------------------------------------------------
local tBidTime = {}
local tTempSellPrice = {}
local tTempCDiamondSellPrice = {}
local bFilterd = false
local bHooked = false
local bAutoSearch = false
local szSellerSearch = ""
--------------------------------------------------------
-- 用户数据存储
--------------------------------------------------------
RegisterCustomData("AH_Helper.szDefaultValue")
RegisterCustomData("AH_Helper.szDefaultTime")
RegisterCustomData("AH_Helper.nDefaultPrices")
RegisterCustomData("AH_Helper.nMaxHistory")
--RegisterCustomData("AH_Helper.nMultiple")
RegisterCustomData("AH_Helper.nPricePercentage")
RegisterCustomData("AH_Helper.bFilterRecipe")
RegisterCustomData("AH_Helper.bFilterBook")
RegisterCustomData("AH_Helper.bAutoSearch")
RegisterCustomData("AH_Helper.bLowestPrices")
RegisterCustomData("AH_Helper.bPricePercentage")
RegisterCustomData("AH_Helper.bShowQualityLevel")
RegisterCustomData("AH_Helper.bFastBid")
RegisterCustomData("AH_Helper.bFastBuy")
RegisterCustomData("AH_Helper.bFastCancel")
--RegisterCustomData("AH_Helper.bGuard")
RegisterCustomData("AH_Helper.bExVersion")
RegisterCustomData("AH_Helper.bRealTime")
RegisterCustomData("AH_Helper.bBidderName")
RegisterCustomData("AH_Helper.bDBClickFastBuy")
RegisterCustomData("AH_Helper.bDBClickFastCancel")
RegisterCustomData("AH_Helper.bDBCtrlSell")
RegisterCustomData("AH_Helper.tItemHistory")
RegisterCustomData("AH_Helper.tItemFavorite")
RegisterCustomData("AH_Helper.tBlackList")
RegisterCustomData("AH_Helper.tSellerList")
RegisterCustomData("AH_Helper.tRealTimeColor")
RegisterCustomData("AH_Helper.tBidderNameColor")
--------------------------------------------------------
-- AH局部变量初始化
--------------------------------------------------------
local NO_BID_PRICE = PackMoney(9000000, 0, 0)
local PRICE_LIMITED = PackMoney(800000, 0, 0)
local tSearchInfoDefault = {
["Name"] = L("STR_HELPER_ITEMNAME"),
["Level"] = {"", ""},
["Quality"] = L("STR_HELPER_ANYLEVEL"),
["Status"] = L("STR_HELPER_ALLSTATE"),
["MaxPrice"] = {"", "" ,""},
}
local AUCTION_ORDER_TYPE = {
QUALITY = 0,
LEVEL = 1,
LEFT_TIME = 2,
PRICE = 3,
BUY_IT_NOW_PRICE = 4,
}
local tItemDataInfo =
{
["Search"] = {nStart = 1, nCurCount = 0, nTotCount = 0, nSortType = AUCTION_ORDER_TYPE.BUY_IT_NOW_PRICE, bDesc = 0, bUnitPrice=true, nRequestID = 0, szCheckName = "CheckBox_RName"},
["Sell"] = {nStart = 1, nCurCount = 0, nTotCount = 0, nSortType = AUCTION_ORDER_TYPE.QUALITY, bDesc = 1, bUnitPrice=false, nRequestID = 1, szCheckName = "CheckBox_AName"},
["Bid"] = {nStart = 1, nCurCount = 0, nTotCount = 0, nSortType = AUCTION_ORDER_TYPE.LEFT_TIME, bDesc = 1, bUnitPrice=false, nRequestID = 2, szCheckName = "CheckBox_BRemainTime"},
}
local tItemWidgetInfo =
{
["Search"] =
{
Scroll="Scroll_Result", BtnUp="Btn_RUp", BtnDown="Btn_RDown", Box="Box_Box", Text="Text_BoxName", Level="Text_BoxLevel", Saler="Text_BoxSaler", Time="Text_BoxRemainTime",
aBidText={"Handle_BidMoney", "Text_MyBid"},
aBuyText={"Handle_BidMoneyU", "Text_UnitPrice"},
tCheck =
{
["CheckBox_RName"] = {imgUp = "Image_RNameUp", imgDown = "Image_RNameDown", nSortType = AUCTION_ORDER_TYPE.QUALITY},
["CheckBox_RLevel"] = {imgUp = "Image_RLevelUp", imgDown = "Image_RLevelDown", nSortType = AUCTION_ORDER_TYPE.LEVEL},
["CheckBox_RemainTime"] = {imgUp = "Image_ReNameUp", imgDown = "Image_ReNameDown", nSortType = AUCTION_ORDER_TYPE.LEFT_TIME},
["CheckBox_Bid"] = {imgUp = "Image_BidNameUp", imgDown = "Image_BidNameDown", nSortType = AUCTION_ORDER_TYPE.PRICE},
["CheckBox_Price"] = {imgUp = "Image_PriceNameUp", imgDown = "Image_PriceNameDown", nSortType = AUCTION_ORDER_TYPE.BUY_IT_NOW_PRICE},
}
},
["Bid"] =
{
Scroll="Scroll_Bid", BtnUp="Btn_BUp", BtnDown="Btn_BDown", Box="Box_BidBox", Text="Text_BidBoxName", Level="Text_BidBoxLevel", Saler="Text_BidBoxSaler", Time="Text_BidBoxRemainTime",
aBidText={"Handle_BidBidMoney", "Text_BidMyBid"},
aBuyText={"Handle_BBidMoneyU", "Text_BUnitPrice"},
tCheck =
{
["CheckBox_BName"] = {imgUp = "Image_BNameUp", imgDown = "Image_BNameDown", nSortType = AUCTION_ORDER_TYPE.QUALITY},
["CheckBox_BLevel"] = {imgUp = "Image_BLevelUp", imgDown = "Image_BLevelDown", nSortType = AUCTION_ORDER_TYPE.LEVEL},
["CheckBox_BRemainTime"] = {imgUp = "Image_BReNameUp", imgDown = "Image_BReNameDown", nSortType = AUCTION_ORDER_TYPE.LEFT_TIME},
["CheckBox_BBid"] = {imgUp = "Image_BBidNameUp", imgDown = "Image_BBidNameDown", nSortType = AUCTION_ORDER_TYPE.PRICE},
["CheckBox_BPrice"] = {imgUp = "Image_BPriceNameUp", imgDown = "Image_BPriceNameDown", nSortType = AUCTION_ORDER_TYPE.BUY_IT_NOW_PRICE},
}
},
["Sell"] =
{
Scroll="Scroll_Auction", BtnUp="Btn_AUp", BtnDown="Btn_ADown", Box="Box_ABox", Text="Text_ABoxName", Level="Text_ABoxLevel", Saler="Text_ABoxSaler", Time="Text_ABoxRemainTime",
aBidText={"Handle_ABidMoney", "Text_AMyBid",},
aBuyText={"Handle_ABidMoneyU", "Text_AUnitPrice",},
tCheck =
{
["CheckBox_AName"] = {imgUp = "Image_ANameUp", imgDown = "Image_ANameDown", nSortType = AUCTION_ORDER_TYPE.QUALITY},
["CheckBox_ALevel"] = {imgUp = "Image_ALevelUp", imgDown = "Image_ALevelDown", nSortType = AUCTION_ORDER_TYPE.LEVEL},
["CheckBox_ARemainTime"] = {imgUp = "Image_AReNameUp", imgDown = "Image_AReNameDown", nSortType = AUCTION_ORDER_TYPE.LEFT_TIME},
["CheckBox_ABid"] = {imgUp = "Image_ABidNameUp", imgDown = "Image_ABidNameDown", nSortType = AUCTION_ORDER_TYPE.PRICE},
["CheckBox_APrice"] = {imgUp = "Image_APriceNameUp", imgDown = "Image_APriceNameDown", nSortType = AUCTION_ORDER_TYPE.BUY_IT_NOW_PRICE},
}
}
}
AH_Helper.UpdateItemListOrg = AuctionPanel.UpdateItemList
AH_Helper.SetSaleInfoOrg = AuctionPanel.SetSaleInfo
AH_Helper.FormatAuctionTimeOrg = AuctionPanel.FormatAuctionTime
AH_Helper.GetItemSellInfoOrg = AuctionPanel.GetItemSellInfo
AH_Helper.OnMouseEnterOrg = AuctionPanel.OnMouseEnter
AH_Helper.OnMouseLeaveOrg = AuctionPanel.OnMouseLeave
AH_Helper.OnFrameBreatheOrg = AuctionPanel.OnFrameBreathe
AH_Helper.OnLButtonClickOrg = AuctionPanel.OnLButtonClick
AH_Helper.OnExchangeBoxItemOrg = AuctionPanel.OnExchangeBoxItem
AH_Helper.AuctionSellOrg = AuctionPanel.AuctionSell
AH_Helper.UpdateItemPriceInfoOrg = AuctionPanel.UpdateItemPriceInfo
AH_Helper.ApplyLookupOrg = AuctionPanel.ApplyLookup
AH_Helper.OnItemLButtonClickOrg = AuctionPanel.OnItemLButtonClick
AH_Helper.OnItemLButtonDBClickOrg = AuctionPanel.OnItemLButtonDBClick
AH_Helper.OnItemMouseEnterOrg = AuctionPanel.OnItemMouseEnter
AH_Helper.OnItemMouseLeaveOrg = AuctionPanel.OnItemMouseLeave
AH_Helper.OnEditChangedOrg = AuctionPanel.OnEditChanged
AH_Helper.InitOrg = AuctionPanel.Init
--AH_Helper.ShowNoticeOrg = AuctionPanel.ShowNotice --去除免确认
AH_Helper.UpdateSaleInfoOrg = AuctionPanel.UpdateSaleInfo
AH_Helper.ExchangeBagAndAuctionItemOrg = AuctionPanel.ExchangeBagAndAuctionItem
--AH_Helper.AuctionBuyOrg = AuctionPanel.AuctionBuy
AH_Helper.OnCheckBoxCheckOrg = AuctionPanel.OnCheckBoxCheck
AH_Helper.SetItemNameOrg = AuctionPanel.SetItemName
--------------------------------------------------------
-- 系统AH函数重构
--------------------------------------------------------
local function FormatMoney(handle, bText)
local szMoney = 0
if bText then
szMoney = handle
else
szMoney = handle:GetText()
end
if not szMoney or szMoney == "" then
szMoney = 0
end
return tonumber(szMoney)
end
local function ConvertMoney(editGB, editG, editS, editC, bUnpack)
local nGoldB, nGold, nSilver, nCopper = 0, 0, 0, 0
if editGB then
if editGB.GetText then
nGoldB = tonumber(editGB:GetText()) or 0
else
nGoldB = tonumber(editGB) or 0
end
end
if editG then
if editG.GetText then
nGold = tonumber(editG:GetText()) or 0
else
nGold = tonumber(editG) or 0
end
end
if editS then
if editS.GetText then
nSilver = tonumber(editS:GetText()) or 0
else
nSilver = tonumber(editS) or 0
end
end
if editC then
if editC.GetText then
nCopper = tonumber(editC.GetText()) or 0
else
nCopper = tonumber(editC) or 0
end
end
if bUnpack then
return (nGoldB * 10000 + nGold), nSilver, nCopper
end
return PackMoney( (nGoldB * 10000 + nGold), nSilver, nCopper )
end
local function GetMoneyTextEx(tMoney, szFont)
local szText = ""
local bCheckZero = true
local nGold, nSilver, nCopper = tMoney.nGold, tMoney.nSilver, tMoney.nCopper
if nGold ~= 0 then
szText = szText.."<text>text=\""..nGold.."\""..szFont.."</text><image>path=\"UI/Image/Common/Money.UITex\" frame=0</image>"
bCheckZero = false
end
if not bCheckZero or nSilver ~= 0 then
szText = szText.."<text>text=\""..nSilver.."\""..szFont.."</text><image>path=\"UI/Image/Common/Money.UITex\" frame=2</image>"
end
szText = szText.."<text>text=\""..nCopper.."\""..szFont.."</text><image>path=\"UI/Image/Common/Money.UITex\" frame=1</image>"
return szText
end
--[[local function FormatBigMoney(nGold)
if AH_Helper.bFormatMoney then
local nLen, szGold = GetIntergerBit(nGold), tostring(nGold)
if nLen > 3 then
local a = string.sub(szGold, 0, nLen - 3)
local b = string.sub(szGold, -3)
return string.format("%s, %s", a, b)
end
return szGold
end
return nGold
end]]
function AuctionPanel.UpdateItemList(frame, szDataType, tItemInfo)
if not tItemInfo then
tItemInfo = {}
end
local INI_FILE_PATH = "UI/Config/Default/AuctionItem.ini"
local player = GetClientPlayer()
local hList, szItem = nil, nil
if szDataType == "Search" then
hList = frame:Lookup("PageSet_Totle/Page_Business/Wnd_Result2", "Handle_List")
szItem = "Handle_ItemList"
elseif szDataType == "Bid" then
hList = frame:Lookup("PageSet_Totle/Page_State/Wnd_Bid", "Handle_BidList")
szItem = "Handle_BidItemList"
elseif szDataType == "Sell" then
hList = frame:Lookup("PageSet_Totle/Page_Auction/Wnd_Auction", "Handle_AList")
szItem = "Handle_AItemList"
end
if szItem == "Handle_ItemList" or "Handle_AItemList" then
INI_FILE_PATH = "Interface/AH/AH_Helper/AH_AuctionItem.ini"
end
hList:Clear()
for k, v in pairs(tItemInfo) do
bFilterd = false
if v["Item"] then
if szDataType == "Search" then
--卖家屏蔽
if not AH_Helper.IsInBlackList(v["SellerName"]) then
--过滤已读秘籍
if AH_Helper.bFilterRecipe and v["Item"].nGenre == ITEM_GENRE.MATERIAL and v["Item"].nSub == 5 then
if not IsMystiqueRecipeRead(v["Item"]) then
local hItem = hList:AppendItemFromIni(INI_FILE_PATH, szItem)
AuctionPanel.SetSaleInfo(hItem, szDataType, v)
else
bFilterd = true
end
elseif AH_Helper.bFilterBook and v["Item"].nGenre == ITEM_GENRE.BOOK then
local nBookID, nSegmentID = GlobelRecipeID2BookID(v["Item"].nBookID)
if not GetClientPlayer().IsBookMemorized(nBookID, nSegmentID) then
local hItem = hList:AppendItemFromIni(INI_FILE_PATH, szItem)
AuctionPanel.SetSaleInfo(hItem, szDataType, v)
else
bFilterd = true
end
else
local hItem = hList:AppendItemFromIni(INI_FILE_PATH, szItem)
AuctionPanel.SetSaleInfo(hItem, szDataType, v)
end
end
else
local hItem = hList:AppendItemFromIni(INI_FILE_PATH, szItem)
AuctionPanel.SetSaleInfo(hItem, szDataType, v)
end
else
Trace("KLUA[ERROR] ui/Config/Default/AuctionPanel.lua UpdateItemList item is nil!!\n")
end
end
AuctionPanel.OnUpdateItemList(hList, szDataType, true)
AuctionPanel.UpdateItemPriceInfo(hList, szDataType)
AuctionPanel.UpdateSelectedInfo(frame, szDataType)
local hWnd = hList:GetParent():GetParent()
AuctionPanel.OnItemDataInfoUpdate(hWnd, szDataType)
--历史记录
if szDataType == "Search" then
local hEdit = AH_Helper.GetSearchEdit(frame)
local szKeyName = hEdit:GetText()
szKeyName = StringReplaceW(szKeyName, " ", "")
if not AH_Helper.IsInHistory(szKeyName) and szKeyName ~= L("STR_HELPER_ITEMNAME") and szKeyName ~= "" then
AH_Helper.AddHistory(szKeyName)
end
end
end
function AuctionPanel.SetSaleInfo(hItem, szDataType, tItemData)
local player = GetClientPlayer()
local tInfo = tItemWidgetInfo[szDataType]
local item = tItemData["Item"]
local nIconID = Table_GetItemIconID(item.nUiId)
local hBox = hItem:Lookup(tInfo.Box)
local hTextName = hItem:Lookup(tInfo.Text)
local hTextSaler = hItem:Lookup(tInfo.Saler)
hItem.nItemID = item.dwID --Fix Bug:日月明尊
hItem.nUiId = item.nUiId
hItem.nGenre = item.nGenre --修复无法购买书籍
hItem.nSaleID = tItemData["ID"]
hItem.nCRC = tItemData["CRC"]
hItem.szItemName = GetItemNameByItem(item)
hItem.szBidderName = tItemData["BidderName"] or ""
hItem.szSellerName = tItemData["SellerName"]
hItem.tBidPrice = tItemData["Price"]
hItem.tBuyPrice = tItemData["BuyItNowPrice"]
hItem.nQuality = item.nQuality
hItem.nVersion = item.nVersion
hItem.dwTabType = item.dwTabType
hItem.dwIndex = item.dwIndex
if MoneyOptCmp(hItem.tBuyPrice, 0) == 0 then
hItem.tBuyPrice = NO_BID_PRICE
end
local nCount = 1
if item.nGenre == ITEM_GENRE.EQUIPMENT then
if item.nSub == EQUIPMENT_SUB.ARROW then --远程武器
nCount = item.nCurrentDurability
else
if AH_Helper.bShowQualityLevel then
hBox:SetOverText(1, item.nLevel)
end
end
elseif item.bCanStack then
nCount = item.nStackNum
end
if nCount == 1 then
hBox:SetOverText(0, "")
else
hBox:SetOverText(0, nCount)
end
hItem.nCount = nCount
--附加TIP所需数据到box
hBox.nItemID = item.dwID
hBox.tBidPrice = tItemData["Price"]
hBox.tBuyPrice = tItemData["BuyItNowPrice"]
hBox.nCount = nCount
--价格记录
if szDataType == "Search" then
local szKey = (item.nGenre == ITEM_GENRE.BOOK) and hItem.szItemName or item.nUiId
hItem.szKey = szKey
if AH_Helper.tItemPrice[szKey] == nil or AH_Helper.tItemPrice[szKey][2] ~= AH_Helper.nVersion then
AH_Helper.tItemPrice[szKey] = {NO_BID_PRICE, AH_Helper.nVersion}
end
if MoneyOptCmp(hItem.tBuyPrice, NO_BID_PRICE) ~= 0 then
local tBuyPrice = MoneyOptDiv(hItem.tBuyPrice, hItem.nCount)
--最低一口价
if MoneyOptCmp(AH_Helper.tItemPrice[szKey][1], tBuyPrice) == 1 then
AH_Helper.tItemPrice[szKey][1] = tBuyPrice
--[[if bAutoSearch then
local szMoney = GetMoneyText((tBuyPrice), "font=10")
local szColor = GetItemFontColorByQuality(item.nQuality, true)
local szItem = MakeItemInfoLink(string.format("[%s]", hItem.szItemName), string.format("font=10 %s", szColor), item.nVersion, item.dwTabType, item.dwIndex)
AH_Library.Message({szItem, L("STR_HELPER_PRICE3"), szMoney}, "MONEY")
end]]
end
-- 五彩石最低一口价
if item.nGenre == ITEM_GENRE.COLOR_DIAMOND then
local nLevel = item.nDetail
if AH_Helper.tCDiamondPrice[nLevel] == nil or AH_Helper.tCDiamondPrice[nLevel][2] ~= AH_Helper.nVersion then
AH_Helper.tCDiamondPrice[nLevel] = {NO_BID_PRICE, AH_Helper.nVersion}
end
if MoneyOptCmp(AH_Helper.tCDiamondPrice[nLevel][1], tBuyPrice) == 1 then
AH_Helper.tCDiamondPrice[nLevel][1] = tBuyPrice
end
end
end
end
hTextName:SetText(hItem.szItemName)
hTextName:SetFontColor(GetItemFontColorByQuality(item.nQuality, false))
hBox:SetObject(UI_OBJECT_ITEM_INFO, item.nVersion, item.dwTabType, item.dwIndex)
hBox:SetObjectIcon(nIconID)
UpdateItemBoxExtend(hBox, item.nGenre, item.nQuality, item.nStrengthLevel)
hBox:SetOverTextPosition(0, ITEM_POSITION.RIGHT_BOTTOM)
hBox:SetOverTextFontScheme(0, 15)
hBox:SetOverTextPosition(1, ITEM_POSITION.LEFT_TOP)
hBox:SetOverTextFontScheme(1, 16)
hItem:Lookup(tInfo.Level):SetText(item.GetRequireLevel())
if szDataType == "Sell" then
if hItem.szBidderName == "" then
hTextSaler:SetText(L("STR_HELPER_NOBODY"))
hTextSaler:SetFontColor(255, 0, 0)
else
hTextSaler:SetText(hItem.szBidderName)
hTextSaler:SetFontColor(0, 200, 0)
end
else
hTextSaler:SetText(tItemData["SellerName"])
end
--[[local nGold, nSliver, nCopper = UnpackMoney(hItem.tBidPrice)
hItem:Lookup(tInfo.aBidText[1]):SetText(nGold)
hItem:Lookup(tInfo.aBidText[2]):SetText(nSliver)
hItem:Lookup(tInfo.aBidText[3]):SetText(nCopper)]]
local smoney = AH_Helper.bExVersion and GetMoneyTextEx(hItem.tBidPrice, "font=212") or GetMoneyText(hItem.tBidPrice, "font=212", "all3", nil, 18)
local hMoney = hItem:Lookup(tInfo.aBidText[1])
hMoney:Clear()
hMoney:AppendItemFromString(smoney)
hMoney:FormatAllItemPos()
if MoneyOptCmp(hItem.tBuyPrice, NO_BID_PRICE) ~= 0 then
--[[nGold, nSliver, nCopper = UnpackMoney(hItem.tBuyPrice)
hItem:Lookup(tInfo.aBuyText[1]):SetText(nGold)
hItem:Lookup(tInfo.aBuyText[2]):SetText(nSliver)
hItem:Lookup(tInfo.aBuyText[3]):SetText(nCopper)]]
smoney = AH_Helper.bExVersion and GetMoneyTextEx(hItem.tBuyPrice, "font=212") or GetMoneyText(hItem.tBuyPrice, "font=212", "all3", nil, 18)
hMoney = hItem:Lookup(tInfo.aBuyText[1])
hMoney:Clear()
hMoney:AppendItemFromString(smoney)
hMoney:FormatAllItemPos()
else
--[[hItem:Lookup(tInfo.aBuyImg[1]):Hide()
hItem:Lookup(tInfo.aBuyImg[2]):Hide()
hItem:Lookup(tInfo.aBuyImg[3]):Hide()
hItem:Lookup(tInfo.aBuyText[4]):Hide()]]
hItem:Lookup(tInfo.aBuyText[1]):Hide()
hItem:Lookup(tInfo.aBuyText[2]):Hide()
end
--竞拍时间显示秒
local nLeftTime = tItemData["LeftTime"]
local hTextTime = hItem:Lookup(tInfo.Time)
local szTime = AuctionPanel.FormatAuctionTime(nLeftTime)
if nLeftTime <= 120 and AH_Helper.bRealTime then
hTextTime:SetText(L("STR_HELPER_SECOND", nLeftTime))
hTextTime:SetFontColor(unpack(AH_Helper.tRealTimeColor))
else
hTextTime:SetText(szTime)
end
--记录拍卖剩余时间
if not tBidTime[hItem.nSaleID] or tBidTime[hItem.nSaleID].nVersion ~= AH_Helper.nVersion then
tBidTime[hItem.nSaleID] = {nTime = nLeftTime * 1000 + GetTickCount(), nVersion = AH_Helper.nVersion}
end
hItem:Show()
end
function AuctionPanel.FormatAuctionTime(nTime)
if not AH_Helper.bRealTime and nTime < 600 then
return g_tAuctionString.STR_AUCTION_NEAR_DUE
end
local szText = ""
local nH, nM, nS = GetTimeToHourMinuteSecond(nTime, false)
if nH and nH > 0 then
if (nM and nM > 0) or (nS and nS > 0) then
nH = nH + 1
end
szText = szText..nH..g_tStrings.STR_BUFF_H_TIME_H
else
nM = nM or 0
nS = nS or 0
if nM == 0 and nS == 0 then
return szText
end
if nS > 0 then
nM = nM + 1
end
if nM >= 60 then
szText = szText..math.ceil(nM / 60)..g_tStrings.STR_BUFF_H_TIME_H
else
szText = szText..nM..g_tStrings.STR_BUFF_H_TIME_M
end
end
return szText
end
--无记录时调整寄售时间
function AuctionPanel.UpdateSaleInfo(frame, bDefault)
AH_Helper.UpdateSaleInfoOrg(frame, bDefault)
if bDefault then
local hWndSale = frame:Lookup("PageSet_Totle/Page_Auction/Wnd_Sale")
local handle = hWndSale:Lookup("", "")
local box = handle:Lookup("Box_Item")
local textTime = handle:Lookup("Text_Time")
local textItemName = handle:Lookup("Text_ItemName")
if not box:IsEmpty() then
local szItemName = textItemName:GetText()
if not AH_Helper.tItemPrice[szItemName] then
local szText = textTime:GetText()
if szText ~= AH_Helper.szDefaultTime then
textTime:SetText(AH_Helper.szDefaultTime)
end
end
end
end
end
function AuctionPanel.GetItemSellInfo(szItemName)
local frame = Station.Lookup("Normal/AuctionPanel")
local szText = frame:Lookup("PageSet_Totle/Page_Auction/Wnd_Sale", "Text_ItemName"):GetText()
local box = frame:Lookup("PageSet_Totle/Page_Auction/Wnd_Sale", "Box_Item")
local item = GetPlayerItem(GetClientPlayer(), box.dwBox, box.dwX)
local szKey = (szItemName == L("STR_HELPER_BOOK")) and szText or item.nUiId --书籍名字转化
if AH_Helper.szDefaultValue == "Btn_Min" then
local function GetSellInfo(szName, tPrice)
local u = {szName = szName, tBidPrice = tPrice[1], tBuyPrice = tPrice[1], szTime = AH_Helper.szDefaultTime}
if AH_Helper.bLowestPrices then
if AH_Helper.bPricePercentage then
u.tBidPrice = MoneyOptMult(u.tBidPrice, AH_Helper.nPricePercentage)
u.tBuyPrice = MoneyOptMult(u.tBuyPrice, AH_Helper.nPricePercentage)
else
--单价判断,防止差价溢出
if MoneyOptCmp(u.tBidPrice, AH_Helper.nDefaultPrices) == 1 then
u.tBidPrice = MoneyOptSub(u.tBidPrice, AH_Helper.nDefaultPrices)
end
if MoneyOptCmp(u.tBuyPrice, AH_Helper.nDefaultPrices) == 1 then
u.tBuyPrice = MoneyOptSub(u.tBuyPrice, AH_Helper.nDefaultPrices)
end
end
end
return u
end
if tTempSellPrice[szKey] then
AH_Library.Message(L("STR_HELPER_LOWPRICE"))
local tPrice = {tTempSellPrice[szKey]}
return GetSellInfo(szKey, tPrice)
else
for k, v in pairs(AH_Helper.tItemPrice) do
if szKey == k and MoneyOptCmp(v[1], NO_BID_PRICE) ~= 0 then
AH_Library.Message(L("STR_HELPER_LOWPRICE"))
if type(szKey) == "string" then
return GetSellInfo(szKey, v)
else
return GetSellInfo(szItemName, v)
end
end
end
end
if item.nGenre == ITEM_GENRE.COLOR_DIAMOND then
local tPrice = AH_Helper.tCDiamondPrice[item.nDetail]
if tPrice and MoneyOptCmp(tPrice[1], NO_BID_PRICE) ~= 0 then
AH_Library.Message(L("STR_HELPER_CDIAMONDPRICE"))
if type(szKey) == "string" then
return GetSellInfo(szKey, tPrice)
else
return GetSellInfo(szItemName, tPrice)
end
end
end
else
for k, v in pairs(AuctionPanel.tItemSellInfoCache) do
if v.szName == szItemName then
AH_Library.Message(L("STR_HELPER_SYSTEMPRICE"))
return v
end
end
end
AH_Library.Message(L("STR_HELPER_NOITEMPRICE"))
return nil
end
function AuctionPanel.OnMouseEnter()
local szName = this:GetName()
if szName == "Btn_Sale" then
AH_Library.OutputTip(L("STR_HELPER_TIP1"))
elseif szName == "Btn_History" then
AH_Library.OutputTip(L("STR_HELPER_TIP2"))
end
end
function AuctionPanel.OnMouseLeave()
local szName = this:GetName()
if szName == "Btn_Sale" then
HideTip()
elseif szName == "Btn_History" then
HideTip()
end
end
function AuctionPanel.OnFrameBreathe()
AH_Helper.OnFrameBreatheOrg()
AH_Helper.OnBreathe()
end
function AuctionPanel.OnLButtonClick()
local szName = this:GetName()
if szName == "Btn_Search" then
local hEdit = AH_Helper.GetSearchEdit()
local szText = hEdit:GetText()
szText = string.gsub(szText, "^%s*(.-)%s*$", "%1")
szText = string.gsub(szText, "[%[%]]", "")
hEdit:SetText(szText)
--bAutoSearch = false
szSellerSearch = ""
elseif szName == "Btn_SearchDefault" then
szSellerSearch = ""
end
return AH_Helper.OnLButtonClickOrg()
end
function AuctionPanel.OnExchangeBoxItem(boxItem, boxDsc, nHandCount, bHand)
if boxDsc == AH_Helper.boxDsc and not boxItem:IsEmpty() then
local frame = Station.Lookup("Normal/AuctionPanel")
if AH_Helper.bDBCtrlSell then
AH_Helper.AuctionAutoSell(frame)
else
return AH_Helper.AuctionSellOrg(frame)
end
else
AH_Helper.OnExchangeBoxItemOrg(boxItem, boxDsc, nHandCount, bHand)
AH_Helper.boxDsc = boxDsc
RemoveUILockItem("Auction")
end
end
function AuctionPanel.OnEditChanged()
local szName = this:GetName()
if szName == "Edit_ItemName" and AH_Helper.bAutoSearch then
local hFocus = Station.GetFocusWindow()
if hFocus then
local szName = hFocus:GetName()
if this:GetTextLength() > 0 and szName == "BigBagPanel" then
--bAutoSearch = true
AH_Helper.UpdateList(this:GetText(), "", true)
end
end
else
return AH_Helper.OnEditChangedOrg()
end
end
function AuctionPanel.AuctionSell(frame)
if IsShiftKeyDown() then
--[[if not AH_Helper.bSellNotice then
local tMsg =
{
szName = "AuctionSell",
szMessage = L("STR_HELPER_MESSAGE2"),
{szOption = g_tStrings.STR_HOTKEY_SURE, fnAction = function() AH_Helper.AuctionAutoSell(frame) end, },
{szOption = g_tStrings.STR_HOTKEY_CANCEL, },
}
MessageBox(tMsg)
else
AH_Helper.AuctionAutoSell(frame)
end]]
AH_Helper.AuctionAutoSell(frame)
elseif IsAltKeyDown() then
--[[if not AH_Helper.bSellNotice then
local tMsg =
{
szName = "AuctionSell2",
szMessage = L("STR_HELPER_MESSAGE2"),
{szOption = g_tStrings.STR_HOTKEY_SURE, fnAction = function() AH_Helper.AuctionSimilarAutoSell(frame) end, },
{szOption = g_tStrings.STR_HOTKEY_CANCEL, },
}
MessageBox(tMsg)
else
AH_Helper.AuctionSimilarAutoSell(frame)
end]]
AH_Helper.AuctionSimilarAutoSell(frame)
else
return AH_Helper.AuctionSellOrg(frame)
end
end
function AuctionPanel.UpdateItemPriceInfo(hList,szDataType)
if szDataType == "Search" then
AH_Helper.UpdatePriceInfo(hList, szDataType)
local frame = Station.Lookup("Normal/AuctionPanel")
local page = frame:Lookup("PageSet_Totle/Page_Business")
local hWndResult = page:Lookup("Wnd_Result2")
local btn = hWndResult:Lookup("Btn_Next")
if bFilterd then
if btn:IsEnabled() then
OutputMessage("MSG_ANNOUNCE_YELLOW", L("STR_HELPER_ALERT1"))
else
OutputMessage("MSG_ANNOUNCE_YELLOW", L("STR_HELPER_ALERT2"))
end
end
else
return AH_Helper.UpdateItemPriceInfoOrg(hList,szDataType)
end
end
function AuctionPanel.ApplyLookup(frame, szType, nSortType, szKey, nStart, bDesc, szSellerName)
tItemDataInfo[szType].nStart = nStart
if szType == "Search" and nStart == 1 then
AH_Helper.nVersion = GetCurrentTime()
end
if szSellerSearch ~= "" then
szSellerName = szSellerSearch
end
return AH_Helper.ApplyLookupOrg(frame, szType, nSortType, szKey, nStart, bDesc, szSellerName)
end
--[[function AuctionPanel.AuctionBuy(hItem, szDataType)
if not AH_Helper.bGuard then
return AH_Helper.AuctionBuyOrg(hItem, szDataType)
end
local szKey = (hItem.nGenre == ITEM_GENRE.BOOK) and hItem.szItemName or hItem.nUiId
local lowestBuyPrice = MoneyOptMult(AH_Helper.tItemPrice[szKey][1], hItem.nCount)
local cmpPrice = MoneyOptMult(lowestBuyPrice, AH_Helper.nMultiple)
if MoneyOptCmp(hItem.tBuyPrice, cmpPrice) == 1 then
local fun = function()
if hItem:IsValid() then
FireEvent("BUY_AUCTION_ITEM")
local AuctionClient = GetAuctionClient()
local tBuyPrice = hItem.tBuyPrice
AuctionClient.Bid(AuctionPanel.dwTargetID, hItem.nSaleID, hItem.nItemID, hItem.nCRC, tBuyPrice.nGold, tBuyPrice.nSilver, tBuyPrice.nCopper)
PlaySound(SOUND.UI_SOUND, g_sound.Trade)
AH_Helper.UpdateList()
end
end
local szContent = FormatString(L("STR_HELPER_GUARDTIP"), hItem.szItemName, AH_Helper.nMultiple)
--local szContent = "<text>text="..EncodeComponentsString(L("STR_HELPER_GUARDTIP")).." font=159 </text>"
return AuctionPanel.ShowNotice(szContent, true, fun, true, true)
else
return AH_Helper.AuctionBuyOrg(hItem, szDataType)
end
end]]
--修复搜索卖家后寄卖页无物品显示的问题
function AuctionPanel.OnCheckBoxCheck()
szSellerSearch = ""
return AH_Helper.OnCheckBoxCheckOrg()
end
-- 修复搜索页没有激活不能搜索的问题
function AuctionPanel.SetItemName(...)
local hPageSet = Station.Lookup("Normal/AuctionPanel/PageSet_Totle")
if hPageSet:GetActivePage():GetName() ~= "Page_Business" then
hPageSet:ActivePage("Page_Business")
end
return AH_Helper.SetItemNameOrg(...)
end
--[[function AuctionPanel.ShowNotice(szNotice, bSure, fun, bCancel, bText)
if AH_Helper.bNoAllPrompt then
fun()
else
AH_Helper.ShowNoticeOrg(szNotice, bSure, fun, bCancel, bText)
end
end]]
function AuctionPanel.OnItemLButtonDBClick()
local szName = this:GetName()
if szName == "Handle_ItemList" and AH_Helper.bDBClickFastBuy then
if MoneyOptCmp(this.tBuyPrice, NO_BID_PRICE) ~= 0 then
AuctionPanel.AuctionBuy(this, "Search")
end
elseif szName == "Handle_AItemList" and AH_Helper.bDBClickFastCancel then
AuctionPanel.AuctionCancel(this)
else
return AH_Helper.OnItemLButtonDBClickOrg()
end
end
function AuctionPanel.OnItemLButtonClick()
local szName = this:GetName()
if szName == "Handle_ItemList" then
AuctionPanel.Selected(this)
AuctionPanel.UpdateSelectedInfo(this:GetRoot(), "Search", true)
if AH_Helper.bFastBid and IsShiftKeyDown() and IsCtrlKeyDown() then
AuctionPanel.AuctionBid(this)
elseif AH_Helper.bFastBuy and IsAltKeyDown() and IsCtrlKeyDown() then
if MoneyOptCmp(this.tBuyPrice, NO_BID_PRICE) ~= 0 then
AuctionPanel.AuctionBuy(this, "Search")
end
end
elseif szName == "Handle_AItemList" then
AuctionPanel.Selected(this)
AuctionPanel.UpdateSelectedInfo(this:GetRoot(), "Sell", true)
if AH_Helper.bFastCancel and IsAltKeyDown() and IsCtrlKeyDown() then
AuctionPanel.AuctionCancel(this)
end
else
return AH_Helper.OnItemLButtonClickOrg()
end
end
function AuctionPanel.OnItemMouseEnter()
local szName = this:GetName()
if szName == "Box_Box" then
if not this:IsEmpty() then
if _G["AH_Tip_Loaded"] then
AH_Tip.szItemTip = AH_Helper.GetItemTip(this)
end
local x, y = this:GetAbsPos()
local w, h = this:GetSize()
OutputItemTip(UI_OBJECT_ITEM_ONLY_ID, this.nItemID, nil, nil, {x, y, w, h})
end
elseif szName == "Handle_ItemList" then
this.bOver = true
AuctionPanel.UpdateBgStatus(this)
elseif szName == "Handle_AItemList" then
this.bOver = true
AuctionPanel.UpdateBgStatus(this)
else
return AH_Helper.OnItemMouseEnterOrg()
end
end
function AuctionPanel.OnItemMouseLeave()
local szName = this:GetName()
if szName == "Box_Box" then
HideTip()
if _G["AH_Tip_Loaded"] then
AH_Tip.szItemTip = nil
end
else
return AH_Helper.OnItemMouseLeaveOrg()
end
end
function AuctionPanel.OnItemRButtonClick()
local szName = this:GetName()
if szName == "Box_Item" then
if not this:IsEmpty() then
RemoveUILockItem("Auction")
AuctionPanel.ClearBox(this)
AuctionPanel.UpdateSaleInfo(this:GetRoot(), true)
end
elseif szName == "Handle_ItemList" then
AuctionPanel.Selected(this)
local hItem = this
local menu = {
{szOption = L("STR_HELPER_SETSELLPRICE"), fnAction = function() AH_Helper.SetTempSellPrice(hItem) end,},
{bDevide = true},
{szOption = L("STR_HELPER_SEARCHALL"), fnAction = function() --[[bAutoSearch = false]] AH_Helper.UpdateList(hItem.szItemName) end,},
{bDevide = true},
{szOption = L("STR_HELPER_SEARCHSELLER", hItem.szSellerName), fnAction = function() AH_Helper.UpdateList(nil, nil, false, hItem.szSellerName) end,},
{szOption = L("STR_HELPER_CONTACTSELLER", hItem.szSellerName), fnAction = function() EditBox_TalkToSomebody(hItem.szSellerName) end,},
{szOption = L("STR_HELPER_ADDSELLER", hItem.szSellerName), fnAction = function() AH_Helper.AddSeller(hItem.szSellerName) end,},
{szOption = L("STR_HELPER_SHIELDEDSELLER", hItem.szSellerName), fnAction = function() AH_Helper.AddBlackList(hItem.szSellerName) AH_Helper.UpdateList() end,},
{bDevide = true},
{szOption = L("STR_HELPER_ADDTOFAVORITES"), fnAction = function() AH_Helper.AddFavorite(hItem.szItemName) end,},
}
local m = AH_Helper.GetPrediction(this)
if m then
table.insert(menu, m)
end
PopupMenu(menu)
end
end
function AuctionPanel.ExchangeBagAndAuctionItem(boxBag)
if not boxBag then
return
end
if AuctionPanel.IsOpened() then
local frame = Station.Lookup("Normal/AuctionPanel")
local hPageSet = frame:Lookup("PageSet_Totle")
local page = frame:Lookup("PageSet_Totle/Page_Auction")
local hWnd = page:Lookup("Wnd_Sale")
local box = hWnd:Lookup("", "Box_Item")
if hPageSet:GetActivePage():GetName() ~= "Page_Auction" then
RemoveUILockItem("Auction")
AuctionPanel.ClearBox(box)
AuctionPanel.UpdateSaleInfo(frame, true)
hPageSet:ActivePage("Page_Auction")
end
if page and page:IsVisible() and hWnd and hWnd:IsVisible() then
AuctionPanel.OnExchangeBoxItem(box, boxBag)
end
end
end
function AuctionPanel.Init(frame)
AH_Helper.InitOrg(frame)
--默认单价
local hWndRes = frame:Lookup("PageSet_Totle/Page_Business/Wnd_Result2")
local hCheckPervalue = hWndRes:Lookup("CheckBox_PerValue")
local hCheckPrice = hWndRes:Lookup("CheckBox_Price")
hCheckPervalue:Check(true)
AuctionPanel.OnSortStateUpdate(hCheckPrice)
if hCheckPrice:Lookup("", "Image_PriceNameDown"):IsVisible() then
AuctionPanel.OnSortStateUpdate(hCheckPrice)
end
AH_Helper.AddWidget(frame)
AH_Helper.SetSellPriceType()
tTempSellPrice = {}
end
--------------------------------------------------------
-- 插件AH函数
--------------------------------------------------------
--显示即时剩余竞拍时间
function AH_Helper.UpdateAllBidItemTime(frame)
local tInfo = tItemWidgetInfo["Search"]
local hList = frame:Lookup("PageSet_Totle/Page_Business/Wnd_Result2", "Handle_List")
local nCount = hList:GetItemCount()
for i = 0, nCount - 1, 1 do
local hItem = hList:Lookup(i)
local hTextTime = hItem:Lookup(tInfo.Time)
if tBidTime[hItem.nSaleID] then
local nLeftTime = math.max(0, math.ceil((tBidTime[hItem.nSaleID].nTime - GetTickCount()) / 1000))
local szTime = AuctionPanel.FormatAuctionTime(nLeftTime)
if nLeftTime <= 120 then
if nLeftTime > 0 then
hTextTime:SetText(L("STR_HELPER_SECOND", nLeftTime))
else
hTextTime:SetText(L("STR_HELPER_SETTLEMENT"))
end
hTextTime:SetFontColor(255, 0, 0)
else
hTextTime:SetText(szTime)
end
end
end
end
function AH_Helper.UpdatePriceInfo(hList, szDataType)
local tInfo = tItemWidgetInfo[szDataType]
local bUnitPrice = AH_Helper.CheckUnitPrice(hList)
local nCount = hList:GetItemCount()
local player = GetClientPlayer()
for i = 0, nCount - 1, 1 do