Skip to content

Commit 97cb484

Browse files
committed
minor fixes
1 parent 4c5ff91 commit 97cb484

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

WinTerrEdit/about.cs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,22 @@ namespace WinTerrEdit
1414
{
1515
public partial class about : Form
1616
{
17-
public about()
17+
public string cont;
18+
19+
public about(string cont)
1820
{
1921
InitializeComponent();
22+
this.cont = cont;
2023
}
2124

2225
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
2326
{
2427
Process.Start("https://www.gnu.org/licenses/");
2528
}
2629

27-
public string obtainContactInfoFromWeb()
28-
{
29-
using(WebClient w = new WebClient())
30-
{
31-
string contactInfo = Encoding.UTF8.GetString(w.DownloadData(@"http://knedit.pw/WTE_Contact_Data"));
32-
contactInfo = contactInfo.Split(new string[] { "##" }, StringSplitOptions.None)[0];
33-
return contactInfo;
34-
}
35-
}
36-
3730
private void about_Load(object sender, EventArgs e)
3831
{
39-
try
40-
{
41-
label2.Text = obtainContactInfoFromWeb();
42-
}
43-
catch
44-
{
45-
label2.Text = "Could not contact server :(";
46-
}
32+
label2.Text = cont;
4733
}
4834
}
4935
}

WinTerrEdit/entry.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Drawing;
55
using System.IO;
66
using System.Linq;
7+
using System.Net;
78
using System.Runtime.InteropServices;
89
using System.Security.Cryptography;
910
using System.Text;
@@ -81,6 +82,7 @@ public partial class entry : Form
8182
public bool useExtendedName = false;
8283
int selectedTab = 0;
8384
Stopwatch st = new Stopwatch();
85+
public string aboutBoxContactData = "Loading...";
8486

8587
public entry()
8688
{
@@ -169,9 +171,13 @@ private void Entry_Load(object sender, EventArgs e)
169171

170172
this.Invoke(new MethodInvoker(delegate ()
171173
{
174+
//LOADING FINISHED
172175
ld.Close();
173176
}));
174177

178+
Thread getContact = new Thread(() => aboutBoxContactData = getContactInfoFromExtServer());
179+
getContact.Start();
180+
175181
//just show the fucking form to the user
176182
User32.AllowSetForegroundWindow((uint)Process.GetCurrentProcess().Id);
177183
User32.SetForegroundWindow(Handle);
@@ -1293,7 +1299,7 @@ private void entry_kDown(object sender, KeyEventArgs e)
12931299
{
12941300
if(e.KeyCode == Keys.F1)
12951301
{
1296-
about ab = new about();
1302+
about ab = new about(aboutBoxContactData);
12971303
ab.ShowDialog();
12981304
}
12991305
if(e.KeyCode == Keys.F2)
@@ -1657,6 +1663,28 @@ private void tabs_selectedChanged(object sender, EventArgs e)
16571663
}
16581664
}
16591665

1666+
public string getContactInfoFromExtServer()
1667+
{
1668+
try
1669+
{
1670+
WebClient w = new WebClient();
1671+
w.Headers.Add("user-agent", "Internal WTE request");
1672+
string _tmp = w.DownloadString(@"http://knedit.pw/WTE_Contact_Data_Tmp/");
1673+
if (_tmp[0] == 'W')
1674+
{
1675+
return _tmp;
1676+
}
1677+
else
1678+
{
1679+
throw new Exception("corrupt data");
1680+
}
1681+
}
1682+
catch
1683+
{
1684+
return "Unknown server error :(";
1685+
}
1686+
}
1687+
16601688
private void nudHair_ValueChanged(object sender, EventArgs e)
16611689
{
16621690
playerHS = (int)nudHair.Value;

0 commit comments

Comments
 (0)