NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

clone_grade_wnd.py (5860B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\omega\qa\clone_grade_wnd.py
      2 from carbonui import Align
      3 from carbonui.text.styles import TextBody
      4 from carbonui.control.button import Button
      5 from carbonui.control.checkbox import Checkbox
      6 from carbonui.control.singlelineedits.singleLineEditInteger import SingleLineEditInteger
      7 from carbonui.control.window import Window
      8 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      9 from eve.client.script.ui.omega.upsell.omegaHeroNotifications import omega_hero_notification
     10 from omega.client.clone_grade_svc import get_clone_grade_svc
     11 from omega.client.mock.omega_state import mocked_is_omega, mocked_is_omega_recurring, mocked_omega_days_remaining, mocked_long_lapsing
     12 from omega.client.qa.settings import mock_omega_state_setting, mocked_quick_pay_setting, mocked_quick_pay_force_redirect, mocked_payment_always_successful
     13 from localization import GetByLabel
     14 
     15 class CloneGradeQAWindow(Window):
     16     __guid__ = 'CloneGradeQAWindow'
     17     default_width = 400
     18     default_height = 600
     19     default_windowID = 'cloneGradeQAWindow'
     20     default_minSize = [default_width, default_height]
     21 
     22     def __init__(self, *args):
     23         super(CloneGradeQAWindow, self).__init__(*args)
     24         self.SetCaption('Clone Grade QA')
     25         self._construct_layout()
     26 
     27     def Close(self, *args, **kw):
     28         super(CloneGradeQAWindow, self).Close(*args, **kw)
     29 
     30     def _construct_layout(self):
     31         self._long_lapsing_checkbox = Checkbox(parent=self.content, align=Align.TOTOP, text='Force Lapsing under 90 days', setting=mocked_long_lapsing)
     32         self._enable_mocks_checkbox = Checkbox(parent=self.content, align=Align.TOTOP, text='Enable mocks', callback=self._on_checkbox_changed)
     33         self._mocks_container = ContainerAutoSize(parent=self.content, align=Align.TOTOP)
     34         self._is_omega_checkbox = Checkbox(parent=self._mocks_container, align=Align.TOTOP, text='Is Omega', callback=self._on_checkbox_changed)
     35         self._is_recurring_checkbox = Checkbox(parent=self._mocks_container, align=Align.TOTOP, text='Is Omega recurring', callback=self._on_checkbox_changed)
     36         Checkbox(parent=self._mocks_container, align=Align.TOTOP, text='Is Quick Pay enabled', setting=mocked_quick_pay_setting)
     37         Checkbox(parent=self._mocks_container, align=Align.TOTOP, text='Force Quick Pay Redirect', setting=mocked_quick_pay_force_redirect)
     38         Checkbox(parent=self._mocks_container, align=Align.TOTOP, text='Force Payments Always Successful', setting=mocked_payment_always_successful)
     39         days_left_container = ContainerAutoSize(parent=self._mocks_container, align=Align.TOTOP, height=32)
     40         self._days_left_input = SingleLineEditInteger(parent=days_left_container, align=Align.TOLEFT, height=32, minValue=1, maxValue=365)
     41         TextBody(parent=days_left_container, align=Align.TOLEFT, text='Days Left/Next Payment', height=32)
     42         Button(parent=self.content, align=Align.TOTOP, label='Trigger activated hero', func=self._on_activated_hero)
     43         Button(parent=self.content, align=Align.TOTOP, label='Trigger extended hero', func=self._on_extended_hero)
     44         Button(parent=self.content, align=Align.TOTOP, label='Apply', func=self._on_apply)
     45         self._svc_return = TextBody(parent=self.content, align=Align.TOTOP)
     46         self._update()
     47 
     48     def _update_availability(self, mocks_enabled, is_omega):
     49         self._is_omega_checkbox.enabled = mocks_enabled
     50         self._is_recurring_checkbox.enabled = mocks_enabled and is_omega
     51         if mocks_enabled and is_omega:
     52             self._days_left_input.Enable()
     53         else:
     54             self._days_left_input.Disable()
     55 
     56     def _update_svc_return_text(self):
     57         if mock_omega_state_setting.is_enabled():
     58             svc = get_clone_grade_svc()
     59             self._svc_return.text = 'Service now returns the following mocks:\n- Is Omega: %s\n- Recurring: %s\n\n- License Info:\n%s\n\n- Subscription Info:\n%s' % ('Yes' if svc.is_omega_without_grace_period() else 'No',
     60              'Yes' if svc.is_omega_subscription_recurring() else 'No',
     61              svc.get_omega_license_without_grace_period(),
     62              svc.get_recurring_subscription_details())
     63         else:
     64             self._svc_return.text = ''
     65 
     66     def _update(self):
     67         self._enable_mocks_checkbox.SetChecked(mock_omega_state_setting.is_enabled(), False)
     68         self._is_omega_checkbox.SetChecked(mocked_is_omega.is_enabled(), False)
     69         self._is_recurring_checkbox.SetChecked(mocked_is_omega_recurring.is_enabled(), False)
     70         self._days_left_input.SetValue(mocked_omega_days_remaining.get(), False)
     71         self._update_availability(mock_omega_state_setting.is_enabled(), mocked_is_omega.is_enabled())
     72 
     73     def _on_checkbox_changed(self, *args):
     74         self._update_availability(self._enable_mocks_checkbox.checked, self._is_omega_checkbox.checked)
     75 
     76     def _on_activated_hero(self, *args):
     77         self.show_hero_notification(text=GetByLabel('UI/OmegaUpsell/OmegaSubscriptionActivated'))
     78 
     79     def _on_extended_hero(self, *args):
     80         self.show_hero_notification(text=GetByLabel('UI/OmegaUpsell/OmegaSubscriptionExtended'))
     81 
     82     def show_hero_notification(self, text):
     83 
     84         def PlayVideo(parent, cancellation_token):
     85             omega_hero_notification(parent, text)
     86 
     87         sm.GetService('heroNotification').play(PlayVideo, 1)
     88 
     89     def _on_apply(self, *args):
     90         if self._enable_mocks_checkbox.checked:
     91             mock_omega_state_setting.enable()
     92             mocked_is_omega.set(self._is_omega_checkbox.checked)
     93             mocked_is_omega_recurring.set(self._is_recurring_checkbox.checked)
     94             mocked_omega_days_remaining.set(self._days_left_input.GetValue())
     95         else:
     96             mock_omega_state_setting.disable()
     97         self._update()
     98         self._update_svc_return_text()