001package com.fs.starfarer.api.campaign.impl.items;
002
003import java.awt.Color;
004
005import com.fs.starfarer.api.Global;
006import com.fs.starfarer.api.campaign.CargoTransferHandlerAPI;
007import com.fs.starfarer.api.campaign.econ.MarketAPI;
008import com.fs.starfarer.api.campaign.econ.SubmarketAPI;
009import com.fs.starfarer.api.impl.campaign.GateEntityPlugin;
010import com.fs.starfarer.api.ui.TooltipMakerAPI;
011import com.fs.starfarer.api.util.Misc;
012
013public class JanusDevicePlugin extends BaseSpecialItemPlugin {
014        
015        @Override
016        public int getPrice(MarketAPI market, SubmarketAPI submarket) {
017                return super.getPrice(market, submarket);
018        }
019        
020        @Override
021        public String getDesignType() {
022                return null;
023        }
024        
025        @Override
026        public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, CargoTransferHandlerAPI transferHandler, Object stackSource) {
027                //super.createTooltip(tooltip, expanded, transferHandler, stackSource);
028                
029                float pad = 3f;
030                float opad = 10f;
031                float small = 5f;
032                Color h = Misc.getHighlightColor();
033                Color g = Misc.getGrayColor();
034                Color b = Misc.getButtonTextColor();
035                b = Misc.getPositiveHighlightColor();
036
037                if (!Global.CODEX_TOOLTIP_MODE) {
038                        tooltip.addTitle(getName());
039                } else {
040                        tooltip.addSpacer(-opad);
041                }
042                
043                String design = getDesignType();
044                if (design != null) {
045                        Misc.addDesignTypePara(tooltip, design, 10f);
046                }
047                
048                if (!spec.getDesc().isEmpty()) {
049                        if (Global.CODEX_TOOLTIP_MODE) {
050                                tooltip.setParaSmallInsignia();
051                        }
052                        tooltip.addPara(spec.getDesc(), Misc.getTextColor(), opad);
053                }
054                
055                addCostLabel(tooltip, opad, transferHandler, stackSource);
056                
057                if (!Global.CODEX_TOOLTIP_MODE) {
058                        tooltip.addPara("Right-click to integrate the " + getName() + " with your fleet", b, opad);
059                }
060        }
061
062        @Override
063        public float getTooltipWidth() {
064                return super.getTooltipWidth();
065        }
066        
067        @Override
068        public boolean isTooltipExpandable() {
069                return false;
070        }
071        
072        @Override
073        public boolean hasRightClickAction() {
074                return true;
075        }
076
077        @Override
078        public boolean shouldRemoveOnRightClickAction() {
079                return true;
080        }
081
082        @Override
083        public void performRightClickAction() {
084                // should be already set but, failsafe
085                Global.getSector().getMemoryWithoutUpdate().set(GateEntityPlugin.GATES_ACTIVE, true);
086                
087                Global.getSector().getMemoryWithoutUpdate().set(GateEntityPlugin.PLAYER_CAN_USE_GATES, true);
088                Global.getSoundPlayer().playUISound(getSpec().getSoundId(), 1f, 1f);
089                Global.getSector().getCampaignUI().getMessageDisplay().addMessage(
090                                getName() + " integrated - can transit active gates");//, 
091        }
092}
093
094
095