Current shape is now saved
This commit is contained in:
@ -12,11 +12,13 @@ import de.frajul.endlessroll.entities.textures.TexturePack;
|
||||
*/
|
||||
|
||||
public enum PlayerShape {
|
||||
BALL(R.string.playershape_name_ball, R.drawable.playershapes_ball), CLOCK(R.string.playershape_name_clock,
|
||||
R.drawable.playershapes_clock), HYPNO_SPIRAL(R.string.playershape_name_hypno_spiral,
|
||||
R.drawable.playershapes_hypno_spiral), PACMAN(R.string.playershape_name_pacman,
|
||||
R.drawable.playershapes_pacman), SMILEY(R.string.playershape_name_smiley,
|
||||
R.drawable.playershapes_smiley);
|
||||
BALL(R.string.playershape_name_ball, R.drawable.playershapes_ball),
|
||||
CLOCK(R.string.playershape_name_clock, R.drawable.playershapes_clock),
|
||||
HYPNO_SPIRAL(R.string.playershape_name_hypno_spiral, R.drawable.playershapes_hypno_spiral),
|
||||
PACMAN(R.string.playershape_name_pacman, R.drawable.playershapes_pacman),
|
||||
SMILEY(R.string.playershape_name_smiley, R.drawable.playershapes_smiley),
|
||||
WHEEL(R.string.playershape_name_wheel, R.drawable.playershapes_wheel),
|
||||
SUN(R.string.playershape_name_sun, R.drawable.playershapes_sun);
|
||||
|
||||
@StringRes
|
||||
private int nameId;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.frajul.endlessroll.main.screens;
|
||||
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TableRow;
|
||||
|
||||
import de.frajul.endlessroll.R;
|
||||
@ -18,14 +19,14 @@ public class PlayerShapeShopScreen extends Screen<LinearLayout> implements Playe
|
||||
private PlayerShapeButton activeButton;
|
||||
|
||||
private TopBar topBar;
|
||||
private TableRow topRow;
|
||||
private TableRow bottomRow;
|
||||
private LinearLayout topRow;
|
||||
private LinearLayout bottomRow;
|
||||
|
||||
public PlayerShapeShopScreen(GameActivity gameActivity) {
|
||||
super(ScreenType.SHAPE_SHOP, gameActivity, R.layout.shape_shop);
|
||||
topBar = super.createTopBar(R.id.shape_shop_topbar);
|
||||
topRow = (TableRow) layout.findViewById(R.id.shape_shop_topRow);
|
||||
bottomRow = (TableRow) layout.findViewById(R.id.shape_shop_bottomRow);
|
||||
topRow = (LinearLayout) layout.findViewById(R.id.shape_shop_topRow);
|
||||
bottomRow = (LinearLayout) layout.findViewById(R.id.shape_shop_bottomRow);
|
||||
}
|
||||
|
||||
private void createViews() {
|
||||
@ -34,8 +35,10 @@ public class PlayerShapeShopScreen extends Screen<LinearLayout> implements Playe
|
||||
int i = 0;
|
||||
int totalShapes = PlayerShape.values().length;
|
||||
for (PlayerShape playerShape : PlayerShape.values()) {
|
||||
PlayerShapeButton button = new PlayerShapeButton(gameActivity, playerShape, this);
|
||||
if (i < totalShapes / 2)
|
||||
boolean lastInRow = i == totalShapes / 2 || i == totalShapes - 1;
|
||||
PlayerShapeButton button = new PlayerShapeButton(gameActivity, playerShape, this,
|
||||
!lastInRow);
|
||||
if (i < totalShapes / 2 + 1)
|
||||
topRow.addView(button.getView());
|
||||
else
|
||||
bottomRow.addView(button.getView());
|
||||
@ -57,6 +60,7 @@ public class PlayerShapeShopScreen extends Screen<LinearLayout> implements Playe
|
||||
|
||||
@Override
|
||||
public void onBackKeyDown() {
|
||||
gameActivity.getDataStorageHandler().writeUserData(gameActivity.getUser());
|
||||
flipToCaller();
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,19 @@
|
||||
package de.frajul.endlessroll.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.frajul.endlessroll.R;
|
||||
import de.frajul.endlessroll.entities.shapes.PlayerShape;
|
||||
import de.frajul.endlessroll.entities.shapes.PlayerShapeButtonOnClickListener;
|
||||
import de.frajul.endlessroll.main.GameLog;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
|
||||
/**
|
||||
* Created by Julian on 22.10.2017.
|
||||
@ -28,16 +29,26 @@ public class PlayerShapeButton implements View.OnClickListener {
|
||||
private Button button;
|
||||
private Animation rotation;
|
||||
|
||||
public PlayerShapeButton(Context context, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener) {
|
||||
public PlayerShapeButton(GameActivity gameActivity, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener, boolean marginToRight) {
|
||||
this.clickListener = clickListener;
|
||||
this.playerShape = playerShape;
|
||||
view = LayoutInflater.from(context).inflate(R.layout.shape_button, null);
|
||||
view = LayoutInflater.from(gameActivity).inflate(R.layout.shape_button, null);
|
||||
view.setLayoutParams(createLayoutParams(marginToRight));
|
||||
textView = (TextView) view.findViewById(R.id.shape_button_textview);
|
||||
textView.setTypeface(gameActivity.getTypeface());
|
||||
textView.setText(playerShape.getNameId());
|
||||
button = (Button) view.findViewById(R.id.shape_button_button);
|
||||
button.setBackgroundDrawable(context.getResources().getDrawable(playerShape.getDrawableId()));
|
||||
button.setBackgroundDrawable(gameActivity.getResources().getDrawable(playerShape.getDrawableId()));
|
||||
button.setOnClickListener(this);
|
||||
rotation = AnimationUtils.loadAnimation(context, R.anim.shape_button_rotation);
|
||||
rotation = AnimationUtils.loadAnimation(gameActivity, R.anim.shape_button_rotation);
|
||||
}
|
||||
|
||||
private LinearLayout.LayoutParams createLayoutParams(boolean marginToRight){
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
if(marginToRight)
|
||||
params.setMargins(0, 0, 60, 0);
|
||||
return params;
|
||||
}
|
||||
|
||||
public void startRotating() {
|
||||
|
Reference in New Issue
Block a user