@@ -58,6 +58,8 @@ def get_argv(arg):
5858from time import strftime
5959from datetime import date
6060import gettext
61+ from pyglet .shapes import Line
62+ from pyglet .shapes import Polygon
6163
6264# TODO check if this is right
6365gettext .install ('messages' , localedir = 'res/i18n' )
@@ -1378,13 +1380,22 @@ def short_name(self, mode=None, back=None):
13781380#
13791381
13801382class Graph :
1383+ class ShapesStore :
1384+ def __init__ (self ):
1385+ self .s = [] # shapes store
1386+ def __iadd__ (self , o ):
1387+ self .s .append (o )
1388+ return self
1389+
13811390 def __init__ (self ):
13821391 self .graph = 2
13831392 self .reset_dictionaries ()
13841393 self .reset_percents ()
13851394 self .batch = None
13861395 self .styles = ['N+10/3+4/3' , 'N' , '%' , 'N.%' , 'N+2*%-1' ]
13871396 self .style = 0
1397+ self .sh = self .ShapesStore ()
1398+
13881399
13891400 def next_style (self ):
13901401 self .style = (self .style + 1 ) % len (self .styles )
@@ -1563,16 +1574,16 @@ def create_batch(self):
15631574 graph_title = mode .long_mode_names [self .graph ] + _ (' N-Back' )
15641575
15651576 if have_shapes :
1566- pyglet . shapes . Line (left , top , left , bottom , color = axiscolor , batch = self .batch )
1567- pyglet . shapes . Line (left , bottom , right , bottom , color = axiscolor , batch = self .batch )
1577+ self . sh += Line (left , top , left , bottom , color = axiscolor , batch = self .batch )
1578+ self . sh += Line (left , bottom , right , bottom , color = axiscolor , batch = self .batch )
15681579 else :
15691580 self .batch .add (3 , pyglet .gl .GL_LINE_STRIP ,
15701581 pyglet .graphics .OrderedGroup (order = 1 ), ('v2i' , (
15711582 left , top ,
15721583 left , bottom ,
15731584 right , bottom )), ('c3B' , axiscolor * 3 ))
15741585
1575- pyglet .text .Label (
1586+ self . sh += pyglet .text .Label (
15761587 _ ('G: Return to Main Screen\n \n N: Next Game Type' ),
15771588 batch = self .batch ,
15781589 multiline = True , width = scale_to_width (300 ),
@@ -1581,31 +1592,31 @@ def create_batch(self):
15811592 x = from_left_edge (10 ), y = from_top_edge (10 ),
15821593 anchor_x = 'left' , anchor_y = 'top' )
15831594
1584- pyglet .text .Label (graph_title ,
1595+ self . sh += pyglet .text .Label (graph_title ,
15851596 batch = self .batch ,
15861597 font_size = calc_fontsize (18 ), weight = 'bold' , color = cfg .COLOR_TEXT ,
15871598 x = center_x , y = top + scale_to_height (60 ),
15881599 anchor_x = 'center' , anchor_y = 'center' )
15891600
1590- pyglet .text .Label (_ ('Date' ),
1601+ self . sh += pyglet .text .Label (_ ('Date' ),
15911602 batch = self .batch ,
15921603 font_size = calc_fontsize (12 ), weight = 'bold' , color = cfg .COLOR_TEXT ,
15931604 x = center_x , y = bottom - scale_to_height (80 ),
15941605 anchor_x = 'center' , anchor_y = 'center' )
15951606
1596- pyglet .text .Label (_ ('Maximum' ), width = scale_to_width (1 ),
1607+ self . sh += pyglet .text .Label (_ ('Maximum' ), width = scale_to_width (1 ),
15971608 batch = self .batch ,
15981609 font_size = calc_fontsize (12 ), weight = 'bold' , color = linecolor2 + (255 ,),
15991610 x = left - scale_to_width (60 ), y = center_y + scale_to_height (50 ),
16001611 anchor_x = 'right' , anchor_y = 'center' )
16011612
1602- pyglet .text .Label (_ ('Average' ), width = scale_to_width (1 ),
1613+ self . sh += pyglet .text .Label (_ ('Average' ), width = scale_to_width (1 ),
16031614 batch = self .batch ,
16041615 font_size = calc_fontsize (12 ), weight = 'bold' , color = linecolor + (255 ,),
16051616 x = left - scale_to_width (60 ), y = center_y + scale_to_height (25 ),
16061617 anchor_x = 'right' , anchor_y = 'center' )
16071618
1608- pyglet .text .Label (_ ('Score' ), width = scale_to_width (1 ),
1619+ self . sh += pyglet .text .Label (_ ('Score' ), width = scale_to_width (1 ),
16091620 batch = self .batch ,
16101621 font_size = calc_fontsize (12 ), weight = 'bold' , color = cfg .COLOR_TEXT ,
16111622 x = left - scale_to_width (60 ), y = center_y ,
@@ -1614,7 +1625,7 @@ def create_batch(self):
16141625 dates = list (dictionary )
16151626 dates .sort ()
16161627 if len (dates ) < 2 :
1617- pyglet .text .Label (_ ('Insufficient data: two days needed' ),
1628+ self . sh += pyglet .text .Label (_ ('Insufficient data: two days needed' ),
16181629 batch = self .batch ,
16191630 font_size = calc_fontsize (12 ), weight = 'bold' , color = axiscolor + (255 ,),
16201631 x = center_x , y = center_y ,
@@ -1668,14 +1679,14 @@ def create_batch(self):
16681679 if 10 < len (dates ):
16691680 datestring = datestring .replace ('-' , '\n ' )
16701681 if not index % (skip_x + 1 ):
1671- pyglet .text .Label (datestring , multiline = True , width = scale_to_width (12 ),
1682+ self . sh += pyglet .text .Label (datestring , multiline = True , width = scale_to_width (12 ),
16721683 batch = self .batch ,
16731684 font_size = calc_fontsize (8 ), weight = 'bold' , color = cfg .COLOR_TEXT ,
16741685 x = x , y = bottom - scale_to_height (15 ),
16751686 anchor_x = 'center' , anchor_y = 'top' )
16761687 if have_shapes :
1677- pyglet . shapes . Line (x , bottom , x , top , color = minorcolor , batch = self .batch )
1678- pyglet . shapes . Line (x , bottom - scale_to_height (10 ), x , bottom , color = minorcolor , batch = self .batch )
1688+ self . sh += Line (x , bottom , x , top , color = minorcolor , batch = self .batch )
1689+ self . sh += Line (x , bottom - scale_to_height (10 ), x , bottom , color = minorcolor , batch = self .batch )
16791690 else :
16801691 self .batch .add (2 , pyglet .gl .GL_LINES ,
16811692 pyglet .graphics .OrderedGroup (order = 0 ), ('v2i' , (
@@ -1691,14 +1702,14 @@ def create_batch(self):
16911702 y_marking = ymin
16921703 while y_marking <= ymax :
16931704 y = int ((y_marking - ymin )/ (ymax - ymin ) * height + bottom )
1694- pyglet .text .Label (str (round (y_marking , 2 )),
1705+ self . sh += pyglet .text .Label (str (round (y_marking , 2 )),
16951706 batch = self .batch ,
16961707 font_size = calc_fontsize (10 ), weight = 'normal' , color = cfg .COLOR_TEXT ,
16971708 x = left - scale_to_width (30 ), y = y + scale_to_width (1 ),
16981709 anchor_x = 'center' , anchor_y = 'center' )
16991710 if have_shapes :
1700- pyglet . shapes . Line (left , y , right , y , color = minorcolor , batch = self .batch )
1701- pyglet . shapes . Line (left - scale_to_width (10 ), y , left , y , color = minorcolor , batch = self .batch )
1711+ self . sh += Line (left , y , right , y , color = minorcolor , batch = self .batch )
1712+ self . sh += Line (left - scale_to_width (10 ), y , left , y , color = minorcolor , batch = self .batch )
17021713 else :
17031714 self .batch .add (2 , pyglet .gl .GL_LINES ,
17041715 pyglet .graphics .OrderedGroup (order = 0 ), ('v2i' , (
@@ -1711,8 +1722,12 @@ def create_batch(self):
17111722 y_marking += y_marking_interval
17121723
17131724 if have_shapes :
1714- for index in range (len (avgpoints ) // 2 - 1 ):
1715- pyglet .shapes .Line (avgpoints [index ], avgpoints [index + 1 ], avgpoints [index + 2 ], avgpoints [index + 3 ], batch = self .batch )
1725+ # blue
1726+ for index in range (0 , len (avgpoints )- 2 , 2 ):
1727+ self .sh += Line (avgpoints [index ], avgpoints [index + 1 ], avgpoints [index + 2 ], avgpoints [index + 3 ], color = linecolor , batch = self .batch )
1728+ # red
1729+ for index in range (0 , len (maxpoints )- 2 , 2 ):
1730+ self .sh += Line (maxpoints [index ], maxpoints [index + 1 ], maxpoints [index + 2 ], maxpoints [index + 3 ], color = linecolor2 , batch = self .batch )
17161731 else :
17171732 self .batch .add (len (avgpoints ) // 2 , pyglet .gl .GL_LINE_STRIP ,
17181733 pyglet .graphics .OrderedGroup (order = 2 ), ('v2i' ,
@@ -1733,7 +1748,8 @@ def create_batch(self):
17331748 maxp = maxpoints [index * 2 + 1 ]
17341749 # draw average
17351750 if have_shapes :
1736- pyglet .shapes .Polygon ((x - radius , avg - radius ), (x - radius , avg + radius ), (x + radius , avg + radius ), (x + radius , avg - radius ), color = linecolor , batch = self .batch )
1751+ None
1752+ #self.sh += Polygon((x - radius, avg - radius), (x - radius, avg + radius), (x + radius, avg + radius), (x + radius, avg - radius), color=linecolor, batch=self.batch)
17371753 else :
17381754 self .batch .add (4 , pyglet .gl .GL_POLYGON ,
17391755 pyglet .graphics .OrderedGroup (order = o ), ('v2i' ,
@@ -1745,7 +1761,8 @@ def create_batch(self):
17451761 o += 1
17461762 # draw maximum
17471763 if have_shapes :
1748- pyglet .shapes .Polygon ((x - radius , maxp - radius ), (x - radius , maxp + radius ), (x + radius , maxp + radius ), (x + radius , maxp - radius ), color = linecolor , batch = self .batch )
1764+ None
1765+ #self.sh += Polygon((x - radius, maxp - radius), (x - radius, maxp + radius), (x + radius, maxp + radius), (x + radius, maxp - radius), color=linecolor, batch=self.batch)
17491766 else :
17501767 self .batch .add (4 , pyglet .gl .GL_POLYGON ,
17511768 pyglet .graphics .OrderedGroup (order = o ), ('v2i' ,
@@ -1771,7 +1788,7 @@ def create_batch(self):
17711788 str_list .append (labelstrings [m ] + '%i%% ' % self .percents [self .graph ][m ][- 1 ]
17721789 + ' ' * (7 - len (mode .modalities [self .graph ])))
17731790
1774- pyglet .text .Label ('' .join (str_list ),
1791+ self . sh += pyglet .text .Label ('' .join (str_list ),
17751792 batch = self .batch ,
17761793 font_size = calc_fontsize (11 ), weight = 'normal' , color = cfg .COLOR_TEXT ,
17771794 x = width_center (), y = scale_to_width (20 ),
0 commit comments