Example #1
0
    def new(self):
        """Create a new config file.

        Returns:
            None

        """
        steam = get_steam_path()
        csgo_path = get_path(steam, 'steamapps/common/Counter-Strike Global Offensive/csgo')
        css_path = get_path(steam, 'steamapps/common/Counter-Strike Source/css')
        default = {'games':
                   [{'audio_dir': 'audio/csgo', 'use_aliases': True, 'audio_rate': 22050,
                     'name': 'Counter-Strike: Global Offensive',
                     'mod_path': csgo_path if steam != os.curdir else os.curdir,
                     'play_key': 'F8', 'relay_key': '='},
                    {'audio_dir': 'audio/css', 'use_aliases': True, 'audio_rate': 11025,
                     'name': 'Counter-Strike: Source',
                     'mod_path': css_path if steam != os.curdir else os.curdir,
                     'play_key': 'F8', 'relay_key': '='}],
                   'steam_path': steam}

        with open(self.config_file, 'w') as f:
            json.dump(default, f, indent=4, sort_keys=True)
Example #2
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()