Skip to content

Commit

Permalink
fix build after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
thelsing committed Nov 17, 2023
1 parent 6c0a095 commit 3cccf97
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 48 deletions.
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def javaArgs = [
"-DMAPTOOL_DATADIR=.maptool-" + vendor.toLowerCase(), "-XX:+ShowCodeDetailsInExceptionMessages",
"--add-opens=java.desktop/java.awt=ALL-UNNAMED", "--add-opens=java.desktop/java.awt.geom=ALL-UNNAMED",
"--add-opens=java.desktop/sun.awt.geom=ALL-UNNAMED", "--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=javafx.web/javafx.scene.web=ALL-UNNAMED", "--add-opens=javafx.web/com.sun.webkit=ALL-UNNAMED", "--add-opens=javafx.web/com.sun.webkit.dom=ALL-UNNAMED",
"--add-opens=javafx.web/javafx.scene.web=ALL-UNNAMED", "--add-opens=javafx.web/com.sun.webkit=ALL-UNNAMED",
"--add-opens=javafx.web/com.sun.webkit.dom=ALL-UNNAMED","--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.desktop/sun.awt=ALL-UNNAMED", "--add-opens=java.desktop/sun.java2d=ALL-UNNAMED",
"--add-opens=java.desktop/javax.swing=ALL-UNNAMED","--add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED",
"--add-opens=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED"]

Expand Down Expand Up @@ -525,7 +527,10 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-freetype-platform:1.12.0:natives-desktop"
implementation "com.badlogicgames.gdx-video:gdx-video:1.3.2-SNAPSHOT"
implementation "com.badlogicgames.gdx-video:gdx-video-lwjgl3:1.3.2-SNAPSHOT"
implementation 'com.badlogicgames.box2dlights:box2dlights:1.5'
//implementation 'com.badlogicgames.box2dlights:box2dlights:1.5'
//implementation 'com.github.thelsing:box2dlights:master-SNAPSHOT'
implementation 'com.github.fgnm:box2dlights:master-SNAPSHOT'
//implementation 'com.github.voodoosoft:box2dlights:master-SNAPSHOT'
implementation 'com.badlogicgames.gdx:gdx-box2d:1.12.0'
implementation "com.badlogicgames.gdx:gdx-box2d-platform:1.12.0:natives-desktop"}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
*/
package net.rptools.maptool.client.ui.zone.gdx;

