Skip to content

Commit

Permalink
Can pan textures vertically in the editor now
Browse files Browse the repository at this point in the history
  • Loading branch information
Interrupt committed Jan 11, 2019
1 parent 4681ae0 commit bb8be30
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 16 deletions.
9 changes: 9 additions & 0 deletions DelvEdit/src/com/interrupt/dungeoneer/editor/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public enum EditorMode { Carve, Paint };
public ActionListener pickNewWallTexAction;
public ActionListener fillTextureAction;

public ActionListener panSurfaceYAction;

public ActionListener xDragMode;
public ActionListener yDragMode;
public ActionListener zDragMode;
Expand Down Expand Up @@ -464,6 +466,13 @@ public void actionPerformed(ActionEvent actionEvent) {
}
};

panSurfaceYAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
editorFrame.panSurfaceV((byte)1);
}
};

rotateWallAngle = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Expand Down
20 changes: 19 additions & 1 deletion DelvEdit/src/com/interrupt/dungeoneer/editor/EditorFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -3509,7 +3509,7 @@ else if(pickedSurface.edge == TileEdges.South) {
t.init(Source.EDITOR);

history.saveState(level);
markWorldAsDirty((int)pickedSurface.position.x, (int)pickedSurface.position.y, 1);
markWorldAsDirty((int)pickedSurface.position.x, (int)pickedSurface.position.z, 1);
}
}

Expand Down Expand Up @@ -3725,6 +3725,24 @@ else if(pickedSurface.edge == TileEdges.West) {
floodFillWallTexture(x - nextXOffset, y - nextYOffset, checkTex, checkAtlas, adjacent);
}

public void panSurfaceV(byte amt) {
if(pickedSurface.isPicked) {
Tile t = level.getTileOrNull((int) pickedSurface.position.x, (int) pickedSurface.position.z);
if(t == null)
return;

boolean isUpperWall = pickedSurface.tileSurface == TileSurface.UpperWall;

if(isUpperWall)
t.setWallYOffset(pickedSurface.edge, (byte)(t.getWallYOffset(pickedSurface.edge) + amt));
else
t.setBottomWallYOffset(pickedSurface.edge, (byte)(t.getBottomWallYOffset(pickedSurface.edge) + amt));

markWorldAsDirty((int)pickedSurface.position.x, (int)pickedSurface.position.y, 1);
history.saveState(level);
}
}

public TextureRegion[] loadAtlas(String texture, int spritesHorizontal, boolean filter) {
Texture spriteTextures = Art.loadTexture(texture);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public void actionPerformed(ActionEvent event) {
.addItem(new MenuItem("Grab Surface Texture", smallSkin, editor.pickWallAction).setAccelerator(new MenuAccelerator(Keys.NUM_2, false, false)))
.addItem(new MenuItem("Pick Surface Texture", smallSkin, editor.pickNewWallTexAction).setAccelerator(new MenuAccelerator(Keys.NUM_2, false, true)))
.addItem(new MenuItem("Flood Fill Surface Texture", smallSkin, editor.fillTextureAction).setAccelerator(new MenuAccelerator(Keys.NUM_5, false, false)))
.addItem(new MenuItem("Pan Texture Vertically", smallSkin, editor.panSurfaceYAction).setAccelerator(new MenuAccelerator(Keys.NUM_6, false, false)))
)
.addItem(new MenuItem("Tiles", smallSkin)
.addItem(new MenuItem("Raise Floor", smallSkin, editor.raiseFloorAction).setAccelerator(new MenuAccelerator(Keys.NUM_3, false, false)))
Expand Down
Binary file added Dungeoneer/chairsea.bin
Binary file not shown.
55 changes: 55 additions & 0 deletions Dungeoneer/errorlog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Fatal error in Game loop!

com.badlogic.gdx.utils.SerializationException: Error reading file: /Users/cuddigan/Github/delverengine/Dungeoneer/assets/data/entities.dat
at com.badlogic.gdx.utils.Json.fromJson(Json.java:715)
at com.interrupt.dungeoneer.game.Game.fromJson(Game.java:1447)
at com.interrupt.dungeoneer.game.ModManager.loadEntityManager(ModManager.java:140)
at com.interrupt.dungeoneer.editor.EditorFrame.init(EditorFrame.java:376)
at com.interrupt.dungeoneer.editor.EditorFrame.create(EditorFrame.java:1866)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)
Caused by: com.badlogic.gdx.utils.SerializationException: Serialization trace:
entities (com.interrupt.managers.EntityManager)
at com.badlogic.gdx.utils.Json.readValue(Json.java:900)
at com.badlogic.gdx.utils.Json.readValue(Json.java:936)
at com.badlogic.gdx.utils.Json.readValue(Json.java:953)
at com.badlogic.gdx.utils.Json.readFields(Json.java:818)
at com.badlogic.gdx.utils.Json.readValue(Json.java:958)
at com.badlogic.gdx.utils.Json.fromJson(Json.java:713)
... 6 more
Caused by: com.badlogic.gdx.utils.reflect.ReflectionException: Class not found: com.interrupt.dungeoneer.entities.triggers.ElevatorTrigger
at com.badlogic.gdx.utils.reflect.ClassReflection.forName(ClassReflection.java:30)
at com.badlogic.gdx.utils.Json.readValue(Json.java:898)
... 11 more
Caused by: java.lang.ClassNotFoundException: com.interrupt.dungeoneer.entities.triggers.ElevatorTrigger
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.badlogic.gdx.utils.reflect.ClassReflection.forName(ClassReflection.java:28)
... 12 more

Fatal error in Game loop!

com.badlogic.gdx.utils.GdxRuntimeException: File not found: levels/first-death-screen-splash.bin (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:142)
at com.interrupt.dungeoneer.serializers.v1.LevelSerializer.loadLevel(LevelSerializer.java:59)
at com.interrupt.dungeoneer.serializers.KryoSerializer.loadLevel(KryoSerializer.java:42)
at com.interrupt.dungeoneer.game.Level.load(Level.java:476)
at com.interrupt.dungeoneer.game.Level.loadForSplash(Level.java:234)
at com.interrupt.dungeoneer.screens.BaseScreen.loadBackgroundLevel(BaseScreen.java:382)
at com.interrupt.dungeoneer.screens.BaseScreen.show(BaseScreen.java:183)
at com.interrupt.dungeoneer.screens.GameOverScreen.show(GameOverScreen.java:222)
at com.badlogic.gdx.Game.setScreen(Game.java:61)
at com.interrupt.dungeoneer.GameApplication.ShowGameOverScreen(GameApplication.java:117)
at com.interrupt.dungeoneer.game.Game.OnGameOver(Game.java:897)
at com.interrupt.dungeoneer.game.Game.tick(Game.java:532)
at com.interrupt.dungeoneer.GameManager.tick(GameManager.java:113)
at com.interrupt.dungeoneer.screens.GameScreen.render(GameScreen.java:73)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.interrupt.dungeoneer.editor.EditorFrame.render(EditorFrame.java:441)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:225)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)

