001package com.fs.starfarer.api.impl.campaign; 002 003import java.awt.Color; 004import java.util.ArrayList; 005import java.util.List; 006 007import com.fs.starfarer.api.Global; 008import com.fs.starfarer.api.campaign.CargoAPI; 009import com.fs.starfarer.api.campaign.FactionAPI; 010import com.fs.starfarer.api.campaign.FactionProductionAPI; 011import com.fs.starfarer.api.campaign.econ.CommodityOnMarketAPI; 012import com.fs.starfarer.api.campaign.econ.MonthlyReport; 013import com.fs.starfarer.api.campaign.econ.MonthlyReport.FDNode; 014import com.fs.starfarer.api.fleet.FleetMemberAPI; 015import com.fs.starfarer.api.ui.Alignment; 016import com.fs.starfarer.api.ui.TooltipMakerAPI; 017import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator; 018import com.fs.starfarer.api.util.Misc; 019 020public class MonthlyReportNodeTooltipCreator implements TooltipCreator { 021 022 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) { 023 FDNode node = (FDNode) tooltipParam; 024 025 float pad = 3f; 026 float opad = 10f; 027 028 //tooltip.addTitle(node.name); 029 030 int crewSalary = Global.getSettings().getInt("crewSalary"); 031 int marineSalary = Global.getSettings().getInt("marineSalary"); 032 int officerBase = Global.getSettings().getInt("officerSalaryBase"); 033 int officerPerLevel = Global.getSettings().getInt("officerSalaryPerLevel"); 034 float storageFreeFraction = Global.getSettings().getFloat("storageFreeFraction"); 035 036 Color h = Misc.getHighlightColor(); 037 038 FactionAPI faction = Global.getSector().getPlayerFaction(); 039 Color color = faction.getBaseUIColor(); 040 Color dark = faction.getDarkUIColor(); 041 Color grid = faction.getGridUIColor(); 042 Color bright = faction.getBrightUIColor(); 043 044 if (MonthlyReport.FLEET.equals(node.custom)) { 045 tooltip.addPara("Fleet-related income and expenses.", 0); 046 } else if (MonthlyReport.OUTPOSTS.equals(node.custom)) { 047 tooltip.addPara("Colony-related income and expenses.", 0); 048 } else if (MonthlyReport.PRODUCTION_WEAPONS.equals(node.custom)) { 049 tooltip.addPara("Weapons and fighter LPCs installed on produced ships.", 0); 050 } else if (MonthlyReport.PRODUCTION.equals(node.custom)) { 051 float currPad = 0f; 052 if (node.custom2 instanceof CargoAPI) { 053 CargoAPI cargo = (CargoAPI) node.custom2; 054 if (!cargo.isEmpty()) { 055 tooltip.addSectionHeading("Equipment", color, dark, Alignment.MID, currPad); 056 tooltip.showCargo(cargo, 10, true, opad); 057 currPad = opad; 058 } 059 List<FleetMemberAPI> ships = new ArrayList<FleetMemberAPI>(); 060 ships.addAll(cargo.getMothballedShips().getMembersListCopy()); 061 if (!ships.isEmpty()) { 062 tooltip.addSectionHeading("Ships", color, dark, Alignment.MID, currPad); 063 tooltip.showShips(ships, 10, true, opad); 064 } 065 } 066 067 FactionAPI pf = Global.getSector().getPlayerFaction(); 068 FactionProductionAPI prod = pf.getProduction(); 069 int accrued = prod.getAccruedProduction(); 070 if (accrued > 0) { 071 tooltip.addPara("A total of %s worth of production effort has been put into projects that have not yet been " + 072 "completed.", currPad, Misc.getHighlightColor(), "" + Misc.getDGSCredits(accrued)); 073 } 074 075 } else if (MonthlyReport.STOCKPILING.equals(node.custom)) { 076 if (node.custom2 instanceof CargoAPI) { 077 tooltip.addPara("Expenses incurred due to the use of local stockpiles to counter shortages.", 0); 078 CargoAPI cargo = (CargoAPI) node.custom2; 079 if (!cargo.isEmpty()) { 080 tooltip.addSectionHeading("Resources", color, dark, Alignment.MID, opad); 081 tooltip.showCargo(cargo, 10, true, opad); 082 } 083 List<FleetMemberAPI> ships = new ArrayList<FleetMemberAPI>(); 084 ships.addAll(cargo.getMothballedShips().getMembersListCopy()); 085 if (!ships.isEmpty()) { 086 tooltip.addSectionHeading("Ships", color, dark, Alignment.MID, opad); 087 tooltip.showShips(ships, 10, true, opad); 088 } 089 } 090 } else if (MonthlyReport.RESTOCKING.equals(node.custom)) { 091 if (node.custom2 instanceof CargoAPI) { 092 tooltip.addPara("Expenses incurred due to the need to restock local stockpiles to replace the resources drawn by your fleet.", 0); 093 CargoAPI cargo = (CargoAPI) node.custom2; 094 if (!cargo.isEmpty()) { 095 tooltip.addSectionHeading("Resources", color, dark, Alignment.MID, opad); 096 tooltip.showCargo(cargo, 10, true, opad); 097 } 098 List<FleetMemberAPI> ships = new ArrayList<FleetMemberAPI>(); 099 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}