Package megamek.common.loaders
Class MekSummaryCache
java.lang.Object
megamek.common.loaders.MekSummaryCache
Cache of the Mek summary information. Implemented as Singleton so a client and server running in the same process can
share it
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(MekSummaryCache.Listener listener) static voiddispose()getByUnitFileUUID(String unitFileUUID) intintstatic MekSummaryCachestatic MekSummaryCachegetInstance(boolean ignoreUnofficial) getLinkedAsset(MekSummary baseUnit) getLinkedAssetForUnitFileUUID(String baseUnitFileUUID) getLinkedBaseUnit(MekSummary asset) static MekSummarygetSummaryFromFile(File unitFile) Builds a fully populatedMekSummaryfrom a standalone unit file, without requiring the entire unit cache to be loaded.static FileGet the directory for the unit cache file.intbooleanbooleanvoidvoidloadMekData(boolean ignoreUnofficial) static voidrebuildUnitData(boolean ignoreUnofficial) Rebuilds the unit cache from scratch, ignoring any existing on-disk cache data.static voidrefreshUnitData(boolean ignoreUnofficial) Checks the unit files directory for any changes since the last time the unit cache was loaded.voidremoveListener(MekSummaryCache.Listener listener)
-
Field Details
-
FILENAME_UNITS_CACHE
- See Also:
-
FILENAME_LOOKUP
- See Also:
-
-
Method Details
-
getInstance
-
getInstance
-
refreshUnitData
public static void refreshUnitData(boolean ignoreUnofficial) Checks the unit files directory for any changes since the last time the unit cache was loaded. If there are any updates, the new cache is saved.- Parameters:
ignoreUnofficial- If true, skips unofficial directories
-
rebuildUnitData
public static void rebuildUnitData(boolean ignoreUnofficial) Rebuilds the unit cache from scratch, ignoring any existing on-disk cache data.- Parameters:
ignoreUnofficial- If true, skips unofficial directories
-
dispose
public static void dispose() -
getUnitCacheDir
Get the directory for the unit cache file.- Returns:
- The path to the directory containing the unit cache.
-
isInitialized
public boolean isInitialized() -
isLoading
public boolean isLoading() -
addListener
-
removeListener
-
getAllMeks
-
getMek
-
getAsset
- Parameters:
name- the unit name (chassis + model)- Returns:
- the Battlefield Support Asset summary with the given name, or
nullif none exists. UnlikegetMek(String), this returns the Asset form even when a base unit shares the same name.
-
getByUnitFileUUID
- Parameters:
unitFileUUID- a unit-file UUID- Returns:
- the unit summary with the given unit-file UUID, or
nullif none exists
-
getLinkedAsset
- Parameters:
baseUnit- a non-asset unit summary- Returns:
- the Battlefield Support Asset linked to the given base unit (whose
linkedUnitIdis the base unit's UUID), ornullif the base unit has no linked asset (or is itself an asset)
-
getLinkedAssetForUnitFileUUID
- Parameters:
baseUnitFileUUID- the base unit's unit-file UUID- Returns:
- the Battlefield Support Asset linked to the base unit with that UUID, or
nullif there is none
-
getLinkedBaseUnit
- Parameters:
asset- a Battlefield Support Asset summary- Returns:
- the base unit linked to the given asset (the unit whose UUID equals the asset's
linkedUnitId), ornullif the asset is standalone (or is not an asset)
-
getFailedFiles
-
loadMekData
public void loadMekData() -
loadMekData
public void loadMekData(boolean ignoreUnofficial) -
getSummaryFromFile
Builds a fully populatedMekSummaryfrom a standalone unit file, without requiring the entire unit cache to be loaded. The unit does not need to be part of the official cache.This is intended for tooling (such as the SVG mass printer) that needs to process arbitrary or custom
.blk/.mtffiles.- Parameters:
unitFile- the unit file to parse- Returns:
- a populated
MekSummary, ornullif the file could not be loaded
-
getCacheCount
public int getCacheCount() -
getFileCount
public int getFileCount() -
getZipCount
public int getZipCount()
-