Merge branch 'master' into devel
This commit is contained in:
commit
27d24006a2
@ -34,19 +34,32 @@ import time
|
|||||||
localConfig = configparser.ConfigParser()
|
localConfig = configparser.ConfigParser()
|
||||||
globalConfig = configparser.ConfigParser()
|
globalConfig = configparser.ConfigParser()
|
||||||
|
|
||||||
|
class scoreboard():
|
||||||
|
'Handles scores and top 10'
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.oldScores = []
|
||||||
|
for i in range(9):
|
||||||
|
try:
|
||||||
|
self.oldScores[i] = read_config("scoreboard", i)
|
||||||
|
except:
|
||||||
|
self.oldScores[i] = 0
|
||||||
|
|
||||||
|
|
||||||
def write_config(writeGlobal = False):
|
def write_config(writeGlobal = False):
|
||||||
if writeGlobal == False:
|
if writeGlobal == False:
|
||||||
with open(gamePath, 'w') as configfile:
|
with open(gamePath + "config.ini", 'w') as configfile:
|
||||||
localConfig.write(configfile)
|
localConfig.write(configfile)
|
||||||
else:
|
else:
|
||||||
with open(globalPath, 'w') as configfile:
|
with open(globalPath + "config.ini", 'w') as configfile:
|
||||||
globalConfig.write(configfile)
|
globalConfig.write(configfile)
|
||||||
|
|
||||||
def read_config(section, value, readGlobal = False):
|
def read_config(section, value, readGlobal = False):
|
||||||
if readGlobal == False:
|
if readGlobal == False:
|
||||||
with open(gamePath, 'r') as configfile:
|
with open(gamePath + "config.ini", 'r') as configfile:
|
||||||
return localConfig.read(section, value)
|
return localConfig.read(section, value)
|
||||||
else:
|
else:
|
||||||
|
with open(globalPath + "config.ini", 'r') as configfile:
|
||||||
return globalConfig.read(section, value)
|
return globalConfig.read(section, value)
|
||||||
|
|
||||||
def speak(text, interupt = True):
|
def speak(text, interupt = True):
|
||||||
@ -69,8 +82,7 @@ def initialize_gui(gameTitle):
|
|||||||
global globalPath
|
global globalPath
|
||||||
global gamePath
|
global gamePath
|
||||||
globalPath = BaseDirectory.xdg_config_home + "/storm-games"
|
globalPath = BaseDirectory.xdg_config_home + "/storm-games"
|
||||||
gamePath = globalPath + "/" + str.lower(str.replace(gameTitle, " ", "-") + "config")
|
gamePath = globalPath + "/" + str.lower(str.replace(gameTitle, " ", "-"))
|
||||||
globalPath = globalPath + "/config"
|
|
||||||
if not os.path.exists(gamePath): os.makedirs(gamePath)
|
if not os.path.exists(gamePath): os.makedirs(gamePath)
|
||||||
# Seed the random generator to the clock
|
# Seed the random generator to the clock
|
||||||
random.seed()
|
random.seed()
|
||||||
@ -189,12 +201,15 @@ def learn_sounds(sounds):
|
|||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
if event.key == pygame.K_ESCAPE: return "menu"
|
if event.key == pygame.K_ESCAPE: return "menu"
|
||||||
if event.key == pygame.K_DOWN and i < len(soundFiles) - 1:
|
if event.key == pygame.K_DOWN and i < len(soundFiles) - 1:
|
||||||
|
pygame.mixer.stop()
|
||||||
i = i + 1
|
i = i + 1
|
||||||
if event.key == pygame.K_UP and i > 0:
|
if event.key == pygame.K_UP and i > 0:
|
||||||
|
pygame.mixer.stop()
|
||||||
i = i - 1
|
i = i - 1
|
||||||
if event.key == pygame.K_RETURN:
|
if event.key == pygame.K_RETURN:
|
||||||
try:
|
try:
|
||||||
soundName = soundFiles[i][:-4]
|
soundName = soundFiles[i][:-4]
|
||||||
|
pygame.mixer.stop()
|
||||||
sounds[soundName].play()
|
sounds[soundName].play()
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
@ -204,7 +219,7 @@ def learn_sounds(sounds):
|
|||||||
event = pygame.event.clear()
|
event = pygame.event.clear()
|
||||||
time.sleep(0.001)
|
time.sleep(0.001)
|
||||||
|
|
||||||
def game_menu(*options):
|
def game_menu(sounds, *options):
|
||||||
loop = True
|
loop = True
|
||||||
if pygame.mixer.music.get_busy():
|
if pygame.mixer.music.get_busy():
|
||||||
pygame.mixer.music.unpause()
|
pygame.mixer.music.unpause()
|
||||||
@ -224,13 +239,26 @@ def game_menu(*options):
|
|||||||
if event.key == pygame.K_ESCAPE: exit_game()
|
if event.key == pygame.K_ESCAPE: exit_game()
|
||||||
if event.key == pygame.K_DOWN and i < len(options) - 1:
|
if event.key == pygame.K_DOWN and i < len(options) - 1:
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
try:
|
||||||
|
sounds['menu-move'].play()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if options[i] != "donate": pygame.mixer.music.unpause()
|
if options[i] != "donate": pygame.mixer.music.unpause()
|
||||||
if event.key == pygame.K_UP and i > 0:
|
if event.key == pygame.K_UP and i > 0:
|
||||||
i = i - 1
|
i = i - 1
|
||||||
|
try:
|
||||||
|
sounds['menu-move'].play()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if options[i] != "donate": pygame.mixer.music.unpause()
|
if options[i] != "donate": pygame.mixer.music.unpause()
|
||||||
if event.key == pygame.K_RETURN:
|
if event.key == pygame.K_RETURN:
|
||||||
try:
|
try:
|
||||||
j = -1
|
j = -1
|
||||||
|
try:
|
||||||
|
sounds['menu-select'].play()
|
||||||
|
time.sleep(sounds['menu-select'].get_length())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
eval(options[i] + "()")
|
eval(options[i] + "()")
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
|
Loading…
Reference in New Issue
Block a user