View difference between Paste ID: 3uvMkjcr and bqxMeGw4
SHOW: | | - or go back to the newest paste.
1
//card data
2
3
namespace GwentHook
4
{
5
	[Serializable]
6
	internal class CardData
7
	{
8
		public class AbilityDefinition
9
		{
10
			public AbilityType type;
11
12
			public string name;
13
14
			public int priority;
15
16
			public int timesApplied;
17
		}
18
19
		public ulong id;
20
21
		public int templateId;
22
23
		public FactionId factionId;
24
25
		public int strength;
26
27
		public CardGroup group;
28
29
		public Rarity rarity;
30
31
		public string type;
32
33
		public CardIcon icon;
34
35
		public Availability availability;
36
37
		public Dictionary<string, string> name;
38
39
		public Dictionary<string, string> tooltip;
40
41
		public List<CardData.AbilityDefinition> abilities;
42
43
		public CardData()
44
		{
45
			this.name = new Dictionary<string, string>();
46
			this.tooltip = new Dictionary<string, string>();
47
			this.abilities = new List<CardData.AbilityDefinition>();
48
		}
49
	}
50
}
51
52
//deck statistics
53
54
namespace GwentHook
55
{
56
	[Serializable]
57
	internal static class DeckStatistics
58
	{
59
		private static List<TrackedDeck> trackedDecks = new List<TrackedDeck>();
60
61
		private static string filePath;
62
63
		private static BaseCollectionController collectionManager;
64
65
		public static void Initialize()
66
		{
67
			DeckStatistics.collectionManager = Singleton<CardsCollectionsAndDecksManager>.get_Instance().GetCollectionController(0);
68
			DeckStatistics.collectionManager.OnDeckSavingFinished.AddListener(new Action<DeckSavingResult>(DeckStatistics.OnDeckSaved), false);
69
			DeckStatistics.collectionManager.OnDeckDeletingFinished.AddListener(new Action<DeckSavingResult>(DeckStatistics.OnDeckDeleted), false);
70
			ulong currentUserID = Singleton<UnityGwentWSFasade>.get_Instance().get_CurrentUserID();
71
			string text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GwentTracker";
72
			Directory.CreateDirectory(text);
73
			DeckStatistics.filePath = string.Concat(new object[]
74
			{
75
				text,
76
				"\\",
77
				currentUserID,
78
				".json"
79
			});
80
			bool flag = false;
81
			if (File.Exists(DeckStatistics.filePath))
82
			{
83
				try
84
				{
85
					DeckStatistics.trackedDecks = (GwentUtil.Deserialize(typeof(List<TrackedDeck>), File.ReadAllText(DeckStatistics.filePath)) as List<TrackedDeck>);
86
					DeckStatistics.HandleDeckDiff();
87
				}
88
				catch (Exception)
89
				{
90
					flag = true;
91
				}
92
				Hook.WriteConsole("Decks loaded");
93
			}
94
			else
95
			{
96
				flag = true;
97
			}
98
			if (flag)
99
			{
100
				Hook.WriteConsole("Reading decks");
101
				DeckStatistics.trackedDecks.Clear();
102
				using (List<EditableDeck>.Enumerator enumerator = DeckStatistics.collectionManager.get_ControlledCollection().GetAllDecks().GetEnumerator())
103
				{
104
					while (enumerator.MoveNext())
105
					{
106
						TrackedDeck item = new TrackedDeck(enumerator.Current.get_EditableDeckId());
107
						DeckStatistics.trackedDecks.Add(item);
108
					}
109
				}
110
				DeckStatistics.SaveFile();
111
			}
112
		}
113
114
		public static void HandleDeckDiff()
115
		{
116
			List<EditableDeck> allDecks = DeckStatistics.collectionManager.get_ControlledCollection().GetAllDecks();
117
			foreach (EditableDeck current in allDecks)
118
			{
119
				bool flag = false;
120
				using (List<TrackedDeck>.Enumerator enumerator2 = DeckStatistics.trackedDecks.GetEnumerator())
121
				{
122
					while (enumerator2.MoveNext())
123
					{
124
						if (enumerator2.Current.GetId() == current.get_EditableDeckId())
125
						{
126
							flag = true;
127
							break;
128
						}
129
					}
130
				}
131
				if (!flag)
132
				{
133
					DeckStatistics.trackedDecks.Add(new TrackedDeck(current.get_EditableDeckId()));
134
				}
135
			}
136
			List<TrackedDeck> list = new List<TrackedDeck>();
137
			foreach (TrackedDeck current2 in DeckStatistics.trackedDecks)
138
			{
139
				bool flag2 = false;
140
				using (List<EditableDeck>.Enumerator enumerator = allDecks.GetEnumerator())
141
				{
142
					while (enumerator.MoveNext())
143
					{
144
						if (enumerator.Current.get_EditableDeckId() == current2.GetId())
145
						{
146
							flag2 = true;
147
							break;
148
						}
149
					}
150
				}
151
				if (!flag2)
152
				{
153
					list.Add(current2);
154
				}
155
			}
156
			foreach (TrackedDeck current3 in list)
157
			{
158
				DeckStatistics.trackedDecks.Remove(current3);
159
			}
160
		}
161
162
		public static bool IsInitialized()
163
		{
164
			return DeckStatistics.collectionManager != null;
165
		}
166
167
		public static void SaveFile()
168
		{
169
			File.WriteAllText(DeckStatistics.filePath, GwentUtil.Serialize(typeof(List<TrackedDeck>), DeckStatistics.trackedDecks));
170
			UserConfig.Save();
171
		}
172
173
		public static void OnDeckSaved(DeckSavingResult result)
174
		{
175
			if (result == null)
176
			{
177
				Hook.WriteConsole("Deck saved");
178
			}
179
		}
180
181
		public static void OnDeckDeleted(DeckSavingResult result)
182
		{
183
			if (result == null)
184
			{
185
				Hook.WriteConsole("Deck deleted");
186
			}
187
		}
188
189
		public static void OnDeckCreated(EditableDeck deck)
190
		{
191
			DeckStatistics.trackedDecks.Add(new TrackedDeck(deck.get_EditableDeckId()));
192
			DeckStatistics.SaveFile();
193
		}
194
195
		public static void OnDeckDeleted(EditableDeck deck)
196
		{
197
			foreach (TrackedDeck current in DeckStatistics.trackedDecks)
198
			{
199
				if (current.GetId() == deck.get_EditableDeckId())
200
				{
201
					DeckStatistics.trackedDecks.Remove(current);
202
					break;
203
				}
204
			}
205
			DeckStatistics.SaveFile();
206
		}
207
208
		public static void HandleCombatResult(CombatResult result)
209
		{
210
			Hook.WriteConsole("Handling combat result");
211
			if (GwentGlobalObjectsRegistry.get_GwentInstance().get_GameMode() != 1)
212
			{
213
				return;
214
			}
215
			PlayerBase topPlayer = GwentGlobalObjectsRegistry.get_GwentInstance().GameController.get_PlayerManager().GetTopPlayer();
216
			FactionId factionId = topPlayer.get_FactionId();
217
			ulong activeDeckId = DeckStatistics.collectionManager.get_ControlledCollection().GetActiveDeckId();
218
			foreach (TrackedDeck current in DeckStatistics.trackedDecks)
219
			{
220
				if (current.GetId() == activeDeckId)
221
				{
222
					GwentInstance.OnlineMode onlineMatchMode = GwentGlobalObjectsRegistry.get_GwentInstance().OnlineMatchMode;
223
					if ((current.trackRanked && onlineMatchMode == 1) || (current.trackCasual && onlineMatchMode == null))
224
					{
225
						if (result.WinningPlayerID == GwentGlobalObjectsRegistry.get_BottomPlayerID())
226
						{
227
							current.AddWin(factionId);
228
						}
229
						if (result.WinningPlayerID == topPlayer.UniqueId)
230
						{
231
							current.AddLose(factionId);
232
						}
233
						DeckStatistics.SaveFile();
234
					}
235
				}
236
			}
237
		}
238
239
		public static TrackedDeck GetActiveDeck()
240
		{
241
			ulong activeDeckId = DeckStatistics.collectionManager.get_ControlledCollection().GetActiveDeckId();
242
			foreach (TrackedDeck current in DeckStatistics.trackedDecks)
243
			{
244
				if (current.GetId() == activeDeckId)
245
				{
246
					return current;
247
				}
248
			}
249
			return null;
250
		}
251
252
		public static List<TrackedDeck> GetAllDecks()
253
		{
254
			ulong currentDeckId = DeckStatistics.collectionManager.get_ControlledCollection().GetActiveDeckId();
255
			return (from a in DeckStatistics.trackedDecks
256
			orderby a.GetId() != currentDeckId
257
			select a).ToList<TrackedDeck>();
258
		}
259
	}
260
}
261
262
//gwent util
263
264
namespace GwentHook
265
{
266
	internal static class GwentUtil
267
	{
268
		private static readonly fsSerializer _serializer = new fsSerializer();
269
270
		public static void CreateCardDatabase()
271
		{
272
			List<CardData> list = new List<CardData>();
273
			Dictionary<int, CardTemplate> cardTemplates = GwentSharedData.get_Instance().get_CardTemplates().CardTemplates;
274
			BaseEntityManager cardManager = GwentGlobalObjectsRegistry.get_GwentInstance().GameController.get_CardManager();
275
			TooltipDefinitions tooltips = GwentSharedData.get_Instance().get_Tooltips();
276
			LocalizationManager instance = LocalizationManager.get_Instance();
277
			CardTypeIconsRegistry cardTypeIconsRegistry = GwentGlobalObjectsRegistry.get_CardTypeIconsRegistry();
278
			foreach (KeyValuePair<int, CardTemplate> current in cardTemplates)
279
			{
280
				foreach (CardDefinition current2 in current.Value.cardDefinitions.DefinitionList)
281
				{
282
					CardData cardData = new CardData();
283
					cardData.templateId = current.Value.templateId;
284
					cardData.factionId = current.Value.factionId;
285
					cardData.strength = current.Value.power;
286
					cardData.group = current.Value.group;
287
					cardData.rarity = current2.RarityWrapper.get_Value();
288
					cardData.id = current2.Id;
289
					cardData.icon = current.Value.CardIcon;
290
					cardData.availability = current2.AvailabilityWrapper.get_Value();
291
					foreach (BaseAbility current3 in current.Value.get_Abilities())
292
					{
293
						CardData.AbilityDefinition abilityDefinition = new CardData.AbilityDefinition();
294
						abilityDefinition.name = current3.get_ID().ToString();
295
						abilityDefinition.priority = current3.get_Priority();
296
						abilityDefinition.timesApplied = current3.ApplyNumOfTimes.ConstValue;
297
						abilityDefinition.type = current3.get_Type();
298
						cardData.abilities.Add(abilityDefinition);
299
					}
300
					Texture texture = cardTypeIconsRegistry.FindIconForAttackType(current.Value.typeArray & 7, current.Value.IsType(256));
301
					cardData.type = "default";
302
					if (texture != null)
303
					{
304
						cardData.type = texture.get_name().Substring(5);
305
					}
306
					if (current.Value.power == 0)
307
					{
308
						cardData.type = "special";
309
					}
310
					list.Add(cardData);
311
				}
312
			}
313
			foreach (string current4 in instance.m_languages)
314
			{
315
				if (!current4.Equals("de-de") && !current4.Equals("pl-pl") && !current4.Equals("en-us") && !current4.Equals("ru-ru") && !current4.Equals("debug"))
316
				{
317
					for (int i = 0; i < list.Count; i++)
318
					{
319
						CardTemplate cardTemplate = cardTemplates[list[i].templateId];
320
						list[i].name[current4] = instance.GetTranslationText(cardTemplate.GetCardNameTextKey());
321
						try
322
						{
323
							CardTooltip cardTooltip = tooltips.get_CardTooltips()[cardTemplate.TooltipID];
324
							CardInstanceDefinition cardInstanceDefinition = default(CardInstanceDefinition);
325
							cardInstanceDefinition.templateId = cardTemplate.templateId;
326
							cardInstanceDefinition.premium = false;
327
							cardInstanceDefinition.artId = cardTemplate.cardDefinitions.DefinitionList[0].ArtIDWrapper.ConstValue;
328
							CardInstance cardInstance = new CardInstance(cardManager, cardManager.GetNextCardInstanceID(), cardInstanceDefinition, 0, 3);
329
							cardTooltip.FillVariables(instance.GetTranslationText(cardTooltip.GetDescriptionKey()), cardInstance);
330
							Hook.WriteConsole(cardTooltip.GetDescriptionKey());
331
							list[i].tooltip[current4] = LocalizationHelper.GetTooltipDescription(cardTooltip, cardInstance);
332
						}
333
						catch (Exception)
334
						{
335
							list[i].tooltip[current4] = "No description available";
336
						}
337
					}
338
				}
339
			}
340
			File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\gwent_data\\CardDatabase.json", GwentUtil.Serialize(typeof(List<CardData>), list));
341
		}
342
343
		public static void ShowCardPreview(CardTemplate template)
344
		{
345
			if (Singleton<UIManager>.get_Instance().GetPanel<UICardSelection>(5011).IsPanelVisible())
346
			{
347
				return;
348
			}
349
			BaseEntityManager arg_4B_0 = GwentGlobalObjectsRegistry.get_GwentInstance().GameController.get_CardManager();
350
			CardInstanceDefinition cardInstanceDefinition = default(CardInstanceDefinition);
351
			cardInstanceDefinition.premium = false;
352
			cardInstanceDefinition.templateId = template.templateId;
353
			cardInstanceDefinition.artId = 0;
354
			CardInstance cardInstance = new CardInstance(arg_4B_0, arg_4B_0.GetNextCardInstanceID(), cardInstanceDefinition, 0, 3);
355
			UICardPreview panel = Singleton<UIManager>.get_Instance().GetPanel<UICardPreview>(12);
356
			if (!panel.IsPanelVisible())
357
			{
358
				panel.Load();
359
				try
360
				{
361
					panel.ShowCardPreview(cardInstance, false);
362
				}
363
				catch (Exception)
364
				{
365
				}
366
			}
367
		}
368
369
		public static string GetDeckName(ulong id)
370
		{
371
			BaseCollectionController collectionController = Singleton<CardsCollectionsAndDecksManager>.get_Instance().GetCollectionController(0);
372
			CardTemplateDefinitions cardTemplates = GwentSharedData.get_Instance().get_CardTemplates();
373
			EditableDeck deck = collectionController.get_ControlledCollection().GetDeck(id);
374
			if (deck != null)
375
			{
376
				DeckInfo deckInfoFromEditableDeck = collectionController.GetDeckInfoFromEditableDeck(deck);
377
				if (!deck.get_Name().StartsWith("###"))
378
				{
379
					return deck.get_Name();
380
				}
381
				CardTemplate templateWithID = cardTemplates.GetTemplateWithID(deckInfoFromEditableDeck.LeaderCard.templateId);
382
				if (templateWithID != null)
383
				{
384
					string str = deck.get_Name().Substring(2);
385
					return LocalizationManager.get_Instance().GetTranslationText(templateWithID.GetCardNameTextKey()) + "'s Deck " + str;
386
				}
387
			}
388
			return "";
389
		}
390
391
		public static CardTemplate GetTemplateByDefinitionId(ulong id)
392
		{
393
			foreach (CardTemplate current in GwentSharedData.get_Instance().get_CardTemplates().GetCardTemplates())
394
			{
395
				using (List<CardDefinition>.Enumerator enumerator2 = current.cardDefinitions.DefinitionList.GetEnumerator())
396
				{
397
					while (enumerator2.MoveNext())
398
					{
399
						if (enumerator2.Current.Id == id)
400
						{
401
							return current;
402
						}
403
					}
404
				}
405
			}
406
			return null;
407
		}
408
409
		public static void ImportDeck(SaveCardsDTO dto)
410
		{
411
			CardTemplateDefinitions cardTemplates = GwentSharedData.get_Instance().get_CardTemplates();
412
			List<CardTemplate> list = new List<CardTemplate>();
413
			foreach (SaveCardsDTO.CardInfo current in dto.cards)
414
			{
415
				list.Add(GwentUtil.GetTemplateByDefinitionId(current.id));
416
			}
417
			CardTemplate templateByDefinitionId = GwentUtil.GetTemplateByDefinitionId(dto.leader.id);
418
			BaseCollectionController collectionController = Singleton<CardsCollectionsAndDecksManager>.get_Instance().GetCollectionController(0);
419
			List<UniversalCard> cards = collectionController.get_ControlledCollection().GetCards();
420
			EditableDeck newDeck = collectionController.GetNewDeck();
421
			newDeck.set_Name("GTImport_" + dto.name);
422
			newDeck.LeaderCardInstanceId = 0uL;
423
			foreach (UniversalCard current2 in cards)
424
			{
425
				CardTemplate templateWithID = cardTemplates.GetTemplateWithID(current2.CardInstanceDefinition.templateId);
426
				if (newDeck.LeaderCardInstanceId == 0uL && templateWithID.templateId == templateByDefinitionId.templateId)
427
				{
428
					newDeck.LeaderCardInstanceId = current2.InstanceId;
429
					newDeck.set_Faction(templateWithID.factionId);
430
				}
431
				else
432
				{
433
					CardTemplate cardTemplate = null;
434
					foreach (CardTemplate current3 in list)
435
					{
436
						if (templateWithID.templateId == current3.templateId)
437
						{
438
							newDeck.CardInstancesIds.Add(current2.InstanceId);
439
							cardTemplate = current3;
440
							break;
441
						}
442
					}
443
					if (cardTemplate != null)
444
					{
445
						list.Remove(cardTemplate);
446
					}
447
				}
448
			}
449
			if (newDeck.LeaderCardInstanceId == 0uL)
450
			{
451
				Singleton<UIManager>.get_Instance().SpawnMessagePopup("Import error", "Missing leader, can't create deck\n\n" + LocalizationManager.get_Instance().GetTranslationText(templateByDefinitionId.GetCardNameTextKey()), 1, true, 0, null, null, 1, true, 0);
452
				Hook.importingDeck = false;
453
				return;
454
			}
455
			collectionController.SaveDeck(newDeck);
456
			if (list.Count > 0)
457
			{
458
				string text = "";
459
				foreach (CardTemplate current4 in list)
460
				{
461
					text = text + LocalizationManager.get_Instance().GetTranslationText(current4.GetCardNameTextKey()) + "\n";
462
				}
463
				Singleton<UIManager>.get_Instance().SpawnMessagePopup("Import complete", "Deck successfully imported!\nYou are missing some cards :(\n\n" + text, 1, true, 0, null, null, 12, true, 0);
464
			}
465
			else
466
			{
467
				Singleton<UIManager>.get_Instance().SpawnMessagePopup("Import complete", "Deck successfully imported!", 1, true, 0, null, null, 1, true, 0);
468
			}
469
			Hook.importingDeck = false;
470
		}
471
472
		public static string Serialize(Type type, object value)
473
		{
474
			fsData fsData;
475
			GwentUtil._serializer.TrySerialize(type, value, ref fsData).AssertSuccessWithoutWarnings();
476
			return fsJsonPrinter.PrettyJson(fsData);
477
		}
478
479
		public static object Deserialize(Type type, string serializedState)
480
		{
481
			fsData fsData = fsJsonParser.Parse(serializedState);
482
			object result = null;
483
			GwentUtil._serializer.TryDeserialize(fsData, type, ref result).AssertSuccessWithoutWarnings();
484
			return result;
485
		}
486
	}
487
}
488
489
//hook
490
491
namespace GwentHook
492
{
493
	internal class Hook : MonoBehaviour
494
	{
495
		[CompilerGenerated]
496
		[Serializable]
497
		private sealed class <>c
498
		{
499
			public static readonly Hook.<>c <>9 = new Hook.<>c();
500
501
			public static Func<bool> <>9__12_0;
502
503
			internal bool <ContinueAwakeAfterDecision>b__12_0()
504
			{
505
				return UserConfig.Vars.AutoUpdateDecision;
506
			}
507
		}
508
509
		public static Version version;
510
511
		public static bool loggedIn;
512
513
		private static Hook self;
514
515
		public static bool importingDeck;
516
517
		private float deltaTime;
518
519
		public static string AssemblyDirectory
520
		{
521
			get
522
			{
523
				return Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path));
524
			}
525
		}
