Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 110062 | Differences between
and this patch

Collapse All | Expand All

(-)modules/menu.py (-4 / +8 lines)
Lines 1058-1066 Link Here
1058
1058
1059
class MenuHiscores(Menu):
1059
class MenuHiscores(Menu):
1060
  '''Menu to display Hiscores'''
1060
  '''Menu to display Hiscores'''
1061
1061
  configfile = None
1062
  
1062
  def __init__(self, titleFont, title, gap, itemFont):
1063
  def __init__(self, titleFont, title, gap, itemFont):
1064
    global configfile
1063
1065
1066
    configfile = os.environ.get('HOME') + "/.pyRacerz.conf"
1064
    Menu.__init__(self, titleFont, title)
1067
    Menu.__init__(self, titleFont, title)
1065
1068
1066
    self.gap = gap
1069
    self.gap = gap
Lines 1071-1077 Link Here
1071
    
1074
    
1072
    confFile=ConfigParser.SafeConfigParser() 
1075
    confFile=ConfigParser.SafeConfigParser() 
1073
    try:
1076
    try:
1074
      confFile.readfp(file(".pyRacerz.conf", "r")) 
1077
      confFile.readfp(file(configfile, "r")) 
1075
      self.nbItem = 0
1078
      self.nbItem = 0
1076
1079
1077
      for sect in confFile.sections():
1080
      for sect in confFile.sections():
Lines 1112-1123 Link Here
1112
      pygame.time.delay(10)
1115
      pygame.time.delay(10)
1113
1116
1114
  def refresh(self):
1117
  def refresh(self):
1115
1118
    global configfile
1119
    
1116
    y = self.startY
1120
    y = self.startY
1117
1121
1118
    confFile=ConfigParser.SafeConfigParser() 
1122
    confFile=ConfigParser.SafeConfigParser() 
1119
    try:
1123
    try:
1120
      confFile.readfp(file(".pyRacerz.conf", "r")) 
1124
      confFile.readfp(file(configfile, "r")) 
1121
    except Exception:
1125
    except Exception:
1122
      return
1126
      return
1123
1127
(-)modules/misc.py (-11 / +19 lines)
Lines 43-48 Link Here
43
43
44
zoom = 1
44
zoom = 1
45
45
46
# path to configfile (to save config in the homedir of the user who is running the game)
47
configfile = None
48
46
def init():
49
def init():
47
  global popUpFont
50
  global popUpFont
48
  global titleFont
51
  global titleFont
Lines 50-55 Link Here
50
  global smallItemFont
53
  global smallItemFont
51
  global bigFont
54
  global bigFont
52
  global background
55
  global background
56
  global configfile
53
57
54
  try:
58
  try:
55
    popUpFont = pygame.font.Font(os.path.join("fonts", "arcade_pizzadude", "ARCADE.TTF"), int(24*zoom))
59
    popUpFont = pygame.font.Font(os.path.join("fonts", "arcade_pizzadude", "ARCADE.TTF"), int(24*zoom))
Lines 63-68 Link Here
63
    sys.exit(-1)
67
    sys.exit(-1)
64
68
65
  background = pygame.transform.scale(pygame.image.load(os.path.join("sprites", "background.png")).convert(), (int(1024*zoom), int(768*zoom)))
69
  background = pygame.transform.scale(pygame.image.load(os.path.join("sprites", "background.png")).convert(), (int(1024*zoom), int(768*zoom)))
70
  configfile = os.environ.get('HOME') + "/.pyRacerz.conf"
66
71
67
def chrono2Str(chrono):
72
def chrono2Str(chrono):
68
  return str(chrono/100.0).replace(".", "''")
73
  return str(chrono/100.0).replace(".", "''")
Lines 152-172 Link Here
152
        y = y - textRect.height
157
        y = y - textRect.height
153
158
154
def addHiScore(track, player):
159
def addHiScore(track, player):
160
  global configfile
155
161
156
  fileExist = 1
162
  fileExist = 1
157
163
158
  confFile=ConfigParser.SafeConfigParser() 
164
  confFile=ConfigParser.SafeConfigParser() 
159
  try:
165
  try:
160
    confFile.readfp(file(".pyRacerz.conf", "r")) 
166
    confFile.readfp(file(configfile, "r")) 
161
  except Exception:
167
  except Exception:
162
    fileExist = 0
168
    fileExist = 0
163
  
169
  
164
  # If the track is not represented, create it
170
  # If the track is not represented, create it
165
  if fileExist == 0 or not confFile.has_section("hi " + track.name):
171
  if fileExist == 0 or not confFile.has_section("hi " + track.name):
166
    fwrite = file(".pyRacerz.conf", "w+")
172
    fwrite = file(configfile, "w+")
167
    confFile.add_section("hi " + track.name)
173
    confFile.add_section("hi " + track.name)
168
    confFile.write(fwrite)
174
    confFile.write(fwrite)
169
    confFile.readfp(file(".pyRacerz.conf", "r")) 
