1package com.fs.starfarer.api.campaign.impl.items;
4import java.util.ArrayList;
6import java.util.Random;
8import org.json.JSONException;
10import com.fs.starfarer.api.Global;
11import com.fs.starfarer.api.campaign.CargoStackAPI;
12import com.fs.starfarer.api.campaign.CargoTransferHandlerAPI;
13import com.fs.starfarer.api.campaign.SpecialItemPlugin;
14import com.fs.starfarer.api.campaign.SpecialItemSpecAPI;
15import com.fs.starfarer.api.campaign.SubmarketPlugin.TransferAction;
16import com.fs.starfarer.api.campaign.econ.MarketAPI;
17import com.fs.starfarer.api.campaign.econ.SubmarketAPI;
18import com.fs.starfarer.api.combat.ShipHullSpecAPI;
19import com.fs.starfarer.api.impl.campaign.ids.Tags;
20import com.fs.starfarer.api.loading.FighterWingSpecAPI;
21import com.fs.starfarer.api.loading.WeaponSpecAPI;
22import com.fs.starfarer.api.ui.LabelAPI;
23import com.fs.starfarer.api.ui.TooltipMakerAPI;
24import com.fs.starfarer.api.util.Highlights;
25import com.fs.starfarer.api.util.Misc;
59 boolean useGray =
true;
63 createTooltip(tooltip, expanded, transferHandler, stackSource, useGray);
71 Misc.addDesignTypePara(tooltip, design, opad);
74 Color c = Misc.getTextColor();
75 if (useGray) c = Misc.getGrayColor();
80 addCostLabel(tooltip, opad, transferHandler, stackSource);
96 public int getPrice(MarketAPI market, SubmarketAPI submarket) {
114 LabelAPI label = tooltip.addPara(data.text, pad);
115 if (data.highlights !=
null) {
116 label.setHighlight(data.highlights.getText());
117 label.setHighlightColors(data.highlights.getColors());
122 public static class ItemCostLabelData {
124 public Highlights highlights;
129 String highlight =
null;
130 Highlights highlights =
null;
131 Color highlightColor = Misc.getHighlightColor();
132 TransferAction action = TransferAction.PLAYER_BUY;
133 if (transferHandler !=
null && stackSource == transferHandler.
getManifestOne()) {
134 action = TransferAction.PLAYER_SELL;
141 text =
"Can not remove item";
143 highlights =
new Highlights();
144 highlights.append(text, Misc.getNegativeHighlightColor());
146 ItemCostLabelData data =
new ItemCostLabelData();
148 data.highlights = highlights;
158 highlightColor = Misc.getNegativeHighlightColor();
162 highlights = transferHandler.
getSubmarketTradedWith().getPlugin().getIllegalTransferTextHighlights(
stack, TransferAction.PLAYER_BUY);
164 if (stackSource !=
null && transferHandler !=
null && !transferHandler.
isNoCost()) {
168 text =
"Sells for: " + Misc.getDGSCredits(cost) +
" per unit.";
169 highlight =
"" + Misc.getDGSCredits(cost);
173 text =
"Price: " + Misc.getDGSCredits(cost) +
" per unit.";
174 highlight =
"" + Misc.getDGSCredits(cost);
181 text =
"Base value: " + Misc.getDGSCredits(cost) +
" per unit.";
182 highlight =
"" + Misc.getDGSCredits(cost);
186 if (highlights ==
null) {
187 highlights =
new Highlights();
188 highlights.setText(highlight);
189 highlights.setColors(highlightColor);
192 ItemCostLabelData data =
new ItemCostLabelData();
194 data.highlights = highlights;
206 protected static interface BlueprintLister {
207 boolean isKnown(String
id);
208 String getNoun(
int num);
212 protected void addShipList(TooltipMakerAPI tooltip, String title, List<String> hulls,
int max,
float opad) {
214 public boolean isKnown(String
id) {
217 public String getNoun(
int num) {
218 if (num == 1)
return "hull";
221 public String
getName(String
id) {
223 return spec.getNameWithDesignationWithDashClass();
228 protected void addWeaponList(TooltipMakerAPI tooltip, String title, List<String> weapons,
int max,
float opad) {
230 public boolean isKnown(String
id) {
233 public String getNoun(
int num) {
234 if (num == 1)
return "weapon";
237 public String
getName(String
id) {
239 return spec.getWeaponName();
244 protected void addFighterList(TooltipMakerAPI tooltip, String title, List<String> wings,
int max,
float opad) {
246 public boolean isKnown(String
id) {
249 public String getNoun(
int num) {
250 if (num == 1)
return "fighter LPC";
251 return "fighter LPCs";
253 public String
getName(String
id) {
255 return spec.getWingName();
260 protected void addBlueprintList(TooltipMakerAPI tooltip, String title, List<String> ids,
int max,
float opad,
261 BlueprintLister lister) {
263 Color b = Misc.getButtonTextColor();
264 Color g = Misc.getGrayColor();
266 tooltip.addPara(title, opad);
272 int left = ids.size();
274 List<String> copy =
new ArrayList<String>();
275 for (String
id : ids) {
276 if (!lister.isKnown(
id)) copy.add(
id);
278 for (String
id : ids) {
279 if (lister.isKnown(
id)) copy.add(
id);
283 for (String
id : ids) {
284 boolean known = lister.isKnown(
id);
287 tooltip.addPara(tab + lister.getName(
id) +
" (known)", g, pad);
289 tooltip.addPara(tab + lister.getName(
id), b, pad);
293 if (ids.size() - left >= max - 1)
break;
296 tooltip.addPara(tab +
"None", pad);
299 String noun = lister.getNoun(left);
300 tooltip.addPara(tab +
"... and %s other " + noun +
"", pad, Misc.getHighlightColor(),
"" + left);
static SettingsAPI getSettings()
static SectorAPI getSector()
ItemCostLabelData getCostLabelData(CargoStackAPI stack, CargoTransferHandlerAPI transferHandler, Object stackSource)
void addCostLabel(TooltipMakerAPI tooltip, float pad, CargoTransferHandlerAPI transferHandler, Object stackSource)
void addWeaponList(TooltipMakerAPI tooltip, String title, List< String > weapons, int max, float opad)
SpecialItemSpecAPI getSpec()
int getPrice(MarketAPI market, SubmarketAPI submarket)
void addBlueprintList(TooltipMakerAPI tooltip, String title, List< String > ids, int max, float opad, BlueprintLister lister)
void addShipList(TooltipMakerAPI tooltip, String title, List< String > hulls, int max, float opad)
boolean hasRightClickAction()
void createTooltip(TooltipMakerAPI tooltip, boolean expanded, CargoTransferHandlerAPI transferHandler, Object stackSource, boolean useGray)
String resolveDropParamsToSpecificItemData(String params, Random random)
void init(CargoStackAPI stack)
boolean shouldRemoveOnRightClickAction()
boolean isTooltipExpandable()
void performRightClickAction()
void createTooltip(TooltipMakerAPI tooltip, boolean expanded, CargoTransferHandlerAPI transferHandler, Object stackSource)
void addFighterList(TooltipMakerAPI tooltip, String title, List< String > wings, int max, float opad)
void render(float x, float y, float w, float h, float alphaMult, float glowMult, SpecialItemRendererAPI renderer)
SpecialItemSpecAPI getSpecialItemSpec(String itemId)
ShipHullSpecAPI getHullSpec(String hullId)
float getFloat(String key)
FighterWingSpecAPI getFighterWingSpec(String wingId)
WeaponSpecAPI getWeaponSpec(String weaponId)
SpecialItemSpecAPI getSpecialItemSpecIfSpecial()
int getBaseValuePerUnit()
float computeCurrentSingleItemSellCost(CargoStackAPI stack)
float computeCurrentSingleItemBuyCost(CargoStackAPI stack)
SubmarketAPI getSubmarketTradedWith()
boolean hasTag(String tag)