526
527
		private void TryStateListening()
528
		{
529
			try
530
			{
531
				StateHandler.Listen();
532
			}
533
			catch (Exception)
534
			{
535
				this.TryStateListening();
536
			}
537
		}
538
539
		public static void WriteConsole(string s)
540
		{
541
		}
542
543
		private void OnTooEarly(BaseInputActionData action)
544
		{
545
			Process.GetCurrentProcess().Kill();
546
		}
547
548
		public static void LoadEverything()
549
		{
550
			DeckStatistics.Initialize();
551
			Hook.loggedIn = true;
552
		}
553
554
		private void Awake()
555
		{
556
			Hook.version = Assembly.GetExecutingAssembly().GetName().Version;
557
			Hook.self = this;
558
			UserConfig.Load();
559
			if (!UserConfig.Vars.AutoUpdateDecision)
560
			{
561
				Singleton<UIManager>.get_Instance().SpawnMessagePopup("Gwent Tracker Info", "Would you like to enable automatic updates?\n\nWe won't ask you again, but you toggle it in the Gwent Tracker options.", 2, true, 0, new Action<BaseInputActionData>(this.OnAutoUpdatesDecisionY), new Action<BaseInputActionData>(this.OnAutoUpdatesDecisionN), 1, true, 0);
562
			}
563
			base.StartCoroutine(this.ContinueAwakeAfterDecision());
564
		}
565
566
		private IEnumerator ContinueAwakeAfterDecision()
567
		{
568
			Func<bool> arg_37_0;
569
			if ((arg_37_0 = Hook.<>c.<>9__12_0) == null)
570
			{
571
				arg_37_0 = (Hook.<>c.<>9__12_0 = new Func<bool>(Hook.<>c.<>9.<ContinueAwakeAfterDecision>b__12_0));
572
			}
573
			yield return new WaitUntil(arg_37_0);
574
			this.CheckForUpdate();
575
			this.TryStateListening();
576
			if (Singleton<UnityGwentWSFasade>.get_Instance().get_CurrentUserID() != 0uL)
577
			{
578
				Hook.LoadEverything();
579
			}
580
			yield break;
581
		}
582
583
		public void CheckForPatchnotes(Version serverVersion)
584
		{
585
			if (serverVersion.CompareTo(new Version(UserConfig.Vars.InstalledVersion)) != 0)
586
			{
587
				UserConfig.Vars.InstalledVersion = serverVersion.ToString();
588
				UserConfig.Save();
589
				WWW www = new WWW("http://www.gwent-tracker.com/api_patchnotes");
590
				base.StartCoroutine(this.WaitForPatchnotes(www));
591
			}
592
		}
593
594
		public void CheckForUpdate()
595
		{
596
			WWW www = new WWW("http://www.gwent-tracker.com/api_version");
597
			base.StartCoroutine(this.WaitForServerVersion(www));
598
		}
599
600
		public void OnAutoUpdatesDecisionY(BaseInputActionData input)
601
		{
602
			UserConfig.Vars.AutoUpdateDecision = true;
603
			UserConfig.Vars.AutoUpdate = true;
604
			UserConfig.Save();
605
		}
606
607
		public void OnAutoUpdatesDecisionN(BaseInputActionData input)
608
		{
609
			UserConfig.Vars.AutoUpdateDecision = true;
610
			UserConfig.Vars.AutoUpdate = false;
611
			UserConfig.Save();
612
		}
613
614
		public void OnVersionManualUpdateConfirmed(BaseInputActionData input)
615
		{
616
			Process.Start("http://www.gwent-tracker.com/");
617
		}
618
619
		public IEnumerator WaitForPatchnotes(WWW www)
620
		{
621
			yield return www;
622
			Singleton<UIManager>.get_Instance().SpawnMessagePopup("Gwent Tracker Patchnotes", www.get_text(), 1, true, 0, null, null, 12, true, 0);
623
			yield break;
624
		}
625
626
		public IEnumerator WaitForServerVersion(WWW www)
627
		{
628
			yield return www;
629
			Version version = new Version(www.get_text());
630
			if (version.CompareTo(Hook.version) > 0)
631
			{
632
				if (UserConfig.Vars.AutoUpdate)
633
				{
634
					WWW www2 = new WWW("http://www.gwent-tracker.com/download/GwentHook.dll");
635
					this.StartCoroutine(this.WaitForUpdateAssembly(www2));
636
				}
637
				else
638
				{
639
					Singleton<UIManager>.get_Instance().SpawnMessagePopup("Gwent Tracker Update", "A new version for Gwent Tracker is available. Would you like to download it now?", 2, true, 0, new Action<BaseInputActionData>(this.OnVersionManualUpdateConfirmed), null, 1, true, 0);
640
				}
641
			}
642
			else
643
			{
644
				this.CheckForPatchnotes(version);
645
			}
646
			yield break;
647
		}
648
649
		public IEnumerator WaitForUpdateAssembly(WWW www)
650
		{
651
			yield return www;
652
			File.WriteAllBytes(Hook.AssemblyDirectory + "\\GwentHook.new", www.get_bytes());
653
			Singleton<UIManager>.get_Instance().SpawnMessagePopup("Gwent Tracker Automatic Update", "A new version has been downloaded!\nIt will automatically install itself on next restart.", 1, true, 0, null, null, 1, true, 0);
654
			yield break;
655
		}
656
657
		public void StartCollectionRoutine(WWW www)
658
		{
659
			base.StartCoroutine(this.WaitForCollectionURL(www));
660
		}
661
662
		public IEnumerator WaitForRankedRecordResponse(WWW www)
663
		{
664
			yield return www;
665
			yield break;
666
		}
667
668
		public static void PostRankedRecord(RankedLeaderboardRecord record)
669
		{
670
			WWWForm wWWForm = new WWWForm();
671
			wWWForm.AddField("data", record.ToJSON());
672
			WWW www = new WWW("http://www.gwent-tracker.com/api_put_rankedrecord", wWWForm);
673
			Hook.self.StartCoroutine(Hook.self.WaitForRankedRecordResponse(www));
674
		}
675
676
		public static void PostCollection(SaveCardsDTO dto)
677
		{
678
			WWWForm wWWForm = new WWWForm();
679
			string text = GwentUtil.Serialize(typeof(SaveCardsDTO), dto);
680
			wWWForm.AddField("data", text);
681
			WWW www = new WWW("http://www.gwent-tracker.com/api_save_cards", wWWForm);
682
			Hook.self.StartCollectionRoutine(www);
683
		}
684
685
		public IEnumerator WaitForCollectionURL(WWW www)
686
		{
687
			yield return www;
688
			string text = www.get_text();
689
			if (text != "ERROR")
690
			{
691
				Application.OpenURL("http://www.gwent-tracker.com/c?id=" + text);
692
			}
693
			yield break;
694
		}
695
696
		public IEnumerator WaitSeconds(float f, Action done)
697
		{
698
			yield return new WaitForSeconds(f);
699
			done();
700
			yield break;
701
		}
702
703
		private void OnImportIsPossible(SaveCardsDTO dto)
