v2.3.1: added a setting for vibration & improved vibration support logic

This commit is contained in:
Evan Debenham
2024-01-25 13:09:00 -05:00
parent b849ca58f0
commit f36dda3064
9 changed files with 147 additions and 72 deletions

View File

@@ -143,6 +143,8 @@ public class SPDSettings extends GameSettings {
public static final String KEY_FLIPTAGS = "flip_tags";
public static final String KEY_BARMODE = "toolbar_mode";
public static final String KEY_SLOTWATERSKIN= "quickslot_waterskin";
public static final String KEY_SYSTEMFONT = "system_font";
public static final String KEY_VIBRATION = "vibration";
//0 = mobile, 1 = mixed (large without inventory in main UI), 2 = large
public static void interfaceSize( int value ){
@@ -201,7 +203,24 @@ public class SPDSettings extends GameSettings {
public static boolean quickslotWaterskin(){
return getBoolean( KEY_SLOTWATERSKIN, true );
}
public static void systemFont(boolean value){
put(KEY_SYSTEMFONT, value);
}
public static boolean systemFont(){
return getBoolean(KEY_SYSTEMFONT,
(language() == Languages.KOREAN || language() == Languages.CHINESE || language() == Languages.JAPANESE));
}
public static void vibration(boolean value){
put(KEY_VIBRATION, value);
}
public static boolean vibration(){
return getBoolean(KEY_VIBRATION, true);
}
//Game State
public static final String KEY_LAST_CLASS = "last_class";
@@ -281,6 +300,55 @@ public class SPDSettings extends GameSettings {
return getInt(KEY_MOVE_SENS, 3, 0, 4);
}
//Connectivity
public static final String KEY_NEWS = "news";
public static final String KEY_UPDATES = "updates";
public static final String KEY_BETAS = "betas";
public static final String KEY_WIFI = "wifi";
public static final String KEY_NEWS_LAST_READ = "news_last_read";
public static void news(boolean value){
put(KEY_NEWS, value);
}
public static boolean news(){
return getBoolean(KEY_NEWS, true);
}
public static void updates(boolean value){
put(KEY_UPDATES, value);
}
public static boolean updates(){
return getBoolean(KEY_UPDATES, true);
}
public static void betas(boolean value){
put(KEY_BETAS, value);
}
public static boolean betas(){
return getBoolean(KEY_BETAS, Game.version.contains("BETA") || Game.version.contains("RC"));
}
public static void WiFi(boolean value){
put(KEY_WIFI, value);
}
public static boolean WiFi(){
return getBoolean(KEY_WIFI, true);
}
public static void newsLastRead(long lastRead){
put(KEY_NEWS_LAST_READ, lastRead);
}
public static long newsLastRead(){
return getLong(KEY_NEWS_LAST_READ, 0);
}
//Audio
public static final String KEY_MUSIC = "music";
@@ -343,10 +411,9 @@ public class SPDSettings extends GameSettings {
return getBoolean( KEY_MUSIC_BG, true);
}
//Languages and Font
//Languages
public static final String KEY_LANG = "language";
public static final String KEY_SYSTEMFONT = "system_font";
public static void language(Languages lang) {
put( KEY_LANG, lang.code());
@@ -360,65 +427,7 @@ public class SPDSettings extends GameSettings {
return Languages.matchCode(code);
}
}
public static void systemFont(boolean value){
put(KEY_SYSTEMFONT, value);
}
public static boolean systemFont(){
return getBoolean(KEY_SYSTEMFONT,
(language() == Languages.KOREAN || language() == Languages.CHINESE || language() == Languages.JAPANESE));
}
//Connectivity
public static final String KEY_NEWS = "news";
public static final String KEY_UPDATES = "updates";
public static final String KEY_BETAS = "betas";
public static final String KEY_WIFI = "wifi";
public static final String KEY_NEWS_LAST_READ = "news_last_read";
public static void news(boolean value){
put(KEY_NEWS, value);
}
public static boolean news(){
return getBoolean(KEY_NEWS, true);
}
public static void updates(boolean value){
put(KEY_UPDATES, value);
}
public static boolean updates(){
return getBoolean(KEY_UPDATES, true);
}
public static void betas(boolean value){
put(KEY_BETAS, value);
}
public static boolean betas(){
return getBoolean(KEY_BETAS, Game.version.contains("BETA") || Game.version.contains("RC"));
}
public static void WiFi(boolean value){
put(KEY_WIFI, value);
}
public static boolean WiFi(){
return getBoolean(KEY_WIFI, true);
}
public static void newsLastRead(long lastRead){
put(KEY_NEWS_LAST_READ, lastRead);
}
public static long newsLastRead(){
return getLong(KEY_NEWS_LAST_READ, 0);
}
//Window management (desktop only atm)
public static final String KEY_WINDOW_WIDTH = "window_width";
@@ -444,5 +453,4 @@ public class SPDSettings extends GameSettings {
public static boolean windowMaximized(){
return getBoolean( KEY_WINDOW_MAXIMIZED, false );
}
}

View File

@@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
import com.watabou.input.ControllerHandler;
import com.watabou.input.GameAction;
import com.watabou.input.KeyBindings;
@@ -161,7 +162,9 @@ public class Button extends Component {
clickReady = false; //did a long click, can't do a regular one
onPointerUp();
Game.vibrate( 50 );
if (SPDSettings.vibration()) {
Game.vibrate(50);
}
}
}
}

View File

@@ -413,6 +413,7 @@ public class WndSettings extends WndTabbed {
CheckBox chkFlipTags;
ColorBlock sep2;
CheckBox chkFont;
CheckBox chkVibrate;
@Override
protected void createChildren() {
@@ -630,6 +631,17 @@ public class WndSettings extends WndTabbed {
};
chkFont.checked(SPDSettings.systemFont());
add(chkFont);
chkVibrate = new CheckBox(Messages.get(this, "vibration")){
@Override
protected void onClick() {
super.onClick();
SPDSettings.vibration(checked());
}
};
chkVibrate.checked(SPDSettings.vibration());
chkVibrate.enable(Game.platform.supportsVibration());
add(chkVibrate);
}
@Override
@@ -667,8 +679,16 @@ public class WndSettings extends WndTabbed {
sep2.size(width, 1);
sep2.y = height + GAP;
chkFont.setRect(0, sep2.y + 1 + GAP, width, BTN_HEIGHT);
height = chkFont.bottom();
if (width > 200) {
chkFont.setRect(0, sep2.y + 1 + GAP, width/2-1, BTN_HEIGHT);
chkVibrate.setRect(chkFont.right()+2, chkFont.top(), width/2-1, BTN_HEIGHT);
height = chkVibrate.bottom();
} else {
chkFont.setRect(0, sep2.y + 1 + GAP, width, BTN_HEIGHT);
chkVibrate.setRect(0, chkFont.bottom() + GAP, width, BTN_HEIGHT);
height = chkVibrate.bottom();
}
}
}