implementation du boutton handicape
This commit is contained in:
@@ -2,6 +2,7 @@ package com.iutlaval.myapplication.Game;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
@@ -93,10 +94,21 @@ public class GameLogicThread extends Thread{
|
||||
Bitmap bitmapEnemyTurn = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_enemy_turn);
|
||||
Bitmap bitmapBattlePhase = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_battlephase);
|
||||
Bitmap bitmapButtonEnd = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_btn_boutonfintour);
|
||||
Bitmap bitmapBackground = BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_b_board_background);
|
||||
Bitmap bitmapVictory = BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_pb_victory);
|
||||
Bitmap bitmapDefeat = BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_pb_defeat);
|
||||
|
||||
SharedPreferences sharedPref = gameActivity.getSharedPreferences("handicape",Context.MODE_PRIVATE);
|
||||
boolean modeHandicape = sharedPref.getBoolean(gameActivity.getString(R.string.handicape), false);
|
||||
|
||||
Bitmap bitmapBackground;
|
||||
if(!modeHandicape)
|
||||
{
|
||||
bitmapBackground = BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_b_board_background);
|
||||
}else{
|
||||
bitmapBackground = BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_b_board_background_handicapted);
|
||||
|
||||
}
|
||||
|
||||
//adding the background
|
||||
renderer.addToDraw(new DrawableBitmap(bitmapBackground, 0,0, "background", 100, 100 ));
|
||||
//drawHandPreview();
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.iutlaval.myapplication;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
@@ -11,6 +14,7 @@ import androidx.fragment.app.DialogFragment;
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private Context context;
|
||||
private boolean disabledMode;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -32,6 +36,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
final ImageButton handicapeButton = (ImageButton) findViewById(R.id.handicapeButton);
|
||||
handicapeButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
handicapeButtonHandle(handicapeButton);
|
||||
}
|
||||
});
|
||||
|
||||
disabledMode=true;
|
||||
handicapeButtonHandle(handicapeButton);
|
||||
}
|
||||
|
||||
private void pickDeckGame() {
|
||||
@@ -44,6 +57,22 @@ public class MainActivity extends AppCompatActivity {
|
||||
d.show(getSupportFragmentManager(),"s");
|
||||
}
|
||||
|
||||
private void handicapeButtonHandle(ImageButton handicapeButton)
|
||||
{
|
||||
if(!disabledMode)
|
||||
{
|
||||
handicapeButton.setImageBitmap(BitmapFactory.decodeResource(getResources(),R.drawable.t_h_handicape));
|
||||
}else{
|
||||
handicapeButton.setImageBitmap(BitmapFactory.decodeResource(getResources(),R.drawable.t_h_handicape_greyed));
|
||||
}
|
||||
disabledMode = ! disabledMode;
|
||||
|
||||
SharedPreferences sharedPref = this.getSharedPreferences("handicape",Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
editor.putBoolean(getString(R.string.handicape), disabledMode);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -65,13 +65,19 @@
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imageButton"
|
||||
android:id="@+id/handicapeButton"
|
||||
android:layout_width="87dp"
|
||||
android:layout_height="84dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/deficients_moteurs"
|
||||
tools:layout_editor_absoluteX="299dp"
|
||||
tools:layout_editor_absoluteY="631dp" />
|
||||
android:src="@drawable/t_h_handicape_greyed"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.92"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView2"
|
||||
app:layout_constraintVertical_bias="0.95" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -3,4 +3,5 @@
|
||||
<string name="title_item_list">Items</string>
|
||||
<string name="title_item_detail">Item Detail</string>
|
||||
<string name="pickdeck">Choisissez votre deck</string>
|
||||
<string name="handicape">false</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user