704
		{
705
			Action <>9__1;
706
			Singleton<UIManager>.get_Instance().SpawnMessagePopup("Deck import", string.Concat(new string[]
707
			{
708
				"Would you like to import this deck?\n\n",
709
				dto.name,
710
				" (",
711
				dto.cards.Count.ToString(),
712
				" Cards)"
713
			}), 2, true, 0, delegate(BaseInputActionData data)
714
			{
715
				MonoBehaviour arg_35_0 = this;
716
				Hook arg_30_0 = this;
717
				float arg_30_1 = 0.5f;
718
				Action arg_30_2;
719
				if ((arg_30_2 = <>9__1) == null)
720
				{
721
					arg_30_2 = (<>9__1 = delegate
722
					{
723
						GwentUtil.ImportDeck(dto);
724
					});
725
				}
726
				arg_35_0.StartCoroutine(arg_30_0.WaitSeconds(arg_30_1, arg_30_2));
727
			}, null, 1, true, 0);
728
		}
729
730
		private void OnMalformattedDeck()
731
		{
732
			Singleton<UIManager>.get_Instance().SpawnMessagePopup("Import error", "The deck you are trying to import is malformatted.\nGwent Tracker is unable to parse it", 1, true, 0, null, null, 1, true, 0);
733
			Hook.importingDeck = false;
734
		}
735
736
		private void OnCollectionImport()
737
		{
738
			Singleton<UIManager>.get_Instance().SpawnMessagePopup("Import error", "You can't import collections.", 1, true, 0, null, null, 1, true, 0);
739
			Hook.importingDeck = false;
740
		}
741
742
		public IEnumerator WaitForDeckToImport(WWW www)
743
		{
744
			yield return www;
745
			try
746
			{
747
				SaveCardsDTO dto = GwentUtil.Deserialize(typeof(SaveCardsDTO), www.get_text()) as SaveCardsDTO;
748
				if (dto.leader == null)
749
				{
750
					this.StartCoroutine(this.WaitSeconds(0.5f, new Action(this.OnCollectionImport)));
751
				}
752
				UserInterface.Hide();
753
				this.StartCoroutine(this.WaitSeconds(0.5f, delegate
754
				{
755
					this.OnImportIsPossible(dto);
756
				}));
757
			}
758
			catch (Exception)
759
			{
760
				UserInterface.Hide();
761
				this.StartCoroutine(this.WaitSeconds(0.5f, new Action(this.OnMalformattedDeck)));
762
			}
763
			yield break;
764
		}
765
766
		private void OnImportWrongUrl()
767
		{
768
			UserInterface.Hide();
769
			Singleton<UIManager>.get_Instance().SpawnMessagePopup("Import error", "You currently don't have a valid deck link in your clipboard.\nPlease copy a deck url and then click the import button again.", 1, true, 0, null, null, 1, true, 0);
770
			Hook.importingDeck = false;
771
		}
772
773
		public static void CurrentlyNotWorking()
774
		{
775
			Singleton<UIManager>.get_Instance().SpawnMessagePopup("Error", "This feature is currently not working.\nExpect it to be fixed very soon! :)", 1, true, 0, null, null, 1, true, 0);
776
		}
777
778
		public static void TryDeckImport()
779
		{
780
			Match match = Regex.Match(GUIUtility.get_systemCopyBuffer(), "http:\\/\\/www.gwent-tracker.com\\/c\\?id=(\\d{10}\\.\\d*)");
781
			if (!match.Success)
782
			{
783
				Hook.self.StartCoroutine(Hook.self.WaitSeconds(0.5f, new Action(Hook.self.OnImportWrongUrl)));
784
				return;
785
			}
786
			string value = match.Groups[1].Value;
787
			WWW www = new WWW("http://www.gwent-tracker.com/api_get_deck?id=" + value);
788
			Hook.self.StartCoroutine(Hook.self.WaitForDeckToImport(www));
789
		}
790
791
		private void Update()
792
		{
793
			Tracker.Update();
794
			if (Hook.loggedIn && Input.GetKeyDown(282))
795
			{
796
				UserInterface.Show();
797
			}
798
		}
799
800
		private void OnGUI()
801
		{
802
			if (Hook.loggedIn)
803
			{
804
				UserInterface.Draw();
805
			}
806
			if (!Tracker.OnGUI())
807
			{
808
				Rect rect = new Rect((float)(Screen.get_width() / 2 - 120), 0f, 240f, 40f);
809
				if (Hook.loggedIn)
810
				{
811
					rect.set_x(0f);
812
				}
813
				if (Hook.loggedIn)
814
				{
815
					if (GUI.Button(rect, "www.gwent-tracker.com\nPress F1 or click here to open Menu"))
816
					{
817
						UserInterface.Show();
818
						return;
819
					}
820
				}
821
				else
822
				{
823
					GUI.Button(rect, "Waiting for you to log in...");
824
				}
825
			}
826
		}
827
	}
