-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainWindow.xaml.cs
1461 lines (1370 loc) · 54.4 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Decompiled with JetBrains decompiler
// Type: Wave.MainWindow
// Assembly: Wave, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 33553988-2CCE-4180-BC86-D1681DD7B18E
// Assembly location: D:\e\shadow\WaveTrial\Wave.exe
using CefSharp;
using CefSharp.Wpf;
using Microsoft.Win32;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SynapseXtra;
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Timers;
using System.Web;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Wave.Classes.Cosmetic;
using Wave.Classes.Implementations;
using Wave.Classes.Passive;
using Wave.Classes.WebSockets;
using Wave.Controls;
using Wave.Controls.AI;
using Wave.Controls.Settings;
#nullable disable
namespace Wave
{
public partial class MainWindow : Window, IComponentConnector, IStyleConnector
{
private readonly string fullscreenPath = "M200-200h80q17 0 28.5 11.5T320-160q0 17-11.5 28.5T280-120H160q-17 0-28.5-11.5T120-160v-120q0-17 11.5-28.5T160-320q17 0 28.5 11.5T200-280v80Zm560 0v-80q0-17 11.5-28.5T800-320q17 0 28.5 11.5T840-280v120q0 17-11.5 28.5T800-120H680q-17 0-28.5-11.5T640-160q0-17 11.5-28.5T680-200h80ZM200-760v80q0 17-11.5 28.5T160-640q-17 0-28.5-11.5T120-680v-120q0-17 11.5-28.5T160-840h120q17 0 28.5 11.5T320-800q0 17-11.5 28.5T280-760h-80Zm560 0h-80q-17 0-28.5-11.5T640-800q0-17 11.5-28.5T680-840h120q17 0 28.5 11.5T840-800v120q0 17-11.5 28.5T800-640q-17 0-28.5-11.5T760-680v-80Z";
private readonly string exitFullscreenPath = "M240-240h-80q-17 0-28.5-11.5T120-280q0-17 11.5-28.5T160-320h120q17 0 28.5 11.5T320-280v120q0 17-11.5 28.5T280-120q-17 0-28.5-11.5T240-160v-80Zm480 0v80q0 17-11.5 28.5T680-120q-17 0-28.5-11.5T640-160v-120q0-17 11.5-28.5T680-320h120q17 0 28.5 11.5T840-280q0 17-11.5 28.5T800-240h-80ZM240-720v-80q0-17 11.5-28.5T280-840q17 0 28.5 11.5T320-800v120q0 17-11.5 28.5T280-640H160q-17 0-28.5-11.5T120-680q0-17 11.5-28.5T160-720h80Zm480 0h80q17 0 28.5 11.5T840-680q0 17-11.5 28.5T800-640H680q-17 0-28.5-11.5T640-680v-120q0-17 11.5-28.5T680-840q17 0 28.5 11.5T720-800v80Z";
private WindowState previousWindowState;
private bool isTransferredToUI;
private int? selectedProcessId;
private readonly Dictionary<string, int> notifications = new Dictionary<string, int>();
private Storyboard currentNotification;
private bool isNotifying;
private int tabReferences;
private readonly AIChat aiChat;
private bool isAIPanelOpen = true;
private int aiReferences;
private bool isSearching;
private string lastQuery;
private int currentPage = 1;
private int totalPages = 1;
private Advertisement currentAdvertisement;
private readonly Timer saveTabTimer = new Timer(60000.0);
internal MainWindow HomeWindow;
internal Grid InvisiGrid;
internal Border MainBorder;
internal Grid MainGrid;
internal Grid MainContainer;
internal BlurEffect MainBlur;
internal Grid TopGrid;
internal Rectangle TopSeparator;
internal DockPanel TopPanel;
internal Button CloseButton;
internal Button MaximiseButton;
internal Button MinimiseButton;
internal Image BloomIcon;
internal Grid SideGrid;
internal Rectangle SideSeparator;
internal StackPanel SidePanel;
internal TabCheckBox HomeButton;
internal TabCheckBox EditorButton;
internal TabCheckBox ScriptsButton;
internal TabCheckBox SettingsButton;
internal Grid TabContainer;
internal Grid HomeTab;
internal Grid EditorTab;
internal Rectangle AISeparator;
internal Rectangle EditorSeparator;
internal StackPanel EditorButtonPanel;
internal Button SelectedProcessButton;
internal Button OpenFileButton;
internal Button SaveFileButton;
internal Button ClearButton;
internal Button ExecuteButton;
internal Button AIToggleButton;
internal ScrollViewer AIChatScroll;
internal StackPanel AIChatPanel;
internal AIBotMessage LoadingAI;
internal Rectangle TabSeparator;
internal Grid AIInputGrid;
internal System.Windows.Shapes.Path AIInputPath;
internal TextBox AIInput;
internal TabControl ScriptTabs;
internal Grid ScriptsTab;
internal TextBox SearchQuery;
internal Button SearchBtn;
internal ScrollViewer SearchResultScroll;
internal WrapPanel SearchResultPanel;
internal Button NextPageBtn;
internal Button PreviousPageBtn;
internal Button ScriptBloxCredits;
internal Border CurrentPageBorder;
internal Label CurrentPageLabel;
internal Grid SettingsTab;
internal Rectangle SettingsSeparator;
internal StackPanel SettingsHeaderStack;
internal Button ExecutorHeaderButton;
internal Button EditorHeaderButton;
internal Button AIHeaderButton;
internal ScrollViewer SettingsScroll;
internal StackPanel SettingsStack;
internal Grid ExecutorHeader;
internal System.Windows.Shapes.Path ExecutorHeaderPath;
internal Label ExecutorHeaderLabel;
internal SettingCheckBox MultiInstance;
internal SettingCheckBox AutoExecute;
internal SettingCheckBox SaveTabs;
internal SettingCheckBox TopMost;
internal Grid EditorHeader;
internal System.Windows.Shapes.Path EditorHeaderPath;
internal Label EditorHeaderLabel;
internal SettingSlider EditorRefreshRate;
internal SettingSlider EditorTextSize;
internal SettingCheckBox ShowMinimap;
internal SettingCheckBox ShowInlayHints;
internal Grid AIHeader;
internal System.Windows.Shapes.Path AIHeaderPath;
internal Label AIHeaderLabel;
internal SettingCheckBox UseConversationHistory;
internal SettingCheckBox AppendCurrentScript;
internal SettingButton ClearConversationHistory;
internal Border NotificationBorder;
internal Grid NotificationGrid;
internal TextBlock NotificationContent;
internal Border DurationIndicator;
internal Button CloseNotificationButton;
internal Grid InstancePopupGrid;
internal Border InstanceBorder;
internal Grid InstanceGrid;
internal Grid InstanceTopGrid;
internal Rectangle InstanceTopSeparator;
internal Button CloseInstanceButton;
internal Label InstanceTitle;
internal ScrollViewer InstanceScroll;
internal StackPanel InstanceStack;
internal Border InstanceBackgroundBorder;
internal Grid LoginPopupGrid;
internal Border LoginBorder;
internal Border LoginBackgroundBorder;
internal Border AdBorder;
internal Grid AdGrid;
internal Button CloseAdButton;
private bool _contentLoaded;
private void DoNotification()
{
this.isNotifying = true;
KeyValuePair<string, int> keyValuePair = this.notifications.First<KeyValuePair<string, int>>();
this.notifications.Remove(keyValuePair.Key);
this.NotificationContent.Text = keyValuePair.Key;
this.DurationIndicator.Width = 0.0;
this.currentNotification = Wave.Classes.Cosmetic.Animation.Animate(new AnimationPropertyBase((object) this.NotificationBorder)
{
Property = (object) FrameworkElement.WidthProperty,
To = (object) 280
}, new AnimationPropertyBase((object) this.DurationIndicator)
{
Property = (object) FrameworkElement.WidthProperty,
To = (object) 278,
Duration = new Duration(TimeSpan.FromMilliseconds((double) keyValuePair.Value)),
DisableEasing = true
});
this.currentNotification.Completed += (EventHandler) ((sender, e) => this.CloseNotification());
}
private void CloseNotification()
{
Wave.Classes.Cosmetic.Animation.Animate(new AnimationPropertyBase((object) this.NotificationBorder)
{
Property = (object) FrameworkElement.WidthProperty,
To = (object) 0
}, new AnimationPropertyBase((object) this.DurationIndicator)
{
Property = (object) FrameworkElement.WidthProperty,
To = (object) 0
}).Completed += (EventHandler) (async (sender2, e2) =>
{
if (this.notifications.Count > 0)
{
await Task.Delay(250);
this.DoNotification();
}
else
this.isNotifying = false;
});
}
private void PopupNotification(string message, int duration = 2500)
{
this.notifications.Add(message, duration);
if (this.isNotifying)
return;
Application.Current.Dispatcher.Invoke((Action) (() => this.DoNotification()));
}
private void NewTab(string tabName = "x", string content = "print('Hello World!');", bool autoSave = true)
{
if (tabName == "x")
{
++this.tabReferences;
tabName = "Tab " + this.tabReferences.ToString() + ".lua";
}
TabItem tabItem = new TabItem();
tabItem.BorderThickness = new Thickness(0.0);
tabItem.FontFamily = new FontFamily("SF Pro");
tabItem.FontSize = 14.0;
tabItem.Foreground = (Brush) new SolidColorBrush(Colors.Gainsboro);
tabItem.Header = (object) tabName;
tabItem.Height = 40.0;
tabItem.Margin = new Thickness(-2.0, -2.0, -2.0, 0.0);
TabItem newItem = tabItem;
ChromiumWebBrowser chromiumWebBrowser = new ChromiumWebBrowser();
chromiumWebBrowser.BorderThickness = new Thickness(0.0);
ChromiumWebBrowser newBrowser = chromiumWebBrowser;
newBrowser.FrameLoadEnd += (EventHandler<FrameLoadEndEventArgs>) (async (sender, e) =>
{
await Task.Delay(1000);
newBrowser.ExecuteScriptAsync("\r\n window.setText('" + HttpUtility.JavaScriptStringEncode(content) + "');\r\n window.updateOptions({\r\n minimap: {\r\n enabled: " + Wave.Classes.Passive.Settings.Instance.ShowMinimap.ToString().ToLower() + "\r\n },\r\n inlayHints: {\r\n enabled: " + Wave.Classes.Passive.Settings.Instance.ShowInlayHints.ToString().ToLower() + "\r\n },\r\n fontSize: " + Wave.Classes.Passive.Settings.Instance.EditorTextSize.ToString() + "\r\n });\r\n ");
newBrowser.GetBrowserHost().WindowlessFrameRate = Wave.Classes.Passive.Settings.Instance.EditorRefreshRate;
if (!(Wave.Classes.Passive.Settings.Instance.SaveTabs & autoSave))
return;
Application.Current.Dispatcher.Invoke((Action) (() => this.AutoSaveTabs()));
});
newItem.Content = (object) newBrowser;
newBrowser.Load("http://localhost:1111");
newItem.IsSelected = true;
this.ScriptTabs.Items.Add((object) newItem);
}
private void RemoveTab(string tabName)
{
if (this.ScriptTabs.Items.Count <= 1)
return;
foreach (TabItem removeItem in (IEnumerable) this.ScriptTabs.Items)
{
if ((string) removeItem.Header == tabName)
{
this.ScriptTabs.Items.Remove((object) removeItem);
break;
}
}
string path = "data/tabs/" + tabName;
if (File.Exists(path))
File.Delete(path);
((TabItem) this.ScriptTabs.Items[0]).IsSelected = true;
}
private async void AutoSaveTabs()
{
foreach (string file in Directory.GetFiles("data/tabs"))
File.Delete(file);
TabItem[] tabItemArray = this.ScriptTabs.Items.Cast<TabItem>().ToArray<TabItem>();
for (int index = 0; index < tabItemArray.Length; ++index)
{
TabItem tabItem = tabItemArray[index];
ChromiumWebBrowser content = (ChromiumWebBrowser) tabItem.Content;
if (content.CanExecuteJavascriptInMainFrame)
{
object result = (await content.EvaluateScriptAsync("window.getText();", new TimeSpan?(), false)).Result;
if (result != null)
File.WriteAllText(Environment.CurrentDirectory + "/data/tabs/" + tabItem.Header?.ToString(), result.ToString());
}
tabItem = (TabItem) null;
}
tabItemArray = (TabItem[]) null;
}
private async void SendAIMessage(string message)
{
this.PopupNotification("This is just a preview, AI is disabled for now ;)", 4000);
}
private string GetApiLink(string query, int page)
{
return query == "" ? "https://scriptblox.com/api/script/fetch?page=" + page.ToString() : "https://scriptblox.com/api/script/search?filters=free&page=" + page.ToString() + "&q=" + query;
}
private void SetCurrentPage(int page)
{
this.currentPage = page;
this.CurrentPageLabel.Content = (object) ("Page " + page.ToString() + "/" + this.totalPages.ToString());
}
private async void SearchScripts(string query = "", int page = 1)
{
MainWindow mainWindow1 = this;
if (mainWindow1.isSearching)
return;
mainWindow1.isSearching = true;
mainWindow1.lastQuery = query;
try
{
mainWindow1.SearchResultPanel.Children.Clear();
using (HttpClient client = new HttpClient())
{
JToken jtoken = JToken.Parse(await (await client.GetAsync(mainWindow1.GetApiLink(query, page))).Content.ReadAsStringAsync())[(object) "result"];
foreach (ScriptObject scriptObject1 in JsonConvert.DeserializeObject<ScriptObject[]>(jtoken[(object) "scripts"].ToString()))
{
MainWindow mainWindow = mainWindow1;
ScriptObject scriptObject = scriptObject1;
ScriptResult element = new ScriptResult(scriptObject);
((ButtonBase) element.FindName("ExecuteButton")).Click += (RoutedEventHandler) (async (sender, e) =>
{
string script = await scriptObject.GetScript();
if (mainWindow.InstanceStack.Children.Count > 1)
{
foreach (InstancePanel child in mainWindow.InstanceStack.Children)
child.Script = script;
mainWindow.AnimatePopupIn(mainWindow.InstancePopupGrid);
}
else
Roblox.ExecuteAll(script);
});
mainWindow1.SearchResultPanel.Children.Add((UIElement) element);
}
mainWindow1.totalPages = Math.Max((int) jtoken[(object) "totalPages"], 1);
}
mainWindow1.SetCurrentPage(page);
}
catch (Exception ex)
{
int num = (int) MessageBox.Show(ex.Message);
}
finally
{
mainWindow1.isSearching = false;
}
}
private void ShowAdPane()
{
if (this.AdBorder.Visibility == Visibility.Collapsed)
{
this.MainBorder.Margin = new Thickness(4.0, 4.0, 4.0, 124.0);
this.Height += 120.0;
this.AdBorder.Visibility = Visibility.Visible;
}
this.MinHeight = 570.0;
}
private void HideAdPane()
{
this.MinHeight = 450.0;
if (this.AdBorder.Visibility != Visibility.Visible)
return;
this.AdBorder.Visibility = Visibility.Collapsed;
this.MainBorder.Margin = new Thickness(4.0, 4.0, 4.0, 4.0);
this.Height -= 120.0;
}
private void LoadAd()
{
this.currentAdvertisement = Advertisements.GetAdvertisement();
this.AdBorder.Background = (Brush) new ImageBrush()
{
ImageSource = (ImageSource) new BitmapImage(new Uri("pack://application:,,,/Wave;component" + this.currentAdvertisement.localImageLink, UriKind.Absolute))
};
this.ShowAdPane();
}
private void InitializeAds()
{
this.LoadAd();
Timer timer = new Timer(300000.0);
timer.Elapsed += (ElapsedEventHandler) ((sender, e) => Application.Current.Dispatcher.Invoke((Action) (() => this.LoadAd())));
timer.Start();
}
private Storyboard AnimatePopupIn(Grid popupGrid)
{
popupGrid.Opacity = 0.0;
popupGrid.Visibility = Visibility.Visible;
Storyboard storyboard = Wave.Classes.Cosmetic.Animation.Animate(new AnimationPropertyBase((object) popupGrid)
{
Property = (object) UIElement.OpacityProperty,
To = (object) 1
});
BlurEffect mainBlur = this.MainBlur;
DependencyProperty radiusProperty = BlurEffect.RadiusProperty;
DoubleAnimation animation = new DoubleAnimation();
animation.To = new double?(8.0);
animation.Duration = (Duration) TimeSpan.FromSeconds(0.35);
mainBlur.BeginAnimation(radiusProperty, (AnimationTimeline) animation);
return storyboard;
}
private Storyboard AnimatePopupOut(Grid popupGrid)
{
Storyboard storyboard = Wave.Classes.Cosmetic.Animation.Animate(new AnimationPropertyBase((object) popupGrid)
{
Property = (object) UIElement.OpacityProperty,
To = (object) 0
});
BlurEffect mainBlur = this.MainBlur;
DependencyProperty radiusProperty = BlurEffect.RadiusProperty;
DoubleAnimation animation = new DoubleAnimation();
animation.To = new double?(0.0);
animation.Duration = (Duration) TimeSpan.FromSeconds(0.35);
mainBlur.BeginAnimation(radiusProperty, (AnimationTimeline) animation);
storyboard.Completed += (EventHandler) ((sender, e) => popupGrid.Visibility = Visibility.Collapsed);
return storyboard;
}
private async void InitiateLogin()
{
if (await this.ValidateLogin())
this.TransferToUI();
else
this.AnimatePopupIn(this.LoginPopupGrid);
}
private async Task<bool> ValidateLogin()
{
bool flag;
return flag;
}
private void TransferToUI()
{
this.LoginPopupGrid.Visibility = Visibility.Collapsed;
WebSocketCollection.AddSocket("clientInformation", 6001).AddBehaviour<ClientInformationBehavior>("/transferClientInformation");
foreach (KeyValuePair<string, WebSocket> socket in WebSocketCollection.Sockets)
socket.Value.Server.Start();
Roblox.OnProcessFound += (EventHandler<RobloxInstanceEventArgs>) ((sender2, e2) =>
{
if (e2.AlreadyOpen)
return;
this.PopupNotification("Attaching...");
});
Roblox.OnProcessAdded += (EventHandler<RobloxInstanceEventArgs>) ((sender2, e2) =>
{
if (!e2.AlreadyOpen)
this.PopupNotification("Attached!");
Application.Current.Dispatcher.Invoke<Task>((Func<Task>) (async () =>
{
InstancePanel instancePanel = new InstancePanel()
{
Margin = new Thickness(4.0, 2.0, 4.0, 2.0),
Width = double.NaN,
ProcessID = e2.Id
};
Task.Run((Func<Task>) (async () =>
{
InstancePanel instancePanel2 = instancePanel;
instancePanel2.Script = (await ((IChromiumWebBrowserBase) this.ScriptTabs.SelectedContent).EvaluateScriptAsync("window.getText();", new TimeSpan?(), false)).Result.ToString();
instancePanel2 = (InstancePanel) null;
}));
((ButtonBase) instancePanel.FindName("SelectButton")).Click += (RoutedEventHandler) ((sender3, e3) => this.UpdateSelectedProcessID(new int?(e2.Id), instancePanel.Username));
this.InstanceStack.Children.Add((UIElement) instancePanel);
if (this.InstanceStack.Children.Count != 1)
;
else
{
while (instancePanel.Username == "Username")
await Task.Delay(250);
this.UpdateSelectedProcessID(new int?(e2.Id), instancePanel.Username);
}
}));
});
Roblox.OnProcessRemoved += (EventHandler<RobloxInstanceEventArgs>) ((sender2, e2) =>
{
foreach (InstancePanel child in this.InstanceStack.Children)
{
if (child.ProcessID == e2.Id)
{
this.InstanceStack.Children.Remove((UIElement) child);
break;
}
}
if (this.InstanceStack.Children.Count == 0)
{
this.UpdateSelectedProcessID(new int?(), (string) null);
}
else
{
int? selectedProcessId = this.selectedProcessId;
int id = e2.Id;
if (!(selectedProcessId.GetValueOrDefault() == id & selectedProcessId.HasValue))
return;
this.UpdateSelectedProcessID(new int?(((InstancePanel) this.InstanceStack.Children[0]).ProcessID), ((InstancePanel) this.InstanceStack.Children[0]).Username);
}
});
Roblox.OnProcessInformationGained += (EventHandler<DetailedRobloxInstanceEventArgs>) ((sender2, e2) => Application.Current.Dispatcher.Invoke((Action) (() =>
{
foreach (InstancePanel child in this.InstanceStack.Children)
{
if (child.ProcessID == e2.ProcessId)
{
child.Username = e2.Username;
child.UserID = e2.UserId;
}
}
})));
Roblox.Start();
this.MultiInstance.IsChecked = Wave.Classes.Passive.Settings.Instance.MultiInstance;
this.AutoExecute.IsChecked = Wave.Classes.Passive.Settings.Instance.AutoExecute;
this.SaveTabs.IsChecked = Wave.Classes.Passive.Settings.Instance.SaveTabs;
this.TopMost.IsChecked = Wave.Classes.Passive.Settings.Instance.TopMost;
this.EditorRefreshRate.Value = (double) Wave.Classes.Passive.Settings.Instance.EditorRefreshRate;
this.EditorTextSize.Value = Wave.Classes.Passive.Settings.Instance.EditorTextSize;
this.ShowMinimap.IsChecked = Wave.Classes.Passive.Settings.Instance.ShowMinimap;
this.ShowInlayHints.IsChecked = Wave.Classes.Passive.Settings.Instance.ShowInlayHints;
this.UseConversationHistory.IsChecked = Wave.Classes.Passive.Settings.Instance.UseConversationHistory;
this.AppendCurrentScript.IsChecked = Wave.Classes.Passive.Settings.Instance.AppendCurrentScript;
this.saveTabTimer.Elapsed += (ElapsedEventHandler) ((sender2, e2) =>
{
if (!Wave.Classes.Passive.Settings.Instance.SaveTabs)
return;
Application.Current.Dispatcher.Invoke((Action) (() => this.AutoSaveTabs()));
});
string[] allowedExtensions = new string[3]
{
".lua",
".luau",
".txt"
};
string[] array = ((IEnumerable<string>) Directory.GetFiles("data/tabs")).Where<string>((Func<string, bool>) (s => ((IEnumerable<string>) allowedExtensions).Contains<string>(System.IO.Path.GetExtension(s).ToLowerInvariant()))).ToArray<string>();
if (array.Length != 0)
{
foreach (string path in array)
{
string fileName = System.IO.Path.GetFileName(path);
Match match1 = Regex.Match(fileName, "Tab (\\d+).lua");
if (match1.Success)
{
int num = int.Parse(match1.Groups[1].Value);
if (num > this.tabReferences)
this.tabReferences = num;
}
Match match2 = Regex.Match(fileName, "AI Reference (\\d+).lua");
if (match2.Success)
{
int num = int.Parse(match2.Groups[1].Value);
if (num > this.aiReferences)
this.aiReferences = num;
}
this.NewTab(fileName, File.ReadAllText(path), false);
}
}
else
this.NewTab();
this.InitializeAds();
this.SearchScripts();
this.Topmost = this.TopMost.IsChecked;
this.isTransferredToUI = true;
}
public override void OnApplyTemplate()
{
HwndSource.FromHwnd(new WindowInteropHelper((Window) this).Handle).AddHook(new HwndSourceHook(MainWindow.WindowProc));
}
private static IntPtr WindowProc(
IntPtr hwnd,
int msg,
IntPtr wParam,
IntPtr lParam,
ref bool handled)
{
if (msg == 36)
{
MainWindow.WmGetMinMaxInfo(hwnd, lParam);
handled = false;
}
return (IntPtr) 0;
}
private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
{
MainWindow.MINMAXINFO structure = (MainWindow.MINMAXINFO) Marshal.PtrToStructure(lParam, typeof (MainWindow.MINMAXINFO));
int flags = 2;
IntPtr hMonitor = MainWindow.MonitorFromWindow(hwnd, flags);
if (hMonitor != IntPtr.Zero)
{
MainWindow.MONITORINFO lpmi = new MainWindow.MONITORINFO();
MainWindow.GetMonitorInfo(hMonitor, lpmi);
MainWindow.RECT rcWork = lpmi.rcWork;
MainWindow.RECT rcMonitor = lpmi.rcMonitor;
structure.ptMaxPosition.x = Math.Abs(rcWork.left - rcMonitor.left);
structure.ptMaxPosition.y = Math.Abs(rcWork.top - rcMonitor.top);
structure.ptMaxSize.x = Math.Abs(rcWork.right - rcWork.left);
structure.ptMaxSize.y = Math.Abs(rcWork.bottom - rcWork.top);
}
Marshal.StructureToPtr<MainWindow.MINMAXINFO>(structure, lParam, true);
}
[DllImport("user32")]
internal static extern bool GetMonitorInfo(IntPtr hMonitor, MainWindow.MONITORINFO lpmi);
[DllImport("user32.dll")]
private static extern bool GetCursorPos(ref Point lpPoint);
[DllImport("User32")]
internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
private void UpdateSelectedProcessID(int? id, string username)
{
this.selectedProcessId = id;
this.SelectedProcessButton.Content = (object) username;
this.SelectedProcessButton.Visibility = !id.HasValue ? Visibility.Collapsed : Visibility.Visible;
}
public MainWindow()
{
MainWindow mainWindow = this;
this.InitializeComponent();
this.previousWindowState = this.WindowState;
this.InstancePopupGrid.Visibility = Visibility.Collapsed;
this.SelectedProcessButton.Visibility = Visibility.Collapsed;
KeyValuePair<TabCheckBox, Grid>[] tabCheckBoxes = new KeyValuePair<TabCheckBox, Grid>[4]
{
new KeyValuePair<TabCheckBox, Grid>(this.HomeButton, this.HomeTab),
new KeyValuePair<TabCheckBox, Grid>(this.EditorButton, this.EditorTab),
new KeyValuePair<TabCheckBox, Grid>(this.ScriptsButton, this.ScriptsTab),
new KeyValuePair<TabCheckBox, Grid>(this.SettingsButton, this.SettingsTab)
};
foreach (KeyValuePair<TabCheckBox, Grid> keyValuePair1 in tabCheckBoxes)
{
KeyValuePair<TabCheckBox, Grid> tab = keyValuePair1;
tab.Value.Visibility = Visibility.Collapsed;
TabCheckBox checkBox = tab.Key;
checkBox.OnEnabled += (EventHandler) ((sender, e) =>
{
checkBox.CanToggle = false;
tab.Value.Visibility = Visibility.Visible;
foreach (KeyValuePair<TabCheckBox, Grid> keyValuePair2 in tabCheckBoxes)
{
TabCheckBox key = keyValuePair2.Key;
if (key.Enabled && key != checkBox)
{
key.CanToggle = true;
key.Enabled = false;
}
}
});
checkBox.OnDisabled += (EventHandler) ((sender, e) => tab.Value.Visibility = Visibility.Collapsed);
}
KeyValuePair<Button, Grid>[] keyValuePairArray = new KeyValuePair<Button, Grid>[3]
{
new KeyValuePair<Button, Grid>(this.ExecutorHeaderButton, this.ExecutorHeader),
new KeyValuePair<Button, Grid>(this.EditorHeaderButton, this.EditorHeader),
new KeyValuePair<Button, Grid>(this.AIHeaderButton, this.AIHeader)
};
foreach (KeyValuePair<Button, Grid> keyValuePair in keyValuePairArray)
{
KeyValuePair<Button, Grid> settingsCategory = keyValuePair;
settingsCategory.Key.Click += (RoutedEventHandler) ((sender, e) => closure_0.SettingsScroll.ScrollToVerticalOffset(settingsCategory.Value.TranslatePoint(new Point(), (UIElement) closure_0.SettingsStack).Y));
}
this.LoginPopupGrid.Opacity = 0.0;
this.MainBlur.Radius = 0.0;
this.NotificationBorder.Width = 0.0;
this.HideAdPane();
tabCheckBoxes[1].Key.Enabled = true;
this.aiChat = new AIChat();
}
private void HomeWindow_Loaded(object sender, RoutedEventArgs e) => this.InitiateLogin();
private void HomeWindow_Closing(object sender, CancelEventArgs e)
{
if (!Wave.Classes.Passive.Settings.Instance.SaveTabs)
return;
this.AutoSaveTabs();
}
private void HomeWindow_SourceInitialized(object sender, EventArgs e)
{
HwndSource.FromHwnd(new WindowInteropHelper((Window) this).Handle).AddHook(new HwndSourceHook(MainWindow.WindowProc));
}
private void HomeWindow_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton != MouseButton.Left)
return;
try
{
this.DragMove();
}
catch
{
}
}
private void HomeWindow_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.WindowState == this.previousWindowState)
return;
this.previousWindowState = this.WindowState;
this.MaximiseButton.Content = this.WindowState == WindowState.Maximized ? (object) this.exitFullscreenPath : (object) this.fullscreenPath;
}
private void CloseButton_Click(object sender, RoutedEventArgs e) => Environment.Exit(0);
private void MaximiseButton_Click(object sender, RoutedEventArgs e)
{
this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
}
private void MinimiseButton_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void NewTabButton_Click(object sender, RoutedEventArgs e) => this.NewTab();
private void CloseTabButton_Click(object sender, RoutedEventArgs e)
{
this.RemoveTab((string) ((HeaderedContentControl) ((FrameworkElement) sender).TemplatedParent).Header);
}
private void TabHeaderScroll_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (e.ExtentWidthChange <= 0.0)
return;
((ScrollViewer) sender).ScrollToRightEnd();
}
private async void ExecuteButton_Click(object sender, RoutedEventArgs e)
{
if (!this.selectedProcessId.HasValue)
return;
int[] processIds = new int[1]
{
this.selectedProcessId.Value
};
Roblox.ExecuteSpecific(processIds, (await ((IChromiumWebBrowserBase) this.ScriptTabs.SelectedContent).EvaluateScriptAsync("window.getText();", new TimeSpan?(), false)).Result.ToString());
processIds = (int[]) null;
}
private void ClearButton_Click(object sender, RoutedEventArgs e)
{
((IChromiumWebBrowserBase) this.ScriptTabs.SelectedContent).ExecuteScriptAsync("window.setText('');");
}
private void OpenFileButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title = "Wave - Open Script";
openFileDialog1.Filter = "Lua Script|*.lua|Text File|*.txt";
OpenFileDialog openFileDialog2 = openFileDialog1;
bool? nullable = openFileDialog2.ShowDialog();
bool flag = true;
if (!(nullable.GetValueOrDefault() == flag & nullable.HasValue))
return;
this.NewTab(System.IO.Path.GetFileName(openFileDialog2.FileName), File.ReadAllText(openFileDialog2.FileName));
}
private async void SaveFileButton_Click(object sender, RoutedEventArgs e)
{
Encoding encoding = Encoding.UTF8;
byte[] bytes = encoding.GetBytes((await ((IChromiumWebBrowserBase) this.ScriptTabs.SelectedContent).EvaluateScriptAsync("window.getText();", new TimeSpan?(), false)).Result.ToString());
encoding = (Encoding) null;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Title = "Wave - Save Script";
saveFileDialog1.Filter = "Lua Script|*.lua";
SaveFileDialog saveFileDialog2 = saveFileDialog1;
bool? nullable = saveFileDialog2.ShowDialog();
bool flag = true;
if (!(nullable.GetValueOrDefault() == flag & nullable.HasValue))
return;
FileStream fileStream = (FileStream) saveFileDialog2.OpenFile();
fileStream.Write(bytes, 0, bytes.Length);
fileStream.Close();
}
private void AIToggleButton_Click(object sender, RoutedEventArgs e)
{
this.isAIPanelOpen = !this.isAIPanelOpen;
Wave.Classes.Cosmetic.Animation.Animate(new AnimationPropertyBase((object) this.AIChatScroll)
{
Property = (object) FrameworkElement.WidthProperty,
To = (object) (this.isAIPanelOpen ? 216 : 0)
}, new AnimationPropertyBase((object) this.AIInputGrid)
{
Property = (object) FrameworkElement.WidthProperty,
To = (object) (this.isAIPanelOpen ? 216 : 0)
});
}
private void AIInput_GotFocus(object sender, RoutedEventArgs e) => this.AIInput.Text = "";
private void AIInput_LostFocus(object sender, RoutedEventArgs e)
{
this.AIInput.Text = "Send a message...";
}
private void AIInput_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.Return)
return;
if (this.AIInput.Text.Length > 0)
this.SendAIMessage(this.AIInput.Text);
FocusManager.SetFocusedElement(FocusManager.GetFocusScope((DependencyObject) this.AIInput), (IInputElement) null);
Keyboard.ClearFocus();
this.AIInput.Text = "Send a message...";
}
private void SearchQuery_GotFocus(object sender, RoutedEventArgs e)
{
this.SearchQuery.Text = "";
}
private void SearchQuery_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.Return)
return;
FocusManager.SetFocusedElement(FocusManager.GetFocusScope((DependencyObject) this.SearchQuery), (IInputElement) null);
Keyboard.ClearFocus();
this.SearchScripts(this.SearchQuery.Text);
if (this.SearchQuery.Text.Length != 0)
return;
this.SearchQuery.Text = "Enter your search query...";
}
private void SearchQuery_LostFocus(object sender, RoutedEventArgs e)
{
if (this.SearchQuery.Text.Length != 0)
return;
this.SearchQuery.Text = "Enter your search query...";
}
private void SearchBtn_Click(object sender, RoutedEventArgs e)
{
this.SearchScripts(this.SearchQuery.Text);
if (this.SearchQuery.Text.Length != 0)
return;
this.SearchQuery.Text = "Enter your search query...";
}
private void NextPageBtn_Click(object sender, RoutedEventArgs e)
{
if (this.currentPage >= this.totalPages)
return;
this.SearchScripts(this.lastQuery, this.currentPage + 1);
}
private void PreviousPageBtn_Click(object sender, RoutedEventArgs e)
{
if (this.currentPage <= 1)
return;
this.SearchScripts(this.lastQuery, this.currentPage - 1);
}
private void ScriptBloxCredits_Click(object sender, RoutedEventArgs e)
{
Process.Start("https://scriptblox.com");
}
private void CloseNotificationButton_Click(object sender, RoutedEventArgs e)
{
if (this.currentNotification.GetCurrentState() != ClockState.Active)
return;
this.currentNotification.Stop();
this.CloseNotification();
}
private void CloseAdButton_Click(object sender, RoutedEventArgs e) => this.HideAdPane();
private void AdBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Process.Start(this.currentAdvertisement.redirectLink);
}
private void MultiInstance_OnCheckedChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.MultiInstance = this.MultiInstance.IsChecked;
Wave.Classes.Passive.Settings.Instance.Save();
Bloxstrap.Instance.MultiInstanceLaunching = this.MultiInstance.IsChecked;
Bloxstrap.Instance.Save();
}
private void AutoExecute_OnCheckedChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.AutoExecute = this.AutoExecute.IsChecked;
Wave.Classes.Passive.Settings.Instance.Save();
}
private void SaveTabs_OnCheckedChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.SaveTabs = this.SaveTabs.IsChecked;
Wave.Classes.Passive.Settings.Instance.Save();
if (!this.isTransferredToUI)
return;
if (this.SaveTabs.IsChecked)
{
this.AutoSaveTabs();
this.saveTabTimer.Start();
}
else
{
this.saveTabTimer.Stop();
foreach (string file in Directory.GetFiles("data/tabs"))
File.Delete(file);
}
}
private void EditorRefreshRate_OnValueChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.EditorRefreshRate = (int) this.EditorRefreshRate.Value;
Wave.Classes.Passive.Settings.Instance.Save();
foreach (ContentControl contentControl in (IEnumerable) this.ScriptTabs.Items)
((IChromiumWebBrowserBase) contentControl.Content).GetBrowserHost().WindowlessFrameRate = Wave.Classes.Passive.Settings.Instance.EditorRefreshRate;
}
private void EditorTextSize_OnValueChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.EditorTextSize = this.EditorTextSize.Value;
Wave.Classes.Passive.Settings.Instance.Save();
foreach (ContentControl contentControl in (IEnumerable) this.ScriptTabs.Items)
((IChromiumWebBrowserBase) contentControl.Content).ExecuteScriptAsync("window.updateOptions({ fontSize: " + Wave.Classes.Passive.Settings.Instance.EditorTextSize.ToString() + " });");
}
private void ShowMinimap_OnCheckedChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.ShowMinimap = this.ShowMinimap.IsChecked;
Wave.Classes.Passive.Settings.Instance.Save();
foreach (ContentControl contentControl in (IEnumerable) this.ScriptTabs.Items)
((IChromiumWebBrowserBase) contentControl.Content).ExecuteScriptAsync("window.updateOptions({ minimap: { enabled: " + Wave.Classes.Passive.Settings.Instance.ShowMinimap.ToString().ToLower() + "} });");
}
private void ShowInlayHints_OnCheckedChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.ShowInlayHints = this.ShowInlayHints.IsChecked;
Wave.Classes.Passive.Settings.Instance.Save();
foreach (ContentControl contentControl in (IEnumerable) this.ScriptTabs.Items)
((IChromiumWebBrowserBase) contentControl.Content).ExecuteScriptAsync("window.updateOptions({ inlayHints: { enabled: " + Wave.Classes.Passive.Settings.Instance.ShowInlayHints.ToString().ToLower() + "} });");
}
private void UseConversationHistory_OnCheckedChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.UseConversationHistory = this.UseConversationHistory.IsChecked;
Wave.Classes.Passive.Settings.Instance.Save();
}
private void TopMost_OnCheckedChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.TopMost = this.TopMost.IsChecked;
Wave.Classes.Passive.Settings.Instance.Save();
this.Topmost = this.TopMost.IsChecked;
}
private void AppendCurrentScript_OnCheckedChanged(object sender, EventArgs e)
{
Wave.Classes.Passive.Settings.Instance.AppendCurrentScript = this.AppendCurrentScript.IsChecked;
Wave.Classes.Passive.Settings.Instance.Save();
}
private void ClearConversationHistory_OnClicked(object sender, EventArgs e)
{
this.aiChat.ClearConversationHistory();
this.AIChatPanel.Children.RemoveRange(1, this.AIChatPanel.Children.Count - 1);
}
private void AIChatScroll_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (e.ExtentHeightChange <= 0.0)
return;
this.AIChatScroll.ScrollToBottom();
}
private void CloseInstanceButton_Click(object sender, RoutedEventArgs e)
{
this.AnimatePopupOut(this.InstancePopupGrid);
}
private async void SelectedProcessButton_Click(object sender, RoutedEventArgs e)
{
string str = (await ((IChromiumWebBrowserBase) this.ScriptTabs.SelectedContent).EvaluateScriptAsync("window.getText();", new TimeSpan?(), false)).Result.ToString();
foreach (InstancePanel child in this.InstanceStack.Children)
child.Script = str;
this.AnimatePopupIn(this.InstancePopupGrid);
}
[DebuggerNonUserCode]