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,34 +156,38 @@ public class SchematicSelector {
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private SchematicNode dirUp(SchematicNode parent) {
|
||||
if(!singleDirOpen) {
|
||||
if(NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
return null;
|
||||
} else {
|
||||
return getParent(parent);
|
||||
}
|
||||
} else {
|
||||
SchematicNode currentParent = parent;
|
||||
boolean isMember = false;
|
||||
do {
|
||||
sdoTrigger = false;
|
||||
if(NodeMember.getNodeMember(currentParent.getId(), user.getId()) != null) {
|
||||
isMember = true;
|
||||
}
|
||||
currentParent = getParent(currentParent);
|
||||
if(currentParent == null)
|
||||
break;
|
||||
getSchematicList(currentParent);
|
||||
} while (sdoTrigger);
|
||||
if(isMember || NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
return null;
|
||||
} else {
|
||||
return currentParent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleClick(SchematicNode node, SchematicNode parent) {
|
||||
if(node == null) {
|
||||
depth--;
|
||||
if(!singleDirOpen) {
|
||||
if(NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
openList(null);
|
||||
} else {
|
||||
openList(getParent(parent));
|
||||
}
|
||||
} else {
|
||||
SchematicNode currentParent = parent;
|
||||
boolean isMember = false;
|
||||
do {
|
||||
sdoTrigger = false;
|
||||
if(NodeMember.getNodeMember(currentParent.getId(), user.getId()) != null) {
|
||||
isMember = true;
|
||||
}
|
||||
currentParent = getParent(currentParent);
|
||||
if(currentParent == null)
|
||||
break;
|
||||
getSchematicList(currentParent);
|
||||
} while (sdoTrigger);
|
||||
if(isMember || NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
openList(null);
|
||||
} else {
|
||||
openList(currentParent);
|
||||
}
|
||||
}
|
||||
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