diff options
author | Ariel Calzada <ariel.calzada@gmail.com> | 2012-04-16 19:13:00 (GMT) |
---|---|---|
committer | Rafael Ortiz <rafael@activitycentral.com> | 2012-04-16 19:18:16 (GMT) |
commit | 5f9ca2ed7e1143e23a86525dd1a1d1c86f604774 (patch) | |
tree | 599d1e7966c10a23fb21f85bb5fec3b391a1e073 | |
parent | 32a8c45503e17ad8b5e8a2f3c756b21cbdbf1d2f (diff) |
This patch fix the bug, accent nicknames are not displayed well
This patch is for fixing the bug in the display of nicknames with accents like áéíóúñ
in maze activity
Signed-off-by: Rafael Ortiz <rafael@activitycentral.com>
-rw-r--r-- | player.py | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -8,17 +8,17 @@ # # Copyright (C) 2007 Joshua Minor # This file is part of Maze.activity -# +# # Maze.activity is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # Maze.activity is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with Maze.activity. If not, see <http://www.gnu.org/licenses/>. @@ -29,14 +29,16 @@ from sugar.graphics.xocolor import XoColor import pygame import re import os +import unicodedata class Player: def __init__(self, buddy, shape='circle'): self.buddy = buddy - self.nick = buddy.props.nick.decode("utf-8") + name = buddy.props.nick.decode('utf-8') + self.nick = unicodedata.normalize('NFC',name) colors = buddy.props.color.split(",") - + def string2Color(str): return (int(str[1:3], 16), int(str[3:5], 16), int(str[5:7], 16)) self.colors = map(string2Color, colors) @@ -70,7 +72,7 @@ class Player: self.position = (1, 1) self.previous = (1, 1) self.elapsed = None - + def animate(self, maze): # if the player finished the maze, then don't move if maze.map[self.position[0]][self.position[1]] == maze.GOAL: @@ -83,7 +85,7 @@ class Player: else: self.direction = (0, 0) return self.position - + def move(self, direction, maze): """Move the player in a given direction (deltax,deltay)""" newposition = (self.position[0] + direction[0], self.position[1] + direction[1]) @@ -111,7 +113,7 @@ class Player: directions.remove(d) # is there only one possible direction? if len(directions) == 1: - self.direction = directions[0] + self.direction = directions[0] else: self.direction = (0, 0) |