1package com.fs.starfarer.api.campaign.impl.items;
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.Comparator;
6import java.util.Iterator;
7import java.util.LinkedHashSet;
13import com.fs.starfarer.api.Global;
14import com.fs.starfarer.api.campaign.CargoStackAPI;
15import com.fs.starfarer.api.campaign.CargoTransferHandlerAPI;
16import com.fs.starfarer.api.campaign.FactionAPI;
17import com.fs.starfarer.api.campaign.econ.MarketAPI;
18import com.fs.starfarer.api.campaign.econ.SubmarketAPI;
19import com.fs.starfarer.api.combat.ShipHullSpecAPI;
20import com.fs.starfarer.api.graphics.SpriteAPI;
21import com.fs.starfarer.api.loading.FighterWingSpecAPI;
22import com.fs.starfarer.api.loading.WeaponSpecAPI;
23import com.fs.starfarer.api.ui.TooltipMakerAPI;
24import com.fs.starfarer.api.util.Misc;
29 protected Set<String>
tags =
new LinkedHashSet<String>();
35 if (!param.isEmpty()) {
36 for (String tag : param.split(
",")) {
38 if (tag.isEmpty())
continue;
73 public void render(
float x,
float y,
float w,
float h,
float alphaMult,
87 float blX = cx - 12f - p;
88 float blY = cy - 22f - p;
89 float tlX = cx - 26f - p;
90 float tlY = cy + 19f + p;
91 float trX = cx + 20f + p;
92 float trY = cy + 24f + p;
93 float brX = cx + 34f + p;
94 float brY = cy - 9f - p;
99 boolean known =
areAllKnown(ships, weapons, fighters);
108 sprite.
setAlphaMult(alphaMult * glowMult * 0.5f * mult);
115 alphaMult * 0.5f, 0f,
false);
123 return super.getPrice(market, submarket);
128 return super.getName();
138 super.createTooltip(tooltip, expanded, transferHandler, stackSource);
155 float shipWeight = 0f;
156 float weaponWeight = 0f;
157 float fighterWeight = 0f;
161 float knownWeight = 0.25f;
162 for (String
id : ships) {
164 shipWeight += knownWeight;
169 for (String
id : weapons) {
171 weaponWeight += knownWeight;
176 for (String
id : fighters) {
178 fighterWeight += knownWeight;
184 float totalWeight = shipWeight + weaponWeight + fighterWeight;
185 if (totalWeight < knownWeight) totalWeight = knownWeight;
187 int maxShips = (int) Math.max(minPer, (shipWeight / totalWeight) * maxTotal);
188 int maxWeapons = (int) Math.max(minPer, (weaponWeight / totalWeight) * maxTotal);
189 int maxFighters = (int) Math.max(minPer, (fighterWeight / totalWeight) * maxTotal);
192 if (!ships.isEmpty()) {
193 addShipList(tooltip,
"Ship hulls:", ships, maxShips, opad);
195 if (!weapons.isEmpty()) {
196 addWeaponList(tooltip,
"Weapons:", weapons, maxWeapons, opad);
198 if (!fighters.isEmpty()) {
199 addFighterList(tooltip,
"Fighters:", fighters, maxFighters, opad);
204 addCostLabel(tooltip, opad, transferHandler, stackSource);
207 boolean known =
areAllKnown(ships, weapons, fighters);
209 tooltip.
addPara(
"All blueprints in package already known", g, opad);
211 tooltip.
addPara(
"Right-click to learn", b, opad);
216 protected boolean areAllKnown(List<String> ships, List<String> weapons, List<String> fighters) {
218 for (String hullId : ships) {
223 for (String weaponId : weapons) {
228 for (String wingId : fighters) {
238 return super.getTooltipWidth();
267 "All blueprints in package already known");
274 for (String
id : ships) {
278 for (String
id : weapons) {
282 for (String
id : fighters) {
309 Iterator<WeaponSpecAPI> iter = specs.iterator();
317 if (!
tags.isEmpty()) {
318 iter = specs.iterator();
319 while (iter.hasNext()) {
321 for (String tag :
tags) {
322 boolean not = tag.startsWith(
"!");
323 tag = not ? tag.substring(1) : tag;
324 boolean has = curr.
hasTag(tag);
333 Collections.sort(specs,
new Comparator<WeaponSpecAPI>() {
339 List<String> result =
new ArrayList<String>();
341 result.add(
spec.getWeaponId());
350 Iterator<ShipHullSpecAPI> iter = specs.iterator();
352 if (!
tags.isEmpty()) {
353 iter = specs.iterator();
354 while (iter.hasNext()) {
368 for (String tag :
tags) {
369 boolean not = tag.startsWith(
"!");
370 tag = not ? tag.substring(1) : tag;
371 boolean has = curr.
hasTag(tag);
382 Collections.sort(specs,
new Comparator<ShipHullSpecAPI>() {
388 List<String> result =
new ArrayList<String>();
390 result.add(
spec.getHullId());
399 Iterator<FighterWingSpecAPI> iter = specs.iterator();
401 if (!
tags.isEmpty()) {
402 iter = specs.iterator();
403 while (iter.hasNext()) {
405 for (String tag :
tags) {
406 boolean not = tag.startsWith(
"!");
407 tag = not ? tag.substring(1) : tag;
408 boolean has = curr.
hasTag(tag);
417 List<String> result =
new ArrayList<String>();
static SettingsAPI getSettings()
static boolean CODEX_TOOLTIP_MODE
static SoundPlayerAPI getSoundPlayer()
static SectorAPI getSector()
void addCostLabel(TooltipMakerAPI tooltip, float pad, CargoTransferHandlerAPI transferHandler, Object stackSource)
void addWeaponList(TooltipMakerAPI tooltip, String title, List< String > weapons, int max, float opad)
void addShipList(TooltipMakerAPI tooltip, String title, List< String > hulls, int max, float opad)
void addFighterList(TooltipMakerAPI tooltip, String title, List< String > wings, int max, float opad)
List< String > getProvidedFighters()
void init(CargoStackAPI stack)
void performRightClickAction()
static List< String > getWeaponIds(Set< String > tags)
transient List< String > cachedWeapons
boolean areAllKnown(List< String > ships, List< String > weapons, List< String > fighters)
boolean isTooltipExpandable()
int getPrice(MarketAPI market, SubmarketAPI submarket)
void render(float x, float y, float w, float h, float alphaMult, float glowMult, SpecialItemRendererAPI renderer)
boolean hasRightClickAction()
List< String > getProvidedShips()
transient List< String > cachedFighters
static List< String > getWingIds(Set< String > tags)
static List< String > getShipIds(Set< String > tags)
List< String > getProvidedIndustries()
boolean shouldRemoveOnRightClickAction()
transient List< String > cachedShips
List< String > getProvidedWeapons()
void createTooltip(TooltipMakerAPI tooltip, boolean expanded, CargoTransferHandlerAPI transferHandler, Object stackSource)
static Color getButtonTextColor()
static Color getGrayColor()
static Color getHighlightColor()
static Color getTooltipTitleAndLightHighlightColor()
static Color getPositiveHighlightColor()
List< WeaponSpecAPI > getAllWeaponSpecs()
List< ShipHullSpecAPI > getAllShipHullSpecs()
SpriteAPI getSprite(String filename)
List< FighterWingSpecAPI > getAllFighterWingSpecs()
SoundAPI playUISound(String id, float pitch, float volume)
MessageDisplayAPI getMessageDisplay()
boolean knowsWeapon(String weaponId)
void addKnownShip(String hullId, boolean setTimestamp)
void addKnownFighter(String wingId, boolean setTimestamp)
void addKnownWeapon(String weaponId, boolean setTimestamp)
boolean knowsFighter(String wingId)
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)
boolean hasTag(String tag)
void setAlphaMult(float alphaMult)
void renderWithCorners(float blX, float blY, float tlX, float tlY, float trX, float trY, float brX, float brY)
boolean hasTag(String tag)
boolean hasTag(String tag)