Interface SettingsAPI


public interface SettingsAPI
Author:
Alex Mosolov Copyright 2012 Fractal Softworks, LLC
  • Method Details

    • getBattleSize

      int getBattleSize()
    • createPerson

      PersonAPI createPerson()
      Can be used outside the campaign, unlike FactoryAPI.createPerson().
      Returns:
    • createCargoStack

      CargoStackAPI createCargoStack(CargoAPI.CargoItemType type, Object data, CargoAPI cargo)
    • createLabel

      LabelAPI createLabel(String text, String font)
    • getBonusXP

      float getBonusXP(String key)
    • getFloat

      float getFloat(String key)
    • getBoolean

      boolean getBoolean(String key)
    • optBoolean

      boolean optBoolean(String key, boolean defaultValue)
    • getScriptClassLoader

      ClassLoader getScriptClassLoader()
    • isCampaignSensorsOn

      boolean isCampaignSensorsOn()
    • isDevMode

      boolean isDevMode()
    • setDevMode

      void setDevMode(boolean devMode)
    • getColor

      Color getColor(String id)
    • getInstanceOfScript

      Object getInstanceOfScript(String className)
    • getString

      String getString(String category, String id)
      Gets a string from a given category in strings.json
      Parameters:
      category -
      id -
      Returns:
    • getSprite

      SpriteAPI getSprite(String filename)
      File must already have been loaded. Mostly useful for retrieving ship and weapon sprites and other such.
      Parameters:
      filename -
      Returns:
    • getSprite

      SpriteAPI getSprite(String category, String key)
      Gets a sprite loaded using the "graphics" section in data/config/settings.json.
      Parameters:
      category -
      key -
      Returns:
    • getSprite

      SpriteAPI getSprite(SpriteId id)
      Same as the method that takes (String category, String key). SpriteId is just a container class for category + id.
      Parameters:
      id -
      Returns:
    • getSpriteName

      String getSpriteName(String category, String id)
    • openStream

      InputStream openStream(String filename) throws IOException
      Use / instead of \ in paths for compatibility (required to work on OS X and Linux).
      Parameters:
      filename -
      Returns:
      Throws:
      IOException
    • loadText

      String loadText(String filename) throws IOException
      Use / instead of \ in paths for compatibility (required to work on OS X and Linux).
      Parameters:
      filename -
      Returns:
      Throws:
      IOException
    • loadJSON

      org.json.JSONObject loadJSON(String filename) throws IOException, org.json.JSONException
      Use / instead of \ in paths for compatibility (required to work on OS X and Linux).
      Parameters:
      filename -
      Returns:
      Throws:
      IOException
      org.json.JSONException
    • loadCSV

      org.json.JSONArray loadCSV(String filename) throws IOException, org.json.JSONException
      Returns an array of JSONObjects with keys corresponding to the columns in the csv file. Use / instead of \ in paths for compatibility (required to work on OS X and Linux).
      Parameters:
      filename -
      Returns:
      Throws:
      IOException
      org.json.JSONException
    • getMergedSpreadsheetDataForMod

      org.json.JSONArray getMergedSpreadsheetDataForMod(String idColumn, String path, String masterMod) throws IOException, org.json.JSONException
      Useful for building a mod that allows other mods to override some of its data. Merges on spreadsheet level only; rows with matching ids get replaced by non-master rows. If multiple non-master rows have the same id, one will be picked in an undefined manner.
      Parameters:
      idColumn - the column to be used as the key for merging spreadsheets.
      path - the location of the spreadsheet, i.e. "mydata/spreadsheet.csv".
      masterMod - name of the mod that has the master copy of the spreadsheet, which will be used as the base version to add to/modify during the merge.
      Returns:
      Throws:
      IOException
      org.json.JSONException
    • getMergedJSONForMod

      org.json.JSONObject getMergedJSONForMod(String path, String masterMod) throws IOException, org.json.JSONException
      Throws:
      IOException
      org.json.JSONException
    • getScreenWidth

      float getScreenWidth()
      Virtual pixels, i.e. divided by getScreenScaleMult().
      Returns:
    • getScreenHeight

      float getScreenHeight()
      Virtual pixels, i.e. divided by getScreenScaleMult().
      Returns:
    • getScreenWidthPixels

      float getScreenWidthPixels()
    • getScreenHeightPixels

      float getScreenHeightPixels()
    • getDescription

      Description getDescription(String id, Description.Type type)
      Gets entry from descriptions.csv.
      Parameters:
      id -
      type -
      Returns:
      description, or null if not found.
    • getCRPlugin

      CombatReadinessPlugin getCRPlugin()
    • getCodeFor

      int getCodeFor(String key)
    • getWeaponSpec

      WeaponSpecAPI getWeaponSpec(String weaponId)
    • loadTexture

      void loadTexture(String filename) throws IOException
      Throws:
      IOException
    • getTargetingRadius

      float getTargetingRadius(org.lwjgl.util.vector.Vector2f from, CombatEntityAPI target, boolean considerShield)
      Bit of a hack to have this method here. It's just a way to call into some unexposed utility code.
      Parameters:
      from -
      target -
      considerShield -
      Returns:
    • getVariant

      ShipVariantAPI getVariant(String variantId)
    • getPlugin

      Object getPlugin(String id)
      Plugins returned by this method are cached and persistent across multiple saves. They should not have any data members that point at campaign data or it will cause a memory leak.
      Parameters:
      id -
      Returns:
    • getSortedSkillIds

      List<String> getSortedSkillIds()
    • getSkillSpec

      SkillSpecAPI getSkillSpec(String skillId)
    • getString

      String getString(String key)
    • getAbilitySpec

      AbilitySpecAPI getAbilitySpec(String abilityId)
    • getSortedAbilityIds

      List<String> getSortedAbilityIds()
    • getBaseTravelSpeed

      float getBaseTravelSpeed()
    • getSpeedPerBurnLevel

      float getSpeedPerBurnLevel()
    • getUnitsPerLightYear

      float getUnitsPerLightYear()
    • getMaxShipsInFleet

      int getMaxShipsInFleet()
    • getTerrainSpec

      TerrainSpecAPI getTerrainSpec(String terrainId)
    • getEventSpec

      EventSpecAPI getEventSpec(String eventId)
    • getCustomEntitySpec

      CustomEntitySpecAPI getCustomEntitySpec(String id)
    • getCurrentState

      GameState getCurrentState()
    • getMaxSensorRange

      int getMaxSensorRange()
    • getMaxSensorRangeHyper

      int getMaxSensorRangeHyper()
    • getMaxSensorRange

      int getMaxSensorRange(LocationAPI loc)
    • getAllVariantIds

      List<String> getAllVariantIds()
    • getAptitudeIds

      List<String> getAptitudeIds()
    • getSkillIds

      List<String> getSkillIds()
    • getLevelupPlugin

      LevelupPlugin getLevelupPlugin()
    • getVersionString

      String getVersionString()
    • loadJSON

      org.json.JSONObject loadJSON(String filename, String modId) throws IOException, org.json.JSONException
      Throws:
      IOException
      org.json.JSONException
    • loadCSV

      org.json.JSONArray loadCSV(String filename, String modId) throws IOException, org.json.JSONException
      Throws:
      IOException
      org.json.JSONException
    • loadText

      String loadText(String filename, String modId) throws IOException, org.json.JSONException
      Throws:
      IOException
      org.json.JSONException
    • getModManager

      ModManagerAPI getModManager()
    • getBaseFleetSelectionRadius

      float getBaseFleetSelectionRadius()
    • getFleetSelectionRadiusPerUnitSize

      float getFleetSelectionRadiusPerUnitSize()
    • getMaxFleetSelectionRadius

      float getMaxFleetSelectionRadius()
    • getEntriesForRole

      List<RoleEntryAPI> getEntriesForRole(String factionId, String role)
    • addEntryForRole

      void addEntryForRole(String factionId, String role, String variantId, float weight)
    • removeEntryForRole

      void removeEntryForRole(String factionId, String role, String variantId)
    • getDefaultEntriesForRole

      List<RoleEntryAPI> getDefaultEntriesForRole(String role)
    • addDefaultEntryForRole

      void addDefaultEntryForRole(String role, String variantId, float weight)
    • removeDefaultEntryForRole

      void removeDefaultEntryForRole(String role, String variantId)
    • profilerBegin

      void profilerBegin(String id)
    • profilerEnd

      void profilerEnd()
    • profilerPrintResultsTree

      void profilerPrintResultsTree()
    • getAllPlanetSpecs

      List<PlanetSpecAPI> getAllPlanetSpecs()
    • getSpec

      Object getSpec(Class c, String id, boolean nullOnNotFound)
    • putSpec

      void putSpec(Class c, String id, Object spec)
    • getAllSpecs

      <T> Collection<T> getAllSpecs(Class<T> c)
    • getRoman

      String getRoman(int n)
      Parameters:
      n - 1 to 3999.
      Returns:
    • greekLetterReset

      void greekLetterReset()
    • getNextCoolGreekLetter

      String getNextCoolGreekLetter(Object context)
    • getNextGreekLetter

      String getNextGreekLetter(Object context)
    • getMarketConditionSpec

      MarketConditionSpecAPI getMarketConditionSpec(String conditionId)
    • createDefaultShipAI

      ShipAIPlugin createDefaultShipAI(ShipAPI ship, ShipAIConfig config)
    • getHullModSpec

      HullModSpecAPI getHullModSpec(String modId)
    • getFighterWingSpec

      FighterWingSpecAPI getFighterWingSpec(String wingId)
    • getAllHullModSpecs

      List<HullModSpecAPI> getAllHullModSpecs()
    • getAllFighterWingSpecs

      List<FighterWingSpecAPI> getAllFighterWingSpecs()
    • getAllWeaponSpecs

      List<WeaponSpecAPI> getAllWeaponSpecs()
    • getActuallyAllWeaponSpecs

      List<WeaponSpecAPI> getActuallyAllWeaponSpecs()
      Includes SYSTEM weapons and, well, everything.
      Returns:
    • isSoundEnabled

      boolean isSoundEnabled()
    • isInCampaignState

      boolean isInCampaignState()
    • isGeneratingNewGame

      boolean isGeneratingNewGame()
    • getAngleInDegreesFast

      float getAngleInDegreesFast(org.lwjgl.util.vector.Vector2f v)
    • getAngleInDegreesFast

      float getAngleInDegreesFast(org.lwjgl.util.vector.Vector2f from, org.lwjgl.util.vector.Vector2f to)
    • getCommoditySpec

      CommoditySpecAPI getCommoditySpec(String commodityId)
    • getHullSpec

      ShipHullSpecAPI getHullSpec(String hullId)
    • getFactionSpec

      FactionSpecAPI getFactionSpec(String id)
    • computeNumFighterBays

      int computeNumFighterBays(ShipVariantAPI variant)
    • isInGame

      boolean isInGame()
      For modding purposes, always returns true.
      Returns:
    • getNewPluginInstance

      Object getNewPluginInstance(String id)
    • getControlStringForAbilitySlot

      String getControlStringForAbilitySlot(int index)
    • getControlStringForEnumName

      String getControlStringForEnumName(String name)
      Total hack instead of moving the Controls enum out to the .api project. Use at own peril.
      Parameters:
      name -
      Returns:
    • isNewPlayer

      boolean isNewPlayer()
    • getIndustrySpec

      IndustrySpecAPI getIndustrySpec(String industryId)
    • getAllCommoditySpecs

      List<CommoditySpecAPI> getAllCommoditySpecs()
    • getInt

      int getInt(String key)
    • getAllIndustrySpecs

      List<IndustrySpecAPI> getAllIndustrySpecs()
    • getSpecialItemSpec

      SpecialItemSpecAPI getSpecialItemSpec(String itemId)
    • getAllSpecialItemSpecs

      List<SpecialItemSpecAPI> getAllSpecialItemSpecs()
    • getAllShipHullSpecs

      List<ShipHullSpecAPI> getAllShipHullSpecs()
    • getSprite

      SpriteAPI getSprite(String category, String id, boolean emptySpriteOnNotFound)
    • createEmptyVariant

      ShipVariantAPI createEmptyVariant(String hullVariantId, ShipHullSpecAPI hullSpec)
    • getHullIdToVariantListMap

      ListMap<String> getHullIdToVariantListMap()
      For default ship roles.
      Returns:
    • readTextFileFromCommon

      String readTextFileFromCommon(String filename) throws IOException
      Throws:
      IOException
    • writeTextFileToCommon

      void writeTextFileToCommon(String filename, String data) throws IOException
      Max size 1mb.
      Parameters:
      filename -
      data -
      Throws:
      IOException
    • fileExistsInCommon

      boolean fileExistsInCommon(String filename)
    • deleteTextFileFromCommon

      void deleteTextFileFromCommon(String filename)
    • getBasePlayerColor

      Color getBasePlayerColor()
    • getDesignTypeColor

      Color getDesignTypeColor(String designType)
    • doesVariantExist

      boolean doesVariantExist(String variantId)
    • addCommodityInfoToTooltip

      void addCommodityInfoToTooltip(TooltipMakerAPI tooltip, float initPad, CommoditySpecAPI spec, int max, boolean withText, boolean withSell, boolean withBuy)
    • getJSONObject

      org.json.JSONObject getJSONObject(String key) throws org.json.JSONException
      Throws:
      org.json.JSONException
    • getJSONArray

      org.json.JSONArray getJSONArray(String key) throws org.json.JSONException
      Throws:
      org.json.JSONException
    • createBaseFaction

      FactionAPI createBaseFaction(String factionId)
      Should be used when faction data needs to be accessed outside the campaign.
      Parameters:
      factionId -
      Returns:
    • getAllMarketConditionSpecs

      List<MarketConditionSpecAPI> getAllMarketConditionSpecs()
    • getAllSubmarketSpecs

      List<SubmarketSpecAPI> getAllSubmarketSpecs()
    • getMinArmorFraction

      float getMinArmorFraction()
    • getMaxArmorDamageReduction

      float getMaxArmorDamageReduction()
    • getShipSystemSpec

      ShipSystemSpecAPI getShipSystemSpec(String id)
    • getAllShipSystemSpecs

      List<ShipSystemSpecAPI> getAllShipSystemSpecs()
    • getScreenScaleMult

      float getScreenScaleMult()
    • getAASamples

      int getAASamples()
    • getMouseX

      int getMouseX()
      Converted to virtual screen coordinates, i.e. adjusted for screen scaling.
      Returns:
    • getMouseY

      int getMouseY()
      Converted to virtual screen coordinates, i.e. adjusted for screen scaling.
      Returns:
    • getShippingCapacity

      int getShippingCapacity(MarketAPI market, boolean inFaction)
    • getSettingsJSON

      org.json.JSONObject getSettingsJSON()
    • resetCached

      void resetCached()
      Must be called after making any changes to result of getSettingsJSON().
    • setFloat

      void setFloat(String key, Float value)
    • setBoolean

      void setBoolean(String key, Boolean value)
    • getAllMissionSpecs

      List<PersonMissionSpec> getAllMissionSpecs()
    • getMissionSpec

      PersonMissionSpec getMissionSpec(String id)
    • getAllBarEventSpecs

      List<BarEventSpec> getAllBarEventSpecs()
    • getBarEventSpec

      BarEventSpec getBarEventSpec(String id)
    • setAutoTurnMode

      void setAutoTurnMode(boolean autoTurnMode)
    • isAutoTurnMode

      boolean isAutoTurnMode()
    • isShowDamageFloaties

      boolean isShowDamageFloaties()
    • getFloatFromArray

      float getFloatFromArray(String key, int index)
    • getIntFromArray

      int getIntFromArray(String key, int index)
    • loadTextureConvertBlackToAlpha

      void loadTextureConvertBlackToAlpha(String filename) throws IOException
      Throws:
      IOException
    • getControlDescriptionForEnumName

      String getControlDescriptionForEnumName(String name)
    • pickShipAIPlugin

      ShipAIPlugin pickShipAIPlugin(FleetMemberAPI member, ShipAPI ship)
    • unloadTexture

      void unloadTexture(String filename)
    • profilerSetEnabled

      void profilerSetEnabled(boolean enabled)
    • profilerReset

      void profilerReset()
    • profilerRestore

      void profilerRestore()
    • getBrightPlayerColor

      Color getBrightPlayerColor()
    • getDarkPlayerColor

      Color getDarkPlayerColor()
    • forceMipmapsFor

      void forceMipmapsFor(String filename, boolean forceMipmaps) throws IOException
      Throws:
      IOException
    • getGameVersion

      String getGameVersion()
      Returns e.g. "0.95a-RC12"
      Returns:
    • computeStringWidth

      float computeStringWidth(String in, String font)
    • createTextField

      TextFieldAPI createTextField(String text, String font)
    • createCheckbox

      ButtonAPI createCheckbox(String text, ButtonAPI.UICheckboxSize size)
    • createCheckbox

      ButtonAPI createCheckbox(String text, String font, Color checkColor, ButtonAPI.UICheckboxSize size)
    • createCustom

      CustomPanelAPI createCustom(float width, float height, CustomUIPanelPlugin plugin)
    • getMissionScore

      int getMissionScore(String id)
    • createWeaponSlot

      WeaponSlotAPI createWeaponSlot(String id, WeaponAPI.WeaponType weaponType, WeaponAPI.WeaponSize slotSize, String slotTypeStr, String nodeId, org.lwjgl.util.vector.Vector2f nodePos, float angle, float arc)
    • getMergedSpreadsheetData

      org.json.JSONArray getMergedSpreadsheetData(String idColumn, String path) throws IOException, org.json.JSONException
      Throws:
      IOException
      org.json.JSONException
    • getMergedJSON

      org.json.JSONObject getMergedJSON(String path) throws IOException, org.json.JSONException
      Throws:
      IOException
      org.json.JSONException
    • setEasySensorBonus

      void setEasySensorBonus(float easySensorBonus)
    • isEnableShipExplosionWhiteout

      boolean isEnableShipExplosionWhiteout()
    • setEnableShipExplosionWhiteout

      void setEnableShipExplosionWhiteout(boolean enableShipExplosionWhiteout)
    • getSystemWeaponSpecs

      List<WeaponSpecAPI> getSystemWeaponSpecs()
    • getSpriteKeys

      List<String> getSpriteKeys(String category)
    • getSpriteKeys

      List<String> getSpriteKeys(String category, String listId)
    • loadJSON

      org.json.JSONObject loadJSON(String filename, boolean withMods) throws IOException, org.json.JSONException
      Throws:
      IOException
      org.json.JSONException
    • loadCSV

      org.json.JSONArray loadCSV(String filename, boolean withMods) throws IOException, org.json.JSONException
      Throws:
      IOException
      org.json.JSONException
    • getSensorRangeMaxHyper

      float getSensorRangeMaxHyper()
    • getSensorRangeMax

      float getSensorRangeMax()
    • loadFont

      void loadFont(String filename) throws IOException
      Throws:
      IOException
    • isStrafeKeyAToggle

      boolean isStrafeKeyAToggle()
    • getAllFactionSpecs

      List<FactionSpecAPI> getAllFactionSpecs()
    • getPersonaltySpec

      PersonalityAPI getPersonaltySpec(String id)
    • writeJSONToCommon

      void writeJSONToCommon(String filename, org.json.JSONObject json, boolean onlyIfChanged) throws IOException, org.json.JSONException
      Parameters:
      onlyIfChanged - should be used sparingly, for something where the file size is fairly small and the writes are common/time sensitive. If true, the write will also happen on a new thread. Can cause increased memory use if overused for large files.
      Throws:
      IOException
      org.json.JSONException
    • readJSONFromCommon

      org.json.JSONObject readJSONFromCommon(String filename, boolean putInWriteCache) throws IOException, org.json.JSONException
      Parameters:
      putInWriteCache - should only be set to true for files you intend to call writeJSONToCommon() for with onlyIfChanged == true. Otherwise, causes unnecessary memory use.
      Throws:
      IOException
      org.json.JSONException
    • getSimOpponents

      List<String> getSimOpponents()
    • getSimOpponentsDev

      List<String> getSimOpponentsDev()
    • getIndustrySupply

      Set<String> getIndustrySupply(String industryId)
      Returns:
      Set of commodity ids, no quantity information.
    • getIndustryDemand

      Set<String> getIndustryDemand(String industryId)
      Returns:
      Set of commodity ids, no quantity information.
    • showCodex

      void showCodex(String entryId)
      Can be called from anywhere. Will do nothing if the Codex is already open.
      Parameters:
      entryId -
    • showCodex

      void showCodex(CodexEntryPlugin tempEntry)
    • showCodex

      void showCodex(List<CodexEntryPlugin> tempEntries)
      Will show the first entry, but will add all of the entries temporarily, until the Codex is closed.
      Parameters:
      tempEntries -
    • showCodex

      void showCodex(FleetMemberAPI member)
    • createFleetMember

      FleetMemberAPI createFleetMember(FleetMemberType type, String variantOrWingId)
    • createFleetMember

      FleetMemberAPI createFleetMember(FleetMemberType type, ShipVariantAPI variant)
    • getAllTerrainSpecs

      List<TerrainSpecAPI> getAllTerrainSpecs()
    • createLocationToken

      SectorEntityToken createLocationToken(float x, float y)
    • hasDesignTypeColor

      boolean hasDesignTypeColor(String designType)
    • getFriendlyFireDanger

      float getFriendlyFireDanger(ShipAPI shooter, CombatEntityAPI target, org.lwjgl.util.vector.Vector2f from, org.lwjgl.util.vector.Vector2f to, float weaponSpeed, float burstFireDuration, float weaponRange)
    • getSafeMovementDir

      float getSafeMovementDir(ShipAPI ship)