From 8064b4ee37e42e6192192273a50e7ab17f6832b4 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 6 Jan 2017 21:37:50 -0500 Subject: [PATCH] v0.5.0: added a visual grid --- core/src/main/assets/visual_grid.png | Bin 0 -> 192 bytes .../shatteredpixeldungeon/Preferences.java | 1 + .../ShatteredPixelDungeon.java | 9 ++ .../scenes/GameScene.java | 7 + .../tiles/DungeonTerrainTilemap.java | 20 +++ .../tiles/GridTileMap.java | 47 +++++++ .../windows/WndSettings.java | 121 ++++++++++-------- .../messages/windows/windows.properties | 27 ++-- 8 files changed, 168 insertions(+), 64 deletions(-) create mode 100644 core/src/main/assets/visual_grid.png create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/GridTileMap.java diff --git a/core/src/main/assets/visual_grid.png b/core/src/main/assets/visual_grid.png new file mode 100644 index 0000000000000000000000000000000000000000..5b30418d153e10eee09d464503abcee8c5bb5a18 GIT binary patch literal 192 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=?Vc`gqj_k4 + */ package com.shatteredpixel.shatteredpixeldungeon.tiles; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/GridTileMap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/GridTileMap.java new file mode 100644 index 000000000..6a91732a1 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/GridTileMap.java @@ -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; + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java index 7d5806708..9ee8a9732 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java @@ -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 ); diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties index 59c99084a..7e6b77fea 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties @@ -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