v0.5.0: added a visual grid

This commit is contained in:
Evan Debenham 2017-01-06 21:37:50 -05:00
parent 07819073fc
commit 8064b4ee37
8 changed files with 168 additions and 64 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

View File

@ -47,6 +47,7 @@ enum Preferences {
public static final String KEY_CLASSICFONT = "classic_font";
public static final String KEY_INTRO = "intro";
public static final String KEY_BRIGHTNESS = "brightness";
public static final String KEY_GRID = "visual_grid";
public static final String KEY_VERSION = "version";
private SharedPreferences prefs;

View File

@ -471,6 +471,15 @@ public class ShatteredPixelDungeon extends Game {
return Preferences.INSTANCE.getInt( Preferences.KEY_BRIGHTNESS, 0, -2, 2 );
}
public static void visualGrid( int value ){
Preferences.INSTANCE.put( Preferences.KEY_GRID, value );
GameScene.updateMap();
}
public static int visualGrid() {
return Preferences.INSTANCE.getInt( Preferences.KEY_GRID, 0, -1, 3 );
}
public static void language(Languages lang) {
Preferences.INSTANCE.put( Preferences.KEY_LANG, lang.code());
}

View File

@ -25,6 +25,7 @@ import android.opengl.GLES20;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.tiles.GridTileMap;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTerrainTilemap;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.tiles.FogOfWar;
@ -113,6 +114,7 @@ public class GameScene extends PixelScene {
private SkinnedBlock water;
private DungeonTerrainTilemap tiles;
private GridTileMap visualGrid;
private TerrainFeaturesTilemap terrainFeatures;
private DungeonWallsTilemap walls;
private WallBlockingTilemap wallBlocking;
@ -201,6 +203,9 @@ public class GameScene extends PixelScene {
addCustomTile(visual.create());
}
visualGrid = new GridTileMap();
terrain.add( visualGrid );
terrainFeatures = new TerrainFeaturesTilemap(Dungeon.level.plants, Dungeon.level.traps);
terrain.add(terrainFeatures);
@ -698,6 +703,7 @@ public class GameScene extends PixelScene {
public static void updateMap() {
if (scene != null) {
scene.tiles.updateMap();
scene.visualGrid.updateMap();
scene.terrainFeatures.updateMap();
scene.walls.updateMap();
}
@ -706,6 +712,7 @@ public class GameScene extends PixelScene {
public static void updateMap( int cell ) {
if (scene != null) {
scene.tiles.updateMapCell( cell );
scene.visualGrid.updateMapCell( cell );
scene.terrainFeatures.updateMapCell( cell );
scene.walls.updateMapCell( cell );
scene.fog.updateFogCell( cell );

View File

@ -1,3 +1,23 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2016 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.tiles;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;

View File

@ -0,0 +1,47 @@
package com.shatteredpixel.shatteredpixeldungeon.tiles;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
public class GridTileMap extends DungeonTilemap {
public GridTileMap() {
super("visual_grid.png");
map( Dungeon.level.map, Dungeon.level.width() );
}
private int gridSetting = -1;
@Override
public synchronized void updateMap() {
gridSetting = ShatteredPixelDungeon.visualGrid();
super.updateMap();
}
@Override
protected int getTileVisual(int pos, int tile, boolean flat) {
if (gridSetting == -1 || pos % 2 != (pos / mapWidth) % 2){
return -1;
} else if (DungeonTileSheet.floorTile(tile)) {
return gridSetting;
} else if (DungeonTileSheet.doorTiles.contains(tile)){
if (DungeonTileSheet.wallStitcheable.contains(map[pos - mapWidth])){
return 12 + gridSetting;
} else if ( tile == Terrain.OPEN_DOOR){
return 8 + gridSetting;
} else {
return 4 + gridSetting;
}
} else {
return -1;
}
}
@Override
protected boolean needsRender(int pos) {
return data[pos] != -1;
}
}

View File

@ -38,14 +38,14 @@ import com.watabou.noosa.audio.Sample;
public class WndSettings extends WndTabbed {
private static final int WIDTH = 112;
private static final int HEIGHT = 124;
private static final int SLIDER_HEIGHT = 25;
private static final int BTN_HEIGHT = 20;
private static final int HEIGHT = 138;
private static final int SLIDER_HEIGHT = 24;
private static final int BTN_HEIGHT = 18;
private static final int GAP_TINY = 2;
private static final int GAP_SML = 5;
private static final int GAP_LRG = 12;
private static final int GAP_SML = 6;
private static final int GAP_LRG = 18;
private ScreenTab screen;
private DisplayTab display;
private UITab ui;
private AudioTab audio;
@ -54,8 +54,8 @@ public class WndSettings extends WndTabbed {
public WndSettings() {
super();
screen = new ScreenTab();
add( screen );
display = new DisplayTab();
add( display );
ui = new UITab();
add( ui );
@ -63,11 +63,11 @@ public class WndSettings extends WndTabbed {
audio = new AudioTab();
add( audio );
add( new LabeledTab(Messages.get(this, "screen")){
add( new LabeledTab(Messages.get(this, "display")){
@Override
protected void select(boolean value) {
super.select(value);
screen.visible = screen.active = value;
display.visible = display.active = value;
if (value) last_index = 0;
}
});
@ -98,9 +98,9 @@ public class WndSettings extends WndTabbed {
}
private class ScreenTab extends Group {
private class DisplayTab extends Group {
public ScreenTab() {
public DisplayTab() {
super();
OptionSlider scale = new OptionSlider(Messages.get(this, "scale"),
@ -126,33 +126,11 @@ public class WndSettings extends WndTabbed {
}
}
};
scale.setSelectedValue(PixelScene.defaultZoom);
scale.setRect(0, 0, WIDTH, SLIDER_HEIGHT);
if ((int)Math.ceil(2* Game.density) < PixelScene.maxDefaultZoom)
if ((int)Math.ceil(2* Game.density) < PixelScene.maxDefaultZoom) {
scale.setSelectedValue(PixelScene.defaultZoom);
scale.setRect(0, 0, WIDTH, SLIDER_HEIGHT);
add(scale);
OptionSlider brightness = new OptionSlider(Messages.get(this, "brightness"),
Messages.get(this, "dark"), Messages.get(this, "bright"), -2, 2) {
@Override
protected void onChange() {
ShatteredPixelDungeon.brightness(getSelectedValue());
}
};
brightness.setSelectedValue(ShatteredPixelDungeon.brightness());
brightness.setRect(0, scale.bottom() + GAP_TINY, WIDTH, SLIDER_HEIGHT);
add(brightness);
CheckBox chkImmersive = new CheckBox( Messages.get(this, "soft_keys") ) {
@Override
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.immerse(checked());
}
};
chkImmersive.setRect( 0, brightness.bottom() + GAP_SML, WIDTH, BTN_HEIGHT );
chkImmersive.checked(ShatteredPixelDungeon.immersed());
chkImmersive.enable(android.os.Build.VERSION.SDK_INT >= 19);
add(chkImmersive);
}
CheckBox chkSaver = new CheckBox( Messages.get(this, "saver") ) {
@Override
@ -161,10 +139,10 @@ public class WndSettings extends WndTabbed {
if (checked()) {
checked(!checked());
ShatteredPixelDungeon.scene().add(new WndOptions(
Messages.get(ScreenTab.class, "saver"),
Messages.get(ScreenTab.class, "saver_desc"),
Messages.get(ScreenTab.class, "okay"),
Messages.get(ScreenTab.class, "cancel")) {
Messages.get(DisplayTab.class, "saver"),
Messages.get(DisplayTab.class, "saver_desc"),
Messages.get(DisplayTab.class, "okay"),
Messages.get(DisplayTab.class, "cancel")) {
@Override
protected void onSelect(int index) {
if (index == 0) {
@ -178,9 +156,11 @@ public class WndSettings extends WndTabbed {
}
}
};
chkSaver.setRect( 0, chkImmersive.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT );
chkSaver.checked(ShatteredPixelDungeon.powerSaver());
if (PixelScene.maxScreenZoom >= 2) add(chkSaver);
if (PixelScene.maxScreenZoom >= 2) {
chkSaver.setRect(0, scale.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
chkSaver.checked(ShatteredPixelDungeon.powerSaver());
add(chkSaver);
}
RedButton btnOrientation = new RedButton( ShatteredPixelDungeon.landscape() ?
Messages.get(this, "portrait")
@ -190,8 +170,33 @@ public class WndSettings extends WndTabbed {
ShatteredPixelDungeon.landscape(!ShatteredPixelDungeon.landscape());
}
};
btnOrientation.setRect(0, chkSaver.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
btnOrientation.setRect(0, chkSaver.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
add( btnOrientation );
OptionSlider brightness = new OptionSlider(Messages.get(this, "brightness"),
Messages.get(this, "dark"), Messages.get(this, "bright"), -2, 2) {
@Override
protected void onChange() {
ShatteredPixelDungeon.brightness(getSelectedValue());
}
};
brightness.setSelectedValue(ShatteredPixelDungeon.brightness());
brightness.setRect(0, btnOrientation.bottom() + GAP_LRG, WIDTH, SLIDER_HEIGHT);
add(brightness);
OptionSlider tileGrid = new OptionSlider(Messages.get(this, "visual_grid"),
Messages.get(this, "off"), Messages.get(this, "high"), -1, 3) {
@Override
protected void onChange() {
ShatteredPixelDungeon.visualGrid(getSelectedValue());
}
};
tileGrid.setSelectedValue(ShatteredPixelDungeon.visualGrid());
tileGrid.setRect(0, brightness.bottom() + GAP_TINY, WIDTH, SLIDER_HEIGHT);
add(tileGrid);
}
}
@ -212,7 +217,7 @@ public class WndSettings extends WndTabbed {
Toolbar.updateLayout();
}
};
btnSplit.setRect( 1, barDesc.y + barDesc.baseLine()+GAP_TINY, 36, 16);
btnSplit.setRect( 0, barDesc.y + barDesc.baseLine()+GAP_TINY, 36, 16);
add(btnSplit);
RedButton btnGrouped = new RedButton(Messages.get(this, "group")){
@ -222,7 +227,7 @@ public class WndSettings extends WndTabbed {
Toolbar.updateLayout();
}
};
btnGrouped.setRect( btnSplit.right()+1, barDesc.y + barDesc.baseLine()+GAP_TINY, 36, 16);
btnGrouped.setRect( btnSplit.right()+GAP_TINY, barDesc.y + barDesc.baseLine()+GAP_TINY, 36, 16);
add(btnGrouped);
RedButton btnCentered = new RedButton(Messages.get(this, "center")){
@ -232,7 +237,7 @@ public class WndSettings extends WndTabbed {
Toolbar.updateLayout();
}
};
btnCentered.setRect(btnGrouped.right()+1, barDesc.y + barDesc.baseLine()+GAP_TINY, 36, 16);
btnCentered.setRect(btnGrouped.right()+GAP_TINY, barDesc.y + barDesc.baseLine()+GAP_TINY, 36, 16);
add(btnCentered);
CheckBox chkFlipToolbar = new CheckBox(Messages.get(this, "flip_toolbar")){
@ -270,6 +275,18 @@ public class WndSettings extends WndTabbed {
slots.setRect(0, chkFlipTags.bottom() + GAP_TINY, WIDTH, SLIDER_HEIGHT);
add(slots);
CheckBox chkImmersive = new CheckBox( Messages.get(this, "soft_keys") ) {
@Override
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.immerse(checked());
}
};
chkImmersive.setRect( 0, slots.bottom() + GAP_SML, WIDTH, BTN_HEIGHT );
chkImmersive.checked(ShatteredPixelDungeon.immersed());
chkImmersive.enable(android.os.Build.VERSION.SDK_INT >= 19);
add(chkImmersive);
CheckBox chkFont = new CheckBox(Messages.get(this, "system_font")){
@Override
protected void onClick() {
@ -287,7 +304,7 @@ public class WndSettings extends WndTabbed {
});
}
};
chkFont.setRect(0, slots.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
chkFont.setRect(0, chkImmersive.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
chkFont.checked(!ShatteredPixelDungeon.classicFont());
add(chkFont);
}
@ -315,7 +332,7 @@ public class WndSettings extends WndTabbed {
ShatteredPixelDungeon.music(!checked());
}
};
musicMute.setRect(0, musicVol.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
musicMute.setRect(0, musicVol.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
musicMute.checked(!ShatteredPixelDungeon.music());
add(musicMute);
@ -339,7 +356,7 @@ public class WndSettings extends WndTabbed {
Sample.INSTANCE.play( Assets.SND_CLICK );
}
};
btnSound.setRect(0, SFXVol.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
btnSound.setRect(0, SFXVol.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT);
btnSound.checked(!ShatteredPixelDungeon.soundFx());
add( btnSound );

View File

@ -80,20 +80,22 @@ windows.wndsadghost.weapon=Ghost's weapon
windows.wndsadghost.armor=Ghost's armor
windows.wndsadghost.farewell=Farewell, adventurer!
windows.wndsettings.screen=Screen
windows.wndsettings.display=Display
windows.wndsettings.ui=UI
windows.wndsettings.audio=Audio
windows.wndsettings$screentab.scale=Display Scale
windows.wndsettings$screentab.brightness=Brightness
windows.wndsettings$screentab.dark=Dark
windows.wndsettings$screentab.bright=Bright
windows.wndsettings$screentab.soft_keys=Hide Software Keys
windows.wndsettings$screentab.saver=Power Saver
windows.wndsettings$screentab.saver_desc=Power Saver mode draws the game at a reduced size and scales it up to fit your screen.\n\nThis will make graphics less crisp and enlarge the UI slightly, but will also improve performance and battery life.\n\nYou may need to restart the game for changes to take effect.
windows.wndsettings$screentab.okay=Okay
windows.wndsettings$screentab.cancel=Cancel
windows.wndsettings$screentab.portrait=Switch to portrait
windows.wndsettings$screentab.landscape=Switch to landscape
windows.wndsettings$displaytab.scale=Display Scale
windows.wndsettings$displaytab.saver=Power Saver
windows.wndsettings$displaytab.saver_desc=Power Saver mode draws the game at a reduced size and scales it up to fit your screen.\n\nThis will make graphics less crisp and enlarge the UI slightly, but will also improve performance and battery life.\n\nYou may need to restart the game for changes to take effect.
windows.wndsettings$displaytab.okay=Okay
windows.wndsettings$displaytab.cancel=Cancel
windows.wndsettings$displaytab.portrait=Switch to portrait
windows.wndsettings$displaytab.landscape=Switch to landscape
windows.wndsettings$displaytab.brightness=Brightness
windows.wndsettings$displaytab.dark=Dark
windows.wndsettings$displaytab.bright=Bright
windows.wndsettings$displaytab.visual_grid=Visual Grid
windows.wndsettings$displaytab.off=Off
windows.wndsettings$displaytab.high=High
windows.wndsettings$uitab.mode=Toolbar Mode:
windows.wndsettings$uitab.split=Split
windows.wndsettings$uitab.group=Group
@ -101,6 +103,7 @@ windows.wndsettings$uitab.center=Center
windows.wndsettings$uitab.flip_toolbar=Flip Toolbar
windows.wndsettings$uitab.flip_indicators=Flip Indicators
windows.wndsettings$uitab.quickslots=Quickslots
windows.wndsettings$uitab.soft_keys=Hide Software Keys
windows.wndsettings$uitab.system_font=System Font
windows.wndsettings$audiotab.music_vol=Music Volume
windows.wndsettings$audiotab.music_mute=Mute Music