use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_TreePlanPanel method getTreeCellRendererComponent.
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value == null) {
return null;
}
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
value = node.getUserObject();
if (value instanceof MapZone) {
return getZoneComponent((MapZone) value, selected);
}
if (value instanceof MapBlock) {
return getBlockComponent((MapBlock) value, selected);
}
if (value instanceof Obj) {
return getObjComponent((Obj) value, selected);
}
// TODO add dungeon icon
JLabel label = new JLabel(value.toString());
label.setForeground(ColorManager.GOLDEN_WHITE);
label.setFont(FontMaster.getFont(FONT.AVQ, 19, Font.PLAIN));
return label;
// new DefaultTreeCellRenderer().getTreeCellRendererComponent(tree,
// value, selected, expanded, leaf, row, hasFocus)
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_TreePlanPanel method initTree.
public void initTree() {
root = new DefaultMutableTreeNode(plan.getDungeon().getName() + " plan");
for (MapZone z : plan.getZones()) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(z);
root.add(node);
for (MapBlock b : plan.getBlocks()) {
if (b.getType() == BLOCK_TYPE.CORRIDOR) {
// TODO
continue;
}
DefaultMutableTreeNode blockNode = new DefaultMutableTreeNode(b);
node.add(blockNode);
if (b.getObjects() != null) {
for (Obj o : b.getObjects()) {
blockNode.add(new DefaultMutableTreeNode(o));
b.getConnectedBlocks();
}
}
}
root.add(node);
}
setTree(new JTree(root));
tree.setOpaque(false);
tree.setSize(new Dimension(VISUALS.PLAN_PANEL_FRAME.getWidth() - 50, 20 * 32));
getTree().setLargeModel(true);
try {
getTree().setUI(this);
} catch (Exception e) {
// new Thread (
// getTree().setUI(this); ).start()
main.system.ExceptionMaster.printStackTrace(e);
}
getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
getTree().setCellRenderer(this);
getTree().addTreeSelectionListener(this);
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_TreePlanPanel method valueChanged.
public void valueChanged(final TreeSelectionEvent e1) {
if (((JTree) e1.getSource()).getSelectionPath() == null) {
return;
}
new Thread(new Runnable() {
@Override
public void run() {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) (((JTree) e1.getSource()).getSelectionPath().getLastPathComponent());
Object value = node.getUserObject();
if (value instanceof MapBlock) {
MapBlock block = (MapBlock) value;
planPanel.setSelectedZone(null);
planPanel.setSelectedBlock(block);
}
if (value instanceof MapZone) {
MapZone mapZone = (MapZone) value;
planPanel.setSelectedBlock(null);
// planPanel.setSelectedZone(mapZone);
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
planPanel.refresh();
}
});
}
}).start();
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LocationBuilder method buildDungeonPlan.
// static use and save as templates...
public DungeonPlan buildDungeonPlan(Location location) {
if (helper == null) {
helper = new BuildHelper(location, params);
helper.setPlan(plan);
}
if (StringMaster.isEmpty(helper.getParams().getValue(BUILD_PARAMS.FILLER_TYPE))) {
{
if (!location.isUnderground()) {
// return;
}
plan = new DungeonPlan(testTemplate, location);
int x1 = 0;
int x2 = params.getIntValue(BUILD_PARAMS.WIDTH);
if (x2 <= 0) {
x2 = location.getCellsX();
} else {
location.setParam(PARAMS.BF_WIDTH, x2);
}
int y1 = 0;
int y2 = params.getIntValue(BUILD_PARAMS.HEIGHT);
if (y2 <= 0) {
y2 = location.getCellsY();
} else {
location.setParam(PARAMS.BF_HEIGHT, y2);
}
MapZone zone = new MapZone(location.getDungeon(), 0, x1, x2, y1, y2);
List<Coordinates> coordinates = CoordinatesMaster.getCoordinatesWithin(x1 - 1, x2 - 1, y1 - 1, y2 - 1);
new MapBlock(0, BLOCK_TYPE.ROOM, zone, plan, coordinates);
plan.getZones().add(zone);
return plan;
}
}
if (TestDungeonInitializer.PRESET_PLAN != null) {
File file = FileManager.getFile(PathFinder.getDungeonLevelFolder() + TestDungeonInitializer.PRESET_PLAN);
if (file.isFile()) {
String data = FileManager.readFile(file);
DungeonPlan plan = null;
try {
plan = loadDungeonMap(data);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
return plan;
}
}
// preset in location-mission, based
// on Level?
// yes, any dungeon could have any template more or less,
template = location.getTemplate();
if (testMode) {
template = testTemplate;
}
if (template == null) {
template = DUNGEON_TEMPLATES.CLASSIC;
}
List<MapBlock> blocks = null;
Map<ObjType, Coordinates> objMap = null;
plan = new DungeonPlan(template, location);
location.setPlan(plan);
plan.setBlocks(blocks);
plan.setObjMap(objMap);
plan.setZones(createMapZones());
// Entrance exit = dungeon.getMainExit();
// Entrance entrance = dungeon.getMainEntrance();
// plan.setBaseAnchor(
// entrance.getCoordinates()
// );
// plan.setEndAnchor(exit.getCoordinates());
// if (!dungeon.isIgnoreRotate())
plan.setRotated(location.isRotated());
plan.setFlippedX(location.isFlippedX());
plan.setFlippedY(location.isFlippedY());
placeMainRooms();
if (!location.isSurface()) {
placeCulDeSacs();
}
if (!location.isSurface() && !helper.getParams().isNoRandomRooms()) {
placeAdditionalRooms();
}
if (!location.isSurface() && !helper.getParams().isNoCorridors()) {
linkWithCorridors();
}
return plan;
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LocationBuilder method placeCulDeSacs.
// public static ObjType getDungeonTypeFromLevelData(String data) {
// return null;
// }
private void placeCulDeSacs() {
int n = helper.getParams().CUL_DE_SACS;
n = MathMaster.applyMod(n, getDungeon().getPlan().getWidthMod());
n = RandomWizard.getRandomIntBetween(n / 2, n * 2);
Loop.startLoop(10000);
while (!Loop.loopEnded()) {
MapBlock block = new RandomWizard<MapBlock>().getRandomListItem(plan.getBlocks());
FACING_DIRECTION direction = FacingMaster.getRandomFacing();
Coordinates baseCoordinate = helper.getRandomWallCoordinate(direction, block);
if (helper.tryPlaceCorridor(block, baseCoordinate, direction, true)) {
n--;
}
if (n < 0) {
break;
}
}
}
Aggregations