support greater modifier category
This commit is contained in:
parent
602d181e58
commit
1ef461ab37
4 changed files with 76 additions and 35 deletions
|
|
@ -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];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -34,13 +34,13 @@ public class Modifiers {
|
||||||
new ChatFormatting[]{ChatFormatting.RED, ChatFormatting.GREEN, ChatFormatting.BLUE, ChatFormatting.YELLOW,
|
new ChatFormatting[]{ChatFormatting.RED, ChatFormatting.GREEN, ChatFormatting.BLUE, ChatFormatting.YELLOW,
|
||||||
ChatFormatting.LIGHT_PURPLE, ChatFormatting.AQUA, ChatFormatting.WHITE};
|
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();
|
Map<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> modifierGroup = ((VaultGearTierConfigAccessor) cfg).getModifierGroup();
|
||||||
|
|
||||||
ArrayList<Component> modList = new ArrayList<>();
|
ArrayList<Component> modList = new ArrayList<>();
|
||||||
|
|
||||||
for (VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup : modifierGroup.keySet()) {
|
for (VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup : modifierGroup.keySet()) {
|
||||||
modList.addAll(getAffixGroupComponents(lvl, affixTagGroup, modifierGroup, tierIncrease));
|
modList.addAll(getAffixGroupComponents(lvl, affixTagGroup, modifierGroup, modifierCategory));
|
||||||
}
|
}
|
||||||
|
|
||||||
return modList;
|
return modList;
|
||||||
|
|
@ -48,7 +48,7 @@ public class Modifiers {
|
||||||
|
|
||||||
private static List<Component> getAffixGroupComponents(int lvl, VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup,
|
private static List<Component> getAffixGroupComponents(int lvl, VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup,
|
||||||
Map<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> modifierGroup,
|
Map<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> modifierGroup,
|
||||||
int tierIncrease) {
|
ModifierCategory modifierCategory) {
|
||||||
|
|
||||||
ArrayList<Component> componentList = new ArrayList<>();
|
ArrayList<Component> componentList = new ArrayList<>();
|
||||||
if (!Config.SHOW_ABILITY_ENHANCEMENTS.get() && affixTagGroup.equals(VaultGearTierConfig.ModifierAffixTagGroup.ABILITY_ENHANCEMENT)) {
|
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<>();
|
Map<String, List<Component>> groupedModifiers = new HashMap<>();
|
||||||
for (VaultGearTierConfig.ModifierTierGroup modifierTierGroup : modifierGroup.get(affixTagGroup)) {
|
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)
|
// 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
|
// maybe ENUM - NORMAL, GREATER, LEGENDARY and the button would cycle through them
|
||||||
if (tierIncrease > 0) {
|
if (modifierCategory.getTierIncrease() > 0) {
|
||||||
mTierList = getIncreasedModifierTiers(lvl, modifierTierGroup, tierIncrease);
|
mTierList = getIncreasedModifierTiers(lvl, modifierTierGroup, modifierCategory);
|
||||||
} else {
|
} else {
|
||||||
mTierList = getModifierTiers(lvl, modifierTierGroup);
|
mTierList = getModifierTiers(lvl, modifierTierGroup);
|
||||||
}
|
}
|
||||||
|
|
@ -128,12 +128,12 @@ public class Modifiers {
|
||||||
|
|
||||||
private static Map<String, Integer> countGroups(int lvl, VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup,
|
private static Map<String, Integer> countGroups(int lvl, VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup,
|
||||||
Map<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> modifierGroup,
|
Map<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> modifierGroup,
|
||||||
int tierIncrease) {
|
ModifierCategory modifierCategory) {
|
||||||
Map<String, Integer> groupCounts = new HashMap<>();
|
Map<String, Integer> groupCounts = new HashMap<>();
|
||||||
for (VaultGearTierConfig.ModifierTierGroup modifierTierGroup : modifierGroup.get(affixTagGroup)) {
|
for (VaultGearTierConfig.ModifierTierGroup modifierTierGroup : modifierGroup.get(affixTagGroup)) {
|
||||||
ArrayList<VaultGearTierConfig.ModifierTier<?>> mTierList;
|
ArrayList<VaultGearTierConfig.ModifierTier<?>> mTierList;
|
||||||
if (tierIncrease > 0) {
|
if (modifierCategory.getTierIncrease() > 0) {
|
||||||
mTierList = getIncreasedModifierTiers(lvl, modifierTierGroup, tierIncrease);
|
mTierList = getIncreasedModifierTiers(lvl, modifierTierGroup, modifierCategory);
|
||||||
} else {
|
} else {
|
||||||
mTierList = getModifierTiers(lvl, modifierTierGroup);
|
mTierList = getModifierTiers(lvl, modifierTierGroup);
|
||||||
}
|
}
|
||||||
|
|
@ -148,14 +148,14 @@ public class Modifiers {
|
||||||
|
|
||||||
//TODO: check how noLegendary works in VH
|
//TODO: check how noLegendary works in VH
|
||||||
private static ArrayList<VaultGearTierConfig.ModifierTier<?>> getIncreasedModifierTiers(int lvl,
|
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 res = new ArrayList<VaultGearTierConfig.ModifierTier<?>>();
|
||||||
var highest = modifierTierGroup.getHighestForLevel(lvl);
|
var highest = modifierTierGroup.getHighestForLevel(lvl);
|
||||||
if (highest == null) {
|
if (highest == null) {
|
||||||
return res; // empty
|
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);
|
var legendTier = modifierTierGroup.get(index);
|
||||||
if (legendTier == null || legendTier.getWeight() == 0){
|
if (legendTier == null || legendTier.getWeight() == 0){
|
||||||
return res; // empty
|
return res; // empty
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.mojang.blaze3d.platform.InputConstants;
|
||||||
import com.radimous.vhatcaniroll.Config;
|
import com.radimous.vhatcaniroll.Config;
|
||||||
import com.radimous.vhatcaniroll.logic.Items;
|
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.ScreenRenderers;
|
||||||
import iskallia.vault.client.gui.framework.ScreenTextures;
|
import iskallia.vault.client.gui.framework.ScreenTextures;
|
||||||
import iskallia.vault.client.gui.framework.element.FakeItemSlotElement;
|
import iskallia.vault.client.gui.framework.element.FakeItemSlotElement;
|
||||||
|
|
@ -34,8 +35,8 @@ public class GearModifierScreen extends AbstractElementScreen {
|
||||||
|
|
||||||
private ModifierListContainer modifierList;
|
private ModifierListContainer modifierList;
|
||||||
private final ScrollableLvlInputElement lvlInput;
|
private final ScrollableLvlInputElement lvlInput;
|
||||||
private int tierIncrease = 0;
|
private ModifierCategory modifierCategory = ModifierCategory.NORMAL;
|
||||||
private LabelElement<?> legendaryLabel;
|
private LabelElement<?> modifierCategoryLabel;
|
||||||
|
|
||||||
private int currIndex = 0;
|
private int currIndex = 0;
|
||||||
private final List<TabElement<?>> tabs = new ArrayList<>();
|
private final List<TabElement<?>> tabs = new ArrayList<>();
|
||||||
|
|
@ -74,7 +75,7 @@ public class GearModifierScreen extends AbstractElementScreen {
|
||||||
|
|
||||||
// inner black window
|
// inner black window
|
||||||
ISpatial modListSpatial = Spatials.positionXY(7, 50).size(this.getGuiSpatial().width() - 14, this.getGuiSpatial().height() - 57);
|
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);
|
this.addElement(this.modifierList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +94,7 @@ public class GearModifierScreen extends AbstractElementScreen {
|
||||||
|
|
||||||
this.removeElement(this.modifierList);
|
this.removeElement(this.modifierList);
|
||||||
ISpatial modListSpatial = Spatials.positionXY(7, 50).size(this.getGuiSpatial().width() - 14, this.getGuiSpatial().height() - 57);
|
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) {
|
if (keepScroll) {
|
||||||
this.modifierList.setScroll(oldScroll);
|
this.modifierList.setScroll(oldScroll);
|
||||||
|
|
@ -221,28 +222,27 @@ public class GearModifierScreen extends AbstractElementScreen {
|
||||||
this.addElement(btnPlus);
|
this.addElement(btnPlus);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleLegend() {
|
private void cycleModifierCategories() {
|
||||||
this.tierIncrease = (tierIncrease + 1) % 3;
|
this.modifierCategory = modifierCategory.next();
|
||||||
updateLegendaryLabel();
|
updateModifierCategoryLabel();
|
||||||
updateModifierList(true);
|
updateModifierList(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLegendaryLabel() {
|
private void updateModifierCategoryLabel() {
|
||||||
if (this.legendaryLabel != null) {
|
if (this.modifierCategoryLabel != null) {
|
||||||
this.removeElement(this.legendaryLabel);
|
this.removeElement(this.modifierCategoryLabel);
|
||||||
}
|
}
|
||||||
var formatting = tierIncrease == 2 ? ChatFormatting.GOLD : tierIncrease == 1 ? ChatFormatting.AQUA : ChatFormatting.WHITE;
|
this.modifierCategoryLabel = new LabelElement<>(Spatials.positionXY(this.getGuiSpatial().width() - 5 - 13, 38),
|
||||||
this.legendaryLabel = new LabelElement<>(Spatials.positionXY(this.getGuiSpatial().width() - 5 - 13, 38),
|
new TextComponent(modifierCategory.getSymbol()).withStyle(modifierCategory.getStyle()), LabelTextStyle.defaultStyle())
|
||||||
new TextComponent("✦").withStyle(formatting), LabelTextStyle.defaultStyle())
|
|
||||||
.layout(this.translateWorldSpatial());
|
.layout(this.translateWorldSpatial());
|
||||||
this.addElement(legendaryLabel);
|
this.addElement(modifierCategoryLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createLegendaryButton() {
|
private void createLegendaryButton() {
|
||||||
updateLegendaryLabel();
|
updateModifierCategoryLabel();
|
||||||
NineSliceButtonElement<?> btnLegend =
|
NineSliceButtonElement<?> btnLegend =
|
||||||
new NineSliceButtonElement<>(Spatials.positionXY(this.getGuiSpatial().width() - 8 - 13, 35).size(14, 14),
|
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);
|
this.addElement(btnLegend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,9 +270,9 @@ public class GearModifierScreen extends AbstractElementScreen {
|
||||||
if (keyCode == InputConstants.KEY_TAB && hasShiftDown()) {
|
if (keyCode == InputConstants.KEY_TAB && hasShiftDown()) {
|
||||||
switchTab((currIndex - 1 + Items.getVaultGearItems().size()) % Items.getVaultGearItems().size());
|
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) {
|
if (keyCode == InputConstants.KEY_LCONTROL || keyCode == InputConstants.KEY_RCONTROL) {
|
||||||
toggleLegend();
|
cycleModifierCategories();
|
||||||
}
|
}
|
||||||
// ctrl + , to toggle compact +lvl to abilities
|
// ctrl + , to toggle compact +lvl to abilities
|
||||||
if (keyCode == InputConstants.KEY_COMMA && hasControlDown()) {
|
if (keyCode == InputConstants.KEY_COMMA && hasControlDown()) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.radimous.vhatcaniroll.ui;
|
package com.radimous.vhatcaniroll.ui;
|
||||||
|
|
||||||
|
import com.radimous.vhatcaniroll.logic.ModifierCategory;
|
||||||
import iskallia.vault.client.gui.framework.ScreenTextures;
|
import iskallia.vault.client.gui.framework.ScreenTextures;
|
||||||
import iskallia.vault.client.gui.framework.element.LabelElement;
|
import iskallia.vault.client.gui.framework.element.LabelElement;
|
||||||
import iskallia.vault.client.gui.framework.element.VerticalScrollClipContainer;
|
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.spatial.spi.ISpatial;
|
||||||
import iskallia.vault.client.gui.framework.text.LabelTextStyle;
|
import iskallia.vault.client.gui.framework.text.LabelTextStyle;
|
||||||
import iskallia.vault.config.gear.VaultGearTierConfig;
|
import iskallia.vault.config.gear.VaultGearTierConfig;
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ import com.radimous.vhatcaniroll.logic.Modifiers;
|
||||||
|
|
||||||
public class ModifierListContainer extends VerticalScrollClipContainer<ModifierListContainer> {
|
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);
|
super(spatial, Padding.ZERO, ScreenTextures.INSET_BLACK_BACKGROUND);
|
||||||
int labelX = 9;
|
int labelX = 9;
|
||||||
int labelY = 20;
|
int labelY = 20;
|
||||||
|
|
@ -29,15 +29,14 @@ public class ModifierListContainer extends VerticalScrollClipContainer<ModifierL
|
||||||
LabelElement<?> itemName = new LabelElement<>(
|
LabelElement<?> itemName = new LabelElement<>(
|
||||||
Spatials.positionXY(labelX, 5).width(this.innerWidth() - labelX).height(15), new TextComponent(
|
Spatials.positionXY(labelX, 5).width(this.innerWidth() - labelX).height(15), new TextComponent(
|
||||||
gearPiece.getItem().toString().toUpperCase() + " - LVL " + lvl)
|
gearPiece.getItem().toString().toUpperCase() + " - LVL " + lvl)
|
||||||
//TODO: make it nicer
|
.withStyle(modifierCategory.getStyle()), LabelTextStyle.defaultStyle()
|
||||||
.withStyle(ChatFormatting.UNDERLINE).withStyle(tierIncrease == 2 ? ChatFormatting.GOLD : tierIncrease == 1 ? ChatFormatting.AQUA : ChatFormatting.WHITE), LabelTextStyle.defaultStyle()
|
|
||||||
);
|
);
|
||||||
this.addElement(itemName);
|
this.addElement(itemName);
|
||||||
|
|
||||||
|
|
||||||
if (optCfg.isPresent()) {
|
if (optCfg.isPresent()) {
|
||||||
VaultGearTierConfig cfg = optCfg.get();
|
VaultGearTierConfig cfg = optCfg.get();
|
||||||
for (var modifier : Modifiers.getModifierList(lvl, cfg, tierIncrease)) {
|
for (var modifier : Modifiers.getModifierList(lvl, cfg, modifierCategory)) {
|
||||||
LabelElement<?> labelelement = new LabelElement<>(
|
LabelElement<?> labelelement = new LabelElement<>(
|
||||||
Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), modifier, LabelTextStyle.defaultStyle()
|
Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), modifier, LabelTextStyle.defaultStyle()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue