Jump to content

  • Log In with Google      Sign In   
  • Create Account

neoforce problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Landi20   Members   -  Reputation: 214

Like
0Likes
Like

Posted 22 August 2012 - 06:30 PM

i make a game using xna with neoforce and have some error
Error 2 The name 'Invoke' does not exist in the current context C:\Users\Alves\Dropbox\Jogos\TomShane.Neoforce.Controls.XNA4\Neoforce\Source\Central\Code\World.cs 156 13 Central
Error 3 The name 'AppendText' does not exist in the current context C:\Users\Alves\Dropbox\Jogos\TomShane.Neoforce.Controls.XNA4\Neoforce\Source\Central\Code\World.cs 161 12 Central
Error 4 'TomShane.Neoforce.Controls.Layout' does not contain a definition for 'Invoke' and no extension method 'Invoke' accepting a first argument of type 'TomShane.Neoforce.Controls.Layout' could be found (are you missing a using directive or an assembly reference?) C:\Users\Alves\Dropbox\Jogos\TomShane.Neoforce.Controls.XNA4\Neoforce\Source\Central\Code\World.cs 166 21 Central
Error 5 'TomShane.Neoforce.Controls.Layout' does not contain a definition for 'Invoke' and no extension method 'Invoke' accepting a first argument of type 'TomShane.Neoforce.Controls.Layout' could be found (are you missing a using directive or an assembly reference?) C:\Users\Alves\Dropbox\Jogos\TomShane.Neoforce.Controls.XNA4\Neoforce\Source\Central\Code\World.cs 176 21 Central
Error 1 'TomShane.Neoforce.Central.World' does not contain a constructor that takes 1 arguments C:\Users\Alves\Dropbox\Jogos\TomShane.Neoforce.Controls.XNA4\Neoforce\Source\Central\Code\Logic.cs 202 46 Central
the same project using forms works but with neoforce don´t work
the code of class world
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;
using System.Threading;
//using System.Drawing;
using TomShane.Neoforce.Controls;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Shared.Protocol;
using Shared.User;
using Message = Shared.Messages.Message;
namespace TomShane.Neoforce.Central
{
	public sealed partial class World : Window
	{
		#region Fields
		const int Port = 50143;
		delegate void SendTextDelegate(Message message);
		delegate void AddUserDelegate(User user);
		delegate void ClearUserListDelegate();
		#endregion
		#region Properties
		User User { get; set; }
		TcpClient TcpClient { get; set; }
		BinaryWriter Writer { get; set; }
		BinaryReader Reader { get; set; }
	   Layout Instance { get; set; }
		#endregion
		public World(Manager manager,string text, Layout instance): base(manager)
		{
			User = new User(text/*, Color.Black, Rank.Normal*/);
			 Instance = instance;
			  SetupClient();
			InitConsole();
		  
	}
	
		void SetupClient()
		{
			try
			{
				TcpClient = new TcpClient("localhost", Port);
				Writer = new BinaryWriter(new NetworkStream(TcpClient.Client));
				Reader = new BinaryReader(new NetworkStream(TcpClient.Client));
				ThreadStart ts = delegate
				{
					HandleServer();
					Close();
				};
				var t = new Thread(ts);
				t.Start();
				//Setup Username and send it to server
			  //  new Message("Ola: " + User.Username, new User("Server", Color.Yellow, Rank.Admin));
				Send(PacketType.SendUser, User);
				GetUserList();
			}
			catch (Exception e)
			{
				MessageBox.Show(Manager, MessageBox.MessageBoxType.CANCEL, "ERRO"+e, "");
				CloseServer();
			}
		}
		#region Methods

		void GetUserList()
		{
			//Get list of users on the server
			//AppendText(new Message("WELCOME TO ", new User("Server", Color.Gold, Rank.Admin)));
		   // AppendText(new Message("WELCOME TO SERVER: " + User.Username + "", new User("Server", Color.Gold, Rank.Admin)));
			Send(PacketType.SendUserList, null);
		}
		void CloseServer()
		{
			if (Writer != null) Writer.Close();
			if (Reader != null) Reader.Close();
			if (TcpClient != null) TcpClient.Close();
			//Logon.Exit();
		}
		void HandleServer()
		{
			try
			{
				ProtocolObject packet;
				while ((packet = Recieve()) != null)
				{
					switch (packet.PacketType)
					{
						#region RecieveChatMessage
						case PacketType.RecieveChatMessage:
							{
								InvokeLog((Message)packet.Payload);
							}
							break;
						#endregion
						#region RecieveUserList
						case PacketType.RecieveUserList:
							{
								InvokeUserList();
								foreach (var l in (List<User>)packet.Payload)
									InvokeUser(l);
							}
							break;
						#endregion
					}
				}
			}
			catch (Exception e)
			{
				MessageBox.Show(Manager, MessageBox.MessageBoxType.CANCEL, "ERRO"+e, "");
				CloseServer();
			}
		}
	  
