Package com.fs.starfarer.api
Interface SettingsAPI
public interface SettingsAPI
- Author:
- Alex Mosolov Copyright 2012 Fractal Softworks, LLC
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCommodityInfoToTooltip
(TooltipMakerAPI tooltip, float initPad, CommoditySpecAPI spec, int max, boolean withText, boolean withSell, boolean withBuy) void
addDefaultEntryForRole
(String role, String variantId, float weight) void
addEntryForRole
(String factionId, String role, String variantId, float weight) int
computeNumFighterBays
(ShipVariantAPI variant) float
computeStringWidth
(String in, String font) createBaseFaction
(String factionId) Should be used when faction data needs to be accessed outside the campaign.createCargoStack
(CargoAPI.CargoItemType type, Object data, CargoAPI cargo) createCheckbox
(String text, ButtonAPI.UICheckboxSize size) createCheckbox
(String text, String font, Color checkColor, ButtonAPI.UICheckboxSize size) createCustom
(float width, float height, CustomUIPanelPlugin plugin) createDefaultShipAI
(ShipAPI ship, ShipAIConfig config) createEmptyVariant
(String hullVariantId, ShipHullSpecAPI hullSpec) createFleetMember
(FleetMemberType type, ShipVariantAPI variant) createFleetMember
(FleetMemberType type, String variantOrWingId) createLabel
(String text, String font) createLocationToken
(float x, float y) Can be used outside the campaign, unlike FactoryAPI.createPerson().createTextField
(String text, String font) createWeaponSlot
(String id, WeaponAPI.WeaponType weaponType, WeaponAPI.WeaponSize slotSize, String slotTypeStr, String nodeId, org.lwjgl.util.vector.Vector2f nodePos, float angle, float arc) void
deleteTextFileFromCommon
(String filename) boolean
doesVariantExist
(String variantId) boolean
fileExistsInCommon
(String filename) void
forceMipmapsFor
(String filename, boolean forceMipmaps) int
getAbilitySpec
(String abilityId) Includes SYSTEM weapons and, well, everything.<T> Collection<T>
getAllSpecs
(Class<T> c) float
getAngleInDegreesFast
(org.lwjgl.util.vector.Vector2f v) float
getAngleInDegreesFast
(org.lwjgl.util.vector.Vector2f from, org.lwjgl.util.vector.Vector2f to) float
float
int
float
getBonusXP
(String key) boolean
getBoolean
(String key) int
getCodeFor
(String key) getCommoditySpec
(String commodityId) getControlStringForAbilitySlot
(int index) Total hack instead of moving the Controls enum out to the .api project.getDescription
(String id, Description.Type type) Gets entry from descriptions.csv.getDesignTypeColor
(String designType) getEntriesForRole
(String factionId, String role) getEventSpec
(String eventId) getFactionSpec
(String id) getFighterWingSpec
(String wingId) float
float
float
getFloatFromArray
(String key, int index) float
getFriendlyFireDanger
(ShipAPI shooter, CombatEntityAPI target, org.lwjgl.util.vector.Vector2f from, org.lwjgl.util.vector.Vector2f to, float weaponSpeed, float burstFireDuration, float weaponRange) Returns e.g.For default ship roles.getHullModSpec
(String modId) getHullSpec
(String hullId) getIndustryDemand
(String industryId) getIndustrySpec
(String industryId) getIndustrySupply
(String industryId) getInstanceOfScript
(String className) int
int
getIntFromArray
(String key, int index) org.json.JSONArray
getJSONArray
(String key) org.json.JSONObject
getJSONObject
(String key) getMarketConditionSpec
(String conditionId) float
float
int
int
int
int
org.json.JSONObject
getMergedJSON
(String path) org.json.JSONObject
getMergedJSONForMod
(String path, String masterMod) org.json.JSONArray
getMergedSpreadsheetData
(String idColumn, String path) org.json.JSONArray
getMergedSpreadsheetDataForMod
(String idColumn, String path, String masterMod) Useful for building a mod that allows other mods to override some of its data.float
int
getMissionSpec
(String id) int
Converted to virtual screen coordinates, i.e.int
Converted to virtual screen coordinates, i.e.getNextCoolGreekLetter
(Object context) getNextGreekLetter
(Object context) Plugins returned by this method are cached and persistent across multiple saves.getRoman
(int n) float
getSafeMovementDir
(ShipAPI ship) float
Virtual pixels, i.e.float
float
float
Virtual pixels, i.e.float
float
float
org.json.JSONObject
int
getShippingCapacity
(MarketAPI market, boolean inFaction) getSkillSpec
(String skillId) getSpecialItemSpec
(String itemId) float
Same as the method that takes (String category, String key).File must already have been loaded.Gets a sprite loaded using the "graphics" section in data/config/settings.json.getSpriteKeys
(String category) getSpriteKeys
(String category, String listId) getSpriteName
(String category, String id) Gets a string from a given category in strings.jsonfloat
getTargetingRadius
(org.lwjgl.util.vector.Vector2f from, CombatEntityAPI target, boolean considerShield) Bit of a hack to have this method here.getTerrainSpec
(String terrainId) float
getVariant
(String variantId) getWeaponSpec
(String weaponId) void
boolean
hasDesignTypeColor
(String designType) boolean
boolean
boolean
boolean
boolean
boolean
boolean
isInGame()
For modding purposes, always returns true.boolean
boolean
boolean
boolean
org.json.JSONArray
Returns an array of JSONObjects with keys corresponding to the columns in the csv file.org.json.JSONArray
org.json.JSONArray
void
org.json.JSONObject
Use / instead of \ in paths for compatibility (required to work on OS X and Linux).org.json.JSONObject
org.json.JSONObject
Use / instead of \ in paths for compatibility (required to work on OS X and Linux).void
loadTexture
(String filename) void
loadTextureConvertBlackToAlpha
(String filename) openStream
(String filename) Use / instead of \ in paths for compatibility (required to work on OS X and Linux).boolean
optBoolean
(String key, boolean defaultValue) pickShipAIPlugin
(FleetMemberAPI member, ShipAPI ship) void
profilerBegin
(String id) void
void
void
void
void
profilerSetEnabled
(boolean enabled) void
org.json.JSONObject
readJSONFromCommon
(String filename, boolean putInWriteCache) readTextFileFromCommon
(String filename) void
removeDefaultEntryForRole
(String role, String variantId) void
removeEntryForRole
(String factionId, String role, String variantId) void
Must be called after making any changes to result of getSettingsJSON().void
setAutoTurnMode
(boolean autoTurnMode) void
setBoolean
(String key, Boolean value) void
setDevMode
(boolean devMode) void
setEasySensorBonus
(float easySensorBonus) void
setEnableShipExplosionWhiteout
(boolean enableShipExplosionWhiteout) void
void
showCodex
(FleetMemberAPI member) void
showCodex
(CodexEntryPlugin tempEntry) void
Can be called from anywhere.void
showCodex
(List<CodexEntryPlugin> tempEntries) Will show the first entry, but will add all of the entries temporarily, until the Codex is closed.void
unloadTexture
(String filename) void
writeJSONToCommon
(String filename, org.json.JSONObject json, boolean onlyIfChanged) void
writeTextFileToCommon
(String filename, String data) Max size 1mb.
-
Method Details
-
getBattleSize
int getBattleSize() -
createPerson
PersonAPI createPerson()Can be used outside the campaign, unlike FactoryAPI.createPerson().- Returns:
-
createCargoStack
-
createLabel
-
getBonusXP
-
getFloat
-
getBoolean
-
optBoolean
-
getScriptClassLoader
ClassLoader getScriptClassLoader() -
isCampaignSensorsOn
boolean isCampaignSensorsOn() -
isDevMode
boolean isDevMode() -
setDevMode
void setDevMode(boolean devMode) -
getColor
-
getInstanceOfScript
-
getString
Gets a string from a given category in strings.json- Parameters:
category
-id
-- Returns:
-
getSprite
File must already have been loaded. Mostly useful for retrieving ship and weapon sprites and other such.- Parameters:
filename
-- Returns:
-
getSprite
Gets a sprite loaded using the "graphics" section in data/config/settings.json.- Parameters:
category
-key
-- Returns:
-
getSprite
Same as the method that takes (String category, String key). SpriteId is just a container class for category + id.- Parameters:
id
-- Returns:
-
getSpriteName
-
openStream
Use / instead of \ in paths for compatibility (required to work on OS X and Linux).- Parameters:
filename
-- Returns:
- Throws:
IOException
-
loadText
Use / instead of \ in paths for compatibility (required to work on OS X and Linux).- Parameters:
filename
-- Returns:
- Throws:
IOException
-
loadJSON
Use / instead of \ in paths for compatibility (required to work on OS X and Linux).- Parameters:
filename
-- Returns:
- Throws:
IOException
org.json.JSONException
-
loadCSV
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
Gets entry from descriptions.csv.- Parameters:
id
-type
-- Returns:
- description, or null if not found.
-
getCRPlugin
CombatReadinessPlugin getCRPlugin() -
getCodeFor
-
getWeaponSpec
-
loadTexture
- 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
-
getPlugin
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
-
getSkillSpec
-
getString
-
getAbilitySpec
-
getSortedAbilityIds
-
getBaseTravelSpeed
float getBaseTravelSpeed() -
getSpeedPerBurnLevel
float getSpeedPerBurnLevel() -
getUnitsPerLightYear
float getUnitsPerLightYear() -
getMaxShipsInFleet
int getMaxShipsInFleet() -
getTerrainSpec
-
getEventSpec
-
getCustomEntitySpec
-
getCurrentState
GameState getCurrentState() -
getMaxSensorRange
int getMaxSensorRange() -
getMaxSensorRangeHyper
int getMaxSensorRangeHyper() -
getMaxSensorRange
-
getAllVariantIds
-
getAptitudeIds
-
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
- Throws:
IOException
org.json.JSONException
-
getModManager
ModManagerAPI getModManager() -
getBaseFleetSelectionRadius
float getBaseFleetSelectionRadius() -
getFleetSelectionRadiusPerUnitSize
float getFleetSelectionRadiusPerUnitSize() -
getMaxFleetSelectionRadius
float getMaxFleetSelectionRadius() -
getEntriesForRole
-
addEntryForRole
-
removeEntryForRole
-
getDefaultEntriesForRole
-
addDefaultEntryForRole
-
removeDefaultEntryForRole
-
profilerBegin
-
profilerEnd
void profilerEnd() -
profilerPrintResultsTree
void profilerPrintResultsTree() -
getAllPlanetSpecs
List<PlanetSpecAPI> getAllPlanetSpecs() -
getSpec
-
putSpec
-
getAllSpecs
-
getRoman
- Parameters:
n
- 1 to 3999.- Returns:
-
greekLetterReset
void greekLetterReset() -
getNextCoolGreekLetter
-
getNextGreekLetter
-
getMarketConditionSpec
-
createDefaultShipAI
-
getHullModSpec
-
getFighterWingSpec
-
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
-
getHullSpec
-
getFactionSpec
-
computeNumFighterBays
-
isInGame
boolean isInGame()For modding purposes, always returns true.- Returns:
-
getNewPluginInstance
-
getControlStringForAbilitySlot
-
getControlStringForEnumName
Total hack instead of moving the Controls enum out to the .api project. Use at own peril.- Parameters:
name
-- Returns:
-
isNewPlayer
boolean isNewPlayer() -
getIndustrySpec
-
getAllCommoditySpecs
List<CommoditySpecAPI> getAllCommoditySpecs() -
getInt
-
getAllIndustrySpecs
List<IndustrySpecAPI> getAllIndustrySpecs() -
getSpecialItemSpec
-
getAllSpecialItemSpecs
List<SpecialItemSpecAPI> getAllSpecialItemSpecs() -
getAllShipHullSpecs
List<ShipHullSpecAPI> getAllShipHullSpecs() -
getSprite
-
createEmptyVariant
-
getHullIdToVariantListMap
For default ship roles.- Returns:
-
readTextFileFromCommon
- Throws:
IOException
-
writeTextFileToCommon
Max size 1mb.- Parameters:
filename
-data
-- Throws:
IOException
-
fileExistsInCommon
-
deleteTextFileFromCommon
-
getBasePlayerColor
Color getBasePlayerColor() -
getDesignTypeColor
-
doesVariantExist
-
addCommodityInfoToTooltip
void addCommodityInfoToTooltip(TooltipMakerAPI tooltip, float initPad, CommoditySpecAPI spec, int max, boolean withText, boolean withSell, boolean withBuy) -
getJSONObject
- Throws:
org.json.JSONException
-
getJSONArray
- Throws:
org.json.JSONException
-
createBaseFaction
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
-
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
-
getSettingsJSON
org.json.JSONObject getSettingsJSON() -
resetCached
void resetCached()Must be called after making any changes to result of getSettingsJSON(). -
setFloat
-
setBoolean
-
getAllMissionSpecs
List<PersonMissionSpec> getAllMissionSpecs() -
getMissionSpec
-
getAllBarEventSpecs
List<BarEventSpec> getAllBarEventSpecs() -
getBarEventSpec
-
setAutoTurnMode
void setAutoTurnMode(boolean autoTurnMode) -
isAutoTurnMode
boolean isAutoTurnMode() -
isShowDamageFloaties
boolean isShowDamageFloaties() -
getFloatFromArray
-
getIntFromArray
-
loadTextureConvertBlackToAlpha
- Throws:
IOException
-
getControlDescriptionForEnumName
-
pickShipAIPlugin
-
unloadTexture
-
profilerSetEnabled
void profilerSetEnabled(boolean enabled) -
profilerReset
void profilerReset() -
profilerRestore
void profilerRestore() -
getBrightPlayerColor
Color getBrightPlayerColor() -
getDarkPlayerColor
Color getDarkPlayerColor() -
forceMipmapsFor
- Throws:
IOException
-
getGameVersion
String getGameVersion()Returns e.g. "0.95a-RC12"- Returns:
-
computeStringWidth
-
createTextField
-
createCheckbox
-
createCheckbox
-
createCustom
-
getMissionScore
-
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
- Throws:
IOException
org.json.JSONException
-
setEasySensorBonus
void setEasySensorBonus(float easySensorBonus) -
isEnableShipExplosionWhiteout
boolean isEnableShipExplosionWhiteout() -
setEnableShipExplosionWhiteout
void setEnableShipExplosionWhiteout(boolean enableShipExplosionWhiteout) -
getSystemWeaponSpecs
List<WeaponSpecAPI> getSystemWeaponSpecs() -
getSpriteKeys
-
getSpriteKeys
-
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
- Throws:
IOException
-
isStrafeKeyAToggle
boolean isStrafeKeyAToggle() -
getAllFactionSpecs
List<FactionSpecAPI> getAllFactionSpecs() -
getPersonaltySpec
-
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
-
getSimOpponentsDev
-
getIndustrySupply
- Returns:
- Set of commodity ids, no quantity information.
-
getIndustryDemand
- Returns:
- Set of commodity ids, no quantity information.
-
showCodex
Can be called from anywhere. Will do nothing if the Codex is already open.- Parameters:
entryId
-
-
showCodex
-
showCodex
Will show the first entry, but will add all of the entries temporarily, until the Codex is closed.- Parameters:
tempEntries
-
-
showCodex
-
createFleetMember
-
createFleetMember
-
getAllTerrainSpecs
List<TerrainSpecAPI> getAllTerrainSpecs() -
createLocationToken
-
hasDesignTypeColor
-
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
-