From ec7e9d3461df2ec483f40eb6166cab3249e45952 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 10 Dec 2019 14:12:15 -0500 Subject: [PATCH 1/3] Improved learn sounds. Added optional menu-move and menu-select sounds. --- libstormgames.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/libstormgames.py b/libstormgames.py index 3483f20..752eca3 100755 --- a/libstormgames.py +++ b/libstormgames.py @@ -33,6 +33,18 @@ import time localConfig = 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): if writeGlobal == False: with open(gamePath, 'w') as configfile: @@ -187,12 +199,15 @@ def learn_sounds(sounds): if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: return "menu" if event.key == pygame.K_DOWN and i < len(soundFiles) - 1: + pygame.mixer.stop() i = i + 1 if event.key == pygame.K_UP and i > 0: + pygame.mixer.stop() i = i - 1 if event.key == pygame.K_RETURN: try: soundName = soundFiles[i][:-4] + pygame.mixer.stop() sounds[soundName].play() continue except: @@ -202,7 +217,7 @@ def learn_sounds(sounds): event = pygame.event.clear() time.sleep(0.001) -def game_menu(*options): +def game_menu(sounds, *options): loop = True if pygame.mixer.music.get_busy(): pygame.mixer.music.unpause() @@ -222,13 +237,26 @@ def game_menu(*options): if event.key == pygame.K_ESCAPE: exit_game() if event.key == pygame.K_DOWN and i < len(options) - 1: i = i + 1 + try: + sounds['menu-move'].play() + except: + pass if options[i] != "donate": pygame.mixer.music.unpause() if event.key == pygame.K_UP and i > 0: i = i - 1 + try: + sounds['menu-move'].play() + except: + pass if options[i] != "donate": pygame.mixer.music.unpause() if event.key == pygame.K_RETURN: try: j = -1 + try: + sounds['menu-select'].play() + time.sleep(sounds['menu-select'].get_length()) + except: + pass eval(options[i] + "()") continue except: From 48217dd63efea44513a55d4e267601c608c5ca8e Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 10 Dec 2019 18:26:57 -0500 Subject: [PATCH 2/3] Fixed an error in game configuration path. --- libstormgames.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstormgames.py b/libstormgames.py index 752eca3..fbe33d5 100755 --- a/libstormgames.py +++ b/libstormgames.py @@ -80,7 +80,7 @@ def initialize_gui(gameTitle): global globalPath global gamePath globalPath = BaseDirectory.xdg_config_home + "/storm-games" - gamePath = globalPath + "/" + str.lower(str.replace(gameTitle, " ", "-") + "config") + gamePath = globalPath + "/" + str.lower(str.replace(gameTitle, " ", "-") + "/config") globalPath = globalPath + "/config" if not os.path.exists(gamePath): os.makedirs(gamePath) # Seed the random generator to the clock From f2326c628c6eddff9f60ea8c0eeca6bbb93dae0a Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 10 Dec 2019 18:36:29 -0500 Subject: [PATCH 3/3] Another attempt at fixing configuration paths. --- libstormgames.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libstormgames.py b/libstormgames.py index fbe33d5..a8b54f2 100755 --- a/libstormgames.py +++ b/libstormgames.py @@ -47,17 +47,18 @@ class scoreboard(): def write_config(writeGlobal = False): if writeGlobal == False: - with open(gamePath, 'w') as configfile: + with open(gamePath + "config.ini", 'w') as configfile: localConfig.write(configfile) else: - with open(globalPath, 'w') as configfile: + with open(globalPath + "config.ini", 'w') as configfile: globalConfig.write(configfile) def read_config(section, value, readGlobal = False): if readGlobal == False: - with open(gamePath, 'r') as configfile: + with open(gamePath + "config.ini", 'r') as configfile: return localConfig.read(section, value) else: + with open(globalPath + "config.ini", 'r') as configfile: return globalConfig.read(section, value) def speak(text, interupt = True): @@ -80,8 +81,7 @@ def initialize_gui(gameTitle): global globalPath global gamePath globalPath = BaseDirectory.xdg_config_home + "/storm-games" - gamePath = globalPath + "/" + str.lower(str.replace(gameTitle, " ", "-") + "/config") - globalPath = globalPath + "/config" + gamePath = globalPath + "/" + str.lower(str.replace(gameTitle, " ", "-")) if not os.path.exists(gamePath): os.makedirs(gamePath) # Seed the random generator to the clock random.seed()