diff --git a/data/environments/default/amb.ogg b/data/environments/default/amb.ogg new file mode 100644 index 0000000..8cc5610 Binary files /dev/null and b/data/environments/default/amb.ogg differ diff --git a/data/environments/default/fall1.ogg b/data/environments/default/fall1.ogg new file mode 100644 index 0000000..b1df8b0 Binary files /dev/null and b/data/environments/default/fall1.ogg differ diff --git a/data/environments/default/step1.ogg b/data/environments/default/step1.ogg new file mode 100644 index 0000000..a186fab Binary files /dev/null and b/data/environments/default/step1.ogg differ diff --git a/data/environments/default/step10.ogg b/data/environments/default/step10.ogg new file mode 100644 index 0000000..d0aa985 Binary files /dev/null and b/data/environments/default/step10.ogg differ diff --git a/data/environments/default/step11.ogg b/data/environments/default/step11.ogg new file mode 100644 index 0000000..9dad9e1 Binary files /dev/null and b/data/environments/default/step11.ogg differ diff --git a/data/environments/default/step12.ogg b/data/environments/default/step12.ogg new file mode 100644 index 0000000..7693839 Binary files /dev/null and b/data/environments/default/step12.ogg differ diff --git a/data/environments/default/step13.ogg b/data/environments/default/step13.ogg new file mode 100644 index 0000000..a500c9a Binary files /dev/null and b/data/environments/default/step13.ogg differ diff --git a/data/environments/default/step14.ogg b/data/environments/default/step14.ogg new file mode 100644 index 0000000..dea997d Binary files /dev/null and b/data/environments/default/step14.ogg differ diff --git a/data/environments/default/step15.ogg b/data/environments/default/step15.ogg new file mode 100644 index 0000000..7842e0f Binary files /dev/null and b/data/environments/default/step15.ogg differ diff --git a/data/environments/default/step16.ogg b/data/environments/default/step16.ogg new file mode 100644 index 0000000..b7f38a3 Binary files /dev/null and b/data/environments/default/step16.ogg differ diff --git a/data/environments/default/step17.ogg b/data/environments/default/step17.ogg new file mode 100644 index 0000000..9187852 Binary files /dev/null and b/data/environments/default/step17.ogg differ diff --git a/data/environments/default/step18.ogg b/data/environments/default/step18.ogg new file mode 100644 index 0000000..2b73d5d Binary files /dev/null and b/data/environments/default/step18.ogg differ diff --git a/data/environments/default/step2.ogg b/data/environments/default/step2.ogg new file mode 100644 index 0000000..c2bbf4d Binary files /dev/null and b/data/environments/default/step2.ogg differ diff --git a/data/environments/default/step3.ogg b/data/environments/default/step3.ogg new file mode 100644 index 0000000..d3af43c Binary files /dev/null and b/data/environments/default/step3.ogg differ diff --git a/data/environments/default/step4.ogg b/data/environments/default/step4.ogg new file mode 100644 index 0000000..d7f7eac Binary files /dev/null and b/data/environments/default/step4.ogg differ diff --git a/data/environments/default/step5.ogg b/data/environments/default/step5.ogg new file mode 100644 index 0000000..78c27ca Binary files /dev/null and b/data/environments/default/step5.ogg differ diff --git a/data/environments/default/step6.ogg b/data/environments/default/step6.ogg new file mode 100644 index 0000000..e058336 Binary files /dev/null and b/data/environments/default/step6.ogg differ diff --git a/data/environments/default/step7.ogg b/data/environments/default/step7.ogg new file mode 100644 index 0000000..49bc075 Binary files /dev/null and b/data/environments/default/step7.ogg differ diff --git a/data/environments/default/step8.ogg b/data/environments/default/step8.ogg new file mode 100644 index 0000000..4145748 Binary files /dev/null and b/data/environments/default/step8.ogg differ diff --git a/data/environments/default/step9.ogg b/data/environments/default/step9.ogg new file mode 100644 index 0000000..82d0f06 Binary files /dev/null and b/data/environments/default/step9.ogg differ diff --git a/data/environments/test/fall1.ogg b/data/environments/test/fall1.ogg new file mode 100644 index 0000000..be7560b Binary files /dev/null and b/data/environments/test/fall1.ogg differ diff --git a/data/environments/test/step1.ogg b/data/environments/test/step1.ogg new file mode 100644 index 0000000..1c7a530 Binary files /dev/null and b/data/environments/test/step1.ogg differ diff --git a/enemy.py b/enemy.py index 12138ba..a322a28 100644 --- a/enemy.py +++ b/enemy.py @@ -89,13 +89,30 @@ def step(self): return self.y -= 1 s = bgtsound.sound() - num = 0 - while True: - num = random.randint(1, 18) - if num != self.lastStepNum: - break - # end while - s.load(globalVars.appMain.sounds["s_lf%d.ogg" % num]) + # Use environment-based footsteps + if hasattr(globalVars.appMain, 'environmentSteps') and len(globalVars.appMain.environmentSteps) > 0: + num = 0 + # If there's only 1 sound, just use it (avoid infinite loop) + if len(globalVars.appMain.environmentSteps) == 1: + num = 0 + else: + while True: + num = random.randint(0, len(globalVars.appMain.environmentSteps) - 1) + if num != self.lastStepNum: + break + # end while + s.load(globalVars.appMain.environmentSteps[num]) + self.lastStepNum = num + else: + # Fallback to old method + num = 0 + while True: + num = random.randint(1, 18) + if num != self.lastStepNum: + break + # end while + s.load(globalVars.appMain.sounds["s_lf%d.ogg" % num]) + self.lastStepNum = num s.pan = self.field.getPan(self.x) s.volume = self.field.getVolume(self.y) s.pitch = random.randint(90, 110) @@ -142,7 +159,14 @@ def playScream(self): def playBodyfall(self): """Makes a bodyfall sound for this enemy. Internally called.""" self.bodyfall = bgtsound.sound() - self.bodyfall.load(globalVars.appMain.sounds["dead.ogg"]) + # Use environment-based body falls + if hasattr(globalVars.appMain, 'environmentFalls') and len(globalVars.appMain.environmentFalls) > 0: + # Randomly select from available body fall sounds + fallIndex = random.randint(0, len(globalVars.appMain.environmentFalls) - 1) + self.bodyfall.load(globalVars.appMain.environmentFalls[fallIndex]) + else: + # Fallback to old method + self.bodyfall.load(globalVars.appMain.sounds["dead.ogg"]) self.bodyfall.pitch = random.randint(70, 130) self.bodyfall.pan = self.field.getPan(self.x) self.bodyfall.volume = self.field.getVolume(self.y) diff --git a/gameOptions.py b/gameOptions.py index ae5f2f2..30b268f 100644 --- a/gameOptions.py +++ b/gameOptions.py @@ -11,6 +11,8 @@ class GameOptions: def __init__(self): self.BGMVOLUME_NEGATIVE_BOUNDARY = -30 self.BGMVOLUME_POSITIVE_BOUNDARY = 0 + self.AMBIANCEVOLUME_NEGATIVE_BOUNDARY = -30 + self.AMBIANCEVOLUME_POSITIVE_BOUNDARY = 0 self.LEFTPANNINGLIMIT_NEGATIVE_BOUNDARY = -100 self.LEFTPANNINGLIMIT_POSITIVE_BOUNDARY = -20 self.RIGHTPANNINGLIMIT_NEGATIVE_BOUNDARY = 20 @@ -29,9 +31,11 @@ def initialize(self, importer): def setDefault(self): self.bgmVolume = -10 + self.ambianceVolume = -10 self.leftPanningLimit = -100 self.rightPanningLimit = 100 self.itemVoice = "chris" + self.environment = "default" self.language = locale.getdefaultlocale()[0] if self.language is None: self.language = "en_US" # OSX may fail to auto language detect when frozen @@ -40,9 +44,11 @@ def setDefault(self): def copyFrom(self, importer): self.bgmVolume = importer.bgmVolume + self.ambianceVolume = importer.ambianceVolume self.leftPanningLimit = importer.leftPanningLimit self.rightPanningLimit = importer.rightPanningLimit self.itemVoice = importer.itemVoice + self.environment = importer.environment self.language = importer.language def load(self, filename): @@ -59,21 +65,27 @@ def load(self, filename): self.bgmVolume = self.BGMVOLUME_NEGATIVE_BOUNDARY if self.bgmVolume > self.BGMVOLUME_POSITIVE_BOUNDARY: self.bgmVolume = self.BGMVOLUME_POSITIVE_BOUNDARY - self.leftPanningLimit = int(values[1]) + self.ambianceVolume = int(values[1]) if numValues > 5 else -10 + if self.ambianceVolume < self.AMBIANCEVOLUME_NEGATIVE_BOUNDARY: + self.ambianceVolume = self.AMBIANCEVOLUME_NEGATIVE_BOUNDARY + if self.ambianceVolume > self.AMBIANCEVOLUME_POSITIVE_BOUNDARY: + self.ambianceVolume = self.AMBIANCEVOLUME_POSITIVE_BOUNDARY + self.leftPanningLimit = int(values[2] if numValues > 5 else values[1]) if self.leftPanningLimit < self.LEFTPANNINGLIMIT_NEGATIVE_BOUNDARY: self.leftPanningLimit = self.LEFTPANNINGLIMIT_NEGATIVE_BOUNDARY if self.leftPanningLimit > self.LEFTPANNINGLIMIT_POSITIVE_BOUNDARY: self.leftPanningLimit = self.LEFTPANNINGLIMIT_POSITIVE_BOUNDARY - self.rightPanningLimit = int(values[2]) + self.rightPanningLimit = int(values[3] if numValues > 5 else values[2]) if self.rightPanningLimit > self.RIGHTPANNINGLIMIT_POSITIVE_BOUNDARY: self.rightPanningLimit = self.RIGHTPANNINGLIMIT_POSITIVE_BOUNDARY if self.rightPanningLimit < self.RIGHTPANNINGLIMIT_NEGATIVE_BOUNDARY: self.rightPanningLimit = self.RIGHTPANNINGLIMIT_NEGATIVE_BOUNDARY - self.itemVoice = values[3] - self.language = values[4] if numValues > 4 else locale.getdefaultlocale()[0] + self.itemVoice = values[4] if numValues > 5 else values[3] + self.environment = values[5] if numValues > 5 else "default" + self.language = values[6] if numValues > 6 else (values[4] if numValues > 4 else locale.getdefaultlocale()[0]) return True def save(self, filename): - s = "%d#%d#%d#%s#%s" % (self.bgmVolume, self.leftPanningLimit, self.rightPanningLimit, self.itemVoice, self.language) + s = "%d#%d#%d#%d#%s#%s#%s" % (self.bgmVolume, self.ambianceVolume, self.leftPanningLimit, self.rightPanningLimit, self.itemVoice, self.environment, self.language) with open(filename, mode="w") as f: f.write(s) diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index c022613..fcaf8b5 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -420,26 +420,38 @@ msgid "" "right arrows to change values, enter to save or escape to discard changes" msgstr "" -#: ssAppMain.py:480 +#: ssAppMain.py:551 msgid "Background music volume" msgstr "" -#: ssAppMain.py:481 +#: ssAppMain.py:552 +msgid "Ambiance volume" +msgstr "" + +#: ssAppMain.py:553 msgid "Left panning limit" msgstr "" -#: ssAppMain.py:482 +#: ssAppMain.py:554 msgid "Right panning limit." msgstr "" -#: ssAppMain.py:483 +#: ssAppMain.py:555 msgid "Item announcement voice" msgstr "" -#: ssAppMain.py:484 +#: ssAppMain.py:556 +msgid "Environment" +msgstr "" + +#: ssAppMain.py:557 msgid "Language (restart to apply)" msgstr "" +#: ssAppMain.py:681 +msgid "No environments found" +msgstr "" + #: ssAppMain.py:498 msgid "Changes discarded." msgstr "" diff --git a/locale/ja_JP/LC_MESSAGES/messages.po b/locale/ja_JP/LC_MESSAGES/messages.po index b9e2d6b..f8d8e33 100644 --- a/locale/ja_JP/LC_MESSAGES/messages.po +++ b/locale/ja_JP/LC_MESSAGES/messages.po @@ -466,26 +466,38 @@ msgstr "" "設定メニューです。上下の矢印キーで設定項目を移動し、左右矢印で値を変更しま" "す。エンターキーで設定を保存し、エスケープキーで変更を破棄します。" -#: ssAppMain.py:480 +#: ssAppMain.py:551 msgid "Background music volume" msgstr "BGMの音量" -#: ssAppMain.py:481 +#: ssAppMain.py:552 +msgid "Ambiance volume" +msgstr "環境音ボリューム" + +#: ssAppMain.py:553 msgid "Left panning limit" msgstr "左側のパンニング・リミット" -#: ssAppMain.py:482 +#: ssAppMain.py:554 msgid "Right panning limit." msgstr "右側のパンニング・リミット" -#: ssAppMain.py:483 +#: ssAppMain.py:555 msgid "Item announcement voice" msgstr "アイテム・アナウンスの声" -#: ssAppMain.py:484 +#: ssAppMain.py:556 +msgid "Environment" +msgstr "環境" + +#: ssAppMain.py:557 msgid "Language (restart to apply)" msgstr "言語(再起動後に適用)" +#: ssAppMain.py:681 +msgid "No environments found" +msgstr "環境が見つかりません" + #: ssAppMain.py:498 msgid "Changes discarded." msgstr "変更を破棄しました。" diff --git a/locale/messages.po b/locale/messages.po index b5513be..cf36e76 100644 --- a/locale/messages.po +++ b/locale/messages.po @@ -420,26 +420,38 @@ msgid "" "right arrows to change values, enter to save or escape to discard changes" msgstr "" -#: ssAppMain.py:480 +#: ssAppMain.py:551 msgid "Background music volume" msgstr "" -#: ssAppMain.py:481 +#: ssAppMain.py:552 +msgid "Ambiance volume" +msgstr "" + +#: ssAppMain.py:553 msgid "Left panning limit" msgstr "" -#: ssAppMain.py:482 +#: ssAppMain.py:554 msgid "Right panning limit." msgstr "" -#: ssAppMain.py:483 +#: ssAppMain.py:555 msgid "Item announcement voice" msgstr "" -#: ssAppMain.py:484 +#: ssAppMain.py:556 +msgid "Environment" +msgstr "" + +#: ssAppMain.py:557 msgid "Language (restart to apply)" msgstr "" +#: ssAppMain.py:681 +msgid "No environments found" +msgstr "" + #: ssAppMain.py:498 msgid "Changes discarded." msgstr "" diff --git a/locale/tr_TR/LC_MESSAGES/messages.po b/locale/tr_TR/LC_MESSAGES/messages.po index 2c2c384..a58967a 100644 --- a/locale/tr_TR/LC_MESSAGES/messages.po +++ b/locale/tr_TR/LC_MESSAGES/messages.po @@ -455,26 +455,38 @@ msgstr "" "değiştirmek için sağ sol okları kullanın, ayarları kaydetmek için enter'ı, " "iptal etmek için escape'i kullanın" -#: ssAppMain.py:480 +#: ssAppMain.py:551 msgid "Background music volume" msgstr "Müzik seviyesi" -#: ssAppMain.py:481 +#: ssAppMain.py:552 +msgid "Ambiance volume" +msgstr "Ortam ses seviyesi" + +#: ssAppMain.py:553 msgid "Left panning limit" msgstr "Soldaki ses sınırı" -#: ssAppMain.py:482 +#: ssAppMain.py:554 msgid "Right panning limit." msgstr "Sağdaki ses sınırı." -#: ssAppMain.py:483 +#: ssAppMain.py:555 msgid "Item announcement voice" msgstr "Bonus duyuru sesi" -#: ssAppMain.py:484 +#: ssAppMain.py:556 +msgid "Environment" +msgstr "Ortam" + +#: ssAppMain.py:557 msgid "Language (restart to apply)" msgstr "Dil (değişikliği uygulamak için oyunu yeniden başlatın)" +#: ssAppMain.py:681 +msgid "No environments found" +msgstr "Ortam bulunamadı" + #: ssAppMain.py:498 msgid "Changes discarded." msgstr "Değişiklikler iptal edildi." diff --git a/locale/v_VN/LC_MESSAGES/messages.po b/locale/v_VN/LC_MESSAGES/messages.po index 2da2348..644aeeb 100644 --- a/locale/v_VN/LC_MESSAGES/messages.po +++ b/locale/v_VN/LC_MESSAGES/messages.po @@ -461,28 +461,40 @@ msgstr "" "trái và phải để thay đổi giá trị của cài đặt đó, Enter để lưu hoặc escape để " "hủy thay đổi" -#: ssAppMain.py:480 +#: ssAppMain.py:551 msgid "Background music volume" msgstr "" "Âm lượng nhạc nền, bấm mũi tên trái và phải để chỉnh Âm lượng nhạc nền. Bấm " "mũi tên phải là tăng, mũi tên trái là dảm" -#: ssAppMain.py:481 +#: ssAppMain.py:552 +msgid "Ambiance volume" +msgstr "Âm lượng môi trường xung quanh, bấm mũi tên trái và phải để chỉnh" + +#: ssAppMain.py:553 msgid "Left panning limit" msgstr "Bên trái, bấm mũi tên phải để đưa nó qua phải và nghe âm thanh" -#: ssAppMain.py:482 +#: ssAppMain.py:554 msgid "Right panning limit." msgstr "Bên phải, bấm mũi tên trái để đưa nó qua trái và nghe âm thanh" -#: ssAppMain.py:483 +#: ssAppMain.py:555 msgid "Item announcement voice" msgstr "Giọng nói thông báo vật phẩm, bấm mũi tên trái và phải để trọn" -#: ssAppMain.py:484 +#: ssAppMain.py:556 +msgid "Environment" +msgstr "Môi trường, bấm mũi tên trái và phải để trọn" + +#: ssAppMain.py:557 msgid "Language (restart to apply)" msgstr "Ngôn ngữ, Bấm mũi tên trái phải để trọn(khởi động lại để áp dụng)" +#: ssAppMain.py:681 +msgid "No environments found" +msgstr "Không tìm thấy môi trường" + #: ssAppMain.py:498 msgid "Changes discarded." msgstr "Các cài đặt đã bị hủy." diff --git a/ssAppMain.py b/ssAppMain.py index 1994a9e..34153e1 100644 --- a/ssAppMain.py +++ b/ssAppMain.py @@ -75,11 +75,22 @@ def initialize(self): self.options.initialize(OPTIONS_FILENAME) self.itemVoices = self.getItemVoicesList() self.locales = self.getLocalesList() + self.environments = self.getEnvironmentsList() + # Validate environment: if not set, deleted, or no environments exist, default appropriately + if len(self.environments) > 0: + # If environment is not set or doesn't exist, use first alphabetically + if not hasattr(self.options, 'environment') or self.options.environment not in self.environments: + self.options.environment = self.environments[0] + else: + # No environments found, set to None to trigger fallback + self.options.environment = None self.initTranslation() self.music = bgtsound.sound() self.musicData = sound_lib.sample.Sample("data/sounds/stream//bg.ogg") self.music.load(self.musicData) self.music.volume = self.options.bgmVolume + self.ambiance = None + self.ambianceData = None self.numScreams = len(glob.glob("data/sounds/scream*.ogg")) self.collectionStorage = collection.CollectionStorage() self.collectionStorage.initialize(self.numScreams, COLLECTION_DATA_FILENAME) @@ -128,14 +139,78 @@ def getLocalesList(self): lst.append(os.path.basename(elem)) return lst + def getEnvironmentsList(self): + """ + Searches for available environments. Returns the list of found environments sorted alphabetically. + + :rtype: list + """ + lst = [] + for elem in glob.glob("data/environments/*"): + if os.path.isdir(elem): + lst.append(os.path.basename(elem)) + lst.sort() # Sort alphabetically + return lst + def loadSounds(self): """Preloads ingame sounds into memory. This is for enhancing performance while playing the game. """ self.sounds = {} files = glob.glob("data/sounds/*.ogg") for elem in files: self.sounds[os.path.basename(elem)] = sound_lib.sample.Sample(elem) + # Load environment sounds + self.loadEnvironmentSounds() # end loadSounds + def loadEnvironmentSounds(self): + """Loads footsteps and body fall sounds from the selected environment.""" + # Free old environment sounds if they exist (avoid memory leak when switching) + if hasattr(self, 'environmentSteps'): + for sample in self.environmentSteps: + # Only free if it's not from the main sounds dict (those are managed separately) + if sample not in self.sounds.values(): + sample.free() + if hasattr(self, 'environmentFalls'): + for sample in self.environmentFalls: + # Only free if it's not from the main sounds dict (those are managed separately) + if sample not in self.sounds.values(): + sample.free() + + # Initialize empty lists + self.environmentSteps = [] + self.environmentFalls = [] + + # Check if environment is set and valid + env = self.options.environment if hasattr(self.options, 'environment') and self.options.environment else None + + if env is not None: + env_path = "data/environments/%s" % env + if os.path.isdir(env_path): + # Try to load footsteps from environment + step_files = glob.glob(env_path + "/step*.ogg") + if len(step_files) > 0: + for elem in step_files: + self.environmentSteps.append(sound_lib.sample.Sample(elem)) + + # Try to load body falls from environment + fall_files = glob.glob(env_path + "/fall*.ogg") + if len(fall_files) > 0: + for elem in fall_files: + self.environmentFalls.append(sound_lib.sample.Sample(elem)) + + # Fallback to old sounds if no environment or no sounds loaded + if len(self.environmentSteps) == 0: + # Fallback to s_lf*.ogg from sounds folder + for i in range(1, 19): + if "s_lf%d.ogg" % i in self.sounds: + self.environmentSteps.append(self.sounds["s_lf%d.ogg" % i]) + + if len(self.environmentFalls) == 0: + # Fallback to dead.ogg from sounds folder + if "dead.ogg" in self.sounds: + self.environmentFalls.append(self.sounds["dead.ogg"]) + # end loadEnvironmentSounds + def getNumScreams(self): """ Returns the number of auto-detected screams. @@ -144,6 +219,31 @@ def getNumScreams(self): """ return self.numScreams + def startAmbiance(self): + """Starts playing the ambiance sound if available in the current environment.""" + env = self.options.environment if hasattr(self.options, 'environment') else "default" + env_path = "data/environments/%s" % env + if not os.path.isdir(env_path): + env_path = "data/environments/default" + amb_file = env_path + "/amb.ogg" + if os.path.isfile(amb_file): + self.ambianceData = sound_lib.sample.Sample(amb_file) + self.ambiance = bgtsound.sound() + self.ambiance.load(self.ambianceData) + self.ambiance.volume = self.options.ambianceVolume if hasattr(self.options, 'ambianceVolume') else -10 + self.ambiance.play_looped() + # end startAmbiance + + def stopAmbiance(self): + """Stops the ambiance sound if it's playing.""" + if self.ambiance is not None: + self.ambiance.stop() + self.ambiance = None + if self.ambianceData is not None: + self.ambianceData.free() + self.ambianceData = None + # end stopAmbiance + def intro(self): """Plays the intro sound. It blocks when the sound is playing, then starts the game music. """ introsound = bgtsound.sound() @@ -478,9 +578,11 @@ def optionsDialog(self): m = self.createMenu( _("Options Menu, use your up and down arrows to choose an option, left and right arrows to change values, enter to save or escape to discard changes")) m.append(_("Background music volume")) + m.append(_("Ambiance volume")) m.append(_("Left panning limit")) m.append(_("Right panning limit.")) m.append(_("Item announcement voice")) + m.append(_("Environment")) m.append(_("Language (restart to apply)")) m.open() while(True): @@ -525,7 +627,21 @@ def optionChange(self, cursor, direction): self.say("%d" % (abs(-30 - self.options.bgmVolume) * 0.5)) return # end bgm volume - if cursor == 1: # left panning limit + if cursor == 1: # ambiance volume + if direction == 1 and self.options.ambianceVolume == self.options.AMBIANCEVOLUME_POSITIVE_BOUNDARY: + return + if direction == -1 and self.options.ambianceVolume == self.options.AMBIANCEVOLUME_NEGATIVE_BOUNDARY: + return + if direction == 1: + self.options.ambianceVolume += 2 + if direction == -1: + self.options.ambianceVolume -= 2 + if self.ambiance is not None: + self.ambiance.volume = self.options.ambianceVolume + self.say("%d" % (abs(-30 - self.options.ambianceVolume) * 0.5)) + return + # end ambiance volume + if cursor == 2: # left panning limit if direction == 1 and self.options.leftPanningLimit == self.options.LEFTPANNINGLIMIT_POSITIVE_BOUNDARY: return if direction == -1 and self.options.leftPanningLimit == self.options.LEFTPANNINGLIMIT_NEGATIVE_BOUNDARY: @@ -540,7 +656,7 @@ def optionChange(self, cursor, direction): s.play() return # end left panning limit - if cursor == 2: # right panning limit + if cursor == 3: # right panning limit if direction == 1 and self.options.rightPanningLimit == self.options.RIGHTPANNINGLIMIT_POSITIVE_BOUNDARY: return if direction == -1 and self.options.rightPanningLimit == self.options.RIGHTPANNINGLIMIT_NEGATIVE_BOUNDARY: @@ -554,8 +670,8 @@ def optionChange(self, cursor, direction): s.pan = self.options.rightPanningLimit s.play() return - # end left panning limit - if cursor == 3: # item voice + # end right panning limit + if cursor == 4: # item voice c = 0 for n in self.itemVoices: # which are we selecting? if self.options.itemVoice == n: @@ -576,7 +692,38 @@ def optionChange(self, cursor, direction): self.options.itemVoice = self.itemVoices[c] return # end item voices - if cursor == 4: # language + if cursor == 5: # environment + # Check if there are any environments available + if len(self.environments) == 0: + self.say(_("No environments found")) + return + c = 0 + for n in self.environments: # which are we selecting? + if self.options.environment == n: + break + c += 1 + # detected the current option + if direction == 1 and c == len(self.environments) - 1: + return # clipping + if direction == -1 and c == 0: + return # clipping + c += direction + self.say(self.environments[c]) + self.options.environment = self.environments[c] + # Reload environment sounds immediately + self.loadEnvironmentSounds() + # Play a test footstep sound + if len(self.environmentSteps) > 0: + testSound = bgtsound.sound() + testSound.load(self.environmentSteps[0]) + testSound.play() + # Restart ambiance if it was playing + if self.ambiance is not None and self.ambiance.playing: + self.stopAmbiance() + self.startAmbiance() + return + # end environment + if cursor == 6: # language c = 0 for n in self.locales: # which are we selecting? if n == self.options.language: @@ -591,7 +738,7 @@ def optionChange(self, cursor, direction): self.say(self.locales[c]) self.options.language = self.locales[c] return - # end item voices + # end language # end optionChange @@ -602,6 +749,7 @@ def gamePlay(self, mode): :rtype: gameResult.GameResult """ self.say(_("%(playmode)s, high score %(highscore)s, start!") % {"playmode": mode, "highscore": self.statsStorage.get("hs_" + mode)}) + self.startAmbiance() field = gameField.GameField() if random.randint(0, 4999) == 1: self.resetMusicPitch(200) @@ -616,6 +764,7 @@ def gamePlay(self, mode): result = gameResult.GameResult() result.initialize(field) result.aborted = True + self.stopAmbiance() return result # end abort if self.keyPressed(window.K_TAB): @@ -623,6 +772,7 @@ def gamePlay(self, mode): if field.frameUpdate() is False: break # end while + self.stopAmbiance() field.clear() self.wait(2000) s = bgtsound.sound()