Skip to content

Commit

Permalink
fix: Properly format major IDs in item guide (Wynntils#1960)
Browse files Browse the repository at this point in the history
* fix: Properly format major IDs in item guide

* Restore getString
  • Loading branch information
magicus authored Aug 8, 2023
1 parent 45ddb28 commit c3d3c2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ public static List<Component> buildTooltip(GearInfo gearInfo, GearInstance gearI
List<Component> footer = new ArrayList<>();

// major ids
// FIXME: This is not the format Wynncraft uses. The major ID name should be followed
// by the lore directly on the same line.
// To fix this, we need a version af wrapTextBySize() that can take in a Component.
// For now, print the name of the major ID on a separate line.
if (!gearInfo.fixedStats().majorIds().isEmpty()) {
for (GearMajorId majorId : gearInfo.fixedStats().majorIds()) {
footer.add(Component.literal("+" + majorId.name() + ": ").withStyle(ChatFormatting.AQUA));
Stream.of(RenderedStringUtils.wrapTextBySize(majorId.lore(), PIXEL_WIDTH))
.forEach(c -> footer.add(c.getComponent().withStyle(ChatFormatting.DARK_AQUA)));
StyledText name = StyledText.fromString(ChatFormatting.AQUA + "+" + majorId.name() + ": ");
// This dance to and from component is needed to properly recolor all neutral text
StyledText lore = StyledText.fromComponent(Component.empty()
.withStyle(ChatFormatting.DARK_AQUA)
.append(majorId.lore().getComponent()));
StyledText majorIdText = name.append(lore);

Stream.of(RenderedStringUtils.wrapTextBySize(majorIdText, PIXEL_WIDTH))
.forEach(c -> footer.add(c.getComponent()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public static StyledText[] wrapTextBySize(StyledText s, int maxPixels) {
StringBuilder result = new StringBuilder();
int length = 0;

// FIXME: codes should not count toward the word length

for (StyledText string : stringArray) {
StyledText[] lines = string.split("\\\\n");
for (int i = 0; i < lines.length; i++) {
Expand Down

0 comments on commit c3d3c2c

Please sign in to comment.