-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainWindow.xaml.cs
152 lines (128 loc) · 4.25 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
using System;
using System.Configuration;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
namespace rev2_Labtool_Framework_
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public struct Rect
{
public int Left { get; set; }
public int Top { get; set; }
public int Right { get; set; }
public int Bottom { get; set; }
}
public partial class MainWindow : Window
{
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private readonly string _githubPage = ConfigurationManager.AppSettings.Get("GithubPage");
private Labtool _labtool;
#region FormHandling
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
_labtool = new Labtool();
try
{
MemoryAccessor.AttachToProcess();
}
catch (Exception exception)
{
MessageBox.Show($"{exception.Message}");
Application.Current.Shutdown();
return;
}
Thread t1 = new Thread(refreshInfo);
t1.IsBackground = true;
t1.Start();
checkbox.IsChecked = false;
SetForegroundWindow(MemoryAccessor.process.MainWindowHandle);
}
private void Window_Closed(object sender, EventArgs e)
{
Environment.Exit(Environment.ExitCode);
MemoryAccessor.Dispose();
}
#endregion
#region FormFunctions
private void updateLabel(System.Windows.Controls.ContentControl updatedLabel, string updatedString)
{
Dispatcher.BeginInvoke(new Action(() =>
{
updatedLabel.Content = updatedString;
}));
}
private void clearGapsString(object sender, RoutedEventArgs e)
{
this.gaps1Textblock.Text = "";
this.gaps2Textblock.Text = "";
}
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("explorer.exe", _githubPage);
}
#endregion
private void refreshInfo()
{
while (true)
{
_labtool.macroButtons();
_labtool.updateFrameInfo();
if (_labtool.f.updateFA)
{
updateLabel(this.fa1Label, _labtool.f.frameAdvantage + "F");
_labtool.f.updateFA = false;
}
if (_labtool.g1.updateGap)
{
Dispatcher.BeginInvoke(new Action(() =>
{
string concat = this.gaps1Textblock.Text;
this.gaps1Textblock.Text = concat.Insert(0, _labtool.g1.rememberGap.ToString() + "F" + Environment.NewLine);
}));
_labtool.g1.updateGap = false;
}
if (_labtool.g2.updateGap)
{
Dispatcher.BeginInvoke(new Action(() =>
{
string concat = this.gaps2Textblock.Text;
this.gaps2Textblock.Text = concat.Insert(0, _labtool.g2.rememberGap.ToString() + "F" + Environment.NewLine);
}));
_labtool.g2.updateGap = false;
}
updateLabel(this.p1HPLabel, "" + _labtool._player1._HP);
updateLabel(this.p2HPLabel, "" + _labtool._player2._HP);
updateLabel(this.p1MeterLabel, "" + _labtool._player1._meter / 100.0);
updateLabel(this.p2MeterLabel, "" + _labtool._player2._meter / 100.0);
updateLabel(this.p1RISCLabel, "" + _labtool._player1._RISC / 100.0);
updateLabel(this.p2RISCLabel, "" + _labtool._player2._RISC / 100.0);
updateLabel(this.p1xPosLabel, "x: " + _labtool._player1._pos.x / 1000);
updateLabel(this.p1yPosLabel, "y: " + _labtool._player1._pos.y / 1000);
updateLabel(this.p2xPosLabel, "x: " + _labtool._player2._pos.x / 1000);
updateLabel(this.p2yPosLabel, "y: " + _labtool._player2._pos.y / 1000);
updateLabel(this.p1CharLabel, "(Player)" + Player.charactersList[_labtool._player1.characterIndex]);
updateLabel(this.p2CharLabel, Player.charactersList[_labtool._player2.characterIndex]);
updateLabel(this.p1DefModifLabel, "[x" + _labtool._player1.getDefenseModifier() + "]");
updateLabel(this.p2DefModifLabel, "[x" + _labtool._player2.getDefenseModifier() + "]");
updateLabel(this.p1StunLabel, "" + _labtool._player1._stun + "/" + _labtool._player1._stunThreshold * 100);
updateLabel(this.p2StunLabel, "" + _labtool._player2._stun + "/" + _labtool._player2._stunThreshold * 100);
updateLabel(this.p1GutsLabel, "(x guts)");
updateLabel(this.p2GutsLabel, "(x guts)");
}
}
private void MenuItem_Click_1(object sender, RoutedEventArgs e)
{
Labtool.processKeys = !Labtool.processKeys;
}
}
}