support greater modifier category

This commit is contained in:
radimous 2024-12-04 18:58:54 +01:00
parent 602d181e58
commit 1ef461ab37
4 changed files with 76 additions and 35 deletions

View file

@ -0,0 +1,42 @@
package com.radimous.vhatcaniroll.logic;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
public enum ModifierCategory {
NORMAL,
GREATER,
LEGENDARY;
public String getSymbol() {
return "";
// greater is not full width :(
// return switch (this) {
// case NORMAL -> "";
// case GREATER -> "";
// case LEGENDARY -> "";
// };
}
public Style getStyle() {
return switch (this) {
case NORMAL -> Style.EMPTY.withColor(ChatFormatting.WHITE);
case GREATER -> Style.EMPTY.withColor(TextColor.fromRgb(5886486));
case LEGENDARY -> Style.EMPTY.withColor(ChatFormatting.GOLD);
};
}
public int getTierIncrease() {
return switch (this) {
case NORMAL -> 0;
case GREATER -> 1;
case LEGENDARY -> 2;
};
}
public ModifierCategory next() {
return values()[(this.ordinal() + 1) % values().length];
}
}

View file

@ -34,13 +34,13 @@ public class Modifiers {
new ChatFormatting[]{ChatFormatting.RED, ChatFormatting.GREEN, ChatFormatting.BLUE, ChatFormatting.YELLOW,
ChatFormatting.LIGHT_PURPLE, ChatFormatting.AQUA, ChatFormatting.WHITE};
public static List<Component> getModifierList(int lvl, VaultGearTierConfig cfg, int tierIncrease) {
public static List<Component> getModifierList(int lvl, VaultGearTierConfig cfg, ModifierCategory modifierCategory) {
Map<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> modifierGroup = ((VaultGearTierConfigAccessor) cfg).getModifierGroup();
ArrayList<Component> modList = new ArrayList<>();
for (VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup : modifierGroup.keySet()) {
modList.addAll(getAffixGroupComponents(lvl, affixTagGroup, modifierGroup, tierIncrease));
modList.addAll(getAffixGroupComponents(lvl, affixTagGroup, modifierGroup, modifierCategory));
}
return modList;
@ -48,7 +48,7 @@ public class Modifiers {
private static List<Component> getAffixGroupComponents(int lvl, VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup,
Map<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> modifierGroup,
int tierIncrease) {
ModifierCategory modifierCategory) {
ArrayList<Component> componentList = new ArrayList<>();
if (!Config.SHOW_ABILITY_ENHANCEMENTS.get() && affixTagGroup.equals(VaultGearTierConfig.ModifierAffixTagGroup.ABILITY_ENHANCEMENT)) {
@ -67,7 +67,7 @@ public class Modifiers {
}
Map<String, Integer> groupCounts = countGroups(lvl, affixTagGroup, modifierGroup, tierIncrease);
Map<String, Integer> groupCounts = countGroups(lvl, affixTagGroup, modifierGroup, modifierCategory);
Map<String, List<Component>> groupedModifiers = new HashMap<>();
for (VaultGearTierConfig.ModifierTierGroup modifierTierGroup : modifierGroup.get(affixTagGroup)) {
@ -75,8 +75,8 @@ public class Modifiers {
// TODO: support greater modifiers (greater is +1 tier, legendary is +2 tiers) (look how VH does it)
// maybe ENUM - NORMAL, GREATER, LEGENDARY and the button would cycle through them
if (tierIncrease > 0) {
mTierList = getIncreasedModifierTiers(lvl, modifierTierGroup, tierIncrease);
if (modifierCategory.getTierIncrease() > 0) {
mTierList = getIncreasedModifierTiers(lvl, modifierTierGroup, modifierCategory);
} else {
mTierList = getModifierTiers(lvl, modifierTierGroup);
}
@ -103,7 +103,7 @@ public class Modifiers {
}
if (Config.SHOW_CHANCE.get()) {
full.append(String.format(" %.2f %%", ((double) weight * 100 / totalWeight)));
full.append(String.format(" %.2f%%", ((double) weight * 100 / totalWeight)));
}
if (Config.ALLOW_DUPE.get() || !(componentList.get(componentList.size() - 1).getString()).equals(full.getString())) { //dumb way to fix ability lvl+ duplication
@ -128,12 +128,12 @@ public class Modifiers {
private static Map<String, Integer> countGroups(int lvl, VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup,
Map<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> modifierGroup,
int tierIncrease) {
ModifierCategory modifierCategory) {
Map<String, Integer> groupCounts = new HashMap<>();
for (VaultGearTierConfig.ModifierTierGroup modifierTierGroup : modifierGroup.get(affixTagGroup)) {
ArrayList<VaultGearTierConfig.ModifierTier<?>> mTierList;
if (tierIncrease > 0) {
mTierList = getIncreasedModifierTiers(lvl, modifierTierGroup, tierIncrease);
if (modifierCategory.getTierIncrease() > 0) {
mTierList = getIncreasedModifierTiers(lvl, modifierTierGroup, modifierCategory);
} else {
mTierList = getModifierTiers(lvl, modifierTierGroup);
}
@ -148,14 +148,14 @@ public class Modifiers {
//TODO: check how noLegendary works in VH
private static ArrayList<VaultGearTierConfig.ModifierTier<?>> getIncreasedModifierTiers(int lvl,
VaultGearTierConfig.ModifierTierGroup modifierTierGroup, int tierIncrease) {
VaultGearTierConfig.ModifierTierGroup modifierTierGroup, ModifierCategory modifierCategory) {
var res = new ArrayList<VaultGearTierConfig.ModifierTier<?>>();
var highest = modifierTierGroup.getHighestForLevel(lvl);
if (highest == null) {
return res; // empty
}
int index = Math.min(highest.getModifierTier() + tierIncrease, modifierTierGroup.size() - 1);
int index = Math.min(highest.getModifierTier() + modifierCategory.getTierIncrease(), modifierTierGroup.size() - 1);
var legendTier = modifierTierGroup.get(index);
if (legendTier == null || legendTier.getWeight() == 0){
return res; // empty

View file

@ -4,6 +4,7 @@ import com.mojang.blaze3d.platform.InputConstants;
import com.radimous.vhatcaniroll.Config;
import com.radimous.vhatcaniroll.logic.Items;
import com.radimous.vhatcaniroll.logic.ModifierCategory;
import iskallia.vault.client.gui.framework.ScreenRenderers;
import iskallia.vault.client.gui.framework.ScreenTextures;
import iskallia.vault.client.gui.framework.element.FakeItemSlotElement;
@ -34,8 +35,8 @@ public class GearModifierScreen extends AbstractElementScreen {
private ModifierListContainer modifierList;
private final ScrollableLvlInputElement lvlInput;
private int tierIncrease = 0;
private LabelElement<?> legendaryLabel;
private ModifierCategory modifierCategory = ModifierCategory.NORMAL;
private LabelElement<?> modifierCategoryLabel;
private int currIndex = 0;
private final List<TabElement<?>> tabs = new ArrayList<>();
@ -74,7 +75,7 @@ public class GearModifierScreen extends AbstractElementScreen {
// inner black window
ISpatial modListSpatial = Spatials.positionXY(7, 50).size(this.getGuiSpatial().width() - 14, this.getGuiSpatial().height() - 57);
this.modifierList = new ModifierListContainer(modListSpatial, lvlInput.getValue(), tierIncrease, getCurrGear()).layout(this.translateWorldSpatial());
this.modifierList = new ModifierListContainer(modListSpatial, lvlInput.getValue(), modifierCategory, getCurrGear()).layout(this.translateWorldSpatial());
this.addElement(this.modifierList);
}
@ -93,7 +94,7 @@ public class GearModifierScreen extends AbstractElementScreen {
this.removeElement(this.modifierList);
ISpatial modListSpatial = Spatials.positionXY(7, 50).size(this.getGuiSpatial().width() - 14, this.getGuiSpatial().height() - 57);
this.modifierList = new ModifierListContainer(modListSpatial, lvlInput.getValue(), tierIncrease, getCurrGear()).layout(this.translateWorldSpatial());
this.modifierList = new ModifierListContainer(modListSpatial, lvlInput.getValue(), modifierCategory, getCurrGear()).layout(this.translateWorldSpatial());
if (keepScroll) {
this.modifierList.setScroll(oldScroll);
@ -221,28 +222,27 @@ public class GearModifierScreen extends AbstractElementScreen {
this.addElement(btnPlus);
}
private void toggleLegend() {
this.tierIncrease = (tierIncrease + 1) % 3;
updateLegendaryLabel();
private void cycleModifierCategories() {
this.modifierCategory = modifierCategory.next();
updateModifierCategoryLabel();
updateModifierList(true);
}
private void updateLegendaryLabel() {
if (this.legendaryLabel != null) {
this.removeElement(this.legendaryLabel);
private void updateModifierCategoryLabel() {
if (this.modifierCategoryLabel != null) {
this.removeElement(this.modifierCategoryLabel);
}
var formatting = tierIncrease == 2 ? ChatFormatting.GOLD : tierIncrease == 1 ? ChatFormatting.AQUA : ChatFormatting.WHITE;
this.legendaryLabel = new LabelElement<>(Spatials.positionXY(this.getGuiSpatial().width() - 5 - 13, 38),
new TextComponent("").withStyle(formatting), LabelTextStyle.defaultStyle())
this.modifierCategoryLabel = new LabelElement<>(Spatials.positionXY(this.getGuiSpatial().width() - 5 - 13, 38),
new TextComponent(modifierCategory.getSymbol()).withStyle(modifierCategory.getStyle()), LabelTextStyle.defaultStyle())
.layout(this.translateWorldSpatial());
this.addElement(legendaryLabel);
this.addElement(modifierCategoryLabel);
}
private void createLegendaryButton() {
updateLegendaryLabel();
updateModifierCategoryLabel();
NineSliceButtonElement<?> btnLegend =
new NineSliceButtonElement<>(Spatials.positionXY(this.getGuiSpatial().width() - 8 - 13, 35).size(14, 14),
ScreenTextures.BUTTON_EMPTY_TEXTURES, this::toggleLegend).layout(this.translateWorldSpatial());
ScreenTextures.BUTTON_EMPTY_TEXTURES, this::cycleModifierCategories).layout(this.translateWorldSpatial());
this.addElement(btnLegend);
}
@ -270,9 +270,9 @@ public class GearModifierScreen extends AbstractElementScreen {
if (keyCode == InputConstants.KEY_TAB && hasShiftDown()) {
switchTab((currIndex - 1 + Items.getVaultGearItems().size()) % Items.getVaultGearItems().size());
}
// ctrl to change tier increase (normal, greater, legendary)
// ctrl to change modifier category (normal, greater, legendary)
if (keyCode == InputConstants.KEY_LCONTROL || keyCode == InputConstants.KEY_RCONTROL) {
toggleLegend();
cycleModifierCategories();
}
// ctrl + , to toggle compact +lvl to abilities
if (keyCode == InputConstants.KEY_COMMA && hasControlDown()) {

View file

@ -1,5 +1,6 @@
package com.radimous.vhatcaniroll.ui;
import com.radimous.vhatcaniroll.logic.ModifierCategory;
import iskallia.vault.client.gui.framework.ScreenTextures;
import iskallia.vault.client.gui.framework.element.LabelElement;
import iskallia.vault.client.gui.framework.element.VerticalScrollClipContainer;
@ -8,7 +9,6 @@ import iskallia.vault.client.gui.framework.spatial.Spatials;
import iskallia.vault.client.gui.framework.spatial.spi.ISpatial;
import iskallia.vault.client.gui.framework.text.LabelTextStyle;
import iskallia.vault.config.gear.VaultGearTierConfig;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack;
@ -18,7 +18,7 @@ import com.radimous.vhatcaniroll.logic.Modifiers;
public class ModifierListContainer extends VerticalScrollClipContainer<ModifierListContainer> {
public ModifierListContainer(ISpatial spatial, int lvl, int tierIncrease, ItemStack gearPiece) {
public ModifierListContainer(ISpatial spatial, int lvl, ModifierCategory modifierCategory, ItemStack gearPiece) {
super(spatial, Padding.ZERO, ScreenTextures.INSET_BLACK_BACKGROUND);
int labelX = 9;
int labelY = 20;
@ -29,15 +29,14 @@ public class ModifierListContainer extends VerticalScrollClipContainer<ModifierL
LabelElement<?> itemName = new LabelElement<>(
Spatials.positionXY(labelX, 5).width(this.innerWidth() - labelX).height(15), new TextComponent(
gearPiece.getItem().toString().toUpperCase() + " - LVL " + lvl)
//TODO: make it nicer
.withStyle(ChatFormatting.UNDERLINE).withStyle(tierIncrease == 2 ? ChatFormatting.GOLD : tierIncrease == 1 ? ChatFormatting.AQUA : ChatFormatting.WHITE), LabelTextStyle.defaultStyle()
.withStyle(modifierCategory.getStyle()), LabelTextStyle.defaultStyle()
);
this.addElement(itemName);
if (optCfg.isPresent()) {
VaultGearTierConfig cfg = optCfg.get();
for (var modifier : Modifiers.getModifierList(lvl, cfg, tierIncrease)) {
for (var modifier : Modifiers.getModifierList(lvl, cfg, modifierCategory)) {
LabelElement<?> labelelement = new LabelElement<>(
Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), modifier, LabelTextStyle.defaultStyle()
);