	  //  void Title(Message message)
	   // {
	   //	 AppendText(message);
		//	Text = message.Text == null ? @"Client" : @"Client - " + message.Text;
	   // }
		#endregion
		#region Send and Recieve
		void Send(PacketType packetType, object payload)
		{
			DataProtocolObject.SerializePacket(Writer, new ProtocolObject(packetType, payload));
		}
		ProtocolObject Recieve()
		{
			return DataProtocolObject.DeserializePacket(Reader);
		}
		#endregion
		#region Delegates
	   void InvokeLog(Message message)
		{
			Invoke(new SendTextDelegate(SendText), message);
		}
		void SendText(Message message)
		{
		   AppendText(message);
		}
		void InvokeUser(User user)
		{
		   Instance.Invoke(new AddUserDelegate(AddUser), user);
		}
	  
		void AddUser(User user)
		{
	   //	AddUserToList(user);
		}
		void InvokeUserList()
		{
		   Instance.Invoke(new ClearUserListDelegate(ClearUsers));
		}
		void ClearUsers()
		{
		  //	userList.Items.Clear();
		}
		#endregion
	  
		#region Console
		private void InitConsole()
	{
	  TabControl tbc = new TabControl(Manager);
	  TomShane.Neoforce.Controls.Console con1 = new TomShane.Neoforce.Controls.Console(Manager);
	  TomShane.Neoforce.Controls.Console con2 = new TomShane.Neoforce.Controls.Console(Manager);
	  //Console con3 = new Console(Manager);
	
	  // Setup of TabControl, which will be holding both consoles
	  tbc.Init();
	  tbc.AddPage("Global");
	  tbc.AddPage("Guild");
	  tbc.AddPage("PARTY");
	  tbc.AddPage("TRADE");
	  tbc.Alpha = 220;
	  tbc.Left = 220;
	  tbc.Height = 220;
	  tbc.Width = 400;
	  tbc.Top = Manager.TargetHeight - tbc.Height - 32;	
	
	  tbc.Movable = true;
	  tbc.Resizable = true;
	  tbc.MinimumHeight = 96;
	  tbc.MinimumWidth = 160;  
					  
	  tbc.TabPages[0].Add(con1);
	  tbc.TabPages[1].Add(con2);
	  //tbc.TabPages[2].Add(con3);
							
	  con1.Init();
	  con2.Init();
	  //con3.Init();
	  con2.Width = con1.Width = tbc.TabPages[0].ClientWidth;
	  con2.Height = con1.Height = tbc.TabPages[0].ClientHeight;
	  con2.Anchor = con1.Anchor = Anchors.All;			  
	  con1.Channels.Add(new ConsoleChannel(0, "General", Color.Orange));
	  con1.Channels.Add(new ConsoleChannel(1, "Private", Color.White));
	  con1.Channels.Add(new ConsoleChannel(2, "System", Color.Yellow));
	  con1.Channels.Add(new ConsoleChannel(3, "Guild", Color.Green));
	
	  // We want to share channels and message buffer in both consoles
	  con2.Channels = con1.Channels;
	  con2.MessageBuffer = con1.MessageBuffer;					  
	
	  // In the second console we display only "Private" messages
	  con2.ChannelFilter.Add(3);		  
	
	  // Select default channels for each tab
	  con1.SelectedChannel = 0;
	  con2.SelectedChannel = 3;
	  //con3.SelectedChannel = 3;
	
	  // Do we want to add timestamp or channel name at the start of every message?
	  con1.MessageFormat = ConsoleMessageFormats.All;
	  con2.MessageFormat = ConsoleMessageFormats.TimeStamp;
	  // Handler for altering incoming message
	  con1.MessageSent += new ConsoleMessageEventHandler(con1_MessageSent);	
	
	  // We send initial welcome message to System channel
	  con1.MessageBuffer.Add(new ConsoleMessage("WELCOME TO THE SERVER!",2));
				  
	  Manager.Add(tbc);	
	}
	////////////////////////////////////////////////////////////////////////////
  
