Package megamek.common.templates
Class TROView
java.lang.Object
megamek.common.templates.TROView
- Direct Known Subclasses:
AeroTROView,BattleArmorTROView,BattlefieldSupportAssetTROView,InfantryTROView,MekTROView,ProtoMekTROView,SupportVeeTROView,VehicleTROView
Fills in a template to produce a unit summary in TRO format.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static enum -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddArmorStructureEntries(Entity entity, BiFunction<Entity, Integer, Integer> provider, int[][] locSets) Convenience method to format armor and structure values, consolidating right/left values into a single entry.protected voidaddBasicData(Entity entity) protected voidaddEntityFluff(Entity entity) protected intaddEquipment(Entity entity) protected intaddEquipment(Entity entity, boolean includeAmmo) protected voidaddFixedOmni(Entity entity) protected voidaddMekVeeAeroFluff(Entity entity) addPatchworkATs(Entity entity, int[][] locSets) protected voidaddTransportBays(Entity entity) static TROViewcreateView(Entity entity, ViewFormatting formatting) protected StringformatArmorType(int at, boolean trim) static StringformatArmorType(Entity entity, boolean trim) protected StringformatLocationTableEntry(Entity entity, Mounted<?> mounted) Formats displayable location name for use in equipment table.static StringformatSystemFluff(System system, EntityFluff fluff, Supplier<String> altText) Builds the fluff name for a system component.formatTransporter(Transporter transporter, String loc) FormatsTransporterto display as a row in an equipment table.booleanprotected ObjectgetModelData(String key) protected StringgetSystemName(Entity entity, int index) Used to show the name of fixed system critical slots in an omni unit.protected StringgetTemplateFileName(boolean html) protected voidinitModel(EntityVerifier verifier) Uses the template and suppliedEntityto generate a TRO documentvoidsetIncludeFluff(boolean includeFluff) Sets whether to include the fluff section when processing the templateprotected voidsetModelData(String key, Object data) protected booleanshowFixedSystem(Entity entity, int index, int loc) Used to determine whether system crits should be shown when detailing fixed equipment in an omni unit.protected booleanTest for whether the mount should be included in the equipment inventory section.protected StringstripNotes(String str) Removes parenthetical and bracketed notes from a String, except parenthetical notes that begin with a digit.
-
Constructor Details
-
TROView
protected TROView()
-
-
Method Details
-
createView
-
getTemplateFileName
-
setModelData
-
getModelData
-
initModel
-
processTemplate
Uses the template and suppliedEntityto generate a TRO document- Returns:
- The generated document. Returns
nullif there was an error that prevented the document from being generated. Check logs for reason.
-
addBasicData
-
addEntityFluff
-
formatSystemFluff
Builds the fluff name for a system component.- Parameters:
system- The system componentfluff- TheEntity's fluff objectaltText- Alternate text that will be used if neither fluff field is set.- Returns:
- The fluff display name, which consists of the manufacturer and the model separated by a space. If either is missing it is left out.
-
addMekVeeAeroFluff
-
formatArmorType
-
formatArmorType
-
addArmorStructureEntries
protected Map<String,String> addArmorStructureEntries(Entity entity, BiFunction<Entity, Integer, Integer> provider, int[][] locSets) Convenience method to format armor and structure values, consolidating right/left values into a single entry. In most cases the right and left armor values are the same, in which case only a single value is used. If the values do not match they are both (or all, in the case of tripod mek legs) given separated by slashes.- Parameters:
entity- The entity to collect structure or armor values forprovider- The function that retrieves the armor or structure value for the entity and locationlocSets- A two-dimensional array that groups locations that should appear on the same line. Any location that is not legal for the unit (e.g. center leg on non-tripods) is ignored. If the first location in a group is illegal, the entire group is skipped.- Returns:
- A
Mapwith the armor/structure value mapped to the abbreviation of each of the location keys.
-
addPatchworkATs
-
addEquipment
-
skipMount
Test for whether the mount should be included in the equipment inventory section.- Parameters:
mount- The equipment mountincludeAmmo- Whether to include ammo in the list- Returns:
- Whether to list the equipment in the inventory section
-
addEquipment
-
addFixedOmni
-
addTransportBays
-
showFixedSystem
Used to determine whether system crits should be shown when detailing fixed equipment in an omni unit. By default, this is false, but meks override it to show some systems.- Parameters:
entity- The unit the TRO is forindex- The system index of the critical slotloc- The slot location- Returns:
- Whether to show this as a fixed system in an omni configuration
-
getSystemName
Used to show the name of fixed system critical slots in an omni unit. This is only used for Meks, and returns a default value of "Unknown System" for other units.- Parameters:
entity- The unit the TRO is forindex- The system index of the critical slot- Returns:
- The name of the system to display in the fixed equipment table
-
formatLocationTableEntry
Formats displayable location name for use in equipment table. The format of the name can vary by unit type due to available space based on number of columns, and in some cases the official TROs have different location names than the ones used by MM.- Parameters:
entity- The entity the TRO is created formounted- The mounted equipment- Returns:
- The location name to use in the table.
-
formatTransporter
FormatsTransporterto display as a row in an equipment table. Any other than bays and troop space are skipped to avoid showing BA handles and such.- Parameters:
transporter- The transporter to show.loc- The location name to display on the table.- Returns:
- A map of values used by the equipment tables (omni fixed and pod/non-omni). Returns
nullfor a type ofTransporterthat should not be shown.
-
stripNotes
Removes parenthetical and bracketed notes from a String, except parenthetical notes that begin with a digit. These are assumed to be a marker of equipment size and left intact.- Parameters:
str- The String to process- Returns:
- The same String with notes removed
-
setIncludeFluff
public void setIncludeFluff(boolean includeFluff) Sets whether to include the fluff section when processing the template- Parameters:
includeFluff- Whether to include the fluff section
-
getIncludeFluff
public boolean getIncludeFluff()- Returns:
- Whether the fluff section will be included when processing the template
-