File: datasclass.py

package info (click to toggle)
pysycache 3.1-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 50,004 kB
  • ctags: 472
  • sloc: python: 5,146; lisp: 1,152; sh: 102; makefile: 51; ansic: 4
file content (89 lines) | stat: -rw-r--r-- 3,384 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python

# -*- coding: utf8 -*- 

#***********************************************************************
# pysycache : a tool for learn to use the mouse
# Copyright (C) 2005-2007 Vincent DEROO (vincent.pysycache@free.fr)
#
# This tool is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#***********************************************************************



import pygame
from pygame.locals import *
import datas
import os
import const



#*******************************************************************************
#                                                                              #
#                                                                              #
#                                   Classes                                    #
#                                                                              #
#                                                                              #
#*******************************************************************************

class BtnMenu(pygame.sprite.Sprite):
	"""This class is for the menus buttons"""
	def __init__(self, left, top, filename, id):
		pygame.sprite.Sprite.__init__(self) 				#call Sprite intializer
		self.image, self.rect = datas.load_image("images", filename)
		(shortname, extension) = os.path.splitext(filename) 
		self.imagename = shortname
		self.rect.left = left
		self.rect.top = top 
		self.id = id
		(self.largeur, self.hauteur) = self.image.get_size()


	def showhelp(self, imgdest):
		myfont = os.path.join(const.GRepPysycache, 'fonts', const.GFontName ).encode(const.GConsoleLocale)
		font = pygame.font.Font(myfont, 20)
		textcolor = 46, 113, 169
		screen = pygame.display.get_surface()

		myrep = os.path.join(const.GRepPysycache, 'help', const.GMyLocale )

		#joue le fichier d'aide
		if const.GWithSound == 1:
			if const.GWithHelp == 1 :
				dirname = os.path.join(const.GRepPysycache, 'help', const.GMyLocale)
				filename = str(self.id) + '.ogg'
				datas.load_sound(dirname, filename)

		#affiche l'aide
		if os.path.isdir(myrep):
			filename = os.path.join(const.GRepPysycache, 'help', const.GMyLocale , str(self.id) + '.txt')
		else :
			filename = os.path.join(const.GRepPysycache, 'help', 'en_EN' , str(self.id) + '.txt')
			
		filename = os.path.join(const.GRepPysycache, 'help', const.GMyLocale , str(self.id) + '.txt')
		if os.path.isfile(filename):
			f = open(filename, 'r')
			lignes  = f.readlines()
			cptligne = 0;
			for j in lignes:
				j = j.strip()
#				text = font.render(unicode(j, "utf-8"), 1, textcolor)
				text = font.render(j.decode("utf-8", "ignore"), 1, textcolor)
				imgdest.blit(text, (195, 301 + 25 * cptligne))
				cptligne += 1
			f.close()

			pygame.display.update()