import box2dLight.ChainLight;
import box2dLight.ConeLight;
import box2dLight.DirectionalLight;
import box2dLight.Light;
import box2dLight.PointLight;
import box2dLight.RayHandler;
import box2dLight.*;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
Expand Down Expand Up @@ -114,10 +109,13 @@ public void create() {
normalProjection.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

/** BOX2D LIGHT STUFF BEGIN */
RayHandler.setGammaCorrection(true);
RayHandler.useDiffuseLight(true);

rayHandler = new RayHandler(world);
var options = new RayHandlerOptions();
options.setDiffuse(true);
options.setGammaCorrection(true);
rayHandler = new RayHandler(world, options);
// RayHandler.setGammaCorrection(true);
// RayHandler.useDiffuseLight(true);
// rayHandler = new RayHandler(world);
rayHandler.setAmbientLight(0f, 0f, 0f, 0.5f);
rayHandler.setBlurNum(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
*/
package net.rptools.maptool.client.ui.zone.gdx;

import box2dLight.ChainLight;
import box2dLight.PointLight;
import box2dLight.RayHandler;
import box2dLight.*;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
Expand Down Expand Up @@ -179,10 +177,13 @@ public void create() {

world = new World(new Vector2(0, 0), true);
debugRenderer = new Box2DDebugRenderer();
RayHandler.setGammaCorrection(true);
RayHandler.useDiffuseLight(true);

rayHandler = new RayHandler(world);
var options = new RayHandlerOptions();
options.setDiffuse(true);
options.setGammaCorrection(true);
rayHandler = new RayHandler(world, options);
// RayHandler.setGammaCorrection(true);
// RayHandler.useDiffuseLight(true);
// rayHandler = new RayHandler(world);
rayHandler.setAmbientLight(0f, 0f, 0f, 0.5f);
rayHandler.setBlurNum(3);

Expand All @@ -200,8 +201,16 @@ public void create() {
128,
Color.WHITE,
600,
-1,
1,
new float[] {700, -600, 1000, -600, 1000, -800, 700, -800, 700, -600});
/*
rayHandler,
128,
Color.WHITE,
600,
1,
new float[] {700, -600, 1000, -600, 1000, -800, 700, -800, 700, -600});
*/
chain.setSoft(false);

manager = new com.badlogic.gdx.assets.AssetManager();
Expand Down Expand Up @@ -522,23 +531,23 @@ private void renderZone(PlayerView view) {

renderBoard();

if (Zone.Layer.BACKGROUND.isEnabled()) {
List<DrawnElement> drawables = zoneCache.getZone().getBackgroundDrawnElements();
if (zoneCache.getZoneRenderer().shouldRenderLayer(Zone.Layer.BACKGROUND, view)) {
List<DrawnElement> drawables = zoneCache.getZone().getDrawnElements(Zone.Layer.BACKGROUND);

timer.start("drawableBackground");
drawnElementRenderer.render(batch, drawables);
timer.stop("drawableBackground");

List<Token> background = zoneCache.getZone().getBackgroundStamps(false);
List<Token> background = zoneCache.getZone().getTokensOnLayer(Zone.Layer.BACKGROUND, false);
if (!background.isEmpty()) {
timer.start("tokensBackground");
renderTokens(background, view, false);
timer.stop("tokensBackground");
}
}
if (Zone.Layer.OBJECT.isEnabled()) {
if (zoneCache.getZoneRenderer().shouldRenderLayer(Zone.Layer.OBJECT, view)) {
// Drawables on the object layer are always below the grid, and...
List<DrawnElement> drawables = zoneCache.getZone().getObjectDrawnElements();
List<DrawnElement> drawables = zoneCache.getZone().getDrawnElements(Zone.Layer.OBJECT);
// if (!drawables.isEmpty()) {
timer.start("drawableObjects");
drawnElementRenderer.render(batch, drawables);
Expand All @@ -552,16 +561,16 @@ private void renderZone(PlayerView view) {

timer.stop("grid");

if (Zone.Layer.OBJECT.isEnabled()) {
if (zoneCache.getZoneRenderer().shouldRenderLayer(Zone.Layer.OBJECT, view)) {
// ... Images on the object layer are always ABOVE the grid.
List<Token> stamps = zoneCache.getZone().getStampTokens(false);
List<Token> stamps = zoneCache.getZone().getTokensOnLayer(Zone.Layer.OBJECT, false);
if (!stamps.isEmpty()) {
timer.start("tokensStamp");
renderTokens(stamps, view, false);
timer.stop("tokensStamp");
}
}
if (Zone.Layer.TOKEN.isEnabled()) {
if (zoneCache.getZoneRenderer().shouldRenderLayer(Zone.Layer.TOKEN, view)) {
timer.start("lights");
renderLights(view);
timer.stop("lights");
Expand Down Expand Up @@ -592,29 +601,29 @@ private void renderZone(PlayerView view) {
* <li>Render Token-layer tokens
* </ol>
*/
if (Zone.Layer.TOKEN.isEnabled()) {
List<DrawnElement> drawables = zoneCache.getZone().getDrawnElements();
if (zoneCache.getZoneRenderer().shouldRenderLayer(Zone.Layer.TOKEN, view)) {
List<DrawnElement> drawables = zoneCache.getZone().getDrawnElements(Zone.Layer.TOKEN);
// if (!drawables.isEmpty()) {
timer.start("drawableTokens");
drawnElementRenderer.render(batch, drawables);
timer.stop("drawableTokens");
// }

if (view.isGMView() && Zone.Layer.GM.isEnabled()) {
drawables = zoneCache.getZone().getGMDrawnElements();
if (zoneCache.getZoneRenderer().shouldRenderLayer(Zone.Layer.GM, view)) {
drawables = zoneCache.getZone().getDrawnElements(Zone.Layer.GM);
// if (!drawables.isEmpty()) {
timer.start("drawableGM");
drawnElementRenderer.render(batch, drawables);
timer.stop("drawableGM");
// }
List<Token> stamps = zoneCache.getZone().getGMStamps(false);
List<Token> stamps = zoneCache.getZone().getTokensOnLayer(Zone.Layer.GM, false);
if (!stamps.isEmpty()) {
timer.start("tokensGM");
renderTokens(stamps, view, false);
timer.stop("tokensGM");
}
}
List<Token> tokens = zoneCache.getZone().getTokens(false);
List<Token> tokens = zoneCache.getZone().getTokensOnLayer(Zone.Layer.TOKEN, false);
if (!tokens.isEmpty()) {
timer.start("tokens");
renderTokens(tokens, view, false);
Expand Down Expand Up @@ -643,7 +652,7 @@ private void renderZone(PlayerView view) {
renderFog(view);
}

if (Zone.Layer.TOKEN.isEnabled()) {
if (zoneCache.getZoneRenderer().shouldRenderLayer(Zone.Layer.TOKEN, view)) {
// Jamz: If there is fog or vision we may need to re-render vision-blocking type tokens
// For example. this allows a "door" stamp to block vision but still allow you to see the
// door.
Expand Down Expand Up @@ -699,7 +708,9 @@ private void renderZone(PlayerView view) {
timer.stop("renderCoordinates");

timer.start("lightSourceIconOverlay.paintOverlay");
if (Zone.Layer.TOKEN.isEnabled() && view.isGMView() && AppState.isShowLightSources()) {
if (zoneCache.getZoneRenderer().shouldRenderLayer(Zone.Layer.TOKEN, view)
&& view.isGMView()
&& AppState.isShowLightSources()) {
paintlightSourceIconOverlay();
}
timer.stop("lightSourceIconOverlay.paintOverlay");
Expand Down Expand Up @@ -1093,7 +1104,7 @@ private void showBlockedMoves(PlayerView view, Set<SelectionSet> movementSet) {
}
// Show path only on the key token on token layer that are visible to the owner or gm while
// fow and vision is on
if (token == keyToken && !token.isStamp()) {
if (token == keyToken && token.getLayer().supportsWalker()) {
renderPath(
walker != null ? walker.getPath() : set.getGridlessPath(),
token.getFootprint(zoneCache.getZone().getGrid()));
Expand Down Expand Up @@ -1187,7 +1198,7 @@ private void showBlockedMoves(PlayerView view, Set<SelectionSet> movementSet) {
y += 10 + h;
x += w / 2;

if (!token.isStamp() && AppState.getShowMovementMeasurements()) {
if (token.getLayer().supportsWalker() && AppState.getShowMovementMeasurements()) {
String distance = "";
if (walker != null) { // This wouldn't be true unless token.isSnapToGrid() &&
// grid.isPathingSupported()
Expand Down Expand Up @@ -1473,14 +1484,14 @@ private void renderTokens(List<Token> tokenList, PlayerView view, boolean figure

timer.start("tokenlist-1");
try {
if (token.isStamp() && zoneCache.getZoneRenderer().isTokenMoving(token)) {
if (token.getLayer().isStampLayer() && zoneCache.getZoneRenderer().isTokenMoving(token)) {
continue;
}
// Don't bother if it's not visible
// NOTE: Not going to use zoneCache.getZone().isTokenVisible as it is very slow. In fact,
// it's faster
// to just draw the tokens and let them be clipped
if ((!token.isVisible() || token.isGMStamp()) && !isGMView) {
if ((!token.isVisible() || !token.getLayer().isVisibleToPlayers()) && !isGMView) {
continue;
}
if (token.isVisibleOnlyToOwner() && !AppUtil.playerOwns(token)) {
Expand Down Expand Up @@ -1510,7 +1521,9 @@ private void renderTokens(List<Token> tokenList, PlayerView view, boolean figure
try {

// Vision visibility
if (!isGMView && token.isToken() && zoneCache.getZoneView().isUsingVision()) {
if (!isGMView
&& token.getLayer().supportsVision()
&& zoneCache.getZoneView().isUsingVision()) {
if (!GraphicsUtil.intersects(visibleScreenArea, tokenBounds)) {
continue;
}
Expand Down Expand Up @@ -1768,14 +1781,16 @@ private void renderTokens(List<Token> tokenList, PlayerView view, boolean figure
zoneCache.getZoneRenderer().getSelectedTokenSet().contains(token.getId());
if (isSelected) {
ImageBorder selectedBorder =
token.isStamp() ? AppStyle.selectedStampBorder : AppStyle.selectedBorder;
token.getLayer().isStampLayer()
? AppStyle.selectedStampBorder
: AppStyle.selectedBorder;
if (zoneCache.getZoneRenderer().getHighlightCommonMacros().contains(token)) {
selectedBorder = AppStyle.commonMacroBorder;
}
if (!AppUtil.playerOwns(token)) {
selectedBorder = AppStyle.selectedUnownedBorder;
}
if (useIF && !token.isStamp() && zoneCache.getZoneView().isUsingVision()) {
if (useIF && token.getLayer().supportsVision() && zoneCache.getZoneView().isUsingVision()) {
Tool tool = MapTool.getFrame().getToolbox().getSelectedTool();
if (tool
instanceof
Expand All @@ -1798,7 +1813,7 @@ private void renderTokens(List<Token> tokenList, PlayerView view, boolean figure
gdxTokenRectangle.height / zoom);

if (token.hasFacing()
&& (token.getShape() == Token.TokenShape.TOP_DOWN || token.isStamp())) {
&& (token.getShape() == Token.TokenShape.TOP_DOWN || token.getLayer().isStampLayer())) {

var transX = gdxTokenRectangle.width / 2f - token.getAnchor().x / zoom;
var transY = gdxTokenRectangle.height / 2f + token.getAnchor().y / zoom;
Expand Down Expand Up @@ -1845,9 +1860,11 @@ private void renderTokens(List<Token> tokenList, PlayerView view, boolean figure
var tokenStackMap = zoneCache.getZoneRenderer().getTokenStackMap();

// Stacks
if (!tokenList.isEmpty()
&& !tokenList.get(0).isStamp()) { // TODO: find a cleaner way to indicate token layer
if (tokenStackMap != null) { // FIXME Needed to prevent NPE but how can it be null?
// TODO: find a cleaner way to indicate token layer
if (!tokenList.isEmpty() && tokenList.get(0).getLayer().isTokenLayer()) {
boolean hideTSI = AppPreferences.getHideTokenStackIndicator();
if (tokenStackMap != null
&& !hideTSI) { // FIXME Needed to prevent NPE but how can it be null?
for (Token token : tokenStackMap.keySet()) {
var tokenRectangle = token.getBounds(zoneCache.getZone());
var stackImage = zoneCache.fetch("stack");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ public void disableLayer(Layer layer) {
disabledLayers.add(layer);
}

private boolean shouldRenderLayer(Layer layer, PlayerView view) {
public boolean shouldRenderLayer(Layer layer, PlayerView view) {
return !disabledLayers.contains(layer) && (layer.isVisibleToPlayers() || view.isGMView());
}

Expand Down

0 comments on commit 3cccf97

Please sign in to comment.