Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max amount in autocrafting preview #758

Merged
merged 6 commits into from
Dec 27, 2024
Merged
Changes from 1 commit
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
Next Next commit
fix: amount in amount screen resetting when resizing
  • Loading branch information
raoulvdberge committed Dec 27, 2024
commit 6bce70848c5b4a3d8c159f66aa9e87f3bede1644
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -16,6 +16,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Autocrafting now handles multiple patterns with the same output correctly by trying to use the pattern with the
highest priority first. If there are missing resources, lower priority patterns are checked.

### Fixed

- Fixed amount in amount screens resetting when resizing the screen.

## [2.0.0-milestone.4.11] - 2024-12-08

### Added
Original file line number Diff line number Diff line change
@@ -114,6 +114,7 @@ public AutocraftingPreviewScreen(final AutocraftingPreviewContainerMenu menu,

@Override
protected void init() {
final boolean wasAlreadyInitialized = amountField != null;
super.init();
previewItemsScrollbar = new ScrollbarWidget(
leftPos + 235,
@@ -128,7 +129,9 @@ protected void init() {
if (confirmButton != null) {
setStartDisabled();
}
getMenu().loadCurrentRequest();
if (!wasAlreadyInitialized) {
getMenu().loadCurrentRequest();
}
getExclusionZones().add(new Rect2i(
leftPos - REQUESTS_WIDTH + 4,
topPos,
@@ -424,13 +427,19 @@ protected void onAmountFieldChanged() {
}

private void setPending() {
if (confirmButton == null) {
return;
}
confirmButton.active = false;
confirmButton.setError(false);
confirmButton.setTooltip(null);
confirmButton.setMessage(PENDING);
}

private void setStartDisabled() {
if (confirmButton == null) {
return;
}
confirmButton.active = false;
confirmButton.setError(false);
confirmButton.setTooltip(null);
Original file line number Diff line number Diff line change
@@ -117,6 +117,7 @@ private Button addCancelButton(final int x, final int y) {

private void addAmountField() {
final Vector3f pos = configuration.getAmountFieldPosition();
final String originalValue = amountField != null ? amountField.getValue() : null;
amountField = new EditBox(
font,
leftPos + (int) pos.x(),
@@ -126,14 +127,17 @@ private void addAmountField() {
Component.empty()
);
amountField.setBordered(false);
if (configuration.getInitialAmount() != null) {
amountField.setTextColor(0xFFFFFF);
if (originalValue != null) {
amountField.setValue(originalValue);
onAmountFieldChanged();
} else if (configuration.getInitialAmount() != null) {
updateAmount(configuration.getInitialAmount());
}
amountField.setVisible(true);
amountField.setCanLoseFocus(this instanceof AlternativesScreen);
amountField.setFocused(true);
amountField.setResponder(value -> onAmountFieldChanged());
amountField.setTextColor(0xFFFFFF);
setFocused(amountField);

addRenderableWidget(amountField);