v0.8.2: added some basic support for demo and instant app functionality

This commit is contained in:
Evan Debenham
2020-07-25 16:15:33 -04:00
parent 666e009334
commit 6cca2154d6
11 changed files with 124 additions and 22 deletions

View File

@@ -42,6 +42,7 @@ scenes.interlevelscene$mode.resurrect=Resurrecting...
scenes.interlevelscene$mode.return=Returning...
scenes.interlevelscene$mode.fall=Falling...
scenes.interlevelscene$mode.reset=Resetting...
scenes.interlevelscene.install=Install the Game
scenes.interlevelscene.file_not_found=Save file not found. If this error persists after restarting, it may mean this save game is corrupted. Sorry about that.
scenes.interlevelscene.io_error=Cannot read save file. If this error persists after restarting, it may mean this save game is corrupted. Sorry about that.
@@ -78,6 +79,7 @@ scenes.titlescene.badges=Badges
scenes.titlescene.news=News
scenes.titlescene.changes=Changes
scenes.titlescene.update=Update
scenes.titlescene.install=Install
scenes.titlescene.settings=Settings
scenes.titlescene.about=About
scenes.titlescene.support=Support the Game

View File

@@ -14,6 +14,7 @@ windows.wnddocument.missing=page missing
windows.wnderror.title=ERROR
windows.wndgame.settings=Settings
windows.wndgame.install=Install the Game
windows.wndgame.challenges=Challenges
windows.wndgame.rankings=Rankings
windows.wndgame.start=Start New Game

View File

@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
@@ -33,8 +34,12 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.services.updates.Updates;
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
import com.shatteredpixel.shatteredpixeldungeon.ui.StyledButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
import com.watabou.gltextures.TextureCache;
@@ -138,8 +143,11 @@ public class InterlevelScene extends PixelScene {
else if (loadingDepth <= 25) loadingAsset = Assets.Interfaces.LOADING_HALLS;
else loadingAsset = Assets.Interfaces.SHADOW;
//slow down transition when displaying an install prompt
if (Updates.isInstallable()){
fadeTime += 0.5f; //adds 1 second total
//speed up transition when debugging
if (DeviceCompat.isDebug()){
} else if (DeviceCompat.isDebug()){
fadeTime /= 2;
}
@@ -189,6 +197,30 @@ public class InterlevelScene extends PixelScene {
);
align(message);
add( message );
if (Updates.isInstallable()){
StyledButton install = new StyledButton(Chrome.Type.GREY_BUTTON_TR, Messages.get(this, "install")){
@Override
public void update() {
super.update();
float p = timeLeft / fadeTime;
if (phase == Phase.FADE_IN) alpha(1 - p);
else if (phase == Phase.FADE_OUT) alpha(p);
else alpha(1);
}
@Override
protected void onClick() {
super.onClick();
Updates.launchInstall();
}
};
install.icon(Icons.get(Icons.CHANGES));
install.textColor(Window.SHPX_COLOR);
install.setSize(install.reqWidth()+5, 20);
install.setPos((Camera.main.width - install.width())/2, (Camera.main.height - message.bottom())/3 + message.bottom());
add(install);
}
phase = Phase.FADE_IN;
timeLeft = fadeTime;

View File

@@ -260,18 +260,23 @@ public class TitleScene extends PixelScene {
public void update() {
super.update();
if (Updates.updateAvailable()){
if (!updateShown){
updateShown = true;
text(Messages.get(TitleScene.class, "update"));
}
if (!updateShown && (Updates.updateAvailable() || Updates.isInstallable())){
updateShown = true;
if (Updates.isInstallable()) text(Messages.get(TitleScene.class, "install"));
else text(Messages.get(TitleScene.class, "update"));
}
if (updateShown){
textColor(ColorMath.interpolate( 0xFFFFFF, Window.SHPX_COLOR, 0.5f + (float)Math.sin(Game.timeTotal*5)/2f));
}
}
@Override
protected void onClick() {
if (Updates.updateAvailable()){
if (Updates.isInstallable()){
Updates.launchInstall();
} else if (Updates.updateAvailable()){
AvailableUpdateData update = Updates.updateData();
ShatteredPixelDungeon.scene().addToFront( new WndOptions(
@@ -290,6 +295,7 @@ public class TitleScene extends PixelScene {
}
}
});
} else {
ChangesScene.changesSelected = 0;
ShatteredPixelDungeon.switchNoFade( ChangesScene.class );

View File

@@ -36,8 +36,12 @@ public class Updates {
private static Date lastCheck = null;
private static final long CHECK_DELAY = 1000*60*60; //1 hour
public static boolean isUpdateable(){
return supportsUpdates() && service.isUpdateable();
}
public static void checkForUpdate(){
if (!supportsUpdates()) return;
if (!isUpdateable()) return;
if (lastCheck != null && (new Date().getTime() - lastCheck.getTime()) < CHECK_DELAY) return;
service.checkForUpdate(!SPDSettings.WiFi(), new UpdateService.UpdateResultCallback() {
@@ -78,4 +82,14 @@ public class Updates {
lastCheck = null;
}
public static boolean isInstallable(){
return supportsUpdates() && service.isInstallable();
}
public static void launchInstall(){
if (supportsUpdates()){
service.initializeInstall();
}
}
}

View File

@@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.HeroSelectScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.RankingsScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.TitleScene;
import com.shatteredpixel.shatteredpixeldungeon.services.updates.Updates;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
@@ -59,6 +60,18 @@ public class WndGame extends Window {
});
curBtn.icon(Icons.get(Icons.PREFS));
//install prompt
if (Updates.isInstallable()){
addButton( curBtn = new RedButton( Messages.get(this, "install") ) {
@Override
protected void onClick() {
Updates.launchInstall();
}
} );
curBtn.textColor(Window.SHPX_COLOR);
curBtn.icon(Icons.get(Icons.CHANGES));
}
// Challenges window
if (Dungeon.challenges > 0) {
addButton( curBtn = new RedButton( Messages.get(this, "challenges") ) {