SteamWar/SpigotCore
Archiviert
13
0

Merge pull request 'Add Reopen to SchematicSelector' (#169) from re_open_schem_gui into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #169
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2022-02-09 18:20:02 +01:00
Commit e9a1b4dbb2
2 geänderte Dateien mit 53 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -41,7 +41,8 @@ public class SchematicSelector {
@Getter @Getter
private SteamwarUser user; private SteamwarUser user;
@Getter @Getter
private final Consumer<SchematicNode> callback; @Setter
private Consumer<SchematicNode> callback;
private final SelectorTarget target; private final SelectorTarget target;
@Getter @Getter
private final SelectorFilter filter = new SelectorFilter(); private final SelectorFilter filter = new SelectorFilter();
@ -58,6 +59,8 @@ public class SchematicSelector {
private int depth = 0; private int depth = 0;
private Sorting sorting = Sorting.NAME; private Sorting sorting = Sorting.NAME;
private boolean invertSorting = false; private boolean invertSorting = false;
@Getter
private SchematicNode lastParent;
public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) { public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) {
this.player = player; this.player = player;
@ -78,9 +81,22 @@ public class SchematicSelector {
this.user = SteamwarUser.get(0); this.user = SteamwarUser.get(0);
} }
openList(null); openList(null);
injectable.onSelectorOpen(this, SchematicSelectorInjectable.OpenFrom.FRESH);
}
public void reOpen() {
openList(lastParent);
injectable.onSelectorOpen(this, SchematicSelectorInjectable.OpenFrom.REOPEN);
}
public void reOpenDirUp() {
depth--;
openList(dirUp(lastParent));
injectable.onSelectorOpen(this, SchematicSelectorInjectable.OpenFrom.REOPEN);
} }
private void openList(SchematicNode parent) { private void openList(SchematicNode parent) {
lastParent = parent;
List<SchematicNode> nodes = applySorting(filter.isFilter()?getFilteredSchematics():getSchematicList(parent)); List<SchematicNode> nodes = applySorting(filter.isFilter()?getFilteredSchematics():getSchematicList(parent));
if(sdoTrigger) { if(sdoTrigger) {
@ -140,14 +156,12 @@ public class SchematicSelector {
inv.open(); inv.open();
} }
private void handleClick(SchematicNode node, SchematicNode parent) { private SchematicNode dirUp(SchematicNode parent) {
if(node == null) {
depth--;
if(!singleDirOpen) { if(!singleDirOpen) {
if(NodeMember.getNodeMember(parent.getId(), user.getId()) != null) { if(NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
openList(null); return null;
} else { } else {
openList(getParent(parent)); return getParent(parent);
} }
} else { } else {
SchematicNode currentParent = parent; SchematicNode currentParent = parent;
@ -163,11 +177,17 @@ public class SchematicSelector {
getSchematicList(currentParent); getSchematicList(currentParent);
} while (sdoTrigger); } while (sdoTrigger);
if(isMember || NodeMember.getNodeMember(parent.getId(), user.getId()) != null) { if(isMember || NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
openList(null); return null;
} else { } else {
openList(currentParent); return currentParent;
} }
} }
}
private void handleClick(SchematicNode node, SchematicNode parent) {
if(node == null) {
depth--;
openList(dirUp(parent));
return; return;
} }
if(node.isDir()) { if(node.isDir()) {

Datei anzeigen

@ -42,4 +42,11 @@ public interface SchematicSelectorInjectable {
default boolean onFolderCreate(SchematicSelector selector, String name) {return true;} default boolean onFolderCreate(SchematicSelector selector, String name) {return true;}
default void onNodeFilter(SchematicSelector selector, SchematicNode node) {} default void onNodeFilter(SchematicSelector selector, SchematicNode node) {}
default void onSelectorOpen(SchematicSelector selector, OpenFrom from) {}
enum OpenFrom {
FRESH,
REOPEN
}
} }