示例#1
0
 def add_manually(self, *args):
     game = Game(self.view.selected_game)
     add_game_dialog = AddGameDialog(self.window, game)
     add_game_dialog.run()
     if add_game_dialog.saved:
         self.view.set_installed(game)
         self.sidebar_treeview.update()
示例#2
0
 def run_no_installer_dialog(self):
     """Open dialog for 'no script available' situation."""
     dlg = NoInstallerDialog(self)
     if dlg.result == dlg.MANUAL_CONF:
         game = Game(self.game_ref)
         game_dialog = AddGameDialog(self, game)
         game_dialog.run()
         if game_dialog.saved:
             self.notify_install_success()
     elif dlg.result == dlg.NEW_INSTALLER:
         installer_url = settings.SITE_URL + "games/%s/" % self.game_ref
         webbrowser.open(installer_url)
示例#3
0
    def run_no_installer_dialog(self):
        """Open dialog for 'no script available' situation."""
        dlg = NoInstallerDialog(self)
        if dlg.result == dlg.MANUAL_CONF:
            game_data = pga.get_game_by_field(self.game_slug, 'slug')

            if game_data and 'slug' in game_data:
                # Game data already exist locally.
                game = Game(game_data['id'])
            else:
                # Try to load game data from remote.
                games = api.get_games([self.game_slug])

                if games and len(games) >= 1:
                    remote_game = games[0]
                    game_data = {
                        'name': remote_game['name'],
                        'slug': remote_game['slug'],
                        'year': remote_game['year'],
                        'updated': remote_game['updated'],
                        'steamid': remote_game['steamid']
                    }
                    game = Game(pga.add_game(**game_data))
                else:
                    game = None

            AddGameDialog(
                self.parent,
                game=game,
                callback=lambda: self.notify_install_success(game_data['id']))
        elif dlg.result == dlg.NEW_INSTALLER:
            webbrowser.open(settings.GAME_URL % self.game_slug)
示例#4
0
 def on_add_game_button_clicked(self, *_args):
     """Add a new game manually with the AddGameDialog."""
     dialog = AddGameDialog(
         self,
         runner=self.selected_runner,
         callback=lambda: self.add_game_to_view(dialog.game.id))
     return True
示例#5
0
 def on_add_game_button_clicked(self, _widget, _data=None):
     """Add a new game manually with the AddGameDialog."""
     dialog = AddGameDialog(
         self.window,
         runner=self.selected_runner,
         callback=lambda: self.add_game_to_view(dialog.game.id))
     return True
示例#6
0
    def on_add_manually(self, widget, *args):
        def on_game_added(game):
            self.view.set_installed(game)
            self.sidebar_treeview.update()

        game = Game(self.view.selected_game)
        AddGameDialog(self,
                      game=game,
                      runner=self.selected_runner,
                      callback=lambda: on_game_added(game))
示例#7
0
    def on_add_manually(self, _widget, *_args):
        """Callback that presents the Add game dialog"""
        def on_game_added(game):
            self.view.set_installed(game)
            self.sidebar_treeview.update()

        game = Game(self.view.selected_game)
        AddGameDialog(self,
                      game=game,
                      runner=self.selected_runner,
                      callback=lambda: on_game_added(game))
 def run_no_installer_dialog(self):
     """Open dialog for 'no script available' situation."""
     dlg = NoInstallerDialog(self)
     if dlg.result == dlg.MANUAL_CONF:
         game_data = pga.get_game_by_field(self.game_slug, 'slug')
         game = Game(game_data['id'])
         AddGameDialog(
             self.parent,
             game=game,
             callback=lambda: self.notify_install_success(game_data['id']))
     elif dlg.result == dlg.NEW_INSTALLER:
         webbrowser.open(settings.GAME_URL % self.game_slug)
示例#9
0
def fetch_script(window, game_ref):
    """Downloads install script(s) for matching game_ref"""
    request = urllib2.Request(url=settings.INSTALLER_URL % game_ref)
    try:
        request = urllib2.urlopen(request)
        script_contents = request.read()
    except IOError:
        dlg = NoInstallerDialog(window)
        if dlg.result == 1:
            game = Game(game_ref)
            game_dialog = AddGameDialog(window, game)
            game_dialog.run()
            if game_dialog.installed:
                window.notify_install_success()
        elif dlg.result == 2:
            installer_url = settings.SITE_URL + "games/%s/" % game_ref
            webbrowser.open(installer_url)
        return
    # Data should be JSON here, but JSON is also valid YAML.
    # At some point we will be dropping the YAML parser and load installer
    # data with json.loads
    return yaml.safe_load(script_contents)
示例#10
0
def fetch_script(window, game_ref):
    """Downloads install script(s) for matching game_ref"""
    request = urllib2.Request(url=settings.INSTALLER_URL % game_ref)
    try:
        request = urllib2.urlopen(request)
        script_contents = request.read()
    except IOError:
        dlg = NoInstallerDialog(window)
        if dlg.result == dlg.MANUAL_CONF:
            game = Game(game_ref)
            game_dialog = AddGameDialog(window, game)
            game_dialog.run()
            if game_dialog.saved:
                window.notify_install_success()
        elif dlg.result == dlg.NEW_INSTALLER:
            installer_url = settings.SITE_URL + "games/%s/" % game_ref
            webbrowser.open(installer_url)
        return
    # Data should be JSON here, but JSON is also valid YAML.
    # At some point we will be dropping the YAML parser and load installer
    # data with json.loads
    return yaml.safe_load(script_contents)
示例#11
0
 def add_game(self, _widget, _data=None):
     """Add a new game."""
     add_game_dialog = AddGameDialog(self.window)
     add_game_dialog.run()
     if add_game_dialog.saved:
         self.add_game_to_view(add_game_dialog.game.id)
示例#12
0
 def add_game(self, _widget, _data=None):
     """Add a new game."""
     add_game_dialog = AddGameDialog(self)
     add_game_dialog.run()
     if add_game_dialog.runner_name and add_game_dialog.slug:
         self.add_game_to_view(add_game_dialog.slug)
示例#13
0
 def add_manually(self, *args):
     game = Game(self.view.selected_game)
     add_game_dialog = AddGameDialog(self, game)
     add_game_dialog.run()
     if add_game_dialog.installed:
         self.view.set_installed(game)
示例#14
0
 def add_game(self, _widget, _data=None):
     """Add a new game."""
     add_game_dialog = AddGameDialog(self)
     add_game_dialog.run()
     if add_game_dialog.runner_name and add_game_dialog.slug:
         self.add_game_to_view(add_game_dialog.slug)
示例#15
0
 def add_manually(self, *args):
     game = Game(self.view.selected_game)
     add_game_dialog = AddGameDialog(self, game)
     add_game_dialog.run()
     if add_game_dialog.installed:
         self.view.set_installed(game)