v0.3.2: added the ability to examine custom tile visuals
This commit is contained in:
parent
d45f2b4573
commit
82cb22f1bf
|
@ -83,9 +83,20 @@ public class MassGravePainter extends Painter {
|
|||
|
||||
public static class Bones extends CustomTileVisual {
|
||||
{
|
||||
name = "Mass grave";
|
||||
|
||||
tx = Assets.PRISON_QUEST;
|
||||
txX = 3;
|
||||
txY = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
if (ofsX == 1 && ofsY == 1) {
|
||||
return "bones litter the floor, what happened here?";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,11 +60,17 @@ public class RitualSitePainter extends Painter {
|
|||
public static class RitualMarker extends CustomTileVisual{
|
||||
|
||||
{
|
||||
name = "Ritual marker";
|
||||
|
||||
tx = Assets.PRISON_QUEST;
|
||||
txX = txY = 0;
|
||||
tileW = tileH = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "A painted marker for some dark ritual. Candles are usually placed on the four corners.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -76,10 +76,16 @@ public class WeakFloorPainter extends Painter {
|
|||
public static class HiddenWell extends CustomTileVisual{
|
||||
|
||||
{
|
||||
name = "Distant well";
|
||||
|
||||
tx = Assets.WEAK_FLOOR;
|
||||
txX = Dungeon.depth/5;
|
||||
txY = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "You can just make out a well in the depths below, perhaps there is something down there?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,14 +32,16 @@ public abstract class CustomTileVisual extends Image implements Bundlable {
|
|||
|
||||
protected static final int TILE_SIZE = 16;
|
||||
|
||||
public String name;
|
||||
|
||||
protected String tx; //string for resource file
|
||||
protected int txX, txY; //position(in tiles) within resource file
|
||||
//bundleable offsets from the standard texture xy, useful for mapping larger than 1x1 textures to many tiles
|
||||
//(e.g. mapping a 3x3 texture to a room, where the corners are walls and the center is the floor)
|
||||
private int ofsX = 0, ofsY = 0;
|
||||
protected int ofsX = 0, ofsY = 0;
|
||||
|
||||
protected int tileX, tileY; //x and y coords for texture within a level
|
||||
protected int tileW = 1, tileH = 1; //width and height in tiles
|
||||
public int tileX, tileY; //x and y coords for texture within a level
|
||||
public int tileW = 1, tileH = 1; //width and height in tiles
|
||||
|
||||
public void pos(int pos) {
|
||||
pos( pos%Level.WIDTH, pos/Level.WIDTH );
|
||||
|
@ -50,6 +52,10 @@ public abstract class CustomTileVisual extends Image implements Bundlable {
|
|||
this.tileY = tileY;
|
||||
}
|
||||
|
||||
public String desc(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public CustomTileVisual create() {
|
||||
texture(tx);
|
||||
frame(texture.uvRect((txX + ofsX) * TILE_SIZE, (txY + ofsY) * TILE_SIZE,
|
||||
|
@ -61,7 +67,7 @@ public abstract class CustomTileVisual extends Image implements Bundlable {
|
|||
return this;
|
||||
}
|
||||
|
||||
//
|
||||
//returns a number of 1x1 tiles to fill a room, based on a 3x3 texture, not dissimilar to a ninepatch.
|
||||
public static ArrayList<CustomTileVisual> CustomTilesForRoom(Room r, Class<?extends CustomTileVisual> c){
|
||||
ArrayList<CustomTileVisual> result = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.CustomTileVisual;
|
||||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
|
@ -49,7 +50,29 @@ public class WndInfoCell extends Window {
|
|||
tile = Terrain.CHASM;
|
||||
}
|
||||
|
||||
CustomTileVisual vis = null;
|
||||
int x = cell % Level.WIDTH;
|
||||
int y = cell / Level.WIDTH;
|
||||
for (CustomTileVisual i : Dungeon.level.customTiles){
|
||||
if ((x >= i.tileX && x < i.tileX+i.tileW) &&
|
||||
(y >= i.tileY && y < i.tileY+i.tileH)){
|
||||
if (i.desc() != null) {
|
||||
vis = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String desc = "";
|
||||
|
||||
IconTitle titlebar = new IconTitle();
|
||||
if (vis != null){
|
||||
titlebar.icon(new Image(vis));
|
||||
titlebar.label(vis.name);
|
||||
desc += vis.desc();
|
||||
} else {
|
||||
|
||||
if (tile == Terrain.WATER) {
|
||||
Image water = new Image(Dungeon.level.waterTex());
|
||||
water.frame(0, 0, DungeonTilemap.SIZE, DungeonTilemap.SIZE);
|
||||
|
@ -58,20 +81,21 @@ public class WndInfoCell extends Window {
|
|||
titlebar.icon(DungeonTilemap.tile(tile));
|
||||
}
|
||||
titlebar.label(Dungeon.level.tileName(tile));
|
||||
desc += Dungeon.level.tileDesc(tile);
|
||||
|
||||
}
|
||||
titlebar.setRect(0, 0, WIDTH, 0);
|
||||
add(titlebar);
|
||||
|
||||
BitmapTextMultiline info = PixelScene.createMultiline(6);
|
||||
add(info);
|
||||
|
||||
StringBuilder desc = new StringBuilder( Dungeon.level.tileDesc( tile ) );
|
||||
|
||||
for (Blob blob:Dungeon.level.blobs.values()) {
|
||||
if (blob.cur[cell] > 0 && blob.tileDesc() != null) {
|
||||
if (desc.length() > 0) {
|
||||
desc.append( "\n\n" );
|
||||
desc += "\n\n";
|
||||
}
|
||||
desc.append( blob.tileDesc() );
|
||||
desc += blob.tileDesc();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user