	////////////////////////////////////////////////////////////////////////////
	void con1_MessageSent(object sender, ConsoleMessageEventArgs e)
	{
	  if (e.Message.Channel == 0)
	  {
		//e.Message.Text = "(!) " + e.Message.Text;
	  }
	}
	////////////////////////////////////////////////////////////////////////////
	  
	#endregion
  
  }
	}
class logic
void btnApply_Click(object sender, Controls.EventArgs e)
	{
		String user = txusername.Text.Trim();
		System.Console.WriteLine(user);
		String userPassword = txpassword.Text.Trim();
		System.Console.WriteLine(userPassword);
		try
		{
		  
			MySqlConnection con = new MySqlConnection("host=localhost;user=root;database=jogo");
			MySqlCommand cmd = new MySqlCommand("SELECT password FROM w70tg_users WHERE username  ='" + user + "'");
			cmd.Connection = con;
			con.Open();
			object hello = cmd.ExecuteScalar();
			if (hello == null)
			{
				MessageBox.Show(Manager, MessageBox.MessageBoxType.CANCEL, "ERRO", "");
			}
			else
			{
				string password = hello.ToString();
				 // que hizo el usuario escribe?			  
				con.Close();
				if (Check(userPassword, password))
				{
					// corregir!
					MySqlCommand cmdo = new MySqlCommand("SELECT w70tg_user_usergroup_map.group_id FROM w70tg_users INNER JOIN w70tg_user_usergroup_map on w70tg_user_usergroup_map.user_id=w70tg_users.id  WHERE username  = '" +  txusername.Text + "'");
					cmdo.Connection = con;
					con.Open();
					object Tipo = cmdo.ExecuteScalar();
					if (Tipo != null && Tipo != DBNull.Value)
					{
						switch (System.Convert.ToInt32(Tipo))
						{
							case 8:
								// serverselection ola = new serverselection();
								// ola.Show();
							   // Hide();
								 World ola = new World(Manager);
								 ola.Text=user;
								ola.Show();
							   //new World(txusername.Text.Trim(),Manager,this).Show();
							   Hide();
								break;
							case 11:
							   MessageBox.Show( Manager,MessageBox.MessageBoxType.CANCEL,"GAME MASTER","");
								break;
							case 10:
								MessageBox.Show(Manager, MessageBox.MessageBoxType.CANCEL, "Moderador","");
								break;
							case 3:
								MessageBox.Show(Manager, MessageBox.MessageBoxType.CANCEL, "VIP", "");
								break;
							case 2:
								MessageBox.Show(Manager, MessageBox.MessageBoxType.CANCEL, "Membro", "");
								break;
							case 1:
								MessageBox.Show(Manager, MessageBox.MessageBoxType.CANCEL, "O Utilizador foi banido\n Contacte a Equipa atravez do suporte para saber a razão pelo qual foi banido(a)","");
								break;
						}
					}
				}
				else
				{
				
					txpassword.Text = null;
					txusername.Text = null;
				}
				con.Close();
			}
		}
		catch (MySqlException msqle)
		{
			MessageBox.Show(Manager, MessageBox.MessageBoxType.CANCEL,"ERRO"+msqle.Message, "");
		}
	/*  Manager.Graphics.IsFullScreen = chkResFull.Checked;
	  int w = 1024;
	  int h = 768;
	  if (rdbRes1024.Checked)
	  {
		w = 1024;
		h = 768;
	  }
	  else if (rdbRes1280.Checked)
	  {
		w = 1280;
		h = 1024;
	  }
	  else if (rdbRes1680.Checked)
	  {
		w = 1680;
		h = 1050;
	  }
	  Manager.Graphics.PreferredBackBufferWidth = w;
	  Manager.Graphics.PreferredBackBufferHeight = h;	
	
	  Manager.Graphics.ApplyChanges();	
   */
	 }
can someone can help me
in logic.cs i want sent the username to world.cs

Edited by Landi20, 22 August 2012 - 06:31 PM.


Sponsor:

#2 6677   Members   -  Reputation: 1058

Like
0Likes
Like

Posted 23 August 2012 - 07:01 AM

I'm not familiar with neoforce but shouldn't there be a "using Tomshane.Neoforce.Central" or similar aswell as neoforce.controls (which you do have)

