fpchess: Some fixes

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1845 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2011-08-27 21:16:40 +00:00
parent 797e6dfabd
commit de135f4ea0
4 changed files with 34 additions and 23 deletions

View File

@ -1,7 +1,7 @@
object formChess: TformChess object formChess: TformChess
Left = 216 Left = 318
Height = 433 Height = 433
Top = 164 Top = 123
Width = 360 Width = 360
ActiveControl = notebookMain ActiveControl = notebookMain
Caption = 'FP Chess 0.1' Caption = 'FP Chess 0.1'
@ -123,8 +123,9 @@ object formChess: TformChess
Left = 8 Left = 8
Height = 21 Height = 21
Top = 74 Top = 74
Width = 338 Width = 346
ItemHeight = 0 ItemHeight = 0
OnChange = comboGameModeSelect
OnSelect = comboGameModeSelect OnSelect = comboGameModeSelect
TabOrder = 5 TabOrder = 5
Text = 'comboGameMode' Text = 'comboGameMode'
@ -168,8 +169,8 @@ object formChess: TformChess
end end
end end
object pageGame: TPage object pageGame: TPage
ClientWidth = 360 ClientWidth = 720
ClientHeight = 433 ClientHeight = 866
object Label5: TLabel object Label5: TLabel
AnchorSideRight.Control = pageGame AnchorSideRight.Control = pageGame
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@ -201,10 +202,17 @@ object formChess: TformChess
Caption = 'labelTime' Caption = 'labelTime'
ParentColor = False ParentColor = False
end end
object memoDebug: TMemo
Left = 8
Height = 106
Top = 440
Width = 344
TabOrder = 0
end
end end
object pageWebservice: TPage object pageWebservice: TPage
ClientWidth = 360 ClientWidth = 720
ClientHeight = 433 ClientHeight = 866
object Label8: TLabel object Label8: TLabel
Left = 0 Left = 0
Height = 32 Height = 32

View File

@ -46,6 +46,7 @@ type
editWebServiceAI: TLabeledEdit; editWebServiceAI: TLabeledEdit;
labelPos: TLabel; labelPos: TLabel;
editPlayerName: TLabeledEdit; editPlayerName: TLabeledEdit;
memoDebug: TMemo;
pageStart: TPage; pageStart: TPage;
notebookMain: TNotebook; notebookMain: TNotebook;
panelModules: TPanel; panelModules: TPanel;
@ -121,7 +122,7 @@ begin
if ANewIndex = gSelectedModuleIndex then Exit; if ANewIndex = gSelectedModuleIndex then Exit;
lModule := GetChessModule(gSelectedModuleIndex); lModule := GetChessModule(gSelectedModuleIndex);
if lModule <> nil then lModule.FreeUserInterface(); if lModule <> nil then lModule.HideUserInterface();
GetChessModule(ANewIndex).ShowUserInterface(panelModules); GetChessModule(ANewIndex).ShowUserInterface(panelModules);
end; end;
@ -170,7 +171,9 @@ begin
begin begin
comboGameMode.ItemIndex := 0; comboGameMode.ItemIndex := 0;
UpdateChessModulesUI(0); UpdateChessModulesUI(0);
gSelectedModuleIndex := 0;
end; end;
gChessModulesDebugOutputDestiny := memoDebug.Lines;
end; end;
procedure TformChess.btnQuitClick(Sender: TObject); procedure TformChess.btnQuitClick(Sender: TObject);

View File

@ -20,9 +20,9 @@ uses
type type
{ TSinglePlayerChessModule } { TFICSChessModule }
TSinglePlayerChessModule = class(TChessModule) TFICSChessModule = class(TChessModule)
public public
SecondPlayerName: string; SecondPlayerName: string;
constructor Create(); constructor Create();
@ -38,9 +38,9 @@ type
implementation implementation
{ TSinglePlayerChessModule } { TFICSChessModule }
constructor TSinglePlayerChessModule.Create; constructor TFICSChessModule.Create;
begin begin
inherited Create; inherited Create;
@ -48,7 +48,7 @@ begin
Kind := cmkSinglePlayer; Kind := cmkSinglePlayer;
end; end;
procedure TSinglePlayerChessModule.CreateUserInterface; procedure TFICSChessModule.CreateUserInterface;
begin begin
{ textSecondPlayerName := TStaticText.Create(nil); { textSecondPlayerName := TStaticText.Create(nil);
textSecondPlayerName.SetBounds(20, 20, 180, 50); textSecondPlayerName.SetBounds(20, 20, 180, 50);
@ -59,48 +59,48 @@ begin
editSecondPlayerName.Text := 'Second player';} editSecondPlayerName.Text := 'Second player';}
end; end;
procedure TSinglePlayerChessModule.ShowUserInterface(AParent: TWinControl); procedure TFICSChessModule.ShowUserInterface(AParent: TWinControl);
begin begin
{ textSecondPlayerName.Parent := AParent; { textSecondPlayerName.Parent := AParent;
editSecondPlayerName.Parent := AParent;} editSecondPlayerName.Parent := AParent;}
end; end;
procedure TSinglePlayerChessModule.HideUserInterface(); procedure TFICSChessModule.HideUserInterface();
begin begin
{ textSecondPlayerName.Parent := nil; { textSecondPlayerName.Parent := nil;
editSecondPlayerName.Parent := nil;} editSecondPlayerName.Parent := nil;}
end; end;
procedure TSinglePlayerChessModule.FreeUserInterface; procedure TFICSChessModule.FreeUserInterface;
begin begin
{ textSecondPlayerName.Free; { textSecondPlayerName.Free;
editSecondPlayerName.Free;} editSecondPlayerName.Free;}
end; end;
procedure TSinglePlayerChessModule.PrepareForGame; procedure TFICSChessModule.PrepareForGame;
begin begin
// SecondPlayerName := editSecondPlayerName.Text; // SecondPlayerName := editSecondPlayerName.Text;
ChessModuleDebugLn('[TSinglePlayerChessModule.PrepareForGame]'); ChessModuleDebugLn('[TFICSChessModule.PrepareForGame]');
end; end;
function TSinglePlayerChessModule.IsMovingAllowedNow: Boolean; function TFICSChessModule.IsMovingAllowedNow: Boolean;
begin begin
Result := not (vChessGame.IsWhitePlayerTurn xor vChessGame.FirstPlayerIsWhite); Result := not (vChessGame.IsWhitePlayerTurn xor vChessGame.FirstPlayerIsWhite);
end; end;
function TSinglePlayerChessModule.GetSecondPlayerName: string; function TFICSChessModule.GetSecondPlayerName: string;
begin begin
// Result := SecondPlayerName; // Result := SecondPlayerName;
end; end;
// If a move came, it is because the local player did a move // If a move came, it is because the local player did a move
// so send this move and start listening for a move // so send this move and start listening for a move
procedure TSinglePlayerChessModule.HandleOnMove(AFrom, ATo: TPoint); procedure TFICSChessModule.HandleOnMove(AFrom, ATo: TPoint);
begin begin
end; end;
initialization initialization
RegisterChessModule(TSinglePlayerChessModule.Create); RegisterChessModule(TFICSChessModule.Create);
end. end.

View File

@ -65,7 +65,7 @@ begin
editSecondPlayerName.Parent := nil; editSecondPlayerName.Parent := nil;
end; end;
procedure TSinglePlayerChessModule.FreeUserInterface; procedure TSinglePlayerChessModule.FreeUserInterface();
begin begin
textSecondPlayerName.Free; textSecondPlayerName.Free;
editSecondPlayerName.Free; editSecondPlayerName.Free;