Exemplo n.º 1
0
    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))
Exemplo n.º 2
0
 def update_profile(self, event):
     self.games = config.get_games()
     self.game = self.games[self.profile.GetSelection()]
     try:
         self.steam_path.SetPath(config.steam_path)
         self.prof_name.SetValue(self.game.name)
         self.game_path.SetPath(self.game.mod_path)
         self.audio_path.SetPath(self.game.audio_dir)
         self.audio_path.SetInitialDirectory(os.path.abspath(self.game.audio_dir))
         self.game_rate.SetValue(self.game.audio_rate)
         self.relay_choice.SetStringSelection(self.game.relay_key)
         self.play_choice.SetStringSelection(self.game.play_key)
         self.aliases_box.SetValue(self.game.use_aliases)
     except (IndexError, NameError, TypeError):
         self.prof_name.Clear()
         self.game_path.SetPath("")
         self.audio_path.SetPath("")
         self.game_rate.Clear()
         self.relay_choice.Clear()
         self.play_choice.Clear()
Exemplo n.º 3
0
    def __init__(self, parent):
        super(MainPanel, self).__init__(parent)
        self.parent = parent
        self.games = config.get_games()
        self.game = None
        self.game_watcher = None
        while not self.games:
            error = wx.MessageDialog(parent=self,
                                     message="You have no games profiles set up. Replacing config with default.",
                                     caption="Info", style=wx.OK | wx.ICON_INFORMATION)
            error.ShowModal()
            error.Destroy()
            config.new()
            config.load()
            self.games = config.get_games()

        self.profile = wx.ComboBox(parent=self, choices=[game.name for game in self.games],
                                   style=wx.CB_READONLY)
        self.profile.SetSelection(0)

        self.track_list = ObjectListView(parent=self, style=wx.LC_REPORT | wx.BORDER_SUNKEN, sortable=True,
                                         useAlternateBackColors=False)
        self.track_list.SetEmptyListMsg("You currently do not have any sound files for this game.")
        self.track_list.SetColumns([
            ColumnDefn(title="#", fixedWidth=50, valueGetter="index", stringConverter="%i"),
            ColumnDefn(title="Title", width=250, valueGetter="name", minimumWidth=150, isSpaceFilling=True),
            ColumnDefn(title="Aliases", width=300, valueGetter="get_aliases", minimumWidth=200, isSpaceFilling=True),
            ColumnDefn(title="Bind", width=75, valueGetter="bind", minimumWidth=50, maximumWidth=120)
        ])
        self.track_list.rowFormatter = lambda x, y: x.SetTextColour(wx.RED) if y.get_aliases() == NO_ALIASES else None
        self.selected_track = None
        self.game_select(event=None)

        refresh_button = wx.Button(parent=self, label="Refresh tracks")
        self.start_stop_button = wx.Button(parent=self, label="Start")
        convert_button = wx.Button(parent=self, label="Audio converter")
        download_button = wx.Button(parent=self, label="Audio downloader")

        top_sizer = wx.BoxSizer(wx.VERTICAL)  # Root sizer
        profile_sizer = wx.BoxSizer(wx.VERTICAL)  # For the profile selection
        olv_sizer = wx.BoxSizer(wx.VERTICAL)  # For the ObjectListView
        button_sizer = wx.BoxSizer(wx.HORIZONTAL)  # Start/Stop and Refresh buttons

        profile_sizer.Add(self.profile, 0, wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ALIGN_TOP, 5)
        olv_sizer.Add(self.track_list, 1, wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ALIGN_TOP, 5)
        button_sizer.Add(self.start_stop_button, 0, wx.ALL | wx.ALIGN_LEFT, 5)
        button_sizer.Add(refresh_button, 0, wx.ALL | wx.ALIGN_LEFT, 5)
        button_sizer.Add(convert_button, 0, wx.ALL | wx.ALIGN_LEFT, 5)
        button_sizer.Add(download_button, 0, wx.ALL | wx.ALIGN_LEFT, 5)

        top_sizer.Add(profile_sizer, 0, wx.ALL | wx.EXPAND, 5)
        top_sizer.Add(olv_sizer, 1, wx.ALL | wx.EXPAND, 5)
        top_sizer.Add(button_sizer, 0, wx.ALL | wx.EXPAND, 5)
        top_sizer.SetSizeHints(self.parent)
        self.SetSizerAndFit(top_sizer)

        # Context menu
        self.context_menu = wx.Menu()
        set_aliases = self.context_menu.Append(wx.ID_ANY, "Set custom aliases")
        clear_aliases = self.context_menu.Append(wx.ID_ANY, "Clear custom aliases")
        set_bind = self.context_menu.Append(wx.ID_ANY, "Set bind")
        clear_bind = self.context_menu.Append(wx.ID_ANY, "Clear bind")
        clear_all = self.context_menu.Append(wx.ID_CLEAR, "Clear EVERYTHING (all tracks)")
        trim_file = self.context_menu.Append(wx.ID_CUT, "Trim audio file")

        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, handler=self.list_right_click, source=self.track_list)
        self.Bind(wx.EVT_MENU, handler=self.set_aliases, source=set_aliases)
        self.Bind(wx.EVT_MENU, handler=self.clear_aliases, source=clear_aliases)
        self.Bind(wx.EVT_MENU, handler=self.set_bind, source=set_bind)
        self.Bind(wx.EVT_MENU, handler=self.clear_bind, source=clear_bind)
        self.Bind(wx.EVT_MENU, handler=self.clear_all, source=clear_all)
        self.Bind(wx.EVT_MENU, handler=self.trim_file, source=trim_file)

        self.Bind(wx.EVT_COMBOBOX, handler=self.game_select, source=self.profile)
        self.Bind(wx.EVT_BUTTON, handler=self.refresh, source=refresh_button)
        self.Bind(wx.EVT_BUTTON, handler=self.start_stop, source=self.start_stop_button)
        self.Bind(wx.EVT_BUTTON, handler=self.convert, source=convert_button)
        self.Bind(wx.EVT_BUTTON, handler=self.download, source=download_button)

        # self.Bind(wx.EVT_SIZE, handler=self.on_size)
        self.Bind(wx.EVT_CLOSE, handler=self.on_exit)
