-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMobileBank.lua
More file actions
3110 lines (2714 loc) · 108 KB
/
MobileBank.lua
File metadata and controls
3110 lines (2714 loc) · 108 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
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
<<<<<<< HEAD
-- MobileBank Extended v1.4g
=======
-- MobileBank Extended v1.2
>>>>>>> origin/master
----------------------------
-- @farangkao
----------------------------
-- ZeroBane Studio Testing Setup
if ESOAddonDev then
print("We are running inside ZeroBrane Studio Environment")
ESOAddonDev.ShowCreateControl = true
ESOAddonDev:GetXML([[MobileBank\MobileBank.xml]])
-- Fake creation of Elements because XML Controls for Virtual Sub-Elements not working yet...
for i=1,11,1 do
WINDOW_MANAGER:CreateControl("MBUI_Row"..i.."ButtonIcon",MBUI,CT_CONTROL)
WINDOW_MANAGER:CreateControl("MBUI_Row"..i.."ButtonStackCount",MBUI,CT_CONTROL)
WINDOW_MANAGER:CreateControl("MBUI_Row"..i.."Name",MBUI,CT_CONTROL)
WINDOW_MANAGER:CreateControl("MBUI_Row"..i.."StatValue",MBUI,CT_CONTROL)
WINDOW_MANAGER:CreateControl("MBUI_Row"..i.."SellPrice",MBUI,CT_CONTROL)
end
<<<<<<< HEAD
for i=1,8 do
_G["MBUI_ContainerTitleInventButton" .. i] = {
SetNormalFontColor = function() end,
SetParent = function() end,
SetFont = function() end,
SetDimensions = function() end,
SetAnchor = function() end,
SetMouseOverFontColor = function() end,
SetHandler = function() end,
SetHidden = function() end,
GetWidth = function() return 100 end,
}
end
=======
>>>>>>> origin/master
MBUI_ContainerTitleSwitchAll.SetState = function (self,state) end
MBUI_ContainerTitleSwitchInv.SetState = function (self,state) end
MBUI_ContainerTitleSwitchBank.SetState = function (self,state) end
MBUI_ContainerTitleSwitchGuild.SetState = function (self,state) end
MBUI_ContainerTitleSwitchRecipes.SetState = function (self,state) end
MBUI_ContainerTitleSwitchLoot.SetState = function (self,state) end
MBUI_ContainerTitleName.SetState = function (self,state) end
<<<<<<< HEAD
MBUI_ContainerTitleToggleEquipped.SetState = function(self,state) end
ZO_CurrencyControl_FormatCurrency = function (test) return "currency" end
MBUI_ContainerTitleFilterAll.SetState = function(self,state) end
MBUI_ContainerTitleFilterSubFilter1.SetState = function(self,state) end
ItemTooltip = {}
ItemTooltip.SetBagItem = 0
=======
ZO_CurrencyControl_FormatCurrency = function (test) return "currency" end
>>>>>>> origin/master
end
--------------------------------
local LAM = {}
MB = {}
<<<<<<< HEAD
MB.version="1.4g"
=======
MB.version="1.2"
>>>>>>> origin/master
MB.dataDefaultItems = {
Guilds={},
Chars={}
}
for i=1,GetNumGuilds() do
MB.dataDefaultItems.Guilds[GetGuildName(i)]={}
end
MB.dataDefaultParams = {
MBUI_Menu = {10,10},
MBUI_Container = {500,120},
hidden = true, -- With new Key and Options menu not necessairy to show Menu anymore.
}
MB.dataDefaultGlobal = {
InventoryToolTips = true, -- With new Key and Options menu not necessairy to show Menu anymore.
ShowEquipped = true,
SelectedAccount = "",
IgnoreGuild1 = true,
IgnoreGuild2 = true,
IgnoreGuild3 = true,
IgnoreGuild4 = true,
IgnoreGuild5 = true,
IgnoreGuildIngredients1 = true,
IgnoreGuildIngredients2 = true,
IgnoreGuildIngredients3 = true,
IgnoreGuildIngredients4 = true,
IgnoreGuildIngredients5 = true
}
MB.UI_Movable=false
MB.AddonReady=false
MB.TempData={}
MB.GCountOnUpdateTimer=0
<<<<<<< HEAD
MB.Debug=false
=======
MB.GuildBankIdToPrepare=1
MB.Debug=true
>>>>>>> origin/master
MB.PreviousButtonClicked=nil
MB.LastButtonClicked=nil
MB.CharsName=nil
MB.GuildsName=nil
MB.FilterChildrens=nil
MB.CurrentFilterType="All"
MB.CurrentSubFilter="1"
MB.LastCommandUI=nil
MB.LastIdToPrepareInvent=1
MB.LastIdToPrepareGuild=1
MB.CursorWasActive=false
MB.Label="Bank"
MB.SearchText=""
MB.Loot = {}
MB.thisCharName=GetUnitName("player")
<<<<<<< HEAD
MB.thisAcocuntName=GetDisplayName()
=======
>>>>>>> origin/master
MB.CurrentChar=MB.thisCharName
local function debug(text)
if MB.Debug then
d(text)
end
end
function MB.OnLoad(eventCode, addOnName)
if (addOnName ~= "MobileBank" ) then return end
--добавляем команду
SLASH_COMMANDS["/mb"] = MB.commandHandler
--Регистрация эвентов
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_OPEN_BANK, MB.PL_Opened)
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_CLOSE_BANK, MB.PL_Closed)
-- EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_OPEN_GUILD_BANK, MB.GB_Opened)
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_GUILD_BANK_ITEMS_READY, MB.GB_Ready)
-- Registering Events
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_LOOT_RECEIVED, MB.LootRecieved)
<<<<<<< HEAD
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, MB.SingleSlotUpdate)
=======
>>>>>>> origin/master
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_CLOSE_BANK, MB.SavePlayerInvent)
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_CLOSE_STORE, MB.SavePlayerInvent)
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_MONEY_UPDATE , MB.SavePlayerInvent)
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_CLOSE_GUILD_BANK, MB.SavePlayerInvent)
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_END_CRAFTING_STATION_INTERACT, MB.SavePlayerInvent)
EVENT_MANAGER:RegisterForEvent("MobileBank", EVENT_MAIL_CLOSE_MAILBOX , MB.SavePlayerInvent)
--Загрузка сохраненных переменных
MB.items= ZO_SavedVars:NewAccountWide( "MB_SavedVars" , 3, "Items" , MB.dataDefaultItems, nil )
-- New for Gold Tracking
<<<<<<< HEAD
MB.gold = ZO_SavedVars:NewAccountWide( "MB_SavedVars", 3, "Gold", MB.dataDefaultItems, nil )
-- New for Aliases
MB.aliases = ZO_SavedVars:NewAccountWide( "MB_SavedVars", 3,"Aliases", MB.dataDefaultItems,nil)
MB.params= ZO_SavedVars:New( "MB_SavedVars" , 3, "Params" , MB.dataDefaultParams, nil )
MB.global= ZO_SavedVars:NewAccountWide( "MB_SavedVars", 3, "Global" , MB.dataDefaultGlobal, nil )
=======
MB.gold = ZO_SavedVars:NewAccountWide("MB_SavedVars", 3, "Gold", MB.dataDefaultItems, nil )
-- New for Aliases
MB.aliases = ZO_SavedVars:NewAccountWide("MB_SavedVars", 3,"Aliases", MB.dataDefaultItems,nil)
MB.params= ZO_SavedVars:New( "MB_SavedVars" , 3, "Params" , MB.dataDefaultParams, nil )
>>>>>>> origin/master
debug("Item Version: " .. tostring(MB.items.version))
debug("API Version: " .. tostring(APIVersion))
<<<<<<< HEAD
if not MB.thisAccountName or MB.thisAccountName == "" then
if GetNumGuilds() > 0 then
MB.thisAccountName, _, _, _, _ = GetGuildMemberInfo(GetGuildId(1),GetPlayerGuildMemberIndex(GetGuildId(1)))
else
MB.thisAccountName = "@" .. GetCVar("AccountName")
end
end
if not MB.global.SelectedAccount or MB.global.SelectedAccount == "" then
MB.global.SelectedAccount = MB.thisAccountName
end
=======
>>>>>>> origin/master
MBUI_ContainerTitleName:SetState(1)
MB.items.Chars[MB.thisCharName]={}
-- New for Gold Tracking
MB.gold.Chars[MB.thisCharName]={}
-- New for Aliases
if MB.aliases.Chars[MB.thisCharName] then
-- We already have Alias entry...
if not MB.thisAccountName or MB.thisAccountName == "" then -- if empty try to get from last time...
MB.thisAccountName = MB.aliases.Chars[MB.thisCharName].Account
else
MB.aliases.Chars[MB.thisCharName].Account = MB.thisAccountName
end
else
local maxid = 0
for k,v in pairs(MB.aliases.Chars) do
if v and v["ID"] > maxid then
maxid = v["ID"]
end
end
if maxid > 0 and maxid < 8 then
maxid = maxid + 1
elseif maxid == 0 then
maxid = 1
else
debug("Problem with Max. ID for Character")
end
MB.aliases.Chars[MB.thisCharName]={
ID= maxid,
<<<<<<< HEAD
Alias = MB.thisCharName,
Account = MB.thisAccountName
=======
Alias = MB.thisCharName
>>>>>>> origin/master
}
end
for i=1,GetNumGuilds() do
local guild = GetGuildName(i)
if MB.aliases.Guilds[guild] and MB.aliases.Guilds[guild].ID then
-- We already have Alias entry...
else
local maxid = 0
for k,v in pairs(MB.aliases.Guilds) do
if v and v["ID"] and v["ID"] > maxid then
maxid = v["ID"]
end
end
if maxid > 0 and maxid < 5 then
maxid = maxid + 1
elseif maxid == 0 then
maxid = 1
else
d("Problem with Max. ID for Guild")
end
MB.aliases.Guilds[guild]={
ID= maxid,
Alias = guild
}
end
end
MB.CharsName={}
for k,v in pairs(MB.items.Chars) do
MB.CharsName[#MB.CharsName+1]=k
end
MB.GuildsName={}
for k,v in pairs(MB.items.Guilds) do
if k ~= "" then
MB.GuildsName[#MB.GuildsName+1]=k
end
end
-- Save current Player Inventory
MB.SavePlayerInvent()
--Инициализация графического интерфейся
MB_UI = WINDOW_MANAGER:GetControlByName("MBUI")
-- Создаем меню
MB.CreateMenu()
-- Создаем банк
MB.CreateBank()
MB.CreateMBSearchBox()
-- Add Settings menu via LibAddonMenu
MB.options.SetData()
<<<<<<< HEAD
MB.HookTooltips()
LAM = LibStub("LibAddonMenu-2.0")
MB.OptionsPanel = LAM:RegisterAddonPanel("MobileBankExtended", MB.options.panelData)
LAM:RegisterOptionControls("MobileBankExtended", MB.options.optionsTable)
if MB.global.ShowEquipped then
MBUI_ContainerTitleToggleEquipped:SetState(1)
else
MBUI_ContainerTitleToggleEquipped:SetState(0)
end
MBUI_ContainerTitleFilterAll:SetState(1)
MBUI_ContainerTitleFilterSubFilter1:SetState(1)
=======
LAM = LibStub("LibAddonMenu-2.0")
MB.OptionsPanel = LAM:RegisterAddonPanel("MobileBankExtended", MB.options.panelData)
LAM:RegisterOptionControls("MobileBankExtended", MB.options.optionsTable)
>>>>>>> origin/master
MB.AddonReady=true
end
function MB.CreateMenu()
MB_UI.Menu=WINDOW_MANAGER:CreateControl("MBUI_Menu",MBUI,CT_CONTROL)
MB_UI.Menu.BG = WINDOW_MANAGER:CreateControl("MBUI_Menu_BG",MBUI_Menu,CT_BACKDROP)
MB_UI.Menu.Title = WINDOW_MANAGER:CreateControl("MBUI_Menu_Title",MBUI_Menu,CT_LABEL)
MB_UI.Menu.Button={}
MB_UI.Menu.Button.Guild = WINDOW_MANAGER:CreateControl("MBUI_Menu_Button_Guild",MBUI_Menu,CT_BUTTON)
MB_UI.Menu.Button.Bank = WINDOW_MANAGER:CreateControl("MBUI_Menu_Button_Bank",MBUI_Menu,CT_BUTTON)
MB_UI.Menu.Button.Invent = WINDOW_MANAGER:CreateControl("MBUI_Menu_Button_Invent",MBUI_Menu,CT_BUTTON)
-- MB_UI.Menu.Button.Move = WINDOW_MANAGER:CreateControl("MBUI_Menu_Button_Move",MBUI_Menu,CT_BUTTON)
--Обработчики событий
-- Клик по гильдии
MB_UI.Menu.Button.Guild:SetHandler("OnClicked" , function(self)
local bool = not(MBUI_Container:IsHidden())
MB.PreviousButtonClicked=MB.LastButtonClicked
MB.LastButtonClicked="Guild"
MB.CurrentLastValue=11
MB.PrepareBankValues("Guild",1)
-- MB.FillBank(MB.CurrentLastValue,MB.BankValueTable)
MB.FilterBank(MB.CurrentLastValue,MB.CurrentFilterType,MB.SearchText)
MB.HideContainer(bool)
end )
-- Клик по банку
MB_UI.Menu.Button.Bank:SetHandler( "OnClicked" , function(self)
local bool = not(MBUI_Container:IsHidden())
MB.PreviousButtonClicked=MB.LastButtonClicked
MB.LastButtonClicked="Bank"
MB.CurrentLastValue=11
MB.PrepareBankValues("Bank")
-- MB.FillBank(MB.CurrentLastValue,MB.BankValueTable)
MB.FilterBank(MB.CurrentLastValue,MB.CurrentFilterType,MB.SearchText)
MB.HideContainer(bool)
end )
-- Клик по инвентарю
MB_UI.Menu.Button.Invent:SetHandler( "OnClicked" , function(self)
local bool = not(MBUI_Container:IsHidden())
MB.PreviousButtonClicked=MB.LastButtonClicked
MB.LastButtonClicked="Invent"
MB.CurrentLastValue=11
MB.PrepareBankValues("Invent",MB.ChangeCharacterDisplay())
-- MB.FillBank(MB.CurrentLastValue,MB.BankValueTable)
MB.FilterBank(MB.CurrentLastValue,MB.CurrentFilterType,MB.SearchText)
MB.HideContainer(bool)
end )
MBUI_Menu:SetHandler("OnMouseUp" , function(self) MB.MouseUp(self) end)
if MBUI_Container then
MBUI_Container:SetHandler("OnMouseUp" , function(self) MB.MouseUp(self) end)
else
print("ERROR MBUI_Container is empty!")
end
--Настройки меню
MB_UI.Menu:SetAnchor(TOPLEFT,MBUI,TOPLEFT,MB.params.MBUI_Menu[1],MB.params.MBUI_Menu[2])
MB_UI.Menu:SetDimensions(200,45)
MB_UI.Menu:SetMouseEnabled(true)
MB_UI.Menu:SetMovable(true)
--Фон
MB_UI.Menu.BG:SetAnchor(CENTER,MBUI_Menu,CENTER,0,0)
MB_UI.Menu.BG:SetDimensions(200,40)
MB_UI.Menu.BG:SetCenterColor(0,0,0,1)
MB_UI.Menu.BG:SetEdgeColor(0,0,0,0)
MB_UI.Menu.BG:SetAlpha(0.5)
--Заголовок
MB_UI.Menu.Title:SetAnchor(CENTER,MBUI_Menu,TOP,0,13)
MB_UI.Menu.Title:SetFont("ZoFontGame" )
MB_UI.Menu.Title:SetColor(255,255,255,1.5)
MB_UI.Menu.Title:SetText( "|cff8000Mobile Bank|" )
-- Кнопка "Гильдия"
MB_UI.Menu.Button.Guild:SetAnchor(BOTTOMLEFT,MBUI_Menu,BOTTOMLEFT,0,0)
MB_UI.Menu.Button.Guild:SetText("[Guild]")
MB_UI.Menu.Button.Guild:SetDimensions(70,25)
MB_UI.Menu.Button.Guild:SetFont("ZoFontGameBold")
MB_UI.Menu.Button.Guild:SetNormalFontColor(0,255,255,.7)
MB_UI.Menu.Button.Guild:SetMouseOverFontColor(0.8,0.4,0,1)
-- Кнопка "Банк"
MB_UI.Menu.Button.Bank:SetAnchor(BOTTOM,MBUI_Menu,BOTTOM,0,0)
MB_UI.Menu.Button.Bank:SetText("[Bank]")
MB_UI.Menu.Button.Bank:SetDimensions(70,25)
MB_UI.Menu.Button.Bank:SetFont("ZoFontGameBold")
MB_UI.Menu.Button.Bank:SetNormalFontColor(0,255,255,.7)
MB_UI.Menu.Button.Bank:SetMouseOverFontColor(0.8,0.4,0,1)
-- Кнопка "Инвентарь"
MB_UI.Menu.Button.Invent:SetAnchor(BOTTOMRIGHT,MBUI_Menu,BOTTOMRIGHT,0,0)
MB_UI.Menu.Button.Invent:SetText("[Invent]")
MB_UI.Menu.Button.Invent:SetDimensions(70,25)
MB_UI.Menu.Button.Invent:SetFont("ZoFontGameBold")
MB_UI.Menu.Button.Invent:SetNormalFontColor(0,255,255,.7)
MB_UI.Menu.Button.Invent:SetMouseOverFontColor(0.8,0.4,0,1)
end
function MB.ChangeCharacterDisplay(init,IdToPrepare)
-- we have 1 to 8 slots, they need to be reordered and compared with the Account...
-- Update Titles with Aliases
local inv1 = 0
local inv2 = 0
local orderTable = {}
local maxorder = 0
local nextXstep = 0
debug("Selected Account: " .. tostring(MB.global.SelectedAccount))
for i=1, #MB.CharsName do
local order = 0
local account = nil
if MB.aliases and MB.aliases.Chars then
for k,v in pairs(MB.aliases.Chars) do
if k == MB.CharsName[i] then
debug("Char @Account: " .. k .. " " .. tostring(v.Account))
if not v.Account or v.Account == "" or v.Account:lower() == MB.global.SelectedAccount:lower() then
if v.Order then
order = v.Order
elseif v.ID and v.ID < 9 then
order = v.ID
end
if v.Account then
account = v.Account
else
account = MB.thisAccountName
end
debug("here")
end
end
end
end
if account then -- and account ~= "" then
if order> maxorder then maxorder = order end
debug("Chars: " .. MB.CharsName[i] .. " " .. tostring(order))
orderTable[#orderTable+1] = order
end
end
-- Set all 0 to the next higher number
for i=1,#orderTable do
if orderTable[i] == 0 then
maxorder = maxorder + 1
orderTable[i] = maxorder
end
end
debug("OrderTable: " .. tostring(#orderTable))
for i,k in ipairs(orderTable) do
debug("order: " .. tostring(i) .. ". " .. tostring(k))
end
if init then
for i=1,8 do
if _G["MBUI_ContainerTitleInventButton" .. i] then
_G["MBUI_ContainerTitleInventButton"..i]:SetHidden(true)
end
end
end
local SortedOrder = {}
for k,v in pairs(orderTable) do
SortedOrder[v] = k
end
debug("Sort Order: " ..tostring(#SortedOrder))
local c=1
for k=1,8 do
if SortedOrder[k] then
local originalcharname=tostring(MB.CharsName[SortedOrder[k]])
local charname = originalcharname
debug(tostring(k) .. ". " .. charname)
-- Support for Alias Names
if MB.aliases.Chars[charname] then
local alias = MB.aliases.Chars[charname].Alias
if alias ~= "" then
charname = alias
end
end
if k < 9 then
if originalcharname == MB.CurrentChar then
inv1 = k
end
if originalcharname == GetUnitName("player") then
inv2 = k
end
if init then
if not _G["MBUI_ContainerTitleInventButton" .. k] then
WINDOW_MANAGER:CreateControl("MBUI_ContainerTitleInventButton"..k,MBUI_ContainerTitle,CT_BUTTON)
end
_G["MBUI_ContainerTitleInventButton"..k]:SetHidden(false)
_G["MBUI_ContainerTitleInventButton"..k]:SetParent(MBUI_ContainerTitleInventButtons)
_G["MBUI_ContainerTitleInventButton"..k]:SetFont("ZoFontGame" )
nextXstep=(MBUI_Container:GetWidth()/#orderTable*c)
_G["MBUI_ContainerTitleInventButton"..k]:SetDimensions(MBUI_Container:GetWidth()/#orderTable,20)
_G["MBUI_ContainerTitleInventButton"..k]:SetAnchor(TOP,MBUI_ContainerTitleInventButtons,TOPLEFT,nextXstep-_G["MBUI_ContainerTitleInventButton"..k]:GetWidth()/2,0) _G["MBUI_ContainerTitleInventButton"..k]:SetNormalFontColor(0,255,255,.7)
_G["MBUI_ContainerTitleInventButton"..k]:SetMouseOverFontColor(0.8,0.4,0,1)
_G["MBUI_ContainerTitleInventButton"..k].CharacterName = originalcharname
_G["MBUI_ContainerTitleInventButton"..k]:SetHandler( "OnClicked" , function(self)
MB.PrepareBankValues("Invent",k)
MB.SortPreparedValues()
MB.FilterBank(11,MB.CurrentFilterType,MB.SearchText)
end)
c = c+1
end
if _G["MBUI_ContainerTitleInventButton" .. k] then
if charname then
_G["MBUI_ContainerTitleInventButton"..k]:SetText("["..charname.."]")
end
if _G["MBUI_ContainerTitleInventButton".. k] then -- ZBS compatibility
if k == IdToPrepare then
_G["MBUI_ContainerTitleInventButton".. k]:SetNormalFontColor(255,255,0,1)
else
_G["MBUI_ContainerTitleInventButton".. k]:SetNormalFontColor(0,255,255,0.7)
end
end
else
debug("Not found: " .. k)
end
end
else
debug("Order not found: " .. k)
end
end
if inv1 > 0 then
return inv1
elseif inv2 > 0 then
return inv2
else
return 1
end
end
function MB.UpdateBankAliases()
-- Update Titles with Aliases
--[[
local orderTable = {}
local maxorder = 0
for i=1, #MB.CharsName do
local order = 0
if MB.aliases and MB.aliases.Chars then
for k,v in pairs(MB.aliases.Chars) do
if k == MB.CharsName[i] then
if v.Order then
order = v.Order
else
order = v.ID
end
end
end
end
if order> maxorder then maxorder = order end
orderTable[i] = order
end
-- Set all 0 to the next higher number
for i=1,#orderTable do
if orderTable[i] == 0 then
maxorder = maxorder + 1
orderTable[i] = maxorder
end
end
for i=1,#MB.CharsName do
for k=1,#orderTable do
if orderTable[k] == i then
local charname=tostring(MB.CharsName[k])
-- Support for Alias Names
if MB.aliases.Chars[charname] then
local alias = MB.aliases.Chars[charname].Alias
if alias ~= "" then
charname = alias
end
end
if k < 9 then
_G["MBUI_ContainerTitleInventButton"..k]:SetText("["..charname.."]")
end
end
end
end
--]]
MB.ChangeCharacterDisplay()
-- Update Guilds
local orderTable = {}
local maxorder = 0
for i=1, #MB.GuildsName do
local order = 0
if MB.aliases and MB.aliases.Guilds then
for k,v in pairs(MB.aliases.Guilds) do
if k == MB.GuildsName[i] then
if v.Order then
order = v.Order
else
order = v.ID
end
end
end
end
if order> maxorder then maxorder = order end
orderTable[i] = order
end
-- Set all 0 to the next higher number
for i=1,#orderTable do
if orderTable[i] == 0 then
maxorder = maxorder + 1
orderTable[i] = maxorder
end
end
for i=1,#MB.GuildsName do
for k=1,#orderTable do
if orderTable[k] == i then
local guildname=tostring(MB.GuildsName[k])
-- Support for Alias Names
if MB.aliases.Guilds[guildname] then
local alias = MB.aliases.Guilds[guildname].Alias
if alias ~= "" then
guildname = alias
end
end
<<<<<<< HEAD
=======
_G["MBUI_ContainerTitleInventButton"..k]:SetText("["..charname.."]")
end
end
end
-- Update Guilds
orderTable = {}
maxorder = 0
for i=1, #MB.GuildsName do
local order = 0
if MB.aliases and MB.aliases.Guilds then
for k,v in pairs(MB.aliases.Guilds) do
if k == MB.GuildsName[i] then
if v.Order then
order = v.Order
else
order = v.ID
end
end
end
end
if order> maxorder then maxorder = order end
orderTable[i] = order
end
-- Set all 0 to the next higher number
for i=1,#orderTable do
if orderTable[i] == 0 then
maxorder = maxorder + 1
orderTable[i] = maxorder
end
end
for i=1,#MB.GuildsName do
for k=1,#orderTable do
if orderTable[k] == i then
local guildname=tostring(MB.GuildsName[k])
-- Support for Alias Names
if MB.aliases.Chars[charname] then
local alias = MB.aliases.Guilds[guildname].Alias
if alias ~= "" then
guildname = alias
end
end
>>>>>>> origin/master
_G["MBUI_ContainerTitleGuildButton"..k]:SetText("["..guildname.."]")
end
end
end
end
function MB.CreateBank()
local OldAnchor=false
-- Настройки контейнера
MBUI_Container:SetAnchor(TOPLEFT,GuiRoot,TOPLEFT,MB.params.MBUI_Container[1],MB.params.MBUI_Container[2])
MBUI_Container:SetMovable(true)
-- Правим Слайдер
MBUI_ContainerSlider:SetValue(11)
-- Создаем кнопки для переключения между гильдбанками
local nextXstep=0
local orderTable = {}
local maxorder = 0
for i=1, #MB.GuildsName do
local order = 0
if MB.aliases and MB.aliases.Guilds then
for k,v in pairs(MB.aliases.Guilds) do
if k == MB.GuildsName[i] then
if v.Order then
order = v.Order
else
order = v.ID
end
end
end
end
if order and order> maxorder then maxorder = order end
orderTable[i] = order
end
-- Set all 0 to the next higher number
for i=1,#orderTable do
if orderTable[i] == 0 then
maxorder = maxorder + 1
orderTable[i] = maxorder
end
end
for i=1,#MB.GuildsName do
for k=1,#orderTable do
if orderTable[k] == i then
local guildname=tostring(MB.GuildsName[k])
-- Support for Alias Names
if MB.aliases.Guilds[guildname] then
local alias = MB.aliases.Guilds[guildname].Alias
if alias ~= "" then
guildname = alias
end
end
if guildname and guildname ~= "" then
WINDOW_MANAGER:CreateControl("MBUI_ContainerTitleGuildButton"..k,MBUI_ContainerTitle,CT_BUTTON)
_G["MBUI_ContainerTitleGuildButton"..k]:SetParent(MBUI_ContainerTitleGuildButtons)
_G["MBUI_ContainerTitleGuildButton"..k]:SetFont("ZoFontGame" )
nextXstep=(MBUI_Container:GetWidth()/#MB.GuildsName*k)
_G["MBUI_ContainerTitleGuildButton"..k]:SetDimensions(MBUI_Container:GetWidth()/#MB.GuildsName,20)
-- Делаем поправку на ширину самой кнопки
_G["MBUI_ContainerTitleGuildButton"..k]:SetAnchor(TOP,MBUI_ContainerTitleGuildButton,TOPLEFT,nextXstep-_G["MBUI_ContainerTitleGuildButton"..k]:GetWidth()/2,0)
_G["MBUI_ContainerTitleGuildButton"..k]:SetText("["..guildname.."]")
_G["MBUI_ContainerTitleGuildButton"..k]:SetNormalFontColor(0,255,255,.7)
_G["MBUI_ContainerTitleGuildButton"..k]:SetMouseOverFontColor(0.8,0.4,0,1)
_G["MBUI_ContainerTitleGuildButton"..k]:SetHandler( "OnClicked" , function(self)
MB.PrepareBankValues("Guild",k)
MB.SortPreparedValues()
-- MB.FillBank(11,MB.BankValueTable)
MB.FilterBank(11,MB.CurrentFilterType,MB.SearchText)
end)
end
end
end
end
MB.ChangeCharacterDisplay(true) -- Create Characters for Inventory
-- Создаем кнопки для переключения между Игроками
<<<<<<< HEAD
--[[
=======
>>>>>>> origin/master
nextXstep=0
orderTable = {}
maxorder = 0
for i=1, #MB.CharsName do
local order = 0
if MB.aliases and MB.aliases.Chars then
for k,v in pairs(MB.aliases.Chars) do
if k == MB.CharsName[i] then
if v.Order then
order = v.Order
else
order = v.ID
end
end
end
end
if order and order> maxorder then maxorder = order end
orderTable[i] = order
end
-- Set all 0 to the next higher number
for i=1,#orderTable do
if orderTable[i] == 0 then
maxorder = maxorder + 1
orderTable[i] = maxorder
end
end
-- MBUI_ContainerTitleInventButtons:SetDimensions(MBUI_Container:GetWidth(),80)
-- MBUI_ContainerTitleInventButtons:SetAnchor(TOP,MBUI_Container,TOPLEFT,0,50)
for i=1,#MB.CharsName do
for k=1,#orderTable do
if orderTable[k] == i then
<<<<<<< HEAD
if k < 9 then
local charname=tostring(MB.CharsName[k])
-- Support for Alias Names
if MB.aliases.Chars[charname] then
local alias = MB.aliases.Chars[charname].Alias
if alias ~= "" then
charname = alias
end
end
WINDOW_MANAGER:CreateControl("MBUI_ContainerTitleInventButton"..k,MBUI_ContainerTitle,CT_BUTTON)
_G["MBUI_ContainerTitleInventButton"..k]:SetParent(MBUI_ContainerTitleInventButtons)
_G["MBUI_ContainerTitleInventButton"..k]:SetFont("ZoFontGame" )
nextXstep=(MBUI_Container:GetWidth()/#MB.CharsName*i)
_G["MBUI_ContainerTitleInventButton"..k]:SetDimensions(MBUI_Container:GetWidth()/#MB.CharsName,20)
-- Делаем поправку на ширину самой кнопки
_G["MBUI_ContainerTitleInventButton"..k]:SetText("["..charname.."]")
_G["MBUI_ContainerTitleInventButton"..k]:SetAnchor(TOP,MBUI_ContainerTitleInventButtons,TOPLEFT,nextXstep-_G["MBUI_ContainerTitleInventButton"..k]:GetWidth()/2,0)
_G["MBUI_ContainerTitleInventButton"..k]:SetNormalFontColor(0,255,255,.7)
_G["MBUI_ContainerTitleInventButton"..k]:SetMouseOverFontColor(0.8,0.4,0,1)
_G["MBUI_ContainerTitleInventButton"..k]:SetHandler( "OnClicked" , function(self)
MB.PrepareBankValues("Invent",k)
MB.SortPreparedValues()
-- MB.FillBank(11,MB.BankValueTable)
MB.FilterBank(11,MB.CurrentFilterType,MB.SearchText)
end)
end
end
=======
local charname=tostring(MB.CharsName[k])
-- Support for Alias Names
if MB.aliases.Chars[charname] then
local alias = MB.aliases.Chars[charname].Alias
if alias ~= "" then
charname = alias
end
end
WINDOW_MANAGER:CreateControl("MBUI_ContainerTitleInventButton"..k,MBUI_ContainerTitle,CT_BUTTON)
_G["MBUI_ContainerTitleInventButton"..k]:SetParent(MBUI_ContainerTitleInventButtons)
_G["MBUI_ContainerTitleInventButton"..k]:SetFont("ZoFontGame" )
nextXstep=(MBUI_Container:GetWidth()/#MB.CharsName*i)
_G["MBUI_ContainerTitleInventButton"..k]:SetDimensions(MBUI_Container:GetWidth()/#MB.CharsName,20)
-- Делаем поправку на ширину самой кнопки
_G["MBUI_ContainerTitleInventButton"..k]:SetText("["..charname.."]")
_G["MBUI_ContainerTitleInventButton"..k]:SetAnchor(TOP,MBUI_ContainerTitleInventButtons,TOPLEFT,nextXstep-_G["MBUI_ContainerTitleInventButton"..k]:GetWidth()/2,0)
_G["MBUI_ContainerTitleInventButton"..k]:SetNormalFontColor(0,255,255,.7)
_G["MBUI_ContainerTitleInventButton"..k]:SetMouseOverFontColor(0.8,0.4,0,1)
_G["MBUI_ContainerTitleInventButton"..k]:SetHandler( "OnClicked" , function(self)
MB.PrepareBankValues("Invent",k)
MB.SortPreparedValues()
-- MB.FillBank(11,MB.BankValueTable)
MB.FilterBank(11,MB.CurrentFilterType,MB.SearchText)
end)
end
>>>>>>> origin/master
end
end
--]]
-- Правим строки (созданы из xml)
for i = 1, 11 do
local dynamicControl = CreateControlFromVirtual("MBUI_Row", MBUI_Container, "MBUI_TemplateRow",i)
-- Строка
local fromtop=150
_G["MBUI_Row"..i]:SetAnchor(TOP,MBUI_Container,TOP,0,fromtop+52*(i-1))
-- _G["MBUI_Row"..i]:SetDimensions (530,52)
-- Анимация
_G["MBUI_Row"..i.."IconTimeline"]=ANIMATION_MANAGER:CreateTimelineFromVirtual("MBUI_IconAnimation",_G["MBUI_Row"..i.."ButtonIcon"])
-- _G["MBUI_Row"..i.."CountTimeline"]=ANIMATION_MANAGER:CreateTimelineFromVirtual("MBUI_IconAnimation",_G["MBUI_Row"..i.."ButtonStackCount"])
end
end
function MB.PrepareBankValues(PrepareType,IdToPrepare)
<<<<<<< HEAD
MB.Label = PrepareType
MB.BankValueTable={}
=======
MB.Label = PrepareType
MB.GuildBankIdToPrepare=GuildBankIdToPrepare
MB.BankValueTable={}
>>>>>>> origin/master
MBUI_ContainerTitleFilter:SetHidden(false)
MBUI_ContainerTitleSwitchAll:SetState(0)
MBUI_ContainerTitleSwitchBank:SetState(0)
MBUI_ContainerTitleSwitchInv:SetState(0)
MBUI_ContainerTitleSwitchGuild:SetState(0)
MBUI_ContainerTitleSwitchRecipes:SetState(0)
MBUI_ContainerTitleSwitchLoot:SetState(0)
<<<<<<< HEAD
MBUI_ContainerTitleToggleEquipped:SetHidden(true)
local recipes = false
=======
>>>>>>> origin/master
if PrepareType=="Bank" then
debug("Preparing Player values")
MBUI_ContainerTitleSwitchBank:SetState(1)
local bagIcon, bagSlots=GetBagInfo(BAG_BANK)
MB.ItemCounter=0
while (MB.ItemCounter < bagSlots) do
if GetItemName(BAG_BANK,MB.ItemCounter)~="" then
--Избавляемся от мусора при сохранении
local name = zo_strformat(SI_TOOLTIP_ITEM_NAME, GetItemName(BAG_BANK, MB.ItemCounter))
local link = GetItemLink(BAG_BANK,MB.ItemCounter)
local clearlink =string.gsub(link, "|h.+|h", "|h"..tostring(name).."|h")
local stackCount = GetSlotStackSize(BAG_BANK,MB.ItemCounter)
local statValue = GetItemStatValue(BAG_BANK,MB.ItemCounter)
local icon, stack, sellPrice, meetsUsageRequirement, locked, equipType, itemStyle, quality,level = GetItemInfo(BAG_BANK,MB.ItemCounter)
local ItemType=GetItemType(BAG_BANK,MB.ItemCounter)
<<<<<<< HEAD
local _, _, _, id, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,_ = ZO_LinkHandler_ParseLink(link)
-- local id=tonumber(link:MB_splitone(":",3)) -- string.sub(link,start,finish))
local level = GetItemLevel(BAG_BANK,MB.ItemCounter)
if statValue == 0 then
statValue = tonumber(level)
if not statValue then
statValue = 1
end
=======
local id=tonumber(link:MB_splitone(":",3)) -- string.sub(link,start,finish))
-- local level = GetItemLevel(BAG_BANK,MB.ItemCounter)
if statValue == 0 then