private void LoadChatboxFromXML(XElement chatboxElement, Dictionary <string, SpriteFont> fonts, ContentManager content, GUIManager parent) { string chatboxName = chatboxElement.Attribute("name")?.Value.ToString(); string texturePath = chatboxElement.Element("texture")?.Value.ToString(); string fontName = chatboxElement.Element("font")?.Value.ToString(); int.TryParse(chatboxElement.Element("padding")?.Element("x")?.Value.ToString(), out int offX); int.TryParse(chatboxElement.Element("padding")?.Element("y")?.Value.ToString(), out int offY); int.TryParse(chatboxElement.Element("maxlines")?.Value.ToString(), out int maxLines); int.TryParse(chatboxElement.Element("zorder")?.Value.ToString(), out int zOrder); var texture = content.LoadTexture2D(Constants.FILEPATH_DATA + texturePath); var position = this.ParsePosition(chatboxElement.Element("position")?.Element("x")?.Value.ToString(), chatboxElement.Element("position")?.Element("y")?.Value.ToString()); if (!bool.TryParse(chatboxElement.Element("visible")?.Value, out bool visible)) { visible = true; } SpriteFont font = fonts[fontName]; var chatBox = new Chatbox(texture, font, maxLines) { Position = position, ChatOffset = new Vector2(offX, offY), ZOrder = zOrder, Visible = visible }; parent.AddWidget(chatBox, chatboxName); }
public void Startup() { UserInterfaceManager.DisposeAllComponents(); NetworkManager.MessageArrived += NetworkManagerMessageArrived; _lobbyChat = new Chatbox(ResourceManager, UserInterfaceManager, KeyBindingManager); _lobbyChat.TextSubmitted += LobbyChatTextSubmitted; _lobbyChat.Update(0); UserInterfaceManager.AddComponent(_lobbyChat); _lobbyText = new TextSprite("lobbyText", "", ResourceManager.GetFont("CALIBRI")) { Color = Color.Black, ShadowColor = Color.DimGray, Shadowed = true, ShadowOffset = new Vector2D(1, 1) }; NetOutgoingMessage message = NetworkManager.CreateMessage(); message.Write((byte)NetMessage.WelcomeMessage); //Request Welcome msg. NetworkManager.SendMessage(message, NetDeliveryMethod.ReliableOrdered); NetworkManager.SendClientName(ConfigurationManager.GetPlayerName()); //Send name. NetOutgoingMessage playerListMsg = NetworkManager.CreateMessage(); playerListMsg.Write((byte)NetMessage.PlayerList); //Request Playerlist. NetworkManager.SendMessage(playerListMsg, NetDeliveryMethod.ReliableOrdered); _playerListTime = DateTime.Now.AddSeconds(PlayerListRefreshDelaySec); NetOutgoingMessage jobListMsg = NetworkManager.CreateMessage(); jobListMsg.Write((byte)NetMessage.JobList); //Request Joblist. NetworkManager.SendMessage(jobListMsg, NetDeliveryMethod.ReliableOrdered); var joinButton = new Button("Join Game", ResourceManager) { mouseOverColor = Color.LightSteelBlue }; joinButton.Position = new Point(605 - joinButton.ClientArea.Width - 5, 200 - joinButton.ClientArea.Height - 5); joinButton.Clicked += JoinButtonClicked; UserInterfaceManager.AddComponent(joinButton); _jobButtonContainer = new ScrollableContainer("LobbyJobCont", new Size(375, 400), ResourceManager) { Position = new Point(630, 10) }; UserInterfaceManager.AddComponent(_jobButtonContainer); Gorgon.CurrentRenderTarget.Clear(); }
public void HandleUIPacket(Dictionary <string, object> packetData) { if (packetData.ContainsKey("dialog")) { UIHandler uiHandler = GameManager.instance.GetComponent <UIHandler>(); UIBase currentUI = uiHandler.GetCurrentUI(); if (currentUI == null || currentUI.GetType() != typeof(Chatbox)) { uiHandler.SetUI(typeof(Chatbox)); try { Chatbox chat = uiHandler.GetCurrentUI(typeof(Chatbox)) as Chatbox; if (chat != null) { chat.SetDialog(packetData["dialog"].ToString()); } } catch (System.InvalidOperationException ex) { Debug.Log($"[UIHandler::ExceptionCaught]: {ex.Message}"); } } } }
private void _joinGame(MsgTickerJoinGame message) { if (_tickerState == TickerState.InGame) { return; } _tickerState = TickerState.InGame; if (_lobby != null) { _lobby.Chat.TextSubmitted -= _chatConsole.ParseChatMessage; _chatConsole.AddString -= _lobby.Chat.AddLine; _lobby.Dispose(); _lobby = null; } _inputManager.SetInputCommand(EngineKeyFunctions.FocusChat, InputCmdHandler.FromDelegate(session => { _gameChat.Input.GrabKeyboardFocus(); })); _gameChat = new Chatbox(); _userInterfaceManager.StateRoot.AddChild(_gameChat); _gameChat.TextSubmitted += _chatConsole.ParseChatMessage; _chatConsole.AddString += _gameChat.AddLine; _gameChat.DefaultChatFormat = "say \"{0}\""; }
/// <summary> /// Append Message to the Chatbox /// </summary> /// <param name="Message"></param> private void LogWrite(String Message, params object[] format) { //return; Message = String.Format(Message, format); if (!IsDisposed) { if (Chatbox.InvokeRequired) { Chatbox.Invoke(new Action(() => { if (ChatboxAutoscroll) { Chatbox.AppendText(Message); } else { BufferedChatlog += Message; } })); } else { Chatbox.AppendText(Message); } } }
public UnRegisterChatCommand(Func <ChatMessage> message, Func <User> user, Configuration config, Chatbox chatbox) : base(user, config) { _message = message(); _config = config; _chatbox = chatbox; IsCommand("unregisterChat", "Unregister Chat For Shoutbox"); }
public SendChatMessageCommand(Func <ChatMessage> message, Func <User> user, Configuration config, Chatbox chatbox) : base(user, config) { _message = message(); _config = config; _chatbox = chatbox; IsCommand("m", "Send a message to chat!"); HasAdditionalArguments(null); }
protected override void Initialize() { base.Initialize(); var chatContainer = GetChild("Panel/VBoxContainer/HBoxContainer/LeftVBox"); Chat = new Chatbox(); chatContainer.AddChild(Chat); Chat.SizeFlagsVertical = SizeFlags.FillExpand; }
private void _joinLobby(MsgTickerJoinLobby message) { if (_tickerState == TickerState.InLobby) { return; } if (_gameChat != null) { _gameChat.TextSubmitted -= _chatConsole.ParseChatMessage; _chatConsole.AddString -= _gameChat.AddLine; _gameChat.Dispose(); _gameChat = null; } _tickerState = TickerState.InLobby; _lobby = new LobbyGui(); _userInterfaceManager.StateRoot.AddChild(_lobby); _lobby.Chat.TextSubmitted += _chatConsole.ParseChatMessage; _chatConsole.AddString += _lobby.Chat.AddLine; _lobby.Chat.DefaultChatFormat = "ooc \"{0}\""; _lobby.ServerName.Text = _baseClient.GameInfo.ServerName; _inputManager.SetInputCommand(EngineKeyFunctions.FocusChat, InputCmdHandler.FromDelegate(session => { _lobby.Chat.Input.GrabKeyboardFocus(); })); _updateLobbyUi(); _lobby.ObserveButton.OnPressed += args => { _chatConsole.ProcessCommand("observe"); }; _lobby.ReadyButton.OnPressed += args => { if (!_gameStarted) { return; } _chatConsole.ProcessCommand("joingame"); }; _lobby.ReadyButton.OnToggled += args => { if (_gameStarted) { return; } _chatConsole.ProcessCommand($"toggleready {args.Pressed}"); }; _lobby.LeaveButton.OnPressed += args => _chatConsole.ProcessCommand("disconnect"); }
private void textBox8_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Chatbox.AppendText("[you] " + this.Sendbox.Text + Environment.NewLine); //send packet to the server PacketChat chat = new PacketChat(this.Sendbox.Text + Environment.NewLine, hostName, "monitor", id); this.serverConnection.WritePacket(chat); Console.WriteLine("Sent message"); Sendbox.Clear(); } }
/******************添加收到的消息******************/ public void AddMsg(string chatMsg) { Chatbox.SelectionAlignment = HorizontalAlignment.Left; Font font = new Font(FontFamily.GenericMonospace, 10, FontStyle.Regular); Chatbox.SelectionFont = font; Chatbox.SelectionColor = Color.Blue; string msg = System.DateTime.Now.ToLocalTime().ToString(); msg = msg + "\n" + ">>> " + chatMsg + "\n"; Chatbox.AppendText(msg); Chatbox.ScrollToCaret(); }
private void BaseClientOnRunLevelChanged(object sender, RunLevelChangedEventArgs e) { if (e.NewLevel != ClientRunLevel.Initialize) { return; } _tickerState = TickerState.Unset; _lobby?.Dispose(); _lobby = null; _gameChat?.Dispose(); _gameChat = null; }
public void Startup() { UserInterfaceManager.DisposeAllComponents(); NetworkManager.MessageArrived += NetworkManagerMessageArrived; _lobbyChat = new Chatbox("lobbychat", new Vector2i(475, 175), ResourceManager); _lobbyChat.TextSubmitted += LobbyChatTextSubmitted; _lobbyChat.Update(0); UserInterfaceManager.AddComponent(_lobbyChat); _lobbyText = new TextSprite("lobbyText", "", ResourceManager.GetFont("CALIBRI")) { Color = SFML.Graphics.Color.Black, ShadowColor = SFML.Graphics.Color.Transparent, Shadowed = true, //TODO CluwneSprite ShadowOffset // ShadowOffset = new Vector2(1, 1) }; NetOutgoingMessage message = NetworkManager.CreateMessage(); message.Write((byte)NetMessage.WelcomeMessage); //Request Welcome msg. NetworkManager.SendMessage(message, NetDeliveryMethod.ReliableOrdered); NetworkManager.SendClientName(ConfigurationManager.GetCVar <string>("player.name")); //Send name. NetOutgoingMessage playerListMsg = NetworkManager.CreateMessage(); playerListMsg.Write((byte)NetMessage.PlayerList); //Request Playerlist. NetworkManager.SendMessage(playerListMsg, NetDeliveryMethod.ReliableOrdered); _playerListTime = DateTime.Now.AddSeconds(PlayerListRefreshDelaySec); var joinButton = new Button("Join Game", ResourceManager) { mouseOverColor = new SFML.Graphics.Color(176, 222, 196) }; joinButton.Position = new Vector2i(605 - joinButton.ClientArea.Width - 5, 200 - joinButton.ClientArea.Height - 5); joinButton.Clicked += JoinButtonClicked; UserInterfaceManager.AddComponent(joinButton); CluwneLib.CurrentRenderTarget.Clear(); }
/// <summary> /// clears the chatbox. /// </summary> private void ClearChatlog() { if (Chatbox.IsDisposed) { return; } if (Chatbox.InvokeRequired) { Chatbox.Invoke(new Action(() => { Chatbox.Clear(); })); } else { Chatbox.Clear(); } }
public void InitGameGui() { mChatBox = new Chatbox(GameCanvas, this); GameMenu = new Menu(GameCanvas); Hotbar = new HotBarWindow(GameCanvas); PlayerBox = new EntityBox(GameCanvas, EntityTypes.Player, Globals.Me, true); if (mPictureWindow == null) { mPictureWindow = new PictureWindow(GameCanvas); } mEventWindow = new EventWindow(GameCanvas); mQuestOfferWindow = new QuestOfferWindow(GameCanvas); mDebugMenu = new DebugMenu(GameCanvas); }
public override void Startup() { IoCManager.InjectDependencies(this); escapeMenu = new EscapeMenu { Visible = false }; escapeMenu.AddToScreen(); _gameChat = new Chatbox(); userInterfaceManager.StateRoot.AddChild(_gameChat); _gameChat.TextSubmitted += console.ParseChatMessage; console.AddString += _gameChat.AddLine; _gameChat.DefaultChatFormat = "say \"{0}\""; }
public override void Startup() { IoCManager.InjectDependencies(this); mapManager.Startup(); inputManager.KeyBindStateChanged += OnKeyBindStateChanged; escapeMenu = new EscapeMenu { Visible = false }; escapeMenu.AddToScreen(); var escapeMenuCommand = InputCmdHandler.FromDelegate(session => { if (escapeMenu.Visible) { if (escapeMenu.IsAtFront()) { escapeMenu.Visible = false; } else { escapeMenu.MoveToFront(); } } else { escapeMenu.OpenCentered(); } }); inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, escapeMenuCommand); inputManager.SetInputCommand(EngineKeyFunctions.FocusChat, InputCmdHandler.FromDelegate(session => { _gameChat.Input.GrabFocus(); })); _gameChat = new Chatbox(); userInterfaceManager.StateRoot.AddChild(_gameChat); _gameChat.TextSubmitted += console.ParseChatMessage; console.AddString += _gameChat.AddLine; _gameChat.DefaultChatFormat = "say \"{0}\""; }
/// <inheritdoc /> public void ParseChatMessage(Chatbox chatBox, string text) { ParseChatMessage(text, chatBox.DefaultChatFormat); }
/******************发送消息******************/ private void Sendbutton_Click(object sender, EventArgs e) { if (Sendchatbox.Text == "") { MessageBox.Show("请先填写消息"); } else { try { //向服务器确认好友是否在线,得到IP NetworkStream stream = toServer.GetStream(); string sendMsg = "q" + friendID; byte[] sendByt = Encoding.ASCII.GetBytes(sendMsg); stream.Write(sendByt, 0, sendByt.Length); byte[] rcvByt = new byte[1024]; int rcvLength = stream.Read(rcvByt, 0, rcvByt.Length); string rcvMsg = Encoding.ASCII.GetString(rcvByt, 0, rcvLength); if (rcvMsg == "n") { MessageBox.Show("好友已离线"); } else { //发送该消息 sendMsg = "msg" + userID + Sendchatbox.Text; sendByt = Encoding.Unicode.GetBytes(sendMsg); if (sendByt.Length > 1024) { MessageBox.Show("一次输入请不要超过500个字"); return; } else { TcpClient tcptoFriend = new TcpClient(); tcptoFriend.Connect(rcvMsg, listenPort); NetworkStream streamtoFriend = tcptoFriend.GetStream(); streamtoFriend.Write(sendByt, 0, sendByt.Length); streamtoFriend.Close(); tcptoFriend.Close(); //stream.Close(); 会报错 //向chatbox添加该消息 Chatbox.SelectionAlignment = HorizontalAlignment.Right; Font font = new Font(FontFamily.GenericMonospace, 10, FontStyle.Regular); Chatbox.SelectionFont = font; Chatbox.SelectionColor = Color.Green; string msg = System.DateTime.Now.ToLocalTime().ToString(); msg = msg + "\n" + ">>> " + Sendchatbox.Text + "\n"; Chatbox.AppendText(msg); Chatbox.ScrollToCaret(); Sendchatbox.Clear(); Sendchatbox.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public Lobby(IDictionary <Type, object> managers) : base(managers) { _background = ResourceManager.GetSprite("mainbg"); _background.Texture.Smooth = true; _imgMainBg = new SimpleImage { Sprite = "lobby_mainbg" }; _imgStatus = new SimpleImage { Sprite = "lobby_statusbar" }; _lblServer = new Label("SERVER:", "MICROGME", ResourceManager); _lblServer.Text.Color = new SFML.Graphics.Color(245, 245, 245); _serverLabels.Add(_lblServer); _lblServerInfo = new Label("LLJK#1", "MICROGME", ResourceManager); _lblServerInfo.Text.Color = new SFML.Graphics.Color(139, 0, 0); _serverLabels.Add(_lblServerInfo); _lblMode = new Label("GAMEMODE:", "MICROGME", ResourceManager); _lblMode.Text.Color = new SFML.Graphics.Color(245, 245, 245); _serverLabels.Add(_lblMode); _lblModeInfo = new Label("SECRET", "MICROGME", ResourceManager); _lblModeInfo.Text.Color = new SFML.Graphics.Color(139, 0, 0); _serverLabels.Add(_lblModeInfo); _lblPlayers = new Label("PLAYERS:", "MICROGME", ResourceManager); _lblPlayers.Text.Color = new SFML.Graphics.Color(245, 245, 245); _serverLabels.Add(_lblPlayers); _lblPlayersInfo = new Label("17/32", "MICROGME", ResourceManager); _lblPlayersInfo.Text.Color = new SFML.Graphics.Color(139, 0, 0); _serverLabels.Add(_lblPlayersInfo); _lblPort = new Label("PORT:", "MICROGME", ResourceManager); _lblPort.Text.Color = new SFML.Graphics.Color(245, 245, 245); _serverLabels.Add(_lblPort); _lblPortInfo = new Label("1212", "MICROGME", ResourceManager); _lblPortInfo.Text.Color = new SFML.Graphics.Color(139, 0, 0); _serverLabels.Add(_lblPortInfo); _tabs = new TabbedMenu { TopSprite = "lobby_tab_top", MidSprite = "lobby_tab_mid", BotSprite = "lobby_tab_bot", TabOffset = new Vector2i(-8, 300), ZDepth = 2 }; _tabJob = new JobTab("lobbyTabJob", new Vector2i(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_bcase" }; _tabs.AddTab(_tabJob); _tabJob._shwDepa.SelectionChanged += new Showcase.ShowcaseSelectionChangedHandler(_shwDepa_SelectionChanged); _tabJob._shwJobs.SelectionChanged += new Showcase.ShowcaseSelectionChangedHandler(_shwJobs_SelectionChanged); _tabCharacter = new TabContainer("lobbyTabCharacter", new Vector2i(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_person" }; _tabs.AddTab(_tabCharacter); _tabObserve = new TabContainer("lobbyTabObserve", new Vector2i(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_eye" }; _tabs.AddTab(_tabObserve); _tabServer = new PlayerListTab("lobbyTabServer", new Vector2i(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_info" }; _tabs.AddTab(_tabServer); _tabs.SelectTab(_tabJob); _lobbyChat = new Chatbox(ResourceManager, UserInterfaceManager, KeyBindingManager) { Size = new Vector2f(780, 225), }; _lobbyChat.Update(0); _imgChatBg = new SimpleImage() { Sprite = "lobby_chatbg", }; _lobbyChat.TextSubmitted += new Chatbox.TextSubmitHandler(_lobbyChat_TextSubmitted); _btnReady = new ImageButton() { ImageNormal = "lobby_ready", ImageHover = "lobby_ready_green", ZDepth = 1 }; _btnReady.Clicked += _btnReady_Clicked; _btnReady.Update(0); _lblServerInfo.FixedWidth = 100; _lblModeInfo.FixedWidth = 90; _lblPlayersInfo.FixedWidth = 60; _lblPortInfo.FixedWidth = 50; UpdateGUIPosition(); }
void _lobbyChat_TextSubmitted(Chatbox chatbox, string text) { }
private static async Task Work() { _config = Configuration.LoadConfig("config.json"); _chatbox = new Chatbox(_config); _skypeCommander = new SkypeCommander(_config); _skypeCommander.SetUp(); //_skypeCommander._skype.SendMessage("princess_bot", "[b]test[/b]"); _aprt = new MessageLoopApartment(); _aprt.Invoke(() => { Application.EnableVisualStyles(); _frm = new Form1(); _frm.Show(); }); _skypeCommander.OnMessageRecieved((message, status) => { Console.WriteLine("Message Recieved: " + message.Body); if (message.Body.IndexOf("|") == 0 && message.Body.Length != 1) { Container container = CreateContainer(message, status); using (var sw = new StringWriter()) { var i = -1; _skypeCommander.DoOnAdminChats(chat => chat.SendMessage(message.Sender.Handle + " - " + message.Body)); try { var commands = container.GetAllInstances<CommandBase>().Where(x => x.ShouldDisplay()); var commandLineToArgs = CommandLineToArgs(message.Body.Substring(1)); foreach (var command in commandLineToArgs) { Console.WriteLine(command); } i = ConsoleCommandDispatcher.DispatchCommand( commands, commandLineToArgs, sw, false); } catch (Exception e) { Console.WriteLine(e); i = 2; } if (i == -2) { message.Chat.SendNickedMessage("Error Processing Request"); } else { if(i != 0) message.Chat.SendNickedMessage(sw.GetStringBuilder().ToString().Replace("SkypeBotTest.vshost.exe", "")); } _config.Save(); } } }); foreach (var chatHandle in _config.RegisteredChats) { _chatbox.Start(_skypeCommander._skype.Chat[chatHandle]); } while (true) { Console.WriteLine("Waiting For Input!"); Console.ReadLine(); } }
private void Awake() { player = GetComponent <SelfData>(); messageBox = GameObject.Find("ChatBar").GetComponent <Chatbox>(); }
// Start is called before the first frame update void Start() { chatbox = GameObject.Find("Chatbox").GetComponent <Chatbox>(); }
public Lobby(IDictionary <Type, object> managers) : base(managers) { _background = ResourceCache.GetSprite("mainbg"); _background.Texture.Smooth = true; _imgMainBg = new SimpleImage { Sprite = "lobby_mainbg" }; _imgStatus = new SimpleImage { Sprite = "lobby_statusbar" }; _lblServer = new Label("SERVER:", "MICROGME", ResourceCache); _lblServer.Text.Color = new Color4(245, 245, 245, 255); _serverLabels.Add(_lblServer); _lblServerInfo = new Label("LLJK#1", "MICROGME", ResourceCache); _lblServerInfo.Text.Color = new Color4(139, 0, 0, 255); _serverLabels.Add(_lblServerInfo); _lblMode = new Label("GAMEMODE:", "MICROGME", ResourceCache); _lblMode.Text.Color = new Color4(245, 245, 245, 255); _serverLabels.Add(_lblMode); _lblModeInfo = new Label("SECRET", "MICROGME", ResourceCache); _lblModeInfo.Text.Color = new Color4(139, 0, 0, 255); _serverLabels.Add(_lblModeInfo); _lblPlayers = new Label("PLAYERS:", "MICROGME", ResourceCache); _lblPlayers.Text.Color = new Color4(245, 245, 245, 255); _serverLabels.Add(_lblPlayers); _lblPlayersInfo = new Label("17/32", "MICROGME", ResourceCache); _lblPlayersInfo.Text.Color = new Color4(139, 0, 0, 255); _serverLabels.Add(_lblPlayersInfo); _lblPort = new Label("PORT:", "MICROGME", ResourceCache); _lblPort.Text.Color = new Color4(245, 245, 245, 255); _serverLabels.Add(_lblPort); _lblPortInfo = new Label(MainScreen.DEFAULT_PORT.ToString(), "MICROGME", ResourceCache); _lblPortInfo.Text.Color = new Color4(139, 0, 0, 255); _serverLabels.Add(_lblPortInfo); _tabs = new TabbedMenu { TopSprite = "lobby_tab_top", MidSprite = "lobby_tab_mid", BotSprite = "lobby_tab_bot", TabOffset = new Vector2i(-8, 300), ZDepth = 2 }; _tabCharacter = new TabContainer("lobbyTabCharacter", new Vector2i(793, 450), ResourceCache) { tabSpriteName = "lobby_tab_person" }; _tabs.AddTab(_tabCharacter); _tabObserve = new TabContainer("lobbyTabObserve", new Vector2i(793, 450), ResourceCache) { tabSpriteName = "lobby_tab_eye" }; _tabs.AddTab(_tabObserve); _tabServer = new PlayerListTab("lobbyTabServer", new Vector2i(793, 450), ResourceCache) { tabSpriteName = "lobby_tab_info" }; _tabs.AddTab(_tabServer); _tabs.SelectTab(_tabServer); _lobbyChat = new Chatbox("lobbychat", new Vector2i(780, 225), ResourceCache); _lobbyChat.Update(0); _imgChatBg = new SimpleImage() { Sprite = "lobby_chatbg", }; _lobbyChat.TextSubmitted += new Chatbox.TextSubmitHandler(_lobbyChat_TextSubmitted); _btnReady = new ImageButton() { ImageNormal = "lobby_ready", ImageHover = "lobby_ready_green", ZDepth = 1 }; _btnReady.Clicked += _btnReady_Clicked; _btnReady.Update(0); _btnBack = new ImageButton() { ImageNormal = "lobby_back", ImageHover = "lobby_back_green", ZDepth = 1 }; _btnBack.Clicked += _btnBack_Clicked; _btnBack.Update(0); _lblServerInfo.FixedWidth = 100; _lblModeInfo.FixedWidth = 90; _lblPlayersInfo.FixedWidth = 60; _lblPortInfo.FixedWidth = 50; UpdateGUIPosition(); }
// Start is called before the first frame update void Start() { playerChat = GameObject.FindGameObjectWithTag("Player").GetComponent <Chatbox>(); }
public void Init(ChatApi chatApi) { this.chatApi = chatApi; // Gui component. chatbox = this.gameObject.AddComponent<Chatbox>() as Chatbox; chatbox.CloseChatWindow(); // The messaging actor messenger = ActorSystem.instance.Find("Messenger") as Messenger; // Parses the chat language used by the gui and calls messenger // Feel free to provide your own implementation, this is mostly a starting point. // Supported syntax is documented in the source chatCommands = new ChatCommands(messenger, chatbox); chatCommands.SetChatApi(chatApi); // Setup callacks so we get notified when we join/leave channels and receive messages Messenger.ChannelJoined channelCallback = ChannelJoined; messenger.OnChannelJoined(channelCallback); Messenger.ChannelLeft channelLeftCallback = ChannelLeft; messenger.OnChannelLeft(channelLeftCallback); Messenger.MessageReceived messageCallback = MessageReceived; messenger.OnMessageReceived(messageCallback); Messenger.InviteReceived inviteCallback = InviteReceived; messenger.OnInviteReceived(inviteCallback); // Send this whenever you want a list of subscribed channels, and the optional // subscriber list if you have set the subscribers flag. We do it on an interval // so that you get notified when new players join a group you are in. // For matchmaking you probably want this value lower so it appears more // responsive. For mmo type games it could be somewhat higher. InvokeRepeating("UpdateChatStatus", 0.01f, 5.0F); }
private void LobbyChatTextSubmitted(Chatbox chatbox, string text) { SendLobbyChat(text); }
public ChatCommands(Messenger _messenger, Chatbox chatbox) { messenger = _messenger; this.chatbox = chatbox; }
public Lobby(IDictionary <Type, object> managers) : base(managers) { _background = ResourceManager.GetSprite("mainbg"); _background.Smoothing = Smoothing.Smooth; _mainbg = new SimpleImage { Sprite = "lobby_mainbg" }; _imgStatus = new SimpleImage { Sprite = "lobby_statusbar" }; _lblServer = new Label("SERVER:", "MICROGME", ResourceManager); _lblServer.Text.Color = Color.WhiteSmoke; _serverLabels.Add(_lblServer); _lblServerInfo = new Label("LLJK#1", "MICROGME", ResourceManager); _lblServerInfo.Text.Color = Color.DarkRed; _serverLabels.Add(_lblServerInfo); _lblMode = new Label("GAMEMODE:", "MICROGME", ResourceManager); _lblMode.Text.Color = Color.WhiteSmoke; _serverLabels.Add(_lblMode); _lblModeInfo = new Label("SECRET", "MICROGME", ResourceManager); _lblModeInfo.Text.Color = Color.DarkRed; _serverLabels.Add(_lblModeInfo); _lblPlayers = new Label("PLAYERS:", "MICROGME", ResourceManager); _lblPlayers.Text.Color = Color.WhiteSmoke; _serverLabels.Add(_lblPlayers); _lblPlayersInfo = new Label("17/32", "MICROGME", ResourceManager); _lblPlayersInfo.Text.Color = Color.DarkRed; _serverLabels.Add(_lblPlayersInfo); _lblPort = new Label("PORT:", "MICROGME", ResourceManager); _lblPort.Text.Color = Color.WhiteSmoke; _serverLabels.Add(_lblPort); _lblPortInfo = new Label("1212", "MICROGME", ResourceManager); _lblPortInfo.Text.Color = Color.DarkRed; _serverLabels.Add(_lblPortInfo); _tabs = new TabbedMenu { TopSprite = "lobby_tab_top", MidSprite = "lobby_tab_mid", BotSprite = "lobby_tab_bot", TabOffset = new Point(-8, 300) }; _tabJob = new JobTab("lobbyTabJob", new Size(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_bcase" }; _tabs.AddTab(_tabJob); _tabJob._shwDepa.SelectionChanged += new Showcase.ShowcaseSelectionChangedHandler(_shwDepa_SelectionChanged); _tabJob._shwJobs.SelectionChanged += new Showcase.ShowcaseSelectionChangedHandler(_shwJobs_SelectionChanged); _tabCharacter = new TabContainer("lobbyTabCharacter", new Size(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_person" }; _tabs.AddTab(_tabCharacter); _tabObserve = new TabContainer("lobbyTabObserve", new Size(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_eye" }; _tabs.AddTab(_tabObserve); _tabServer = new PlayerListTab("lobbyTabServer", new Size(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_info" }; _tabs.AddTab(_tabServer); _tabs.SelectTab(_tabJob); _lobbyChat = new Chatbox(ResourceManager, UserInterfaceManager, KeyBindingManager) { Size = new Vector2D(780, 225), }; _lobbyChat.Update(0); _imgChatBg = new SimpleImage() { Sprite = "lobby_chatbg", }; _lobbyChat.TextSubmitted += new Chatbox.TextSubmitHandler(_lobbyChat_TextSubmitted); }
public override void InitializeGUI() { //TODO: This needs to go in BaseClient NetworkManager.RegisterNetMessage <MsgPlayerListReq>(MsgPlayerListReq.NAME, (int)MsgPlayerListReq.ID, message => Logger.Error($"[SRV] Unhandled NetMessage type: {message.MsgId}")); NetworkManager.RegisterNetMessage <MsgPlayerList>(MsgPlayerList.NAME, (int)MsgPlayerList.ID, HandlePlayerList); _uiScreen = new Screen(); _uiScreen.BackgroundImage = ResourceCache.GetSprite("ss14_logo_background"); // UI screen is added in startup var imgMainBg = new SimpleImage(); imgMainBg.Sprite = "lobby_mainbg"; imgMainBg.Alignment = Align.HCenter | Align.VCenter; _uiScreen.AddControl(imgMainBg); var imgStatus = new SimpleImage(); imgStatus.Sprite = "lobby_statusbar"; imgStatus.LocalPosition = new Vector2i(10, 63); imgMainBg.AddControl(imgStatus); var lblServer = new Label("SERVER: ", "MICROGME"); lblServer.ForegroundColor = new Color(245, 245, 245); lblServer.LocalPosition = new Vector2i(5, 2); imgStatus.AddControl(lblServer); _lblServerInfo = new Label("LLJK#1", "MICROGME"); _lblServerInfo.ForegroundColor = new Color(139, 0, 0); _lblServerInfo.FixedWidth = 100; _lblServerInfo.Alignment = Align.Right; lblServer.AddControl(_lblServerInfo); var lblMode = new Label("GAMEMODE: ", "MICROGME"); lblMode.ForegroundColor = new Color(245, 245, 245); lblMode.Alignment = Align.Right; lblMode.LocalPosition = new Vector2i(10, 0); _lblServerInfo.AddControl(lblMode); _lblModeInfo = new Label("SECRET", "MICROGME"); _lblModeInfo.ForegroundColor = new Color(139, 0, 0); _lblModeInfo.FixedWidth = 90; _lblModeInfo.Alignment = Align.Right; lblMode.AddControl(_lblModeInfo); var lblPlayers = new Label("PLAYERS: ", "MICROGME"); lblPlayers.ForegroundColor = new Color(245, 245, 245); lblPlayers.Alignment = Align.Right; lblPlayers.LocalPosition = new Vector2i(10, 0); _lblModeInfo.AddControl(lblPlayers); _lblPlayersInfo = new Label("17/32", "MICROGME"); _lblPlayersInfo.ForegroundColor = new Color(139, 0, 0); _lblPlayersInfo.FixedWidth = 60; _lblPlayersInfo.Alignment = Align.Right; lblPlayers.AddControl(_lblPlayersInfo); var lblPort = new Label("PORT: ", "MICROGME"); lblPort.ForegroundColor = new Color(245, 245, 245); lblPort.Alignment = Align.Right; lblPort.LocalPosition = new Vector2i(10, 0); _lblPlayersInfo.AddControl(lblPort); _lblPortInfo = new Label(MainScreen.DefaultPort.ToString(), "MICROGME"); _lblPortInfo.ForegroundColor = new Color(139, 0, 0); _lblPortInfo.FixedWidth = 50; _lblPortInfo.Alignment = Align.Right; lblPort.AddControl(_lblPortInfo); _tabs = new TabbedMenu(); _tabs.TopSprite = "lobby_tab_top"; _tabs.MidSprite = "lobby_tab_mid"; _tabs.BotSprite = "lobby_tab_bot"; _tabs.TabOffset = new Vector2i(-8, 300); _tabs.LocalPosition = new Vector2i(5, 90); imgMainBg.AddControl(_tabs); var tabCharacter = new TabContainer(new Vector2i(793, 350)); tabCharacter.TabSpriteName = "lobby_tab_person"; _tabs.AddTab(tabCharacter); var tabObserve = new TabContainer(new Vector2i(793, 350)); tabObserve.TabSpriteName = "lobby_tab_eye"; _tabs.AddTab(tabObserve); var tabServer = new PlayerListTab(new Vector2i(793, 350)); tabServer.TabSpriteName = "lobby_tab_info"; _tabs.AddTab(tabServer); _tabs.SelectTab(tabServer); var imgChatBg = new SimpleImage(); imgChatBg.Sprite = "lobby_chatbg"; imgChatBg.Alignment = Align.HCenter | Align.Bottom; imgChatBg.Resize += (sender, args) => { imgChatBg.LocalPosition = new Vector2i(0, -9 + -imgChatBg.Height); }; imgMainBg.AddControl(imgChatBg); _lobbyChat = new Chatbox(new Vector2i(780, 225)); _lobbyChat.Alignment = Align.HCenter | Align.VCenter; imgChatBg.AddControl(_lobbyChat); var btnReady = new ImageButton(); btnReady.ImageNormal = "lobby_ready"; btnReady.ImageHover = "lobby_ready_green"; btnReady.Alignment = Align.Right; btnReady.Resize += (sender, args) => { btnReady.LocalPosition = new Vector2i(-5 + -btnReady.Width, -5 + -btnReady.Height); }; imgChatBg.AddControl(btnReady); btnReady.Clicked += _btnReady_Clicked; var btnBack = new ImageButton(); btnBack.ImageNormal = "lobby_back"; btnBack.ImageHover = "lobby_back_green"; btnBack.Resize += (sender, args) => { btnBack.LocalPosition = new Vector2i(-5 + -btnBack.Width, 0); }; btnReady.AddControl(btnBack); btnBack.Clicked += _btnBack_Clicked; }
/// <inheritdoc /> public override void InitializeGUI() { _uiScreen = new Screen(); _uiScreen.BackgroundImage = ResourceCache.GetSprite("ss14_logo_background"); // UI screen is added in startup var imgTitle = new SimpleImage(); imgTitle.Sprite = "ss14_logo"; imgTitle.Alignment = Align.Right; imgTitle.LocalPosition = new Vector2i(-550, 100); _uiScreen.AddControl(imgTitle); var txtConnect = new Textbox(100); txtConnect.Text = ConfigurationManager.GetCVar <string>("net.server"); txtConnect.Alignment = Align.Left | Align.Bottom; txtConnect.LocalPosition = new Vector2i(10, 50); txtConnect.OnSubmit += (sender, text) => { StartConnect(text); }; imgTitle.AddControl(txtConnect); var btnConnect = new ImageButton(); btnConnect.ImageNormal = "connect_norm"; btnConnect.ImageHover = "connect_hover"; btnConnect.Alignment = Align.Left | Align.Bottom; btnConnect.LocalPosition = new Vector2i(0, 20); btnConnect.Clicked += sender => { if (!_isConnecting) { StartConnect(txtConnect.Text); } else { _isConnecting = false; NetworkManager.ClientDisconnect("Client disconnected from game."); } }; txtConnect.AddControl(btnConnect); var btnOptions = new ImageButton(); btnOptions.ImageNormal = "options_norm"; btnOptions.ImageHover = "options_hover"; btnOptions.Alignment = Align.Left | Align.Bottom; btnOptions.LocalPosition = new Vector2i(0, 20); btnOptions.Clicked += sender => { if (_isConnecting) { _isConnecting = false; NetworkManager.ClientDisconnect("Client disconnected from game."); } StateManager.RequestStateChange <OptionsMenu>(); }; btnConnect.AddControl(btnOptions); var btnExit = new ImageButton(); btnExit.ImageNormal = "exit_norm"; btnExit.ImageHover = "exit_hover"; btnExit.Alignment = Align.Left | Align.Bottom; btnExit.LocalPosition = new Vector2i(0, 20); btnExit.Clicked += sender => CluwneLib.Stop(); btnOptions.AddControl(btnExit); var fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); var lblVersion = new Label("v. " + fvi.FileVersion, "CALIBRI"); lblVersion.ForegroundColor = new Color(245, 245, 245); lblVersion.Alignment = Align.Right | Align.Bottom; lblVersion.Resize += (sender, args) => { lblVersion.LocalPosition = new Vector2i(-3 + -lblVersion.ClientArea.Width, -3 + -lblVersion.ClientArea.Height); }; _uiScreen.AddControl(lblVersion); #if uiDev var chat = new Chatbox(new Vector2i(400, 200)); chat.LocalPosition = new Vector2i(25, 25); _uiScreen.AddControl(chat); var listPanel = new ListPanel(); listPanel.Size = new Vector2i(200, 200); listPanel.LocalPosition = new Vector2i(450, 250); _uiScreen.AddControl(listPanel); for (var i = 0; i < 5; i++) { var label = new Label($"Label: {i}", "CALIBRI"); listPanel.AddControl(label); } var rtp = new RichTextPanel(); rtp.Size = new Vector2i(400, 200); rtp.LocalPosition = new Vector2i(25, 250); rtp.BackgroundColor = Color4.DarkGray; rtp.ForegroundColor = new Color4(230, 230, 230, 255); rtp.DrawBorder = true; rtp.DrawBackground = true; _uiScreen.AddControl(rtp); rtp.Text.Append("Textbox says, \"Oh, my, God Becky, look at the image.\"\n"); rtp.Text.Append("Textbox says, \"It is so big, it looks like, one of those buttons' girlfriends.\"\n"); rtp.Text.Append("Textbox says, \"I mean, the image, is just so big. I can't believe it's just so square, it's like out there.\"\n"); rtp.Text.Append("Textbox says, \"I mean gross, look. It's just so, black!\"\n"); #endif }
// Start is called before the first frame update void Start() { chatbox = GameObject.Find("Chatbox").GetComponent <Chatbox>(); chatbox.Show(); chatbox.ShowTextSilent("Which Pokemon will you choose?"); }