Skip to content

Commit

Permalink
Improve searching configs
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Apr 15, 2024
1 parent 0fca143 commit 84acf80
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@
import me.shedaniel.rei.impl.client.gui.widget.basewidgets.TextFieldWidget;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import org.apache.commons.compress.harmony.unpack200.bytecode.forms.WideForm;
import net.minecraft.network.chat.Component;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -92,7 +91,7 @@ public REIConfigScreen(Screen parent) {
}

public REIConfigScreen(Screen parent, List<OptionCategory> categories) {
super(new TranslatableComponent("config.roughlyenoughitems.title"));
super(Component.translatable("config.roughlyenoughitems.title"));
this.parent = parent;
this.categories = CollectionUtils.map(categories, OptionCategory::copy);
this.cleanRequiresLevel();
Expand Down Expand Up @@ -158,6 +157,12 @@ protected void renderSuggestion(PoseStack matrices, int x, int y) {
this.widgets.add(textField);
this.widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
textField.setSuggestion(!textField.isFocused() && textField.getText().isEmpty() ? I18n.get("config.rei.texts.search_options") : null);
if (!textField.isFocused()) return;
Rectangle bounds = textField.getBounds();
GuiComponent.fill(matrices, bounds.x - 6, bounds.y - 6, bounds.getMaxX() + 4, bounds.y - 5, 0xffe0e0e0);
GuiComponent.fill(matrices, bounds.x - 6, bounds.getMaxY() + 1, bounds.getMaxX() + 4, bounds.getMaxY() + 2, 0xffe0e0e0);
GuiComponent.fill(matrices, bounds.x - 6, bounds.y - 6, bounds.x - 7, bounds.getMaxY() + 2, 0xffe0e0e0);
GuiComponent.fill(matrices, bounds.getMaxX() + 3, bounds.y - 6, bounds.getMaxX() + 4, bounds.getMaxY() + 2, 0xffe0e0e0);
}));
this.widgets.add(ConfigSearchListWidget.create(this, this.categories, textField, new Rectangle(8, 32 + 20 + 4, width - 16, height - 32 - (32 + 20 + 4))));
} else {
Expand Down Expand Up @@ -230,7 +235,11 @@ public void render(PoseStack poses, int mouseX, int mouseY, float delta) {

@Override
public void onClose() {
this.minecraft.setScreen(this.parent);
if (searching) {
setSearching(false);
} else {
this.minecraft.setScreen(this.parent);
}
}

@Override
Expand Down

0 comments on commit 84acf80

Please sign in to comment.