Skip to content

Commit

Permalink
Square Item Rarity Background (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed Nov 6, 2023
1 parent 32aac90 commit 6768b76
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
24 changes: 24 additions & 0 deletions src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.hysky.skyblocker.config;

import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.skyblock.item.CustomArmorTrims;
import de.hysky.skyblocker.utils.chat.ChatFilterResult;
import de.hysky.skyblocker.utils.waypoint.Waypoint;
Expand All @@ -10,6 +11,7 @@
import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -497,10 +499,32 @@ public static class ItemInfoDisplay {
@SerialEntry
public boolean itemRarityBackgrounds = false;

@SerialEntry
public RarityBackgroundStyle itemRarityBackgroundStyle = RarityBackgroundStyle.CIRCULAR;

@SerialEntry
public float itemRarityBackgroundsOpacity = 1f;
}

public enum RarityBackgroundStyle {
CIRCULAR(new Identifier(SkyblockerMod.NAMESPACE, "item_rarity_background_circular")),
SQUARE(new Identifier(SkyblockerMod.NAMESPACE, "item_rarity_background_square"));

public final Identifier tex;

private RarityBackgroundStyle(Identifier tex) {
this.tex = tex;
}

@Override
public String toString() {
return switch (this) {
case CIRCULAR -> "Circular";
case SQUARE -> "Square";
};
}
}

public static class WikiLookup {
@SerialEntry
public boolean enableWikiLookup = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.general.itemInfoDisplay.itemRarityBackgrounds = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<SkyblockerConfig.RarityBackgroundStyle>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.itemInfoDisplay.itemRarityBackgroundStyle"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.general.itemInfoDisplay.itemRarityBackgroundStyle.@Tooltip")))
.binding(defaults.general.itemInfoDisplay.itemRarityBackgroundStyle,
() -> config.general.itemInfoDisplay.itemRarityBackgroundStyle,
newValue -> config.general.itemInfoDisplay.itemRarityBackgroundStyle = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(Option.<Float>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.itemInfoDisplay.itemRarityBackgroundsOpacity"))
.binding(defaults.general.itemInfoDisplay.itemRarityBackgroundsOpacity,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package de.hysky.skyblocker.skyblock.item;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

import com.google.common.collect.ImmutableMap;
import com.mojang.blaze3d.systems.RenderSystem;
import de.hysky.skyblocker.SkyblockerMod;

import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
Expand All @@ -16,16 +22,10 @@
import net.minecraft.client.texture.Sprite;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

public class ItemRarityBackgrounds {
private static final Identifier RARITY_BG_TEX = new Identifier(SkyblockerMod.NAMESPACE, "item_rarity_background");
private static final Supplier<Sprite> SPRITE = () -> MinecraftClient.getInstance().getGuiAtlasManager().getSprite(RARITY_BG_TEX);
private static final SkyblockerConfig.ItemInfoDisplay CONFIG = SkyblockerConfigManager.get().general.itemInfoDisplay;
private static final Supplier<Sprite> SPRITE = () -> MinecraftClient.getInstance().getGuiAtlasManager().getSprite(CONFIG.itemRarityBackgroundStyle.tex);
private static final ImmutableMap<String, SkyblockItemRarity> LORE_RARITIES = ImmutableMap.ofEntries(
Map.entry("ADMIN", SkyblockItemRarity.ADMIN),
Map.entry("SPECIAL", SkyblockItemRarity.SPECIAL), //Very special is the same color so this will cover it
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
"text.autoconfig.skyblocker.option.general.itemInfoDisplay.attributeShardInfo.@Tooltip": "Displays the attribute's level as the stack count and the initials of the attribute's name.",
"text.autoconfig.skyblocker.option.general.itemInfoDisplay.itemRarityBackgrounds": "Item Rarity Backgrounds",
"text.autoconfig.skyblocker.option.general.itemInfoDisplay.itemRarityBackgrounds.@Tooltip": "Displays a colored background behind an item, the color represents the item's rarity.",
"text.autoconfig.skyblocker.option.general.itemInfoDisplay.itemRarityBackgroundStyle": "Item Rarity Background Style",
"text.autoconfig.skyblocker.option.general.itemInfoDisplay.itemRarityBackgroundStyle.@Tooltip": "Choose between a circular or a square background style!",
"text.autoconfig.skyblocker.option.general.itemInfoDisplay.itemRarityBackgroundsOpacity": "Item Rarity Backgrounds Opacity",
"text.autoconfig.skyblocker.option.general.wikiLookup": "Wiki Lookup",
"text.autoconfig.skyblocker.option.general.wikiLookup.enableWikiLookup": "Enable Wiki Lookup",
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6768b76

Please sign in to comment.