close Warning: Can't synchronize with repository "(default)" (No changeset 184 in the repository). Look in the Trac log for more information.

source: trunk/Forms/UFormChat.pas

Last change on this file was 180, checked in by chronos, 6 years ago
  • Modified: Client related interface moved from FormMain to FormClient. This code change will later allow to implement network client-server gameplay.
  • Added: Allow to open other spectator client windows.
File size: 1.0 KB
Line 
1unit UFormChat;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, UGame;
9
10type
11
12 { TFormChat }
13
14 TFormChat = class(TForm)
15 ButtonMessageSend: TButton;
16 EditMessage: TEdit;
17 Label1: TLabel;
18 MemoChat: TMemo;
19 procedure ButtonMessageSendClick(Sender: TObject);
20 procedure EditMessageKeyPress(Sender: TObject; var Key: char);
21 private
22
23 public
24 Client: TClient;
25 end;
26
27var
28 FormChat: TFormChat;
29
30implementation
31
32{$R *.lfm}
33
34{ TFormChat }
35
36procedure TFormChat.EditMessageKeyPress(Sender: TObject; var Key: char);
37begin
38 if Key = #13 then ButtonMessageSend.Click;
39end;
40
41procedure TFormChat.ButtonMessageSendClick(Sender: TObject);
42var
43 TextMessage: TCommandTextMessage;
44begin
45 if Assigned(Client) then
46 with Client do begin
47 TextMessage.Text := EditMessage.Text;
48 Client.Send(cmdTextMessage, @TextMessage, nil);
49 MemoChat.Lines.Add(Client.Name + ': ' + EditMessage.Text);
50 EditMessage.Text := '';
51 end;
52end;
53
54end.
55
Note: See TracBrowser for help on using the repository browser.