15 changes: 11 additions & 4 deletions Dungeoneer/src/com/interrupt/dungeoneer/gfx/Tesselator.java
Original file line number Diff line number Diff line change
Expand Up @@ -797,12 +797,19 @@ else if(dir == TileEdges.East) {

float texU1 = renderer.GetTexUAt(x + x_offsets.val1, x + x_offsets.val2, y + y_offsets.val1, y + y_offsets.val2, 0f, reg, atlas);
float texU2 = renderer.GetTexUAt(x + x_offsets.val1, x + x_offsets.val2, y + y_offsets.val1, y + y_offsets.val2, 1f, reg, atlas);
float v;

if(bottomWallIndex != null && bottomWallIndex >= i) {
v = reg.getV() + checkDir.getBottomWallYOffset(dir) * 0.0625f;
} else {
v = reg.getV() + checkDir.getWallYOffset(dir) * 0.0625f;
}

// This is ugly!
selectedTesselator.addVertex(x + x_offsets.val1, ends.get(i).val1 , y + y_offsets.val1, texU1, renderer.GetTexVAt(ends.get(i).val1, atlas) + reg.getV(), showLights ? getLightColorAt(level,x + x_offsets.val1, ends.get(i).val1, y + y_offsets.val1, normal) : fullBrightColor);
selectedTesselator.addVertex(x + x_offsets.val1, starts.get(i).val1, y + y_offsets.val1, texU1, renderer.GetTexVAt(starts.get(i).val1, atlas) + reg.getV(), showLights ? getLightColorAt(level,x + x_offsets.val1, starts.get(i).val1, y + y_offsets.val1, normal) : fullBrightColor);
selectedTesselator.addVertex(x + x_offsets.val2, ends.get(i).val2, y + y_offsets.val2, texU2, renderer.GetTexVAt(ends.get(i).val2, atlas) + reg.getV(), showLights ? getLightColorAt(level,x + x_offsets.val2, ends.get(i).val2, y + y_offsets.val2, normal) : fullBrightColor);
selectedTesselator.addVertex(x + x_offsets.val2, starts.get(i).val2, y + y_offsets.val2, texU2, renderer.GetTexVAt(starts.get(i).val2, atlas) + reg.getV(), showLights ? getLightColorAt(level,x + x_offsets.val2, starts.get(i).val2, y + y_offsets.val2, normal) : fullBrightColor);
selectedTesselator.addVertex(x + x_offsets.val1, ends.get(i).val1 , y + y_offsets.val1, texU1, renderer.GetTexVAt(ends.get(i).val1, atlas) + v, showLights ? getLightColorAt(level,x + x_offsets.val1, ends.get(i).val1, y + y_offsets.val1, normal) : fullBrightColor);
selectedTesselator.addVertex(x + x_offsets.val1, starts.get(i).val1, y + y_offsets.val1, texU1, renderer.GetTexVAt(starts.get(i).val1, atlas) + v, showLights ? getLightColorAt(level,x + x_offsets.val1, starts.get(i).val1, y + y_offsets.val1, normal) : fullBrightColor);
selectedTesselator.addVertex(x + x_offsets.val2, ends.get(i).val2, y + y_offsets.val2, texU2, renderer.GetTexVAt(ends.get(i).val2, atlas) + v, showLights ? getLightColorAt(level,x + x_offsets.val2, ends.get(i).val2, y + y_offsets.val2, normal) : fullBrightColor);
selectedTesselator.addVertex(x + x_offsets.val2, starts.get(i).val2, y + y_offsets.val2, texU2, renderer.GetTexVAt(starts.get(i).val2, atlas) + v, showLights ? getLightColorAt(level,x + x_offsets.val2, starts.get(i).val2, y + y_offsets.val2, normal) : fullBrightColor);
selectedTesselator.finishQuad();

tuplePool.freeAll();
Expand Down
50 changes: 39 additions & 11 deletions Dungeoneer/src/com/interrupt/dungeoneer/tiles/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ public enum TileSpaceType { EMPTY, SOLID, OPEN_NW, OPEN_NE, OPEN_SW, OPEN_SE };
public String bottomEastTexAtlas = null;
public String bottomWestTexAtlas = null;

public Integer northTexYOffset = null;
public Integer southTexYOffset = null;
public Integer eastTexYOffset = null;
public Integer westTexYOffset = null;

public Integer bottomNorthTexYOffset = null;
public Integer bottomSouthTexYOffset = null;
public Integer bottomEastTexYOffset = null;
public Integer bottomWestTexYOffset = null;
public Byte northTexYOffset = null;
public Byte southTexYOffset = null;
public Byte eastTexYOffset = null;
public Byte westTexYOffset = null;

public Byte bottomNorthTexYOffset = null;
public Byte bottomSouthTexYOffset = null;
public Byte bottomEastTexYOffset = null;
public Byte bottomWestTexYOffset = null;

public float floorHeight = -0.5f;
public float ceilHeight = 0.5f;
Expand Down Expand Up @@ -1036,8 +1036,8 @@ public String getWallBottomTexAtlas(TileEdges dir) {
return null;
}

public int getWallYOffset(TileEdges dir) {
Integer found = null;
public byte getWallYOffset(TileEdges dir) {
Byte found = null;
if(dir == TileEdges.North) found = northTexYOffset;
else if(dir == TileEdges.South) found = southTexYOffset;
else if(dir == TileEdges.East) found = eastTexYOffset;
Expand All @@ -1050,6 +1050,34 @@ public int getWallYOffset(TileEdges dir) {
return found;
}

public void setWallYOffset(TileEdges dir, byte val) {
if(dir == TileEdges.North) northTexYOffset = val;
else if(dir == TileEdges.South) southTexYOffset = val;
else if(dir == TileEdges.East) eastTexYOffset = val;
else if(dir == TileEdges.West) westTexYOffset = val;
}

public byte getBottomWallYOffset(TileEdges dir) {
Byte found = null;
if(dir == TileEdges.North) found = bottomNorthTexYOffset;
else if(dir == TileEdges.South) found = bottomSouthTexYOffset;
else if(dir == TileEdges.East) found = bottomEastTexYOffset;
else if(dir == TileEdges.West) found = bottomWestTexYOffset;

if(found == null) {
return 0;
}

return found;
}

public void setBottomWallYOffset(TileEdges dir, byte val) {
if(dir == TileEdges.North) bottomNorthTexYOffset = val;
else if(dir == TileEdges.South) bottomSouthTexYOffset = val;
else if(dir == TileEdges.East) bottomEastTexYOffset = val;
else if(dir == TileEdges.West) bottomWestTexYOffset = val;
}

public void setWallTexture(TileEdges dir, byte tex, String atlas) {
if(dir == TileEdges.North) {
northTex = tex;
Expand Down

0 comments on commit bb8be30

Please sign in to comment.