Class CConfig

java.lang.Object
megameklab.util.CConfig

public final class CConfig extends Object
Class for Client's configuration.
  • Field Details

  • Method Details

    • load

      public static void load()
      Loads the MegaMekLab configuration.
    • importSettings

      public static void importSettings(MenuBarOwner menuBarOwner, File settingsFile)
      Tries to import settings from the given properties file. When successful, also applies some of the settings and shows a popup message.
      Parameters:
      menuBarOwner - The MenuBar owner frame calling this
      settingsFile - The file (should always be megameklab.properties in another MML install)
    • loadConfigFile

      public static void loadConfigFile()
      Loads the Config file.
    • ensureConfigFileExists

      public static void ensureConfigFileExists()
      Creates a new Config file, and directories, if it is missing.
    • getParam

      public static String getParam(String param, String defaultVal)
      Get a config value, with a default value to be used if the value is not found.
      Parameters:
      param - The key
      defaultVal - The value to return if the entry is not found
      Returns:
      The value associated with the key
    • getParam

      public static String getParam(String param)
      Get a config value.
      Parameters:
      param - The key
      Returns:
      The value associated with the key. If not found, an empty String is returned
    • setParam

      public static void setParam(String param, String value)
      Set a config value.
      Parameters:
      param - the name of the parameter
      value - the value to set the parameter to
    • getIntParam

      public static int getIntParam(String param, int defaultVal)
      Return the int value of a given config property. Return the provided default value if the property is a non-number.
      Parameters:
      param - The parameter name
      defaultVal - The value to return if the property does not exist or is not a valid string representation of the integer
      Returns:
      The integer value of the property
    • getIntParam

      public static int getIntParam(String param)
      Return the int value of a given config property. Return a 0 if the property is a non-number.
      Parameters:
      param - The parameter name
      Returns:
      The integer value of the property
    • getEnumParam

      public static <E extends Enum<E>> E getEnumParam(String key, Class<E> enumClass, E defaultVal)
      Return the enum value of a given config property.
    • setEnumParam

      @Deprecated(since="0.51.0", forRemoval=true) public static <E extends Enum<E>> void setEnumParam(String key, E value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set a config value to the name of the enum.
      Parameters:
      key - the name of the parameter
      value - the value to set the parameter to
    • getBooleanParam

      public static boolean getBooleanParam(String param)
      Parameters:
      param - the parameter's name
      Returns:
      the boolean value of a given config property. Return a false if the property does not exist.
    • saveConfig

      public static void saveConfig()
      Write the config file out to ./data/mwconfig.txt.
    • getForegroundColor

      public static Color getForegroundColor(String fieldName)
    • getBackgroundColor

      public static Color getBackgroundColor(String fieldName)
    • setMostRecentFile

      public static void setMostRecentFile(String newFile)
      Adds a file to the most recent files list.
      Parameters:
      newFile - The path to the file to add.
    • setMostRecentFile

      public static void setMostRecentFile(String newFile, String entryName)
      Adds a file (and optionally an entry name if it's a ZIP) to the most recent files list.
      Parameters:
      newFile - The path to the file.
      entryName - The name of the entry within the file (e.g., for ZIP files). Can be null.
    • getRecentFiles

      public static List<String> getRecentFiles()
      Returns:
      A list of the most recently loaded unit files.
    • scaleUnits

      public static RSScale scaleUnits()
      Returns:
      The currently selected scale units for record sheet printing
    • formatScale

      public static String formatScale(double val, boolean showUnits)
      Applies the scale factor to a value and optionally adds the unit abbreviation
      Parameters:
      val - The base distance (standard hexes)
      showUnits - Whether to append the unit abbreviation
      Returns:
      A String representation of the scaled value
    • getFileChooserSize

      public static Optional<Dimension> getFileChooserSize()
    • getFileChooserPosition

      public static Optional<Point> getFileChooserPosition()
    • writeFileChooserSettings

      public static void writeFileChooserSettings(JDialog dialog)
    • getForceBuildPosition

      public static Optional<Point> getForceBuildPosition()
    • writeForceBuildPosition

      public static void writeForceBuildPosition(JFrame frame)
    • getMainUiWindowSize

      public static Optional<Dimension> getMainUiWindowSize(MenuBarOwner mainUi)
    • getMainUiWindowPosition

      public static Optional<Point> getMainUiWindowPosition(MenuBarOwner mainUi)
    • getNamedWindowSize

      @Deprecated(since="0.51.0", forRemoval=true) public static Optional<Dimension> getNamedWindowSize(String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • writeMainUiWindowSettings

      public static void writeMainUiWindowSettings(MenuBarOwner mainUi)
    • writeNamedWindowSize

      @Deprecated(since="0.51.0", forRemoval=true) public static void writeNamedWindowSize(String name, Window component)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getRecentFile

      public static String getRecentFile(int recentFileNumber)
    • getStartUpType

      public static MMLStartUp getStartUpType()
    • getMekNameArrangement

      public static MekChassisArrangement getMekNameArrangement()
    • includeLicense

      public static boolean includeLicense()
    • resetWindowPositions

      public static void resetWindowPositions()