#3 Landi20   Members   -  Reputation: 214

Like
0Likes
Like

Posted 23 August 2012 - 08:16 AM

yes using the neoforce central in my code
i can send the name of username to other windows

#4 6677   Members   -  Reputation: 1058

Like
0Likes
Like

Posted 23 August 2012 - 10:59 AM

You only have a using statement for neoforce controls, none for neoforce central. I think it is most likely a referencing issue.

#5 Landi20   Members   -  Reputation: 214

Like
0Likes
Like

Posted 23 August 2012 - 11:25 AM

this is my code and have the same error
but if i use i form i dont have any error
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;
using System.Threading;
using TomShane.Neoforce.Controls;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Shared.Protocol;
using Shared.User;
using Message = Shared.Messages.Message;
using System.Windows.Forms;
using FableServer;
using TomShane.Neoforce.Central;

namespace TomShane.Neoforce.Central
{
	public sealed partial class World : Window
	{
		#region Fields
		const int Port = 50143;
		delegate void SendTextDelegate(Message message);
		delegate void AddUserDelegate(User user);
		delegate void ClearUserListDelegate();
		#endregion
		#region Properties
		User User { get; set; }
		TcpClient TcpClient { get; set; }
		BinaryWriter Writer { get; set; }
		BinaryReader Reader { get; set; }
	 Layout Instance { get; set; }
		#endregion
		public  World(Manager manager,string text, Layout instance): base(manager)
		{
		  User = new User(text, System.Drawing.Color.Black, Rank.Normal);
		   Instance = instance;
			 SetupClient();
		  
			InitConsole();
		  
	}
	  
	
		void SetupClient()
		{
			try
			{
				TcpClient = new TcpClient("localhost", Port);
				Writer = new BinaryWriter(new NetworkStream(TcpClient.Client));
				Reader = new BinaryReader(new NetworkStream(TcpClient.Client));
				ThreadStart ts = delegate
				{
					HandleServer();
					Close();
				};
				var t = new Thread(ts);
				t.Start();
				//Setup Username and send it to server
			  //  new Message("Ola: " + User.Username, new User("Server", Color.Yellow, Rank.Admin));
				Send(PacketType.SendUser, User);
				GetUserList();
			}
			catch (Exception e)
			{
				TomShane.Neoforce.Controls.MessageBox.Show(Manager, TomShane.Neoforce.Controls.MessageBox.MessageBoxType.CANCEL, "ERRO"+e, "");
				CloseServer();
			}
		}
		#region Methods

		void GetUserList()
		{
			//Get list of users on the server
			//AppendText(new Message("WELCOME TO ", new User("Server", Color.Gold, Rank.Admin)));
		   // AppendText(new Message("WELCOME TO SERVER: " + User.Username + "", new User("Server", Color.Gold, Rank.Admin)));
			Send(PacketType.SendUserList, null);
		}
		void CloseServer()
		{
			if (Writer != null) Writer.Close();
			if (Reader != null) Reader.Close();
			if (TcpClient != null) TcpClient.Close();
			//Logon.Exit();
		}
		void HandleServer()
		{
			try
			{
				ProtocolObject packet;
				while ((packet = Recieve()) != null)
				{
					switch (packet.PacketType)
					{
						#region RecieveChatMessage
						case PacketType.RecieveChatMessage:
							{
								InvokeLog((Message)packet.Payload);
							}
							break;
						#endregion
						#region RecieveUserList
						case PacketType.RecieveUserList:
							{
								InvokeUserList();
								foreach (var l in (List<User>)packet.Payload)
									InvokeUser(l);
							}
							break;
						#endregion
					}
				}
			}
			catch (Exception e)
			{
				TomShane.Neoforce.Controls.MessageBox.Show(Manager, TomShane.Neoforce.Controls.MessageBox.MessageBoxType.CANCEL, "ERRO"+e, "");
				CloseServer();
			}
		}
	  
	   void Title(Message message)
		{
			AppendText(message);
		   Text = message.Text == null ? @"Client" : @"Client - " + message.Text;
	   }
		#endregion
		#region Send and Recieve
		void Send(PacketType packetType, object payload)
		{
			DataProtocolObject.SerializePacket(Writer, new ProtocolObject(packetType, payload));
		}
		ProtocolObject Recieve()
		{
			return DataProtocolObject.DeserializePacket(Reader);
		}
		#endregion
		#region Delegates
	   void InvokeLog(Message message)
		{
			Invoke(new SendTextDelegate(SendText), message);
		}
		void SendText(Message message)
		{
		   AppendText(message);
		}
		void InvokeUser(User user)
		{
		   Instance.Invoke(new AddUserDelegate(AddUser), user);
		}
	  
