Splashscreen wechselt jetzt erst zur gui nachdem die Map vom server empfangen wurde
This commit is contained in:
@@ -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 ()
|
||||
@@ -171,7 +174,7 @@ namespace WorldOfPeacecraft
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace WorldOfPeacecraft
|
||||
private MapPanel MapPanel;
|
||||
private ChatPanel ChatPanel;
|
||||
private OnlinePlayerList OnlinePlayerList;
|
||||
private bool loaded = false;
|
||||
|
||||
//private Music m = new Music();
|
||||
|
||||
@@ -44,7 +45,6 @@ namespace WorldOfPeacecraft
|
||||
{
|
||||
base.OnLoad (e);
|
||||
InitializeComponents ();
|
||||
Backend.StartThreads ();
|
||||
}
|
||||
|
||||
protected override void OnPaint (PaintEventArgs e)
|
||||
@@ -62,11 +62,7 @@ namespace WorldOfPeacecraft
|
||||
this.SuspendLayout();
|
||||
this.Size = new Size(OnlinePlayerWidth + 400 + ChatWidth, 400);
|
||||
OnlinePlayerList.Location = new Point(0,0);
|
||||
OnlinePlayerList.Size = new Size(OnlinePlayerWidth, 400);
|
||||
MapPanel.Location = new Point(OnlinePlayerWidth,0);
|
||||
MapPanel.Size = new Size(400, 400);
|
||||
ChatPanel.Location = new Point (OnlinePlayerWidth + 400, 0);
|
||||
ChatPanel.Size = new Size (300, 400);
|
||||
this.DoubleBuffered = true;
|
||||
this.MaximizeBox = false;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
@@ -78,6 +74,8 @@ namespace WorldOfPeacecraft
|
||||
this.Controls.Add (ChatPanel);
|
||||
|
||||
this.ResumeLayout();
|
||||
loaded = true;
|
||||
this.PerformRefresh();
|
||||
|
||||
//m.Playmusic ("overworld");
|
||||
}
|
||||
@@ -91,13 +89,12 @@ namespace WorldOfPeacecraft
|
||||
|
||||
public void PerformRefresh ()
|
||||
{
|
||||
this.BeginInvoke(new MethodInvoker(delegate
|
||||
{
|
||||
if (loaded) {
|
||||
this.BeginInvoke (new MethodInvoker (delegate {
|
||||
MapPanel.PerformLayout ();
|
||||
this.SuspendLayout();
|
||||
this.SetClientSizeCore(OnlinePlayerWidth + MapPanel.Width + ChatWidth, MapPanel.Height);
|
||||
OnlinePlayerList.Size = new Size(OnlinePlayerWidth, MapPanel.Height);
|
||||
MapPanel.Location = new Point(OnlinePlayerWidth, 0);
|
||||
ChatPanel.Location = new Point (OnlinePlayerWidth + MapPanel.Width, 0);
|
||||
ChatPanel.Size = new Size (ChatWidth, MapPanel.Height);
|
||||
this.ResumeLayout();
|
||||
@@ -105,6 +102,7 @@ namespace WorldOfPeacecraft
|
||||
this.Refresh();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadResources(){
|
||||
MapPanel.LoadResources ();
|
||||
|
||||
@@ -22,10 +22,8 @@ namespace WorldOfPeacecraft
|
||||
void moveRight();
|
||||
void MoveTo(int x, int y);
|
||||
|
||||
void StartThreads();
|
||||
|
||||
void Stop();
|
||||
|
||||
void Connect();
|
||||
void Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace WorldOfPeacecraft
|
||||
}
|
||||
|
||||
private void ThreadEntry(){
|
||||
Thread.Sleep(250);
|
||||
gui.LoadResources ();
|
||||
backend.Connect ();
|
||||
Thread.Sleep (1000);
|
||||
backend.Initialize ();
|
||||
if (GuiHasLoaded != null)
|
||||
GuiHasLoaded (this,gui);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user