v0.8.2: added a settings menu tab for connectivity options
This commit is contained in:
parent
a312ea8350
commit
192ecce74b
core/src/main
services
news
debugNews/src/main/java/com/shatteredpixel/shatteredpixeldungeon/services/news
shatteredNews/src/main/java/com/shatteredpixel/shatteredpixeldungeon/services/news
src/main/java/com/shatteredpixel/shatteredpixeldungeon/services
updates
debugUpdates/src/main/java/com/shatteredpixel/shatteredpixeldungeon/services/updates
githubUpdates/src/main/java/com/shatteredpixel/shatteredpixeldungeon/services/updates
Binary file not shown.
Before ![]() (image error) Size: 10 KiB After ![]() (image error) Size: 10 KiB ![]() ![]() |
|
@ -171,6 +171,9 @@ windows.wndsettings$langstab.transifex=All translation provided by volunteers th
|
|||
windows.wndsettings$langstab.credits=credits
|
||||
windows.wndsettings$langstab.reviewers=reviewers
|
||||
windows.wndsettings$langstab.translators=translators
|
||||
windows.wndsettings$datatab.news=Check for news
|
||||
windows.wndsettings$datatab.updates=Check for updates
|
||||
windows.wndsettings$datatab.wifi=Only check on WiFi
|
||||
|
||||
windows.wndstartgame.title=Choose Your Hero
|
||||
windows.wndstartgame.huntress_unlock=Defeat the boss on floor 15 to unlock this character
|
||||
|
|
|
@ -253,6 +253,36 @@ public class SPDSettings extends GameSettings {
|
|||
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_WIFI = "wifi";
|
||||
|
||||
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 WiFi(boolean value){
|
||||
put(KEY_WIFI, value);
|
||||
}
|
||||
|
||||
public static boolean WiFi(){
|
||||
return getBoolean(KEY_WIFI, true);
|
||||
}
|
||||
|
||||
//Window management (desktop only atm)
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball;
|
||||
|
@ -241,7 +242,7 @@ public class TitleScene extends PixelScene {
|
|||
|
||||
public ChangesButton( Chrome.Type type, String label ){
|
||||
super(type, label);
|
||||
Updates.checkForUpdate();
|
||||
if (SPDSettings.updates()) Updates.checkForUpdate();
|
||||
}
|
||||
|
||||
boolean updateShown = false;
|
||||
|
|
|
@ -39,7 +39,7 @@ public class News {
|
|||
if (!supportsNews()) return;
|
||||
if (lastCheck != null && (new Date().getTime() - lastCheck.getTime()) < CHECK_DELAY) return;
|
||||
|
||||
service.checkForArticles(new NewsService.NewsResultCallback() {
|
||||
service.checkForArticles(false, new NewsService.NewsResultCallback() {
|
||||
@Override
|
||||
public void onArticlesFound(ArrayList<NewsArticle> articles) {
|
||||
lastCheck = new Date();
|
||||
|
@ -73,6 +73,9 @@ public class News {
|
|||
return unread;
|
||||
}
|
||||
|
||||
|
||||
public static void clearArticles(){
|
||||
articles = null;
|
||||
lastCheck = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.services.updates;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Updates {
|
||||
|
@ -38,7 +40,7 @@ public class Updates {
|
|||
if (!supportsUpdates()) return;
|
||||
if (lastCheck != null && (new Date().getTime() - lastCheck.getTime()) < CHECK_DELAY) return;
|
||||
|
||||
service.checkForUpdate(new UpdateService.UpdateResultCallback() {
|
||||
service.checkForUpdate(!SPDSettings.WiFi(), new UpdateService.UpdateResultCallback() {
|
||||
@Override
|
||||
public void onUpdateAvailable(AvailableUpdateData update) {
|
||||
lastCheck = new Date();
|
||||
|
@ -71,4 +73,9 @@ public class Updates {
|
|||
return updateData;
|
||||
}
|
||||
|
||||
public static void clearUpdate(){
|
||||
updateData = null;
|
||||
lastCheck = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public enum Icons {
|
|||
CLOSE,
|
||||
ARROW,
|
||||
DISPLAY,
|
||||
//TODO UI,
|
||||
DATA,
|
||||
AUDIO,
|
||||
|
||||
//ingame UI icons
|
||||
|
@ -125,10 +125,12 @@ public enum Icons {
|
|||
icon.frame( icon.texture.uvRect( 32, 16, 45, 32 ) );
|
||||
break;
|
||||
//TODO UI icon?
|
||||
case AUDIO:
|
||||
icon.frame( icon.texture.uvRect( 64, 16, 77, 28 ) );
|
||||
case DATA:
|
||||
icon.frame( icon.texture.uvRect( 48, 16, 64, 31 ) );
|
||||
break;
|
||||
case AUDIO:
|
||||
icon.frame( icon.texture.uvRect( 64, 16, 78, 30 ) );
|
||||
break;
|
||||
|
||||
case SKULL:
|
||||
icon.frame( icon.texture.uvRect( 0, 32, 8, 40 ) );
|
||||
break;
|
||||
|
|
|
@ -45,7 +45,8 @@ public class Window extends Group implements Signal.Listener<KeyEvent> {
|
|||
protected PointerArea blocker;
|
||||
protected ShadowBox shadow;
|
||||
protected NinePatch chrome;
|
||||
|
||||
|
||||
public static final int WHITE = 0xFFFFFF;
|
||||
public static final int TITLE_COLOR = 0xFFFF44;
|
||||
public static final int SHPX_COLOR = 0x33BB33;
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Languages;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.services.news.News;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.services.updates.Updates;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.CheckBox;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
|
||||
|
@ -64,6 +66,7 @@ public class WndSettings extends WndTabbed {
|
|||
private UITab ui;
|
||||
private AudioTab audio;
|
||||
private LangsTab langs;
|
||||
private DataTab data;
|
||||
|
||||
public static int last_index = 0;
|
||||
|
||||
|
@ -145,6 +148,20 @@ public class WndSettings extends WndTabbed {
|
|||
|
||||
});
|
||||
|
||||
data = new DataTab();
|
||||
data.setSize(width, 0);
|
||||
height = Math.max(height, data.height());
|
||||
add( data );
|
||||
|
||||
add( new IconTab(Icons.get(Icons.DATA)){
|
||||
@Override
|
||||
protected void select(boolean value) {
|
||||
super.select(value);
|
||||
data.visible = data.active = value;
|
||||
if (value) last_index = 4;
|
||||
}
|
||||
});
|
||||
|
||||
resize(width, (int)Math.ceil(height));
|
||||
|
||||
layoutTabs();
|
||||
|
@ -169,7 +186,7 @@ public class WndSettings extends WndTabbed {
|
|||
});
|
||||
}
|
||||
|
||||
private class DisplayTab extends Component {
|
||||
private static class DisplayTab extends Component {
|
||||
|
||||
OptionSlider optScale;
|
||||
CheckBox chkSaver;
|
||||
|
@ -300,7 +317,7 @@ public class WndSettings extends WndTabbed {
|
|||
|
||||
}
|
||||
|
||||
private class UITab extends Component {
|
||||
private static class UITab extends Component {
|
||||
|
||||
RenderedTextBlock barDesc;
|
||||
RedButton btnSplit; RedButton btnGrouped; RedButton btnCentered;
|
||||
|
@ -320,28 +337,40 @@ public class WndSettings extends WndTabbed {
|
|||
btnSplit = new RedButton(Messages.get(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(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(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(this, "flip_toolbar")){
|
||||
|
@ -445,7 +474,7 @@ public class WndSettings extends WndTabbed {
|
|||
|
||||
}
|
||||
|
||||
private class AudioTab extends Component {
|
||||
private static class AudioTab extends Component {
|
||||
|
||||
OptionSlider optMusic;
|
||||
CheckBox chkMusicMute;
|
||||
|
@ -518,7 +547,7 @@ public class WndSettings extends WndTabbed {
|
|||
|
||||
}
|
||||
|
||||
private class LangsTab extends Component{
|
||||
private static class LangsTab extends Component{
|
||||
|
||||
final static int COLS_P = 3;
|
||||
final static int COLS_L = 4;
|
||||
|
@ -735,4 +764,68 @@ public class WndSettings extends WndTabbed {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
private static class DataTab extends Component{
|
||||
|
||||
CheckBox chkNews;
|
||||
CheckBox chkUpdates;
|
||||
CheckBox chkWifi;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
chkNews = new CheckBox(Messages.get(this, "news")){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
SPDSettings.news(checked());
|
||||
News.clearArticles();
|
||||
}
|
||||
};
|
||||
chkNews.checked(SPDSettings.news());
|
||||
add(chkNews);
|
||||
|
||||
chkUpdates = new CheckBox(Messages.get(this, "updates")){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
SPDSettings.updates(checked());
|
||||
Updates.clearUpdate();
|
||||
}
|
||||
};
|
||||
chkUpdates.checked(SPDSettings.updates());
|
||||
add(chkUpdates);
|
||||
|
||||
if (!DeviceCompat.isDesktop()){
|
||||
chkWifi = new CheckBox(Messages.get(this, "wifi")){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
SPDSettings.WiFi(checked());
|
||||
}
|
||||
};
|
||||
chkWifi.checked(SPDSettings.WiFi());
|
||||
add(chkWifi);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
if (width > 200){
|
||||
chkNews.setRect(0, 0, width/2-1, BTN_HEIGHT);
|
||||
chkUpdates.setRect(chkNews.right() + GAP_TINY, chkNews.top(), width/2-1, BTN_HEIGHT);
|
||||
} else {
|
||||
chkNews.setRect(0, 0, width, BTN_HEIGHT);
|
||||
chkUpdates.setRect(0, chkNews.bottom()+GAP_TINY, width, BTN_HEIGHT);
|
||||
}
|
||||
|
||||
float pos = chkUpdates.bottom();
|
||||
if (chkWifi != null){
|
||||
chkWifi.setRect(0, pos + GAP_TINY, width, BTN_HEIGHT);
|
||||
pos = chkWifi.bottom();
|
||||
}
|
||||
|
||||
height = pos;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,14 +21,19 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.services.news;
|
||||
|
||||
import com.watabou.noosa.Game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class DebugNews extends NewsService {
|
||||
|
||||
@Override
|
||||
public void checkForArticles(NewsResultCallback callback) {
|
||||
public void checkForArticles(boolean useMetered, NewsResultCallback callback) {
|
||||
|
||||
if (!useMetered && !Game.platform.connectedToUnmeteredNetwork()){
|
||||
callback.onConnectionFailed();
|
||||
}
|
||||
|
||||
//turn on to test connection failure
|
||||
if (false){
|
||||
|
|
|
@ -34,9 +34,9 @@ import java.util.Locale;
|
|||
public class ShatteredNews extends NewsService {
|
||||
|
||||
@Override
|
||||
public void checkForArticles(NewsResultCallback callback) {
|
||||
public void checkForArticles(boolean useMetered, NewsResultCallback callback) {
|
||||
|
||||
if (!Game.platform.connectedToUnmeteredNetwork()){
|
||||
if (!useMetered && !Game.platform.connectedToUnmeteredNetwork()){
|
||||
callback.onConnectionFailed();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,6 @@ public abstract class NewsService {
|
|||
public abstract void onConnectionFailed();
|
||||
}
|
||||
|
||||
public abstract void checkForArticles( NewsResultCallback callback );
|
||||
public abstract void checkForArticles(boolean useMetered, NewsResultCallback callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public abstract class UpdateService {
|
|||
public abstract void onConnectionFailed();
|
||||
}
|
||||
|
||||
public abstract void checkForUpdate( UpdateResultCallback callback );
|
||||
public abstract void checkForUpdate( boolean useMetered, UpdateResultCallback callback );
|
||||
|
||||
public abstract void initializeUpdate( AvailableUpdateData update );
|
||||
|
||||
|
|
|
@ -30,7 +30,12 @@ public class DebugUpdates extends UpdateService {
|
|||
private static AvailableUpdateData debugUpdateInfo;
|
||||
|
||||
@Override
|
||||
public void checkForUpdate(UpdateResultCallback callback) {
|
||||
public void checkForUpdate(boolean useMetered, UpdateResultCallback callback) {
|
||||
|
||||
if (!useMetered && !Game.platform.connectedToUnmeteredNetwork()){
|
||||
callback.onConnectionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
//turn on to test update UI
|
||||
if (false){
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.badlogic.gdx.Net;
|
|||
import com.watabou.noosa.Game;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.DeviceCompat;
|
||||
import com.watabou.utils.GameSettings;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -39,9 +40,9 @@ public class GitHubUpdates extends UpdateService {
|
|||
private static Pattern versionCodePattern = Pattern.compile("internal version number: ([0-9]*)", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
@Override
|
||||
public void checkForUpdate(UpdateResultCallback callback) {
|
||||
public void checkForUpdate(boolean useMetered, UpdateResultCallback callback) {
|
||||
|
||||
if (!Game.platform.connectedToUnmeteredNetwork()){
|
||||
if (!useMetered && !Game.platform.connectedToUnmeteredNetwork()){
|
||||
callback.onConnectionFailed();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user