Starsector API
Loading...
Searching...
No Matches
MonthlyReportNodeTooltipCreator.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign;
2
3import java.awt.Color;
4import java.util.ArrayList;
5import java.util.List;
6
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.campaign.CargoAPI;
9import com.fs.starfarer.api.campaign.FactionAPI;
10import com.fs.starfarer.api.campaign.FactionProductionAPI;
11import com.fs.starfarer.api.campaign.econ.CommodityOnMarketAPI;
12import com.fs.starfarer.api.campaign.econ.MonthlyReport;
13import com.fs.starfarer.api.campaign.econ.MonthlyReport.FDNode;
14import com.fs.starfarer.api.fleet.FleetMemberAPI;
15import com.fs.starfarer.api.ui.Alignment;
16import com.fs.starfarer.api.ui.TooltipMakerAPI;
17import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
18import com.fs.starfarer.api.util.Misc;
19
20public class MonthlyReportNodeTooltipCreator implements TooltipCreator {
21
22 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
23 FDNode node = (FDNode) tooltipParam;
24
25 float pad = 3f;
26 float opad = 10f;
27
28 //tooltip.addTitle(node.name);
29
30 int crewSalary = Global.getSettings().getInt("crewSalary");
31 int marineSalary = Global.getSettings().getInt("marineSalary");
32 int officerBase = Global.getSettings().getInt("officerSalaryBase");
33 int officerPerLevel = Global.getSettings().getInt("officerSalaryPerLevel");
34 float storageFreeFraction = Global.getSettings().getFloat("storageFreeFraction");
35
36 Color h = Misc.getHighlightColor();
37
38 FactionAPI faction = Global.getSector().getPlayerFaction();
39 Color color = faction.getBaseUIColor();
40 Color dark = faction.getDarkUIColor();
41 Color grid = faction.getGridUIColor();
42 Color bright = faction.getBrightUIColor();
43
44 if (MonthlyReport.FLEET.equals(node.custom)) {
45 tooltip.addPara("Fleet-related income and expenses.", 0);
46 } else if (MonthlyReport.OUTPOSTS.equals(node.custom)) {
47 tooltip.addPara("Colony-related income and expenses.", 0);
48 } else if (MonthlyReport.PRODUCTION_WEAPONS.equals(node.custom)) {
49 tooltip.addPara("Weapons and fighter LPCs installed on produced ships.", 0);
50 } else if (MonthlyReport.PRODUCTION.equals(node.custom)) {
51 float currPad = 0f;
52 if (node.custom2 instanceof CargoAPI) {
53 CargoAPI cargo = (CargoAPI) node.custom2;
54 if (!cargo.isEmpty()) {
55 tooltip.addSectionHeading("Equipment", color, dark, Alignment.MID, currPad);
56 tooltip.showCargo(cargo, 10, true, opad);
57 currPad = opad;
58 }
59 List<FleetMemberAPI> ships = new ArrayList<FleetMemberAPI>();
60 ships.addAll(cargo.getMothballedShips().getMembersListCopy());
61 if (!ships.isEmpty()) {
62 tooltip.addSectionHeading("Ships", color, dark, Alignment.MID, currPad);
63 tooltip.showShips(ships, 10, true, opad);
64 }
65 }
66
67 FactionAPI pf = Global.getSector().getPlayerFaction();
68 FactionProductionAPI prod = pf.getProduction();
69 int accrued = prod.getAccruedProduction();
70 if (accrued > 0) {
71 tooltip.addPara("A total of %s worth of production effort has been put into projects that have not yet been " +
72 "completed.", currPad, Misc.getHighlightColor(), "" + Misc.getDGSCredits(accrued));
73 }
74
75 } else if (MonthlyReport.STOCKPILING.equals(node.custom)) {
76 if (node.custom2 instanceof CargoAPI) {
77 tooltip.addPara("Expenses incurred due to the use of local stockpiles to counter shortages.", 0);
78 CargoAPI cargo = (CargoAPI) node.custom2;
79 if (!cargo.isEmpty()) {
80 tooltip.addSectionHeading("Resources", color, dark, Alignment.MID, opad);
81 tooltip.showCargo(cargo, 10, true, opad);
82 }
83 List<FleetMemberAPI> ships = new ArrayList<FleetMemberAPI>();
84 ships.addAll(cargo.getMothballedShips().getMembersListCopy());
85 if (!ships.isEmpty()) {
86 tooltip.addSectionHeading("Ships", color, dark, Alignment.MID, opad);
87 tooltip.showShips(ships, 10, true, opad);
88 }
89 }
90 } else if (MonthlyReport.RESTOCKING.equals(node.custom)) {
91 if (node.custom2 instanceof CargoAPI) {
92 tooltip.addPara("Expenses incurred due to the need to restock local stockpiles to replace the resources drawn by your fleet.", 0);
93 CargoAPI cargo = (CargoAPI) node.custom2;
94 if (!cargo.isEmpty()) {
95 tooltip.addSectionHeading("Resources", color, dark, Alignment.MID, opad);
96 tooltip.showCargo(cargo, 10, true, opad);
97 }
98 List<FleetMemberAPI> ships = new ArrayList<FleetMemberAPI>();
99 ships.addAll(cargo.getMothballedShips().getMembersListCopy());
100 if (!ships.isEmpty()) {
101 tooltip.addSectionHeading("Ships", color, dark, Alignment.MID, opad);
102 tooltip.showShips(ships, 10, true, opad);
103 }
104 }
105 } else if (MonthlyReport.OFFICERS.equals(node.custom)) {
106 tooltip.addPara(
107 "Each officer receives a base salary of %s credits per month, plus %s credits per officer level.", 0,
108 h, Misc.getWithDGS(officerBase), Misc.getWithDGS(officerPerLevel));
109 } else if (MonthlyReport.ADMIN.equals(node.custom)) {
110 float f = Global.getSettings().getFloat("idleAdminSalaryMult");
111 tooltip.addPara(
112 "Each administrator receives a salary that depends on their skills. " +
113 "When not assigned to govern a colony, their salary is reduced to %s.", 0,
114 Misc.getHighlightColor(), "" + (int)Math.round(f * 100f) + "%");
115 } else if (MonthlyReport.CREW.equals(node.custom)) {
116 tooltip.addPara("Each crew member receives a monthly salary of %s credits.", 0,
117 h, Misc.getWithDGS(crewSalary));
118 } else if (MonthlyReport.MARINES.equals(node.custom)) {
119 tooltip.addPara("Each marine receives a monthly salary of %s credits.", 0,
120 h, Misc.getWithDGS(marineSalary));
121 } else if (MonthlyReport.LAST_MONTH_DEBT.equals(node.custom)) {
122 tooltip.addPara("Unpaid debt carried over from last month.", 0);
123 } else if (MonthlyReport.INDUSTRIES.equals(node.custom)) {
124 tooltip.addPara("Upkeep and income from industries and structures located at the outpost or colony.", 0);
125 } else if (MonthlyReport.INCENTIVES.equals(node.custom)) {
126 tooltip.addPara("Total spent on hazard pay and related growth incentives at the colony during the previous month.", 0);
127 } else if (MonthlyReport.EXPORTS.equals(node.custom)) {
128 tooltip.addPara("Income from out-of-faction exports by this outpost or colony. " +
129 "Smuggling and in-faction exports do not produce income.", 0);
130 } else if (MonthlyReport.STORAGE.equals(node.custom)) {
131// tooltip.addPara("Fees and expenses incurred by storing crew or materiel at a location. These include " +
132// "things like rent (for populated planets) and life support/maintenance/etc for storage at an " +
133// "otherwise-abandoned location.", 0);
134 tooltip.addPara("Fees and expenses incurred by storing crew or materiel at a location. Includes rent, security, and other such.", 0);
135
136 String percent = "" + (int) (storageFreeFraction * 100f) + "%";
137 tooltip.addPara("The monthly expenses are generally %s of the base value of what's in storage.", 10f, h,
138 percent);
139
140 tooltip.addPara("Storage at a colony under your control does not incur any fees.", 10f);
141 } else if (node.custom instanceof CommodityOnMarketAPI) {
142 float quantity = 0;
143 if (node.custom2 instanceof Float) {
144 quantity = (Float) node.custom2;
145 if (quantity < 1) quantity = 1;
146 }
147 String units = "units";
148 if (quantity <= 1) units = "unit";
149 CommodityOnMarketAPI com = (CommodityOnMarketAPI) node.custom;
150 tooltip.addPara("Approximately %s " + units + " of " + com.getCommodity().getName() + ".", 0f,
151 h, Misc.getWithDGS(quantity));
152 }
153// else if (MonthlyReport.STORAGE_CARGO.equals(node.custom)) {
154// MarketAPI market = (MarketAPI) node.custom2;
155// //FactionAPI faction = market.getFaction();
156// Misc.addStorageInfo(tooltip, color, dark, market, false, true);
157// } else if (MonthlyReport.STORAGE_SHIPS.equals(node.custom)) {
158//
159// }
160
161 }
162
163
164
165 public float getTooltipWidth(Object tooltipParam) {
166 return 450;
167 }
168
169 public boolean isTooltipExpandable(Object tooltipParam) {
170 return false;
171 }
172
173}
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam)