Skip to content

Commit

Permalink
Fix cut-off labels and inconsistency in one
Browse files Browse the repository at this point in the history
* The last example from the placeholder API had the underline cut off
* Some labels in the screen-tab might have been cut off
* In Text Format, the first time the screen is opened, the label appeared at the bottom instead of where it should be
  • Loading branch information
Zailer43 committed Sep 7, 2024
1 parent 47d0b50 commit ac6e784
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ScreenTabContainer extends StyledFlowLayout {
public ScreenTabContainer(String baseTranslationKey, Sizing horizontalSizing, Sizing verticalSizing, String id) {
super(horizontalSizing, verticalSizing, Algorithm.VERTICAL);
this.selected = false;
this.componentList = new ArrayList<>();
this.componentList = null;
this.id(getScreenTabId(id));

String translationKey = "fzmm.gui." + baseTranslationKey + ".tab." + id;
Expand All @@ -30,26 +30,26 @@ public ScreenTabContainer(String baseTranslationKey, Sizing horizontalSizing, Si
.child(
StyledComponents.label(Text.translatable(translationKey))
.tooltip(Text.translatable(translationKey + ".tooltip"))
).alignment(HorizontalAlignment.CENTER, VerticalAlignment.CENTER)
.margins(Insets.vertical(4));
.margins(Insets.vertical(4))
).alignment(HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}

public void setSelected(boolean selected, boolean addLabel) {
if (this.selected && selected) {
public void setSelected(boolean select, boolean addLabel) {
if (this.selected && select) {
return;
}
this.selected = selected;
this.selected = select;

if (this.selected) {
if (this.componentList == null) {
this.componentList = new ArrayList<>(this.children());
}
this.clearChildren();

if (select) {
if (addLabel) {
this.child(this.labelLayout);
}
this.children(this.componentList);
this.componentList.clear();
} else {
this.removeChild(this.labelLayout);
this.componentList.addAll(this.children());
this.clearChildren();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.wispforest.owo.ui.component.Components;
import io.wispforest.owo.ui.container.FlowLayout;
import io.wispforest.owo.ui.core.Component;
import io.wispforest.owo.ui.core.Insets;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
import net.minecraft.item.Items;
Expand Down Expand Up @@ -68,8 +69,11 @@ private void addUsageExamples() {

componentList.add(StyledComponents.label(Text.translatable("fzmm.gui.textFormat.label.placeholderApi.examples")));

for (var example : examples)
for (var example : examples) {
componentList.add(StyledComponents.label(PlaceholderApiCompat.parse(example)).tooltip(Text.literal(example)));
}

componentList.get(componentList.size() - 1).margins(Insets.bottom(6));

this.infoLayout.children(componentList);
}
Expand Down

0 comments on commit ac6e784

Please sign in to comment.