Files
SAE41_2022/app/src/main/java/com/example/mastermind/MainActivity.java

66 lines
2.2 KiB
Java
Raw Normal View History

2023-04-03 09:13:48 +02:00
package com.example.mastermind;
import android.app.Activity;
2023-04-03 12:38:17 +02:00
import android.content.Intent;
2023-04-03 09:13:48 +02:00
import android.os.Bundle;
2023-04-03 12:38:17 +02:00
import android.widget.Button;
import android.view.View;
2023-04-03 09:13:48 +02:00
public class MainActivity extends Activity {
2023-04-03 12:38:17 +02:00
private Button mHotSeat;
private Button mORDI;
private Button mSettings;
2023-04-07 16:12:04 +02:00
private Button mRules;
private boolean pionV;
2023-04-03 09:13:48 +02:00
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
2023-04-03 12:38:17 +02:00
mHotSeat = findViewById(R.id.HotSeat);
mORDI = findViewById(R.id.ORDI);
mSettings = findViewById(R.id.Settings);
2023-04-07 16:12:04 +02:00
mRules = findViewById(R.id.Rules);
2023-04-03 19:42:09 +02:00
mHotSeat.setOnClickListener(new View.OnClickListener() {
2023-04-03 12:38:17 +02:00
@Override
public void onClick(View v) {
2023-04-08 16:15:01 +02:00
Intent HotSeat = new Intent(MainActivity.this, GameActivity.class);
HotSeat.putExtra("bot", false);
2023-04-09 22:48:04 +02:00
HotSeat.putExtra("pionVide", pionV);
startActivity(HotSeat);
2023-04-03 12:38:17 +02:00
}
});
mORDI.setOnClickListener(new View.OnClickListener() {
2023-04-03 12:38:17 +02:00
@Override
public void onClick(View v) {
2023-04-08 16:15:01 +02:00
Intent ordi = new Intent(MainActivity.this, GameActivity.class);
ordi.putExtra("bot", true);
2023-04-09 22:48:04 +02:00
ordi.putExtra("pionVide", pionV);
startActivity(ordi);
2023-04-03 12:38:17 +02:00
}
});
2023-04-03 15:39:44 +02:00
mSettings.setOnClickListener(new View.OnClickListener() {
2023-04-03 12:38:17 +02:00
@Override
public void onClick(View v) {
Intent settings = new Intent(MainActivity.this, SettingsActivity.class);
2023-04-09 22:48:04 +02:00
startActivityForResult(settings, 2);
2023-04-03 12:38:17 +02:00
}
2023-04-03 15:39:44 +02:00
});
2023-04-07 16:12:04 +02:00
mRules.setOnClickListener(new View.OnClickListener() {
2023-04-03 12:38:17 +02:00
@Override
public void onClick(View v) {
2023-04-07 16:12:04 +02:00
Intent rules = new Intent(MainActivity.this, RulesActivity.class);
startActivity(rules);
2023-04-03 12:38:17 +02:00
}
2023-04-07 16:12:04 +02:00
});
2023-04-03 09:13:48 +02:00
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
2023-04-09 22:48:04 +02:00
if(requestCode == 2) {
pionV = data.getBooleanExtra("pionV", false);
}
}
2023-04-03 09:13:48 +02:00
}