use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.
the class AV_Tree method build.
private DefaultMutableTreeNode build(List<String> typesDoc, String group) {
DefaultMutableTreeNode result = new DefaultMutableTreeNode(group);
List<String> subGroups = new ArrayList<>();
// if (workspace!=null) workspace.getGrouping() ;
if (!StringMaster.isEmpty(group)) {
try {
Set<String> groups = XML_Reader.getTreeSubGroupMap().get(group);
if (groups == null) {
groups = XML_Reader.getTreeSubGroupMap(!XML_Reader.isMacro()).get(group);
}
subGroups = new ArrayList<>(groups);
Class<?> ENUM = EnumMaster.getEnumClass(type.getSubGroupingKey().getName());
if (ENUM != null) {
Collections.sort(subGroups, new EnumMaster<>().getEnumSorter(ENUM));
}
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
} else if (workspace != null) {
subGroups = workspace.getSubgroups();
if (subGroups == null) // TODO custom *grouping* -> enum class + property!
{
if (workspace.isSearch()) {
subGroups = ListMaster.toStringList(DC_TYPE.values());
} else {
subGroups = ListMaster.toStringList(MetaEnums.WORKSPACE_GROUP.values());
subGroups.add("");
}
}
// subGroups = workspace.getSubgroups();
// subGroups = workspace.getSubgroups();
}
// TODO filter generic groups
if (subGroups.size() <= 1) {
return buildSimple(typesDoc, group);
}
for (String subGroup : subGroups) {
DefaultMutableTreeNode subNode = new DefaultMutableTreeNode(subGroup);
List<String> upgrades = new ArrayList<>();
List<String> list;
if (workspace == null) {
// Set<String> c = XML_Reader.getTreeSubGroupedTypeMap(XML_Reader.isMacro()).get(
// subGroup);
// if (!ListMaster.isNotEmpty(c)) {
// c = XML_Reader.getTreeSubGroupedTypeMap(!XML_Reader.isMacro()).get(subGroup);
// }
// list = new ArrayList<>(c);
// list.removeIf(t-> t==null );
list = StringMaster.toNameList(main.system.entity.FilterMaster.getFilteredTypeList(type, type.getSubGroupingKey(), subGroup));
try {
Collections.sort(list, getComparator());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
} else {
if (workspace.isSearch()) {
list = DataManager.toStringList(new Filter<ObjType>().filter(workspace.getTypeList(), G_PROPS.TYPE, subGroup));
try {
Collections.sort(list, new EnumMaster<>().getEnumSorter(DC_TYPE.class));
} catch (Exception e) {
try {
Collections.sort(list, new EnumMaster<>().getEnumSorter(EnumMaster.getEnumClass(type.getGroupingKey().getName())));
} catch (Exception e1) {
e1.printStackTrace();
}
main.system.ExceptionMaster.printStackTrace(e);
}
} else {
PROPERTY filterValue = G_PROPS.WORKSPACE_GROUP;
if (workspace.getSubgroupingProp() != null) {
filterValue = workspace.getSubgroupingProp();
}
list = DataManager.toStringList(new Filter<ObjType>().filter(workspace.getTypeList(), filterValue, subGroup));
try {
Collections.sort(list, new EnumMaster<>().getEnumSorter(WORKSPACE_GROUP.class));
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
}
for (String typeName : list) {
if (!typesDoc.contains(typeName)) {
continue;
}
addNode(subNode, typeName, upgrades);
}
if (!subNode.isLeaf()) {
result.add(subNode);
}
// TODO is it ok?
DefaultMutableTreeNode subNode2 = subNode;
if (isFullNodeStructureOn()) {
// ???
for (String typeName : upgrades) {
subNode.add(new DefaultMutableTreeNode(typeName));
}
} else {
// add upgrade nodes - works only for 3 levels
while (true) {
List<String> upgrades2 = new ArrayList<>(upgrades);
for (String typeName : upgrades2) {
// Node!
if (addUpgradeNode(subNode2, typeName)) {
upgrades.remove(typeName);
}
}
if (upgrades.isEmpty()) {
parent = null;
i = 0;
break;
}
/*
* basically, it seems that root type count limits depth
* the preCheck
*
*
*/
if (parent == null) {
if (subNode2 == null) {
parent = subNode2;
} else {
parent = subNode;
}
}
subNode2 = getNextNode();
if (subNode2 == null) {
parent = null;
i = 0;
LogMaster.log(1, upgrades + " remain, parent=" + parent + i);
for (String typeName : upgrades) {
subNode.add(new DefaultMutableTreeNode(typeName));
}
break;
}
// tr
}
}
}
// return (DefaultMutableTreeNode) result.getFirstChild();
return result;
}
use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.
the class PresetLauncher method initLaunch.
public static LAUNCH initLaunch(String option) {
launch = new EnumMaster<LAUNCH>().retrieveEnumConst(LAUNCH.class, option);
if (launch == null) {
return null;
}
if (launch.logChannelsOn != null) {
Arrays.stream(launch.logChannelsOn).forEach(c -> {
c.setOn(true);
});
}
if (launch.logChannelsOff != null) {
Arrays.stream(launch.logChannelsOff).forEach(c -> {
c.setOn(false);
});
}
if (launch.preset != null) {
Preset p = PresetMaster.loadPreset(launch.preset);
PresetMaster.setPreset(p);
}
if (launch.dungeonPath != null) {
// DungeonMaster.setDEFAULT_DUNGEON_PATH(launch.dungeonPath);
}
if (launch.dungeonType != null) {
// DungeonMaster.setDEFAULT_DUNGEON(launch.dungeonType);
}
return launch;
}
use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.
the class AutoTestRunner method run.
public void run() {
Unit unit = master.getSource();
RuleMaster.setScope(RULE_SCOPE.TEST);
if (test.getArg(TEST_ARGS.RULE_SCOPE) != null) {
RuleMaster.setScope(new EnumMaster<RULE_SCOPE>().retrieveEnumConst(RULE_SCOPE.class, test.getArg(TEST_ARGS.RULE_SCOPE)));
}
switch(test.getType()) {
case ACTION_SKILL:
runActionSkillTest();
break;
default:
addTestTypes(unit);
break;
}
runTestFunctions();
// switch (test.getAssertions()) {
// }
}
use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.
the class ArcaneTower method genericInit.
public static void genericInit(boolean av) {
EnumMaster.getAdditionalEnumClasses().add(StatEnums.class);
ContentManager.setTypeMaster(new TypeMaster() {
public OBJ_TYPE getOBJ_TYPE(String typeName) {
// AT_OBJ_TYPE.valueOf(typeName);
return new EnumMaster<AT_OBJ_TYPE>().retrieveEnumConst(AT_OBJ_TYPE.class, typeName);
}
});
XML_Reader.setCustomTypesPath(getTypesPath());
contentManager = new AT_ContentManager(dcSync);
if (av) {
launchAV();
}
// launchBackground();
initSimulation();
if (!av) {
contentManager.contentInit();
CoreEngine.systemInit();
XML_Reader.loadXml(getTypesPath());
}
sim.initObjTypes();
ContentManager.setInstance(contentManager);
}
use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.
the class HT_MapBuilder method getLinkVariant.
protected LINK_VARIANT getLinkVariant(ObjType type, int i, int sublingCount) {
LINK_VARIANT variant = getDefaultLinkVariant();
Integer circle = type.getIntParam(PARAMS.CIRCLE);
String linkName = type.getProperty(PROPS.LINK_VARIANT);
if (linkName.isEmpty()) {
if (!isAddLinkPerChild()) {
List<ObjType> typesOnRow = getTypesWithinRange(type, sublingCount, sublingCount, 64, 64);
ObjType parent = DataManager.getParent(type);
if (typesOnRow.size() >= 1) {
int index = 0;
while (index < typesOnRow.size()) {
if (alteredTypeLinkMap.containsKey(DataManager.getParent(typesOnRow.get(index)))) {
// TODO short? if any
return LINK_VARIANT.VERTICAL;
}
// in
// line are long!
index++;
}
LogMaster.log(1, type.getName() + "*!* Link made LONG! - " + typesOnRow);
alteredTypeLinkMap.put(parent, type);
return LINK_VARIANT.VERTICAL_LONG;
}
} else {
if (sublingCount > 1) {
if (sublingCount % 2 == 1) {
if ((i == sublingCount / 2)) {
// getSpecialLink?
variant = getDefaultLinkVariant();
} else if (i < sublingCount / 2) {
linkName += "ANGLE_TO_LEFT";
} else {
linkName += "ANGLE_TO_RIGHT";
}
} else if (i % 2 == 0) {
linkName += "ANGLE_TO_LEFT";
} else {
linkName += "ANGLE_TO_RIGHT";
}
}
if (!linkName.isEmpty()) {
if (circle > 0 && circle < 4) {
linkName += circle;
}
}
}
}
if (!linkName.isEmpty()) {
variant = new EnumMaster<LINK_VARIANT>().retrieveEnumConst(LINK_VARIANT.class, linkName);
}
if (variant == null) {
variant = getDefaultLinkVariant();
}
return variant;
}
Aggregations