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

skillPlanEditorOverview.py (8173B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\skillPlan\skillPlanEditor\skillPlanEditorOverview.py
      2 from __future__ import absolute_import
      3 import evetypes
      4 import uthread2
      5 from carbon.client.script.environment.AudioUtil import PlaySound
      6 from carbon.common.script.util.commonutils import StripTags
      7 from carbonui import Density, uiconst
      8 from carbonui.button import styling
      9 from carbonui.control.button import Button
     10 from carbonui.control.combo import Combo
     11 from carbonui.control.scrollContainer import ScrollContainer
     12 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText
     13 from carbonui.primitives.container import Container
     14 from characterdata import careerpath
     15 from eve.client.script.ui.control.eveEditPlainText import EditPlainText
     16 from eve.client.script.ui.control.eveLabel import EveLabelLarge
     17 from eve.client.script.ui.skillPlan import skillPlanUISignals
     18 from eve.client.script.ui.skillPlan.controls.milestoneIndicatorHeader import LoadMilestonesTooltipPanel
     19 from eve.client.script.ui.skillPlan.milestone.skillPlanProgressIndicatorEditable import SkillPlanProgressIndicatorEditable
     20 from localization import GetByLabel, GetByMessageID
     21 from player_messaging.client.ui_message import prompt_player_fsd_dialog
     22 from .saveSkillPlanButton import SkillPlanEditorSaveButton
     23 from skills.skillplan import skillPlanConst
     24 from skills.skillplan.skillPlanConst import MAX_LEN_NAME, MAX_LEN_DESC
     25 from skills.skillplan.skillPlanService import GetSkillPlanSvc
     26 
     27 class SkillPlanEditorOverview(Container):
     28 
     29     def ApplyAttributes(self, attributes):
     30         super(SkillPlanEditorOverview, self).ApplyAttributes(attributes)
     31         self.skillPlan = None
     32         skillPlanUISignals.on_skill_requirements_changed.connect(self.OnSkillRequirementsChanged)
     33         skillPlanUISignals.on_milestone_added.connect(self.UpdateMilestoneCountLabel)
     34         skillPlanUISignals.on_milestone_removed.connect(self.UpdateMilestoneCountLabel)
     35         skillPlanUISignals.on_contents_list_started_reconstructing.connect(self.OnContentsListStartedReconstructing)
     36         skillPlanUISignals.on_contents_list_finished_reconstructing.connect(self.OnContentsListFinishedReconstructing)
     37         self.ConstructMilestoneEditor()
     38         self.detailsCont = ScrollContainer(parent=self, name='detailsCont')
     39         self._ConstructDetailsCont()
     40         self.buttonsCont = Container(parent=self, name='buttonsCont', align=uiconst.TOBOTTOM, height=styling.get_height(Density.NORMAL), padTop=10, idx=0)
     41         self._ConstructButtonsCont()
     42         self.UpdateSaveButtonState()
     43 
     44     def UpdateMilestoneCountLabel(self, *args):
     45         self.milestoneCountLabel.text = '%s/%s' % (len(self.skillPlan.GetMilestones()), skillPlanConst.MAX_NUM_MILESTONES)
     46 
     47     def _ConstructDetailsCont(self):
     48         EveLabelLarge(parent=self.detailsCont, align=uiconst.TOTOP, text=GetByLabel('UI/Common/Name'), padTop=12)
     49         self.nameEdit = SingleLineEditText(parent=self.detailsCont, align=uiconst.TOTOP, hintText=GetByLabel('UI/SkillPlan/EnterPlanName'), maxLength=MAX_LEN_NAME, showLetterCounter=True)
     50         self.nameEdit.OnChange = self.OnNameEditChanged
     51         EveLabelLarge(parent=self.detailsCont, align=uiconst.TOTOP, text=GetByLabel('UI/Common/Description'), padTop=12)
     52         self.descriptionEdit = EditPlainText(parent=self.detailsCont, align=uiconst.TOTOP, height=120, padTop=2, hintText=GetByLabel('UI/SkillPlan/EnterPlanDescription'), maxLength=MAX_LEN_DESC, allowFormatChanges=False)
     53         self.categoryCombo = Combo(name='categoryCombo', parent=self.detailsCont, align=uiconst.TOTOP, label=GetByLabel('UI/Common/Category'), padTop=32, options=self._GetCategoryComboOptions())
     54 
     55     def _GetCategoryComboOptions(self):
     56         options = [(GetByLabel('UI/Generic/None'), 0)]
     57         options += [ (GetByMessageID(c.nameID), cID) for cID, c in careerpath.get_career_paths().iteritems() ]
     58         return options
     59 
     60     def _ConstructButtonsCont(self):
     61         clearButtonParent = self.buttonsCont
     62         clearButtonParent = Container(parent=self.buttonsCont, align=uiconst.TOLEFT_PROP, width=0.5)
     63         self.clearButton = Button(name='clearButton', parent=clearButtonParent, align=uiconst.TOTOP, label=GetByLabel('UI/Inventory/Clear'), func=self.OnClearButton)
     64         saveButtonParent = self.buttonsCont
     65         saveButtonParent = Container(parent=self.buttonsCont, align=uiconst.TOALL, padLeft=4)
     66         self.saveButton = SkillPlanEditorSaveButton(name='saveButton', parent=saveButtonParent, align=uiconst.TOTOP, label=GetByLabel('UI/Common/Buttons/Save'), func=self.OnSaveButton)
     67 
     68     def OnSkillRequirementsChanged(self, skillPlanID):
     69         self.UpdateSaveButtonState()
     70 
     71     def OnNameEditChanged(self, _):
     72         self.UpdateSaveButtonState()
     73 
     74     def ConstructMilestoneEditor(self):
     75         topCont = Container(name='topCont', parent=self, state=uiconst.UI_NORMAL, align=uiconst.TOTOP, height=20, padBottom=-6)
     76         topCont.LoadTooltipPanel = LoadMilestonesTooltipPanel
     77         EveLabelLarge(parent=topCont, name='skillPlanOverviewLabel', align=uiconst.TOPLEFT, text=GetByLabel('UI/SkillPlan/Milestones'))
     78         self.milestoneCountLabel = EveLabelLarge(parent=topCont, name='milestoneCountLabel', align=uiconst.TOPRIGHT)
     79         self.milestoneEditor = SkillPlanProgressIndicatorEditable(parent=self, align=uiconst.TOTOP_PROP, height=0.4)
     80         self.milestoneEditor.onMilestoneDataDroppedSignal.connect(self.OnMilestoneDataDropped)
     81 
     82     def OnMilestoneDataDropped(self, typeID, level, milestoneID = None):
     83         oldMilestone = milestoneID and self.skillPlan.GetMilestone(milestoneID)
     84         if oldMilestone:
     85             oldMilestoneTypeID = oldMilestone.GetTypeID()
     86             msgArgs = {'milestoneNameOld': evetypes.GetName(oldMilestoneTypeID),
     87              'milestoneNameNew': evetypes.GetName(typeID)}
     88             if prompt_player_fsd_dialog('ReplaceMilestoneWithNewMilestone', msgArgs, uiconst.YESNO) == uiconst.ID_YES:
     89                 self.skillPlan.RemoveMilestone(milestoneID)
     90             else:
     91                 return
     92         PlaySound(uiconst.SOUND_ADD_OR_USE)
     93         if level is None:
     94             self.skillPlan.AddTypeIDMilestone(typeID)
     95         else:
     96             self.skillPlan.AddSkillRequirementMilestone(typeID, level)
     97 
     98     def SetSkillPlan(self, skillPlan):
     99         self.skillPlan = skillPlan
    100         self.nameEdit.SetValue(self.skillPlan.GetName(), 0)
    101         self.descriptionEdit.SetText(self.skillPlan.GetDescription())
    102         if self.skillPlan.HasEditableCategoryID():
    103             self.categoryCombo.Show()
    104             self.categoryCombo.SetValue(self.skillPlan.GetCategoryID())
    105         else:
    106             self.categoryCombo.Hide()
    107         uthread2.StartTasklet(self.milestoneEditor.SetSkillPlan, self.skillPlan)
    108         self.UpdateSaveButtonState()
    109         self.UpdateMilestoneCountLabel()
    110 
    111     def OnClearButton(self, *args):
    112         if self.skillPlan:
    113             self.skillPlan.ClearSkillRequirements()
    114             self.skillPlan.ClearMilestones()
    115             self.nameEdit.Clear()
    116             self.categoryCombo.SetValue(0)
    117             self.descriptionEdit.Clear()
    118             skillPlanUISignals.on_skill_plan_cleared(self.skillPlan.GetID())
    119 
    120     def OnSaveButton(self, *args):
    121         self.skillPlan.AdjustMilestonesToAddAndDeletedIDs()
    122         self.SetNameAndDescriptionInPlan()
    123         if self.skillPlan.HasEditableCategoryID():
    124             self.skillPlan.SetCategoryID(self.categoryCombo.GetValue())
    125         GetSkillPlanSvc().Save(self.skillPlan)
    126 
    127     def SetNameAndDescriptionInPlan(self):
    128         if self.skillPlan:
    129             self.skillPlan.SetName(self.nameEdit.GetValue())
    130             desc = self.descriptionEdit.GetValue()
    131             desc = StripTags(desc, stripOnly=['font'])
    132             self.skillPlan.SetDescription(desc)
    133 
    134     def UpdateSaveButtonState(self):
    135         self.saveButton.UpdateState(self.skillPlan, self.nameEdit.GetValue(False))
    136 
    137     def OnContentsListStartedReconstructing(self):
    138         self.clearButton.Disable()
    139         self.saveButton.Disable()
    140 
    141     def OnContentsListFinishedReconstructing(self):
    142         self.clearButton.Enable()
    143         self.UpdateSaveButtonState()