Skip to content

Commit

Permalink
New Feature: Different color for orders outbid by your own orders (Is…
Browse files Browse the repository at this point in the history
…sue #416)
  • Loading branch information
GoldenGnu committed Sep 23, 2023
1 parent db1f05d commit 015b6f4
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class MyMarketOrder extends RawMarketOrder implements Comparable<MyMarket
private String issuedByName = "";
private Double brokersFee;
private Outbid outbid;
private boolean outbidOwned = false;
private boolean esi = true;
//soft init
private JButton jButton;
Expand Down Expand Up @@ -323,6 +324,14 @@ public boolean isOutbid() {
return outbid.getCount() > 0;
}

public boolean isOutbidOwned() {
return outbidOwned;
}

public void setOutbidOwned(boolean outbidOwned) {
this.outbidOwned = outbidOwned;
}

public boolean haveOutbid() {
return outbid != null;
}
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/net/nikr/eve/jeveasset/data/profile/ProfileData.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import ca.odell.glazedlists.EventList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
Expand Down Expand Up @@ -326,6 +327,7 @@ public void updateMarketOrders(OutbidProcesserOutput output) {
}
}
}
updateOutbidOwned(marketOrdersList);
AddedData.getMarketOrders().commitQueue();
Program.ensureEDT(new Runnable() {
@Override
Expand Down Expand Up @@ -586,6 +588,7 @@ public synchronized void updateEventLists(Date addedDate) {
order.setChanged(AddedData.getMarketOrders().getAdd(marketOrdersAdded, order.getOrderID(), changed));
}
}
updateOutbidOwned(marketOrders);
AddedData.getMarketOrders().commitQueue();
//Update IndustryJobs dynamic values
for (MyIndustryJob industryJob : industryJobs) {
Expand Down Expand Up @@ -927,6 +930,41 @@ public static <T extends ItemType & EditablePriceType> void updatePrices(EventLi
updateList(eventList, found);
}

private void updateOutbidOwned(Collection<MyMarketOrder> marketOrders) {
Map<Integer, Set<Long>> lowestBuy = new HashMap<>();
Map<Integer, Set<Long>> lowestSell = new HashMap<>();
for (MyMarketOrder order : marketOrders) { //Find lowest
if (order.isActive() && order.haveOutbid() && !order.isOutbid()) { //Lowest
Map<Integer, Set<Long>> lowest;
if (order.isBuyOrder()) {
lowest = lowestBuy;
} else {
lowest = lowestSell;
}
Set<Long> orderIDs = lowest.get(order.getTypeID());
if (orderIDs == null) {
orderIDs = new HashSet<>();
lowest.put(order.getTypeID(), orderIDs);
}
orderIDs.add(order.getOrderID());
}
}
for (MyMarketOrder order : marketOrders) { //Set owned
if (!order.isActive()) {
order.setOutbidOwned(false);
continue;
}
Map<Integer, Set<Long>> lowest;
if (order.isBuyOrder()) {
lowest = lowestBuy;
} else {
lowest = lowestSell;
}
Set<Long> orderIDs = lowest.get(order.getTypeID());
order.setOutbidOwned(orderIDs != null && !orderIDs.contains(order.getOrderID())); //Not null and not one of the lowest orders
}
}

private void updateIndustryJobPrices(EventList<MyIndustryJob> eventList, Set<Integer> typeIDs) {
if (typeIDs == null || typeIDs.isEmpty()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public enum ColorEntry {
STOCKPILE_TABLE_OVER_THRESHOLD(ColorEntryGroup.STOCKPILE, DataColors.get().stockpileTableOverThreshold()),
STOCKPILE_ICON_OVER_THRESHOLD(ColorEntryGroup.STOCKPILE, DataColors.get().stockpileIconOverThreshold(), Background.EDITABLE_AND_NOT_NULL, Foreground.NOT_EDITABLE),
MARKET_ORDERS_OUTBID_NOT_BEST(ColorEntryGroup.MARKET_ORDERS, DataColors.get().marketOrdersOutbidNotBest()),
MARKET_ORDERS_OUTBID_NOT_BEST_OWNED(ColorEntryGroup.MARKET_ORDERS, DataColors.get().marketOrdersOutbidNotBestOwned()),
MARKET_ORDERS_OUTBID_BEST(ColorEntryGroup.MARKET_ORDERS, DataColors.get().marketOrdersOutbidBest()),
MARKET_ORDERS_OUTBID_UNKNOWN(ColorEntryGroup.MARKET_ORDERS, DataColors.get().marketOrdersOutbidUnknown()),
MARKET_ORDERS_EXPIRED(ColorEntryGroup.MARKET_ORDERS, DataColors.get().marketOrdersExpired()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected void createColors(Map<ColorEntry, ColorThemeEntry> colors) {
colors.put(ColorEntry.STOCKPILE_TABLE_OVER_THRESHOLD, new ColorThemeEntry(Colors.COLORBLIND_YELLOW));
colors.put(ColorEntry.STOCKPILE_ICON_OVER_THRESHOLD, new ColorThemeEntry(Colors.COLORBLIND_YELLOW));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST, new ColorThemeEntry(Colors.COLORBLIND_MAGENTA));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST_OWNED, new ColorThemeEntry(Colors.COLORBLIND_ORANGE));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_BEST, new ColorThemeEntry(Colors.COLORBLIND_YELLOW));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_UNKNOWN, new ColorThemeEntry(Colors.COLORBLIND_GRAY));
colors.put(ColorEntry.MARKET_ORDERS_EXPIRED, new ColorThemeEntry(Colors.COLORBLIND_MAGENTA));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected void createColors(Map<ColorEntry, ColorThemeEntry> colors) {
colors.put(ColorEntry.STOCKPILE_TABLE_OVER_THRESHOLD, new ColorThemeEntry(Colors.DARK_GREEN));
colors.put(ColorEntry.STOCKPILE_ICON_OVER_THRESHOLD, new ColorThemeEntry(Colors.LIGHT_GREEN));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST, new ColorThemeEntry(Colors.DARK_RED));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST_OWNED, new ColorThemeEntry(Colors.DARK_ORANGE));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_BEST, new ColorThemeEntry(Colors.DARK_GREEN));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_UNKNOWN, new ColorThemeEntry(Colors.DARK_GRAY));
colors.put(ColorEntry.MARKET_ORDERS_EXPIRED, new ColorThemeEntry(Colors.DARK_RED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected void createColors(Map<ColorEntry, ColorThemeEntry> colors) {
colors.put(ColorEntry.STOCKPILE_TABLE_OVER_THRESHOLD, new ColorThemeEntry(Colors.LIGHT_GREEN));
colors.put(ColorEntry.STOCKPILE_ICON_OVER_THRESHOLD, new ColorThemeEntry(Colors.LIGHT_GREEN));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST, new ColorThemeEntry(Colors.LIGHT_RED));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST_OWNED, new ColorThemeEntry(Colors.LIGHT_ORANGE));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_BEST, new ColorThemeEntry(Colors.LIGHT_GREEN));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_UNKNOWN, new ColorThemeEntry(Colors.LIGHT_GRAY));
colors.put(ColorEntry.MARKET_ORDERS_EXPIRED, new ColorThemeEntry(Colors.LIGHT_RED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected void createColors(Map<ColorEntry, ColorThemeEntry> colors) {
colors.put(ColorEntry.STOCKPILE_TABLE_OVER_THRESHOLD, new ColorThemeEntry(Colors.STRONG_GREEN));
colors.put(ColorEntry.STOCKPILE_ICON_OVER_THRESHOLD, new ColorThemeEntry(Colors.STRONG_GREEN));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST, new ColorThemeEntry(Colors.STRONG_RED));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST_OWNED, new ColorThemeEntry(Colors.STRONG_ORANGE));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_BEST, new ColorThemeEntry(Colors.STRONG_GREEN));
colors.put(ColorEntry.MARKET_ORDERS_OUTBID_UNKNOWN, new ColorThemeEntry(Colors.STRONG_GRAY));
colors.put(ColorEntry.MARKET_ORDERS_EXPIRED, new ColorThemeEntry(Colors.STRONG_RED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public Component prepareRenderer(final TableCellRenderer renderer, final int row
if (columnName.equals(MarketTableFormat.OUTBID_PRICE.getColumnName())) {
if (marketOrder.haveOutbid()) {
if (marketOrder.isOutbid()) {
ColorSettings.configCell(component, ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST, isSelected);
if (marketOrder.isOutbidOwned()) {
ColorSettings.configCell(component, ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST_OWNED, isSelected);
} else {
ColorSettings.configCell(component, ColorEntry.MARKET_ORDERS_OUTBID_NOT_BEST, isSelected);
}
} else {
ColorSettings.configCell(component, ColorEntry.MARKET_ORDERS_OUTBID_BEST, isSelected);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/nikr/eve/jeveasset/i18n/DataColors.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public DataColors(final Locale locale) {
public abstract String stockpileTableOverThreshold();
public abstract String stockpileIconOverThreshold();
public abstract String marketOrdersOutbidNotBest();
public abstract String marketOrdersOutbidNotBestOwned();
public abstract String marketOrdersOutbidBest();
public abstract String marketOrdersOutbidUnknown();
public abstract String marketOrdersExpired();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ stockpileTableOverThreshold=Over Threshold: Table
stockpileIconOverThreshold=Over Threshold: Icon
#Market Orders
marketOrdersOutbidNotBest=Outbid: Not Best
marketOrdersOutbidNotBestOwned=Outbid: Not Best (Best Owned)
marketOrdersOutbidBest=Outbid: Best
marketOrdersOutbidUnknown=Outbid: Unknown
marketOrdersExpired=Expired
Expand Down

0 comments on commit 015b6f4

Please sign in to comment.