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

View File

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

View File

@ -71,6 +71,7 @@ end;
procedure TformTappyTuxGame.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
CloseAction := caHide;
GetCurrentModule().EndGame();
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
amargo
boi
beber
beliche
cão
cão
casa
cozinha
dia
dois
duelo
ema
então
então
elefante
foca
filme
feijão
gás
feijão
gás
gostar
goiaba
há
haste
hotel
ímã
rei
isto
isolar
já
jóia
jacaré
já
jacaré
ler
lesma
lista
mal
mau
menina
não
o
nada
nascer
oi
ora
ontem
pio
pão
pão
palito
quem
queijo
rói
caçar
rimar
reunir
sino
@ -53,13 +53,12 @@ simples
similar
tatu
triste
tâmara
tâmara
uva
urubu
unânime
véu
unânime
vôo
veia
vestido
zelar
zumbido

View File

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

View File

@ -40,6 +40,7 @@ type
procedure StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer); override;
procedure createQuestion(); override;
function GetFallingDurationFromLevel: Integer;
function GetTextFileFromLanguageId(AID: Integer): string;
procedure Answered(AText: string); override;
procedure EndGame(); override;
procedure GameWon(); override;
@ -82,6 +83,14 @@ begin
timerWords.OnTimer := @HandleOnTimer;
NewQuestionFrequency := 5000;
ConfigItems :=
'English' + LineEnding +
'Portuguese' + LineEnding +
'French' + LineEnding +
'German' + LineEnding +
'Italian' + LineEnding +
'Afrikaans' + LineEnding;
end;
destructor TTappyWords.Destroy;
@ -95,12 +104,14 @@ procedure TTappyWords.TranslateTextsToEnglish;
begin
ShortDescription := 'TappyWords';
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;
procedure TTappyWords.TranslateTextsToPortuguese;
begin
ShortDescription := 'TappyWords';
LongDescription := 'Um jogo para aprender a digitar e ortografia';
ConfigCaption := 'Selecione uma lista de palavras';
end;
procedure TTappyWords.StartNewGame(SndFX: Integer; Music: Integer; Level: Integer; QuestionList: Integer);
@ -121,9 +132,12 @@ begin
if (Music = 1) then gameMusic := false;
gameSLevel := gameLevel;
// Loads the list of questions
if QuestionList < 0 then QuestionList := 0;
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');
UpdateLevel(gameLevel);
@ -244,6 +258,19 @@ begin
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);
var
i: Integer;

View File

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