[gcompris] lang, fixed enter text algorightm.
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris] lang, fixed enter text algorightm.
- Date: Tue, 3 Sep 2013 21:36:29 +0000 (UTC)
commit 249f1cc533243a4bd59914a25031c49b87c89790
Author: Bruno Coudoin <bcoudoin gcompris net>
Date: Tue Sep 3 23:34:11 2013 +0200
lang, fixed enter text algorightm.
src/lang-activity/langEnterText.py | 40 +++++++++++++----------------------
1 files changed, 15 insertions(+), 25 deletions(-)
---
diff --git a/src/lang-activity/langEnterText.py b/src/lang-activity/langEnterText.py
index 70c93ef..d172d86 100644
--- a/src/lang-activity/langEnterText.py
+++ b/src/lang-activity/langEnterText.py
@@ -165,7 +165,7 @@ class EnterText:
alignment = pango.ALIGN_CENTER,
width = 300
)
- self.setQuestion()
+ self.setQuestion(self.tripletToFind.descriptionTranslated, self.textEntry.text)
# The OK Button
item = goocanvas.Svg(parent = self.gameroot,
@@ -185,29 +185,19 @@ class EnterText:
# Set the question with dots like L...E
# The number of dots depends on the errorCount
# Return False if all spots are filled
- def setQuestion(self):
-
- text = self.tripletToFind.descriptionTranslated[0]
-
- lastGoodLetter = 1
- for lastGoodLetter in range(lastGoodLetter,
- min(len(self.tripletToFind.descriptionTranslated),
- len(self.textEntry.text))):
- if self.textEntry.text[lastGoodLetter] == self.tripletToFind.descriptionTranslated[lastGoodLetter]:
- text = text + self.tripletToFind.descriptionTranslated[lastGoodLetter]
-
- # Add a char to help
- if self.errorCount:
- try:
- text = text + self.tripletToFind.descriptionTranslated[lastGoodLetter + 1]
- except:
- return False
-
- remaining = len(self.tripletToFind.descriptionTranslated) - len(text) - 1
- if remaining >= 0:
- text = \
- text + '.' * remaining + \
- self.tripletToFind.descriptionTranslated[-1]
+ def setQuestion(self, descriptionTranslated, textEntry):
+
+ text = ''
+ clueGiven = False
+
+ for i in range(0, len(descriptionTranslated)):
+ if len(textEntry) > i and textEntry[i] == descriptionTranslated[i]:
+ text = text + descriptionTranslated[i]
+ elif not clueGiven:
+ text = text + descriptionTranslated[i]
+ clueGiven = True
+ else:
+ text = text + '.'
self.questionItem.set_properties(text = text,)
return True
@@ -221,7 +211,7 @@ class EnterText:
self.start()
else:
self.errorCount += 1
- if self.setQuestion():
+ if self.setQuestion(self.tripletToFind.descriptionTranslated, self.textEntry.text):
if self.errorCount == 1:
self.triplets.append(self.tripletToFind)
self.repeat()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]