Splashscreen wechselt jetzt erst zur gui nachdem die Map vom server empfangen wurde

This commit is contained in:
2014-05-14 10:31:41 +02:00
parent f4325f6030
commit a640c92961
4 changed files with 30 additions and 28 deletions

View File

@@ -17,6 +17,8 @@ namespace WorldOfPeacecraft
private Buffer SenderBuffer;
private IGui Gui;
private int SelfId;
private AutoResetEvent InitializedEvent = new AutoResetEvent(false);
private bool initialized = false;
public Backend (IGui gui)
{
@@ -30,9 +32,9 @@ namespace WorldOfPeacecraft
Parse = new Parser (this, receiverBuffer);
Rec = new Receiver (Client, receiverBuffer);
Send = new Sender (Client, SenderBuffer);
SenderBuffer.AddLine ("get:map");
SenderBuffer.AddLine ("get:me");
SenderBuffer.AddLine ("get:ents");
SenderBuffer.AddLine ("get:map");
}
public void SetSelfId (int id)
@@ -98,6 +100,7 @@ namespace WorldOfPeacecraft
public void SetMap (Map map)
{
this.Map = map;
InitializedEvent.Set();
}
public ITile[,] GetMap ()
@@ -166,12 +169,12 @@ namespace WorldOfPeacecraft
}
}
public void RefreshGui()
public void RefreshGui ()
{
Gui.PerformRefresh();
Gui.PerformRefresh ();
}
public void StartThreads() {
private void StartThreads() {
Parse.Start ();
Rec.Start ();
Send.Start ();
@@ -183,8 +186,11 @@ namespace WorldOfPeacecraft
Client.Close ();
}
public void Connect(){
public void Initialize(){
Client.Connect ("localhost", 9999);
StartThreads ();
InitializedEvent.WaitOne();
initialized = true;
}
}
}