Skip to content

Commit 100b7aa

Browse files
committed
fix last selected resolution and inconsistent move order
1 parent 3143ec1 commit 100b7aa

5 files changed

Lines changed: 11 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,2 @@
1-
- Changed the **Sort** cycling button to a dropdown button.
2-
- Added dropdown button next to the **Open Pack Folder** button to open additional folders if there is any.
3-
- Added buttons to toggle **default** and **lock** of profiles next to the profile list when on dev mode.
4-
- Increased the max height of context menu.
5-
- Fixed folder pack order not saving when the folder pack list is not closed.
6-
- Fixed 'Open File' and 'Show File Manager' context menu options not appearing when the pack file is locked.
7-
- Fixed pack entries getting stuck with the incompatible title and description when navigating by keyboard.
8-
- Fixed hidden override not immediately reflecting on the pack screen when toggling dev mode.
9-
- Fixed profile name failing to resolve when the profiles directory has not yet created.
10-
- Fixed crash when reading an invalid config file.
11-
12-
---
13-
**Packed Packs API**
14-
- Added methods to add `Renderable` and `Renderable & LayoutElement`s to `InitializePackEntryEvent`.
15-
- Added `ScreenContext#getMinecraft()`
1+
- Fixed focus not correctly resolving on updating a pack list if multiple packs are selected.
2+
- Fixed inconsistent move order when dragging and dropping multiple packs to the same pack list

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ org.gradle.parallel=true
55
# Project
66
archives_base_name=packed_packs
77
maven_group=io.github.fishstiz.packed_packs
8-
mod_version=2.2.0-alpha.1+26.2
8+
mod_version=2.2.1-alpha.1+26.2
99
mod_id=packed_packs
1010
mod_name=Packed Packs
1111
mod_author=fishstiz

mod/common/src/main/java/io/github/fishstiz/packed_packs/gui/components/PackList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void setFocused(@Nullable GuiEventListener focused) {
251251

252252
private @Nullable Entry getSelected() {
253253
for (Entry entry : children()) {
254-
if (entry.entryModel.selected()) {
254+
if (entry.entryModel.selectedLast()) {
255255
return entry;
256256
}
257257
}

mod/common/src/main/java/io/github/fishstiz/packed_packs/gui/model/PackListViewModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public void drag() {
416416

417417
List<Pack> payload = createPayload();
418418
if (!payload.isEmpty()) {
419-
List<Pack> orderedPayload = sortByOrderOf(state.get().visiblePacks(), payload).reversed();
419+
List<Pack> orderedPayload = sortByOrderOf(state.get().visiblePacks(), payload);
420420
dispatch.accept(new PackListIntent.Drag(target, this, new ObjectLinkedOpenHashSet<>(orderedPayload)));
421421
}
422422
}

mod/common/src/main/java/io/github/fishstiz/packed_packs/gui/states/PackedPacksReducer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ yield new PackedPacksState(
156156
CollectionUtils.addIf(packs, payload, p -> canTransfer(target, p, options));
157157
if (!packs.isEmpty()) {
158158
yield this.reduce(newState, switch (destination.type()) {
159-
case AVAILABLE -> new PackListIntent.Disable(destination, ctx, packs);
160-
case ENABLED -> new PackListIntent.Enable(destination, ctx, packs, position);
159+
case AVAILABLE -> new PackListIntent.Disable(destination, ctx, packs.reversed());
160+
case ENABLED -> new PackListIntent.Enable(destination, ctx, packs.reversed(), position);
161161
});
162162
}
163163
}
@@ -246,11 +246,14 @@ private PackListState reduceList(PackListState state, PackListIntent.ListScoped
246246
List<Pack> ordered = sortByOrderOf(state.visiblePacks(), move.payload());
247247
List<Pack> newPacks = new ObjectArrayList<>(state.packs());
248248
int to = move.index();
249+
int insertOffset = 0;
249250
for (Pack pack : ordered) {
250251
int previous = newPacks.indexOf(pack);
251-
int target = previous != -1 && previous < to ? to - 1 : to;
252+
boolean isBeforeTo = previous != -1 && previous < to;
253+
int target = isBeforeTo ? to - 1 : to + insertOffset;
252254
newPacks.remove(pack);
253255
newPacks.add(Math.clamp(target, 0, newPacks.size()), pack);
256+
if (!isBeforeTo) insertOffset++;
254257
}
255258
yield newPacks.equals(state.packs()) ? state : state.withPacks(newPacks, options);
256259
}

0 commit comments

Comments
 (0)