Merge pull request 'Add Reopen to SchematicSelector' (#169) from re_open_schem_gui into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #169 Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
e9a1b4dbb2
@ -41,7 +41,8 @@ public class SchematicSelector {
|
||||
@Getter
|
||||
private SteamwarUser user;
|
||||
@Getter
|
||||
private final Consumer<SchematicNode> callback;
|
||||
@Setter
|
||||
private Consumer<SchematicNode> callback;
|
||||
private final SelectorTarget target;
|
||||
@Getter
|
||||
private final SelectorFilter filter = new SelectorFilter();
|
||||
@ -58,6 +59,8 @@ public class SchematicSelector {
|
||||
private int depth = 0;
|
||||
private Sorting sorting = Sorting.NAME;
|
||||
private boolean invertSorting = false;
|
||||
@Getter
|
||||
private SchematicNode lastParent;
|
||||
|
||||
public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) {
|
||||
this.player = player;
|
||||
@ -78,9 +81,22 @@ public class SchematicSelector {
|
||||
this.user = SteamwarUser.get(0);
|
||||
}
|
||||
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) {
|
||||
lastParent = parent;
|
||||
List<SchematicNode> nodes = applySorting(filter.isFilter()?getFilteredSchematics():getSchematicList(parent));
|
||||
|
||||
if(sdoTrigger) {
|
||||
@ -140,14 +156,12 @@ public class SchematicSelector {
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private void handleClick(SchematicNode node, SchematicNode parent) {
|
||||
if(node == null) {
|
||||
depth--;
|
||||
private SchematicNode dirUp(SchematicNode parent) {
|
||||
if(!singleDirOpen) {
|
||||
if(NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
openList(null);
|
||||
return null;
|
||||
} else {
|
||||
openList(getParent(parent));
|
||||
return getParent(parent);
|
||||
}
|
||||
} else {
|
||||
SchematicNode currentParent = parent;
|
||||
@ -163,11 +177,17 @@ public class SchematicSelector {
|
||||
getSchematicList(currentParent);
|
||||
} while (sdoTrigger);
|
||||
if(isMember || NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
openList(null);
|
||||
return null;
|
||||
} else {
|
||||
openList(currentParent);
|
||||
return currentParent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleClick(SchematicNode node, SchematicNode parent) {
|
||||
if(node == null) {
|
||||
depth--;
|
||||
openList(dirUp(parent));
|
||||
return;
|
||||
}
|
||||
if(node.isDir()) {
|
||||
|
@ -42,4 +42,11 @@ public interface SchematicSelectorInjectable {
|
||||
default boolean onFolderCreate(SchematicSelector selector, String name) {return true;}
|
||||
|
||||
default void onNodeFilter(SchematicSelector selector, SchematicNode node) {}
|
||||
|
||||
default void onSelectorOpen(SchematicSelector selector, OpenFrom from) {}
|
||||
|
||||
enum OpenFrom {
|
||||
FRESH,
|
||||
REOPEN
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren