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.PlayerShape;
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());
    }
}
