forked from NearInfinityBrowser/NearInfinity
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Area Viewer: Add new layer "Impeded Door Cells"
Experimental implementation: may have some performance issues if many cell blocks are defined.
- Loading branch information
Showing
18 changed files
with
548 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/org/infinity/resource/are/viewer/BasicCompositeLayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Near Infinity - An Infinity Engine Browser and Editor | ||
// Copyright (C) 2001 Jon Olav Hauglid | ||
// See LICENSE.txt for license information | ||
|
||
package org.infinity.resource.are.viewer; | ||
|
||
import java.util.HashMap; | ||
|
||
import org.infinity.gui.layeritem.AbstractLayerItem; | ||
import org.infinity.resource.AbstractStruct; | ||
import org.infinity.resource.are.viewer.ViewerConstants.LayerType; | ||
|
||
/** | ||
* Specialized base class for layer-specific managers that consists of multiple sublayers. | ||
* | ||
* @param <E> Type of the layer item in the manager | ||
* @param <R> Type of the resource that contains layer items | ||
*/ | ||
public abstract class BasicCompositeLayer<E extends LayerObject, R extends AbstractStruct> extends BasicLayer<E, R> { | ||
/** Predefined identifier for use with the primary sublayer. */ | ||
public static final int LAYER_PRIMARY = 0; | ||
|
||
private final HashMap<Integer, Boolean> layerEnabled = new HashMap<>(); | ||
|
||
public BasicCompositeLayer(R parent, LayerType type, AreaViewer viewer) { | ||
super(parent, type, viewer); | ||
setLayerEnabled(LAYER_PRIMARY, true); | ||
} | ||
|
||
public boolean isLayerVisible(int id) { | ||
return isLayerVisible() && layerEnabled.getOrDefault(id, false); | ||
} | ||
|
||
@Override | ||
public void setLayerVisible(boolean visible) { | ||
setVisibilityState(visible); | ||
|
||
getLayerObjects().stream().forEach(obj -> { | ||
AbstractLayerItem[] items = obj.getLayerItems(); | ||
for (final AbstractLayerItem item : items) { | ||
final int id = item.getId(); | ||
item.setVisible(isLayerVisible(id) && isLayerEnabled(id)); | ||
} | ||
}); | ||
} | ||
|
||
public boolean isLayerEnabled(int id) { | ||
return layerEnabled.getOrDefault(id, false); | ||
} | ||
|
||
public void setLayerEnabled(int id, boolean enable) { | ||
if (isLayerEnabled(id) != enable) { | ||
layerEnabled.put(id, enable); | ||
setLayerVisible(isLayerVisible(LAYER_PRIMARY) || isLayerVisible(id)); | ||
} | ||
} | ||
} |
68 changes: 0 additions & 68 deletions
68
src/org/infinity/resource/are/viewer/BasicTargetLayer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.