コード例 #1
0
    def handle_result2(self, result: Tuple[bool, str]) -> None:
        logger.debug(f'Second fetch result {result}')
        self.res2 = result[0]

        if self.res2 is True:
            pass
        else:
            self.login_failed()
            wgv_utils.popup_msg(result[1])
            return

        if self.res1 == True and self.res2 == True:
            self.button_login.setText(
                'Loading and Initializing... (rendering time varies with dock size)'
            )
            logger.info("SUCCESS!")
            # No popup msg on Login Success
            # if self.check_auto.isChecked() is True:
            #     pass
            # else:
            #     wgv_utils.popup_msg('Login Success')
            self.login_success()
        else:
            self.login_failed()
            wgv_utils.popup_msg(
                "Login Failed (3): Probably due to bad server connection")
コード例 #2
0
    def zip_download_finished(self, res: bool) -> None:
        self.progress_bar.close()
        self.progress_bar = None
        del self.progress_bar
        self.bee_download_zip = None
        del self.bee_download_zip
        self.show()
        if self.sig_close_login is not None:
            self.sig_close_login.emit()
            self.sig_close_login = None
            del self.sig_close_login
        else:
            pass

        if res is True:
            # Original UI initialization sequence
            self.api_initGame()
            # 1. The init order cannot be changed right now
            #   tab_dock init all ships data and it's independent of side dock
            # 2. Tabs must be created before menu bar,  menu bar reference main_tabs
            self.main_tabs = MainInterfaceTabs(self, self.threadpool,
                                               self.is_realrun)
            # TODO loading speed is slow
            self.main_tabs.init_tab(QKEYS.UI_TAB_SHIP, 'tab_dock')
            self.init_side_dock()
            self.main_tabs.init_tab(QKEYS.UI_TAB_EXP, 'tab_exp')
            self.main_tabs.init_tab(QKEYS.UI_TAB_THER, 'tab_thermopylae')
            self.main_tabs.init_tab(QKEYS.UI_TAB_ADV, 'tab_adv')
            self.menu_bar = MainInterfaceMenuBar(self)
            self.init_ui()
        else:
            wgv_utils.popup_msg("Failed to download essential zip resources.")
コード例 #3
0
 def handle_result1(self, result: Tuple[bool, str]) -> None:
     logger.debug(f'First fetch result {result}')
     self.res1 = result[0]
     if self.res1 is True:
         self.bee2.start()
     else:
         self.login_failed()
         err_msg = result[
             1] if result[1] != '' else "Unexpected Connection Error"
         wgv_utils.popup_msg(err_msg)
コード例 #4
0
    def start_login(self) -> None:
        self._version_check = None
        del self._version_check

        if self.check_disclaimer.isChecked() is True:
            self.container.setEnabled(False)
            self.on_save_clicked()
            self._check_password()
        else:
            wgv_utils.popup_msg('Read disclaimer and check to proceed')
コード例 #5
0
 def clear_all_cache(self) -> None:
     reply = QMessageBox.question(self, 'Warning', "Do you want to clear all caches?\n(Re-caching takes time)",
                                  QMessageBox.Yes, QMessageBox.No)
     if reply == QMessageBox.Yes:
         res = wgv_data.clear_cache_folder(True)
         if res is True:
             wgv_utils.popup_msg('Clear success')
         else:
             wgv_utils.popup_msg('Clear failed')
     else:
         pass
コード例 #6
0
 def _get_password(self) -> str:
     if wgv_data.is_key_exists() and self.qsettings.contains(
             QKEYS.LOGIN_PSWD):
         try:
             key = self.encryptor.load_key(wgv_data.get_key_path())
             res = self.encryptor.decrypt_data(
                 key,
                 self.qsettings.value(QKEYS.LOGIN_PSWD)).decode("utf-8")
         except AttributeError:
             res = ''
             wgv_utils.popup_msg(
                 'Error: Key file or config file may be corrupted.')
     else:
         res = ''
     return res
コード例 #7
0
    def start_bypass_login(self) -> None:
        user_cookie = wgv_data.load_cookies()
        if 'cookies' in user_cookie and 'hf_skey' in user_cookie['cookies']:
            token = user_cookie['cookies']['hf_skey']
            if token == "" or len(token) < 50:
                # The random part is 32, the timestamp is 10, the UID part is at least 10
                res = False
            else:
                res = True
        else:
            res = False

        if res is True:
            self.login_success(True)
        else:
            self.button_bypass.setEnabled(False)
            wgv_utils.popup_msg("Your cookies is invalid. Please use Login")
コード例 #8
0
    def api_initGame(self) -> None:
        if self.is_realrun:
            data = self.api.initGame()
            wgv_data.save_api_initGame(data)
        else:
            data = wgv_data.get_api_initGame()

        if 'eid' in data:
            wgv_utils.popup_msg(get_error_text(data['eid']), "Init Error")
            sys.exit(-1)

        try:
            wgv_data.save_equipmentVo(data['equipmentVo'])
            wgv_data.save_user_tactics(data['tactics'])
            wgv_data.save_userVo(data['userVo'])
            wgv_data.save_user_fleets(data['fleetVo'])
            wgv_data.save_pveExploreVo(data['pveExploreVo'])
        except KeyError:
            wgv_utils.popup_msg("Game data init failed...", "Init Error")
            # TODO? quit_application() not working
            sys.exit(-1)
コード例 #9
0
    def fetch_finished(self, res: bool) -> None:
        self.loading_screen.stop()
        self.is_check_finished = True
        if res is True:
            user_ver = version.parse(wgv_utils.get_app_version())
            latest_ver = version.parse(self.latest_ver)
            if user_ver == latest_ver:
                logger.debug('User has latest version installed.')
                res = 0
            elif user_ver < latest_ver:
                res = self.detail_version_check(user_ver, latest_ver)
            elif user_ver > latest_ver:
                logger.error(
                    f'Version check has unexpected outcome user: {user_ver}, cloud: {latest_ver}'
                )
                res = -1
            else:
                logger.error(
                    f'Version check has unexpected outcome user: {user_ver}, cloud: {latest_ver}'
                )
                res = -1
        else:
            wgv_utils.popup_msg(
                'Failed to check latest app version due to unideal Internet connection.'
            )
            res = 1

        if res == 0:
            logger.debug('Version check succeed.')
        elif res == 1:
            logger.debug(
                'Version check succeed. User skips the latest download.')
        elif res == -1:
            wgv_utils.popup_msg(
                'Version check failed. Please re-download the application.',
                'Info')
            wgv_utils.force_quit(0)
        else:
            pass
コード例 #10
0
    def detail_version_check(self, user_ver: version.Version,
                             latest_ver: version.Version) -> int:
        if user_ver.major < latest_ver.major:
            wgv_utils.popup_msg(
                f'WGViewer v{self.latest_ver} is available. This is a mandatory major update',
                'Major Update')
            res = True
        elif user_ver.minor < latest_ver.minor:
            res = self.is_update('Minor Update', 'a recommended')
        elif user_ver.micro < latest_ver.micro:
            res = self.is_update('Micro Update', 'an optional')
        else:
            logger.error(
                f'Version check has unexpected outcome user: {user_ver}, cloud: {latest_ver}'
            )
            res = self.is_update('Update', 'an optional')

        if res is True:
            self.download_update()
            r = 0
        else:
            r = 1
        return r
コード例 #11
0
 def clear_user_cache() -> None:
     res = wgv_data.clear_cache_folder(False)
     if res is True:
         wgv_utils.popup_msg('Clear success')
     else:
         wgv_utils.popup_msg('Clear failed')