828
}
829
830
//main
831
832
namespace GwentHook
833
{
834
	public class Main
835
	{
836
		public static GameObject loadObject;
837
838
		public static void Start()
839
		{
840
			Main.loadObject = new GameObject();
841
			Main.loadObject.AddComponent<SanitizeHook>();
842
			Object.DontDestroyOnLoad(Main.loadObject);
843
		}
844
	}
845
}
846
847
848
//movable
849
850
namespace GwentHook
851
{
852
	[Serializable]
853
	internal class Movable
854
	{
855
		[SerializeField]
856
		private Vector2 localPosition;
857
858
		private Vector2 localOffset;
859
860
		private bool moving;
861
862
		public Movable(Vector2 initialPosition)
863
		{
864
			this.localPosition = initialPosition;
865
			this.moving = false;
866
		}
867
868
		public void StartMoving(Vector2 mousePosition)
869
		{
870
			this.localOffset = this.localPosition - mousePosition;
871
			this.moving = true;
872
		}
873
874
		public void Update(Vector2 mousePosition)
875
		{
876
			if (this.moving)
877
			{
878
				this.localPosition = mousePosition + this.localOffset;
879
			}
880
		}
881
882
		public void StopMoving()
883
		{
884
			this.moving = false;
885
		}
886
887
		public Vector2 GetPosition()
888
		{
889
			return this.localPosition;
890
		}
891
	}
892
}
893
894
//player deck
895
896
namespace GwentHook
897
{
898
	internal class PlayerDeck
899
	{
900
		private static List<CardTemplate> deck = new List<CardTemplate>();
901
902
		private static BaseGwentController gameController;
903
904
		public static void Update()
905
		{
906
			PlayerDeck.deck.Clear();
907
			PlayerDeck.gameController = GwentGlobalObjectsRegistry.get_GwentInstance().GameController;
908
			foreach (CardInstanceDefinition current in Singleton<CardsCollectionsAndDecksManager>.get_Instance().GetCollectionController(0).GetActiveDeckInfo().Cards)
909
			{
910
				CardTemplate templateWithID = PlayerDeck.gameController.get_CardManager().GetTemplateDefinitions().GetTemplateWithID(current.templateId);
911
				PlayerDeck.deck.Add(templateWithID);
912
			}
913
		}
914
915
		public static string GetName()
916
		{
917
			BaseCollectionController expr_0B = Singleton<CardsCollectionsAndDecksManager>.get_Instance().GetCollectionController(0);
918
			DeckInfo activeDeckInfo = expr_0B.GetActiveDeckInfo();
919
			string name = expr_0B.get_ControlledCollection().GetActiveDeck().get_Name();
920
			if (name.StartsWith("###"))
921
			{
922
				CardTemplate templateWithID = PlayerDeck.gameController.get_CardManager().GetTemplateDefinitions().GetTemplateWithID(activeDeckInfo.LeaderCard.templateId);
923
				if (templateWithID != null)
924
				{
925
					string str = name.Substring(2);
926
					return LocalizationManager.get_Instance().GetTranslationText(templateWithID.GetCardNameTextKey()) + "'s Deck " + str;
927
				}
928
			}
929
			return name;
930
		}
931
932
		public static List<CardTemplate> Get()
933
		{
934
			return PlayerDeck.deck;
935
		}
936
937
		public static void Add(CardTemplate card, int count = 1)
938
		{
939
			for (int i = 0; i < count; i++)
940
			{
941
				PlayerDeck.deck.Add(card);
942
			}
943
		}
944
	}
945
}
946
947
//sanitize hook
948
949
namespace GwentHook
950
{
951
	internal class SanitizeHook : MonoBehaviour
952
	{
953
		private void FixedUpdate()
954
		{
955
			if (GwentGlobalObjectsRegistry.get_Instance() == null || !GwentGlobalObjectsRegistry.get_Instance())
956
			{
957
				return;
958
			}
959
			if (ApplicationFlowController.Singleton() == null)
960
			{
961
				return;
962
			}
963
			if (ApplicationFlowController.Singleton().get_StateMachine().GetCurrentState() == null)
964
			{
965
				return;
966
			}
967
			Object.FindObjectOfType<ApplicationFlowController>().get_gameObject().AddComponent<Hook>();
968
			Object.Destroy(Main.loadObject);
969
		}
970
	}
971
}
972
973
//save cards dto
974
975
namespace GwentHook
976
{
977
	[Serializable]
978
	public class SaveCardsDTO
979
	{
980
		[Serializable]
981
		public class CardInfo
982
		{
983
			public ulong id;
984
985
			public bool premium;
986
987
			public CardInfo(ulong i, bool p)
988
			{
989
				this.id = i;
990
				this.premium = p;
991
			}
992
		}
993
994
		public List<SaveCardsDTO.CardInfo> cards;
995
996
		public string name;
997
998
		public SaveCardsDTO.CardInfo leader;
999
1000
		public SaveCardsDTO(string name)
1001
		{
1002
			this.name = name;
1003
			this.cards = new List<SaveCardsDTO.CardInfo>();
1004
			this.leader = null;
1005
		}
1006
1007
		public void AddCard(ulong i, bool p)
1008
		{
1009
			this.cards.Add(new SaveCardsDTO.CardInfo(i, p));
1010
		}
1011
1012
		public void SetLeader(ulong i, bool p)
1013
		{
1014
			this.leader = new SaveCardsDTO.CardInfo(i, p);
1015
		}
1016
	}
1017
}
1018
1019
//state handler
1020
1021
namespace GwentHook
1022
{
1023
	internal class StateHandler
1024
	{
1025
		private static FiniteStateMachine fsm;
1026
1027
		private static Dictionary<string, Action<IBaseState, IBaseState>> map;
1028
1029
		private static List<RedPlayer> players = new List<RedPlayer>();
1030
1031
		public static void BindStateMachines(FiniteStateMachine fsm)
1032
		{
1033
			fsm.OnStateChanged.AddListener(new Action<IBaseState, IBaseState>(StateHandler.OnStateChangedMaster), false);
1034
			foreach (IBaseState current in fsm.GetRegisteredStates())
1035
			{
1036
				if (current.get_SubStateMachine() != null)
1037
				{
1038
					StateHandler.BindStateMachines(current.get_SubStateMachine());
1039
				}
1040
			}
1041
		}
1042
1043
		public static void Listen()
1044
		{
1045
			Hook.WriteConsole("Initialized");
1046
			StateHandler.fsm = ApplicationFlowController.Singleton().get_StateMachine();
1047
			StateHandler.map = new Dictionary<string, Action<IBaseState, IBaseState>>();
1048
			StateHandler.BindStateMachines(StateHandler.fsm);
1049
			StateHandler.AddListener("Game Intro State", new Action<IBaseState, IBaseState>(StateHandler.OnGameIntro));
1050
			StateHandler.AddListener("Game Outcome", new Action<IBaseState, IBaseState>(StateHandler.OnGameOutcome));
1051
			StateHandler.AddListener("Game Online State", new Action<IBaseState, IBaseState>(StateHandler.OnGameOnline));
1052
			StateHandler.AddListener("Deck Create State", new Action<IBaseState, IBaseState>(StateHandler.OnDeckCreate));
1053
			StateHandler.AddListener("Deck Selection State", new Action<IBaseState, IBaseState>(StateHandler.OnDeckSelection));
1054
			StateHandler.AddListener("Welcome", new Action<IBaseState, IBaseState>(StateHandler.OnLoggedIn));
1055
		}
1056
1057
		public static void Deafen()
1058
		{
1059
			StateHandler.map.Clear();
1060
		}
1061
1062
		private static void OnSeasonDataSuccess(Season season)
1063
		{
1064
			foreach (RedPlayer current in StateHandler.players)
1065
			{
1066
				Singleton<UnityGwentWSFasade>.get_Instance().get_WSFasade().GetUsersInSeason(season.get_Id(), current.get_ServiceID(), new Action<RankedLeaderboardRecord>(StateHandler.OnLeaderboardRecordSuccess), new Action<Exception>(StateHandler.OnLeaderboardRecordFailure));
1067
			}
1068
		}
1069
1070
		private static void OnLeaderboardRecordSuccess(RankedLeaderboardRecord record)
1071
		{
1072
			Tracker.AddRecord(record);
1073
			Hook.PostRankedRecord(record);
1074
		}
1075
1076
		private static void OnLeaderboardRecordFailure(Exception e)
1077
		{
1078
		}
1079
1080
		private static void OnLoggedIn(IBaseState _old, IBaseState _new)
1081
		{
1082
			Hook.LoadEverything();
1083
		}
1084
1085
		private static void OnDeckSelection(IBaseState _old, IBaseState _new)
1086
		{
1087
			AppDeckSelectionState expr_06 = _new as AppDeckSelectionState;
1088
			expr_06.OnDeckMarkedForRemoval.RemoveListener(new Action<EditableDeck>(DeckStatistics.OnDeckDeleted));
1089
			expr_06.OnDeckMarkedForRemoval.AddListener(new Action<EditableDeck>(DeckStatistics.OnDeckDeleted), false);
1090
		}
1091
1092
		private static void OnDeckCreate(IBaseState _old, IBaseState _new)
1093
		{
1094
			AppDeckCreateState expr_06 = _new as AppDeckCreateState;
1095
			expr_06.OnDeckCreated.RemoveListener(new Action<EditableDeck>(DeckStatistics.OnDeckCreated));
1096
			expr_06.OnDeckCreated.AddListener(new Action<EditableDeck>(DeckStatistics.OnDeckCreated), false);
1097
		}
1098
1099
		private static void OnGameOnline(IBaseState _old, IBaseState _new)
1100
		{
1101
			ILobbyManager lobbyManager = Reflector.FindProperty<ILobbyManager>(_new, "LobbyManager").Get();
1102
			if (lobbyManager != null)
1103
			{
1104
				StateHandler.players.Clear();
1105
				foreach (KeyValuePair<int, RedPlayer> current in lobbyManager.get_CurrentLobby().GetPlayers())
1106
				{
1107
					StateHandler.players.Add(current.Value);
1108
				}
1109
				Tracker.ResetRecords();
1110
				Singleton<UnityGwentWSFasade>.get_Instance().get_WSFasade().GetCurrentSeason(new Action<Season>(StateHandler.OnSeasonDataSuccess), new Action<Exception>(StateHandler.OnLeaderboardRecordFailure));
1111
			}
1112
		}
1113
1114
		private static void OnGameIntro(IBaseState _old, IBaseState _new)
1115
		{
1116
			StatusEvents.Listen();
1117
		}
1118
1119
		private static void OnGameOutcome(IBaseState _old, IBaseState _new)
1120
		{
1121
			StatusEvents.Deafen();
1122
			DeckStatistics.HandleCombatResult((_new as AppGameOutcomeState).CombatResult);
1123
		}
1124
1125
		public static void AddListener(string id, Action<IBaseState, IBaseState> handler)
1126
		{
1127
			StateHandler.map[id] = handler;
1128
		}
1129
1130
		private static void OnStateChangedMaster(IBaseState _old, IBaseState _new)
1131
		{
1132
			try
1133
			{
1134
				Hook.WriteConsole("State: " + _new.ToString());
1135
				Action<IBaseState, IBaseState> action;
1136
				if (StateHandler.map.TryGetValue(_new.ToString(), out action))
1137
				{
1138
					action(_old, _new);
1139
				}
1140
			}
1141
			catch (Exception)
1142
			{
1143
			}
1144
		}
1145
	}
1146
}
1147
1148
//status events
1149
1150
namespace GwentHook
1151
{
1152
	internal class StatusEvents
1153
	{
1154
		public static void Listen()
1155
		{
1156
			BaseGwentController expr_0A = GwentGlobalObjectsRegistry.get_GwentInstance().GameController;
1157
			expr_0A.get_StatusEvents().OnGameStarted.AddListener(new Action(StatusEvents.OnGameStarted), false);
1158
			expr_0A.get_StatusEvents().OnGameEnded.AddListener(new Action<int, EndGameReason>(StatusEvents.OnGameEnded), false);
1159
			expr_0A.get_StatusEvents().OnAbilityWillAffect.AddListener(new Action<AbilityEventInfo>(StatusEvents.OnAbilityWillAffect), false);
1160
			expr_0A.get_StatusEvents().OnAbilityApplyEnded.AddListener(new Action<AbilityEventInfo>(StatusEvents.OnAbilityApplyEnded), false);
1161
			expr_0A.get_StatusEvents().OnCardSpawnedCard.AddListener(new Action<CardInstance, CardInstance>(StatusEvents.OnCardSpawnedCard), false);
1162
			expr_0A.get_StatusEvents().OnCardsBanished.AddListener(new Action<ulong[]>(StatusEvents.OnCardsBanished), false);
1163
		}
1164
1165
		public static void Deafen()
1166
		{
1167
			BaseGwentController expr_0A = GwentGlobalObjectsRegistry.get_GwentInstance().GameController;
1168
			expr_0A.get_StatusEvents().OnGameStarted.RemoveListener(new Action(StatusEvents.OnGameStarted));
1169
			expr_0A.get_StatusEvents().OnGameEnded.RemoveListener(new Action<int, EndGameReason>(StatusEvents.OnGameEnded));
1170
			expr_0A.get_StatusEvents().OnAbilityApplyStarted.RemoveListener(new Action<AbilityEventInfo>(StatusEvents.OnAbilityWillAffect));
1171
			expr_0A.get_StatusEvents().OnAbilityApplyEnded.RemoveListener(new Action<AbilityEventInfo>(StatusEvents.OnAbilityApplyEnded));
1172
			expr_0A.get_StatusEvents().OnCardSpawnedCard.RemoveListener(new Action<CardInstance, CardInstance>(StatusEvents.OnCardSpawnedCard));
1173
			expr_0A.get_StatusEvents().OnCardsBanished.RemoveListener(new Action<ulong[]>(StatusEvents.OnCardsBanished));
1174
		}
1175
1176
		public static void OnGameStarted()
1177
		{
1178
			PlayerDeck.Update();
1179
			Tracker.Listen();
1180
		}
1181
1182
		public static void OnGameEnded(int unk, EndGameReason reason)
1183
		{
1184
			Tracker.Deafen();
1185
		}
1186
1187
		public static void OnAbilityApplyEnded(AbilityEventInfo info)
1188
		{
1189
			Tracker.OnAbilityApplyEnded(info);
1190
		}
1191
1192
		public static void OnAbilityWillAffect(AbilityEventInfo info)
1193
		{
1194
			Tracker.OnAbilityWillAffect(info);
1195
		}
1196
1197
		public static void OnCardSpawnedCard(CardInstance dst, CardInstance src)
1198
		{
1199
		}
1200
1201
		public static void OnCardsBanished(ulong[] instanceIds)
1202
		{
1203
			Tracker.OnCardBanished(instanceIds);
1204
		}
1205
	}
1206
}
1207
1208
//tracked deck
1209
1210
namespace GwentHook
1211
{
1212
	[Serializable]
1213
	public class TrackedDeck
1214
	{
1215
		[Serializable]
1216
		public class WL
1217
		{
1218
			public int w;
1219
1220
			public int l;
1221
1222
			public WL(int w, int l)
1223
			{
1224
				this.w = w;
1225
				this.l = l;
1226
			}
1227
1228
			public float GetAsPercent()
1229
			{
1230
				if (this.w + this.l != 0)
1231
				{
1232
					return (float)Math.Round((double)((float)this.w / (float)(this.w + this.l) * 100f), 0);
1233
				}
1234
				return 0f;
1235
			}
1236
		}
1237
1238
		[SerializeField]
1239
		private ulong id;
1240
1241
		[SerializeField]
1242
		private Dictionary<FactionId, TrackedDeck.WL> stats;
1243
1244
		[SerializeField]
1245
		public bool trackRanked;
1246
1247
		[SerializeField]
1248
		public bool trackCasual;
1249
1250
		public TrackedDeck(ulong id)
1251
		{
1252
			this.stats = new Dictionary<FactionId, TrackedDeck.WL>();
1253
			this.trackRanked = true;
1254
			this.trackCasual = false;
1255
			foreach (FactionId current in Enum.GetValues(typeof(FactionId)).Cast<FactionId>())
1256
			{
1257
				if (current != null && current != -1 && current != 6)
1258
				{
1259
					this.stats[current] = new TrackedDeck.WL(0, 0);
1260
				}
1261
			}
1262
			this.id = id;
1263
		}
1264
1265
		public void AddWin(FactionId faction)
1266
		{
1267
			this.stats[faction].w++;
1268
		}
1269
1270
		public void AddLose(FactionId faction)
1271
		{
1272
			this.stats[faction].l++;
1273
		}
1274
1275
		public TrackedDeck.WL GetWLForFaction(FactionId faction)
1276
		{
1277
			return this.stats[faction];
1278
		}
1279
1280
		public ulong GetId()
1281
		{
1282
			return this.id;
1283
		}
1284
1285
		public TrackedDeck.WL GetWLSum()
1286
		{
1287
			TrackedDeck.WL wL = new TrackedDeck.WL(0, 0);
1288
			foreach (KeyValuePair<FactionId, TrackedDeck.WL> current in this.stats)
1289
			{
1290
				wL.w += current.Value.w;
1291
				wL.l += current.Value.l;
1292
			}
1293
			return wL;
1294
		}
1295
1296
		public Dictionary<FactionId, TrackedDeck.WL> GetStats()
1297
		{
1298
			return this.stats;
1299
		}
1300
1301
		public void Reset()
1302
		{
1303
			foreach (KeyValuePair<FactionId, TrackedDeck.WL> current in this.stats)
1304
			{
1305
				current.Value.w = (current.Value.l = 0);
1306
			}
1307
		}
1308
	}
1309
}
1310
1311
//tracker
1312
1313
namespace GwentHook
1314
{
1315
	internal class Tracker
1316
	{
1317
		public class TrackerSkin
1318
		{
1319
			private static GUIStyle buttonStyle = new GUIStyle();
1320
1321
			private static GUIStyle boxStyle = new GUIStyle();
1322
1323
			private static bool initialized = false;
1324
1325
			public static Texture2D CreateBorderedButtonTexture(int w, int h, Color border, Color fill)
1326
			{
1327
				Texture2D texture2D = new Texture2D(w, h);
1328
				for (int i = 0; i < w; i++)
1329
				{
1330
					for (int j = 0; j < h; j++)
1331
					{
1332
						if (i == 0 || i == w - 1 || j == 0 || j == h - 1)
1333
						{
1334
							texture2D.SetPixel(i, j, border);
1335
						}
1336
						else
1337
						{
1338
							texture2D.SetPixel(i, j, fill);
1339
						}
1340
					}
1341
				}
1342
				texture2D.Apply();
1343
				return texture2D;
1344
			}
1345
1346
			public static void Initialize()
1347
			{
1348
				if (!Tracker.TrackerSkin.initialized)
1349
				{
1350
					Tracker.TrackerSkin.buttonStyle = new GUIStyle(GUI.get_skin().get_button());
1351
					Tracker.TrackerSkin.buttonStyle.set_alignment(3);
1352
					Tracker.TrackerSkin.buttonStyle.get_padding().set_left(50);
1353
					Tracker.TrackerSkin.buttonStyle.get_normal().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserConfig.Vars.ScaleX, UserConfig.Vars.ScaleY, Color.get_black(), new Color(0f, 0f, 0f, 0.5f)));
1354
					Tracker.TrackerSkin.buttonStyle.get_hover().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserConfig.Vars.ScaleX, UserConfig.Vars.ScaleY, Color.get_black(), new Color(0f, 0f, 0f, 0.6f)));
1355
					Tracker.TrackerSkin.buttonStyle.get_active().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserConfig.Vars.ScaleX, UserConfig.Vars.ScaleY, Color.get_black(), new Color(0f, 0f, 0f, 0.7f)));
1356
					Tracker.TrackerSkin.buttonStyle.get_focused().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserConfig.Vars.ScaleX, UserConfig.Vars.ScaleY, Color.get_black(), new Color(0f, 0f, 0f, 0.8f)));
1357
					Tracker.TrackerSkin.boxStyle = new GUIStyle(GUI.get_skin().get_box());
1358
					Tracker.TrackerSkin.boxStyle.set_alignment(4);
1359
					Tracker.TrackerSkin.boxStyle.get_normal().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserConfig.Vars.ScaleX, UserConfig.Vars.ScaleY, Color.get_gray(), Color.get_black()));
1360
					Tracker.TrackerSkin.initialized = true;
1361
					Hook.WriteConsole("Tracker initialized");
1362
				}
1363
			}
1364
1365
			public static bool Button(Rect position, string text, int indent = 60)
1366
			{
1367
				Tracker.TrackerSkin.buttonStyle.get_padding().set_left(indent);
1368
				Tracker.TrackerSkin.buttonStyle.set_fontSize(UserConfig.Vars.ScaleY / 2);
1369
				return GUI.Button(position, text, Tracker.TrackerSkin.buttonStyle);
1370
			}
1371
1372
			public static void Box(Rect position, string text)
1373
			{
1374
				Tracker.TrackerSkin.boxStyle.set_fontSize(UserConfig.Vars.ScaleY / 2);
1375
				GUI.Box(position, text, Tracker.TrackerSkin.boxStyle);
1376
			}
1377
1378
			public static bool RepeatButton(Rect position, string text, int indent = 60)
1379
			{
1380
				Tracker.TrackerSkin.buttonStyle.get_padding().set_left(indent);
1381
				Tracker.TrackerSkin.buttonStyle.set_alignment(3);
1382
				Tracker.TrackerSkin.buttonStyle.set_fontSize(UserConfig.Vars.ScaleY / 2);
1383
				return GUI.RepeatButton(position, text, Tracker.TrackerSkin.buttonStyle);
1384
			}
1385
1386
			public static bool StatisticButton(Rect position, string text)
1387
			{
1388
				Tracker.TrackerSkin.buttonStyle.get_padding().set_left(0);
1389
				Tracker.TrackerSkin.buttonStyle.set_alignment(4);
1390
				Tracker.TrackerSkin.buttonStyle.set_fontSize(UserConfig.Vars.ScaleY / 2);
1391
				return GUI.RepeatButton(position, text, Tracker.TrackerSkin.buttonStyle);
1392
			}
1393
		}
1394
1395
		[CompilerGenerated]
1396
		[Serializable]
1397
		private sealed class <>c
