package com.helldivers.app;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;

/**
 * Main Activity - Menu principal con tematica Helldivers 2
 * Optimizado para Samsung Galaxy S3 (720x1280 xhdpi, landscape)
 */
public class MainActivity extends AppCompatActivity {

    private SoundManager soundManager;
    private Button btnQrInstagram;
    private Button btnMinijuego;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Inicializar SoundManager
        soundManager = new SoundManager(this);

        // Referencias UI
        btnQrInstagram = findViewById(R.id.btn_qr_instagram);
        btnMinijuego = findViewById(R.id.btn_minijuego);

        if (btnQrInstagram == null || btnMinijuego == null) {
            throw new RuntimeException("Button not found in layout");
        }

        // Configurar listeners
        btnQrInstagram.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                soundManager.playButtonClick();
                Intent intent = new Intent(MainActivity.this, ActivityQR.class);
                startActivity(intent);
            }
        });

        btnMinijuego.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                soundManager.playButtonClick();
                Intent intent = new Intent(MainActivity.this, ActivityGame.class);
                startActivity(intent);
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (soundManager != null) {
            soundManager.resume();
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (soundManager != null) {
            soundManager.pause();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (soundManager != null) {
            soundManager.release();
        }
    }
}