Example #1
0
        public void OnMessage(object sender, PlayerIOClient.Message e)
        {
            if (e.Type == "init")
            {
                MapFrame = Frame.FromMessage(e, false);
                if (MapFrame != null)
                {
                    if (e.GetUInt(21) == 0)
                    {
                        EEditor.MainForm.userdata.thisColor = Color.Transparent;
                    }
                    else
                    {
                        EEditor.MainForm.userdata.useColor  = true;
                        EEditor.MainForm.userdata.thisColor = UIntToColor(e.GetUInt(21));
                    }

                    var owner = e.GetString(0) == "" ? "Unknown" : e.GetString(0);
                    MainForm.Text = e[1] + " by " + owner + " (" + e[18] + "x" + e[19] + ") - EEditor " + this.ProductVersion;
                    SizeWidth     = MapFrame.Width;
                    SizeHeight    = MapFrame.Height;
                    Connection.Disconnect();
                    Connection.OnMessage -= OnMessage;
                    s.Release();
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                    Close();
                }
                else
                {
                    MessageBox.Show("World's width and height aren't integers. Please report this to our bug tracker.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    s.Release();
                    DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    Close();
                }
            }
            else if (e.Type == "upgrade")
            {
                MessageBox.Show("Game got updated. Please report this to our bug tracker.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                s.Release();
                DialogResult = System.Windows.Forms.DialogResult.Cancel;
                Close();
            }
            else
            {
                messages += 1;
                if (messages == 1)
                {
                    MessageBox.Show(e.GetString(1), e.GetString(0), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    s.Release();
                    DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    Close();
                }

                //if (e.Type != "b" && e.Type != "m" && e.Type != "hide" && e.Type != "show")Console.WriteLine(e.ToString());
            }
        }