campaign_progress.py (3913B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\theatersOfWar\campaigns\campaign_progress.py 2 import mathext 3 from carbon.common.script.util.format import FmtAmt 4 from carbonui import Align, TextColor 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.containerAutoSize import ContainerAutoSize 7 from carbonui.primitives.layoutGrid import LayoutGrid 8 from carbonui.text.custom import TextCustom 9 from carbonui.text.styles import TextDetail 10 from carbonui.uianimations import animations 11 from eve.client.script.ui.control.gauge import Gauge 12 from eve.client.script.ui.shared.theatersOfWar.dashboard.dashboardConst import ID_CAMPAIGNS 13 from eve.client.script.ui.shared.theatersOfWar.dashboard.signals import on_landing_page_widget_clicked 14 from eveui import Sprite 15 from evewar.warText import GetByLabel 16 17 class BaseProgress(ContainerAutoSize): 18 default_width = 100 19 default_align = Align.CENTER 20 label_path = 'UI/Campaigns/NumObjectives' 21 22 def ApplyAttributes(self, attributes): 23 super(BaseProgress, self).ApplyAttributes(attributes) 24 icon_texture_path = attributes.icon_texture_path 25 icon_cont = Container(name='icon_cont', parent=self, align=Align.TOTOP, height=40) 26 icon = Sprite(parent=icon_cont, pos=(0, 0, 40, 40), align=Align.CENTERTOP, texturePath=icon_texture_path) 27 grid_cont = ContainerAutoSize(name='grid_cont', parent=self, align=Align.TOTOP) 28 grid = LayoutGrid(name='grid', parent=grid_cont, align=Align.CENTER, columns=1) 29 number_grid = LayoutGrid(name='number_grid', parent=grid, align=Align.CENTERTOP, columns=3) 30 self.progress_label = TextCustom(parent=number_grid, text='0', fontsize=32, align=Align.CENTERBOTTOM) 31 TextCustom(parent=number_grid, text='/', fontsize=20, align=Align.CENTERBOTTOM, color=TextColor.SECONDARY) 32 self.target_label = TextCustom(parent=number_grid, text='0', fontsize=20, align=Align.CENTERBOTTOM, color=TextColor.SECONDARY) 33 num_objectives_text = GetByLabel('UI/Campaigns/ObjectivesProgressHeader').upper() 34 d = TextDetail(text=num_objectives_text, align=Align.CENTER, color=TextColor.SECONDARY, upperCase=True) 35 grid.AddCell(d, colSpan=grid.columns) 36 grid.FillRow() 37 self.gauge = Gauge(align=Align.TOTOP, gaugeHeight=4) 38 grid.AddCell(self.gauge, colSpan=grid.columns) 39 grid.FillRow() 40 41 def load_ui(self, progress_value, target_value, color): 42 if target_value: 43 progress_percentage = float(progress_value) / target_value 44 else: 45 progress_percentage = 0 46 self.set_values(FmtAmt(min(progress_value, target_value)), FmtAmt(target_value), progress_percentage) 47 self.gauge.SetColor(color) 48 49 def set_values(self, progress_text, target_text, gauge_value): 50 self.progress_label.SetText(progress_text) 51 self.target_label.SetText(target_text) 52 self.gauge.SetValue(mathext.clamp(gauge_value, 0.0, 1.0)) 53 54 def OnMouseEnter(self, *args): 55 animations.FadeIn(self, endVal=1.2) 56 57 def OnMouseExit(self, *args): 58 animations.FadeIn(self, endVal=1.0) 59 60 61 class CampaignProgress(BaseProgress): 62 63 def ApplyAttributes(self, attributes): 64 self.campaign_controller = attributes.campaign_controller 65 self.window_controller = attributes.window_controller 66 super(CampaignProgress, self).ApplyAttributes(attributes) 67 68 def load_progess_values(self): 69 progress_value = self.campaign_controller.current_progress 70 target_value = self.campaign_controller.target_progress 71 color = self.campaign_controller.theme_pack.accent 72 self.load_ui(progress_value, target_value, color) 73 74 def OnClick(self, *args): 75 extra_args = {'campaign_id': self.campaign_controller.campaign_id} 76 self.window_controller.on_page_changed(ID_CAMPAIGNS, extra_args)