Exemplo n.º 4
0
    def __init__(self, parent):
        super(SetupDialog, self).__init__(parent, title="pyjam Setup", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        self.steam_path = wx.DirPickerCtrl(self, name="Path to Steam")
        self.steam_path.SetInitialDirectory(get_steam_path())
        steam_path_text = wx.StaticText(self, label="Path to Steam (e.g. C:\\Program Files (x86)\\Steam)")

        self.games = config.get_games()
        self.profile = wx.ComboBox(self, choices=[game.name for game in self.games], style=wx.CB_READONLY)
        self.profile.SetSelection(0)
        self.game = self.games[self.profile.GetSelection()]

        separator = wx.StaticLine(self, style=wx.LI_HORIZONTAL, size=(self.GetSize()[0], 1))

        self.prof_name = wx.TextCtrl(self)
        prof_name_text = wx.StaticText(self, label="Profile/game name")

        self.game_path = wx.DirPickerCtrl(self, message="Path to game")
        self.game_path.SetInitialDirectory(get_steam_path())
        self.game_path.SetToolTip("The folder the game is located in. Include the mod folder. For example, "
                                  "/Steam/steamapps/common/Counter-Strike: Global Offensive/csgo")
        game_path_text = wx.StaticText(self, label="Game folder (include mod folder, e.g. games\\Team Fortress 2\\tf2)")

        self.audio_path = wx.DirPickerCtrl(self, message="Path to audio")
        self.audio_path.SetInitialDirectory(os.getcwd())
        self.audio_path.SetToolTip("The folder pyjam will load audio from.")
        audio_path_text = wx.StaticText(self, label="Audio folder for this game")

        self.game_rate = intctrl.IntCtrl(self)
        self.game_rate.SetToolTip("The sample rate mic audio is played at. Most games have this at 11025. "
                                  "Games like CS:GO or Dota 2, however, use 22050."
                                  "If audio sounds too slow or too fast, chances are you need to switch these values.")
        game_rate_text = wx.StaticText(self, label="Audio rate (usually 11025 or 22050)")

        self.relay_choice = wx.ComboBox(self, choices=jam.common.SOURCE_KEYS, style=wx.CB_READONLY)
        self.relay_choice.SetToolTip("The relay key is how pyjam will interact with the game. You only need "
                                     "to change this if you have an overlapping bind.")
        relay_text = wx.StaticText(self, label="Relay key (default is fine for most cases, ignore)")

        self.play_choice = wx.ComboBox(self, choices=jam.common.SOURCE_KEYS, style=wx.CB_READONLY)
        self.play_choice.SetToolTip("The key you will use to start/stop music.")
        play_text = wx.StaticText(self, label="Play audio key")

        self.aliases_box = wx.CheckBox(self, label="Enable aliases")
        self.aliases_box.SetToolTip("Whether or not to enable the usage of selecting songs with aliases (words) "
                                    "instead of indexes (numbers)")

        save_button = wx.Button(self, wx.ID_SAVE, label="Save Game")
        new_button = wx.Button(self, wx.ID_NEW, label="New Game")
        remove_button = wx.Button(self, wx.ID_REMOVE, label="Remove Game")

        # Sizer stuff
        top_sizer = wx.BoxSizer(wx.VERTICAL)
        profile_sizer = wx.BoxSizer(wx.VERTICAL)
        button_sizer = wx.BoxSizer(wx.HORIZONTAL)

        top_sizer.Add(profile_sizer, 1, wx.ALL | wx.EXPAND | wx.ALIGN_TOP, 5)
        top_sizer.Add(button_sizer, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)
        profile_sizer.Add(steam_path_text, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 3)
        profile_sizer.Add(self.steam_path, 0, wx.ALL ^ wx.LEFT ^ wx.TOP | wx.ALIGN_LEFT | wx.EXPAND, 5)
        profile_sizer.Add(self.profile, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 5)
        profile_sizer.Add(separator, 0, wx.TOP | wx.BOTTOM | wx.ALIGN_LEFT, 3)
        profile_sizer.Add(prof_name_text, 0, wx.ALL ^ wx.BOTTOM ^ wx.LEFT | wx.ALIGN_LEFT, 3)
        profile_sizer.Add(self.prof_name, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT | wx.EXPAND, 5)
        profile_sizer.Add(game_path_text, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 3)
        profile_sizer.Add(self.game_path, 0, wx.ALL ^ wx.LEFT ^ wx.TOP | wx.ALIGN_LEFT | wx.EXPAND, 5)
        profile_sizer.Add(audio_path_text, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 3)
        profile_sizer.Add(self.audio_path, 0, wx.ALL ^ wx.LEFT ^ wx.TOP | wx.ALIGN_LEFT | wx.EXPAND, 5)
        profile_sizer.Add(game_rate_text, 0, wx.ALL ^ wx.BOTTOM ^ wx.LEFT | wx.ALIGN_LEFT, 3)
        profile_sizer.Add(self.game_rate, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 5)
        profile_sizer.Add(relay_text, 0, wx.ALL ^ wx.BOTTOM ^ wx.LEFT | wx.ALIGN_LEFT, 3)
        profile_sizer.Add(self.relay_choice, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 5)
        profile_sizer.Add(play_text, 0, wx.ALL ^ wx.BOTTOM ^ wx.LEFT | wx.ALIGN_LEFT, 3)
        profile_sizer.Add(self.play_choice, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 5)
        profile_sizer.Add(self.aliases_box, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 7)
        button_sizer.Add(save_button, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        button_sizer.Add(new_button, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        button_sizer.Add(remove_button, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)

        # self.Bind doesn't seem to work for wx.EVT_KEY_DOWN or wx.EVT_CHAR. Very likely intentional.
        # http://wiki.wxpython.org/self.Bind%20vs.%20self.button.Bind.
        self.relay_choice.Bind(wx.EVT_KEY_DOWN, handler=jam.common.key_choice_override, source=self.relay_choice)
        self.play_choice.Bind(wx.EVT_KEY_DOWN, handler=jam.common.key_choice_override, source=self.play_choice)
        self.Bind(wx.EVT_COMBOBOX, handler=self.update_profile, source=self.profile)
        self.Bind(wx.EVT_BUTTON, handler=self.save, id=wx.ID_SAVE)
        self.Bind(wx.EVT_BUTTON, handler=self.new, id=wx.ID_NEW)
        self.Bind(wx.EVT_BUTTON, handler=self.remove, id=wx.ID_REMOVE)

        self.SetSizerAndFit(top_sizer)
        self.update_profile(event=None)
        self.Center()
        self.ShowModal()
Exemplo n.º 5
0
 def settings(self, event):
     SetupDialog(self)
     self.games = config.get_games()
     self.profile.Set([game.name for game in self.games])
     self.profile.SetSelection(0)
     self.game_select(event=None)