Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Museum HUD #1064

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,16 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.uiAndVisuals.showEquipmentInInventory = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.uiAndVisuals.museumOverlay"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.museumOverlay.@Tooltip")))
.binding(defaults.uiAndVisuals.museumOverlay,
() -> config.uiAndVisuals.museumOverlay,
newValue -> config.uiAndVisuals.museumOverlay = newValue)
.controller(ConfigUtils::createBooleanController)
.build())

//Chest Value FIXME change dropdown to color controller
//Chest Value FIXME change dropdown to color controller
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.uiAndVisuals.chestValue"))
.collapsed(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class UIAndVisualsConfig {
@SerialEntry
public boolean showEquipmentInInventory = true;

@SerialEntry
public boolean museumOverlay = true;

@SerialEntry
public ChestValue chestValue = new ChestValue();

Expand Down
41 changes: 34 additions & 7 deletions src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.systems.RenderSystem;

import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
Expand All @@ -13,10 +12,15 @@
import de.hysky.skyblocker.skyblock.experiment.SuperpairsSolver;
import de.hysky.skyblocker.skyblock.experiment.UltrasequencerSolver;
import de.hysky.skyblocker.skyblock.garden.VisitorHelper;
import de.hysky.skyblocker.skyblock.item.*;
import de.hysky.skyblocker.skyblock.item.ItemPrice;
import de.hysky.skyblocker.skyblock.item.ItemProtection;
import de.hysky.skyblocker.skyblock.item.ItemRarityBackgrounds;
import de.hysky.skyblocker.skyblock.item.WikiLookup;
import de.hysky.skyblocker.skyblock.item.slottext.SlotTextManager;
import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview;
import de.hysky.skyblocker.skyblock.item.tooltip.CompactorDeletorPreview;
import de.hysky.skyblocker.skyblock.museum.MuseumItemCache;
import de.hysky.skyblocker.skyblock.museum.MuseumManager;
import de.hysky.skyblocker.skyblock.quicknav.QuickNav;
import de.hysky.skyblocker.skyblock.quicknav.QuickNavButton;
import de.hysky.skyblocker.utils.ItemUtils;
Expand Down Expand Up @@ -102,6 +106,15 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
@Shadow
protected abstract List<Text> getTooltipFromItem(ItemStack stack);

@Shadow
protected int backgroundWidth;

@Shadow
protected int x;

@Shadow
protected int y;

@Unique
private List<QuickNavButton> quickNavButtons;

Expand All @@ -118,13 +131,28 @@ protected HandledScreenMixin(Text title) {
}
}

@Inject(method = "init", at = @At("TAIL"))
private void skyblocker$initMuseumOverlay(CallbackInfo ci) {
if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().uiAndVisuals.museumOverlay && client != null && client.player != null && !client.player.isCreative() && getTitle().getString().contains("Museum")) {
new MuseumManager(this, this.x, this.y, this.backgroundWidth);
}
}

@Inject(method = "close", at = @At("HEAD"))
7azeemm marked this conversation as resolved.
Show resolved Hide resolved
private void skyblocker$removeMuseumOverlay(CallbackInfo ci) {
if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().uiAndVisuals.museumOverlay && client != null && client.player != null && !client.player.isCreative() && getTitle().getString().contains("Museum")) {
// Reset Overlay variables when no longer in Museum inventory
MuseumManager.reset();
}
}

@Inject(at = @At("HEAD"), method = "keyPressed")
public void skyblocker$keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
if (this.client != null && this.client.player != null && this.focusedSlot != null && keyCode != 256 && !this.client.options.inventoryKey.matchesKey(keyCode, scanCode) && Utils.isOnSkyblock()) {
SkyblockerConfig config = SkyblockerConfigManager.get();
//wiki lookup
if (config.general.wikiLookup.enableWikiLookup && WikiLookup.wikiLookup.matchesKey(keyCode, scanCode)) {
WikiLookup.openWiki(this.focusedSlot, client.player);
WikiLookup.openWiki(this.focusedSlot.getStack(), client.player);
}
//item protection
if (ItemProtection.itemProtection.matchesKey(keyCode, scanCode)) {
Expand Down Expand Up @@ -311,10 +339,9 @@ protected HandledScreenMixin(Text title) {
}
}

case GenericContainerScreenHandler genericContainerScreenHandler when title.equals(MuseumItemCache.DONATION_CONFIRMATION_SCREEN_TITLE) -> {
//Museum Item Cache donation tracking
MuseumItemCache.handleClick(slot, slotId, genericContainerScreenHandler.slots);
}
//Museum Item Cache donation tracking
case GenericContainerScreenHandler genericContainerScreenHandler when title.equals(MuseumItemCache.DONATION_CONFIRMATION_SCREEN_TITLE) ->
MuseumItemCache.handleClick(slot, slotId, genericContainerScreenHandler.slots);

case null, default -> {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.slot.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import org.jetbrains.annotations.NotNull;
Expand All @@ -32,8 +32,8 @@ public static void init() {
));
}

