lazarus-ccr/applications/fpchess/mod_samecomputer.pas
sekelsenmat 8659c35b4f Starts commiting the KCChess engine
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1871 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2011-08-30 12:37:28 +00:00

98 lines
2.2 KiB
ObjectPascal

unit mod_samecomputer;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
StdCtrls, Forms, Controls,
chessmodules;
type
{ TSinglePlayerChessModule }
TSameComputerChessModule = class(TChessModule)
private
textSecondPlayerName: TStaticText;
editSecondPlayerName: TEdit;
public
SecondPlayerName: string;
constructor Create();
procedure CreateUserInterface(); override;
procedure ShowUserInterface(AParent: TWinControl); override;
procedure HideUserInterface(); override;
procedure FreeUserInterface(); override;
procedure PrepareForGame(); override;
function IsMovingAllowedNow(): Boolean; override;
function GetSecondPlayerName(): string; override;
procedure HandleOnMove(AFrom, ATo: TPoint); override;
end;
implementation
{ TSameComputerChessModule }
constructor TSameComputerChessModule.Create;
begin
inherited Create;
Description := 'Play against a friend in the same computer';
Kind := cmkSinglePlayer;
end;
procedure TSameComputerChessModule.CreateUserInterface;
begin
textSecondPlayerName := TStaticText.Create(nil);
textSecondPlayerName.SetBounds(20, 20, 180, 50);
textSecondPlayerName.Caption := 'Name of the second player';
editSecondPlayerName := TEdit.Create(nil);
editSecondPlayerName.SetBounds(200, 20, 150, 50);
editSecondPlayerName.Text := 'Second player';
end;
procedure TSameComputerChessModule.ShowUserInterface(AParent: TWinControl);
begin
textSecondPlayerName.Parent := AParent;
editSecondPlayerName.Parent := AParent;
end;
procedure TSameComputerChessModule.HideUserInterface();
begin
textSecondPlayerName.Parent := nil;
editSecondPlayerName.Parent := nil;
end;
procedure TSameComputerChessModule.FreeUserInterface();
begin
textSecondPlayerName.Free;
editSecondPlayerName.Free;
end;
procedure TSameComputerChessModule.PrepareForGame;
begin
SecondPlayerName := editSecondPlayerName.Text;
end;
function TSameComputerChessModule.IsMovingAllowedNow: Boolean;
begin
Result := True;
end;
function TSameComputerChessModule.GetSecondPlayerName: string;
begin
Result := SecondPlayerName;
end;
procedure TSameComputerChessModule.HandleOnMove(AFrom, ATo: TPoint);
begin
end;
initialization
RegisterChessModule(TSameComputerChessModule.Create);
end.