diff options
author | Walter Bender <walter.bender@gmail.com> | 2013-02-01 23:44:57 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2013-02-01 23:44:57 (GMT) |
commit | ffda647870496e7ec58f72029dc4e5c37e416b10 (patch) | |
tree | 7df2582853e0c6e219e1822a220829401f62cb2e | |
parent | f59b2031db0dde0291377243604551278024dd16 (diff) |
updates from .NI feedback
-rw-r--r-- | IKnowMyABCs.py | 19 | ||||
-rw-r--r-- | NEWS | 11 | ||||
-rw-r--r-- | activity/activity.info | 2 | ||||
-rwxr-xr-x | genpieces.py | 10 | ||||
-rw-r--r-- | images/correct.png | bin | 0 -> 41806 bytes | |||
-rw-r--r-- | images/es/raton.png | bin | 31216 -> 27519 bytes | |||
-rw-r--r-- | images/wrong.png | bin | 0 -> 42162 bytes | |||
-rw-r--r-- | lessons/es/alphabet.csv | 2 | ||||
-rw-r--r-- | page.py | 91 |
9 files changed, 116 insertions, 19 deletions
diff --git a/IKnowMyABCs.py b/IKnowMyABCs.py index 32a517f..bd27c97 100644 --- a/IKnowMyABCs.py +++ b/IKnowMyABCs.py @@ -65,16 +65,21 @@ class IKnowMyABCs(activity.Activity): # FIXME: find some reasonable default situation language = 'es' - if os.path.exists(os.path.join('~', 'Activities', + home_path = os.path.expanduser('~') + if os.path.exists(os.path.join(home_path, 'Activities', 'IKnowMyABCs.activity')): - self._lessons_path = os.path.join('~', 'Activities', - 'IKnowMyABCs.activity', - 'lessons', language) + self.activity_path = os.path.join(home_path, 'Activities', + 'IKnowMyABCs.activity') else: - self._lessons_path = os.path.join('.', 'lessons', language) + self.activity_path = os.path.abspath('.') + + self._lessons_path = os.path.join(self.activity_path, + 'lessons', language) + self._images_path = os.path.join(self.activity_path, + 'images', language) + self._sounds_path = os.path.join(self.activity_path, + 'sounds', language) - self._images_path = self._lessons_path.replace('lessons', 'images') - self._sounds_path = self._lessons_path.replace('lessons', 'sounds') self._setup_toolbars() # Create a canvas @@ -1,3 +1,14 @@ +5 + +Enhancements based on feedback from .NI: + +* Level 1: add the uppercase and lowercase letters +* Level 2: link the name of the letter and its image; + for example: The XO says: "A" de "Ave", "E" de Elefante +* Change the background color to one of the XO colors +* Add visual to feedback for Levels 3 and 4 +* Don't repeat letter until all letters seen + 3 * GTK3 port by Ignacio Rodriguez diff --git a/activity/activity.info b/activity/activity.info index 8747a3c..ef666e8 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = I Know My ABCs -activity_version = 3 +activity_version = 5 license = GPLv3 bundle_id = org.sugarlabs.IKnowMyABCs exec = sugar-activity IKnowMyABCs.IKnowMyABCs diff --git a/genpieces.py b/genpieces.py index f4d8485..f2c2d27 100755 --- a/genpieces.py +++ b/genpieces.py @@ -146,6 +146,16 @@ def generator(datapath): close_file(f) +def genblank(w, h, colors, stroke_width=1.0): + svg = SVG() + svg.set_scale(1) + svg.set_colors(colors) + svg.set_stroke_width(stroke_width) + svg_string = svg.header(int(w / 80), int(h / 60)) + svg_string += svg.footer() + return svg_string + + def main(): return 0 diff --git a/images/correct.png b/images/correct.png Binary files differnew file mode 100644 index 0000000..95f5d5d --- /dev/null +++ b/images/correct.png diff --git a/images/es/raton.png b/images/es/raton.png Binary files differindex f2e087d..4542274 100644 --- a/images/es/raton.png +++ b/images/es/raton.png diff --git a/images/wrong.png b/images/wrong.png Binary files differnew file mode 100644 index 0000000..63084d4 --- /dev/null +++ b/images/wrong.png diff --git a/lessons/es/alphabet.csv b/lessons/es/alphabet.csv index 690f314..4233eb4 100644 --- a/lessons/es/alphabet.csv +++ b/lessons/es/alphabet.csv @@ -18,7 +18,7 @@ k, (k)ilo, #FFC040, kilo.png, kilo.ogg, k.ogg l, (l)oro, #00A0FF, loro.png, loro.ogg, l.ogg m, (m)esa, #C72020, mesa.png, mesa.ogg, m.ogg n, (n)ube, #7A6BBD, nube.png, nube.ogg, n.ogg -ñ, (ñ)andú, #80C040/#C93C7E, nandu.png, nandu.ogg, ny.ogg +Ññ, (ñ)andú, #80C040/#C93C7E, nandu.png, nandu.ogg, ny.ogg o, (o)s(o), #A4221E, oso.png, oso.ogg, o.ogg p, (p)ato, #A4221E, pato.png, pato.ogg, p.ogg q, (q)ueso, #FFC040, queso.png, queso.ogg, q.ogg @@ -23,10 +23,11 @@ from utils.play_audio import play_audio_from_file import logging _logger = logging.getLogger('iknowmyabcs-activity') +from sugar3 import profile from sugar3.graphics import style GRID_CELL_SIZE = style.GRID_CELL_SIZE -from genpieces import generate_card +from genpieces import generate_card, genblank from utils.sprites import Sprites, Sprite @@ -46,11 +47,14 @@ class Page(): self._images_path = images_path self._sounds_path = sounds_path + self._colors = profile.get_color().to_string().split(',') + self._card_data = [] self._color_data = [] self._image_data = [] self._media_data = [] # (image sound, letter sound) self._word_data = [] + self._deja_vu = [] # Starting from command line if self._activity is None: @@ -75,7 +79,7 @@ class Page(): self._grid_x_offset = int( (self._width - XDIM * (self._card_width + GUTTER * 2)) / 2) self._grid_y_offset = 0 - self._scale = self._card_width / 80 + self._scale = self._card_width / 80. self._sprites = Sprites(self._canvas) self.current_card = 0 self._cards = [] @@ -84,14 +88,44 @@ class Page(): self._release = None self.timeout = None + self._my_canvas = Sprite( + self._sprites, 0, 0, svg_str_to_pixbuf(genblank( + self._width, self._height, (self._colors[0], + self._colors[0])))) + self._my_canvas.type = 'background' + + self._smile = Sprite(self._sprites, + int(self._width / 4), + int(self._height / 4), + GdkPixbuf.Pixbuf.new_from_file_at_size( + os.path.join(self._activity.activity_path, + 'images', 'correct.png'), + int(self._width / 2), + int(self._height / 2))) + + self._frown = Sprite(self._sprites, + int(self._width / 4), + int(self._height / 4), + GdkPixbuf.Pixbuf.new_from_file_at_size( + os.path.join(self._activity.activity_path, + 'images', 'wrong.png'), + int(self._width / 2), + int(self._height / 2))) + self.load_level(os.path.join(self._lessons_path, 'alphabet' + '.csv')) self.new_page() + def _hide_feedback(self): + if hasattr(self, '_smile'): + self._smile.hide() + self._frown.hide() + def new_page(self, cardtype='alpha'): ''' Load a page of cards ''' if self.timeout is not None: GObject.source_remove(self.timeout) self._hide_cards() + self._hide_feedback() if cardtype == 'alpha': self._alpha_cards() else: @@ -159,7 +193,8 @@ class Page(): stroke = self._test_for_stroke() self._cards.append(Sprite(self._sprites, x, y, svg_str_to_pixbuf(generate_card( - string=card[0], + string='%s%s' % ( + card[0].upper(), card[0].lower()), colors=[self._color_data[self.current_card][0], '#FFFFFF'], stroke=stroke, @@ -180,15 +215,28 @@ class Page(): self._activity.status.set_text( _('Click on the card that corresponds to the sound.')) self.target = int(uniform(0, len(self._cards))) + # Don't repeat + while self.target in self._deja_vu: + self.target = int(uniform(0, len(self._cards))) + self._deja_vu.append(self.target) + if len(self._deja_vu) == len(self._cards): + self._deja_vu = [] if self.timeout is not None: GObject.source_remove(self.timeout) self.timeout = GObject.timeout_add(1000, self._play_target_sound) def _play_target_sound(self): - if self._activity.mode == 'find by letter': + if self._activity.mode in ['letter', 'find by letter']: + play_audio_from_file(os.path.join( + self._sounds_path, + self._media_data[self.target][1])) + elif self._activity.mode == 'picture': play_audio_from_file(os.path.join( self._sounds_path, self._media_data[self.target][1])) + GObject.timeout_add(1000, play_audio_from_file, os.path.join( + self._sounds_path, + self._media_data[self.target][0])) else: play_audio_from_file(os.path.join( self._sounds_path, @@ -211,23 +259,46 @@ class Page(): x, y = map(int, event.get_coords()) spr = self._sprites.find_sprite((x, y)) + if spr is None: + return + if spr.type == 'background': + return if spr in self._cards: self.current_card = self._cards.index(spr) elif spr in self._pictures: self.current_card = self._pictures.index(spr) if self._activity.mode in ['letter', 'picture']: - play_audio_from_file(os.path.join( - self._sounds_path, - self._media_data[self.current_card][1])) - elif self._activity.mode in ['find by letter', 'find by word']: + self.target = self.current_card + self._play_target_sound() + else: if self.current_card == self.target: self._activity.status.set_text(_('Very good!')) + self._play(True) if self.timeout is not None: GObject.source_remove(self.timeout) - self.timeout = GObject.timeout_add(1000, self.new_target) + self.timeout = GObject.timeout_add(1000, self._correct_feedback) else: self._activity.status.set_text(_('Please try again.')) - self._play_target_sound() + self._play(False) + if self.timeout is not None: + GObject.source_remove(self.timeout) + self.timeout = GObject.timeout_add(1000, self._wrong_feedback) + + def _correct_feedback(self): + self._hide_feedback() + self.new_target() + + def _wrong_feedback(self): + self._hide_feedback() + self._play_target_sound() + + def _play(self, great): + if great: + self._smile.set_layer(1000) + # play_audio_from_file(os.getcwd() + '/sounds/great.ogg') + else: + self._frown.set_layer(1000) + # play_audio_from_file(os.getcwd() + '/sounds/bad.ogg') def _keypress_cb(self, area, event): ''' No keyboard shortcuts at the moment. Perhaps jump to the page |