Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPootle daemon <pootle@pootle.sugarlabs.org>2013-10-15 04:30:36 (GMT)
committer Pootle daemon <pootle@pootle.sugarlabs.org>2013-10-15 04:30:36 (GMT)
commitcef949304fd6f0fb22aa4fb48adc7db93e850eb8 (patch)
treee980b2968a2654b9c59c145e198bef10b8e557d4
parent1d9a51ae2d8372128a37ae64b1d90ab23f392a8e (diff)
parent068c2315d92f056b7e694f0ee5f2ab41a54c5b67 (diff)
Merge branch 'master' of git.sugarlabs.org:turtleart/mainline
-rw-r--r--NEWS1
-rw-r--r--TurtleArt/tawindow.py2
-rw-r--r--plugins/turtle_blocks_extras/turtle_blocks_extras.py138
-rw-r--r--samples/game-snake.tb57
-rw-r--r--samples/games-snake.tb53
-rw-r--r--samples/thumbnails/game-snake.png (renamed from samples/thumbnails/games-snake.png)bin9694 -> 9694 bytes
6 files changed, 162 insertions, 89 deletions
diff --git a/NEWS b/NEWS
index af4df0e..6ff2d7b 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ ENHANCEMENTS:
BUG FIXES:
* Fixed regression in Sugar 84 support
* Fixed problem with GNOME due to Sugar button check (Alan Aguiar)
+* Fixed label updates on mouse x, mouse y, and keyboard
191
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 4388779..a03240b 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -4369,6 +4369,8 @@ before making changes to your program'))
self.status_spr.set_shape(self.status_shapes[shp])
self.status_spr.set_label_attributes(12.0, rescale=False)
if shp == 'status':
+ if label in ['True', 'False']:
+ label = _(label)
self.status_spr.set_label('"%s"' % (str(label)))
else:
self.status_spr.set_label(str(label))
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
index 1f910fd..3cb4fb9 100644
--- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py
+++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
@@ -337,6 +337,7 @@ pressed'))
lambda self:
primitive_dictionary['mousebutton2']())
+ primitive_dictionary['mousex'] = self._prim_mouse_x
palette.add_block('mousex',
style='box-style',
label=_('mouse x'),
@@ -345,8 +346,9 @@ pressed'))
help_string=_('returns mouse x coordinate'))
self.tw.lc.def_prim('mousex', 0,
lambda self:
- self.tw.mouse_x - (self.tw.canvas.width / 2))
+ primitive_dictionary['mousex']())
+ primitive_dictionary['mousey'] = self._prim_mouse_y
palette.add_block('mousey',
style='box-style',
label=_('mouse y'),
@@ -355,7 +357,7 @@ pressed'))
help_string=_('returns mouse y coordinate'))
self.tw.lc.def_prim('mousey', 0,
lambda self:
- (self.tw.canvas.height / 2) - self.tw.mouse_y)
+ primitive_dictionary['mousey']())
primitive_dictionary['kbinput'] = self._prim_kbinput
palette.add_block('kbinput',
@@ -367,6 +369,7 @@ stored in keyboard block)'))
self.tw.lc.def_prim('kbinput', 0,
lambda self: primitive_dictionary['kbinput']())
+ primitive_dictionary['keyboard'] = self._prim_keyboard
palette.add_block('keyboard',
style='box-style',
label=_('keyboard'),
@@ -375,32 +378,8 @@ stored in keyboard block)'))
logo_command='make "keyboard readchar',
help_string=_('holds results of query-keyboard \
block as ASCII'))
- self.tw.lc.def_prim('keyboard', 0, lambda self: self.tw.lc.keyboard)
-
- '''
- palette.add_block('keyboard_chr',
- style='box-style',
- label='chr(%s)' % (_('keyboard')),
- prim_name='keyboard_chr',
- value_block=True,
- logo_command='make "keyboard readchar',
- help_string=_('holds results of query-keyboard \
-block as character'))
- self.tw.lc.def_prim('keyboard_chr', 0,
- lambda self: chr(self.tw.lc.keyboard))
-
- primitive_dictionary['keyboardnum'] = self._prim_keyboard_num
- palette.add_block('keyboard_num',
- style='box-style',
- label='num(%s)' % (_('keyboard')),
- prim_name='keyboard_num',
- value_block=True,
- logo_command='make "keyboard readchar',
- help_string=_('holds results of query-keyboard \
-block as number'))
- self.tw.lc.def_prim('keyboard_num', 0,
- lambda self: primitive_dictionary['keyboardnum']())
- '''
+ self.tw.lc.def_prim('keyboard', 0,
+ lambda self: primitive_dictionary['keyboard']())
primitive_dictionary['readpixel'] = self._prim_readpixel
palette.add_block('readpixel',
@@ -1021,20 +1000,93 @@ Journal objects'))
""" Empty FILO """
self.tw.lc.heap = []
+ def _prim_keyboard(self):
+ """ Return last character typed """
+ return self.tw.lc.keyboard
+
def _prim_kbinput(self):
""" Query keyboard """
+ DICT = {
+ 'Left': 1,
+ 'KP_Left': 1,
+ 'Up': 2,
+ 'KP_Up': 2,
+ 'Right': 3,
+ 'KP_Right': 3,
+ 'Down': 4,
+ 'KP_Down': 4,
+ 'BackSpace': 8,
+ 'Tab': 9,
+ 'Return': 13,
+ 'Escape': 27,
+ 'space': 32,
+ ' ': 32,
+ 'exclam': 33,
+ 'quotedbl': 34,
+ 'numbersign': 35,
+ 'dollar': 36,
+ 'percent': 37,
+ 'ampersand': 38,
+ 'apostrophe': 39,
+ 'parenleft': 40,
+ 'parenright': 41,
+ 'asterisk': 42,
+ 'plus': 43,
+ 'comma': 44,
+ 'minus': 45,
+ 'period': 46,
+ 'slash': 47,
+ 'colon': 58,
+ 'semicolon': 59,
+ 'less': 60,
+ 'equal': 61,
+ 'greater': 62,
+ 'question': 63,
+ 'at': 64,
+ 'underscore': 95,
+ 'bracketleft': 91,
+ 'backslash': 92,
+ 'bracketright': 93,
+ 'asciicircum': 94,
+ 'grave': 96,
+ 'braceleft': 123,
+ 'bar': 124,
+ 'braceright': 125,
+ 'asciitilde': 126,
+ 'Delete': 127,
+ }
+ REVERSE_DICT = {
+ 1: _('left'),
+ 2: _('up'),
+ 3: _('right'),
+ 4: _('down'),
+ 8: _('backspace'),
+ 9: _('tab'),
+ # TRANS: enter is the name of the enter (or return) key
+ 13: _('enter'),
+ 27: 'esc',
+ # TRANS: space is the name of the space key
+ 32: _('space'),
+ 127: _('delete')
+ }
+
if len(self.tw.keypress) == 1:
self.tw.lc.keyboard = ord(self.tw.keypress[0])
+ elif self.tw.keypress in DICT:
+ self.tw.lc.keyboard = DICT[self.tw.keypress]
else:
- try:
- self.tw.lc.keyboard = {
- 'Escape': 27, 'space': 32, ' ': 32,
- 'Return': 13, 'KP_Up': 2, 'KP_Down': 4, 'KP_Left': 1,
- 'KP_Right': 3}[self.tw.keypress]
- except KeyError:
- self.tw.lc.keyboard = 0
+ self.tw.lc.keyboard = 0
if self.tw.lc.update_values:
- self.tw.lc.update_label_value('keyboard', self.tw.lc.keyboard)
+ if self.tw.keypress in DICT:
+ if DICT[self.tw.keypress] in REVERSE_DICT:
+ self.tw.lc.update_label_value(
+ 'keyboard', REVERSE_DICT[DICT[self.tw.keypress]])
+ else:
+ self.tw.lc.update_label_value('keyboard',
+ chr(DICT[self.tw.keypress]))
+ elif self.tw.lc.keyboard > 0:
+ self.tw.lc.update_label_value('keyboard',
+ chr(self.tw.lc.keyboard))
self.tw.keypress = ''
def _prim_list(self, blklist):
@@ -1339,6 +1391,20 @@ Journal objects'))
csd.write("\n</CsoundSynthesizer>")
csd.close()
+ def _prim_mouse_x(self):
+ """ Return mouse x coordinate """
+ mousex = int(self.tw.mouse_x - (self.tw.canvas.width / 2))
+ if self.tw.lc.update_values:
+ self.tw.lc.update_label_value('mousex', mousex)
+ return mousex
+
+ def _prim_mouse_y(self):
+ """ Return mouse y coordinate """
+ mousey = int((self.tw.canvas.height / 2) - self.tw.mouse_y)
+ if self.tw.lc.update_values:
+ self.tw.lc.update_label_value('mousey', mousey)
+ return mousey
+
def _prim_mouse_button(self):
""" Return 1 if mouse button is pressed """
if self.tw.mouse_flag == 1:
diff --git a/samples/game-snake.tb b/samples/game-snake.tb
new file mode 100644
index 0000000..95be7b7
--- /dev/null
+++ b/samples/game-snake.tb
@@ -0,0 +1,57 @@
+[[0, ["start", 2.0], 200, 180, [null, 56]],
+[1, "hat", 740, 420, [null, 2, 13]],
+[2, ["string", "left"], 799, 432, [1, null]],
+[3, "hat", 740, 180, [null, 4, 12]],
+[4, ["string", "right"], 799, 192, [3, null]],
+[5, "stack", 520, 276, [11, 6, 7]],
+[6, ["string", "left"], 579, 276, [5, null]],
+[7, "stack", 520, 318, [5, 8, 9]],
+[8, ["string", "right"], 579, 318, [7, null]],
+[9, "forward", 520, 360, [7, 10, 51]],
+[10, ["number", 10], 594, 360, [9, null]],
+[11, "kbinput", 520, 234, [33, 5]],
+[12, ["vspace", 0], 740, 234, [3, 14]],
+[13, ["vspace", 0], 740, 474, [1, 15]],
+[14, ["if", 0], 740, 276, [12, 16, 20, null]],
+[15, ["if", 0], 740, 516, [13, 17, 22, null]],
+[16, ["equal2", 0], 806, 242, [14, 45, 18, null]],
+[17, ["equal2", 0], 806, 482, [15, 46, 19, null]],
+[18, "keyboard", 862, 284, [16, null]],
+[19, "keyboard", 862, 524, [17, null]],
+[20, "right", 758, 342, [14, 21, null]],
+[21, ["number", 10], 830, 342, [20, null]],
+[22, "left", 758, 582, [15, 23, null]],
+[23, ["number", 10], 837, 582, [22, null]],
+[24, "wait", 218, 502, [35, 25, null]],
+[25, ["number", 0.1], 287, 502, [24, null]],
+[26, "forward", 1020, 276, [30, 27, 39]],
+[27, ["number", 3], 1094, 276, [26, null]],
+[28, "back", 1020, 402, [39, 29, 31]],
+[29, ["number", 3], 1078, 402, [28, null]],
+[30, "penup", 1020, 234, [49, 26]],
+[31, "pendown", 1020, 444, [28, null]],
+[32, "showblocks", 200, 562, [47, null]],
+[33, "hat", 520, 180, [null, 34, 11]],
+[34, ["string", "action"], 579, 192, [33, null]],
+[35, "stack", 218, 460, [47, 36, 24]],
+[36, ["string", "action"], 277, 460, [35, null]],
+[37, "setpensize", 200, 268, [56, 38, 54]],
+[38, ["number", 5], 301, 268, [37, null]],
+[39, ["storein", 0], 1020, 318, [26, 40, 41, 28]],
+[40, ["string", "color"], 1115, 318, [39, null]],
+[41, "see", 1115, 360, [39, null]],
+[42, ["equal2", 0], 256, 360, [47, 43, 53, null]],
+[43, "box", 312, 360, [42, 44, null]],
+[44, ["string", "color"], 367, 360, [43, null]],
+[45, ["number", 3], 862, 242, [16, null]],
+[46, ["number", 1], 862, 482, [17, null]],
+[47, ["until", 21], 200, 394, [48, 42, 35, 32]],
+[48, ["vspace", 0], 200, 352, [54, 47]],
+[49, "hat", 1020, 180, [null, 50, 30]],
+[50, ["string", "look ahead"], 1079, 192, [49, null]],
+[51, "stack", 520, 402, [9, 52, null]],
+[52, ["string", "look ahead"], 579, 402, [51, null]],
+[53, "red", 312, 402, [42, null]],
+[54, "setcolor", 200, 310, [37, 55, 48]],
+[55, "red", 281, 310, [54, null]],
+[56, "clean", 200, 226, [0, 37]]]
diff --git a/samples/games-snake.tb b/samples/games-snake.tb
deleted file mode 100644
index 397ffc8..0000000
--- a/samples/games-snake.tb
+++ /dev/null
@@ -1,53 +0,0 @@
-[[0, ["start", 2.0], 400, 20, [null, 51]],
-[1, "hat", 820, 260, [null, 2, 14]],
-[2, ["string", "left"], 879, 272, [1, null]],
-[3, "hat", 820, 20, [null, 4, 13]],
-[4, ["string", "right"], 879, 32, [3, null]],
-[5, "stack", 160, 236, [11, 6, 7]],
-[6, ["string", "left"], 219, 236, [5, null]],
-[7, "stack", 160, 278, [5, 8, 9]],
-[8, ["string", "right"], 219, 278, [7, null]],
-[9, "forward", 160, 320, [7, 10, 37]],
-[10, ["number", 10], 234, 320, [9, null]],
-[11, "kbinput", 160, 194, [47, 5]],
-[12, ["forever", 166], 400, 108, [51, 49, null]],
-[13, ["vspace", 0], 820, 74, [3, 15]],
-[14, ["vspace", 0], 820, 314, [1, 16]],
-[15, ["if", 0], 820, 116, [13, 19, 23, null]],
-[16, ["if", 0], 820, 356, [14, 20, 25, null]],
-[17, ["string", "l"], 942, 322, [20, null]],
-[18, ["string", "r"], 942, 82, [19, null]],
-[19, ["equal2", 0], 886, 82, [15, 18, 21, null]],
-[20, ["equal2", 0], 886, 322, [16, 17, 22, null]],
-[21, "keyboard", 942, 124, [19, null]],
-[22, "keyboard", 942, 364, [20, null]],
-[23, "right", 838, 182, [15, 24, null]],
-[24, ["number", 10], 910, 182, [23, null]],
-[25, "left", 838, 422, [16, 26, null]],
-[26, ["number", 10], 917, 422, [25, null]],
-[27, "wait", 418, 474, [39, 28, null]],
-[28, ["number", 0.1], 487, 474, [27, null]],
-[29, "forward", 160, 404, [37, 30, 33]],
-[30, ["number", 8.0], 234, 404, [29, null]],
-[31, "back", 160, 488, [33, 32, 38]],
-[32, ["number", 8.0], 218, 488, [31, null]],
-[33, "readpixel", 160, 446, [29, 31]],
-[34, "pop", 594, 192, [45, null]],
-[35, "pop", 648, 234, [46, null]],
-[36, "pop", 648, 276, [46, null]],
-[37, "penup", 160, 362, [9, 29]],
-[38, "pendown", 160, 530, [31, null]],
-[39, ["if", 21], 418, 306, [42, 40, 44, 27]],
-[40, ["equal2", 40], 484, 192, [39, 45, 41, null]],
-[41, ["number", 255], 540, 314, [40, null]],
-[42, ["vspace", 40], 418, 184, [49, 39]],
-[43, "stopstack", 436, 414, [44, null]],
-[44, "showblocks", 436, 372, [39, 43]],
-[45, ["plus2", 0], 540, 192, [40, 34, 46]],
-[46, ["plus2", 0], 594, 234, [45, 35, 36]],
-[47, "hat", 160, 140, [null, 48, 11]],
-[48, ["string", "acci\u00f3n"], 219, 152, [47, null]],
-[49, "stack", 418, 142, [12, 50, 42]],
-[50, ["string", "acci\u00f3n"], 477, 142, [49, null]],
-[51, "setpensize", 400, 66, [0, 52, 12]],
-[52, ["number", 5], 501, 66, [51, null]]]
diff --git a/samples/thumbnails/games-snake.png b/samples/thumbnails/game-snake.png
index da57530..da57530 100644
--- a/samples/thumbnails/games-snake.png
+++ b/samples/thumbnails/game-snake.png
Binary files differ