1398
		{
1399
			public static readonly Tracker.<>c <>9 = new Tracker.<>c();
1400
1401
			public static Func<CardInstance, CardGroup> <>9__24_0;
1402
1403
			public static Func<CardInstance, int> <>9__24_1;
1404
1405
			public static Func<CardTemplate, CardGroup> <>9__25_0;
1406
1407
			public static Func<CardTemplate, int> <>9__25_1;
1408
1409
			public static Predicate<CardTemplate> <>9__25_2;
1410
1411
			internal CardGroup <GetOpponentCards>b__24_0(CardInstance a)
1412
			{
1413
				return a.get_CardGroup();
1414
			}
1415
1416
			internal int <GetOpponentCards>b__24_1(CardInstance a)
1417
			{
1418
				return a.get_TemplateID();
1419
			}
1420
1421
			internal CardGroup <GetDeckCards>b__25_0(CardTemplate a)
1422
			{
1423
				return a.group;
1424
			}
1425
1426
			internal int <GetDeckCards>b__25_1(CardTemplate a)
1427
			{
1428
				return a.templateId;
1429
			}
1430
1431
			internal bool <GetDeckCards>b__25_2(CardTemplate card)
1432
			{
1433
				return (card.group != 1 || !UserConfig.Vars.DeckBronze) && (card.group != 2 || !UserConfig.Vars.DeckSilver) && (card.group != 3 || !UserConfig.Vars.DeckGold);
1434
			}
1435
		}
1436
1437
		private static GwentGameController gameController;
1438
1439
		private static GameBoardManager boardManager;
1440
1441
		private static BasePlayerController playerController;
1442
1443
		private static CardTypeIconsRegistry iconRegistry;
1444
1445
		private static List<Sprite> raritySprites;
1446
1447
		private static Texture2D[] groupTextures = new Texture2D[4];
1448
1449
		private static Texture2D fallbackTexture = null;
1450
1451
		private static bool shouldTrack;
1452
1453
		private static float updateTime = 0.5f;
1454
1455
		private static List<RankedLeaderboardRecord> playerRecords = new List<RankedLeaderboardRecord>();
1456
1457
		private static List<CardTemplate> banishedCards = new List<CardTemplate>();
1458
1459
		private static List<CardTemplate> opponentCards = new List<CardTemplate>();
1460
1461
		private static List<CardTemplate> deckCards = new List<CardTemplate>();
1462
1463
		public static void Listen()
1464
		{
1465
			Tracker.gameController = (GwentGlobalObjectsRegistry.get_GwentInstance().GameController as GwentGameController);
1466
			Tracker.boardManager = (Tracker.gameController.get_CardManager().get_Board() as GameBoardManager);
1467
			Tracker.playerController = Tracker.gameController.get_PlayerManager().GetPlayerController(1);
1468
			Tracker.iconRegistry = GwentGlobalObjectsRegistry.get_CardTypeIconsRegistry();
1469
			CardRarityRenderer expr_51 = Object.FindObjectOfType<CardRarityRenderer>();
1470
			if (expr_51 == null)
1471
			{
1472
				Hook.WriteConsole("cardIconsController is null");
1473
			}
1474
			else
1475
			{
1476
				Hook.WriteConsole("cardIconsController is not null");
1477
			}
1478
			Tracker.raritySprites = Reflector.FindField<List<Sprite>>(expr_51, "m_RaritySpriteList").Get();
1479
			for (int i = 0; i < Tracker.groupTextures.Length; i++)
1480
			{
1481
				Tracker.groupTextures[i] = new Texture2D(1, 1);
1482
				CardGroup group = i;
1483
				Tracker.groupTextures[i].SetPixel(0, 0, Tracker.GetCardGroupColor(group));
1484
				Tracker.groupTextures[i].Apply();
1485
			}
1486
			if (Tracker.fallbackTexture == null)
1487
			{
1488
				Tracker.fallbackTexture = new Texture2D(1, 1);
1489
				Tracker.fallbackTexture.LoadImage(Convert.FromBase64String(Tracker.getB64Image()));
1490
			}
1491
			Tracker.shouldTrack = true;
1492
			Hook.WriteConsole("Tracker is listening");
1493
		}
1494
1495
		public static void Deafen()
1496
		{
1497
			Tracker.shouldTrack = false;
1498
			Tracker.banishedCards.Clear();
1499
			for (int i = 0; i < Tracker.groupTextures.Length; i++)
1500
			{
1501
				Object.Destroy(Tracker.groupTextures[i]);
1502
			}
1503
		}
1504
1505
		public static void ResetRecords()
1506
		{
1507
			Tracker.playerRecords.Clear();
1508
		}
1509
1510
		public static void AddRecord(RankedLeaderboardRecord record)
1511
		{
1512
			Tracker.playerRecords.Add(record);
1513
		}
1514
1515
		private static Color GetCardGroupColor(CardGroup group)
1516
		{
1517
			if (group == 1)
1518
			{
1519
				return new Color(0.7f, 0.5f, 0f);
1520
			}
1521
			if (group == 2)
1522
			{
1523
				return new Color(0.9f, 0.9f, 0.9f);
1524
			}
1525
			if (group == 3)
1526
			{
1527
				return new Color(0.9f, 0.8f, 0f);
1528
			}
1529
			return Color.get_white();
1530
		}
1531
1532
		private static void DrawCard(Rect position, CardTemplate card, int count = -1)
1533
		{
1534
			GUI.set_color(Color.get_white());
1535
			string text = LocalizationManager.get_Instance().GetTranslationText(card.GetCardNameTextKey());
1536
			if (count != -1)
1537
			{
1538
				text = count + "  " + text;
1539
			}
1540
			int num = UserConfig.Vars.ScaleY - 10;
1541
			int num2 = UserConfig.Vars.ScaleY - 6;
1542
			if (Tracker.TrackerSkin.Button(position, text, UserConfig.Vars.Rarity ? (num + num2 + 25) : (num2 + 20)))
1543
			{
1544
				GwentUtil.ShowCardPreview(card);
1545
			}
1546
			if (UserConfig.Vars.Rarity)
1547
			{
1548
				Rarity value = card.cardDefinitions.DefinitionList[0].RarityWrapper.get_Value();
1549
				GUI.DrawTexture(new Rect(position.get_x() + 15f, position.get_y() + 5f, (float)num, (float)num), Tracker.raritySprites[UIHelper.GetIconIndexForRarity(value, 0)].get_texture());
1550
			}
1551
			GUIStyle gUIStyle = new GUIStyle();
1552
			gUIStyle.get_normal().set_background(Tracker.groupTextures[card.group]);
1553
			GUI.Box(new Rect(position.get_x() + 1f, position.get_y() + 1f, 5f, position.get_height() - 2f), "", gUIStyle);
1554
			GUI.set_color(Tracker.GetCardGroupColor(card.group));
1555
			Texture texture = Tracker.iconRegistry.FindIconForAttackType(card.typeArray & 7, card.IsType(256));
1556
			bool flag = texture == null || card.power == 0;
1557
			if (flag)
1558
			{
1559
				texture = Tracker.fallbackTexture;
1560
				GUI.set_color(Color.get_white());
1561
				num2 = UserConfig.Vars.ScaleY;
1562
			}
1563
			int num3 = UserConfig.Vars.Rarity ? (15 + num + 5) : 15;
1564
			if (flag)
1565
			{
1566
				num3 -= 3;
1567
			}
1568
			GUI.DrawTexture(new Rect(position.get_x() + (float)num3, position.get_y() + (float)(flag ? 1 : 3), (float)num2, (float)num2), texture);
1569
		}
1570
1571
		public static void UpdateMovables(Vector2 mousePos)
1572
		{
1573
			bool mouseButtonUp = Input.GetMouseButtonUp(0);
1574
			FieldInfo[] fields = typeof(UserConfig.ConfigData.Movables).GetFields();
1575
			for (int i = 0; i < fields.Length; i++)
1576
			{
1577
				Movable movable = fields[i].GetValue(UserConfig.Vars.Anchors) as Movable;
1578
				movable.Update(mousePos);
1579
				if (mouseButtonUp)
1580
				{
1581
					movable.StopMoving();
1582
				}
1583
			}
1584
		}
1585
1586
		public static void DrawMovableCardList(Movable movable, string title, ref bool showToggle, bool group, List<CardTemplate> list)
1587
		{
1588
			Vector2 mousePosition = Event.get_current().get_mousePosition();
1589
			GUI.set_color(Color.get_white());
1590
			Vector2 position = movable.GetPosition();
1591
			int num = 0;
1592
			int num2 = 1;
1593
			if (Tracker.TrackerSkin.RepeatButton(new Rect(position.x, position.y + (float)((UserConfig.Vars.ScaleY + num2) * num), (float)(UserConfig.Vars.ScaleX - (UserConfig.Vars.ScaleY + num2)), (float)UserConfig.Vars.ScaleY), title, 10))
1594
			{
1595
				movable.StartMoving(mousePosition);
1596
			}
1597
			if (GUI.Button(new Rect(position.x + (float)UserConfig.Vars.ScaleX - (float)UserConfig.Vars.ScaleY, position.y + (float)((UserConfig.Vars.ScaleY + num2) * num), (float)UserConfig.Vars.ScaleY, (float)UserConfig.Vars.ScaleY), showToggle ? "-" : "+"))
1598
			{
1599
				showToggle = !showToggle;
1600
			}
1601
			if (!showToggle)
1602
			{
1603
				return;
1604
			}
1605
			num++;
1606
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
1607
			if (group)
1608
			{
1609
				foreach (CardTemplate current in list)
1610
				{
1611
					if (dictionary.Keys.Contains(current.templateId))
1612
					{
1613
						Dictionary<int, int> arg_129_0 = dictionary;
1614
						int templateId = current.templateId;
1615
						int num3 = arg_129_0[templateId];
1616
						arg_129_0[templateId] = num3 + 1;
1617
					}
1618
					else
1619
					{
1620
						dictionary[current.templateId] = 1;
1621
					}
1622
				}
1623
			}
1624
			foreach (CardTemplate current2 in list)
1625
			{
1626
				int num4 = dictionary.Keys.Contains(current2.templateId) ? dictionary[current2.templateId] : -1;
1627
				if ((group && num4 != -1) || !group)
1628
				{
1629
					Tracker.DrawCard(new Rect(position.x, position.y + (float)((UserConfig.Vars.ScaleY + num2) * num), (float)UserConfig.Vars.ScaleX, (float)UserConfig.Vars.ScaleY), current2, num4);
1630
				}
1631
				if (num4 != -1 & group)
1632
				{
1633
					dictionary.Remove(current2.templateId);
1634
					num++;
1635
				}
1636
				if (!group)
1637
				{
1638
					num++;
1639
				}
1640
			}
1641
		}
1642
1643
		public static bool Update()
1644
		{
1645
			if (!Tracker.shouldTrack)
1646
			{
1647
				return false;
1648
			}
1649
			Tracker.updateTime += Time.get_deltaTime();
1650
			if (Tracker.updateTime > 0.5f)
1651
			{
1652
				List<CardInstance> allPlayerCards = Tracker.playerController.TargetPlayer.GetAllPlayerCards();
1653
				List<CardInstance> allPlayerCards2 = Tracker.playerController.get_OtherPlayer().GetAllPlayerCards();
1654
				if (UserConfig.Vars.OpponentOverlay)
1655
				{
1656
					Tracker.opponentCards = Tracker.GetOpponentCards(allPlayerCards, allPlayerCards2);
1657
				}
1658
				if (UserConfig.Vars.DeckOverlay)
1659
				{
1660
					Tracker.deckCards = Tracker.GetDeckCards(allPlayerCards, allPlayerCards2);
1661
				}
1662
				Tracker.updateTime = 0f;
1663
			}
1664
			Tracker.UpdateMovables(Event.get_current().get_mousePosition());
1665
			return true;
1666
		}
1667
1668
		public static bool OnGUI()
