v1.3.0: expanded and restructured the settings menu

This commit is contained in:
Evan Debenham
2022-06-01 15:54:58 -04:00
parent 2c15e6b22e
commit 1add7aa5d5
9 changed files with 426 additions and 158 deletions

View File

@@ -26,6 +26,7 @@ import com.badlogic.gdx.Input;
import com.badlogic.gdx.controllers.Controller; import com.badlogic.gdx.controllers.Controller;
import com.badlogic.gdx.controllers.ControllerListener; import com.badlogic.gdx.controllers.ControllerListener;
import com.badlogic.gdx.controllers.ControllerMapping; import com.badlogic.gdx.controllers.ControllerMapping;
import com.badlogic.gdx.controllers.Controllers;
import com.watabou.utils.DeviceCompat; import com.watabou.utils.DeviceCompat;
import com.watabou.utils.PointF; import com.watabou.utils.PointF;
@@ -60,6 +61,10 @@ public class ControllerHandler implements ControllerListener {
} }
} }
public static boolean isControllerConnected(){
return controllersSupported() && Controllers.getCurrent() != null;
}
@Override @Override
public void connected(Controller controller) { public void connected(Controller controller) {
setControllerType(controller); setControllerType(controller);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -206,7 +206,6 @@ windows.wndsettings$displaytab.okay=Okay
windows.wndsettings$displaytab.cancel=Cancel windows.wndsettings$displaytab.cancel=Cancel
windows.wndsettings$displaytab.portrait=Switch to portrait windows.wndsettings$displaytab.portrait=Switch to portrait
windows.wndsettings$displaytab.landscape=Switch to landscape windows.wndsettings$displaytab.landscape=Switch to landscape
windows.wndsettings$displaytab.scale=Display Scale
windows.wndsettings$displaytab.brightness=Brightness windows.wndsettings$displaytab.brightness=Brightness
windows.wndsettings$displaytab.dark=Dark windows.wndsettings$displaytab.dark=Dark
windows.wndsettings$displaytab.bright=Bright windows.wndsettings$displaytab.bright=Bright
@@ -214,9 +213,11 @@ windows.wndsettings$displaytab.visual_grid=Visual Grid
windows.wndsettings$displaytab.off=Off windows.wndsettings$displaytab.off=Off
windows.wndsettings$displaytab.high=High windows.wndsettings$displaytab.high=High
windows.wndsettings$uitab.title=Interface Settings windows.wndsettings$uitab.title=Interface Settings
windows.wndsettings$uitab.size=Interface Size windows.wndsettings$uitab.ui_mode=Interface Mode
windows.wndsettings$uitab.scale=Interface Scale
windows.wndsettings$uitab.mobile=Mobile windows.wndsettings$uitab.mobile=Mobile
windows.wndsettings$uitab.full=Full windows.wndsettings$uitab.full=Full
windows.wndsettings$uitab.toolbar_settings=Toolbar Settings
windows.wndsettings$uitab.mode=Toolbar Mode: windows.wndsettings$uitab.mode=Toolbar Mode:
windows.wndsettings$uitab.split=Split windows.wndsettings$uitab.split=Split
windows.wndsettings$uitab.group=Group windows.wndsettings$uitab.group=Group
@@ -226,6 +227,13 @@ windows.wndsettings$uitab.flip_indicators=Flip Indicators
windows.wndsettings$uitab.quickslots=Quickslots windows.wndsettings$uitab.quickslots=Quickslots
windows.wndsettings$uitab.system_font=System Font windows.wndsettings$uitab.system_font=System Font
windows.wndsettings$uitab.key_bindings=Key Bindings windows.wndsettings$uitab.key_bindings=Key Bindings
windows.wndsettings$inputtab.title=Input Settings
windows.wndsettings$inputtab.key_bindings=Key Bindings
windows.wndsettings$inputtab.controller_bindings=Controller Bindings
windows.wndsettings$inputtab.controller_sensitivity=Controller Pointer Sensitivity
windows.wndsettings$inputtab.movement_sensitivity=Hold To Move Sensitivity
windows.wndsettings$inputtab.off=Off
windows.wndsettings$inputtab.high=High
windows.wndsettings$datatab.title=Connectivity Settings windows.wndsettings$datatab.title=Connectivity Settings
windows.wndsettings$datatab.news=Check for news windows.wndsettings$datatab.news=Check for news
windows.wndsettings$datatab.updates=Check for updates windows.wndsettings$datatab.updates=Check for updates

View File

@@ -48,12 +48,11 @@ public class SPDSettings extends GameSettings {
return getInt( KEY_VERSION, 0 ); return getInt( KEY_VERSION, 0 );
} }
//Graphics //Display
public static final String KEY_FULLSCREEN = "fullscreen"; public static final String KEY_FULLSCREEN = "fullscreen";
public static final String KEY_LANDSCAPE = "landscape"; public static final String KEY_LANDSCAPE = "landscape";
public static final String KEY_POWER_SAVER = "power_saver"; public static final String KEY_POWER_SAVER = "power_saver";
public static final String KEY_SCALE = "scale";
public static final String KEY_ZOOM = "zoom"; public static final String KEY_ZOOM = "zoom";
public static final String KEY_BRIGHTNESS = "brightness"; public static final String KEY_BRIGHTNESS = "brightness";
public static final String KEY_GRID = "visual_grid"; public static final String KEY_GRID = "visual_grid";
@@ -92,14 +91,6 @@ public class SPDSettings extends GameSettings {
return getBoolean( KEY_POWER_SAVER, false ); return getBoolean( KEY_POWER_SAVER, false );
} }
public static void scale( int value ) {
put( KEY_SCALE, value );
}
public static int scale() {
return getInt( KEY_SCALE, 0 );
}
public static void zoom( int value ) { public static void zoom( int value ) {
put( KEY_ZOOM, value ); put( KEY_ZOOM, value );
} }
@@ -129,6 +120,7 @@ public class SPDSettings extends GameSettings {
//Interface //Interface
public static final String KEY_UI_SIZE = "full_ui"; public static final String KEY_UI_SIZE = "full_ui";
public static final String KEY_SCALE = "scale";
public static final String KEY_QUICKSLOTS = "quickslots"; public static final String KEY_QUICKSLOTS = "quickslots";
public static final String KEY_FLIPTOOLBAR = "flipped_ui"; public static final String KEY_FLIPTOOLBAR = "flipped_ui";
public static final String KEY_FLIPTAGS = "flip_tags"; public static final String KEY_FLIPTAGS = "flip_tags";
@@ -151,6 +143,14 @@ public class SPDSettings extends GameSettings {
} }
return size; return size;
} }
public static void scale( int value ) {
put( KEY_SCALE, value );
}
public static int scale() {
return getInt( KEY_SCALE, 0 );
}
public static void quickSlots( int value ){ put( KEY_QUICKSLOTS, value ); } public static void quickSlots( int value ){ put( KEY_QUICKSLOTS, value ); }
@@ -224,7 +224,28 @@ public class SPDSettings extends GameSettings {
public static boolean supportNagged() { public static boolean supportNagged() {
return getBoolean(KEY_SUPPORT_NAGGED, false); return getBoolean(KEY_SUPPORT_NAGGED, false);
} }
//Input
public static final String KEY_CONTROLLER_SENS = "controller_sens";
public static final String KEY_MOVE_SENS = "move_sens";
public static void controllerPointerSensitivity( int value ){
put( KEY_CONTROLLER_SENS, value );
}
public static int controllerPointerSensitivity(){
return getInt(KEY_CONTROLLER_SENS, 5, 1, 10);
}
public static void movementHoldSensitivity( int value ){
put( KEY_MOVE_SENS, value );
}
public static int movementHoldSensitivity(){
return getInt(KEY_MOVE_SENS, 3, 0, 4);
}
//Audio //Audio
public static final String KEY_MUSIC = "music"; public static final String KEY_MUSIC = "music";

View File

@@ -251,10 +251,24 @@ public class CellSelector extends ScrollArea {
private GameAction heldAction3 = SPDAction.NONE; private GameAction heldAction3 = SPDAction.NONE;
private float heldDelay = 0f; private float heldDelay = 0f;
//note that delay starts ticking down on the frame it is processed
// so in most cases the actual wait is 50-58ms
private static final float INITIAL_DELAY = 0.06f;
private boolean delayingForRelease = false; private boolean delayingForRelease = false;
private static float initialDelay(){
switch (SPDSettings.movementHoldSensitivity()){
case 0:
return Float.POSITIVE_INFINITY;
case 1:
return 0.13f;
case 2:
return 0.09f;
//note that delay starts ticking down on the frame it is processed
// so in most cases the actual default wait is 50-58ms
case 3: default:
return 0.06f;
case 4:
return 0.03f;
}
}
private Signal.Listener<KeyEvent> keyListener = new Signal.Listener<KeyEvent>() { private Signal.Listener<KeyEvent> keyListener = new Signal.Listener<KeyEvent>() {
@Override @Override
@@ -307,7 +321,7 @@ public class CellSelector extends ScrollArea {
delayingForRelease = true; delayingForRelease = true;
//in case more keys are being released //in case more keys are being released
//note that this delay can tick down while the hero is moving //note that this delay can tick down while the hero is moving
heldDelay = INITIAL_DELAY; heldDelay = initialDelay();
} }
} else if (directionFromAction(action) != 0) { } else if (directionFromAction(action) != 0) {
@@ -316,7 +330,7 @@ public class CellSelector extends ScrollArea {
lastCellMoved = -1; lastCellMoved = -1;
if (heldAction1 == SPDAction.NONE){ if (heldAction1 == SPDAction.NONE){
heldAction1 = action; heldAction1 = action;
heldDelay = INITIAL_DELAY; heldDelay = initialDelay();
delayingForRelease = false; delayingForRelease = false;
} else if (heldAction2 == SPDAction.NONE){ } else if (heldAction2 == SPDAction.NONE){
heldAction2 = action; heldAction2 = action;
@@ -349,7 +363,7 @@ public class CellSelector extends ScrollArea {
if (newLeftStick != leftStickAction){ if (newLeftStick != leftStickAction){
if (leftStickAction == SPDAction.NONE){ if (leftStickAction == SPDAction.NONE){
heldDelay = INITIAL_DELAY; heldDelay = initialDelay();
Dungeon.hero.resting = false; Dungeon.hero.resting = false;
} else if (newLeftStick == SPDAction.NONE && heldDelay > 0f){ } else if (newLeftStick == SPDAction.NONE && heldDelay > 0f){
heldDelay = 0f; heldDelay = 0f;

View File

@@ -172,9 +172,19 @@ public class PixelScene extends Scene {
ControllerHandler.setControllerPointer(true); ControllerHandler.setControllerPointer(true);
virtualCursorPos = PointerEvent.currentHoverPos(); virtualCursorPos = PointerEvent.currentHoverPos();
} }
//cursor moves 500 scaled pixels per second at full speed, 100 at minimum speed
virtualCursorPos.x += defaultZoom * 500 * Game.elapsed * ControllerHandler.rightStickPosition.x; int sensitivity = SPDSettings.controllerPointerSensitivity() * 100;
virtualCursorPos.y += defaultZoom * 500 * Game.elapsed * ControllerHandler.rightStickPosition.y;
//cursor moves 100xsens scaled pixels per second at full speed
//35x at 50% movement, ~9x at 20% deadzone threshold
float xMove = (float)Math.pow(Math.abs(ControllerHandler.rightStickPosition.x), 1.5);
if (ControllerHandler.rightStickPosition.x < 0) xMove = -xMove;
float yMove = (float)Math.pow(Math.abs(ControllerHandler.rightStickPosition.y), 1.5);
if (ControllerHandler.rightStickPosition.y < 0) yMove = -yMove;
virtualCursorPos.x += defaultZoom * sensitivity * Game.elapsed * xMove;
virtualCursorPos.y += defaultZoom * sensitivity * Game.elapsed * yMove;
virtualCursorPos.x = GameMath.gate(0, virtualCursorPos.x, Game.width); virtualCursorPos.x = GameMath.gate(0, virtualCursorPos.x, Game.width);
virtualCursorPos.y = GameMath.gate(0, virtualCursorPos.y, Game.height); virtualCursorPos.y = GameMath.gate(0, virtualCursorPos.y, Game.height);
PointerEvent.addPointerEvent(new PointerEvent((int) virtualCursorPos.x, (int) virtualCursorPos.y, 10_000, PointerEvent.Type.HOVER, PointerEvent.NONE)); PointerEvent.addPointerEvent(new PointerEvent((int) virtualCursorPos.x, (int) virtualCursorPos.y, 10_000, PointerEvent.Type.HOVER, PointerEvent.NONE));

View File

@@ -56,6 +56,7 @@ public enum Icons {
AUDIO, AUDIO,
LANGS, LANGS,
CONTROLLER, CONTROLLER,
KEYBOARD,
STATS, STATS,
CHALLENGE_OFF, CHALLENGE_OFF,
CHALLENGE_ON, CHALLENGE_ON,
@@ -179,7 +180,7 @@ public enum Icons {
icon.frame( icon.texture.uvRectBySize( 32, 32, 16, 12 ) ); icon.frame( icon.texture.uvRectBySize( 32, 32, 16, 12 ) );
break; break;
case DATA: case DATA:
icon.frame( icon.texture.uvRectBySize( 48, 32, 16, 15 ) ); icon.frame( icon.texture.uvRectBySize( 48, 32, 14, 15 ) );
break; break;
case AUDIO: case AUDIO:
icon.frame( icon.texture.uvRectBySize( 64, 32, 14, 14 ) ); icon.frame( icon.texture.uvRectBySize( 64, 32, 14, 14 ) );
@@ -190,29 +191,32 @@ public enum Icons {
case CONTROLLER: case CONTROLLER:
icon.frame( icon.texture.uvRectBySize( 96, 32, 16, 12 ) ); icon.frame( icon.texture.uvRectBySize( 96, 32, 16, 12 ) );
break; break;
case KEYBOARD:
icon.frame( icon.texture.uvRectBySize( 112, 32, 15, 12 ) );
break;
case STATS: case STATS:
icon.frame( icon.texture.uvRectBySize( 112, 32, 16, 13 ) ); icon.frame( icon.texture.uvRectBySize( 128, 32, 16, 13 ) );
break; break;
case CHALLENGE_OFF: case CHALLENGE_OFF:
icon.frame( icon.texture.uvRectBySize( 128, 32, 14, 12 ) );
break;
case CHALLENGE_ON:
icon.frame( icon.texture.uvRectBySize( 144, 32, 14, 12 ) ); icon.frame( icon.texture.uvRectBySize( 144, 32, 14, 12 ) );
break; break;
case RENAME_OFF: case CHALLENGE_ON:
icon.frame( icon.texture.uvRectBySize( 160, 32, 15, 14 ) ); icon.frame( icon.texture.uvRectBySize( 160, 32, 14, 12 ) );
break; break;
case RENAME_ON: case RENAME_OFF:
icon.frame( icon.texture.uvRectBySize( 176, 32, 15, 14 ) ); icon.frame( icon.texture.uvRectBySize( 176, 32, 15, 14 ) );
break; break;
case RENAME_ON:
icon.frame( icon.texture.uvRectBySize( 192, 32, 15, 14 ) );
break;
case SEED: case SEED:
icon.frame( icon.texture.uvRectBySize( 192, 32, 10, 10 ) ); icon.frame( icon.texture.uvRectBySize( 208, 32, 10, 10 ) );
break; break;
case LEFTARROW: case LEFTARROW:
icon.frame( icon.texture.uvRectBySize( 208, 32, 14, 8 ) ); icon.frame( icon.texture.uvRectBySize( 224, 32, 14, 8 ) );
break; break;
case RIGHTARROW: case RIGHTARROW:
icon.frame( icon.texture.uvRectBySize( 224, 32, 14, 8 ) ); icon.frame( icon.texture.uvRectBySize( 240, 32, 14, 8 ) );
break; break;
case UNCHECKED: case UNCHECKED:

View File

@@ -60,6 +60,11 @@ public abstract class OptionSlider extends Component {
active = false; active = false;
} }
if (title.length() > 20){
remove(this.title);
this.title = PixelScene.renderTextBlock(6);
add(this.title);
}
this.title.text(title); this.title.text(title);
this.minTxt.text(minTxt); this.minTxt.text(minTxt);
this.maxTxt.text(maxTxt); this.maxTxt.text(maxTxt);

View File

@@ -40,8 +40,10 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar; import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.input.ControllerHandler;
import com.watabou.noosa.ColorBlock; import com.watabou.noosa.ColorBlock;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.ui.Component; import com.watabou.noosa.ui.Component;
import com.watabou.utils.DeviceCompat; import com.watabou.utils.DeviceCompat;
@@ -56,12 +58,13 @@ public class WndSettings extends WndTabbed {
private static final int WIDTH_P = 122; private static final int WIDTH_P = 122;
private static final int WIDTH_L = 223; private static final int WIDTH_L = 223;
private static final int SLIDER_HEIGHT = 24; private static final int SLIDER_HEIGHT = 23;
private static final int BTN_HEIGHT = 18; private static final int BTN_HEIGHT = 17;
private static final float GAP = 2; private static final float GAP = 2;
private DisplayTab display; private DisplayTab display;
private UITab ui; private UITab ui;
private InputTab input;
private DataTab data; private DataTab data;
private AudioTab audio; private AudioTab audio;
private LangsTab langs; private LangsTab langs;
@@ -103,6 +106,28 @@ public class WndSettings extends WndTabbed {
} }
}); });
input = new InputTab();
input.setSize(width, 0);
height = Math.max(height, input.height());
if (DeviceCompat.hasHardKeyboard() || ControllerHandler.isControllerConnected()) {
add( input );
Image icon;
if (ControllerHandler.controllerPointerActive() || !DeviceCompat.hasHardKeyboard()){
icon = Icons.get(Icons.CONTROLLER);
} else {
icon = Icons.get(Icons.KEYBOARD);
}
add(new IconTab(icon) {
@Override
protected void select(boolean value) {
super.select(value);
input.visible = input.active = value;
if (value) last_index = 2;
}
});
}
data = new DataTab(); data = new DataTab();
data.setSize(width, 0); data.setSize(width, 0);
height = Math.max(height, data.height()); height = Math.max(height, data.height());
@@ -113,7 +138,7 @@ public class WndSettings extends WndTabbed {
protected void select(boolean value) { protected void select(boolean value) {
super.select(value); super.select(value);
data.visible = data.active = value; data.visible = data.active = value;
if (value) last_index = 2; if (value) last_index = 3;
} }
}); });
@@ -127,7 +152,7 @@ public class WndSettings extends WndTabbed {
protected void select(boolean value) { protected void select(boolean value) {
super.select(value); super.select(value);
audio.visible = audio.active = value; audio.visible = audio.active = value;
if (value) last_index = 3; if (value) last_index = 4;
} }
}); });
@@ -142,7 +167,7 @@ public class WndSettings extends WndTabbed {
protected void select(boolean value) { protected void select(boolean value) {
super.select(value); super.select(value);
langs.visible = langs.active = value; langs.visible = langs.active = value;
if (value) last_index = 4; if (value) last_index = 5;
} }
@Override @Override
@@ -165,7 +190,12 @@ public class WndSettings extends WndTabbed {
layoutTabs(); layoutTabs();
select(last_index); if (tabs.size() == 5 && last_index >= 3){
//input tab isn't visible
select(last_index-1);
} else {
select(last_index);
}
} }
@@ -221,7 +251,7 @@ public class WndSettings extends WndTabbed {
} }
add(chkFullscreen); add(chkFullscreen);
if ((int)Math.ceil(2* Game.density) < PixelScene.maxDefaultZoom) { /*if ((int)Math.ceil(2* Game.density) < PixelScene.maxDefaultZoom) {
optScale = new OptionSlider(Messages.get(this, "scale"), optScale = new OptionSlider(Messages.get(this, "scale"),
(int)Math.ceil(2* Game.density)+ "X", (int)Math.ceil(2* Game.density)+ "X",
PixelScene.maxDefaultZoom + "X", PixelScene.maxDefaultZoom + "X",
@@ -237,7 +267,7 @@ public class WndSettings extends WndTabbed {
}; };
optScale.setSelectedValue(PixelScene.defaultZoom); optScale.setSelectedValue(PixelScene.defaultZoom);
add(optScale); add(optScale);
} }*/
if (DeviceCompat.isAndroid() && PixelScene.maxScreenZoom >= 2) { if (DeviceCompat.isAndroid() && PixelScene.maxScreenZoom >= 2) {
chkSaver = new CheckBox(Messages.get(this, "saver")) { chkSaver = new CheckBox(Messages.get(this, "saver")) {
@@ -367,10 +397,9 @@ public class WndSettings extends WndTabbed {
RenderedTextBlock title; RenderedTextBlock title;
ColorBlock sep1; ColorBlock sep1;
OptionSlider optUISize; OptionSlider optUIMode;
RenderedTextBlock barDesc; OptionSlider optUIScale;
RedButton btnSplit; RedButton btnGrouped; RedButton btnCentered; RedButton btnToolbarSettings;
CheckBox chkFlipToolbar;
CheckBox chkFlipTags; CheckBox chkFlipTags;
ColorBlock sep2; ColorBlock sep2;
CheckBox chkFont; CheckBox chkFont;
@@ -390,8 +419,8 @@ public class WndSettings extends WndTabbed {
float wMin = Game.width / PixelScene.MIN_WIDTH_FULL; float wMin = Game.width / PixelScene.MIN_WIDTH_FULL;
float hMin = Game.height / PixelScene.MIN_HEIGHT_FULL; float hMin = Game.height / PixelScene.MIN_HEIGHT_FULL;
if (Math.min(wMin, hMin) >= 2*Game.density){ if (Math.min(wMin, hMin) >= 2*Game.density){
optUISize = new OptionSlider( optUIMode = new OptionSlider(
Messages.get(this, "size"), Messages.get(this, "ui_mode"),
Messages.get(this, "mobile"), Messages.get(this, "mobile"),
Messages.get(this, "full"), Messages.get(this, "full"),
0, 0,
@@ -403,78 +432,152 @@ public class WndSettings extends WndTabbed {
ShatteredPixelDungeon.seamlessResetScene(); ShatteredPixelDungeon.seamlessResetScene();
} }
}; };
optUISize.setSelectedValue(SPDSettings.interfaceSize()); optUIMode.setSelectedValue(SPDSettings.interfaceSize());
add(optUISize); add(optUIMode);
}
if ((int)Math.ceil(2* Game.density) < PixelScene.maxDefaultZoom) {
optUIScale = new OptionSlider(Messages.get(this, "scale"),
(int)Math.ceil(2* Game.density)+ "X",
PixelScene.maxDefaultZoom + "X",
(int)Math.ceil(2* Game.density),
PixelScene.maxDefaultZoom ) {
@Override
protected void onChange() {
if (getSelectedValue() != SPDSettings.scale()) {
SPDSettings.scale(getSelectedValue());
ShatteredPixelDungeon.seamlessResetScene();
}
}
};
optUIScale.setSelectedValue(PixelScene.defaultZoom);
add(optUIScale);
} }
if (SPDSettings.interfaceSize() == 0) { if (SPDSettings.interfaceSize() == 0) {
barDesc = PixelScene.renderTextBlock(Messages.get(this, "mode"), 9); btnToolbarSettings = new RedButton(Messages.get(this, "toolbar_settings"), 9){
add(barDesc);
btnSplit = new RedButton(Messages.get(this, "split")) {
@Override @Override
protected void onClick() { protected void onClick() {
textColor(TITLE_COLOR); ShatteredPixelDungeon.scene().addToFront(new Window(){
btnGrouped.textColor(WHITE);
btnCentered.textColor(WHITE); RenderedTextBlock barDesc;
SPDSettings.toolbarMode(Toolbar.Mode.SPLIT.name()); RedButton btnSplit; RedButton btnGrouped; RedButton btnCentered;
Toolbar.updateLayout(); CheckBox chkFlipToolbar;
CheckBox chkFlipTags;
//TODO checkbox for forcing 6 quicksltos on mobile portrait
{
barDesc = PixelScene.renderTextBlock(Messages.get(WndSettings.UITab.this, "mode"), 9);
add(barDesc);
btnSplit = new RedButton(Messages.get(WndSettings.UITab.this, "split")) {
@Override
protected void onClick() {
textColor(TITLE_COLOR);
btnGrouped.textColor(WHITE);
btnCentered.textColor(WHITE);
SPDSettings.toolbarMode(Toolbar.Mode.SPLIT.name());
Toolbar.updateLayout();
}
};
if (SPDSettings.toolbarMode().equals(Toolbar.Mode.SPLIT.name())) {
btnSplit.textColor(TITLE_COLOR);
}
add(btnSplit);
btnGrouped = new RedButton(Messages.get(WndSettings.UITab.this, "group")) {
@Override
protected void onClick() {
btnSplit.textColor(WHITE);
textColor(TITLE_COLOR);
btnCentered.textColor(WHITE);
SPDSettings.toolbarMode(Toolbar.Mode.GROUP.name());
Toolbar.updateLayout();
}
};
if (SPDSettings.toolbarMode().equals(Toolbar.Mode.GROUP.name())) {
btnGrouped.textColor(TITLE_COLOR);
}
add(btnGrouped);
btnCentered = new RedButton(Messages.get(WndSettings.UITab.this, "center")) {
@Override
protected void onClick() {
btnSplit.textColor(WHITE);
btnGrouped.textColor(WHITE);
textColor(TITLE_COLOR);
SPDSettings.toolbarMode(Toolbar.Mode.CENTER.name());
Toolbar.updateLayout();
}
};
if (SPDSettings.toolbarMode().equals(Toolbar.Mode.CENTER.name())) {
btnCentered.textColor(TITLE_COLOR);
}
add(btnCentered);
chkFlipToolbar = new CheckBox(Messages.get(WndSettings.UITab.this, "flip_toolbar")) {
@Override
protected void onClick() {
super.onClick();
SPDSettings.flipToolbar(checked());
Toolbar.updateLayout();
}
};
chkFlipToolbar.checked(SPDSettings.flipToolbar());
add(chkFlipToolbar);
chkFlipTags = new CheckBox(Messages.get(WndSettings.UITab.this, "flip_indicators")){
@Override
protected void onClick() {
super.onClick();
SPDSettings.flipTags(checked());
GameScene.layoutTags();
}
};
chkFlipTags.checked(SPDSettings.flipTags());
add(chkFlipTags);
//layout
resize(WIDTH_P, 0);
barDesc.setPos((width - barDesc.width()) / 2f, GAP);
PixelScene.align(barDesc);
int btnWidth = (int) (width - 2 * GAP) / 3;
btnSplit.setRect(0, barDesc.bottom() + GAP, btnWidth, BTN_HEIGHT-2);
btnGrouped.setRect(btnSplit.right() + GAP, btnSplit.top(), btnWidth, BTN_HEIGHT-2);
btnCentered.setRect(btnGrouped.right() + GAP, btnSplit.top(), btnWidth, BTN_HEIGHT-2);
if (width > 200) {
chkFlipToolbar.setRect(0, btnGrouped.bottom() + GAP, width / 2 - 1, BTN_HEIGHT);
chkFlipTags.setRect(chkFlipToolbar.right() + GAP, chkFlipToolbar.top(), width / 2 - 1, BTN_HEIGHT);
} else {
chkFlipToolbar.setRect(0, btnGrouped.bottom() + GAP, width, BTN_HEIGHT);
chkFlipTags.setRect(0, chkFlipToolbar.bottom() + GAP, width, BTN_HEIGHT);
}
resize(WIDTH_P, (int)chkFlipTags.bottom());
}
});
} }
}; };
if (SPDSettings.toolbarMode().equals(Toolbar.Mode.SPLIT.name())) add(btnToolbarSettings);
btnSplit.textColor(TITLE_COLOR);
add(btnSplit);
btnGrouped = new RedButton(Messages.get(this, "group")) { } else {
@Override
protected void onClick() {
btnSplit.textColor(WHITE);
textColor(TITLE_COLOR);
btnCentered.textColor(WHITE);
SPDSettings.toolbarMode(Toolbar.Mode.GROUP.name());
Toolbar.updateLayout();
}
};
if (SPDSettings.toolbarMode().equals(Toolbar.Mode.GROUP.name()))
btnGrouped.textColor(TITLE_COLOR);
add(btnGrouped);
btnCentered = new RedButton(Messages.get(this, "center")) { chkFlipTags = new CheckBox(Messages.get(this, "flip_indicators")) {
@Override
protected void onClick() {
btnSplit.textColor(WHITE);
btnGrouped.textColor(WHITE);
textColor(TITLE_COLOR);
SPDSettings.toolbarMode(Toolbar.Mode.CENTER.name());
Toolbar.updateLayout();
}
};
if (SPDSettings.toolbarMode().equals(Toolbar.Mode.CENTER.name()))
btnCentered.textColor(TITLE_COLOR);
add(btnCentered);
chkFlipToolbar = new CheckBox(Messages.get(this, "flip_toolbar")) {
@Override @Override
protected void onClick() { protected void onClick() {
super.onClick(); super.onClick();
SPDSettings.flipToolbar(checked()); SPDSettings.flipTags(checked());
Toolbar.updateLayout(); GameScene.layoutTags();
} }
}; };
chkFlipToolbar.checked(SPDSettings.flipToolbar()); chkFlipTags.checked(SPDSettings.flipTags());
add(chkFlipToolbar); add(chkFlipTags);
}
chkFlipTags = new CheckBox(Messages.get(this, "flip_indicators")){ }
@Override
protected void onClick() {
super.onClick();
SPDSettings.flipTags(checked());
GameScene.layoutTags();
}
};
chkFlipTags.checked(SPDSettings.flipTags());
add(chkFlipTags);
sep2 = new ColorBlock(1, 1, 0xFF000000); sep2 = new ColorBlock(1, 1, 0xFF000000);
add(sep2); add(sep2);
@@ -498,22 +601,6 @@ public class WndSettings extends WndTabbed {
}; };
chkFont.checked(SPDSettings.systemFont()); chkFont.checked(SPDSettings.systemFont());
add(chkFont); add(chkFont);
if (DeviceCompat.hasHardKeyboard()){
sep3 = new ColorBlock(1, 1, 0xFF000000);
add(sep3);
btnKeyBindings = new RedButton(Messages.get(this, "key_bindings")){
@Override
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.scene().addToFront(new WndKeyBindings());
}
};
add(btnKeyBindings);
}
} }
@Override @Override
@@ -524,33 +611,32 @@ public class WndSettings extends WndTabbed {
height = sep1.y + 1; height = sep1.y + 1;
if (optUISize != null){ if (optUIMode != null && optUIScale != null && width > 200){
optUISize.setRect(0, height + GAP, width, SLIDER_HEIGHT); optUIMode.setRect(0, height + GAP, width/2-1, SLIDER_HEIGHT);
height = optUISize.bottom(); optUIScale.setRect(width/2+1, height + GAP, width/2-1, SLIDER_HEIGHT);
height = optUIScale.bottom();
} else {
if (optUIMode != null) {
optUIMode.setRect(0, height + GAP, width, SLIDER_HEIGHT);
height = optUIMode.bottom();
}
if (optUIScale != null) {
optUIScale.setRect(0, height + GAP, width, SLIDER_HEIGHT);
height = optUIScale.bottom();
}
} }
if (barDesc != null) { if (btnToolbarSettings != null) {
barDesc.setPos((width - barDesc.width()) / 2f, height + GAP); btnToolbarSettings.setRect(0, height + GAP, width, BTN_HEIGHT);
PixelScene.align(barDesc); height = btnToolbarSettings.bottom();
int btnWidth = (int) (width - 2 * GAP) / 3;
btnSplit.setRect(0, barDesc.bottom() + GAP, btnWidth, 16);
btnGrouped.setRect(btnSplit.right() + GAP, btnSplit.top(), btnWidth, 16);
btnCentered.setRect(btnGrouped.right() + GAP, btnSplit.top(), btnWidth, 16);
if (width > 200) {
chkFlipToolbar.setRect(0, btnGrouped.bottom() + GAP, width / 2 - 1, BTN_HEIGHT);
chkFlipTags.setRect(chkFlipToolbar.right() + GAP, chkFlipToolbar.top(), width / 2 - 1, BTN_HEIGHT);
} else {
chkFlipToolbar.setRect(0, btnGrouped.bottom() + GAP, width, BTN_HEIGHT);
chkFlipTags.setRect(0, chkFlipToolbar.bottom() + GAP, width, BTN_HEIGHT);
}
} else { } else {
chkFlipTags.setRect(0, height + GAP, width, BTN_HEIGHT); chkFlipTags.setRect(0, height + GAP, width, BTN_HEIGHT);
height = chkFlipTags.bottom();
} }
sep2.size(width, 1); sep2.size(width, 1);
sep2.y = chkFlipTags.bottom() + 2; sep2.y = height + 2;
chkFont.setRect(0, sep2.y + 1 + GAP, width, BTN_HEIGHT); chkFont.setRect(0, sep2.y + 1 + GAP, width, BTN_HEIGHT);
@@ -575,6 +661,128 @@ public class WndSettings extends WndTabbed {
} }
private static class InputTab extends Component{
RenderedTextBlock title;
ColorBlock sep1;
RedButton btnKeyBindings;
RedButton btnControllerBindings;
ColorBlock sep2;
OptionSlider optControlSens;
OptionSlider optHoldMoveSens;
@Override
protected void createChildren() {
title = PixelScene.renderTextBlock(Messages.get(this, "title"), 9);
title.hardlight(TITLE_COLOR);
add(title);
sep1 = new ColorBlock(1, 1, 0xFF000000);
add(sep1);
if (DeviceCompat.hasHardKeyboard()){
btnKeyBindings = new RedButton(Messages.get(this, "key_bindings")){
@Override
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.scene().addToFront(new WndKeyBindings());
}
};
add(btnKeyBindings);
}
if (ControllerHandler.isControllerConnected()){
btnControllerBindings = new RedButton(Messages.get(this, "controller_bindings")){
@Override
protected void onClick() {
super.onClick();
//TODO Controller bindings menu
}
};
add(btnControllerBindings);
}
sep2 = new ColorBlock(1, 1, 0xFF000000);
add(sep2);
optControlSens = new OptionSlider(
Messages.get(this, "controller_sensitivity"),
"1",
"10",
1,
10
) {
@Override
protected void onChange() {
SPDSettings.controllerPointerSensitivity(getSelectedValue());
}
};
optControlSens.setSelectedValue(SPDSettings.controllerPointerSensitivity());
add(optControlSens);
optHoldMoveSens = new OptionSlider(
Messages.get(this, "movement_sensitivity"),
Messages.get(this, "off"),
Messages.get(this, "high"),
0,
4
) {
@Override
protected void onChange() {
SPDSettings.movementHoldSensitivity(getSelectedValue());
}
};
optHoldMoveSens.setSelectedValue(SPDSettings.movementHoldSensitivity());
add(optHoldMoveSens);
}
@Override
protected void layout() {
title.setPos((width - title.width())/2, y + GAP);
sep1.size(width, 1);
sep1.y = title.bottom() + 2*GAP;
height = sep1.y+1;
if (width > 200 && btnKeyBindings != null && btnControllerBindings != null){
btnKeyBindings.setRect(0, height + GAP, width/2-1, BTN_HEIGHT);
btnControllerBindings.setRect(width/2+1, height + GAP, width/2-1, BTN_HEIGHT);
height = btnControllerBindings.bottom();
} else {
if (btnKeyBindings != null) {
btnKeyBindings.setRect(0, height + GAP, width, BTN_HEIGHT);
height = btnKeyBindings.bottom();
}
if (btnControllerBindings != null) {
btnControllerBindings.setRect(0, height + GAP, width, BTN_HEIGHT);
height = btnControllerBindings.bottom();
}
}
sep2.size(width, 1);
sep2.y = height+ GAP;
if (width > 200){
optControlSens.setRect(0, sep2.y + 1 + GAP, width/2-1, SLIDER_HEIGHT);
optHoldMoveSens.setRect(width/2 + 1, optControlSens.top(), width/2 -1, SLIDER_HEIGHT);
} else {
optControlSens.setRect(0, sep2.y + 1 + GAP, width, SLIDER_HEIGHT);
optHoldMoveSens.setRect(0, optControlSens.bottom() + GAP, width, SLIDER_HEIGHT);
}
height = optHoldMoveSens.bottom();
}
}
private static class DataTab extends Component{ private static class DataTab extends Component{
RenderedTextBlock title; RenderedTextBlock title;
@@ -811,13 +1019,12 @@ public class WndSettings extends WndTabbed {
private static class LangsTab extends Component{ private static class LangsTab extends Component{
final static int COLS_P = 3; final static int COLS_P = 3;
final static int COLS_L = 4; final static int COLS_L = 6;
final static int BTN_HEIGHT = 11; final static int BTN_HEIGHT = 11;
RenderedTextBlock title; RenderedTextBlock title;
ColorBlock sep1; ColorBlock sep1;
RenderedTextBlock txtLangName;
RenderedTextBlock txtLangInfo; RenderedTextBlock txtLangInfo;
ColorBlock sep2; ColorBlock sep2;
RedButton[] lanBtns; RedButton[] lanBtns;
@@ -843,17 +1050,14 @@ public class WndSettings extends WndTabbed {
final Languages currLang = Messages.lang(); final Languages currLang = Messages.lang();
txtLangName = PixelScene.renderTextBlock( Messages.titleCase(currLang.nativeName()) , 9 );
if (currLang.status() == Languages.Status.REVIEWED) txtLangName.hardlight(TITLE_COLOR);
else if (currLang.status() == Languages.Status.UNREVIEWED) txtLangName.hardlight(CharSprite.WARNING);
else if (currLang.status() == Languages.Status.INCOMPLETE) txtLangName.hardlight(CharSprite.NEGATIVE);
add(txtLangName);
txtLangInfo = PixelScene.renderTextBlock(6); txtLangInfo = PixelScene.renderTextBlock(6);
if (currLang == Languages.ENGLISH) txtLangInfo.text("This is the source language, written by the developer."); String info = "_" + Messages.titleCase(currLang.nativeName()) + "_ - ";
else if (currLang.status() == Languages.Status.REVIEWED) txtLangInfo.text(Messages.get(this, "completed")); if (currLang == Languages.ENGLISH) info += "This is the source language, written by the developer.";
else if (currLang.status() == Languages.Status.UNREVIEWED) txtLangInfo.text(Messages.get(this, "unreviewed")); else if (currLang.status() == Languages.Status.REVIEWED) info += Messages.get(this, "completed");
else if (currLang.status() == Languages.Status.INCOMPLETE) txtLangInfo.text(Messages.get(this, "unfinished")); else if (currLang.status() == Languages.Status.UNREVIEWED) info += Messages.get(this, "unreviewed");
else if (currLang.status() == Languages.Status.INCOMPLETE) info += Messages.get(this, "unfinished");
txtLangInfo.text(info);
if (currLang.status() == Languages.Status.UNREVIEWED) txtLangInfo.setHightlighting(true, CharSprite.WARNING); if (currLang.status() == Languages.Status.UNREVIEWED) txtLangInfo.setHightlighting(true, CharSprite.WARNING);
else if (currLang.status() == Languages.Status.INCOMPLETE) txtLangInfo.setHightlighting(true, CharSprite.NEGATIVE); else if (currLang.status() == Languages.Status.INCOMPLETE) txtLangInfo.setHightlighting(true, CharSprite.NEGATIVE);
add(txtLangInfo); add(txtLangInfo);
@@ -864,7 +1068,7 @@ public class WndSettings extends WndTabbed {
lanBtns = new RedButton[langs.size()]; lanBtns = new RedButton[langs.size()];
for (int i = 0; i < langs.size(); i++){ for (int i = 0; i < langs.size(); i++){
final int langIndex = i; final int langIndex = i;
RedButton btn = new RedButton(Messages.titleCase(langs.get(i).nativeName()), 8){ RedButton btn = new RedButton(Messages.titleCase(langs.get(i).nativeName()), 7){
@Override @Override
protected void onClick() { protected void onClick() {
super.onClick(); super.onClick();
@@ -902,7 +1106,7 @@ public class WndSettings extends WndTabbed {
sep3 = new ColorBlock(1, 1, 0xFF000000); sep3 = new ColorBlock(1, 1, 0xFF000000);
add(sep3); add(sep3);
txtTranifex = PixelScene.renderTextBlock(6); txtTranifex = PixelScene.renderTextBlock(5);
txtTranifex.text(Messages.get(this, "transifex")); txtTranifex.text(Messages.get(this, "transifex"));
add(txtTranifex); add(txtTranifex);
@@ -995,10 +1199,7 @@ public class WndSettings extends WndTabbed {
sep1.size(width, 1); sep1.size(width, 1);
sep1.y = title.bottom() + 2*GAP; sep1.y = title.bottom() + 2*GAP;
txtLangName.setPos( (width - txtLangName.width())/2f, sep1.y + 1 + GAP ); txtLangInfo.setPos(0, sep1.y + 1 + GAP);
PixelScene.align(txtLangName);
txtLangInfo.setPos(0, txtLangName.bottom() + 2*GAP);
txtLangInfo.maxWidth((int)width); txtLangInfo.maxWidth((int)width);
y = txtLangInfo.bottom() + GAP; y = txtLangInfo.bottom() + GAP;