Package: pathological / 1.1.3-16

20_highscores.patch Patch series | download
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
From: Debian Games Team <pkg-games-devel@lists.alioth.debian.org>
Date: Thu, 11 Apr 2013 01:16:52 +0200
Subject: 20_highscores

---
 pathological    |    6 +-----
 pathological.py |   53 ++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/pathological b/pathological
index ca356b3..8a77cb7 100755
--- a/pathological
+++ b/pathological
@@ -32,8 +32,4 @@ done
 
 cd /usr/share/games/pathological
 
-if [ -z "$scoresfile" ]; then
-	scoresfile=/var/games/pathological_scores
-fi
-
-exec ./pathological.py $options $scoresfile
+exec ./pathological.py $options
diff --git a/pathological.py b/pathological.py
index 5c15009..d86c6ca 100755
--- a/pathological.py
+++ b/pathological.py
@@ -1,6 +1,8 @@
 #!/usr/bin/python
+# -*- coding: iso-8859-1 -*-
 """
 Copyright (C) 2003  John-Paul Gignac
+          (C) 2004  Joe Wreschnig
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -22,7 +24,7 @@ import os, pygame, random, time, math, re, sys, md5
 from pygame.locals import *
 
 # Parse the command line
-highscores_file = "pathological_scores"
+highscores_file = os.path.join(os.environ["HOME"], ".pathological_scores")
 screenshot = 0
 fullscreen = 0
 colorblind = 0
@@ -51,7 +53,7 @@ else:
 
 # The location of the setgid script for writing highscores
 # This script is only used if the highscores file is not writable directly
-write_highscores = "/usr/lib/pathological/bin/write-highscores"
+write_highscores = "/usr/lib/games/pathological/bin/write-highscores"
 
 # Game constants
 wheel_steps = 9
@@ -1562,7 +1564,7 @@ def popdown( popup_rc):
 		pygame.display.update( popup_rc[1])
 
 class Game:
-	def __init__(self, screen, circuit, highscores):
+	def __init__(self, screen, circuit, highscores, level = 0):
 		self.screen = screen
 		self.circuit = circuit
 		self.highscores = highscores
@@ -1578,7 +1580,7 @@ class Game:
 		f.close()
 		self.numlevels = j / vert_tiles
 
-		self.level = 0
+		self.level = level
 		self.score = 0
 		self.lives = initial_lives
 
@@ -1829,6 +1831,7 @@ def get_name( screen, font, cursor_box, backcol, forecol):
 class IntroScreen:
 	menu = ("Start Game", "High Scores", "Fullscreen:", "Music:",
 		"Sound Effects:", "Quit Game")
+	start_level = 1
 	menu_width = 240
 	menu_pos = ((800 - menu_width)/2, 145)
 	menu_font_height = 32
@@ -1914,6 +1917,14 @@ class IntroScreen:
 			self.screen.blit( menu_option, (self.menu_pos[0], y))
 			y += self.menu_font_height
 
+		levelt = self.menu_font.render("(Lvl. %d)" %
+					       IntroScreen.start_level,
+					       1, self.menu_color)
+		lt_r = levelt.get_rect()
+		lt_r.right = self.menu_pos[0] + self.menu_option_left + 40
+		lt_r.top = self.menu_pos[1]
+		self.screen.blit(levelt, lt_r)
+
 		if fullscreen: offon = 'On'
 		else: offon = 'Off'
 		offon = self.menu_font.render( offon, 1, self.menu_color)
@@ -1966,6 +1977,15 @@ class IntroScreen:
 		self.curpage = 1
 		self.draw_menu()
 
+	def inc_level(self):
+		if (IntroScreen.start_level <
+		    max([s[2] for s in self.highscores.scores])):
+			IntroScreen.start_level += 1
+
+	def dec_level(self):
+		if IntroScreen.start_level > 1:
+			IntroScreen.start_level -= 1
+
 	def do(self, show_highscores=0):
 		self.scroller_pos = -self.scroller_rect[2]
 
@@ -2028,7 +2048,15 @@ class IntroScreen:
 						self.draw_menu()
 					elif event.key == K_SPACE or event.key == K_RETURN:
 						rc = self.menu_select( self.menu_cursor)
-						if rc < 1: return rc
+						if rc: return rc
+					elif event.key == K_LEFT:
+						if self.menu_cursor == 0:
+							self.dec_level()
+							self.draw_menu()
+					elif event.key == K_RIGHT:
+						if self.menu_cursor == 0:
+							self.inc_level()
+							self.draw_menu()
 					continue
 				elif event.type is MOUSEBUTTONDOWN:
 					if self.curpage == 1:
@@ -2044,9 +2072,8 @@ class IntroScreen:
 					if pos[1] < self.menu_pos[1]: continue
 					i = (pos[1] - self.menu_pos[1]) / self.menu_font_height
 					if i >= len(self.menu): continue
-
 					rc = self.menu_select( i)
-					if rc < 1: return rc
+					if rc: return rc
 
 			pygame.display.update( self.dirty_rects)
 
@@ -2057,7 +2084,7 @@ class IntroScreen:
 	#  1 - Unknown option
 	def menu_select( self, i):
 		if i == 0:
-			return 0
+			return IntroScreen.start_level
 		elif i == 1:
 			play_sound( menu_select)
 			self.go_to_highscores()
@@ -2075,7 +2102,7 @@ class IntroScreen:
 			self.draw_menu()
 		elif i == 5:
 			return -1
-		return 1
+		return 0
 
 	hs_font_height = 24
 	hs_width = 320
@@ -2157,7 +2184,10 @@ def setup_everything():
 		pygame.mixer.pre_init(44100,-16,1,4096)
 
 	# Initialize the game module
-	pygame.init()
+	pygame.display.init()
+	pygame.mixer.init()
+	pygame.font.init()
+	pygame.key.set_repeat(500, 30)
 
 	if not pygame.font: print 'Warning, fonts disabled'
 	if not pygame.mixer: print 'Warning, sound disabled'
@@ -2189,7 +2219,8 @@ while 1:
 
 	if rc < 0: break   # Handle the QUIT message
 
-	game = Game(screen, 'all-boards', highscores)
+	# If rc is positive, it's a level.
+	game = Game(screen, 'all-boards', highscores, rc - 1)
 
 	show_highscores = 1