@@ -58,6 +58,8 @@ def get_argv(arg):
58
58
from time import strftime
59
59
from datetime import date
60
60
import gettext
61
+ from pyglet .shapes import Line
62
+ from pyglet .shapes import Polygon
61
63
62
64
# TODO check if this is right
63
65
gettext .install ('messages' , localedir = 'res/i18n' )
@@ -1378,13 +1380,22 @@ def short_name(self, mode=None, back=None):
1378
1380
#
1379
1381
1380
1382
class 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
+
1381
1390
def __init__ (self ):
1382
1391
self .graph = 2
1383
1392
self .reset_dictionaries ()
1384
1393
self .reset_percents ()
1385
1394
self .batch = None
1386
1395
self .styles = ['N+10/3+4/3' , 'N' , '%' , 'N.%' , 'N+2*%-1' ]
1387
1396
self .style = 0
1397
+ self .sh = self .ShapesStore ()
1398
+
1388
1399
1389
1400
def next_style (self ):
1390
1401
self .style = (self .style + 1 ) % len (self .styles )
@@ -1563,16 +1574,16 @@ def create_batch(self):
1563
1574
graph_title = mode .long_mode_names [self .graph ] + _ (' N-Back' )
1564
1575
1565
1576
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 )
1568
1579
else :
1569
1580
self .batch .add (3 , pyglet .gl .GL_LINE_STRIP ,
1570
1581
pyglet .graphics .OrderedGroup (order = 1 ), ('v2i' , (
1571
1582
left , top ,
1572
1583
left , bottom ,
1573
1584
right , bottom )), ('c3B' , axiscolor * 3 ))
1574
1585
1575
- pyglet .text .Label (
1586
+ self . sh += pyglet .text .Label (
1576
1587
_ ('G: Return to Main Screen\n \n N: Next Game Type' ),
1577
1588
batch = self .batch ,
1578
1589
multiline = True , width = scale_to_width (300 ),
@@ -1581,31 +1592,31 @@ def create_batch(self):
1581
1592
x = from_left_edge (10 ), y = from_top_edge (10 ),
1582
1593
anchor_x = 'left' , anchor_y = 'top' )
1583
1594
1584
- pyglet .text .Label (graph_title ,
1595
+ self . sh += pyglet .text .Label (graph_title ,
1585
1596
batch = self .batch ,
1586
1597
font_size = calc_fontsize (18 ), weight = 'bold' , color = cfg .COLOR_TEXT ,
1587
1598
x = center_x , y = top + scale_to_height (60 ),
1588
1599
anchor_x = 'center' , anchor_y = 'center' )
1589
1600
1590
- pyglet .text .Label (_ ('Date' ),
1601
+ self . sh += pyglet .text .Label (_ ('Date' ),
1591
1602
batch = self .batch ,
1592
1603
font_size = calc_fontsize (12 ), weight = 'bold' , color = cfg .COLOR_TEXT ,
1593
1604
x = center_x , y = bottom - scale_to_height (80 ),
1594
1605
anchor_x = 'center' , anchor_y = 'center' )
1595
1606
1596
- pyglet .text .Label (_ ('Maximum' ), width = scale_to_width (1 ),
1607
+ self . sh += pyglet .text .Label (_ ('Maximum' ), width = scale_to_width (1 ),
1597
1608
batch = self .batch ,
1598
1609
font_size = calc_fontsize (12 ), weight = 'bold' , color = linecolor2 + (255 ,),
1599
1610
x = left - scale_to_width (60 ), y = center_y + scale_to_height (50 ),
1600
1611
anchor_x = 'right' , anchor_y = 'center' )
1601
1612
1602
- pyglet .text .Label (_ ('Average' ), width = scale_to_width (1 ),
1613
+ self . sh += pyglet .text .Label (_ ('Average' ), width = scale_to_width (1 ),
1603
1614
batch = self .batch ,
1604
1615
font_size = calc_fontsize (12 ), weight = 'bold' , color = linecolor + (255 ,),
1605
1616
x = left - scale_to_width (60 ), y = center_y + scale_to_height (25 ),
1606
1617
anchor_x = 'right' , anchor_y = 'center' )
1607
1618
1608
- pyglet .text .Label (_ ('Score' ), width = scale_to_width (1 ),
1619
+ self . sh += pyglet .text .Label (_ ('Score' ), width = scale_to_width (1 ),
1609
1620
batch = self .batch ,
1610
1621
font_size = calc_fontsize (12 ), weight = 'bold' , color = cfg .COLOR_TEXT ,
1611
1622
x = left - scale_to_width (60 ), y = center_y ,
@@ -1614,7 +1625,7 @@ def create_batch(self):
1614
1625
dates = list (dictionary )
1615
1626
dates .sort ()
1616
1627
if len (dates ) < 2 :
1617
- pyglet .text .Label (_ ('Insufficient data: two days needed' ),
1628
+ self . sh += pyglet .text .Label (_ ('Insufficient data: two days needed' ),
1618
1629
batch = self .batch ,
1619
1630
font_size = calc_fontsize (12 ), weight = 'bold' , color = axiscolor + (255 ,),
1620
1631
x = center_x , y = center_y ,
@@ -1668,14 +1679,14 @@ def create_batch(self):
1668
1679
if 10 < len (dates ):
1669
1680
datestring = datestring .replace ('-' , '\n ' )
1670
1681
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 ),
1672
1683
batch = self .batch ,
1673
1684
font_size = calc_fontsize (8 ), weight = 'bold' , color = cfg .COLOR_TEXT ,
1674
1685
x = x , y = bottom - scale_to_height (15 ),
1675
1686
anchor_x = 'center' , anchor_y = 'top' )
1676
1687
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 )
1679
1690
else :
1680
1691
self .batch .add (2 , pyglet .gl .GL_LINES ,
1681
1692
pyglet .graphics .OrderedGroup (order = 0 ), ('v2i' , (
@@ -1691,14 +1702,14 @@ def create_batch(self):
1691
1702
y_marking = ymin
1692
1703
while y_marking <= ymax :
1693
1704
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 )),
1695
1706
batch = self .batch ,
1696
1707
font_size = calc_fontsize (10 ), weight = 'normal' , color = cfg .COLOR_TEXT ,
1697
1708
x = left - scale_to_width (30 ), y = y + scale_to_width (1 ),
1698
1709
anchor_x = 'center' , anchor_y = 'center' )
1699
1710
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 )
1702
1713
else :
1703
1714
self .batch .add (2 , pyglet .gl .GL_LINES ,
1704
1715
pyglet .graphics .OrderedGroup (order = 0 ), ('v2i' , (
@@ -1711,8 +1722,12 @@ def create_batch(self):
1711
1722
y_marking += y_marking_interval
1712
1723
1713
1724
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 )
1716
1731
else :
1717
1732
self .batch .add (len (avgpoints ) // 2 , pyglet .gl .GL_LINE_STRIP ,
1718
1733
pyglet .graphics .OrderedGroup (order = 2 ), ('v2i' ,
@@ -1733,7 +1748,8 @@ def create_batch(self):
1733
1748
maxp = maxpoints [index * 2 + 1 ]
1734
1749
# draw average
1735
1750
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)
1737
1753
else :
1738
1754
self .batch .add (4 , pyglet .gl .GL_POLYGON ,
1739
1755
pyglet .graphics .OrderedGroup (order = o ), ('v2i' ,
@@ -1745,7 +1761,8 @@ def create_batch(self):
1745
1761
o += 1
1746
1762
# draw maximum
1747
1763
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)
1749
1766
else :
1750
1767
self .batch .add (4 , pyglet .gl .GL_POLYGON ,
1751
1768
pyglet .graphics .OrderedGroup (order = o ), ('v2i' ,
@@ -1771,7 +1788,7 @@ def create_batch(self):
1771
1788
str_list .append (labelstrings [m ] + '%i%% ' % self .percents [self .graph ][m ][- 1 ]
1772
1789
+ ' ' * (7 - len (mode .modalities [self .graph ])))
1773
1790
1774
- pyglet .text .Label ('' .join (str_list ),
1791
+ self . sh += pyglet .text .Label ('' .join (str_list ),
1775
1792
batch = self .batch ,
1776
1793
font_size = calc_fontsize (11 ), weight = 'normal' , color = cfg .COLOR_TEXT ,
1777
1794
x = width_center (), y = scale_to_width (20 ),
0 commit comments