		void AddUser(User user)
		{
	   //	AddUserToList(user);
		}
		void InvokeUserList()
		{
		   Instance.Invoke(new ClearUserListDelegate(ClearUsers));
		}
		void ClearUsers()
		{
		  //	userList.Items.Clear();
		}
		#endregion
	 void AppendText(Message message)
		{
			//con1.SelectionColor = message.User.Color;
			//con1.AppendText(Environment.NewLine + message.User.Username + ": " + message.Text);
		}
	
		#region Console
		private void InitConsole()
	{
	  TomShane.Neoforce.Controls.TabControl tbc = new TomShane.Neoforce.Controls.TabControl(Manager);
	  TomShane.Neoforce.Controls.Console con1 = new TomShane.Neoforce.Controls.Console(Manager);
	  TomShane.Neoforce.Controls.Console con2 = new TomShane.Neoforce.Controls.Console(Manager);
	  //Console con3 = new Console(Manager);
	
	  // Setup of TabControl, which will be holding both consoles
	  tbc.Init();
	  tbc.AddPage("Global");
	  tbc.AddPage("Guild");
	  tbc.AddPage("PARTY");
	  tbc.AddPage("TRADE");
	  tbc.Alpha = 220;
	  tbc.Left = 220;
	  tbc.Height = 220;
	  tbc.Width = 400;
	  tbc.Top = Manager.TargetHeight - tbc.Height - 32;	
	
	  tbc.Movable = true;
	  tbc.Resizable = true;
	  tbc.MinimumHeight = 96;
	  tbc.MinimumWidth = 160;  
					  
	  tbc.TabPages[0].Add(con1);
	  tbc.TabPages[1].Add(con2);
	  //tbc.TabPages[2].Add(con3);
							
	  con1.Init();
	  con2.Init();
	  //con3.Init();
	  con2.Width = con1.Width = tbc.TabPages[0].ClientWidth;
	  con2.Height = con1.Height = tbc.TabPages[0].ClientHeight;
	  con2.Anchor = con1.Anchor = Anchors.All;			  
	  con1.Channels.Add(new ConsoleChannel(0, "General", Color.Orange));
	  con1.Channels.Add(new ConsoleChannel(1, "Private", Color.White));
	  con1.Channels.Add(new ConsoleChannel(2, "System", Color.Yellow));
	  con1.Channels.Add(new ConsoleChannel(3, "Guild", Color.Green));
	
	  // We want to share channels and message buffer in both consoles
	  con2.Channels = con1.Channels;
	  con2.MessageBuffer = con1.MessageBuffer;					  
	
	  // In the second console we display only "Private" messages
	  con2.ChannelFilter.Add(3);		  
	
	  // Select default channels for each tab
	  con1.SelectedChannel = 0;
	  con2.SelectedChannel = 3;
	  //con3.SelectedChannel = 3;
	
	  // Do we want to add timestamp or channel name at the start of every message?
	  con1.MessageFormat = ConsoleMessageFormats.All;
	  con2.MessageFormat = ConsoleMessageFormats.TimeStamp;
	  // Handler for altering incoming message
	  con1.MessageSent += new ConsoleMessageEventHandler(con1_MessageSent);	
	
	  // We send initial welcome message to System channel
	  con1.MessageBuffer.Add(new ConsoleMessage("WELCOME TO THE SERVER!",2));
				  
	  Manager.Add(tbc);	
	}
	////////////////////////////////////////////////////////////////////////////
  
	////////////////////////////////////////////////////////////////////////////
	void con1_MessageSent(object sender, ConsoleMessageEventArgs e)
	{
	  if (e.Message.Channel == 0)
	  {
		//e.Message.Text = "(!) " + e.Message.Text;
	  }
	}
	////////////////////////////////////////////////////////////////////////////
	  
	#endregion
  
  }
	}

Edited by Landi20, 23 August 2012 - 11:26 AM.


#6 Landi20   Members   -  Reputation: 214

Like
0Likes
Like

Posted 03 September 2012 - 12:23 PM

the problem as been solve
topic can be close




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS