21 import com.nokia.meego 1.0
22 import com.nokia.extras 1.0
24 import
"array.js" as MyArray
28 orientationLock: PageOrientation.LockLandscape;
30 property variant anagram: kanagramEngineHelper.createNextAnagram();
31 property int anagramStatus: anagramStatusEnumeration.init;
32 property int currentOriginalWordIndex: 0;
33 property string originalWordLetterButtonBackground:
"image://theme/meegotouch-button-inverted-background";
34 property int countDownTimerValue: kanagramEngineHelper.resolveTime;
35 property bool initialized:
false;
38 id: anagramStatusEnumeration;
40 property int active: 2;
41 property int resolved: 3;
45 if (status == PageStatus.Active && anagramStatus != anagramStatusEnumeration.resolved) {
46 if (rootWindow.languageSelectionChanged ==
true) {
48 if (kanagramEngineHelper.useSounds) {
49 chalkSoundEffect.play();
52 categorySelectionDialog.model = kanagramGame.vocabularyList();
58 if (categorySelectionDialog.selectedIndex >= categorySelectionDialog.model.length) {
59 categorySelectionDialog.selectedIndex = 0;
62 kanagramGame.setCurrentCategory(categorySelectionDialog.selectedIndex);
63 kanagramEngineHelper.saveSettings();
65 kanagramGame.useVocabulary(categorySelectionDialog.selectedIndex);
67 rootWindow.languageSelectionChanged =
false;
70 secondTimer.repeat =
true;
71 secondTimer.restart();
76 target: platformWindow;
79 if (platformWindow.active && status == PageStatus.Active
80 && anagramStatus != anagramStatusEnumeration.resolved) {
81 secondTimer.repeat =
true;
82 secondTimer.restart();
84 anagramHintInfoBanner.hide();
86 secondTimer.repeat =
false;
92 Component.onCompleted: {
93 categorySelectionDialog.selectedIndex = kanagramGame.currentCategory();
97 function pushPage(file) {
98 var component = Qt.createComponent(file)
99 if (component.status == Component.Ready)
100 pageStack.push(component);
102 console.log(
"Error loading component:", component.errorString());
105 function resolveAnagram() {
106 originalWordLetterRepeater.model = kanagramEngineHelper.anagramOriginalWord();
107 currentOriginalWordIndex = originalWordLetterRepeater.model.length;
108 anagramStatus = anagramStatusEnumeration.resolved;
109 anagramHintInfoBanner.hide();
112 function nextAnagram() {
113 anagramHintInfoBanner.hide();
114 anagramStatus = anagramStatusEnumeration.init;
115 anagram = kanagramEngineHelper.createNextAnagram();
116 anagramLetterRepeater.model = anagram;
117 originalWordLetterRepeater.model = anagram;
118 currentOriginalWordIndex = 0;
119 countDownTimerValue = kanagramEngineHelper.resolveTime;
120 MyArray.sourceDestinationLetterIndexHash = [];
125 id: anagramHintInfoBanner;
126 text: i18n(
"No hint available");
127 iconSource:
"dialog-information.png";
137 iconSource:
"help-hint.png";
140 anagramHintInfoBanner.text = kanagramGame.hint();
141 anagramHintInfoBanner.timerShowTime = kanagramEngineHelper.hintHideTime * 1000;
144 anagramHintInfoBanner.show();
149 iconSource:
"games-solve.png";
152 if (kanagramEngineHelper.useSounds) {
153 chalkSoundEffect.play();
158 secondTimer.repeat =
false;
164 text: categorySelectionDialog.model[categorySelectionDialog.selectedIndex];
171 categorySelectionDialog.open();
176 iconSource:
"go-next.png";
179 if (kanagramEngineHelper.useSounds) {
180 chalkSoundEffect.play();
184 secondTimer.repeat =
true;
185 secondTimer.restart();
190 iconSource:
"settings.png";
193 anagramHintInfoBanner.hide();
194 pageStack.push(mainSettingsPage);
196 secondTimer.repeat =
false;
202 tools: mainPageTools;
206 id: categorySelectionDialog;
207 titleText:
"Choose an anagram category"
209 model: kanagramGame.vocabularyList();
211 onSelectedIndexChanged: {
213 if (kanagramEngineHelper.useSounds) {
214 initialized ==
true ? chalkSoundEffect.play() : initialized =
true;
217 kanagramGame.setCurrentCategory(selectedIndex);
218 kanagramEngineHelper.saveSettings();
219 kanagramGame.useVocabulary(selectedIndex);
229 triggeredOnStart:
false;
232 if (kanagramEngineHelper.resolveTime != 0 && --countDownTimerValue == 0) {
234 anagramResultTimer.start();
235 originalWordLetterButtonBackground =
236 "image://theme/meegotouch-button-negative-background";
240 if (kanagramEngineHelper.useSounds) {
241 wrongSoundEffect.play();
248 id: anagramResultTimer;
252 triggeredOnStart:
false;
255 originalWordLetterButtonBackground =
256 "image://theme/meegotouch-button-inverted-background";
259 secondTimer.repeat =
true;
274 letterText: Math.floor(countDownTimerValue / 60 / 10);
275 visible: kanagramEngineHelper.resolveTime == 0 ?
false :
true;
279 letterText: Math.floor(countDownTimerValue / 60 % 10);
280 visible: kanagramEngineHelper.resolveTime == 0 ?
false :
true;
285 visible: kanagramEngineHelper.resolveTime == 0 ?
false :
true;
289 letterText: Math.floor(countDownTimerValue % 60 / 10);
290 visible: kanagramEngineHelper.resolveTime == 0 ?
false :
true;
294 letterText: Math.floor(countDownTimerValue % 60 % 10);
295 visible: kanagramEngineHelper.resolveTime == 0 ?
false :
true;
299 iconSource:
"timer-pause.png";
302 anagramHintInfoBanner.hide();
306 secondTimer.repeat =
false;
316 verticalCenterOffset: 15;
324 horizontalCenter: parent.horizontalCenter;
329 id: originalWordLetterRepeater;
332 id: originalWordLetterId;
333 text: anagramStatus == anagramStatusEnumeration.init ?
"" : modelData;
335 platformStyle: ButtonStyle {
336 background: originalWordLetterButtonBackground;
339 fontCapitalization: Font.AllUppercase;
340 fontWeight: Font.Bold;
341 horizontalAlignment: Text.AlignHCenter;
343 pressedTextColor:
"pink";
344 disabledTextColor:
"gray";
345 checkedTextColor:
"blue";
351 if (index + 1 == currentOriginalWordIndex && currentOriginalWordIndex != 0
352 && anagramStatus != anagramStatusEnumeration.resolved) {
353 if (kanagramEngineHelper.useSounds) {
354 anagramLetterPressSoundEffect.play();
357 var tmpAnagramLetterRepeaterModel = anagramLetterRepeater.model;
358 tmpAnagramLetterRepeaterModel[MyArray.sourceDestinationLetterIndexHash[index]] = originalWordLetterId.text;
359 anagramLetterRepeater.model = tmpAnagramLetterRepeaterModel;
361 MyArray.sourceDestinationLetterIndexHash.pop();
363 originalWordLetterRepeater.model = kanagramEngineHelper.removeInCurrentOriginalWord(index);
364 --currentOriginalWordIndex;
375 fillMode: Image.PreserveAspectFit;
376 source:
"chalk-separator.png";
382 horizontalCenter: parent.horizontalCenter;
387 id: anagramLetterRepeater;
391 text: anagramStatus == anagramStatusEnumeration.resolved ?
"" : modelData;
393 platformStyle: ButtonStyle {
394 background:
"image://theme/meegotouch-button-inverted-background";
397 fontCapitalization: Font.AllUppercase;
398 fontWeight: Font.Bold;
399 horizontalAlignment: Text.AlignHCenter;
401 pressedTextColor:
"pink";
402 disabledTextColor:
"gray";
403 checkedTextColor:
"blue";
409 if (anagramStatus != anagramStatusEnumeration.resolved)
411 if (anagramLetterId.text !=
"")
413 if (kanagramEngineHelper.useSounds) {
414 anagramLetterPressSoundEffect.play();
417 anagramStatus = anagramStatusEnumeration.active;
419 originalWordLetterRepeater.model =
420 kanagramEngineHelper.insertInCurrentOriginalWord(currentOriginalWordIndex, anagramLetterId.text);
422 ++currentOriginalWordIndex;
424 var tmpAnagramLetterRepeaterModel = anagramLetterRepeater.model;
425 tmpAnagramLetterRepeaterModel[[index]] =
"";
426 anagramLetterRepeater.model = tmpAnagramLetterRepeaterModel;
428 MyArray.sourceDestinationLetterIndexHash.push(index);
431 if (currentOriginalWordIndex == originalWordLetterRepeater.model.length)
433 anagramResultTimer.start();
434 anagramStatus = anagramStatusEnumeration.resolved;
435 anagramHintInfoBanner.hide();
436 if (kanagramEngineHelper.compareWords() ==
true)
438 originalWordLetterButtonBackground =
439 "image://theme/meegotouch-button-positive-background";
441 if (kanagramEngineHelper.useSounds) {
442 rightSoundEffect.play();
447 originalWordLetterButtonBackground =
448 "image://theme/meegotouch-button-negative-background";
450 if (kanagramEngineHelper.useSounds) {
451 wrongSoundEffect.play();