Shapes can now be recieved through fulfilling tasks

This commit is contained in:
=
2017-10-30 16:54:05 +01:00
parent c9e718f6ad
commit 44d7665442
24 changed files with 694 additions and 312 deletions

View File

@ -1,6 +1,5 @@
package de.frajul.endlessroll.views;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -29,25 +28,29 @@ public class PlayerShapeButton implements View.OnClickListener {
private Button button;
private Animation rotation;
public PlayerShapeButton(GameActivity gameActivity, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener, boolean marginToRight) {
private boolean locked;
public PlayerShapeButton(GameActivity gameActivity, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener, boolean locked, boolean marginToRight) {
this.clickListener = clickListener;
this.playerShape = playerShape;
this.locked = locked;
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());
textView.setText(locked ? R.string.playershape_name_locked : playerShape.getNameId());
button = (Button) view.findViewById(R.id.shape_button_button);
button.setBackgroundDrawable(gameActivity.getResources().getDrawable(playerShape.getDrawableId()));
button.setBackgroundDrawable(
gameActivity.getResources().getDrawable(locked ? R.drawable.playershapes_locked : playerShape.getDrawableId()));
button.setOnClickListener(this);
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);
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;
}
@ -68,6 +71,10 @@ public class PlayerShapeButton implements View.OnClickListener {
return view;
}
public boolean isLocked() {
return locked;
}
public PlayerShape getPlayerShape() {
return playerShape;
}

View File

@ -0,0 +1,54 @@
package de.frajul.endlessroll.views;
import android.graphics.Typeface;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.shapes.EmptyTask;
import de.frajul.endlessroll.entities.shapes.PlayerShape;
import de.frajul.endlessroll.entities.shapes.Task;
import de.frajul.endlessroll.main.GameActivity;
/**
* Created by Julian on 03.06.2017.
*/
public class ShapeInspector {
private GameActivity gameActivity;
private TextView title;
private ImageView imageView;
private TextView description;
private ShapeInspectorCheckbox checkbox;
private PlayerShape shape;
private boolean locked;
public ShapeInspector(GameActivity gameActivity, View layout) {
this.gameActivity = gameActivity;
Typeface typeface = gameActivity.getTypeface();
title = (TextView) layout.findViewById(R.id.shape_inspector_title);
title.setTypeface(typeface);
imageView = (ImageView) layout.findViewById(R.id.shape_inspector_imageview);
description = (TextView) layout.findViewById(R.id.shape_inspector_description);
description.setTypeface(typeface);
checkbox = new ShapeInspectorCheckbox(gameActivity, typeface,
layout.findViewById(R.id.shape_inspector_check_box));
}
public void update(PlayerShape shape, boolean locked) {
this.shape = shape;
this.locked = locked;
title.setText(locked ? R.string.playershape_name_locked : shape.getNameId());
imageView.setImageDrawable(gameActivity.getResources()
.getDrawable(locked ? R.drawable.playershapes_locked : shape.getDrawableId()));
description.setText(
locked ? R.string.playershape_description_locked : shape.getDescriptionId());
checkbox.updateForTask(shape.getUnlockTask());
}
}

View File

@ -0,0 +1,50 @@
package de.frajul.endlessroll.views;
import android.graphics.Typeface;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.shapes.EmptyTask;
import de.frajul.endlessroll.entities.shapes.Task;
import de.frajul.endlessroll.main.GameActivity;
/**
* Created by Julian on 30.10.2017.
*/
public class ShapeInspectorCheckbox {
private GameActivity gameActivity;
private View layout;
private ImageView image;
private TextView textView;
public ShapeInspectorCheckbox(GameActivity gameActivity, Typeface typeface, View layout) {
this.gameActivity = gameActivity;
this.layout = layout;
image = (ImageView) layout.findViewById(R.id.shape_inspector_check_box_image);
textView = (TextView) layout.findViewById(R.id.shape_inspector_check_box_text);
textView.setTypeface(typeface);
}
public void updateForTask(Task task) {
boolean taskNotEmpty = !(task instanceof EmptyTask);
setVisible(taskNotEmpty);
if (taskNotEmpty) {
textView.setText(task.toString(gameActivity, gameActivity.getLevelManager()));
setChecked(task.isConditionFulfilled());
}
}
private void setChecked(boolean checked) {
int drawableId = checked ? R.drawable.guis_checkbox_checked : R.drawable.guis_checkbox_unchecked;
image.setBackgroundDrawable(gameActivity.getResources().getDrawable(drawableId));
}
private void setVisible(boolean visible) {
layout.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}
}