def save(self, event): # type: (int) -> None config.steam_path = self.steam_path.GetPath() self.profile.SetString(self.profile.GetSelection(), self.prof_name.GetValue()) self.game.name = self.prof_name.GetValue() self.game.mod_path = self.game_path.GetPath() self.game.audio_dir = self.audio_path.GetPath() self.game.audio_rate = self.game_rate.GetValue() self.game.relay_key = self.relay_choice.GetStringSelection() self.game.play_key = self.play_choice.GetStringSelection() self.game.use_aliases = self.aliases_box.IsChecked() config.set_games(self.games) config.save() self.update_profile(event=None) if not os.path.exists(self.audio_path.GetPath()): os.makedirs(self.audio_path.GetPath())
def new(self, event): # type: (int) -> None new_profile = wx.TextEntryDialog(parent=self, message="Enter the name of your new game.", caption="pyjam") if new_profile.ShowModal() != wx.ID_OK: new_profile.Destroy() return name = new_profile.GetValue() new_profile.Destroy() self.profile.Append(name) self.games.append(Game(name=name)) config.set_games(self.games) config.save() self.profile.SetSelection(self.profile.GetCount() - 1) self.update_profile(event=None) logger.info("New game created: {name}".format(name=name))
def remove(self, event): if len(self.games) <= 1: message = wx.MessageDialog(parent=self, message="You can't remove your only game!", style=wx.OK | wx.ICON_EXCLAMATION) message.ShowModal() message.Destroy() return False name = self.game.name self.games.pop(self.profile.GetSelection()) config.set_games(self.games) config.save() self.games = config.get_games() self.profile.Set([game.name for game in self.games]) self.profile.SetSelection(0) self.update_profile(event=None) logger.info("Game removed: {name}".format(name=name))