unit UFormChat;

{$mode delphi}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  UGame, UGameClient;

type

  { TFormChat }

  TFormChat = class(TForm)
    ButtonMessageSend: TButton;
    EditMessage: TEdit;
    Label1: TLabel;
    MemoChat: TMemo;
    procedure ButtonMessageSendClick(Sender: TObject);
    procedure EditMessageKeyPress(Sender: TObject; var Key: char);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private

  public
    Client: TClient;
  end;

var
  FormChat: TFormChat;


implementation

{$R *.lfm}

uses
  UCore;

{ TFormChat }

procedure TFormChat.EditMessageKeyPress(Sender: TObject; var Key: char);
begin
  if Key = #13 then ButtonMessageSend.Click;
end;

procedure TFormChat.FormCreate(Sender: TObject);
begin
  Core.CoolTranslator1.TranslateComponentRecursive(Self);
end;

procedure TFormChat.FormShow(Sender: TObject);
begin
  Core.ThemeManager1.UseTheme(Self);
end;

procedure TFormChat.ButtonMessageSendClick(Sender: TObject);
begin
  if Assigned(Client) then
  with Client do begin
    Protocol.SendMessage(EditMessage.Text);
    MemoChat.Lines.Add(Client.Name + ': ' + EditMessage.Text);
    EditMessage.Text := '';
  end;
end;

end.

