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

dataLoader.py (3815B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\paints\data\dataLoader.py
      2 import trinity
      3 from fsdBuiltData.common.base import BuiltDataLoader
      4 from paints.data.const import ALL_PAINT_RARITIES, ALL_PAINT_FINISHES
      5 try:
      6     import paintsLoader
      7 except ImportError:
      8     paintsLoader = None
      9 
     10 try:
     11     import hueCategoriesLoader
     12 except ImportError:
     13     hueCategoriesLoader = None
     14 
     15 class _PaintsDataLoader(BuiltDataLoader):
     16     __resBuiltFile__ = 'res:/staticdata/paints.fsdbinary'
     17     __clientAutobuildBuiltFile__ = 'eve/autobuild/staticData/client/paints.fsdbinary'
     18     __serverAutobuildBuiltFile__ = 'eve/autobuild/staticData/server/paints.fsdbinary'
     19     __loader__ = paintsLoader
     20 
     21 
     22 class _HueCategoriesDataLoader(BuiltDataLoader):
     23     __resBuiltFile__ = 'res:/staticdata/hueCategories.fsdbinary'
     24     __clientAutobuildBuiltFile__ = 'eve/autobuild/staticData/client/hueCategories.fsdbinary'
     25     __serverAutobuildBuiltFile__ = 'eve/autobuild/staticData/server/hueCategories.fsdbinary'
     26     __loader__ = hueCategoriesLoader
     27 
     28 
     29 def _get_paint(paint_id):
     30     paint_data = _PaintsDataLoader.GetData()
     31     try:
     32         return paint_data[paint_id]
     33     except KeyError:
     34         raise PaintDoesNotExistError(paint_id)
     35 
     36 
     37 def get_paint_ids():
     38     return _PaintsDataLoader.GetData().keys()
     39 
     40 
     41 def get_paint_ids_with_finish(finish_id):
     42     if finish_id not in ALL_PAINT_FINISHES:
     43         raise ValueError("Invalid finish ID '{0}'".format(finish_id))
     44     paint_ids = [ paint_id for paint_id, paint in _PaintsDataLoader.GetData().iteritems() if paint.finish == finish_id ]
     45     return paint_ids
     46 
     47 
     48 def get_paint_ids_with_rarity(rarity_id):
     49     if rarity_id not in ALL_PAINT_RARITIES:
     50         raise ValueError("Invalid rarity ID '{0}'".format(rarity_id))
     51     paint_ids = [ paint_id for paint_id, paint in _PaintsDataLoader.GetData().iteritems() if paint.rarity == rarity_id ]
     52     return paint_ids
     53 
     54 
     55 def get_paint_ids_with_hue_category(hue_category_id):
     56     _get_hue_category(hue_category_id)
     57     paint_ids = [ paint_id for paint_id, paint in _PaintsDataLoader.GetData().iteritems() if paint.hueCategory == hue_category_id ]
     58     return paint_ids
     59 
     60 
     61 def get_paint_material_name(paint_id):
     62     return _get_paint(paint_id).materialName
     63 
     64 
     65 def get_material_rgba(paint_id):
     66     material_name = get_paint_material_name(paint_id)
     67     material = trinity.Load('res:/dx9/model/SpaceObjectFactory/materials/{}.red'.format(material_name))
     68     return material.parameters[0].value
     69 
     70 
     71 def get_paint_brand_name_id(paint_id):
     72     return _get_paint(paint_id).paintNameID
     73 
     74 
     75 def get_paint_finish(paint_id):
     76     return _get_paint(paint_id).finish
     77 
     78 
     79 def get_paint_rarity(paint_id):
     80     return _get_paint(paint_id).rarity
     81 
     82 
     83 def get_paint_hue_category(paint_id):
     84     return _get_paint(paint_id).hueCategory
     85 
     86 
     87 def _get_hue_category(hue_category_id):
     88     hue_category_data = _HueCategoriesDataLoader.GetData()
     89     try:
     90         return hue_category_data[hue_category_id]
     91     except KeyError:
     92         raise HueCategoryDoesNotExistError(hue_category_id)
     93 
     94 
     95 def get_hue_category_ids():
     96     return _HueCategoriesDataLoader.GetData().keys()
     97 
     98 
     99 def get_hue_category_message_id(hue_category_id):
    100     return _get_hue_category(hue_category_id).hueNameID
    101 
    102 
    103 def get_hue_category_hue(hue_category_id):
    104     return _get_hue_category(hue_category_id).hue
    105 
    106 
    107 class PaintDataError(Exception):
    108     pass
    109 
    110 
    111 class PaintDoesNotExistError(PaintDataError):
    112 
    113     def __init__(self, paint_id):
    114         self.paint_id = paint_id
    115 
    116     def __str__(self):
    117         return "Paint ID '{0}' does not exist".format(self.paint_id)
    118 
    119 
    120 class HueCategoryDoesNotExistError(PaintDataError):
    121 
    122     def __init__(self, hue_category_id):
    123         self.hue_category_id = hue_category_id
    124 
    125     def __str__(self):
    126         return "Hue Category '{0}' does not exist".format(self.hue_category_id)