Search in sources :

Example 1 with ITradeStationInfo

use of forestry.api.mail.ITradeStationInfo in project ForestryMC by ForestryMC.

the class ContainerCatalogue method rebuildStationsList.

private void rebuildStationsList() {
    stations.clear();
    IPostOffice postOffice = PostManager.postRegistry.getPostOffice(player.world);
    Map<IMailAddress, ITradeStation> tradeStations = postOffice.getActiveTradeStations(player.world);
    for (ITradeStation station : tradeStations.values()) {
        ITradeStationInfo info = station.getTradeInfo();
        // Filter out any trade stations which do not actually offer anything.
        if (FILTERS.get(currentFilter).contains(info.getState())) {
            stations.add(station);
        }
    }
    stationIndex = 0;
    updateTradeInfo();
}
Also used : ITradeStation(forestry.api.mail.ITradeStation) IMailAddress(forestry.api.mail.IMailAddress) IPostOffice(forestry.api.mail.IPostOffice) ITradeStationInfo(forestry.api.mail.ITradeStationInfo)

Example 2 with ITradeStationInfo

use of forestry.api.mail.ITradeStationInfo in project ForestryMC by ForestryMC.

the class GuiCatalogue method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    switch(button.id) {
        case 0:
            mc.player.closeScreen();
            break;
        case // next page
        2:
            NetworkUtil.sendToServer(new PacketGuiSelectRequest(0, 0));
            break;
        case // previous page
        3:
            NetworkUtil.sendToServer(new PacketGuiSelectRequest(1, 0));
            break;
        case // cycle filter
        4:
            NetworkUtil.sendToServer(new PacketGuiSelectRequest(2, 0));
            break;
        case 5:
            ITradeStationInfo info = container.getTradeInfo();
            if (info != null) {
                SessionVars.setStringVar("mail.letter.recipient", info.getAddress().getName());
                SessionVars.setStringVar("mail.letter.addressee", EnumAddressee.TRADER.toString());
            }
            mc.player.closeScreen();
            break;
    }
}
Also used : PacketGuiSelectRequest(forestry.core.network.packets.PacketGuiSelectRequest) ITradeStationInfo(forestry.api.mail.ITradeStationInfo)

Example 3 with ITradeStationInfo

use of forestry.api.mail.ITradeStationInfo in project ForestryMC by ForestryMC.

the class GuiCatalogue method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
    fontRenderer.drawString(String.format("%s / %s", container.getPageNumber(), container.getPageCount()), guiLeft + xSize - 72, guiTop + 12, ColourProperties.INSTANCE.get("gui.book"));
    clearTradeInfoWidgets();
    ITradeStationInfo tradeInfo = container.getTradeInfo();
    if (tradeInfo != null) {
        drawTradePreview(tradeInfo, guiLeft + 38, guiTop + 30);
        buttonUse.enabled = tradeInfo.getState().isOk();
    } else {
        drawNoTrade(guiLeft + 38, guiTop + 30);
        buttonUse.enabled = false;
    }
    buttonFilter.displayString = Translator.translateToLocal("for.gui.mail.filter." + container.getFilterIdent());
}
Also used : ITradeStationInfo(forestry.api.mail.ITradeStationInfo)

Aggregations

ITradeStationInfo (forestry.api.mail.ITradeStationInfo)3 IMailAddress (forestry.api.mail.IMailAddress)1 IPostOffice (forestry.api.mail.IPostOffice)1 ITradeStation (forestry.api.mail.ITradeStation)1 PacketGuiSelectRequest (forestry.core.network.packets.PacketGuiSelectRequest)1