Skip to content

Commit 827a130

Browse files
committed
improve ui and fix entry settings
1 parent 65c03a0 commit 827a130

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

src/main/java/gregtech/api/cover/CoverWithUI.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ static Flow createTitleRow(ItemStack stack) {
105105
.child(new ItemDrawable(stack).asWidget().size(16).marginRight(4))
106106
.child(IKey.str(stack.getDisplayName())
107107
.color(UI_TITLE_COLOR)
108-
.shadow(false)
109108
.asWidget().heightRel(1.0f));
110109
}
111110

src/main/java/gregtech/common/covers/ender/CoverAbstractEnderLink.java

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.cleanroommc.modularui.widgets.textfield.TextFieldWidget;
4949
import org.jetbrains.annotations.NotNull;
5050
import org.jetbrains.annotations.Nullable;
51+
import org.lwjgl.input.Keyboard;
5152

5253
import java.util.Objects;
5354
import java.util.Set;
@@ -303,25 +304,35 @@ protected PanelSyncHandler.IPanelBuilder entrySelector(EntryTypes<T> type) {
303304
}
304305

305306
protected PanelSyncHandler.IPanelBuilder entryDescription(String key, T entry) {
306-
return (syncManager, syncHandler) -> GTGuis.createPopupPanel(key, 168, 36 + 6)
307-
.child(IKey.lang("cover.generic.ender.set_description.title", entry.getColorStr())
308-
.color(UI_TITLE_COLOR)
309-
.shadow(false)
310-
.asWidget()
311-
.left(4)
312-
.top(6))
313-
.child(new TextFieldWidget()
314-
.setTextColor(Color.WHITE.darker(1))
315-
.widthRel(0.95f)
316-
.height(18)
317-
.value(new StringSyncValue(entry::getDescription, string -> {
318-
entry.setDescription(string);
319-
if (syncHandler.isPanelOpen()) {
320-
syncHandler.closePanel();
307+
return (syncManager, syncHandler) -> {
308+
var sync = new StringSyncValue(entry::getDescription, entry::setDescription);
309+
return GTGuis.createPopupPanel(key, 168, 36 + 6)
310+
.child(IKey.lang("cover.generic.ender.set_description.title", entry.getColorStr())
311+
.color(UI_TITLE_COLOR)
312+
.asWidget()
313+
.left(4)
314+
.top(6))
315+
.child(new TextFieldWidget() {
316+
317+
// todo move this to new class?
318+
@Override
319+
public @NotNull Result onKeyPressed(char character, int keyCode) {
320+
var result = super.onKeyPressed(character, keyCode);
321+
if (result == Result.SUCCESS && keyCode == Keyboard.KEY_RETURN) {
322+
sync.setStringValue(getText());
323+
if (syncHandler.isPanelOpen()) {
324+
syncHandler.closePanel();
325+
}
321326
}
322-
}))
323-
.alignX(0.5f)
324-
.bottom(6));
327+
return result;
328+
}
329+
}.setTextColor(Color.WHITE.darker(1))
330+
.value(sync)
331+
.widthRel(0.95f)
332+
.height(18)
333+
.alignX(0.5f)
334+
.bottom(6));
335+
};
325336
}
326337

327338
protected IWidget createRow(final String name, final PanelSyncManager syncManager, final EntryTypes<T> type) {
@@ -346,7 +357,7 @@ protected IWidget createRow(final String name, final PanelSyncManager syncManage
346357
.size(16)
347358
.background(GTGuiTextures.SLOT.asIcon().size(18))
348359
.top(1))
349-
.child(new InteractableText<>(entry, CoverAbstractEnderLink.this::updateColor)
360+
.child(new InteractableText<>(entry, this::updateColor)
350361
.tooltip(tooltip -> tooltip.setAutoUpdate(true))
351362
.tooltipBuilder(tooltip -> {
352363
String desc = entry.getDescription();
@@ -361,7 +372,6 @@ protected IWidget createRow(final String name, final PanelSyncManager syncManage
361372
.addTooltipLine(IKey.lang("cover.generic.ender.set_description.tooltip"))
362373
.onMousePressed(i -> {
363374
// open entry settings
364-
// todo this isn't working for some reason
365375
if (panelHandler.isPanelOpen()) {
366376
panelHandler.closePanel();
367377
} else {

0 commit comments

Comments
 (0)