Skip to content

Commit

Permalink
Add item rarity background opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Oct 7, 2023
1 parent 238ed9a commit 0103dca
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
4 changes: 4 additions & 0 deletions src/main/java/me/xmrvizzy/skyblocker/config/ConfigUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.controller.BooleanControllerBuilder;
import dev.isxander.yacl3.api.controller.EnumControllerBuilder;
import dev.isxander.yacl3.api.controller.ValueFormatter;
import me.xmrvizzy.skyblocker.config.controllers.EnumDropdownControllerBuilder;
import net.minecraft.text.Text;

public class ConfigUtils {
public static final ValueFormatter<Float> FLOAT_TWO_FORMATTER = value -> Text.literal(String.format("%,.2f", value).replaceAll("[\u00a0\u202F]", " "));

public static BooleanControllerBuilder createBooleanController(Option<Boolean> opt) {
return BooleanControllerBuilder.create(opt).yesNoFormatter().coloured(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ public static class ItemInfoDisplay {

@SerialEntry
public boolean itemRarityBackgrounds = false;

@SerialEntry
public float itemRarityBackgroundsOpacity = 1f;
}

public static class SpecialEffects {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
package me.xmrvizzy.skyblocker.config.categories;

import dev.isxander.yacl3.api.ButtonOption;
import dev.isxander.yacl3.api.ConfigCategory;
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.OptionDescription;
import dev.isxander.yacl3.api.OptionGroup;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.config.ConfigUtils;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.skyblock.shortcut.ShortcutsConfigScreen;
import me.xmrvizzy.skyblocker.utils.render.title.TitleContainerConfigScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;

public class GeneralCategory {

public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig config) {
public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig config) {
return ConfigCategory.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.category.general"))

//Ungrouped Options
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.acceptReparty"))
Expand Down Expand Up @@ -57,7 +54,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.general.hideStatusEffectOverlay = newValue)
.controller(ConfigUtils::createBooleanController)
.build())

//Tab Hud
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.tabHud"))
Expand Down Expand Up @@ -94,7 +91,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.build())

//Fancy Bars
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.bars"))
Expand Down Expand Up @@ -135,7 +132,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.build())

//Experiments Solver
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.experiments"))
Expand All @@ -162,7 +159,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Fishing Helper
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.fishing"))
Expand All @@ -175,7 +172,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Fairy Souls Helper
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.fairySouls"))
Expand Down Expand Up @@ -203,7 +200,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Shortcuts
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.shortcuts"))
Expand Down Expand Up @@ -238,7 +235,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.action((screen, opt) -> MinecraftClient.getInstance().setScreen(new ShortcutsConfigScreen(screen)))
.build())
.build())

//Quiver Warning
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.quiverWarning"))
Expand All @@ -265,7 +262,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Item List
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.itemList"))
Expand All @@ -278,7 +275,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Item Tooltip
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip"))
Expand Down Expand Up @@ -335,7 +332,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Item Info Display
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.itemInfoDisplay"))
Expand All @@ -356,8 +353,15 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.general.itemInfoDisplay.itemRarityBackgrounds = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Float>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.itemInfoDisplay.itemRarityBackgroundsOpacity"))
.binding(defaults.general.itemInfoDisplay.itemRarityBackgroundsOpacity,
() -> config.general.itemInfoDisplay.itemRarityBackgroundsOpacity,
newValue -> config.general.itemInfoDisplay.itemRarityBackgroundsOpacity = newValue)
.controller(opt -> FloatSliderControllerBuilder.create(opt).range(0f, 1f).step(0.05f).formatValue(ConfigUtils.FLOAT_TWO_FORMATTER))
.build())
.build())

//Special Effects
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.specialEffects"))
Expand All @@ -371,7 +375,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Hitboxes
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.hitbox"))
Expand All @@ -391,7 +395,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Title Container
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.titleContainer"))
Expand Down Expand Up @@ -438,7 +442,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.action((screen, opt) -> MinecraftClient.getInstance().setScreen(new TitleContainerConfigScreen(screen)))
.build())
.build())

//Teleport Overlays
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.teleportOverlay"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap;
import me.xmrvizzy.skyblocker.SkyblockerMod;
import me.xmrvizzy.skyblocker.config.SkyblockerConfigManager;
import me.xmrvizzy.skyblocker.utils.Utils;
import me.xmrvizzy.skyblocker.utils.scheduler.Scheduler;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
Expand Down Expand Up @@ -100,8 +101,8 @@ private static void draw(DrawContext context, int x, int y, SkyblockItemRarity r
//Enable blending to handle HUD translucency
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
context.drawSprite(x, y, 0, 16, 16, SPRITE.get(), rarity.r, rarity.g, rarity.b, 1f);

context.drawSprite(x, y, 0, 16, 16, SPRITE.get(), rarity.r, rarity.g, rarity.b, SkyblockerConfigManager.get().general.itemInfoDisplay.itemRarityBackgroundsOpacity);

RenderSystem.disableBlend();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"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.itemRarityBackgroundsOpacity": "Item Rarity Backgrounds Opacity",
"text.autoconfig.skyblocker.option.general.specialEffects": "Special Effects",
"text.autoconfig.skyblocker.option.general.specialEffects.rareDungeonDropEffects": "Rare Dungeon Drop Effects",
"text.autoconfig.skyblocker.option.general.specialEffects.rareDungeonDropEffects.@Tooltip": "Adds a special visual effect triggered upon obtaining rare dungeon loot!",
Expand Down

0 comments on commit 0103dca

Please sign in to comment.