1669
		{
1670
			if (!Tracker.shouldTrack)
1671
			{
1672
				return false;
1673
			}
1674
			Tracker.TrackerSkin.Initialize();
1675
			Vector2 mousePosition = Event.get_current().get_mousePosition();
1676
			if (UserConfig.Vars.DeckOverlay)
1677
			{
1678
				Tracker.DrawMovableCardList(UserConfig.Vars.Anchors.Deck, PlayerDeck.GetName(), ref UserConfig.Vars.CollapseDeck, UserConfig.Vars.GroupCards, Tracker.deckCards);
1679
			}
1680
			if (UserConfig.Vars.OpponentOverlay)
1681
			{
1682
				Tracker.DrawMovableCardList(UserConfig.Vars.Anchors.Opponent, "Opponent", ref UserConfig.Vars.CollapseOpponent, UserConfig.Vars.GroupCards, Tracker.opponentCards);
1683
			}
1684
			if (UserConfig.Vars.BanishedOverlay)
1685
			{
1686
				Tracker.DrawMovableCardList(UserConfig.Vars.Anchors.Banished, "Banished", ref UserConfig.Vars.CollapseBanished, UserConfig.Vars.GroupCards, Tracker.banishedCards);
1687
			}
1688
			GUI.set_color(Color.get_white());
1689
			foreach (RankedLeaderboardRecord current in Tracker.playerRecords)
1690
			{
1691
				Hook.WriteConsole(current.ToJSON());
1692
				Movable movable = UserConfig.Vars.Anchors.Rank1;
1693
				if (current.get_Username() == Singleton<ProfileManager>.get_Instance().get_NameToDisplay())
1694
				{
1695
					movable = UserConfig.Vars.Anchors.Rank2;
1696
				}
1697
				Vector2 position = movable.GetPosition();
1698
				if (Tracker.TrackerSkin.RepeatButton(new Rect(position.x, position.y, (float)UserConfig.Vars.ScaleX, (float)UserConfig.Vars.ScaleY), string.Concat(new object[]
1699
				{
1700
					"#",
1701
					current.get_Position(),
1702
					" with ",
1703
					current.get_Score(),
1704
					" MMR"
1705
				}), 10))
1706
				{
1707
					movable.StartMoving(mousePosition);
1708
				}
1709
			}
1710
			if (UserConfig.Vars.BaseStrengthOverlay)
1711
			{
1712
				CardSelectableObject cardSelectableObject = GwentGlobalObjectsRegistry.get_SelectionHandler().get_CurrentHighlight() as CardSelectableObject;
1713
				if (cardSelectableObject != null && cardSelectableObject.get_CardInstance() != null && !CardTypeHelper.GetContainedFlags(cardSelectableObject.get_CardInstance().get_CardType()).Contains(1024) && !Singleton<UIManager>.get_Instance().IsPanelVisible(5011))
1714
				{
1715
					int weatherSavedPower = cardSelectableObject.get_CardInstance().get_Tokens().get_PowerToken().WeatherSavedPower;
1716
					string arg = (weatherSavedPower > 0) ? (" | Without Weather: " + weatherSavedPower) : "";
1717
					Tracker.TrackerSkin.Box(new Rect((float)(Screen.get_width() / 2 - UserConfig.Vars.ScaleX / 2), (float)(Screen.get_height() / 2 - UserConfig.Vars.ScaleY / 2), (float)UserConfig.Vars.ScaleX, (float)UserConfig.Vars.ScaleY), "Base Strength: " + cardSelectableObject.get_CardInstance().GetBasePower() + arg);
1718
				}
1719
			}
1720
			if (UserConfig.Vars.StatisticOverlay)
1721
			{
1722
				TrackedDeck expr_2F2 = DeckStatistics.GetActiveDeck();
1723
				TrackedDeck.WL wLSum = expr_2F2.GetWLSum();
1724
				TrackedDeck.WL wLForFaction = expr_2F2.GetWLForFaction(Tracker.playerController.get_OtherPlayer().get_FactionId());
1725
				Vector2 position2 = UserConfig.Vars.Anchors.Statistic.GetPosition();
1726
				if (Tracker.TrackerSkin.StatisticButton(new Rect(position2.x, position2.y, (float)UserConfig.Vars.ScaleX, (float)((UserConfig.Vars.ScaleY - 5) * 2)), string.Concat(new object[]
1727
				{
1728
					"All: ",
1729
					wLSum.w,
1730
					" - ",
1731
					wLSum.l,
1732
					" (",
1733
					wLSum.GetAsPercent().ToString(),
1734
					"%)\n",
1735
					LocalizationHelper.GetFactionName(Tracker.playerController.get_OtherPlayer().get_FactionId()),
1736
					": ",
1737
					wLForFaction.w,
1738
					" - ",
1739
					wLForFaction.l,
1740
					" (",
1741
					wLForFaction.GetAsPercent().ToString(),
1742
					"%)"
1743
				})))
1744
				{
1745
					UserConfig.Vars.Anchors.Statistic.StartMoving(mousePosition);
1746
				}
1747
			}
1748
			return true;
1749
		}
1750
1751
		private static List<CardTemplate> GetOpponentCards(List<CardInstance> l1, List<CardInstance> l2)
1752
		{
1753
			int uniqueId = Tracker.playerController.get_OtherPlayer().UniqueId;
1754
			IEnumerable<CardInstance> arg_36_0 = l1.Concat(l2);
1755
			Func<CardInstance, CardGroup> arg_36_1;
1756
			if ((arg_36_1 = Tracker.<>c.<>9__24_0) == null)
1757
			{
1758
				arg_36_1 = (Tracker.<>c.<>9__24_0 = new Func<CardInstance, CardGroup>(Tracker.<>c.<>9.<GetOpponentCards>b__24_0));
1759
			}
1760
			IOrderedEnumerable<CardInstance> arg_5A_0 = arg_36_0.OrderBy(arg_36_1);
1761
			Func<CardInstance, int> arg_5A_1;
1762
			if ((arg_5A_1 = Tracker.<>c.<>9__24_1) == null)
1763
			{
1764
				arg_5A_1 = (Tracker.<>c.<>9__24_1 = new Func<CardInstance, int>(Tracker.<>c.<>9.<GetOpponentCards>b__24_1));
1765
			}
1766
			List<CardInstance> arg_6A_0 = arg_5A_0.ThenBy(arg_5A_1).ToList<CardInstance>();
1767
			List<CardTemplate> list = new List<CardTemplate>();
1768
			foreach (CardInstance current in arg_6A_0)
1769
			{
1770
				if (Tracker.OpponentCardFilter(current, uniqueId))
1771
				{
1772
					list.Add(current.get_TemplateRef());
1773
				}
1774
			}
1775
			return list;
1776
		}
1777
1778
		private static List<CardTemplate> GetDeckCards(List<CardInstance> l1, List<CardInstance> l2)
1779
		{
1780
			List<CardTemplate> list = new List<CardTemplate>();
1781
			foreach (CardInstance current in Tracker.boardManager.GetCardsInLocation(GwentGlobalObjectsRegistry.get_BottomPlayerID(), 2))
1782
			{
1783
				list.Add(current.get_TemplateRef());
1784
			}
1785
			List<CardTemplate> list2 = new List<CardTemplate>(PlayerDeck.Get());
1786
			IEnumerable<CardTemplate> arg_72_0 = list2;
1787
			Func<CardTemplate, CardGroup> arg_72_1;
1788
			if ((arg_72_1 = Tracker.<>c.<>9__25_0) == null)
1789
			{
1790
				arg_72_1 = (Tracker.<>c.<>9__25_0 = new Func<CardTemplate, CardGroup>(Tracker.<>c.<>9.<GetDeckCards>b__25_0));
1791
			}
1792
			IOrderedEnumerable<CardTemplate> arg_96_0 = arg_72_0.OrderBy(arg_72_1);
1793
			Func<CardTemplate, int> arg_96_1;
1794
			if ((arg_96_1 = Tracker.<>c.<>9__25_1) == null)
1795
			{
1796
				arg_96_1 = (Tracker.<>c.<>9__25_1 = new Func<CardTemplate, int>(Tracker.<>c.<>9.<GetDeckCards>b__25_1));
1797
			}
1798
			list2 = arg_96_0.ThenBy(arg_96_1).ToList<CardTemplate>();
1799
			int bottomPlayerID = GwentGlobalObjectsRegistry.get_BottomPlayerID();
1800
			foreach (CardInstance current2 in l1)
1801
			{
1802
				if (current2.get_Revealed() && (current2.get_PlayedBy() != Tracker.playerController.get_OtherPlayer().UniqueId || (current2.get_PlayedBy() == Tracker.playerController.get_OtherPlayer().UniqueId && current2.get_SpawningPlayer() == Tracker.playerController.TargetPlayer.UniqueId)))
1803
				{
1804
					int templateId = current2.get_OriginalDefinition().templateId;
1805
					int i = 0;
1806
					while (i < list2.Count)
1807
					{
1808
						if (list2[i].templateId == templateId)
1809
						{
1810
							if (list.Contains(current2.get_TemplateRef()))
1811
							{
1812
								list.Remove(current2.get_TemplateRef());
1813
								break;
1814
							}
1815
							list2.RemoveAt(i);
1816
							break;
1817
						}
1818
						else
1819
						{
1820
							i++;
1821
						}
1822
					}
1823
				}
1824
			}
1825
			foreach (CardInstance current3 in l2)
1826
			{
1827
				if (current3.get_Revealed() && (current3.get_PlayedBy() == bottomPlayerID || current3.get_SpawningPlayer() == bottomPlayerID))
1828
				{
1829
					int templateId2 = current3.get_OriginalDefinition().templateId;
1830
					int j = 0;
1831
					while (j < list2.Count)
1832
					{
1833
						if (list2[j].templateId == templateId2)
1834
						{
1835
							if (list.Contains(current3.get_TemplateRef()))
1836
							{
1837
								list.Remove(current3.get_TemplateRef());
1838
								break;
1839
							}
1840
							list2.RemoveAt(j);
1841
							break;
1842
						}
1843
						else
1844
						{
1845
							j++;
1846
						}
1847
					}
1848
				}
1849
			}
1850
			List<CardTemplate> arg_256_0 = list2;
1851
			Predicate<CardTemplate> arg_256_1;
1852
			if ((arg_256_1 = Tracker.<>c.<>9__25_2) == null)
1853
			{
1854
				arg_256_1 = (Tracker.<>c.<>9__25_2 = new Predicate<CardTemplate>(Tracker.<>c.<>9.<GetDeckCards>b__25_2));
1855
			}
1856
			arg_256_0.RemoveAll(arg_256_1);
1857
			Hook.WriteConsole(list.Count.ToString());
1858
			foreach (CardTemplate current4 in list)
1859
			{
1860
				if (current4.templateId != -1)
1861
				{
1862
					list2.Add(current4);
1863
				}
1864
			}
1865
			return list2;
1866
		}
1867
1868
		public static bool OpponentCardFilter(CardInstance card, int opponentId)
1869
		{
1870
			if ((card.get_CardGroup() != 1 || !UserConfig.Vars.OpponentBronze) && (card.get_CardGroup() != 2 || !UserConfig.Vars.OpponentSilver) && (card.get_CardGroup() != 3 || !UserConfig.Vars.OpponentGold))
1871
			{
1872
				return false;
1873
			}
1874
			if (CardTypeHelper.GetContainedFlags(card.get_CardType()).Contains(1024) && card.get_Tokens().get_AmbushToken().get_CurrentState() == 1)
1875
			{
1876
				return false;
1877
			}
1878
			Availability value = card.GetCardDefinition().AvailabilityWrapper.get_Value();
1879
			return card.get_Revealed() && card.get_SpawningPlayer() == opponentId && card.get_Location() != 8 && card.get_Location() != 2 && !card.IsLeader && value != null && value != 268435455;
1880
		}
1881
1882
		public static void OnAbilityWillAffect(AbilityEventInfo info)
1883
		{
1884
			if (info.SourceCard == 0uL || info.AffectedInstances == null || info.AffectedInstances.Count <= 0)
1885
			{
1886
				return;
1887
			}
1888
			int bottomPlayerID = GwentGlobalObjectsRegistry.get_BottomPlayerID();
1889
			CardInstance cardInstanceFromID = Tracker.gameController.get_CardManager().GetCardInstanceFromID(info.SourceCard);
1890
			if (cardInstanceFromID != null && (cardInstanceFromID.get_PlayedBy() == bottomPlayerID || cardInstanceFromID.get_SpawningPlayer() == bottomPlayerID))
1891
			{
1892
				Hook.WriteConsole("AbilityWillAffect: " + info.AbilityId.ToString());
1893
				if (info.AbilityId == -813761170)
1894
				{
1895
					PlayerDeck.Add(cardInstanceFromID.get_TemplateRef(), 2);
1896
				}
1897
			}
1898
		}
1899
1900
		public static void OnAbilityApplyEnded(AbilityEventInfo info)
1901
		{
1902
			if (info.SourceCard == 0uL || info.AffectedInstances == null || info.AffectedInstances.Count <= 0)
1903
			{
1904
				return;
1905
			}
1906
			int bottomPlayerID = GwentGlobalObjectsRegistry.get_BottomPlayerID();
1907
			CardInstance cardInstanceFromID = Tracker.gameController.get_CardManager().GetCardInstanceFromID(info.SourceCard);
1908
			if (cardInstanceFromID != null && info.AbilityId == -31051523)
1909
			{
1910
				CardInstance cardInstanceFromID2 = Tracker.gameController.get_CardManager().GetCardInstanceFromID(info.AffectedInstances[0]);
1911
				if (cardInstanceFromID2 != null)
1912
				{
1913
					PlayerDeck.Add(cardInstanceFromID2.get_TemplateRef(), 1);
1914
				}
1915
			}
1916
			if (cardInstanceFromID != null && (cardInstanceFromID.get_PlayedBy() == bottomPlayerID || cardInstanceFromID.get_SpawningPlayer() == bottomPlayerID))
1917
			{
1918
				Hook.WriteConsole("AbilityApplyEnded: " + info.AbilityId.ToString());
1919
				if (info.AbilityId == -372716485)
1920
				{
1921
					CardInstance cardInstanceFromID3 = Tracker.gameController.get_CardManager().GetCardInstanceFromID(info.AffectedInstances[0]);
1922
					if (cardInstanceFromID3 != null)
1923
					{
1924
						PlayerDeck.Add(cardInstanceFromID3.get_TemplateRef(), 2);
1925
					}
1926
				}
1927
				if (info.AbilityId == 1288951619 || info.AbilityId == -1505577093)
1928
				{
1929
					CardInstance cardInstanceFromID4 = Tracker.gameController.get_CardManager().GetCardInstanceFromID(info.AffectedInstances[0]);
1930
					if (cardInstanceFromID4 != null)
1931
					{
1932
						PlayerDeck.Add(cardInstanceFromID4.get_TemplateRef(), 1);
1933
					}
1934
				}
1935
				if (info.AbilityId == 1263231436)
1936
				{
1937
					foreach (ulong current in info.AffectedInstances)
1938
					{
1939
						CardInstance cardInstanceFromID5 = Tracker.gameController.get_CardManager().GetCardInstanceFromID(current);
1940
						if (cardInstanceFromID5 != null)
1941
						{
1942
							PlayerDeck.Add(cardInstanceFromID5.get_TemplateRef(), 1);
1943
						}
1944
					}
1945
				}
1946
				if (info.AbilityId == -2024648741)
1947
				{
1948
					CardInstance cardInstanceFromID6 = Tracker.gameController.get_CardManager().GetCardInstanceFromID(info.AffectedInstances[0]);
1949
					if (cardInstanceFromID6 != null)
1950
					{
1951
						PlayerDeck.Add(cardInstanceFromID6.get_TemplateRef(), 2);
1952
					}
1953
				}
1954
				if (info.AbilityId == -1862040966)
1955
				{
1956
					CardInstance cardInstanceFromID7 = Tracker.gameController.get_CardManager().GetCardInstanceFromID(info.AffectedInstances[0]);
1957
					if (cardInstanceFromID7 != null)
1958
					{
1959
						PlayerDeck.Add(cardInstanceFromID7.get_TemplateRef(), 1);
1960
					}
1961
				}
1962
				if (info.AbilityId == -733948379 || info.AbilityId == -646357120 || info.AbilityId == -281179227)
1963
				{
1964
					CardInstance cardInstanceFromID8 = Tracker.gameController.get_CardManager().GetCardInstanceFromID(info.AffectedInstances[0]);
1965
					if (cardInstanceFromID8 != null)
1966
					{
1967
						PlayerDeck.Add(cardInstanceFromID8.get_TemplateRef(), 1);
1968
						Hook.WriteConsole(cardInstanceFromID8.GetTextKey());
1969
					}
1970
				}
1971
			}
1972
		}
