viewcontroller.py (6005B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\eveclientqatools\sofpreviewer\viewcontroller.py 2 from __future__ import absolute_import 3 import blue 4 import trinity 5 import fsdBuiltData.common.graphicMaterialSets as graphicMaterialSets 6 from eveclientqatools.sofpreviewer.model import SofPreviewerModel 7 from eveclientqatools.sofpreviewer.view import SofPreviewerView 8 from eveclientqatools.sofpreviewer.statemachinecontroller import StateMachineController 9 from .materialselection.viewcontroller import MaterialSelectionViewController 10 from .visualization.viewcontroller import VisualizationViewController 11 from .sofselection.viewcontroller import SofSelectionViewController 12 from .highslotselection.viewcontroller import HighSlotSelectionViewController 13 14 class SofPreviewerController(object): 15 16 def __init__(self): 17 self.view = SofPreviewerView(controller=self) 18 self.model = SofPreviewerModel() 19 self.updateShip = True 20 self.sofSelectionViewController = SofSelectionViewController(self.model, self, self.view) 21 self.materialSelectionViewController = MaterialSelectionViewController(self.model, self, self.view) 22 self.visualizationViewController = VisualizationViewController(self.model, self, self.view) 23 self.highSlotSelectionViewController = HighSlotSelectionViewController(self.model, self, self.view) 24 self.stateMachineController = StateMachineController() 25 26 @property 27 def shipModel(self): 28 return self.view.previewCont.context.GetModel() 29 30 def UpdatePlayerShip(self): 31 michelle = sm.GetService('michelle') 32 ship = michelle.GetBall(session.shipid) 33 if ship is None: 34 return 35 ship.UnfitHardpoints() 36 ship.Release() 37 while ship.model is not None: 38 blue.synchro.Yield() 39 40 ship.released = False 41 ship.GetDNA = self.GetPreviewDna 42 ship.LoadModel() 43 ship.Assemble() 44 if self.visualizationViewController.currentDirtLevel is not None: 45 ship.model.dirtLevel = self.visualizationViewController.currentDirtLevel 46 self.stateMachineController.ApplyTo(ship.model) 47 ship.model.StartControllers() 48 self.highSlotSelectionViewController.UpdateDNA(ship.GetDNA()) 49 self.highSlotSelectionViewController.ShowBanner(True, ship.model) 50 51 def ShowUI(self): 52 self.view.ShowUI(self.sofSelectionViewController, self.materialSelectionViewController, self.visualizationViewController, self.highSlotSelectionViewController) 53 self.view.previewCont.PreviewSofDna(self.GetPreviewDna()) 54 self.ReloadStateMachineOptions() 55 return self 56 57 def GetPreviewDna(self): 58 dna = self.sofSelectionViewController.GetCurrentHull() + ':' + self.sofSelectionViewController.viewModel.currentFaction + ':' + self.sofSelectionViewController.viewModel.currentRace 59 dna = self.materialSelectionViewController.AppendMaterialToDna(dna) 60 dna = self.visualizationViewController.AppendResPathToDna(dna) 61 dna = self.visualizationViewController.AppendVariantToDna(dna) 62 dna = self.AppendCurrentPatternToDna(dna) 63 if self.view is not None and self.view.dnaLabel is not None: 64 self.view.dnaLabel.text = dna 65 return dna 66 67 def AppendCurrentPatternToDna(self, dna): 68 if self.sofSelectionViewController.currentPattern != 'None': 69 dna += ':pattern?' + str(self.sofSelectionViewController.currentPattern) + ';' + str(self.materialSelectionViewController.currentPatternMat[0]) + ';' + str(self.materialSelectionViewController.currentPatternMat[1]) 70 return dna 71 72 def ReloadStateMachineOptions(self): 73 model = self.shipModel 74 hull = self.sofSelectionViewController.GetCurrentHull() 75 self.stateMachineController.SetupForHullAndModel(hull, model) 76 self.visualizationViewController.RefreshStateMachine(self.stateMachineController) 77 78 def UpdatePreviewShip(self): 79 dna = self.GetPreviewDna() 80 self.highSlotSelectionViewController.UpdateDNA(dna) 81 if self.view.previewCont is not None and self.updateShip: 82 self.view.previewCont.PreviewSofDna(dna, dirt=self.visualizationViewController.currentDirtLevel) 83 self.ReloadStateMachineOptions() 84 self.highSlotSelectionViewController.ShowBanner(self.highSlotSelectionViewController.isShowBannerChecked, self.shipModel) 85 86 def GetCurrentMaterialSetID(self): 87 if not hasattr(self.view.rightView, 'rightView') or not hasattr(self.view.rightView, 'materialSetIDCombo'): 88 return -1 89 return self.view.rightView.materialSetIDCombo.GetValue() 90 91 def FilterMaterialSet(self, filterByRace): 92 materialSets = graphicMaterialSets.GetGraphicMaterialSets() 93 availableMaterialSets = [] 94 self.sofSelectionViewController.FilterMaterialSet(filterByRace, materialSets, availableMaterialSets) 95 availableMaterialSets = sorted(availableMaterialSets, key=lambda x: x[0]) 96 options = [('None', -1)] + [ ('%s: %s' % keyAndDesc, keyAndDesc[0]) for keyAndDesc in availableMaterialSets ] 97 self.visualizationViewController.FilterMaterialSet(options) 98 99 def OnMaterialSetIDChange(self, *args): 100 self.updateShip = False 101 materialSet = self.visualizationViewController.GetCurrentMaterialSet() 102 self.sofSelectionViewController.OnMaterialSetIDChange(materialSet) 103 self.materialSelectionViewController.OnMaterialSetIDChange(materialSet) 104 self.visualizationViewController.OnMaterialSetIDChange(materialSet) 105 self.updateShip = True 106 self.UpdatePreviewShip() 107 self.sofSelectionViewController.UpdateIcon() 108 109 def OnApplyButton(self, *args): 110 self.UpdatePlayerShip() 111 112 def OnCopyDnaButton(self, *args): 113 blue.pyos.SetClipboardData(self.GetPreviewDna()) 114 115 @property 116 def isMaterialSetFilteredByRace(self): 117 return self.view.rightView.materialSetFilteredByRace.GetValue()