Fixes an access violation on quit and implements support for multiple languages and for the all wordlists

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2151 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2011-11-17 06:57:03 +00:00
parent 3bc96963bc
commit dcc85b95c3
8 changed files with 167 additions and 154 deletions

View File

@ -1,22 +1,23 @@
object formConfig: TformConfig object formConfig: TformConfig
Left = 779 Left = 290
Height = 432 Height = 432
Top = 336 Top = 192
Width = 582 Width = 582
Caption = 'TappyTux Loader' Caption = 'TappyTux Loader'
ClientHeight = 432 ClientHeight = 432
ClientWidth = 582 ClientWidth = 582
OnClick = btnLoadClick OnClick = btnLoadClick
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow
Position = poDesktopCenter Position = poDesktopCenter
LCLVersion = '0.9.31' LCLVersion = '0.9.31'
Visible = True Visible = True
object comboGameType: TComboBox object comboGameType: TComboBox
Left = 9 Left = 9
Height = 23 Height = 21
Top = 38 Top = 38
Width = 183 Width = 183
ItemHeight = 15 ItemHeight = 0
OnChange = comboGameTypeChange OnChange = comboGameTypeChange
TabOrder = 0 TabOrder = 0
Text = 'GameType' Text = 'GameType'
@ -29,74 +30,66 @@ object formConfig: TformConfig
ReadOnly = True ReadOnly = True
TabOrder = 1 TabOrder = 1
end end
object listWordlist: TLabel object labelWordlist: TLabel
Left = 208 Left = 208
Height = 16 Height = 17
Top = 16 Top = 16
Width = 79 Width = 93
Caption = 'Select Wordlist' Caption = 'Select Wordlist'
ParentColor = False ParentColor = False
end end
object ltbWordlist: TListBox object listWordlist: TListBox
Left = 212 Left = 212
Height = 300 Height = 300
Top = 38 Top = 38
Width = 132 Width = 132
Items.Strings = ( ItemHeight = 0
'English'
'German'
'Afrikaans'
'French'
'Portuguese'
)
ItemHeight = 15
ScrollWidth = 130
TabOrder = 2 TabOrder = 2
end end
object lblSettings: TLabel object lblSettings: TLabel
Left = 400 Left = 392
Height = 16 Height = 17
Top = 16 Top = 16
Width = 43 Width = 52
Caption = 'Settings' Caption = 'Settings'
ParentColor = False ParentColor = False
end end
object lblSound: TLabel object lblSound: TLabel
Left = 408 Left = 367
Height = 16 Height = 17
Top = 47 Top = 72
Width = 53 Width = 63
Caption = 'Sound FX' Caption = 'Sound FX'
Font.Style = [fsBold] Font.Style = [fsBold]
ParentColor = False ParentColor = False
ParentFont = False ParentFont = False
end end
object lblMusic: TLabel object lblMusic: TLabel
Left = 408 Left = 367
Height = 16 Height = 17
Top = 79 Top = 104
Width = 33 Width = 40
Caption = 'Music' Caption = 'Music'
Font.Style = [fsBold] Font.Style = [fsBold]
ParentColor = False ParentColor = False
ParentFont = False ParentFont = False
end end
object lblLevel: TLabel object lblLevel: TLabel
Left = 408 Left = 367
Height = 16 Height = 17
Top = 111 Top = 132
Width = 79 Width = 93
Caption = 'Starting Level' Caption = 'Starting Level'
Font.Style = [fsBold] Font.Style = [fsBold]
ParentColor = False ParentColor = False
ParentFont = False ParentFont = False
end end
object comboSound: TComboBox object comboSound: TComboBox
Left = 493 Left = 464
Height = 23 Height = 21
Top = 40 Top = 68
Width = 68 Width = 104
ItemHeight = 15 ItemHeight = 0
Items.Strings = ( Items.Strings = (
'ON' 'ON'
'OFF' 'OFF'
@ -105,11 +98,11 @@ object formConfig: TformConfig
Text = 'Select' Text = 'Select'
end end
object comboMusic: TComboBox object comboMusic: TComboBox
Left = 493 Left = 464
Height = 23 Height = 21
Top = 72 Top = 96
Width = 68 Width = 104
ItemHeight = 15 ItemHeight = 0
Items.Strings = ( Items.Strings = (
'ON' 'ON'
'OFF' 'OFF'
@ -118,11 +111,11 @@ object formConfig: TformConfig
Text = 'Select' Text = 'Select'
end end
object comboLevel: TComboBox object comboLevel: TComboBox
Left = 493 Left = 464
Height = 23 Height = 21
Top = 104 Top = 128
Width = 68 Width = 104
ItemHeight = 15 ItemHeight = 0
Items.Strings = ( Items.Strings = (
'1' '1'
'2' '2'
@ -139,18 +132,18 @@ object formConfig: TformConfig
Text = 'Select' Text = 'Select'
end end
object lblCredits: TLabel object lblCredits: TLabel
Left = 400 Left = 440
Height = 16 Height = 17
Top = 168 Top = 200
Width = 38 Width = 46
Caption = 'Credits' Caption = 'Credits'
ParentColor = False ParentColor = False
end end
object memoCredits: TMemo object memoCredits: TMemo
Left = 408 Left = 367
Height = 173 Height = 125
Top = 189 Top = 237
Width = 153 Width = 201
Font.Height = -9 Font.Height = -9
Lines.Strings = ( Lines.Strings = (
'TappyTux 3.0 (2011)' 'TappyTux 3.0 (2011)'
@ -202,7 +195,7 @@ object formConfig: TformConfig
Height = 37 Height = 37
Top = 379 Top = 379
Width = 542 Width = 542
Caption = 'Load' Caption = 'Play'
OnClick = btnLoadClick OnClick = btnLoadClick
TabOrder = 7 TabOrder = 7
end end
@ -212,14 +205,41 @@ object formConfig: TformConfig
Top = 342 Top = 342
Width = 133 Width = 133
Caption = 'Wordlist Editor' Caption = 'Wordlist Editor'
Enabled = False
OnClick = btnWordlistClick
TabOrder = 8 TabOrder = 8
end end
object lblGameType: TLabel object lblGameType: TLabel
Left = 16 Left = 16
Height = 16 Height = 17
Top = 16 Top = 16
Width = 58 Width = 67
Caption = 'GameType' Caption = 'GameType'
ParentColor = False ParentColor = False
end end
object lblLevel1: TLabel
Left = 367
Height = 17
Top = 46
Width = 66
Caption = 'Language'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object comboLanguage: TComboBox
Left = 464
Height = 21
Top = 42
Width = 104
ItemHeight = 0
ItemIndex = 0
Items.Strings = (
'English'
'Portuguese'
)
OnChange = comboLanguageChange
TabOrder = 9
Text = 'English'
end
end end

View File

@ -18,23 +18,28 @@ type
TformConfig = class(TForm) TformConfig = class(TForm)
btnLoad: TButton; btnLoad: TButton;
btnWordlist: TButton; btnWordlist: TButton;
comboLanguage: TComboBox;
comboGameType: TComboBox; comboGameType: TComboBox;
comboSound: TComboBox; comboSound: TComboBox;
comboMusic: TComboBox; comboMusic: TComboBox;
comboLevel: TComboBox; comboLevel: TComboBox;
lblGameType: TLabel; lblGameType: TLabel;
listWordlist: TLabel; labelWordlist: TLabel;
lblLevel1: TLabel;
lblSettings: TLabel; lblSettings: TLabel;
lblSound: TLabel; lblSound: TLabel;
lblMusic: TLabel; lblMusic: TLabel;
lblLevel: TLabel; lblLevel: TLabel;
lblCredits: TLabel; lblCredits: TLabel;
ltbWordlist: TListBox; listWordlist: TListBox;
memoGameType: TMemo; memoGameType: TMemo;
memoCredits: TMemo; memoCredits: TMemo;
procedure btnLoadClick(Sender: TObject); procedure btnLoadClick(Sender: TObject);
procedure btnWordlistClick(Sender: TObject);
procedure comboGameTypeChange(Sender: TObject); procedure comboGameTypeChange(Sender: TObject);
procedure comboLanguageChange(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure memoCreditsChange(Sender: TObject); procedure memoCreditsChange(Sender: TObject);
private private
{ private declarations } { private declarations }
@ -54,10 +59,29 @@ implementation
{ TformConfig } { TformConfig }
procedure TformConfig.comboGameTypeChange(Sender: TObject); procedure TformConfig.comboGameTypeChange(Sender: TObject);
var
lModule: TTappyModule;
begin begin
memoGameType.Clear; lModule := GetModule(comboGameType.itemIndex);
memoGameType.Lines.Add(GetModule(comboGameType.itemIndex).LongDescription); memoGameType.Text := lModule.LongDescription;
labelWordlist.Caption := lModule.ConfigCaption;
listWordlist.Items.Text := lModule.ConfigItems;
if listWordlist.Items.Count >= comboLanguage.ItemIndex then
listWordlist.ItemIndex := comboLanguage.ItemIndex;
end;
procedure TformConfig.comboLanguageChange(Sender: TObject);
begin
case comboLanguage.ItemIndex of
0:
begin
end;
1:
begin
end;
end;
end; end;
procedure TformConfig.btnLoadClick(Sender: TObject); procedure TformConfig.btnLoadClick(Sender: TObject);
@ -65,11 +89,16 @@ begin
SetCurrentModule(comboGameType.ItemIndex); SetCurrentModule(comboGameType.ItemIndex);
formTappyTuxGame.Show; formTappyTuxGame.Show;
GetCurrentModule().StartNewGame(comboSound.ItemIndex, comboMusic.ItemIndex, GetCurrentModule().StartNewGame(comboSound.ItemIndex, comboMusic.ItemIndex,
comboLevel.ItemIndex, ltbWordlist.ItemIndex); comboLevel.ItemIndex, listWordlist.ItemIndex);
Hide; Hide;
end; end;
procedure TformConfig.btnWordlistClick(Sender: TObject);
begin
end;
procedure TformConfig.FormCreate(Sender: TObject); procedure TformConfig.FormCreate(Sender: TObject);
var var
i: Integer; i: Integer;
@ -81,6 +110,11 @@ begin
GetModule(i).InitModule(); GetModule(i).InitModule();
end; end;
procedure TformConfig.FormShow(Sender: TObject);
begin
comboGameTypeChange(Self);
end;
procedure TformConfig.memoCreditsChange(Sender: TObject); procedure TformConfig.memoCreditsChange(Sender: TObject);
begin begin

View File

@ -71,6 +71,7 @@ end;
procedure TformTappyTuxGame.FormClose(Sender: TObject; procedure TformTappyTuxGame.FormClose(Sender: TObject;
var CloseAction: TCloseAction); var CloseAction: TCloseAction);
begin begin
CloseAction := caHide;
GetCurrentModule().EndGame(); GetCurrentModule().EndGame();
end; end;

View File

@ -1,71 +0,0 @@
cachorro
gato
peixe
p�ssaro
macaco
le�o
tigre
elefante
crocodilo
abelha
mosca
�gua-viva
tartaruga
lagartixa
sapo
minhoca
centop�ia
rinoceronte
coiote
�guia
canguru
coala
morcego
gavi�o
pav�o
cobra
camelo
lontra
tubar�o
coelho
baleia
urso
foca
escorpi�o
touro
vaca
galinha
formiga
borboleta
girafa
arara
salamandra
r�
pinguim
tatu
avestruz
hiena
pelicano
pombo
orangotango
coruja
papagaio
tucano
ornitorrinco
gamb�
rato
esquilo
golfinho
ovelha
morsa
suricato
ornitorrinco
toupeira
barata
lula
polvo
tamandu�
camar�o
l�mure
besouro
on�a

View File

@ -1,51 +1,51 @@
ano ano
abrir abrir
amargo amargo
boi boi
beber beber
beliche beliche
cão cão
casa casa
cozinha cozinha
dia dia
dois dois
duelo duelo
ema ema
então então
elefante elefante
foca foca
filme filme
feijão feijão
gás gás
gostar gostar
goiaba goiaba
há
haste haste
hotel hotel
ímã rei
isto isto
isolar isolar
já já
jóia
jacaré jacaré
ler ler
lesma lesma
lista lista
mal mal
mau mau
menina menina
não o
nada nada
nascer nascer
oi oi
ora ora
ontem ontem
pio pio
pão pão
palito palito
quem quem
queijo queijo
rói caçar
rimar rimar
reunir reunir
sino sino
@ -53,13 +53,12 @@ simples
similar similar
tatu tatu
triste triste
tâmara tâmara
uva uva
urubu urubu
unânime unânime
véu vôo
veia veia
vestido vestido
zelar zelar
zumbido zumbido

View File

@ -312,6 +312,8 @@ begin
vTappyTuxDrawer.RemoveAnimation(i); vTappyTuxDrawer.RemoveAnimation(i);
j := vTappyTuxDrawer.GetAnimationCount - 1; j := vTappyTuxDrawer.GetAnimationCount - 1;
end; end;
GoToConfigForm();
end; end;
procedure TTappyMath.GameWon; procedure TTappyMath.GameWon;

View File

@ -40,6 +40,7 @@ type
procedure StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); override; procedure StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); override;
procedure createQuestion(); override; procedure createQuestion(); override;
function GetFallingDurationFromLevel: Integer; function GetFallingDurationFromLevel: Integer;
function GetTextFileFromLanguageId(AID: Integer): string;
procedure Answered(AText: string); override; procedure Answered(AText: string); override;
procedure EndGame(); override; procedure EndGame(); override;
procedure GameWon(); override; procedure GameWon(); override;
@ -82,6 +83,14 @@ begin
timerWords.OnTimer := @HandleOnTimer; timerWords.OnTimer := @HandleOnTimer;
NewQuestionFrequency := 5000; NewQuestionFrequency := 5000;
ConfigItems :=
'English' + LineEnding +
'Portuguese' + LineEnding +
'French' + LineEnding +
'German' + LineEnding +
'Italian' + LineEnding +
'Afrikaans' + LineEnding;
end; end;
destructor TTappyWords.Destroy; destructor TTappyWords.Destroy;
@ -95,12 +104,14 @@ procedure TTappyWords.TranslateTextsToEnglish;
begin begin
ShortDescription := 'TappyWords'; ShortDescription := 'TappyWords';
LongDescription := 'A game to learn typing and ortography.'; // Hint: Try to keep looking at the screen instead of the keyboard! LongDescription := 'A game to learn typing and ortography.'; // Hint: Try to keep looking at the screen instead of the keyboard!
ConfigCaption := 'Select a list of words';
end; end;
procedure TTappyWords.TranslateTextsToPortuguese; procedure TTappyWords.TranslateTextsToPortuguese;
begin begin
ShortDescription := 'TappyWords'; ShortDescription := 'TappyWords';
LongDescription := 'Um jogo para aprender a digitar e ortografia'; LongDescription := 'Um jogo para aprender a digitar e ortografia';
ConfigCaption := 'Selecione uma lista de palavras';
end; end;
procedure TTappyWords.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); procedure TTappyWords.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer);
@ -121,9 +132,12 @@ begin
if (Music = 1) then gameMusic := false; if (Music = 1) then gameMusic := false;
gameSLevel := gameLevel; gameSLevel := gameLevel;
// Loads the list of questions
if QuestionList < 0 then QuestionList := 0; if QuestionList < 0 then QuestionList := 0;
gameQuestionList := TStringList.Create; gameQuestionList := TStringList.Create;
gameQuestionList.LoadFromFile(vTappyTuxConfig.GetResourcesDir() + 'images'+PathDelim+'modules'+PathDelim+'tappywords'+PathDelim+'0.txt'); gameQuestionList.LoadFromFile(vTappyTuxConfig.GetResourcesDir() +
'images' + PathDelim + 'modules' + PathDelim + 'tappywords'
+ PathDelim + GetTextFileFromLanguageId(QuestionList));
//gameQuestionList.LoadFromFile('C:/'+IntToStr(QuestionList)+'.txt'); //gameQuestionList.LoadFromFile('C:/'+IntToStr(QuestionList)+'.txt');
UpdateLevel(gameLevel); UpdateLevel(gameLevel);
@ -244,6 +258,19 @@ begin
end; end;
end; end;
function TTappyWords.GetTextFileFromLanguageId(AID: Integer): string;
begin
case AID of
1: Result := 'wordlist.Portuguese';
2: Result := 'wordlist.French';
3: Result := 'wordlist.German';
4: Result := 'wordlist.Italian';
5: Result := 'wordlist.Afrikaans';
else
Result := 'wordlist.English';
end;
end;
procedure TTappyWords.Answered(AText: string); procedure TTappyWords.Answered(AText: string);
var var
i: Integer; i: Integer;

View File

@ -18,6 +18,7 @@ type
imgLevel2, imgLevel3: TJPEGImage; imgLevel2, imgLevel3: TJPEGImage;
imgPenguim : TBitmap; imgPenguim : TBitmap;
ShortDescription, LongDescription: string; ShortDescription, LongDescription: string;
ConfigCaption, ConfigItems: string;
constructor Create; virtual; constructor Create; virtual;
destructor Destroy; override; destructor Destroy; override;
procedure LoadImages; virtual; procedure LoadImages; virtual;
@ -127,7 +128,7 @@ begin
StartNewGame(formConfig.comboSound.ItemIndex, StartNewGame(formConfig.comboSound.ItemIndex,
formConfig.comboMusic.ItemIndex, formConfig.comboMusic.ItemIndex,
formConfig.comboLevel.ItemIndex, formConfig.comboLevel.ItemIndex,
formConfig.ltbWordlist.ItemIndex); formConfig.listWordlist.ItemIndex);
end; end;
procedure TTappyModule.UpdateLevel(ALevel: Integer); procedure TTappyModule.UpdateLevel(ALevel: Integer);