1973
1974
		public static void OnCardBanished(ulong[] instanceIds)
1975
		{
1976
			for (int i = 0; i < instanceIds.Length; i++)
1977
			{
1978
				ulong num = instanceIds[i];
1979
				try
1980
				{
1981
					CardInstance cardInstanceFromID = Tracker.gameController.get_CardManager().GetCardInstanceFromID(num);
1982
					if (cardInstanceFromID != null)
1983
					{
1984
						Availability value = cardInstanceFromID.GetCardDefinition().AvailabilityWrapper.get_Value();
1985
						if (value == 268435455 || value == null)
1986
						{
1987
							break;
1988
						}
1989
						if (LocalizationManager.get_Instance().GetTranslationText(cardInstanceFromID.GetTextKey()).StartsWith("#"))
1990
						{
1991
							break;
1992
						}
1993
						Tracker.banishedCards.Add(cardInstanceFromID.get_TemplateRef());
1994
					}
1995
				}
1996
				catch (Exception)
1997
				{
1998
				}
1999
			}
2000
		}
2001
2002
		private static Vector3 WorldToScreen(Vector3 worldPos)
2003
		{
2004
			Vector3 vector = Camera.get_main().WorldToScreenPoint(worldPos);
2005
			vector.y = (float)Screen.get_height() - (vector.y + vector.z) + -180f;
2006
			return vector;
2007
		}
2008
2009
		private static void DrawCardInfoDebug()
2010
		{
2011
		}
2012
2013
		private static string getB64Image()
2014
		{
2015
			return "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";
2016
		}
2017
	}
2018
}
2019
2020
//user config
2021
2022
namespace GwentHook
2023
{
2024
	internal static class UserConfig
2025
	{
2026
		[Serializable]
2027
		public class ConfigData
2028
		{
2029
			[Serializable]
2030
			public class Movables
2031
			{
2032
				public Movable Deck;
2033
2034
				public Movable Opponent;
2035
2036
				public Movable Banished;
2037
2038
				public Movable Statistic;
2039
2040
				public Movable Rank1;
2041
2042
				public Movable Rank2;
2043
2044
				public Movables()
2045
				{
2046
					int num = (int)((double)Screen.get_height() * 0.15);
2047
					this.Deck = new Movable(new Vector2((float)(Screen.get_width() - UserConfig.DefaultScaleX), (float)num));
2048
					this.Opponent = new Movable(new Vector2(0f, (float)num));
2049
					this.Banished = new Movable(new Vector2((float)(Screen.get_width() / 2 - UserConfig.DefaultScaleX / 2), (float)num));
2050
					this.Statistic = new Movable(new Vector2((float)(Screen.get_width() / 2 - UserConfig.DefaultScaleX / 2), 0f));
2051
					this.Rank1 = new Movable(new Vector2(0f, 0f));
2052
					this.Rank2 = new Movable(new Vector2(0f, (float)(Screen.get_height() - UserConfig.DefaultScaleY)));
2053
				}
2054
			}
2055
2056
			public bool AutoUpdate;
2057
2058
			public bool AutoUpdateDecision;
2059
2060
			public string InstalledVersion;
2061
2062
			public bool StartWithWindows;
2063
2064
			public bool StatisticOverlay;
2065
2066
			public bool DeckOverlay;
2067
2068
			public bool DeckBronze;
2069
2070
			public bool DeckSilver;
2071
2072
			public bool DeckGold;
2073
2074
			public bool OpponentOverlay;
2075
2076
			public bool OpponentBronze;
2077
2078
			public bool OpponentSilver;
2079
2080
			public bool OpponentGold;
2081
2082
			public bool CollapseDeck;
2083
2084
			public bool CollapseOpponent;
2085
2086
			public bool CollapseBanished;
2087
2088
			public bool Rarity;
2089
2090
			public bool BaseStrengthOverlay;
2091
2092
			public bool BanishedOverlay;
2093
2094
			public bool GroupCards;
2095
2096
			public int ScaleX;
2097
2098
			public int ScaleY;
2099
2100
			public UserConfig.ConfigData.Movables Anchors;
2101
2102
			public ConfigData()
2103
			{
2104
				this.AutoUpdate = false;
2105
				this.AutoUpdateDecision = false;
2106
				this.InstalledVersion = "0.0.0.0";
2107
				this.StartWithWindows = false;
2108
				this.StatisticOverlay = true;
2109
				this.DeckOverlay = true;
2110
				this.DeckBronze = true;
2111
				this.DeckSilver = true;
2112
				this.DeckGold = true;
2113
				this.OpponentOverlay = true;
2114
				this.OpponentBronze = true;
2115
				this.OpponentSilver = true;
2116
				this.OpponentGold = true;
2117
				this.Rarity = true;
2118
				this.BaseStrengthOverlay = true;
2119
				this.BanishedOverlay = true;
2120
				this.GroupCards = true;
2121
				this.CollapseDeck = true;
2122
				this.CollapseOpponent = true;
2123
				this.CollapseBanished = true;
2124
				this.ScaleX = UserConfig.DefaultScaleX;
2125
				this.ScaleY = UserConfig.DefaultScaleY;
2126
				this.Anchors = new UserConfig.ConfigData.Movables();
2127
			}
2128
		}
2129
2130
		private static int DefaultScaleX = 250;
2131
2132
		private static int DefaultScaleY = 26;
2133
2134
		public static UserConfig.ConfigData Vars = new UserConfig.ConfigData();
2135
2136
		private static string GetPath()
2137
		{
2138
			string expr_11 = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GwentTracker";
2139
			Directory.CreateDirectory(expr_11);
2140
			return expr_11 + "\\config.json";
2141
		}
2142
2143
		public static void Save()
2144
		{
2145
			File.WriteAllText(UserConfig.GetPath(), GwentUtil.Serialize(typeof(UserConfig.ConfigData), UserConfig.Vars));
2146
		}
2147
2148
		public static void Load()
2149
		{
2150
			try
2151
			{
2152
				UserConfig.Vars = (GwentUtil.Deserialize(typeof(UserConfig.ConfigData), File.ReadAllText(UserConfig.GetPath())) as UserConfig.ConfigData);
2153
			}
2154
			catch (Exception)
2155
			{
2156
				UserConfig.Vars = new UserConfig.ConfigData();
2157
			}
2158
		}
2159
2160
		public static void Kill()
2161
		{
2162
			UserConfig.Vars = new UserConfig.ConfigData();
2163
			UserConfig.Save();
2164
		}
2165
2166
		public static void RegisterInStartup(bool isChecked)
2167
		{
2168
			RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
2169
			if (isChecked)
2170
			{
2171
				registryKey.SetValue("Gwent Tracker", Hook.AssemblyDirectory.Replace('/', '\\') + "\\Gwent Tracker.exe");
2172
				return;
2173
			}
2174
			registryKey.DeleteValue("Gwent Tracker");
2175
		}
2176
	}
2177
}
2178
2179
//user interface
2180
2181
namespace GwentHook
2182
{
2183
	internal class UserInterface
2184
	{
2185
		public static bool visible;
2186
2187
		private static Vector2 scrollPos;
2188
2189
		private static bool initialized = false;
2190
2191
		private static GUIStyle windowStyle;
2192
2193
		private static GUIStyle verticalStyle;
2194
2195
		private static GUIStyle listButton;
2196
2197
		private static GUIStyle listButtonActive;
2198
2199
		private static int w = 400;
2200
2201
		private static int h1 = 230;
2202
2203
		private static int h2 = 190;
2204
2205
		private static int h3 = 10;
2206
2207
		private static int o = 20;
2208
2209
		private static TrackedDeck trackedDeck;
2210
2211
		private static bool startupState;
2212
2213
		public static bool Draw()
2214
		{
2215
			if (!UserInterface.visible)
2216
			{
2217
				return false;
2218
			}
2219
			int num = UserInterface.h1 + UserInterface.h2 + UserInterface.h3;
2220
			Rect rect = new Rect((float)(Screen.get_width() / 2 - UserInterface.w - UserInterface.o), (float)(Screen.get_height() / 2 - num / 2 - UserInterface.o), (float)(UserInterface.w * 2 + UserInterface.o * 2), (float)UserInterface.h2);
2221
			Rect rect2 = new Rect((float)(Screen.get_width() / 2 - UserInterface.w - UserInterface.o), (float)(Screen.get_height() / 2 - num / 2 + UserInterface.h2 + 1), (float)(UserInterface.w + UserInterface.o), (float)UserInterface.h1);
2222
			Rect rect3 = new Rect((float)(Screen.get_width() / 2), (float)(Screen.get_height() / 2 - num / 2 + UserInterface.h2 + 1), (float)(UserInterface.w + UserInterface.o), (float)UserInterface.h1);
2223
			Rect rect4 = new Rect((float)(Screen.get_width() / 2 - (UserInterface.w + UserInterface.o) / 2), (float)(Screen.get_height() / 2 - num / 2 + UserInterface.h1 + UserInterface.h2 + 1), (float)(UserInterface.w + UserInterface.o), (float)UserInterface.h3);
2224
			if (!UserInterface.initialized)
2225
			{
2226
				UserInterface.windowStyle = new GUIStyle(GUI.get_skin().get_window());
2227
				GUIStyleState arg_1FE_0 = UserInterface.windowStyle.get_normal();
2228
				GUIStyleState arg_1F7_0 = UserInterface.windowStyle.get_active();
2229
				GUIStyleState arg_1ED_0 = UserInterface.windowStyle.get_hover();
2230
				GUIStyleState arg_1E3_0 = UserInterface.windowStyle.get_focused();
2231
				GUIStyleState arg_1D9_0 = UserInterface.windowStyle.get_onActive();
2232
				GUIStyleState arg_1CF_0 = UserInterface.windowStyle.get_onNormal();
2233
				GUIStyleState arg_1C5_0 = UserInterface.windowStyle.get_onHover();
2234
				Texture2D texture2D;
2235
				UserInterface.windowStyle.get_onNormal().set_background(texture2D = Tracker.TrackerSkin.CreateBorderedButtonTexture(UserInterface.w, UserInterface.h1, Color.get_black(), new Color(0.3f, 0.3f, 0.3f, 1f)));
2236
				Texture2D texture2D2;
2237
				arg_1C5_0.set_background(texture2D2 = texture2D);
2238
				Texture2D texture2D3;
2239
				arg_1CF_0.set_background(texture2D3 = texture2D2);
2240
				Texture2D texture2D4;
2241
				arg_1D9_0.set_background(texture2D4 = texture2D3);
2242
				Texture2D texture2D5;
2243
				arg_1E3_0.set_background(texture2D5 = texture2D4);
2244
				Texture2D texture2D6;
2245
				arg_1ED_0.set_background(texture2D6 = texture2D5);
2246
				Texture2D background;
2247
				arg_1F7_0.set_background(background = texture2D6);
2248
				arg_1FE_0.set_background(background);
2249
				GUIStyleState arg_29E_0 = UserInterface.windowStyle.get_normal();
2250
				GUIStyleState arg_297_0 = UserInterface.windowStyle.get_active();
2251
				GUIStyleState arg_28D_0 = UserInterface.windowStyle.get_hover();
2252
				GUIStyleState arg_283_0 = UserInterface.windowStyle.get_focused();
2253
				GUIStyleState arg_279_0 = UserInterface.windowStyle.get_onActive();
2254
				GUIStyleState arg_26F_0 = UserInterface.windowStyle.get_onNormal();
2255
				GUIStyleState arg_265_0 = UserInterface.windowStyle.get_onHover();
2256
				Color white;
2257
				UserInterface.windowStyle.get_onNormal().set_textColor(white = Color.get_white());
2258
				Color color;
2259
				arg_265_0.set_textColor(color = white);
2260
				Color color2;
2261
				arg_26F_0.set_textColor(color2 = color);
2262
				Color color3;
2263
				arg_279_0.set_textColor(color3 = color2);
2264
				Color color4;
2265
				arg_283_0.set_textColor(color4 = color3);
2266
				Color color5;
2267
				arg_28D_0.set_textColor(color5 = color4);
2268
				Color textColor;
2269
				arg_297_0.set_textColor(textColor = color5);
2270
				arg_29E_0.set_textColor(textColor);
2271
				UserInterface.verticalStyle = new GUIStyle(GUI.get_skin().get_box());
2272
				UserInterface.listButton = new GUIStyle(GUI.get_skin().get_button());
2273
				UserInterface.listButton.get_normal().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserInterface.w, UserInterface.h2, Color.get_black(), new Color(0f, 0f, 0f, 0.5f)));
2274
				UserInterface.listButton.get_hover().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserInterface.w, UserInterface.h2, Color.get_black(), new Color(0f, 0f, 0f, 0.6f)));
