mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 22:29:50 +00:00
Merge branch 'dev' into syntax-highlighter-unified
This commit is contained in:
commit
39a43a339b
78 files changed
+4554
-1446
No files matched your search
@@ -15,11 +15,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
public class AuctionClientConfig {
|
||||
// Cached values from server
|
||||
private static long listingFee = 0;
|
||||
private static String currencyName = "Gold";
|
||||
private static int auctionDurationHours = 48;
|
||||
private static String currencyName = "Coins";
|
||||
private static int auctionDurationHours = 24;
|
||||
private static double minBidIncrement = 0.05;
|
||||
private static int maxActiveListings = 10;
|
||||
private static int claimExpirationDays = 30;
|
||||
private static int maxActiveListings = 8;
|
||||
private static int claimExpirationDays = 20;
|
||||
private static boolean auctionEnabled = false;
|
||||
|
||||
/**
|
||||
@@ -47,11 +47,11 @@ public class AuctionClientConfig {
|
||||
*/
|
||||
public static void reset() {
|
||||
listingFee = 0;
|
||||
currencyName = "Gold";
|
||||
auctionDurationHours = 48;
|
||||
currencyName = "Coins";
|
||||
auctionDurationHours = 24;
|
||||
minBidIncrement = 0.05;
|
||||
maxActiveListings = 10;
|
||||
claimExpirationDays = 30;
|
||||
maxActiveListings = 8;
|
||||
claimExpirationDays = 20;
|
||||
auctionEnabled = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import kamkeel.npcs.addon.client.DBCClient;
|
||||
import kamkeel.npcs.client.renderer.TelegraphRenderer;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
|
||||
@@ -5,7 +5,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import kamkeel.npcs.network.packets.player.InputDevicePacket;
|
||||
|
||||
@@ -3,7 +3,7 @@ package noppes.npcs.client.gui.advanced;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.Condition;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
@@ -47,9 +47,9 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig {
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 3: Damage Per Tick + Damage Interval
|
||||
addLabel(new GuiNpcLabel(104, "ability.dmgPerTick", labelX, y + 5));
|
||||
addTextField(createFloatField(104, fieldX, y, 50, hazard.getDamagePerTick()));
|
||||
// Row 3: Damage Per Second + Damage Interval
|
||||
addLabel(new GuiNpcLabel(104, "ability.dmgPerSec", labelX, y + 5));
|
||||
addTextField(createFloatField(104, fieldX, y, 50, hazard.getDamagePerSecond()));
|
||||
|
||||
addLabel(new GuiNpcLabel(105, "ability.dmgInterval", col2LabelX, y + 5));
|
||||
addTextField(createIntField(105, col2FieldX, y, 50, hazard.getDamageInterval()));
|
||||
@@ -99,7 +99,7 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig {
|
||||
hazard.setInnerRadius(parseFloat(field, hazard.getInnerRadius()));
|
||||
break;
|
||||
case 104:
|
||||
hazard.setDamagePerTick(parseFloat(field, hazard.getDamagePerTick()));
|
||||
hazard.setDamagePerSecond(parseFloat(field, hazard.getDamagePerSecond()));
|
||||
break;
|
||||
case 105:
|
||||
hazard.setDamageInterval(field.getInteger());
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData {
|
||||
int y = guiTop + 10;
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 85 + 160, y, 52, 20, "selectServer.edit"));
|
||||
this.addButton(new GuiNpcButton(8, guiLeft + 85, y, 155, 20, new String[]{"role.none", "role.trader", "role.follower", "role.bank", "role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)"), "role.mount", "role.auctioneer"}, npc.advanced.role.ordinal()));
|
||||
getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman);
|
||||
getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman && npc.advanced.role != EnumRoleType.Auctioneer);
|
||||
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += 22, 52, 20, "selectServer.edit"));
|
||||
this.addButton(new GuiNpcButton(5, guiLeft + 85, y, 155, 20, new String[]{"job.none", "job.bard", "job.healer", "job.guard", "job.itemgiver", "role.follower", "job.spawner", "job.conversation", "job.chunkloader"}, npc.advanced.job.ordinal()));
|
||||
@@ -84,7 +84,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData {
|
||||
hasChanges = true;
|
||||
npc.advanced.setRole(button.getValue());
|
||||
|
||||
getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman);
|
||||
getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman && npc.advanced.role != EnumRoleType.Auctioneer);
|
||||
}
|
||||
if (button.id == 4) {
|
||||
save();
|
||||
|
||||
@@ -8,7 +8,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.AuctionClientConfig;
|
||||
import noppes.npcs.constants.EnumClaimType;
|
||||
import noppes.npcs.containers.ContainerAuctionListing;
|
||||
import noppes.npcs.containers.ContainerAuctionSell;
|
||||
import noppes.npcs.containers.ContainerAuctionTrades;
|
||||
import noppes.npcs.controllers.data.AuctionClaim;
|
||||
import noppes.npcs.controllers.data.AuctionListing;
|
||||
@@ -41,6 +43,10 @@ public class AuctionTooltipHandler {
|
||||
else if (screen instanceof GuiAuctionTrades) {
|
||||
addTradesTooltip((GuiAuctionTrades) screen, stack, tooltip);
|
||||
}
|
||||
// Check if we're in the sell GUI
|
||||
else if (screen instanceof GuiAuctionSell) {
|
||||
addSellTooltip((GuiAuctionSell) screen, stack, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,10 +60,7 @@ public class AuctionTooltipHandler {
|
||||
AuctionListing listing = container.getListingForItem(stack);
|
||||
if (listing == null) return;
|
||||
|
||||
// Add separator
|
||||
tooltip.add("");
|
||||
tooltip.add(EnumChatFormatting.DARK_GRAY + "--- " + EnumChatFormatting.GOLD +
|
||||
StatCollector.translateToLocal("auction.title") + EnumChatFormatting.DARK_GRAY + " ---");
|
||||
|
||||
// Seller
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.seller")
|
||||
@@ -94,22 +97,21 @@ public class AuctionTooltipHandler {
|
||||
ContainerAuctionTrades container = (ContainerAuctionTrades) gui.inventorySlots;
|
||||
if (container == null) return;
|
||||
|
||||
// Check if it's an active listing
|
||||
AuctionListing listing = container.getListingForItem(stack);
|
||||
if (listing != null) {
|
||||
// Check if it's an item I'm selling
|
||||
AuctionListing sellingListing = container.getSellingListingForItem(stack);
|
||||
if (sellingListing != null) {
|
||||
tooltip.add("");
|
||||
tooltip.add(EnumChatFormatting.DARK_GRAY + "--- " + EnumChatFormatting.GOLD +
|
||||
StatCollector.translateToLocal("auction.trades.activeListing") + EnumChatFormatting.DARK_GRAY + " ---");
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.selling"));
|
||||
|
||||
if (listing.hasBids()) {
|
||||
if (sellingListing.hasBids()) {
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.currentBid")
|
||||
.replace("%s", EnumChatFormatting.GOLD + formatCurrency(listing.currentBid)));
|
||||
tooltip.add(EnumChatFormatting.GRAY + String.format(StatCollector.translateToLocal("auction.bids"), listing.bidCount));
|
||||
.replace("%s", EnumChatFormatting.GOLD + formatCurrency(sellingListing.currentBid)));
|
||||
tooltip.add(EnumChatFormatting.GRAY + String.format(StatCollector.translateToLocal("auction.bids"), sellingListing.bidCount));
|
||||
} else {
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.noBids"));
|
||||
}
|
||||
|
||||
long timeRemaining = listing.getTimeRemaining();
|
||||
long timeRemaining = sellingListing.getTimeRemaining();
|
||||
String timeText = StatCollector.translateToLocal("auction.timeLeft")
|
||||
.replace("%s", formatTimeRemaining(timeRemaining));
|
||||
tooltip.add((timeRemaining < 3600000 ? EnumChatFormatting.RED : EnumChatFormatting.WHITE) + timeText);
|
||||
@@ -119,29 +121,65 @@ public class AuctionTooltipHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if it's an item I'm bidding on
|
||||
AuctionListing biddingListing = container.getBiddingListingForItem(stack);
|
||||
if (biddingListing != null) {
|
||||
tooltip.add("");
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.trades.bidding"));
|
||||
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.currentBid")
|
||||
.replace("%s", EnumChatFormatting.GOLD + formatCurrency(biddingListing.currentBid)));
|
||||
tooltip.add(EnumChatFormatting.GRAY + String.format(StatCollector.translateToLocal("auction.bids"), biddingListing.bidCount));
|
||||
|
||||
long timeRemaining = biddingListing.getTimeRemaining();
|
||||
String timeText = StatCollector.translateToLocal("auction.timeLeft")
|
||||
.replace("%s", formatTimeRemaining(timeRemaining));
|
||||
tooltip.add((timeRemaining < 3600000 ? EnumChatFormatting.RED : EnumChatFormatting.WHITE) + timeText);
|
||||
|
||||
tooltip.add("");
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.trades.clickToRebid"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if it's a claim
|
||||
AuctionClaim claim = container.getClaimForItem(stack);
|
||||
if (claim != null) {
|
||||
tooltip.add("");
|
||||
|
||||
String claimTitle;
|
||||
// Title based on claim type
|
||||
switch (claim.type) {
|
||||
case ITEM:
|
||||
claimTitle = StatCollector.translateToLocal("auction.claim.item");
|
||||
if (claim.isReturned) {
|
||||
// Expired - returned to seller
|
||||
tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocal("auction.trades.expired"));
|
||||
} else {
|
||||
// Won item
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.won"));
|
||||
}
|
||||
break;
|
||||
case CURRENCY:
|
||||
claimTitle = StatCollector.translateToLocal("auction.claim.currency");
|
||||
// Sold - money to claim
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.sold"));
|
||||
if (claim.itemName != null && !claim.itemName.isEmpty()) {
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.claim.soldItem")
|
||||
.replace("%s", EnumChatFormatting.WHITE + claim.itemName));
|
||||
}
|
||||
if (claim.otherPlayerName != null && !claim.otherPlayerName.isEmpty()) {
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.claim.buyer")
|
||||
.replace("%s", EnumChatFormatting.WHITE + claim.otherPlayerName));
|
||||
}
|
||||
break;
|
||||
case REFUND:
|
||||
claimTitle = StatCollector.translateToLocal("auction.claim.refund");
|
||||
// Outbid - refund available
|
||||
tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocal("auction.trades.outbid"));
|
||||
if (claim.otherPlayerName != null && !claim.otherPlayerName.isEmpty()) {
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.claim.outbidBy")
|
||||
.replace("%s", EnumChatFormatting.WHITE + claim.otherPlayerName));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
claimTitle = "Claim";
|
||||
}
|
||||
|
||||
tooltip.add(EnumChatFormatting.DARK_GRAY + "--- " + EnumChatFormatting.GOLD +
|
||||
claimTitle + EnumChatFormatting.DARK_GRAY + " ---");
|
||||
|
||||
// Amount for currency claims (including REFUND)
|
||||
if (claim.type.isCurrency()) {
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.claim.amount")
|
||||
.replace("%s", EnumChatFormatting.GOLD + formatCurrency(claim.currency)));
|
||||
@@ -158,10 +196,40 @@ public class AuctionTooltipHandler {
|
||||
}
|
||||
|
||||
tooltip.add("");
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.claim.clickToClaim"));
|
||||
|
||||
// Show rebid option for REFUND claims with item (active auction)
|
||||
if (claim.type == EnumClaimType.REFUND && claim.item != null) {
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.leftClickRebid"));
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.trades.rightClickRefund"));
|
||||
} else {
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.claim.clickToClaim"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add sell page tooltip info.
|
||||
*/
|
||||
private static void addSellTooltip(GuiAuctionSell gui, ItemStack stack, List<String> tooltip) {
|
||||
ContainerAuctionSell container = (ContainerAuctionSell) gui.inventorySlots;
|
||||
if (container == null) return;
|
||||
|
||||
// Check if this is the sell slot item
|
||||
ItemStack sellItem = container.getItemToSell();
|
||||
if (sellItem != null && ItemStack.areItemStacksEqual(stack, sellItem)) {
|
||||
// This is the item in the sell slot
|
||||
tooltip.add("");
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.sell.leftClear"));
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.sell.rightRemove"));
|
||||
return;
|
||||
}
|
||||
|
||||
// This is an inventory item - show add controls
|
||||
tooltip.add("");
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.sell.leftAdd"));
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.sell.rightAddOne"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Format currency with commas.
|
||||
*/
|
||||
|
||||
@@ -29,20 +29,19 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
|
||||
private static final ResourceLocation ICON_BID = new ResourceLocation("customnpcs", "textures/items/npcCoinDiamond.png");
|
||||
private static final ResourceLocation ICON_BUYOUT = new ResourceLocation("customnpcs", "textures/items/npcCoinEmerald.png");
|
||||
|
||||
// Layout - non-final for testing/positioning
|
||||
protected int itemSlotX = 56;
|
||||
protected int itemSlotY = 52;
|
||||
protected int btnBidX = 56;
|
||||
protected int btnBidY = 80;
|
||||
protected int btnBuyoutX = 80;
|
||||
protected int btnBuyoutY = 80;
|
||||
protected int infoX = 110;
|
||||
protected int infoY = 50;
|
||||
protected int infoWidth = 130;
|
||||
// Layout
|
||||
private int itemSlotX = 70;
|
||||
private int itemSlotY = 75;
|
||||
private int btnBidX = 58;
|
||||
private int btnBidY = 110;
|
||||
private int btnBuyoutX = 82;
|
||||
private int btnBuyoutY = 110;
|
||||
private int infoX = 110;
|
||||
private int infoY = 50;
|
||||
|
||||
// Button IDs
|
||||
private static final int BTN_BID = 200;
|
||||
private static final int BTN_BUYOUT = 201;
|
||||
private int btnBidId = 200;
|
||||
private int btnBuyoutId = 201;
|
||||
|
||||
private final ContainerAuctionBidding biddingContainer;
|
||||
private AuctionListing listing;
|
||||
@@ -64,12 +63,12 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
|
||||
super.initGui();
|
||||
|
||||
// Bid button (diamond coin)
|
||||
btnBid = new GuiAuctionNavButton(BTN_BID, guiLeft + btnBidX, guiTop + btnBidY,
|
||||
btnBid = new GuiAuctionNavButton(btnBidId, guiLeft + btnBidX, guiTop + btnBidY,
|
||||
"auction.bid.place", ICON_BID);
|
||||
addButton(btnBid);
|
||||
|
||||
// Buy Now button (emerald coin) - only visible if listing has buyout
|
||||
btnBuyout = new GuiAuctionNavButton(BTN_BUYOUT, guiLeft + btnBuyoutX, guiTop + btnBuyoutY,
|
||||
btnBuyout = new GuiAuctionNavButton(btnBuyoutId, guiLeft + btnBuyoutX, guiTop + btnBuyoutY,
|
||||
"auction.bid.buyout", ICON_BUYOUT);
|
||||
addButton(btnBuyout);
|
||||
|
||||
@@ -112,15 +111,12 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
|
||||
|
||||
if (listing == null) return;
|
||||
|
||||
switch (button.id) {
|
||||
case BTN_BID:
|
||||
openBidSubGui();
|
||||
break;
|
||||
case BTN_BUYOUT:
|
||||
if (listing.hasBuyout()) {
|
||||
openBuyNowSubGui();
|
||||
}
|
||||
break;
|
||||
if (button.id == btnBidId) {
|
||||
openBidSubGui();
|
||||
} else if (button.id == btnBuyoutId) {
|
||||
if (listing.hasBuyout()) {
|
||||
openBuyNowSubGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,38 +186,46 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
|
||||
|
||||
/** Draw auction listing information on the right side */
|
||||
private void drawAuctionInfo() {
|
||||
int x = guiLeft + infoX;
|
||||
int x = guiLeft + 105;
|
||||
int y = guiTop + infoY;
|
||||
int lineHeight = 12;
|
||||
String currencyName = AuctionClientConfig.getCurrencyName();
|
||||
int xRight = guiLeft + 215;
|
||||
|
||||
int lineHeight = 9;
|
||||
|
||||
// Seller
|
||||
String sellerLabel = StatCollector.translateToLocal("auction.seller").replace("%s", "");
|
||||
fontRendererObj.drawString(EnumChatFormatting.GRAY + sellerLabel, x, y, 0xFFFFFF);
|
||||
y += lineHeight;
|
||||
fontRendererObj.drawString(EnumChatFormatting.WHITE + listing.sellerName, x + 10, y, 0xFFFFFF);
|
||||
|
||||
String label = listing.sellerName;
|
||||
int length = fontRendererObj.getStringWidth(label);
|
||||
fontRendererObj.drawString(EnumChatFormatting.WHITE + listing.sellerName, xRight - length, y, 0xFFFFFF);
|
||||
y += lineHeight + 4;
|
||||
|
||||
// Current Bid or Starting Price
|
||||
if (listing.hasBids()) {
|
||||
String bidLabel = StatCollector.translateToLocal("auction.info.currentBid");
|
||||
String bidLabel = StatCollector.translateToLocal("auction.info.currentBid") + ":";
|
||||
fontRendererObj.drawString(EnumChatFormatting.YELLOW + bidLabel, x, y, 0xFFFFFF);
|
||||
y += lineHeight;
|
||||
fontRendererObj.drawString(EnumChatFormatting.GOLD + formatCurrency(listing.currentBid) + " " + currencyName, x + 10, y, 0xFFFFFF);
|
||||
|
||||
label = formatCurrency(listing.currentBid);
|
||||
length = fontRendererObj.getStringWidth(label);
|
||||
fontRendererObj.drawString(EnumChatFormatting.GOLD + label, xRight - length, y, 0xFFFFFF);
|
||||
y += lineHeight + 4;
|
||||
|
||||
// Current Bidder
|
||||
String bidderLabel = StatCollector.translateToLocal("auction.info.highBidder");
|
||||
fontRendererObj.drawString(EnumChatFormatting.GRAY + bidderLabel, x, y, 0xFFFFFF);
|
||||
y += lineHeight;
|
||||
String bidderName = listing.highBidderName != null ? listing.highBidderName : "???";
|
||||
fontRendererObj.drawString(EnumChatFormatting.WHITE + bidderName, x + 10, y, 0xFFFFFF);
|
||||
|
||||
label = listing.highBidderName != null ? listing.highBidderName : "???";
|
||||
length = fontRendererObj.getStringWidth(label);
|
||||
fontRendererObj.drawString(EnumChatFormatting.WHITE + label, xRight - length, y, 0xFFFFFF);
|
||||
y += lineHeight + 4;
|
||||
} else {
|
||||
String startLabel = StatCollector.translateToLocal("auction.info.startingPrice");
|
||||
fontRendererObj.drawString(EnumChatFormatting.YELLOW + startLabel, x, y, 0xFFFFFF);
|
||||
y += lineHeight;
|
||||
fontRendererObj.drawString(EnumChatFormatting.GOLD + formatCurrency(listing.startingPrice) + " " + currencyName, x + 10, y, 0xFFFFFF);
|
||||
|
||||
label = formatCurrency(listing.startingPrice);
|
||||
length = fontRendererObj.getStringWidth(label);
|
||||
fontRendererObj.drawString(EnumChatFormatting.GOLD + label, xRight - length, y, 0xFFFFFF);
|
||||
y += lineHeight + 4;
|
||||
}
|
||||
|
||||
@@ -229,25 +233,31 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
|
||||
if (listing.hasBuyout()) {
|
||||
String buyoutLabel = StatCollector.translateToLocal("auction.info.buyoutPrice");
|
||||
fontRendererObj.drawString(EnumChatFormatting.GREEN + buyoutLabel, x, y, 0xFFFFFF);
|
||||
y += lineHeight;
|
||||
fontRendererObj.drawString(EnumChatFormatting.GREEN + formatCurrency(listing.buyoutPrice) + " " + currencyName, x + 10, y, 0xFFFFFF);
|
||||
|
||||
label = formatCurrency(listing.buyoutPrice);
|
||||
length = fontRendererObj.getStringWidth(label);
|
||||
fontRendererObj.drawString(EnumChatFormatting.GREEN + label, xRight - length, y, 0xFFFFFF);
|
||||
y += lineHeight + 4;
|
||||
}
|
||||
|
||||
// Time Remaining
|
||||
String timeLabel = StatCollector.translateToLocal("auction.info.timeLeft");
|
||||
fontRendererObj.drawString(EnumChatFormatting.GRAY + timeLabel, x, y, 0xFFFFFF);
|
||||
y += lineHeight;
|
||||
long timeRemaining = listing.getTimeRemaining();
|
||||
EnumChatFormatting timeColor = timeRemaining < 3600000 ? EnumChatFormatting.RED : EnumChatFormatting.WHITE;
|
||||
fontRendererObj.drawString(timeColor + formatTimeRemaining(timeRemaining), x + 10, y, 0xFFFFFF);
|
||||
|
||||
label = timeColor + formatTimeRemaining(timeRemaining);
|
||||
length = fontRendererObj.getStringWidth(label);
|
||||
fontRendererObj.drawString(label, xRight - length, y, 0xFFFFFF);
|
||||
y += lineHeight + 4;
|
||||
|
||||
// Bid Count
|
||||
String bidCountLabel = StatCollector.translateToLocal("auction.info.bidCount");
|
||||
fontRendererObj.drawString(EnumChatFormatting.GRAY + bidCountLabel, x, y, 0xFFFFFF);
|
||||
y += lineHeight;
|
||||
fontRendererObj.drawString(EnumChatFormatting.WHITE + String.valueOf(listing.bidCount), x + 10, y, 0xFFFFFF);
|
||||
|
||||
label = String.valueOf(listing.bidCount);
|
||||
length = fontRendererObj.getStringWidth(label);
|
||||
fontRendererObj.drawString(EnumChatFormatting.WHITE + label, xRight - length, y, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,6 @@ import noppes.npcs.client.gui.util.ITextfieldListener;
|
||||
import noppes.npcs.client.AuctionClientConfig;
|
||||
import noppes.npcs.containers.ContainerAuctionSell;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -30,23 +29,23 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
private static final ResourceLocation ICON_COIN = new ResourceLocation("customnpcs", "textures/items/npcCoinBronze.png");
|
||||
private static final ResourceLocation ICON_BAG = new ResourceLocation("customnpcs", "textures/items/npcBag.png");
|
||||
|
||||
// Layout - non-final for testing/positioning
|
||||
protected int contentX = 50;
|
||||
protected int contentY = 50;
|
||||
protected int confirmBtnX = 180;
|
||||
protected int confirmBtnY = 120;
|
||||
protected int navYBuyout = 109;
|
||||
// Layout
|
||||
private int contentX = 58;
|
||||
private int contentY = 50;
|
||||
private int confirmBtnX = 200;
|
||||
private int confirmBtnY = 118;
|
||||
private int navYBuyout = 109;
|
||||
|
||||
// Component IDs
|
||||
private static final int TXT_STARTING_PRICE = 1;
|
||||
private static final int TXT_BUYOUT_PRICE = 2;
|
||||
private static final int BTN_CONFIRM = 10;
|
||||
private static final int BTN_ALLOW_BUYOUT = 11;
|
||||
private int txtStartingPriceId = 1;
|
||||
private int txtBuyoutPriceId = 2;
|
||||
private int btnConfirmId = 10;
|
||||
private int btnAllowBuyoutId = 11;
|
||||
|
||||
private final ContainerAuctionSell sellContainer;
|
||||
private long startingPrice = 0;
|
||||
private long buyoutPrice = 0;
|
||||
private boolean allowBuyout = false;
|
||||
private boolean allowBuyout = true;
|
||||
private String errorMessage = null;
|
||||
|
||||
// Buttons
|
||||
@@ -67,7 +66,7 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
|
||||
// Starting Price label and field
|
||||
addLabel(new GuiNpcLabel(1, "auction.sell.startingPrice", guiLeft + contentX, y + 5, 0xFFFFFF));
|
||||
GuiNpcTextField startingField = new GuiNpcTextField(TXT_STARTING_PRICE, this, fontRendererObj,
|
||||
GuiNpcTextField startingField = new GuiNpcTextField(txtStartingPriceId, this, fontRendererObj,
|
||||
guiLeft + contentX + 80, y, 80, 18, startingPrice > 0 ? String.valueOf(startingPrice) : "");
|
||||
startingField.setIntegersOnly();
|
||||
addTextField(startingField);
|
||||
@@ -78,20 +77,20 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
lblBuyout = new GuiNpcLabel(2, "auction.sell.buyoutPrice", guiLeft + contentX, y + 5, 0xFFFFFF);
|
||||
addLabel(lblBuyout);
|
||||
|
||||
txtBuyout = new GuiNpcTextField(TXT_BUYOUT_PRICE, this, fontRendererObj,
|
||||
txtBuyout = new GuiNpcTextField(txtBuyoutPriceId, this, fontRendererObj,
|
||||
guiLeft + contentX + 80, y, 80, 18, buyoutPrice > 0 ? String.valueOf(buyoutPrice) : "");
|
||||
txtBuyout.setIntegersOnly();
|
||||
addTextField(txtBuyout);
|
||||
|
||||
// Allow Buyout toggle button (18x18 with bag icon)
|
||||
btnAllowBuyout = new GuiAuctionNavButton(BTN_ALLOW_BUYOUT, guiLeft + navX, guiTop + navYBuyout,
|
||||
btnAllowBuyout = new GuiAuctionNavButton(btnAllowBuyoutId, guiLeft + navX, guiTop + navYBuyout,
|
||||
"auction.sell.allowBuyout", ICON_BAG);
|
||||
btnAllowBuyout.setToggle(true); // This is a toggle, not a nav button
|
||||
btnAllowBuyout.setSelected(allowBuyout);
|
||||
addButton(btnAllowBuyout);
|
||||
|
||||
// Confirm button (custom textured button - using GuiAuctionNavButton)
|
||||
GuiAuctionNavButton btnConfirm = new GuiAuctionNavButton(BTN_CONFIRM, guiLeft + confirmBtnX, guiTop + confirmBtnY,
|
||||
GuiAuctionNavButton btnConfirm = new GuiAuctionNavButton(btnConfirmId, guiLeft + confirmBtnX - 20, guiTop + confirmBtnY - 10,
|
||||
"auction.sell.confirm", ICON_COIN);
|
||||
addButton(btnConfirm);
|
||||
|
||||
@@ -141,13 +140,13 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
if (textfield.id == TXT_STARTING_PRICE) {
|
||||
if (textfield.id == txtStartingPriceId) {
|
||||
try {
|
||||
startingPrice = Long.parseLong(textfield.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
startingPrice = 0;
|
||||
}
|
||||
} else if (textfield.id == TXT_BUYOUT_PRICE) {
|
||||
} else if (textfield.id == txtBuyoutPriceId) {
|
||||
try {
|
||||
String text = textfield.getText().trim();
|
||||
buyoutPrice = text.isEmpty() ? 0 : Long.parseLong(text);
|
||||
@@ -162,9 +161,9 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
public void actionPerformed(GuiButton button) {
|
||||
super.actionPerformed(button);
|
||||
|
||||
if (button.id == BTN_CONFIRM) {
|
||||
if (button.id == btnConfirmId) {
|
||||
createListing();
|
||||
} else if (button.id == BTN_ALLOW_BUYOUT) {
|
||||
} else if (button.id == btnAllowBuyoutId) {
|
||||
allowBuyout = !allowBuyout;
|
||||
btnAllowBuyout.setSelected(allowBuyout);
|
||||
updateBuyoutVisibility();
|
||||
@@ -175,8 +174,8 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
|
||||
private void createListing() {
|
||||
// Get latest values from text fields
|
||||
GuiNpcTextField startingField = getTextField(TXT_STARTING_PRICE);
|
||||
GuiNpcTextField buyoutField = getTextField(TXT_BUYOUT_PRICE);
|
||||
GuiNpcTextField startingField = getTextField(txtStartingPriceId);
|
||||
GuiNpcTextField buyoutField = getTextField(txtBuyoutPriceId);
|
||||
|
||||
if (startingField != null) {
|
||||
try {
|
||||
@@ -234,21 +233,20 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
@Override
|
||||
protected void drawAuctionContent(float partialTicks, int mouseX, int mouseY) {
|
||||
// Draw sell slot background (centered in content area)
|
||||
int slotX = guiLeft + contentX + 30;
|
||||
int slotY = guiTop + contentY + 55;
|
||||
int slotX = guiLeft + contentX;
|
||||
int slotY = guiTop + contentY + 50;
|
||||
drawAuctionSlot(slotX, slotY);
|
||||
|
||||
// Draw listing fee info (uses cached config from server)
|
||||
String feeText = StatCollector.translateToLocal("auction.sell.fee")
|
||||
.replace("%s", formatCurrency(AuctionClientConfig.getListingFee()) + " " + AuctionClientConfig.getCurrencyName());
|
||||
fontRendererObj.drawString(EnumChatFormatting.GRAY + feeText, guiLeft + contentX, guiTop + contentY + 80, 0xFFFFFF);
|
||||
fontRendererObj.drawString(EnumChatFormatting.GRAY + feeText, guiLeft + contentX, guiTop + contentY + 77, 0xFFFFFF);
|
||||
|
||||
// Draw error message if any
|
||||
if (errorMessage != null) {
|
||||
fontRendererObj.drawString(EnumChatFormatting.RED + errorMessage, guiLeft + contentX, guiTop + contentY + 95, 0xFFFFFF);
|
||||
}
|
||||
|
||||
// Draw item count indicator for sell slot
|
||||
drawSellSlotIndicator(slotX, slotY);
|
||||
}
|
||||
|
||||
@@ -261,14 +259,11 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
|
||||
// Color: green if valid, red if over limit
|
||||
int color = sellItem.stackSize <= inventoryCount ? 0x55FF55 : 0xFF5555;
|
||||
|
||||
int textWidth = fontRendererObj.getStringWidth(countText);
|
||||
fontRendererObj.drawStringWithShadow(countText, slotX + 18 + 4, slotY + 5, color);
|
||||
} else {
|
||||
// Draw "Place item here" hint
|
||||
String hint = StatCollector.translateToLocal("auction.sell.placeItem");
|
||||
int hintWidth = fontRendererObj.getStringWidth(hint);
|
||||
fontRendererObj.drawString(EnumChatFormatting.GRAY + hint, slotX + 9 - hintWidth / 2 + 20, slotY + 5, 0xFFFFFF);
|
||||
fontRendererObj.drawString(EnumChatFormatting.GRAY + hint, slotX + 20, slotY + 5, 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,14 +304,8 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
if (hasSubGui()) return;
|
||||
|
||||
// Draw tooltips for buttons
|
||||
// Draw tooltips for buttons (icons, not items - item tooltips handled by AuctionTooltipHandler)
|
||||
drawSellPageTooltips(mouseX, mouseY);
|
||||
|
||||
// Sell slot tooltip
|
||||
drawSellSlotTooltip(mouseX, mouseY);
|
||||
|
||||
// Inventory item tooltip (only add extra info, item tooltip is handled by AuctionTooltipHandler)
|
||||
drawInventoryTooltip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
/** Draw tooltips for sell page buttons */
|
||||
@@ -324,7 +313,7 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
List<String> tooltip = null;
|
||||
|
||||
// Check all buttons
|
||||
GuiNpcButton confirmBtn = getButton(BTN_CONFIRM);
|
||||
GuiNpcButton confirmBtn = getButton(btnConfirmId);
|
||||
if (confirmBtn instanceof GuiAuctionNavButton) {
|
||||
GuiAuctionNavButton btn = (GuiAuctionNavButton) confirmBtn;
|
||||
if (btn.isHovered()) {
|
||||
@@ -337,64 +326,7 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
|
||||
}
|
||||
|
||||
if (tooltip != null && !tooltip.isEmpty()) {
|
||||
drawTooltip(tooltip, mouseX - guiLeft, mouseY - guiTop);
|
||||
drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj);
|
||||
}
|
||||
}
|
||||
|
||||
/** Draw tooltip for sell slot */
|
||||
private void drawSellSlotTooltip(int mouseX, int mouseY) {
|
||||
int slotX = guiLeft + contentX + 30;
|
||||
int slotY = guiTop + contentY + 55;
|
||||
|
||||
if (mouseX >= slotX && mouseX < slotX + 18 && mouseY >= slotY && mouseY < slotY + 18) {
|
||||
ItemStack sellItem = sellContainer.getItemToSell();
|
||||
if (sellItem != null) {
|
||||
List<String> tooltip = new ArrayList<>();
|
||||
tooltip.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("auction.sell.slotTitle"));
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.sell.leftClear"));
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.sell.rightRemove"));
|
||||
drawTooltip(tooltip, mouseX - guiLeft, mouseY - guiTop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Draw tooltip for inventory items */
|
||||
private void drawInventoryTooltip(int mouseX, int mouseY) {
|
||||
Slot hoveredSlot = getSlotUnderMouse(mouseX, mouseY);
|
||||
if (hoveredSlot != null && sellContainer.isPlayerInventorySlot(hoveredSlot.slotNumber)) {
|
||||
if (hoveredSlot.getStack() != null) {
|
||||
List<String> tooltip = new ArrayList<>();
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.sell.leftAdd"));
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.sell.rightAddOne"));
|
||||
drawTooltip(tooltip, mouseX - guiLeft, mouseY - guiTop + 40);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Get slot under mouse position */
|
||||
private Slot getSlotUnderMouse(int mouseX, int mouseY) {
|
||||
for (int i = 0; i < inventorySlots.inventorySlots.size(); i++) {
|
||||
Slot slot = (Slot) inventorySlots.inventorySlots.get(i);
|
||||
if (isMouseOverSlot(slot, mouseX, mouseY)) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Check if mouse is over a slot */
|
||||
private boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) {
|
||||
int x = guiLeft + slot.xDisplayPosition;
|
||||
int y = guiTop + slot.yDisplayPosition;
|
||||
return mouseX >= x && mouseX < x + 16 && mouseY >= y && mouseY < y + 16;
|
||||
}
|
||||
|
||||
/** Draw tooltip with proper GL state */
|
||||
private void drawTooltip(List<String> tooltip, int x, int y) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
drawHoveringText(tooltip, x, y, fontRendererObj);
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
// Icon textures
|
||||
private static final ResourceLocation ICON_X = new ResourceLocation("customnpcs", "textures/gui/auction/x_icon.png");
|
||||
private static final ResourceLocation ICON_CHECK = new ResourceLocation("customnpcs", "textures/gui/auction/check_icon.png");
|
||||
private static final ResourceLocation ICON_COIN = new ResourceLocation("customnpcs", "textures/items/npcCoinGold.png");
|
||||
|
||||
// Grid layout
|
||||
private static final int GRID_X = 56;
|
||||
@@ -37,9 +38,10 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
private static final int TOTAL_SLOTS = COLS * ROWS;
|
||||
|
||||
// Slot tint colors (ARGB)
|
||||
private static final int TINT_BLUE = 0x303060FF; // Active listing/bid
|
||||
private static final int TINT_GREEN = 0x3030FF60; // Claimable
|
||||
private static final int TINT_RED = 0x30FF4040; // Refund
|
||||
private static final int TINT_BLUE = 0x303060FF; // Active listing/bid (selling)
|
||||
private static final int TINT_GREEN = 0x3030FF30; // Sold (currency claim) or Won (item claim)
|
||||
private static final int TINT_YELLOW = 0x30FFFF30; // Outbid (refund claim)
|
||||
private static final int TINT_RED = 0x30FF3030; // Expired/Returned (item returned to seller)
|
||||
|
||||
private final ContainerAuctionTrades tradesContainer;
|
||||
private int maxTradeSlots;
|
||||
@@ -53,7 +55,8 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
public GuiAuctionTrades(EntityNPCInterface npc, ContainerAuctionTrades container) {
|
||||
super(npc, container);
|
||||
this.tradesContainer = container;
|
||||
this.maxTradeSlots = AuctionClientConfig.getMaxActiveListings() * 2;
|
||||
// Initial value from client config, updated when server sends trades data
|
||||
this.maxTradeSlots = AuctionClientConfig.getMaxActiveListings();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,10 +92,28 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
// Right-click on own listing = show cancel
|
||||
setPending(slot, PendingOp.CANCEL);
|
||||
NoppesUtil.clickSound();
|
||||
} else if (claim != null && mouseButton == 0) {
|
||||
// Left-click on claim = show claim
|
||||
setPending(slot, PendingOp.CLAIM);
|
||||
} else if (listing != null && tradesContainer.isBiddingAt(slot) && mouseButton == 0) {
|
||||
// Left-click on active bid = open bidding GUI to increase bid
|
||||
AuctionActionPacket.openBidding(listing.id);
|
||||
NoppesUtil.clickSound();
|
||||
} else if (claim != null) {
|
||||
// Handle claim clicks
|
||||
if (claim.type == EnumClaimType.REFUND && claim.item != null) {
|
||||
// REFUND with item = can rebid
|
||||
if (mouseButton == 0) {
|
||||
// Left-click = open bidding to rebid
|
||||
AuctionActionPacket.openBidding(claim.listingId);
|
||||
NoppesUtil.clickSound();
|
||||
} else if (mouseButton == 1) {
|
||||
// Right-click = show refund claim confirmation
|
||||
setPending(slot, PendingOp.CLAIM);
|
||||
NoppesUtil.clickSound();
|
||||
}
|
||||
} else if (mouseButton == 0) {
|
||||
// Normal claim - left-click shows claim confirmation
|
||||
setPending(slot, PendingOp.CLAIM);
|
||||
NoppesUtil.clickSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,18 +127,31 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
playConfirmSound();
|
||||
}
|
||||
clearPending();
|
||||
} else if (pendingOp == PendingOp.CLAIM && mouseButton == 0) {
|
||||
// Left-click confirms claim
|
||||
} else if (pendingOp == PendingOp.CLAIM) {
|
||||
AuctionClaim claim = tradesContainer.getClaimAt(pendingSlot);
|
||||
if (claim != null) {
|
||||
if (claim.type.isItem()) {
|
||||
AuctionActionPacket.claimItem(claim.id);
|
||||
// For REFUND claims with item (rebid option), right-click confirms refund
|
||||
// For all others, left-click confirms claim
|
||||
boolean shouldClaim = (claim.type == EnumClaimType.REFUND && claim.item != null)
|
||||
? mouseButton == 1 // Right-click for rebiddable refunds
|
||||
: mouseButton == 0; // Left-click for normal claims
|
||||
|
||||
if (shouldClaim) {
|
||||
if (claim.type.isItem()) {
|
||||
AuctionActionPacket.claimItem(claim.id);
|
||||
} else {
|
||||
AuctionActionPacket.claimCurrency(claim.id);
|
||||
}
|
||||
playConfirmSound();
|
||||
clearPending();
|
||||
} else {
|
||||
AuctionActionPacket.claimCurrency(claim.id);
|
||||
// Wrong button - cancel operation
|
||||
clearPending();
|
||||
NoppesUtil.clickSound();
|
||||
}
|
||||
playConfirmSound();
|
||||
} else {
|
||||
clearPending();
|
||||
}
|
||||
clearPending();
|
||||
} else {
|
||||
// Wrong button - cancel operation
|
||||
clearPending();
|
||||
@@ -156,7 +190,6 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
int col = relX / 18;
|
||||
int row = relY / 18;
|
||||
if (col >= COLS || row >= ROWS) return -1;
|
||||
if (relX % 18 >= 18 || relY % 18 >= 18) return -1;
|
||||
|
||||
return col + row * COLS;
|
||||
}
|
||||
@@ -184,13 +217,23 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
drawDarkenedOverlay(x, y);
|
||||
}
|
||||
|
||||
// Pending operation icon
|
||||
// Pending operation icon or currency claim coin
|
||||
if (slot == pendingSlot) {
|
||||
if (pendingOp == PendingOp.CANCEL) {
|
||||
drawIconOverlay(x, y, ICON_X);
|
||||
} else if (pendingOp == PendingOp.CLAIM) {
|
||||
drawIconOverlay(x, y, ICON_CHECK);
|
||||
}
|
||||
} else {
|
||||
// Draw coin icon for currency claims or refund claims without item
|
||||
AuctionClaim claim = tradesContainer.getClaimAt(slot);
|
||||
if (claim != null) {
|
||||
// Show coin if: CURRENCY claim OR REFUND claim without item
|
||||
if (claim.type == EnumClaimType.CURRENCY ||
|
||||
(claim.type == EnumClaimType.REFUND && claim.item == null)) {
|
||||
drawIconOverlay(x, y, ICON_COIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,9 +245,27 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
AuctionClaim claim = tradesContainer.getClaimAt(slot);
|
||||
|
||||
if (listing != null) {
|
||||
return TINT_BLUE;
|
||||
if (tradesContainer.isSellingAt(slot)) {
|
||||
// Selling - Blue
|
||||
return TINT_BLUE;
|
||||
} else {
|
||||
// Bidding - Yellow
|
||||
return TINT_YELLOW;
|
||||
}
|
||||
} else if (claim != null) {
|
||||
return (claim.type == EnumClaimType.REFUND) ? TINT_RED : TINT_GREEN;
|
||||
switch (claim.type) {
|
||||
case CURRENCY:
|
||||
// Sold item - Green
|
||||
return TINT_GREEN;
|
||||
case REFUND:
|
||||
// Outbid - Red (whether rebiddable or not)
|
||||
return TINT_RED;
|
||||
case ITEM:
|
||||
// Won item (green) or Returned/Expired (red)
|
||||
return claim.isReturned ? TINT_RED : TINT_GREEN;
|
||||
default:
|
||||
return TINT_GREEN;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -247,12 +308,41 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
} else if (tradesContainer.isBiddingAt(slot)) {
|
||||
tooltip.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal("auction.trades.activeBid"));
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.trades.winningBid"));
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.trades.leftClickToIncrease"));
|
||||
}
|
||||
} else if (claim != null) {
|
||||
if (claim.type == EnumClaimType.REFUND) {
|
||||
tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocal("auction.trades.refundClaim"));
|
||||
} else {
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.pendingClaim"));
|
||||
switch (claim.type) {
|
||||
case CURRENCY:
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.soldClaim"));
|
||||
if (!claim.itemName.isEmpty()) {
|
||||
tooltip.add(EnumChatFormatting.WHITE + claim.itemName);
|
||||
}
|
||||
if (!claim.otherPlayerName.isEmpty()) {
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.trades.buyer") + ": " + EnumChatFormatting.AQUA + claim.otherPlayerName);
|
||||
}
|
||||
tooltip.add(EnumChatFormatting.GOLD + String.format("%,d", claim.currency) + " " + AuctionClientConfig.getCurrencyName());
|
||||
break;
|
||||
case REFUND:
|
||||
tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocal("auction.trades.outbid"));
|
||||
if (!claim.otherPlayerName.isEmpty()) {
|
||||
tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("auction.trades.outbidBy") + ": " + EnumChatFormatting.AQUA + claim.otherPlayerName);
|
||||
}
|
||||
tooltip.add(EnumChatFormatting.GOLD + String.format("%,d", claim.currency) + " " + AuctionClientConfig.getCurrencyName());
|
||||
// Show rebid option if item is present (active listing)
|
||||
if (claim.item != null) {
|
||||
tooltip.add("");
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.leftClickRebid"));
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.trades.rightClickRefund"));
|
||||
return; // Skip the generic claim message
|
||||
}
|
||||
break;
|
||||
case ITEM:
|
||||
if (claim.isReturned) {
|
||||
tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocal("auction.trades.expiredClaim"));
|
||||
} else {
|
||||
tooltip.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("auction.trades.wonClaim"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("auction.trades.leftClickToClaim"));
|
||||
} else if (slot >= maxTradeSlots) {
|
||||
@@ -280,7 +370,14 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
|
||||
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if (compound.hasKey("TradesUpdate")) {
|
||||
if (compound.hasKey("TradesData")) {
|
||||
// Full trades data received from server
|
||||
tradesContainer.setTradesData(compound);
|
||||
// Update max trade slots from server (permission-aware)
|
||||
this.maxTradeSlots = tradesContainer.getMaxTradeSlots();
|
||||
clearPending();
|
||||
} else if (compound.hasKey("TradesUpdate")) {
|
||||
// Legacy flag - should not happen now but keep for safety
|
||||
tradesContainer.refreshData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
* Shows minimum bid, player balance, and input field.
|
||||
*/
|
||||
public class SubGuiAuctionBid extends SubGuiInterface implements ITextfieldListener {
|
||||
private static final int TXT_BID = 1;
|
||||
private static final int BTN_BID = 10;
|
||||
private static final int BTN_CANCEL = 11;
|
||||
private int txtBidId = 1;
|
||||
private int btnBidId = 10;
|
||||
private int btnCancelId = 11;
|
||||
|
||||
private final String listingId;
|
||||
private final long minimumBid;
|
||||
@@ -47,25 +47,21 @@ public class SubGuiAuctionBid extends SubGuiInterface implements ITextfieldListe
|
||||
int y = guiTop + 15;
|
||||
String currencyName = AuctionClientConfig.getCurrencyName();
|
||||
|
||||
// Title
|
||||
addLabel(new GuiNpcLabel(0, "auction.bid.title", centerX - 50, y, 0xFFFFFF));
|
||||
y += 18;
|
||||
|
||||
// Minimum bid info
|
||||
String minText = StatCollector.translateToLocal("auction.bid.minimum")
|
||||
.replace("%s", EnumChatFormatting.GOLD + formatCurrency(minimumBid) + " " + currencyName);
|
||||
addLabel(new GuiNpcLabel(1, minText, guiLeft + 15, y, 0xAAAAAA));
|
||||
.replace("%s", EnumChatFormatting.DARK_RED + formatCurrency(minimumBid) + " " + currencyName);
|
||||
addLabel(new GuiNpcLabel(1, minText, guiLeft + 15, y));
|
||||
y += 14;
|
||||
|
||||
// Your balance
|
||||
String balanceText = StatCollector.translateToLocal("auction.bid.yourBalance")
|
||||
.replace("%s", EnumChatFormatting.WHITE + formatCurrency(playerBalance) + " " + currencyName);
|
||||
addLabel(new GuiNpcLabel(2, balanceText, guiLeft + 15, y, 0xAAAAAA));
|
||||
.replace("%s", EnumChatFormatting.DARK_GREEN + formatCurrency(playerBalance) + " " + currencyName);
|
||||
addLabel(new GuiNpcLabel(2, balanceText, guiLeft + 15, y));
|
||||
y += 18;
|
||||
|
||||
// Bid amount field
|
||||
addLabel(new GuiNpcLabel(3, "auction.bid.yourBid", guiLeft + 15, y + 4, 0xFFFFFF));
|
||||
GuiNpcTextField bidField = new GuiNpcTextField(TXT_BID, this, fontRendererObj,
|
||||
addLabel(new GuiNpcLabel(3, "auction.bid.yourBid", guiLeft + 15, y + 4));
|
||||
GuiNpcTextField bidField = new GuiNpcTextField(txtBidId, this, fontRendererObj,
|
||||
guiLeft + 80, y, 100, 18, String.valueOf(minimumBid));
|
||||
bidField.setIntegersOnly();
|
||||
addTextField(bidField);
|
||||
@@ -81,13 +77,13 @@ public class SubGuiAuctionBid extends SubGuiInterface implements ITextfieldListe
|
||||
int totalBtnWidth = btnWidth * 2 + btnSpacing;
|
||||
int btnX = centerX - totalBtnWidth / 2;
|
||||
|
||||
addButton(new GuiNpcButton(BTN_BID, btnX, y, btnWidth, 20, "auction.bid.placeBid"));
|
||||
addButton(new GuiNpcButton(BTN_CANCEL, btnX + btnWidth + btnSpacing, y, btnWidth, 20, "gui.cancel"));
|
||||
addButton(new GuiNpcButton(btnBidId, btnX, y, btnWidth, 20, "auction.bid.placeBid"));
|
||||
addButton(new GuiNpcButton(btnCancelId, btnX + btnWidth + btnSpacing, y, btnWidth, 20, "gui.cancel"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
if (textfield.id == TXT_BID) {
|
||||
if (textfield.id == txtBidId) {
|
||||
try {
|
||||
bidAmount = Long.parseLong(textfield.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
@@ -100,19 +96,16 @@ public class SubGuiAuctionBid extends SubGuiInterface implements ITextfieldListe
|
||||
|
||||
@Override
|
||||
public void buttonEvent(GuiButton button) {
|
||||
switch (button.id) {
|
||||
case BTN_BID:
|
||||
placeBid();
|
||||
break;
|
||||
case BTN_CANCEL:
|
||||
close();
|
||||
break;
|
||||
if (button.id == btnBidId) {
|
||||
placeBid();
|
||||
} else if (button.id == btnCancelId) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
private void placeBid() {
|
||||
// Get latest value from text field
|
||||
GuiNpcTextField bidField = getTextField(TXT_BID);
|
||||
GuiNpcTextField bidField = getTextField(txtBidId);
|
||||
if (bidField != null) {
|
||||
try {
|
||||
bidAmount = Long.parseLong(bidField.getText());
|
||||
|
||||
@@ -14,8 +14,8 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
* Shows buyout price, player balance, and confirmation buttons.
|
||||
*/
|
||||
public class SubGuiAuctionBuyNow extends SubGuiInterface {
|
||||
private static final int BTN_CONFIRM = 10;
|
||||
private static final int BTN_CANCEL = 11;
|
||||
private int btnConfirmId = 10;
|
||||
private int btnCancelId = 11;
|
||||
|
||||
private final String listingId;
|
||||
private final long buyoutPrice;
|
||||
@@ -44,25 +44,25 @@ public class SubGuiAuctionBuyNow extends SubGuiInterface {
|
||||
// Title
|
||||
String title = StatCollector.translateToLocal("auction.buyout.title");
|
||||
int titleWidth = fontRendererObj.getStringWidth(title);
|
||||
addLabel(new GuiNpcLabel(0, title, centerX - titleWidth / 2, y, 0xFFFFFF));
|
||||
addLabel(new GuiNpcLabel(0, title, centerX - titleWidth / 2, y));
|
||||
y += 20;
|
||||
|
||||
// Confirmation message
|
||||
String confirmMsg = StatCollector.translateToLocal("auction.buyout.confirm");
|
||||
int confirmWidth = fontRendererObj.getStringWidth(confirmMsg);
|
||||
addLabel(new GuiNpcLabel(1, confirmMsg, centerX - confirmWidth / 2, y, 0xAAAAAA));
|
||||
addLabel(new GuiNpcLabel(1, confirmMsg, centerX - confirmWidth / 2, y));
|
||||
y += 16;
|
||||
|
||||
// Buyout price
|
||||
String priceText = EnumChatFormatting.GREEN + formatCurrency(buyoutPrice) + " " + currencyName;
|
||||
String priceText = EnumChatFormatting.DARK_RED + formatCurrency(buyoutPrice) + " " + currencyName;
|
||||
int priceWidth = fontRendererObj.getStringWidth(priceText);
|
||||
addLabel(new GuiNpcLabel(2, priceText, centerX - priceWidth / 2, y, 0xFFFFFF));
|
||||
addLabel(new GuiNpcLabel(2, priceText, centerX - priceWidth / 2, y));
|
||||
y += 20;
|
||||
|
||||
// Your balance
|
||||
String balanceLabel = StatCollector.translateToLocal("auction.bid.yourBalance");
|
||||
String balanceText = balanceLabel.replace("%s", EnumChatFormatting.WHITE + formatCurrency(playerBalance) + " " + currencyName);
|
||||
addLabel(new GuiNpcLabel(3, balanceText, guiLeft + 20, y, 0xAAAAAA));
|
||||
String balanceText = balanceLabel.replace("%s", EnumChatFormatting.DARK_GREEN + formatCurrency(playerBalance) + " " + currencyName);
|
||||
addLabel(new GuiNpcLabel(3, balanceText, guiLeft + 20, y));
|
||||
y += 14;
|
||||
|
||||
// Insufficient funds warning
|
||||
@@ -78,23 +78,20 @@ public class SubGuiAuctionBuyNow extends SubGuiInterface {
|
||||
int totalBtnWidth = btnWidth * 2 + btnSpacing;
|
||||
int btnX = centerX - totalBtnWidth / 2;
|
||||
|
||||
GuiNpcButton confirmBtn = new GuiNpcButton(BTN_CONFIRM, btnX, y, btnWidth, 20, "gui.yes");
|
||||
GuiNpcButton confirmBtn = new GuiNpcButton(btnConfirmId, btnX, y, btnWidth, 20, "gui.yes");
|
||||
confirmBtn.enabled = playerBalance >= buyoutPrice;
|
||||
addButton(confirmBtn);
|
||||
addButton(new GuiNpcButton(BTN_CANCEL, btnX + btnWidth + btnSpacing, y, btnWidth, 20, "gui.cancel"));
|
||||
addButton(new GuiNpcButton(btnCancelId, btnX + btnWidth + btnSpacing, y, btnWidth, 20, "gui.cancel"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonEvent(GuiButton button) {
|
||||
switch (button.id) {
|
||||
case BTN_CONFIRM:
|
||||
if (playerBalance >= buyoutPrice) {
|
||||
confirmPurchase();
|
||||
}
|
||||
break;
|
||||
case BTN_CANCEL:
|
||||
close();
|
||||
break;
|
||||
if (button.id == btnConfirmId) {
|
||||
if (playerBalance >= buyoutPrice) {
|
||||
confirmPurchase();
|
||||
}
|
||||
} else if (button.id == btnCancelId) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user