-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutputWindow.cs
More file actions
172 lines (150 loc) · 5.77 KB
/
Copy pathoutputWindow.cs
File metadata and controls
172 lines (150 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SPTMiniLauncher
{
public partial class outputWindow : Form
{
public string currentDir = Environment.CurrentDirectory;
public string fullProfilesPath;
public bool modProblem = false;
Form1 mainForm = new Form1();
public outputWindow()
{
InitializeComponent();
}
private void outputWindow_Load(object sender, EventArgs e)
{
}
private void richTextBox1_MouseDown(object sender, MouseEventArgs e)
{
}
private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.C)
{
e.Handled = true;
e.SuppressKeyPress = true;
}
}
private void outputWindow_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
this.Hide();
}
// base.OnFormClosing(e);
}
private void outputWindow_LocationChanged(object sender, EventArgs e)
{
/*
if (bDetach.Text.Contains("#SUSPENDED#"))
{
if (Owner != null && !Owner.IsDisposed)
{
this.Left = Owner.Left + Owner.Width;
this.Top = Owner.Top;
}
}
*/
}
private void sptOutputWindow_TextChanged(object sender, EventArgs e)
{
string fullString = sptOutputWindow.Text;
if (Properties.Settings.Default.serverErrorMessages)
{
string fullServerPath = Properties.Settings.Default.server_path;
string userFolder = Path.Combine(fullServerPath, "user");
string modsFolder = Path.Combine(userFolder, "mods");
bool userExists = Directory.Exists(userFolder);
bool modsExists = Directory.Exists(modsFolder);
if (userExists && modsExists)
{
string[] mods = Directory.GetDirectories(modsFolder, "*", SearchOption.TopDirectoryOnly);
for (int i = 0; i < mods.Length; i++)
{
if (!modProblem)
{
// string pattern = @":(\d+):";
// string pattern = @"\((.+?\.([tj]s)):";
string pattern = @"\((.+?\.([tj]s)):(\d+):";
string keyword = Path.GetFileName(mods[i]);
Match match = Regex.Match(fullString, pattern);
if (match.Success)
{
string filePath = match.Groups[1].Value;
string fileLineNmbr = match.Groups[3].Value;
if (int.TryParse(fileLineNmbr, out int lineNumber))
{
if (MessageBox.Show($"It appears that the mod \"{Path.GetFileName(mods[i])}\" has an issue with the source code.\n" +
$"\n" +
$"Line: {lineNumber.ToString()}\n" +
$"File: {Path.GetFileName(filePath)}\n" +
$"\n" +
$"Full path:\n{filePath}\n" +
$"\n" +
$"Would you like to open the file?", this.Text, MessageBoxButtons.YesNo) == DialogResult.Yes)
{
Process.Start(filePath);
}
}
modProblem = true;
break;
}
}
}
}
}
}
public void scrollTextForm()
{
sptOutputWindow.ScrollToCaret();
}
public void matchModFolder(string path)
{
}
private void bDetach_MouseDown(object sender, MouseEventArgs e)
{
}
private void bDetach_MouseEnter(object sender, EventArgs e)
{
bDetach.ForeColor = Color.DodgerBlue;
}
private void bDetach_MouseLeave(object sender, EventArgs e)
{
bDetach.ForeColor = Color.LightGray;
}
private void bDetach_Click(object sender, EventArgs e)
{
/*
if (bDetach.Text.ToLower() == "click to toggle: stickied")
{
bDetach.Text = "Click to toggle: detached";
}
else
{
bDetach.Text = "Click to toggle: stickied";
this.Location = new Point(mainForm.Location.X + mainForm.Width, mainForm.Location.Y);
this.Size = new Size(this.Size.Width, mainForm.Size.Height);
}
*/
}
private void bToggleWordWrap_MouseDown(object sender, MouseEventArgs e)
{
if (sptOutputWindow.WordWrap)
sptOutputWindow.WordWrap = false;
else
sptOutputWindow.WordWrap = true;
}
}
}