-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconstants.py
207 lines (176 loc) · 6.62 KB
/
constants.py
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# Constants used in the game and some simple initialization routines
# This file should be kept as small as possible, probably. (But I seem
# to be failing at doing that.)
import sys
import os
import locale
from string import maketrans
from i18n import *
VERSION = "1.1.0"
try: locale.setlocale(locale.LC_ALL, '')
except locale.Error: pass
# Detect the name of the OS - Mac OS X is not really UNIX.
osname = None
if os.name == "nt": osname = "win32"
elif os.name == "posix":
if os.path.islink("/System/Library/CoreServices/WindowServer"):
osname = "macosx"
elif "HOME" in os.environ:
osname = "posix"
else:
raise SystemExit(
"Your platform is not supported by pydance. In particular, it\n" +
"doesn't seem to be Win32, Mac OS X, or a Unix that sets $HOME.")
# Find out our real directory - resolve symlinks, etc
pydance_path = sys.argv[0]
if osname == "posix":
pydance_path = os.path.split(os.path.realpath(pydance_path))[0]
else: pydance_path = os.path.split(os.path.abspath(pydance_path))[0]
sys.path.insert(0, pydance_path)
if os.path.exists(os.path.join(pydance_path, "pydance.zip")):
sys.path.insert(0, os.path.join(pydance_path, "pydance.zip"))
# Set up some names for commonly referenced directories
image_path = os.path.join(pydance_path, "images")
sound_path = os.path.join(pydance_path, "sound")
# Set a name for our savable resource directory
rc_path = None
if osname == "posix":
rc_path = os.path.join(os.environ["HOME"], ".pydance")
elif osname == "macosx":
rc_path = os.path.join(os.environ["HOME"], "Library",
"Preferences", "pydance")
elif osname == "win32": rc_path = "."
if not os.path.isdir(rc_path): os.mkdir(rc_path)
search_paths = (pydance_path, rc_path)
if not sys.stdout.isatty():
sys.stdout = file(os.path.join(rc_path, "pydance.log"), "w")
sys.stderr = sys.stdout
import pygame
import games
import config
import colors
from pygame.locals import *
# SDL_mixer is the bane of my existance.
if osname == 'posix': # We need to force stereo in many cases.
try: pygame.mixer.pre_init(44100, -16, 2)
except pygame.error: pass
# Set up the configuration file
default_conf = {
"fonttheme": "default",
"djtheme": "djenzay",
"songdir": os.pathsep.join([os.path.join(rc_path, "songs"),
os.path.join(pydance_path, "songs")]),
"coursedir": os.pathsep.join([os.path.join(rc_path, "courses"),
os.path.join(pydance_path, "courses")]),
"stickycombo": 1, "lowestcombo": 4, "stickyjudge": 1,
"lyriccolor": "cyan/aqua",
"onboardaudio": 0, "masteroffset": 0,
"explodestyle": 3, "vesacompat": 0, "fullscreen": 0,
"sortmode": 0,
"folders": 1,
"previewmusic": 1,
"showbackground": 1, "bgbrightness": 127,
"gratuitous": 1,
"assist": 0,
"fpsdisplay": 1, "showlyrics": 1,
"showcombo": 1,
"autofail": 1,
"animation": 1,
"grading": 1,
"saveinput": 1,
"strobe": 0,
"usepsyco": 1,
"autogen": 1,
"centerconfirm": 1,
"songinfoscreen": 1,
# Player config
"spin": 0,
"accel": 0,
"transform": 0,
"scale": 1,
"speed": 1.0,
"fade": 0,
"size": 0,
"dark": 0,
"jumps": 1,
"holds": 1,
"colortype": 4,
"scrollstyle": 0,
# Game options
"battle": 0,
"scoring": 0,
"combo": 0,
"grade": 0,
"judge": 0,
"judgescale": 1.0,
"life": 1.0,
"secret": 1,
"lifebar": 0,
"onilives": 3,
}
for game in games.GAMES.values():
default_conf["%s-theme" % game.theme] = game.theme_default
mainconfig = config.Config(default_conf)
if osname == "posix":
mainconfig.load("/etc/pydance.cfg", True)
elif osname == "macosx":
mainconfig.load("/Library/Preferences/pydance/pydance.cfg", True)
mainconfig.load("pydance.cfg")
mainconfig.load(os.path.join(rc_path, "pydance.cfg"))
mainconfig["sortmode"] %= 6
player_config = dict([(k, mainconfig[k]) for k in
["spin", "accel", "transform", "scale", "speed",
"fade", "size", "dark", "jumps", "holds", "colortype",
"scrollstyle"]])
game_config = dict([(k, mainconfig[k]) for k in
["battle", "scoring", "combo", "grade", "judge",
"judgescale", "life", "secret", "lifebar", "onilives"]])
# The list of options that are safe to change between songs on a
# playlist
# Each tuple has the following entries:
# 0. Option "key", like the one used in the options.OPTIONS dictionary
# 1. A dictionary of option values that require special displaying:
# the key is the value of the option and the value is a string that
# should be shown on the song info screen if that option is
# selected. If there is no key for a particular option, the string
# that is displayed for that value in the option menu is used.
# E.g. for the "jumps" option, value 0 will map to "No Jumps" while
# value 2 is not in the dictionary so will display "Wide".
changeable_between = [('speed', {}),
('transform', {}),
('size', {}),
('fade', {}),
('accel', {}),
('scale', {}),
('scrollstyle', {}),
('jumps', {0:"No Jumps"}),
('spin', {1:"Spin"}),
('colortype', {}),
('dark', {1:"Dark"}),
('holds', {0:"No Holds"})
]
pygame.init()
# The different colors pydance uses for difficulties in the UI.
DIFF_COLORS = { "BEGINNER": colors.color[_("white")],
"LIGHT": colors.color[_("orange")],
"EASY": colors.color[_("orange")],
"BASIC": colors.color[_("orange")],
"STANDARD": colors.color[_("red")],
"STANDER": colors.color[_("red")], # Shit you not, 3 people.
"TRICK": colors.color[_("red")],
"MEDIUM": colors.color[_("red")],
"DOUBLE": colors.color[_("red")],
"ANOTHER": colors.color[_("red")],
"PARA": colors.color[_("blue")],
"NORMAL": colors.color[_("red")],
"MANIAC": colors.color[_("green")],
"HARD": colors.color[_("green")],
"HEAVY": colors.color[_("green")],
"HARDCORE": colors.color[_("purple")],
"SMANIAC": colors.color[_("purple")],
"S-MANIAC": colors.color[_("purple")], # Very common typo
"CHALLENGE": colors.color[_("purple")],
"CRAZY": colors.color[_("purple")],
"EXPERT": colors.color[_("purple")]
}
ZERO_ALPHA = maketrans(''.join([chr(x) for x in range(ord("a"),ord("z")+1)+range(ord("A"),ord("Z")+1)]),'0'*26*2)