Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,19 @@ public boolean keyPressed(int typedChar, int keyCode, int modifiers) {
return false;
}
} else {
saveSetting();
return super.keyPressed(typedChar, keyCode, modifiers);
// Don't close all GUIs, but go back to the part's aspect overview GUI.
exitToPartGui();
return true;
}
}

/**
* Save the current setting and go back to the aspect overview GUI of the part.
*/
protected void exitToPartGui() {
buttonExit.onPress();
}

@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
return subGuiHolder.mouseClicked(mouseX, mouseY, mouseButton)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class ContainerScreenPartOffset<T extends ContainerPartOffset> extends Co
private WidgetNumberField numberFieldX = null;
private WidgetNumberField numberFieldY = null;
private WidgetNumberField numberFieldZ = null;
private ButtonText buttonSave = null;

public ContainerScreenPartOffset(T container, Inventory inventory, Component title) {
super(container, inventory, title);
Expand Down Expand Up @@ -86,7 +87,7 @@ public void init() {
numberFieldZ.setCanLoseFocus(true);

MutableComponent save = Component.translatable("gui.integrateddynamics.button.save");
addRenderableWidget(new ButtonText(this.leftPos + 178, this.topPos + 6, font.width(save.getVisualOrderText()) + 6, 16, save, save,
addRenderableWidget(buttonSave = new ButtonText(this.leftPos + 178, this.topPos + 6, font.width(save.getVisualOrderText()) + 6, 16, save, save,
createServerPressable(ContainerPartOffset.BUTTON_SAVE, b -> onSave()), true));

this.refreshValues();
Expand Down Expand Up @@ -122,10 +123,19 @@ public boolean keyPressed(int typedChar, int keyCode, int modifiers) {
}
return true;
} else {
return super.keyPressed(typedChar, keyCode, modifiers);
// Don't close all GUIs, but go back to the part's GUI.
exitToPartGui();
return true;
}
}

/**
* Save the current offsets and go back to the GUI of the part.
*/
protected void exitToPartGui() {
buttonSave.onPress();
}

@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
if (this.numberFieldX.mouseClicked(mouseX, mouseY, mouseButton)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class ContainerScreenPartSettings<T extends ContainerPartSettings> extend
private WidgetNumberField numberFieldChannel = null;
private WidgetTextFieldDropdown<Direction> dropdownFieldSide = null;
private List<SideDropdownEntry> dropdownEntries;
private ButtonText buttonSave = null;

public ContainerScreenPartSettings(T container, Inventory inventory, Component title) {
super(container, inventory, title);
Expand Down Expand Up @@ -134,7 +135,7 @@ public void init() {
}

MutableComponent save = Component.translatable("gui.integrateddynamics.button.save");
addRenderableWidget(new ButtonText(this.leftPos + 178, this.topPos + 8, font.width(save.getVisualOrderText()) + 6, 16, save, save,
addRenderableWidget(buttonSave = new ButtonText(this.leftPos + 178, this.topPos + 8, font.width(save.getVisualOrderText()) + 6, 16, save, save,
createServerPressable(ContainerPartSettings.BUTTON_SAVE, b -> onSave()), true));

this.refreshValues();
Expand Down Expand Up @@ -216,10 +217,19 @@ public boolean keyPressed(int typedChar, int keyCode, int modifiers) {
}
return true;
} else {
return super.keyPressed(typedChar, keyCode, modifiers);
// Don't close all GUIs, but go back to the part's GUI.
exitToPartGui();
return true;
}
}

/**
* Save the current settings and go back to the GUI of the part.
*/
protected void exitToPartGui() {
buttonSave.onPress();
}

@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
if (isFieldSideEnabled()) {
Expand Down
Loading