175
    confFile.readfp(file(configfile, "r")) 
170
176
171
  # For the Inverse
177
  # For the Inverse
172
  if track.reverse == 0:
178
  if track.reverse == 0:
Lines 180-186 Link Here
180
    h.update(str("level" + str(level)))
186
    h.update(str("level" + str(level)))
181
    h.update(player.name)
187
    h.update(player.name)
182
    h.update(str(player.bestChrono))
188
    h.update(str(player.bestChrono))
183
    fwrite = file(".pyRacerz.conf", "w+")
189
    fwrite = file(configfile, "w+")
184
    confFile.set("hi " + track.name, "level" + str(level), player.name + " " + str(player.bestChrono) + " " + h.hexdigest())
190
    confFile.set("hi " + track.name, "level" + str(level), player.name + " " + str(player.bestChrono) + " " + h.hexdigest())
185
    confFile.write(fwrite)
191
    confFile.write(fwrite)
186
    return 1
192
    return 1
Lines 196-202 Link Here
196
        h.update(str("level" + str(level)))
202
        h.update(str("level" + str(level)))
197
        h.update(player.name)
203
        h.update(player.name)
198
        h.update(str(player.bestChrono))
204
        h.update(str(player.bestChrono))
199
        fwrite = file(".pyRacerz.conf", "w+")
205
        fwrite = file(configfile, "w+")
200
        confFile.set("hi " + track.name, "level" + str(level), player.name + " " + str(player.bestChrono) + " " + h.hexdigest())
206
        confFile.set("hi " + track.name, "level" + str(level), player.name + " " + str(player.bestChrono) + " " + h.hexdigest())
201
        confFile.write(fwrite)
207
        confFile.write(fwrite)
202
        return 1
208
        return 1
Lines 208-223 Link Here
208
      h.update(str("level" + str(level)))
214
      h.update(str("level" + str(level)))
209
      h.update(player.name)
215
      h.update(player.name)
210
      h.update(str(player.bestChrono))
216
      h.update(str(player.bestChrono))
211
      fwrite = file(".pyRacerz.conf", "w+")
217
      fwrite = file(configfile, "w+")
212
      confFile.set("hi " + track.name, "level" + str(level), player.name + " " + str(player.bestChrono) + " " + h.hexdigest())
218
      confFile.set("hi " + track.name, "level" + str(level), player.name + " " + str(player.bestChrono) + " " + h.hexdigest())
213
      confFile.write(fwrite)
219
      confFile.write(fwrite)
214
      return 1
220
      return 1
215
221
216
def getUnlockLevel():
222
def getUnlockLevel():
223
  global configfile
217
224
218
  confFile=ConfigParser.SafeConfigParser() 
225
  confFile=ConfigParser.SafeConfigParser() 
219
  try:
226
  try:
220
    confFile.readfp(file(".pyRacerz.conf", "r")) 
227
    confFile.readfp(file(configfile, "r")) 
221
  except Exception:
228
  except Exception:
222
    return 0
229
    return 0
223
230
Lines 235-240 Link Here
235
    return 0
242
    return 0
236
243
237
def setUnlockLevel(lck):
244
def setUnlockLevel(lck):
245
  global configfile
238
246
239
  # Only change the unlock level if it's better than the actual one
247
  # Only change the unlock level if it's better than the actual one
240
  if getUnlockLevel() >= lck:
248
  if getUnlockLevel() >= lck:
Lines 244-262 Link Here
244
252
245
  confFile=ConfigParser.SafeConfigParser() 
253
  confFile=ConfigParser.SafeConfigParser() 
246
  try:
254
  try:
247
    confFile.readfp(file(".pyRacerz.conf", "r")) 
255
    confFile.readfp(file(configfile, "r")) 
248
  except Exception:
256
  except Exception:
249
    fileExist = 0
257
    fileExist = 0
250
258
251
  if fileExist == 0 or not confFile.has_section("unlockLevel"):
259
  if fileExist == 0 or not confFile.has_section("unlockLevel"):
252
    fwrite = file(".pyRacerz.conf", "w+")
260
    fwrite = file(configfile, "w+")
253
    confFile.add_section("unlockLevel")
261
    confFile.add_section("unlockLevel")
254
    confFile.write(fwrite)
262
    confFile.write(fwrite)
255
    confFile.readfp(file(".pyRacerz.conf", "r"))
263
    confFile.readfp(file(configfile, "r"))
256
264
257
  h = sha.new("pyRacerz")
265
  h = sha.new("pyRacerz")
258
  h.update(str(lck))
266
  h.update(str(lck))
259
  fwrite = file(".pyRacerz.conf", "w+")
267
  fwrite = file(configfile, "w+")
260
  confFile.set("unlockLevel", "key", str(lck) + " " + h.hexdigest())
268
  confFile.set("unlockLevel", "key", str(lck) + " " + h.hexdigest())
261
  confFile.write(fwrite)
269
  confFile.write(fwrite)

Return to bug 110062