2275
				UserInterface.listButton.get_active().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserInterface.w, UserInterface.h2, Color.get_black(), new Color(0f, 0f, 0f, 0.7f)));
2276
				UserInterface.listButton.get_focused().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserInterface.w, UserInterface.h2, Color.get_black(), new Color(0f, 0f, 0f, 0.8f)));
2277
				UserInterface.listButton.set_alignment(3);
2278
				UserInterface.listButtonActive = new GUIStyle(GUI.get_skin().get_button());
2279
				UserInterface.listButtonActive.get_normal().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserInterface.w, UserInterface.h2, new Color(0.5f, 0.5f, 0.5f, 0.5f), new Color(0.5f, 0.5f, 0.5f, 0.5f)));
2280
				UserInterface.listButtonActive.get_hover().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserInterface.w, UserInterface.h2, new Color(0.5f, 0.5f, 0.5f, 0.6f), new Color(0.5f, 0.5f, 0.5f, 0.6f)));
2281
				UserInterface.listButtonActive.get_active().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserInterface.w, UserInterface.h2, new Color(0.5f, 0.5f, 0.5f, 0.7f), new Color(0.5f, 0.5f, 0.5f, 0.7f)));
2282
				UserInterface.listButtonActive.get_focused().set_background(Tracker.TrackerSkin.CreateBorderedButtonTexture(UserInterface.w, UserInterface.h2, new Color(0.5f, 0.5f, 0.5f, 0.8f), new Color(0.5f, 0.5f, 0.5f, 0.8f)));
2283
				UserInterface.listButtonActive.set_alignment(3);
2284
				UserInterface.initialized = true;
2285
			}
2286
			GUILayout.Window(1337, rect2, new GUI.WindowFunction(UserInterface.DoMainWindowL), "", UserInterface.windowStyle, new GUILayoutOption[0]);
2287
			GUILayout.Window(1338, rect3, new GUI.WindowFunction(UserInterface.DoMainWindowR), "", UserInterface.windowStyle, new GUILayoutOption[0]);
2288
			GUILayout.Window(1339, rect4, new GUI.WindowFunction(UserInterface.DoBottomWindow), "", UserInterface.windowStyle, new GUILayoutOption[0]);
2289
			if (UserInterface.trackedDeck != null)
2290
			{
2291
				GUILayout.Window(1340, rect, new GUI.WindowFunction(UserInterface.DoSelectorWindow), "", UserInterface.windowStyle, new GUILayoutOption[0]);
2292
			}
2293
			return true;
2294
		}
2295
2296
		private static void DoMainWindowL(int windowID)
2297
		{
2298
			GUILayout.Space(-10f);
2299
			GUILayout.BeginVertical(UserInterface.verticalStyle, new GUILayoutOption[0]);
2300
			UserConfig.Vars.Rarity = GUILayout.Toggle(UserConfig.Vars.Rarity, " Show card rarity", new GUILayoutOption[0]);
2301
			UserConfig.Vars.BaseStrengthOverlay = GUILayout.Toggle(UserConfig.Vars.BaseStrengthOverlay, " Show base strength", new GUILayoutOption[0]);
2302
			UserConfig.Vars.StatisticOverlay = GUILayout.Toggle(UserConfig.Vars.StatisticOverlay, " Show deck statistic", new GUILayoutOption[0]);
2303
			UserConfig.Vars.BanishedOverlay = GUILayout.Toggle(UserConfig.Vars.BanishedOverlay, " Show banished cards", new GUILayoutOption[0]);
2304
			UserConfig.Vars.GroupCards = GUILayout.Toggle(UserConfig.Vars.GroupCards, " Group cards", new GUILayoutOption[0]);
2305
			UserConfig.Vars.DeckOverlay = GUILayout.Toggle(UserConfig.Vars.DeckOverlay, " Show own deck", new GUILayoutOption[0]);
2306
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
2307
			GUILayout.Space(15f);
2308
			UserConfig.Vars.DeckBronze = GUILayout.Toggle(UserConfig.Vars.DeckBronze, " Bronze", new GUILayoutOption[]
2309
			{
2310
				GUILayout.Width(80f)
2311
			});
2312
			UserConfig.Vars.DeckSilver = GUILayout.Toggle(UserConfig.Vars.DeckSilver, " Silver", new GUILayoutOption[]
2313
			{
2314
				GUILayout.Width(80f)
2315
			});
2316
			UserConfig.Vars.DeckGold = GUILayout.Toggle(UserConfig.Vars.DeckGold, " Gold", new GUILayoutOption[]
2317
			{
2318
				GUILayout.Width(80f)
2319
			});
2320
			GUILayout.EndHorizontal();
2321
			UserConfig.Vars.OpponentOverlay = GUILayout.Toggle(UserConfig.Vars.OpponentOverlay, " Show opponent cards", new GUILayoutOption[0]);
2322
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
2323
			GUILayout.Space(15f);
2324
			UserConfig.Vars.OpponentBronze = GUILayout.Toggle(UserConfig.Vars.OpponentBronze, " Bronze", new GUILayoutOption[]
2325
			{
2326
				GUILayout.Width(80f)
2327
			});
2328
			UserConfig.Vars.OpponentSilver = GUILayout.Toggle(UserConfig.Vars.OpponentSilver, " Silver", new GUILayoutOption[]
2329
			{
2330
				GUILayout.Width(80f)
2331
			});
2332
			UserConfig.Vars.OpponentGold = GUILayout.Toggle(UserConfig.Vars.OpponentGold, " Gold", new GUILayoutOption[]
2333
			{
2334
				GUILayout.Width(80f)
2335
			});
2336
			GUILayout.EndHorizontal();
2337
			GUILayout.EndVertical();
2338
		}
2339
2340
		private static void DoMainWindowR(int windowID)
2341
		{
2342
			GUILayout.Space(-10f);
2343
			GUILayout.BeginVertical(UserInterface.verticalStyle, new GUILayoutOption[0]);
2344
			GUILayout.Label("Scale X", new GUILayoutOption[0]);
2345
			UserConfig.Vars.ScaleX = (int)GUILayout.HorizontalSlider((float)UserConfig.Vars.ScaleX, 100f, 500f, new GUILayoutOption[0]);
2346
			GUILayout.Label("Scale Y", new GUILayoutOption[0]);
2347
			UserConfig.Vars.ScaleY = (int)GUILayout.HorizontalSlider((float)UserConfig.Vars.ScaleY, 16f, 46f, new GUILayoutOption[0]);
2348
			GUILayout.EndVertical();
2349
			GUILayout.Space(5f);
2350
			GUILayout.BeginVertical(UserInterface.verticalStyle, new GUILayoutOption[0]);
2351
			UserConfig.Vars.AutoUpdate = GUILayout.Toggle(UserConfig.Vars.AutoUpdate, " Enable automatic updates", new GUILayoutOption[0]);
2352
			UserConfig.Vars.StartWithWindows = GUILayout.Toggle(UserConfig.Vars.StartWithWindows, " Start with windows", new GUILayoutOption[0]);
2353
			GUILayout.EndVertical();
2354
			GUILayout.Space(5f);
2355
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
2356
			if (GUILayout.Button("Share card collection", new GUILayoutOption[0]))
2357
			{
2358
				UserInterface.OnShareCollection();
2359
			}
2360
			if (GUILayout.Button(Hook.importingDeck ? "Importing.." : "Import deck", new GUILayoutOption[0]))
2361
			{
2362
				Hook.CurrentlyNotWorking();
2363
				return;
2364
			}
2365
			GUILayout.EndHorizontal();
2366
			GUILayout.Space(5f);
2367
			if (GUILayout.Button("Reset everything (except statistics)", new GUILayoutOption[0]))
2368
			{
2369
				UserConfig.Kill();
2370
			}
2371
		}
2372
2373
		private static void DoSelectorWindow(int windowID)
2374
		{
2375
			GUILayout.Space(-10f);
2376
			GUILayout.Box("Gwent Tracker v" + Hook.version.ToString() + " - by buffy", new GUILayoutOption[0]);
2377
			GUILayout.Space(10f);
2378
			GUILayout.BeginHorizontal(UserInterface.verticalStyle, new GUILayoutOption[0]);
2379
			UserInterface.scrollPos = GUILayout.BeginScrollView(UserInterface.scrollPos, new GUILayoutOption[0]);
2380
			foreach (TrackedDeck current in DeckStatistics.GetAllDecks())
2381
			{
2382
				GUIStyle gUIStyle = UserInterface.listButton;
2383
				if (current == UserInterface.trackedDeck)
2384
				{
2385
					gUIStyle = UserInterface.listButtonActive;
2386
				}
2387
				if (GUILayout.Button(GwentUtil.GetDeckName(current.GetId()), gUIStyle, new GUILayoutOption[0]))
2388
				{
2389
					UserInterface.trackedDeck = current;
2390
				}
2391
			}
2392
			GUILayout.EndScrollView();
2393
			GUILayout.Space(20f);
2394
			GUILayout.BeginVertical(new GUILayoutOption[0]);
2395
			UserInterface.trackedDeck.trackCasual = GUILayout.Toggle(UserInterface.trackedDeck.trackCasual, " Track in casual play", new GUILayoutOption[0]);
2396
			UserInterface.trackedDeck.trackRanked = GUILayout.Toggle(UserInterface.trackedDeck.trackRanked, " Track in ranked play", new GUILayoutOption[0]);
2397
			GUILayout.Space(5f);
2398
			if (GUILayout.Button("Reset statistic", new GUILayoutOption[]
2399
			{
2400
				GUILayout.Width(137f)
2401
			}))
2402
			{
2403
				UserInterface.trackedDeck.Reset();
2404
			}
2405
			if (GUILayout.Button("Share with others", new GUILayoutOption[]
2406
			{
2407
				GUILayout.Width(137f)
2408
			}))
2409
			{
2410
				UserInterface.OnShareDeck();
2411
			}
2412
			GUILayout.EndVertical();
2413
			foreach (TrackedDeck current2 in DeckStatistics.GetAllDecks())
2414
			{
2415
				if (current2.GetId() == UserInterface.trackedDeck.GetId())
2416
				{
2417
					GUILayout.Space(10f);
2418
					GUILayout.BeginVertical(new GUILayoutOption[0]);
2419
					GUILayout.Label("All factions", new GUILayoutOption[0]);
2420
					foreach (KeyValuePair<FactionId, TrackedDeck.WL> current3 in current2.GetStats())
2421
					{
2422
						GUILayout.Label(LocalizationHelper.GetFactionName(current3.Key), new GUILayoutOption[0]);
2423
					}
2424
					GUILayout.EndVertical();
2425
					GUILayout.BeginVertical(new GUILayoutOption[0]);
2426
					TrackedDeck.WL wLSum = current2.GetWLSum();
2427
					GUILayout.Label(string.Concat(new object[]
2428
					{
2429
						" [",
2430
						wLSum.w,
2431
						" - ",
2432
						wLSum.l,
2433
						"] [",
2434
						wLSum.GetAsPercent().ToString(),
2435
						"%]"
2436
					}), new GUILayoutOption[0]);
2437
					foreach (KeyValuePair<FactionId, TrackedDeck.WL> current4 in current2.GetStats())
2438
					{
2439
						GUILayout.Label(string.Concat(new object[]
2440
						{
2441
							" [",
2442
							current4.Value.w,
2443
							" - ",
2444
							current4.Value.l,
2445
							"] [",
2446
							current4.Value.GetAsPercent().ToString(),
2447
							"%]"
2448
						}), new GUILayoutOption[0]);
2449
					}
2450
					GUILayout.EndVertical();
2451
				}
2452
			}
2453
			GUILayout.EndHorizontal();
2454
		}
2455
2456
		private static void DoBottomWindow(int windowID)
2457
		{
2458
			GUILayout.Space(-10f);
2459
			if (GUILayout.Button("Save and close", new GUILayoutOption[0]))
2460
			{
2461
				UserInterface.Hide();
2462
			}
2463
		}
2464
2465
		public static void OnShareDeck()
2466
		{
2467
			Hook.CurrentlyNotWorking();
2468
		}
2469
2470
		public static void OnShareCollection()
2471
		{
2472
			Hook.CurrentlyNotWorking();
2473
		}
2474
2475
		public static TrackedDeck GetFallbackDeck()
2476
		{
2477
			TrackedDeck result = null;
2478
			List<TrackedDeck> allDecks = DeckStatistics.GetAllDecks();
2479
			if (allDecks.Count > 0)
2480
			{
2481
				result = allDecks[0];
2482
				ulong activeDeckId = Singleton<CardsCollectionsAndDecksManager>.get_Instance().GetCollection(0).GetActiveDeckId();
2483
				foreach (TrackedDeck current in allDecks)
2484
				{
2485
					if (current.GetId() == activeDeckId)
2486
					{
2487
						result = current;
2488
						break;
2489
					}
2490
				}
2491
			}
2492
			return result;
2493
		}
2494
2495
		public static void Show()
2496
		{
2497
			UserInterface.visible = true;
2498
			InputManager.get_Instance().set_enabled(false);
2499
			UserInterface.startupState = UserConfig.Vars.StartWithWindows;
2500
			UserInterface.trackedDeck = UserInterface.GetFallbackDeck();
2501
		}
2502
2503
		public static void Hide()
2504
		{
2505
			UserInterface.visible = false;
2506
			InputManager.get_Instance().set_enabled(true);
2507
			UserConfig.Save();
2508
			if (UserConfig.Vars.StartWithWindows != UserInterface.startupState)
2509
			{
2510
				UserConfig.RegisterInStartup(UserConfig.Vars.StartWithWindows);
2511
			}
2512
		}
2513
	}
2514
}