public static void openWiki(@NotNull Slot slot, @NotNull PlayerEntity player) {
ItemUtils.getItemIdOptional(slot.getStack())
public static void openWiki(@NotNull ItemStack itemStack, @NotNull PlayerEntity player) {
ItemUtils.getItemIdOptional(itemStack)
.map(ItemRepository::getWikiLink)
.ifPresentOrElse(wikiLink -> CompletableFuture.runAsync(() -> Util.getOperatingSystem().open(wikiLink)).exceptionally(e -> {
LOGGER.error("[Skyblocker] Error while retrieving wiki article...", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void addToTooltip(@Nullable Slot focusedSloFt, ItemStack stack, List<Text
}
}

private double getItemCost(NEURecipe recipe, int depth) {
public static double getItemCost(NEURecipe recipe, int depth) {
if (depth >= MAX_RECURSION_DEPTH) return -1;

double totalCraftCost = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.hysky.skyblocker.skyblock.item.tooltip.adders;

import de.hysky.skyblocker.skyblock.item.MuseumItemCache;
import de.hysky.skyblocker.skyblock.museum.MuseumItemCache;
import de.hysky.skyblocker.skyblock.item.tooltip.SimpleTooltipAdder;
import de.hysky.skyblocker.skyblock.item.tooltip.info.TooltipInfoType;
import de.hysky.skyblocker.utils.ItemUtils;
Expand Down
112 changes: 112 additions & 0 deletions src/main/java/de/hysky/skyblocker/skyblock/museum/Donation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package de.hysky.skyblocker.skyblock.museum;

import it.unimi.dsi.fastutil.objects.ObjectDoublePair;
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
import it.unimi.dsi.fastutil.objects.ObjectObjectMutablePair;

import java.util.ArrayList;
import java.util.List;

public class Donation {
private final String category;
private final String id;
private final List<ObjectObjectMutablePair<String, PriceData>> set;
private final List<String> downgrades = new ArrayList<>();
private final int xp;
private List<ObjectIntPair<String>> countsTowards;
private PriceData priceData;
private ObjectDoublePair<String> discount;
private int totalXp;
private double xpCoinsRatio;

public Donation(String category, String id, List<ObjectObjectMutablePair<String, PriceData>> set, int xp) {
this.category = category;
this.id = id;
this.set = set;
this.xp = xp;
}

public int getTotalXp() {
return totalXp;
}

public void setTotalXp(int totalXp) {
this.totalXp = totalXp;
}

public List<ObjectIntPair<String>> getCountsTowards() {
return countsTowards;
}

public void setCountsTowards(List<ObjectIntPair<String>> countsTowards) {
this.countsTowards = countsTowards;
}

public PriceData getPriceData() {
return priceData;
}

public void setPriceData() {
this.priceData = new PriceData(this);
}

public ObjectDoublePair<String> getDiscount() {
return discount;
}

public void setDiscount(ObjectDoublePair<String> discount) {
this.discount = discount;
}

public boolean hasDiscount() {
return discount != null && discount.rightDouble() > 0d;
}

public void addDowngrade(String downgrade) {
this.downgrades.add(downgrade);
}

public List<String> getDowngrades() {
return downgrades;
}

public double getXpCoinsRatio() {
return xpCoinsRatio;
}

public void setXpCoinsRatio(double xpCoinsRatio) {
this.xpCoinsRatio = xpCoinsRatio;
}

public String getCategory() {
return category;
}

public String getId() {
return id;
}

public boolean isSet() {
return !set.isEmpty();
}

public List<ObjectObjectMutablePair<String, PriceData>> getSet() {
return set;
}

public int getXp() {
return xp;
}

public boolean isCraftable() {
return this.priceData.getCraftCost() > 0;
}

public boolean hasLBinPrice() {
return this.priceData.getLBinPrice() > 0;
}

public boolean hasPrice() {
return this.priceData.getEffectivePrice() > 0;
}
}
Loading