-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRefereePatcherForm.cs
102 lines (95 loc) · 3.46 KB
/
RefereePatcherForm.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
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CM0102Patcher
{
public partial class RefereePatcherForm : Form
{
public RefereePatcherForm()
{
InitializeComponent();
try
{
if (!string.IsNullOrEmpty(RegString.GetRegString()))
{
var path = (string)Registry.GetValue(RegString.GetRegString(), "Location", "");
if (!string.IsNullOrEmpty(path))
{
var dataPath = Path.Combine(path, "Data");
labelFilename.Text = Path.Combine(dataPath, "officials.dat");
}
}
}
catch { }
}
private void buttonBrowse_Click(object sender, EventArgs e)
{
try
{
var ofd = new OpenFileDialog();
ofd.Filter = "CM0102 officials.dat file|officials.dat|All files (*.*)|*.*";
ofd.Title = "Select a CM0102 officials.dat file";
try
{
if (!string.IsNullOrEmpty(RegString.GetRegString()))
{
var path = (string)Registry.GetValue(RegString.GetRegString(), "Location", "");
if (!string.IsNullOrEmpty(path))
ofd.InitialDirectory = Path.Combine(path, "Data");
}
}
catch { }
if (ofd.ShowDialog() == DialogResult.OK)
{
labelFilename.Text = ofd.FileName;
}
}
catch (Exception ex)
{
ExceptionMsgBox.Show(ex);
}
}
private void buttonApply_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(labelFilename.Text))
{
MessageBox.Show("Please select an officals.dat to modify", "Select File Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (checkBoxDiscplineFixed.Checked && (((int)numericModifier.Value) > 20 || ((int)numericModifier.Value) < 1))
{
MessageBox.Show("Set Discipine Value Between 1-20!", "Discipline Only Mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var rp = new RefereePatcher();
rp.PatchOfficialsFile(labelFilename.Text, (int)numericModifier.Value, checkBoxDiscplineFixed.Checked);
MessageBox.Show("Officals.dat Patched!", "Referee Patcher", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}
catch (Exception ex)
{
ExceptionMsgBox.Show(ex);
}
}
private void checkBoxDiscplineFixed_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxDiscplineFixed.Checked)
{
label3.Text = "Set All Refs Discipline To:";
if (numericModifier.Value > 20)
numericModifier.Value = 5;
}
else
label3.Text = "CA/PA/Discipline Percentage Modifier:";
}
}
}