Class TROView

java.lang.Object
megamek.common.templates.TROView
Direct Known Subclasses:
AeroTROView, BattleArmorTROView, BattlefieldSupportAssetTROView, InfantryTROView, MekTROView, ProtoMekTROView, SupportVeeTROView, VehicleTROView

public class TROView extends Object
Fills in a template to produce a unit summary in TRO format.
  • Constructor Details

    • TROView

      protected TROView()
  • Method Details

    • createView

      public static TROView createView(Entity entity, ViewFormatting formatting)
    • getTemplateFileName

      @Nullable protected String getTemplateFileName(boolean html)
    • setModelData

      protected void setModelData(String key, Object data)
    • getModelData

      protected Object getModelData(String key)
    • initModel

      protected void initModel(EntityVerifier verifier)
    • processTemplate

      @Nullable public String processTemplate()
      Uses the template and supplied Entity to generate a TRO document
      Returns:
      The generated document. Returns null if there was an error that prevented the document from being generated. Check logs for reason.
    • addBasicData

      protected void addBasicData(Entity entity)
    • addEntityFluff

      protected void addEntityFluff(Entity entity)
    • formatSystemFluff

      public static String formatSystemFluff(System system, EntityFluff fluff, Supplier<String> altText)
      Builds the fluff name for a system component.
      Parameters:
      system - The system component
      fluff - The Entity's fluff object
      altText - 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

      protected void addMekVeeAeroFluff(Entity entity)
    • formatArmorType

      public static String formatArmorType(Entity entity, boolean trim)
    • formatArmorType

      protected String formatArmorType(int at, boolean trim)
    • 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 for
      provider - The function that retrieves the armor or structure value for the entity and location
      locSets - 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 Map with the armor/structure value mapped to the abbreviation of each of the location keys.
    • addPatchworkATs

      protected Map<String,String> addPatchworkATs(Entity entity, int[][] locSets)
    • addEquipment

      protected int addEquipment(Entity entity)
    • skipMount

      protected boolean skipMount(Mounted<?> mount, boolean includeAmmo)
      Test for whether the mount should be included in the equipment inventory section.
      Parameters:
      mount - The equipment mount
      includeAmmo - Whether to include ammo in the list
      Returns:
      Whether to list the equipment in the inventory section
    • addEquipment

      protected int addEquipment(Entity entity, boolean includeAmmo)
    • addFixedOmni

      protected void addFixedOmni(Entity entity)
    • addTransportBays

      protected void addTransportBays(Entity entity)
    • showFixedSystem

      protected boolean showFixedSystem(Entity entity, int index, int loc)
      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 for
      index - The system index of the critical slot
      loc - The slot location
      Returns:
      Whether to show this as a fixed system in an omni configuration
    • getSystemName

      protected String getSystemName(Entity entity, int index)
      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 for
      index - The system index of the critical slot
      Returns:
      The name of the system to display in the fixed equipment table
    • formatLocationTableEntry

      protected String formatLocationTableEntry(Entity entity, Mounted<?> mounted)
      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 for
      mounted - The mounted equipment
      Returns:
      The location name to use in the table.
    • formatTransporter

      @Nullable protected Map<String,Object> formatTransporter(Transporter transporter, String loc)
      Formats Transporter to 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 null for a type of Transporter that should not be shown.
    • stripNotes

      protected String stripNotes(String str)
      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