tappytux: Removes the fixed background and implements real drawing in the drawer component

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1960 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat 2011-09-15 14:14:50 +00:00
parent a487e2f6d7
commit e8a94cd00b
10 changed files with 185 additions and 1628 deletions

View File

@ -1,4 +1,4 @@
object Form1: TForm1
object formConfig: TformConfig
Left = 578
Height = 436
Top = 262
@ -10,28 +10,28 @@ object Form1: TForm1
OnCreate = FormCreate
LCLVersion = '0.9.31'
object comboGameType: TComboBox
Left = 17
Height = 23
Left = 9
Height = 27
Top = 38
Width = 100
ItemHeight = 15
Width = 183
ItemHeight = 0
OnChange = comboGameTypeChange
TabOrder = 0
Text = 'GameType'
end
object memoGameType: TMemo
Left = 17
Left = 8
Height = 290
Top = 72
Width = 143
Width = 184
ReadOnly = True
TabOrder = 1
end
object listWordlist: TLabel
Left = 208
Height = 16
Height = 18
Top = 16
Width = 79
Width = 94
Caption = 'Select Wordlist'
ParentColor = False
end
@ -47,22 +47,23 @@ object Form1: TForm1
'French'
'Portuguese'
)
ItemHeight = 15
ItemHeight = 23
ScrollWidth = 130
TabOrder = 2
end
object lblSettings: TLabel
Left = 400
Height = 16
Height = 18
Top = 16
Width = 43
Width = 54
Caption = 'Settings'
ParentColor = False
end
object lblSound: TLabel
Left = 408
Height = 16
Height = 18
Top = 47
Width = 53
Width = 71
Caption = 'Sound FX'
Font.Style = [fsBold]
ParentColor = False
@ -70,9 +71,9 @@ object Form1: TForm1
end
object lblMusic: TLabel
Left = 408
Height = 16
Height = 18
Top = 79
Width = 33
Width = 43
Caption = 'Music'
Font.Style = [fsBold]
ParentColor = False
@ -80,9 +81,9 @@ object Form1: TForm1
end
object lblLevel: TLabel
Left = 408
Height = 16
Height = 18
Top = 111
Width = 79
Width = 103
Caption = 'Starting Level'
Font.Style = [fsBold]
ParentColor = False
@ -90,10 +91,10 @@ object Form1: TForm1
end
object comboSound: TComboBox
Left = 493
Height = 23
Height = 27
Top = 40
Width = 68
ItemHeight = 15
ItemHeight = 0
Items.Strings = (
'ON'
'OFF'
@ -104,10 +105,10 @@ object Form1: TForm1
end
object comboMusic: TComboBox
Left = 493
Height = 23
Height = 27
Top = 72
Width = 68
ItemHeight = 15
ItemHeight = 0
Items.Strings = (
'ON'
'OFF'
@ -117,10 +118,10 @@ object Form1: TForm1
end
object comboLevel: TComboBox
Left = 493
Height = 23
Height = 27
Top = 104
Width = 68
ItemHeight = 15
ItemHeight = 0
Items.Strings = (
'1'
'2'
@ -138,9 +139,9 @@ object Form1: TForm1
end
object lblCredits: TLabel
Left = 400
Height = 16
Height = 18
Top = 168
Width = 38
Width = 46
Caption = 'Credits'
ParentColor = False
end
@ -188,9 +189,9 @@ object Form1: TForm1
end
object lblGameType: TLabel
Left = 16
Height = 16
Height = 18
Top = 16
Width = 58
Width = 68
Caption = 'GameType'
ParentColor = False
end

View File

@ -11,9 +11,9 @@ uses
type
{ TForm1 }
{ TformConfig }
TForm1 = class(TForm)
TformConfig = class(TForm)
btnLoad: TButton;
btnWordlist: TButton;
comboGameType: TComboBox;
@ -43,16 +43,16 @@ type
end;
var
Form1: TForm1;
formConfig: TformConfig;
implementation
{$R *.lfm}
{ TForm1 }
{ TformConfig }
procedure TForm1.comboGameTypeChange(Sender: TObject);
procedure TformConfig.comboGameTypeChange(Sender: TObject);
begin
Case comboGameType.itemIndex of
@ -74,14 +74,15 @@ begin
end;
procedure TForm1.btnLoadClick(Sender: TObject);
procedure TformConfig.btnLoadClick(Sender: TObject);
begin
Form2.Show;
Hide;
SetCurrentModule(comboGameType.ItemIndex);
formTappyTuxGame.Show;
Hide;
end;
procedure TForm1.comboSoundChange(Sender: TObject);
procedure TformConfig.comboSoundChange(Sender: TObject);
begin
{
@ -100,17 +101,17 @@ begin
end;
procedure TForm1.FormClick(Sender: TObject);
procedure TformConfig.FormClick(Sender: TObject);
begin
end;
procedure TForm1.FormCreate(Sender: TObject);
procedure TformConfig.FormCreate(Sender: TObject);
begin
TranslateUI();
end;
procedure TForm1.TranslateUI;
procedure TformConfig.TranslateUI;
var
i: Integer;
lModule: TTappyModule;

File diff suppressed because it is too large Load Diff

View File

@ -6,19 +6,20 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls;
ExtCtrls,
// TappyTux
tappydrawer;
type
{ TForm2 }
{ TformTappyTuxGame }
TForm2 = class(TForm)
TformTappyTuxGame = class(TForm)
btnExit: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
@ -30,13 +31,11 @@ type
{ private declarations }
public
{ public declarations }
backgroundImage: TJpegImage;
end;
end;
var
Form2: TForm2;
formTappyTuxGame: TformTappyTuxGame;
implementation
@ -44,27 +43,33 @@ uses gameconfigform;
{$R *.lfm}
{ TForm2 }
{ TformTappyTuxGame }
procedure TForm2.btnExitClick(Sender: TObject);
procedure TformTappyTuxGame.btnExitClick(Sender: TObject);
begin
Close;
Form1.Show;
formConfig.Show;
end;
procedure TForm2.Edit1KeyPress(Sender: TObject; var Key: char);
procedure TformTappyTuxGame.Edit1KeyPress(Sender: TObject; var Key: char);
begin
if Key = #13 then
begin
Form2.Memo1.Lines.Add(Edit1.Text);
Form2.Edit1.Clear;
formTappyTuxGame.Memo1.Lines.Add(Edit1.Text);
formTappyTuxGame.Edit1.Clear;
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
procedure TformTappyTuxGame.FormCreate(Sender: TObject);
begin
// Creation of internal components
vTappyTuxDrawer := TTappyTuxDrawer.Create(Self);
vTappyTuxDrawer.Parent := Self;
vTappyTuxDrawer.Top := 0;
vTappyTuxDrawer.Left := 100;
vTappyTuxDrawer.Height := Height-vTappyTuxDrawer.Top;
vTappyTuxDrawer.Width := Width-vTappyTuxDrawer.Left;
vTappyTuxDrawer.SendToBack();
end;

View File

@ -14,11 +14,11 @@ type
TTappyTuxConfig = class
public
function GetResourcesDir: string;
function GetCurrentSkinDir: string;
end;
const
STR_LINUX_RESOURCES_FOLDER = '/usr/share/tappytux/';
STR_LINUX_RESOURCES_FOLDER = '/home/felipe/Programas/lazarus-ccr/applications/tappytux/'; // Temporary debug path
//STR_LINUX_RESOURCES_FOLDER = '/usr/share/tappytux/'; // Real path
ID_ENGLISH = 0;
ID_PORTUGUESE = 1;
@ -65,11 +65,6 @@ begin
{$endif}
end;
function TTappyTuxConfig.GetCurrentSkinDir: string;
begin
Result := GetResourcesDir() + 'skins' + PathDelim + 'classic' + PathDelim;
end;
initialization
vTappyTuxConfig := TTappyTuxConfig.Create;

View File

@ -160,7 +160,7 @@ begin
lTmpBmp := TBitmap.Create;
try
// First draw the background
lIntfImage.LoadFromBitmap(GetCurrentModule().imgBackground.Handle, 0{bmpBoard.MaskHandle});
lIntfImage.LoadFromBitmap(GetCurrentModule().GetBackgroundImage(2).Handle, 0{bmpBoard.MaskHandle});
// Now the module should draw itself

View File

@ -1,6 +1,6 @@
unit tappygamedata;
{$mode objfpc}{$H}
{$mode objfpc}{$H+}
interface

View File

@ -14,11 +14,12 @@ type
TTappyModule = class
public
imgBackground: TPortableNetworkGraphic;
imgLevel2, imgLevel3: TJPEGImage;
ShortDescription, LongDescription: string;
constructor Create; virtual;
destructor Destroy; override;
procedure LoadImages; virtual;
function GetBackgroundImage(ALevel: Integer): TJPEGImage;
procedure TranslateTexts(ALanguage: Integer);
procedure TranslateTextsToEnglish; virtual;
procedure TranslateTextsToPortuguese; virtual;
@ -67,35 +68,35 @@ constructor TTappyModule.Create;
begin
inherited Create;
imgLevel2 := TJPEGImage.Create;
imgLevel3 := TJPEGImage.Create;
LoadImages();
TranslateTexts(ID_ENGLISH);
end;
destructor TTappyModule.Destroy;
begin
imgLevel2.Free;
imgLevel3.Free;
inherited Destroy;
end;
procedure TTappyModule.LoadImages;
var
lDir: string;
begin
{ var
lDir: string;
begin
lDir := vChessConfig.GetCurrentSkinDir();}
lDir := vTappyTuxConfig.GetResourcesDir();
{ imgBoard.LoadFromFile(lDir + 'base.png');
imgWPawn.LoadFromFile(lDir + 'wpawn.png');
imgWKnight.LoadFromFile(lDir + 'wknight.png');
imgWBishop.LoadFromFile(lDir + 'wbishop.png');
imgWRook.LoadFromFile(lDir + 'wrook.png');
imgWQueen.LoadFromFile(lDir + 'wqueen.png');
imgWKing.LoadFromFile(lDir + 'wking.png');
imgBPawn.LoadFromFile(lDir + 'bpawn.png');
imgBKnight.LoadFromFile(lDir + 'bknight.png');
imgBBishop.LoadFromFile(lDir + 'bbishop.png');
imgBRook.LoadFromFile(lDir + 'brook.png');
imgBQueen.LoadFromFile(lDir + 'bqueen.png');
imgBKing.LoadFromFile(lDir + 'bking.png');}
imgLevel2.LoadFromFile(lDir + 'images/levels/level2.jpg');
imgLevel3.LoadFromFile(lDir + 'images/levels/level3.jpg');
end;
function TTappyModule.GetBackgroundImage(ALevel: Integer): TJPEGImage;
begin
Result := imgLevel3;
end;
procedure TTappyModule.TranslateTexts(ALanguage: Integer);

View File

@ -27,6 +27,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@ -39,90 +40,87 @@
<Filename Value="tappytux.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="tappytux"/>
<UsageCount Value="35"/>
<UsageCount Value="36"/>
</Unit0>
<Unit1>
<Filename Value="gameconfigform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ComponentName Value="formConfig"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="gameconfigform"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
<TopLine Value="68"/>
<CursorPos X="16" Y="85"/>
<UsageCount Value="35"/>
<TopLine Value="27"/>
<CursorPos X="10" Y="55"/>
<UsageCount Value="36"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="gameplayform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form2"/>
<ComponentName Value="formTappyTuxGame"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="gameplayform"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="40"/>
<CursorPos X="48" Y="60"/>
<UsageCount Value="35"/>
<TopLine Value="28"/>
<CursorPos X="28" Y="69"/>
<UsageCount Value="36"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit2>
<Unit3>
<Filename Value="tappyconfig.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="tappyconfig"/>
<EditorIndex Value="4"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="21" Y="24"/>
<UsageCount Value="29"/>
<TopLine Value="16"/>
<CursorPos X="19" Y="50"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="tappydrawer.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="tappydrawer"/>
<EditorIndex Value="5"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="70" Y="291"/>
<UsageCount Value="29"/>
<TopLine Value="183"/>
<CursorPos X="31" Y="189"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="tappygamedata.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="tappygamedata"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="35" Y="72"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
<TopLine Value="229"/>
<CursorPos X="19" Y="3"/>
<UsageCount Value="30"/>
</Unit5>
<Unit6>
<Filename Value="mod_tappywords.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mod_tappywords"/>
<EditorIndex Value="6"/>
<EditorIndex Value="5"/>
<WindowIndex Value="0"/>
<TopLine Value="12"/>
<TopLine Value="1"/>
<CursorPos X="1" Y="15"/>
<UsageCount Value="29"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="tappymodules.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="tappymodules"/>
<EditorIndex Value="7"/>
<EditorIndex Value="6"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="30" Y="70"/>
<UsageCount Value="29"/>
<TopLine Value="56"/>
<CursorPos X="4" Y="101"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
@ -133,7 +131,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="6" Y="39"/>
<UsageCount Value="28"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
@ -147,123 +145,123 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="gameplayform.pas"/>
<Caret Line="23" Column="20" TopLine="4"/>
<Caret Line="11" Column="30" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="gameplayform.pas"/>
<Caret Line="48" Column="41" TopLine="21"/>
<Filename Value="gameconfigform.pas"/>
<Caret Line="85" Column="16" TopLine="68"/>
</Position2>
<Position3>
<Filename Value="gameconfigform.pas"/>
<Caret Line="105" Column="52" TopLine="69"/>
<Caret Line="80" Column="45" TopLine="55"/>
</Position3>
<Position4>
<Filename Value="gameconfigform.pas"/>
<Caret Line="108" Column="38" TopLine="96"/>
<Filename Value="gameplayform.pas"/>
<Caret Line="42" Column="21" TopLine="1"/>
</Position4>
<Position5>
<Filename Value="gameplayform.pas"/>
<Caret Line="23" Column="28" TopLine="9"/>
<Caret Line="51" Column="8" TopLine="27"/>
</Position5>
<Position6>
<Filename Value="gameplayform.pas"/>
<Caret Line="47" Column="40" TopLine="23"/>
<Filename Value="tappydrawer.pas"/>
<Caret Line="163" Column="41" TopLine="152"/>
</Position6>
<Position7>
<Filename Value="gameplayform.pas"/>
<Caret Line="30" Column="35" TopLine="26"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="22" Column="25" TopLine="1"/>
</Position7>
<Position8>
<Filename Value="gameplayform.pas"/>
<Caret Line="32" Column="35" TopLine="28"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="79" Column="17" TopLine="58"/>
</Position8>
<Position9>
<Filename Value="gameplayform.pas"/>
<Caret Line="31" Column="35" TopLine="27"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="89" Column="23" TopLine="65"/>
</Position9>
<Position10>
<Filename Value="gameplayform.pas"/>
<Caret Line="50" Column="1" TopLine="22"/>
<Filename Value="tappydrawer.pas"/>
<Caret Line="163" Column="41" TopLine="152"/>
</Position10>
<Position11>
<Filename Value="gameplayform.pas"/>
<Caret Line="51" Column="1" TopLine="23"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="89" Column="26" TopLine="65"/>
</Position11>
<Position12>
<Filename Value="gameplayform.pas"/>
<Caret Line="52" Column="1" TopLine="24"/>
<Filename Value="tappydrawer.pas"/>
<Caret Line="163" Column="50" TopLine="100"/>
</Position12>
<Position13>
<Filename Value="gameplayform.pas"/>
<Caret Line="53" Column="1" TopLine="25"/>
<Filename Value="tappydrawer.pas"/>
<Caret Line="149" Column="120" TopLine="139"/>
</Position13>
<Position14>
<Filename Value="gameplayform.pas"/>
<Caret Line="54" Column="1" TopLine="26"/>
<Filename Value="tappydrawer.pas"/>
<Caret Line="163" Column="1" TopLine="139"/>
</Position14>
<Position15>
<Filename Value="gameplayform.pas"/>
<Caret Line="55" Column="1" TopLine="27"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="47" Column="1" TopLine="23"/>
</Position15>
<Position16>
<Filename Value="gameplayform.pas"/>
<Caret Line="32" Column="3" TopLine="28"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="42" Column="15" TopLine="24"/>
</Position16>
<Position17>
<Filename Value="gameplayform.pas"/>
<Caret Line="34" Column="3" TopLine="30"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="52" Column="1" TopLine="24"/>
</Position17>
<Position18>
<Filename Value="gameplayform.pas"/>
<Caret Line="58" Column="26" TopLine="35"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="42" Column="1" TopLine="24"/>
</Position18>
<Position19>
<Filename Value="gameplayform.pas"/>
<Caret Line="51" Column="41" TopLine="35"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="52" Column="1" TopLine="24"/>
</Position19>
<Position20>
<Filename Value="gameplayform.pas"/>
<Caret Line="45" Column="50" TopLine="31"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="53" Column="1" TopLine="24"/>
</Position20>
<Position21>
<Filename Value="gameplayform.pas"/>
<Caret Line="75" Column="3" TopLine="43"/>
<Filename Value="gameconfigform.pas"/>
<Caret Line="121" Column="1" TopLine="80"/>
</Position21>
<Position22>
<Filename Value="gameplayform.pas"/>
<Caret Line="56" Column="5" TopLine="33"/>
<Filename Value="gameconfigform.pas"/>
<Caret Line="120" Column="1" TopLine="80"/>
</Position22>
<Position23>
<Filename Value="gameplayform.pas"/>
<Caret Line="28" Column="43" TopLine="23"/>
<Filename Value="gameconfigform.pas"/>
<Caret Line="79" Column="49" TopLine="77"/>
</Position23>
<Position24>
<Filename Value="gameconfigform.pas"/>
<Caret Line="82" Column="45" TopLine="66"/>
<Caret Line="80" Column="23" TopLine="55"/>
</Position24>
<Position25>
<Filename Value="gameconfigform.pas"/>
<Caret Line="80" Column="23" TopLine="64"/>
<Caret Line="79" Column="12" TopLine="55"/>
</Position25>
<Position26>
<Filename Value="gameconfigform.pas"/>
<Caret Line="82" Column="40" TopLine="64"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="22" Column="75" TopLine="14"/>
</Position26>
<Position27>
<Filename Value="gameconfigform.pas"/>
<Caret Line="85" Column="52" TopLine="65"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="98" Column="22" TopLine="77"/>
</Position27>
<Position28>
<Filename Value="gameconfigform.pas"/>
<Caret Line="80" Column="26" TopLine="64"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="22" Column="74" TopLine="1"/>
</Position28>
<Position29>
<Filename Value="gameconfigform.pas"/>
<Caret Line="85" Column="42" TopLine="64"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="96" Column="29" TopLine="77"/>
</Position29>
<Position30>
<Filename Value="gameconfigform.pas"/>
<Caret Line="80" Column="41" TopLine="64"/>
<Filename Value="tappymodules.pas"/>
<Caret Line="22" Column="74" TopLine="1"/>
</Position30>
</JumpHistory>
</ProjectOptions>

View File

@ -16,8 +16,8 @@ uses
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.CreateForm(TformConfig, formConfig);
Application.CreateForm(TformTappyTuxGame, formTappyTuxGame);
Application.Run;
end.