1package com.fs.starfarer.api.campaign.impl.items;
3import java.util.ArrayList;
4import java.util.HashSet;
5import java.util.Iterator;
7import java.util.Random;
12import org.json.JSONArray;
13import org.json.JSONException;
14import org.json.JSONObject;
16import com.fs.starfarer.api.Global;
17import com.fs.starfarer.api.campaign.CargoStackAPI;
18import com.fs.starfarer.api.campaign.CargoTransferHandlerAPI;
19import com.fs.starfarer.api.campaign.econ.MarketAPI;
20import com.fs.starfarer.api.campaign.econ.SubmarketAPI;
21import com.fs.starfarer.api.combat.ShipHullSpecAPI;
22import com.fs.starfarer.api.graphics.SpriteAPI;
23import com.fs.starfarer.api.loading.Description;
24import com.fs.starfarer.api.loading.Description.Type;
25import com.fs.starfarer.api.ui.TooltipMakerAPI;
26import com.fs.starfarer.api.util.Misc;
27import com.fs.starfarer.api.util.WeightedRandomPicker;
44 List<String> result =
new ArrayList<String>();
58 public void render(
float x,
float y,
float w,
float h,
float alphaMult,
84 alphaMult * mult, glowMult * 0.5f * mult,
false);
85 renderer.
renderShipWithCorners(hullId,
null, blX, blY, tlX, tlY, trX, trY, brX, brY,
86 alphaMult * mult, glowMult * 0.5f * mult, !known);
99 alphaMult * 0.5f, 0f,
false);
128 return super.getPrice(market, submarket);
142 return super.getName();
155 super.createTooltip(tooltip, expanded, transferHandler, stackSource);
169 List<String> hulls =
new ArrayList<String>();
171 addShipList(tooltip,
"Ship hulls:", hulls, 1, opad);
180 addCostLabel(tooltip, opad, transferHandler, stackSource);
183 tooltip.
addPara(
"Already known", g, opad);
185 tooltip.
addPara(
"Right-click to learn", b, opad);
225 if (params ==
null || params.isEmpty())
return null;
227 if (!params.startsWith(
"{")) {
231 JSONObject json =
new JSONObject(params);
233 Set<String> tags =
new HashSet<String>();
234 if (json.has(
"tags")) {
235 JSONArray tagsArray = json.getJSONArray(
"tags");
236 for (
int i = 0; i < tagsArray.length(); i++) {
237 tags.add(tagsArray.getString(i));
245 public static String
pickShip(Set<String> tags, Random random) {
248 Iterator<ShipHullSpecAPI> iter = specs.iterator();
264 if (!tags.isEmpty()) {
265 iter = specs.iterator();
266 while (iter.hasNext()) {
268 for (String tag : tags) {
269 boolean not = tag.startsWith(
"!");
270 tag = not ? tag.substring(1) : tag;
271 boolean has = curr.
hasTag(tag);
static SettingsAPI getSettings()
static SoundPlayerAPI getSoundPlayer()
static SectorAPI getSector()
void addCostLabel(TooltipMakerAPI tooltip, float pad, CargoTransferHandlerAPI transferHandler, Object stackSource)
void addShipList(TooltipMakerAPI tooltip, String title, List< String > hulls, int max, float opad)
List< String > getProvidedShips()
List< String > getProvidedWeapons()
void performRightClickAction()
boolean hasRightClickAction()
void init(CargoStackAPI stack)
int getPrice(MarketAPI market, SubmarketAPI submarket)
static String pickShip(Set< String > tags, Random random)
boolean shouldRemoveOnRightClickAction()
List< String > getProvidedIndustries()
String resolveDropParamsToSpecificItemData(String params, Random random)
List< String > getProvidedFighters()
void render(float x, float y, float w, float h, float alphaMult, float glowMult, SpecialItemRendererAPI renderer)
void createTooltip(TooltipMakerAPI tooltip, boolean expanded, CargoTransferHandlerAPI transferHandler, Object stackSource)
String getText1FirstPara()
static Color getButtonTextColor()
static Color setAlpha(Color color, int alpha)
static Color getGrayColor()
static Color getHighlightColor()
static Color getPositiveHighlightColor()
Description getDescription(String id, Type type)
ShipHullSpecAPI getHullSpec(String hullId)
float getFloat(String key)
List< ShipHullSpecAPI > getAllShipHullSpecs()
SpriteAPI getSprite(String filename)
SoundAPI playUISound(String id, float pitch, float volume)
MessageDisplayAPI getMessageDisplay()
SpecialItemData getSpecialDataIfSpecial()
void addKnownShip(String hullId, boolean setTimestamp)
boolean knowsShip(String hullId)
void addMessage(String text)
FactionAPI getPlayerFaction()
CampaignUIAPI getCampaignUI()
void renderScanlinesWithCorners(float blX, float blY, float tlX, float tlY, float trX, float trY, float brX, float brY, float alphaMult, boolean additive)
void renderBGWithCorners(Color bgColor, float blX, float blY, float tlX, float tlY, float trX, float trY, float brX, float brY, float alphaMult, float glowMult, boolean additive)
void renderShipWithCorners(String hullOrWingId, Color bgColor, float blX, float blY, float tlX, float tlY, float trX, float trY, float brX, float brY, float alphaMult, float glowMult, boolean withSpotlight)
boolean hasTag(String tag)
String getNameWithDesignationWithDashClass()
String getDescriptionPrefix()
String getDescriptionId()
void setColor(Color color)
void setAlphaMult(float alphaMult)
void renderWithCorners(float blX, float blY, float tlX, float tlY, float trX, float trY, float brX, float brY)