Added functionality to fps/performance-boost buttons

New Gradle version
This commit is contained in:
=
2018-04-22 12:35:49 +02:00
parent 30b702b778
commit 1871979b41
129 changed files with 109 additions and 41982 deletions

View File

@ -29,6 +29,8 @@ public class DataStorageHandler {
private final String USER_TOOLS_LOCKED = "ToolsLocked";
private final String USER_PLAYER_SHAPE = "PlayerShape";
private final String TOOL_SHOP_TUTORIAL_FINISHED = "ToolShopTutorialFinished";
private final String SHOW_FPS = "ShowFps";
private final String PERFORMANCE_BOOST = "PerformanceBoost";
private SharedPreferences preferences;
private MyDatabase database;
@ -38,6 +40,26 @@ public class DataStorageHandler {
database = new MyDatabase(activity);
}
public boolean readIsShowFps() {
return preferences.getBoolean(SHOW_FPS, false);
}
public void writeShowFps(boolean showFps) {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(SHOW_FPS, showFps);
editor.apply();
}
public boolean readIsPerformanceBoost() {
return preferences.getBoolean(PERFORMANCE_BOOST, false);
}
public void writePerformanceBoost(boolean performanceBoost) {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(PERFORMANCE_BOOST, performanceBoost);
editor.apply();
}
public boolean readIsSoundsMuted() {
return preferences.getBoolean(SOUNDS_MUTED, false);
}

View File

@ -104,6 +104,9 @@ public class Game extends Rendering<GameScene> {
player = scene.getPlayer();
viewManager.resetViews(gameActivity.getUser());
setCurrentTool(viewManager.toolButtonBar.getActiveButton().getToolType(), true);
viewManager.setShowFps(gameActivity.getDataStorageHandler().readIsShowFps());
viewManager
.setBoostPerformance(gameActivity.getDataStorageHandler().readIsPerformanceBoost());
viewManager.startCountdown();
}
} catch (Exception e) {
@ -131,8 +134,7 @@ public class Game extends Rendering<GameScene> {
return;
float playerProgress = player.getProgress();
float playerSpeed = player.getMovement().getX();
viewManager.update(gameState == GameState.RUNNING, timer, playerProgress, playerSpeed);
viewManager.update(gameState == GameState.RUNNING, timer, playerProgress);
switch (gameState) {
case RUNNING:
if (player.getPosition().y < -2f) {
@ -204,6 +206,9 @@ public class Game extends Rendering<GameScene> {
public void continueGame() {
viewManager.hideShortMenu();
gameState = GameState.COUNTDOWN;
viewManager.setShowFps(gameActivity.getDataStorageHandler().readIsShowFps());
viewManager
.setBoostPerformance(gameActivity.getDataStorageHandler().readIsPerformanceBoost());
viewManager.startCountdown();
}
@ -220,8 +225,8 @@ public class Game extends Rendering<GameScene> {
handler.toScreen(Screen.ScreenType.LEVELS);
}
public void onToolButtonFinishedLoading(ToolType toolType){
if(currentTool == ToolType.BOMB && toolType == ToolType.BOMB)
public void onToolButtonFinishedLoading(ToolType toolType) {
if (currentTool == ToolType.BOMB && toolType == ToolType.BOMB)
scene.getBombSelected().set(true);
}

View File

@ -10,6 +10,7 @@ import android.widget.ToggleButton;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.main.GameLog;
import de.frajul.endlessroll.views.ConfirmDialog;
import de.frajul.endlessroll.views.CreditsDialog;
import de.frajul.endlessroll.views.TopBar;
@ -70,7 +71,9 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
musicToggle.setChecked(!gameActivity.getSoundManager().isMusicMuted());
soundToggle.setChecked(!gameActivity.getSoundManager().isSoundsMuted());
//TODO: set fps/performance checkboxes selected
fpsCheckbox.setChecked(gameActivity.getDataStorageHandler().readIsShowFps());
performanceCheckbox
.setChecked(gameActivity.getDataStorageHandler().readIsPerformanceBoost());
resetButton.setEnabled(super.caller != ScreenType.GAME);
}
@ -80,8 +83,8 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
.writeSoundsMuted(gameActivity.getSoundManager().isSoundsMuted());
gameActivity.getDataStorageHandler()
.writeMusicMuted(gameActivity.getSoundManager().isMusicMuted());
//TODO: write fps/performance
gameActivity.getDataStorageHandler().writeShowFps(fpsCheckbox.isChecked());
gameActivity.getDataStorageHandler().writePerformanceBoost(performanceCheckbox.isChecked());
flipToCaller();
}

View File

@ -72,9 +72,7 @@ public class ToolButton {
return gd;
}
public void update(float frameTime) {
boolean showAnimation = true;
//TODO: showAnimationBoolean
public void update(float frameTime, boolean showAnimation) {
if (progress != 100) {
progress += (frameTime) / (toolType
.getCurrentUpgradeValue(ToolUpgradeType.COOLDOWN) / 100);

View File

@ -66,9 +66,9 @@ public class ToolButtonBar implements View.OnClickListener{
button.setProgress(100);
}
public void update(float frameTime) {
public void update(float frameTime, boolean showAnimation) {
for (ToolButton button : buttons)
button.update(frameTime);
button.update(frameTime, showAnimation);
}
public void setActive(ToolType activeType) {

View File

@ -37,6 +37,9 @@ public class ViewManager implements View.OnClickListener {
public ShortMenu shortMenu;
private Countdown countdown;
private boolean showFps = false;
private boolean boostPerformance = false;
private List<BombErrorMessage> bombErrorMessages = new ArrayList<>();
private String fpsFormat, playerProgressFormat;
@ -83,7 +86,7 @@ public class ViewManager implements View.OnClickListener {
goalMessage.prepareToBeShown();
}
public void updateCountdown(float delta){
public void updateCountdown(float delta) {
countdown.update(delta);
}
@ -110,7 +113,7 @@ public class ViewManager implements View.OnClickListener {
@Override
public void run() {
toolButtonBar.reset(user.getToolSlotSettings());
toolButtonBar.update(0);
toolButtonBar.update(0, false);
playerProgress.setText(R.string.game_playerprogress_placeholder);
}
});
@ -155,14 +158,15 @@ public class ViewManager implements View.OnClickListener {
countdown.stop();
}
public void update(final boolean gameRunning, final Timer timer, final float playerX, final float playerXMov) {
public void update(final boolean gameRunning, final Timer timer, final float playerX) {
gameViewHandler.startInUiThread(new Runnable() {
@Override
public void run() {
fpsView.setText(String.format(fpsFormat, timer.getFps()));
if (showFps)
fpsView.setText(String.format(fpsFormat, timer.getFps()));
if (gameRunning) {
playerProgress.setText(String.format(playerProgressFormat, toMeters(playerX)));
toolButtonBar.update(timer.getFrameTimeSeconds());
toolButtonBar.update(timer.getFrameTimeSeconds(), !boostPerformance);
}
}
});
@ -176,4 +180,12 @@ public class ViewManager implements View.OnClickListener {
return shortMenu.isVisible();
}
public void setShowFps(final boolean showFps) {
fpsView.setVisibility(showFps ? View.VISIBLE : View.GONE);
this.showFps = showFps;
}
public void setBoostPerformance(boolean boostPerformance) {
this.boostPerformance = boostPerformance;
}
}