|
@@ -0,0 +1,262 @@
|
|
|
+package app.brest.testmin3d;
|
|
|
+
|
|
|
+import android.animation.ObjectAnimator;
|
|
|
+import android.app.Activity;
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.Point;
|
|
|
+import android.graphics.Typeface;
|
|
|
+import android.graphics.drawable.Drawable;
|
|
|
+import android.os.Handler;
|
|
|
+import android.support.v7.app.AppCompatActivity;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.text.Layout;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.Display;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.ImageButton;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+import android.widget.Toast;
|
|
|
+
|
|
|
+import app.brest.app.brest.ui.RotateButton;
|
|
|
+import app.brest.utils.app.brest.game.Game;
|
|
|
+import app.brest.utils.app.brest.game.Resource;
|
|
|
+import app.brest.utils.app.brest.game.Stage;
|
|
|
+
|
|
|
+public class NewMenuActivity extends Activity implements View.OnClickListener{
|
|
|
+
|
|
|
+ private int mWidth;
|
|
|
+ private int mHeight;
|
|
|
+ protected Game mGame;
|
|
|
+
|
|
|
+ private RelativeLayout mRootLayout;
|
|
|
+ private Handler mCustomHandler = new Handler();
|
|
|
+ //private final int COLOR_BACKGROUND = ;
|
|
|
+ private final int COLOR_SHAPE = R.color.dull_2;
|
|
|
+ private final int COLOR_BACKGROUND_SECOND = R.color.dull_3;
|
|
|
+ private final int COLOR_OTHER = R.color.dull_4;
|
|
|
+ private final int COLOR_TEXT = R.color.dull_5;
|
|
|
+
|
|
|
+ private Button mIbScanner;
|
|
|
+ private Button mBBriefing;
|
|
|
+ private Button mBInvotory;
|
|
|
+ private Button mBMap;
|
|
|
+ private Button mBOptions;
|
|
|
+ private Button mBMenu;
|
|
|
+ private Button mBSend;
|
|
|
+
|
|
|
+
|
|
|
+ private void setUpStyle()
|
|
|
+ {
|
|
|
+ mRootLayout.setBackgroundResource(R.drawable.background);
|
|
|
+ int h4 = mHeight/3;
|
|
|
+ int w4 = mWidth/3;
|
|
|
+ int w = (int)(w4*1.25);
|
|
|
+ int h = 80;
|
|
|
+ moveView(mBBriefing, w4-2*w/3, h4-h,w,h);
|
|
|
+ moveView(mBInvotory, 2*w4-w/3, h4-h,w,h);
|
|
|
+ moveView(mBMap, w4-2*w/3, 2*h4,w,h);
|
|
|
+ moveView(mBOptions, 2*w4-w/3, 2*h4,w,h);
|
|
|
+ moveView(mBSend, 0, mHeight-100, mWidth, 100);
|
|
|
+ mBMenu.setTextSize(28);
|
|
|
+ mBMenu.setTypeface(null,Typeface.BOLD);
|
|
|
+ sendVisibility();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateSize()
|
|
|
+ {
|
|
|
+ Display display = getWindowManager().getDefaultDisplay();
|
|
|
+ Point size = new Point();
|
|
|
+ display.getSize(size);
|
|
|
+ mWidth = size.x;
|
|
|
+ mHeight = size.y;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void moveView(View v, int x, int y, int w, int h)
|
|
|
+ {
|
|
|
+ RelativeLayout.LayoutParams l = new RelativeLayout.LayoutParams(w, h);
|
|
|
+ l.leftMargin = x;
|
|
|
+ l.topMargin = y;
|
|
|
+ v.setLayoutParams(l);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void moveView(View v, int x, int y)
|
|
|
+ {
|
|
|
+
|
|
|
+ moveView(v, x, y, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ protected Button newButton(String text, float angle)
|
|
|
+ {
|
|
|
+ Button b = new RotateButton(this,angle);
|
|
|
+ b.setText(text);
|
|
|
+ mRootLayout.addView(b);
|
|
|
+ b.setBackgroundResource(R.drawable.button);
|
|
|
+ b.setTextColor(getResources().getColor(R.color.dull_4));
|
|
|
+ b.setTextSize(22);
|
|
|
+ b.setOnClickListener(this);
|
|
|
+ return b;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected Button newButton(String text)
|
|
|
+ {
|
|
|
+ return newButton(text, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_new_menu);
|
|
|
+ mRootLayout = (RelativeLayout)findViewById(R.id.menu_root);
|
|
|
+
|
|
|
+ Game g = null;//Game.load(this);
|
|
|
+
|
|
|
+ if (g!= null && mGame==null) {
|
|
|
+ mGame = g;
|
|
|
+ Game.setGame(mGame);
|
|
|
+ mGame.newSensorManager(this);
|
|
|
+ Toast.makeText(this, "Chargement", Toast.LENGTH_LONG).show();
|
|
|
+ }
|
|
|
+ else if( mGame==null)
|
|
|
+ {
|
|
|
+ mGame = new Game("game_medium", this);
|
|
|
+ Game.setGame(mGame);
|
|
|
+ Toast.makeText(this, "Nouveau Jeu", Toast.LENGTH_LONG).show();
|
|
|
+ }else if( mGame==null)
|
|
|
+ {
|
|
|
+ Toast.makeText(this, "Erreur", Toast.LENGTH_LONG).show();
|
|
|
+ throw new Error("Le jeu n'est pas sauvegardé");
|
|
|
+ }
|
|
|
+ updateSize();
|
|
|
+
|
|
|
+ mIbScanner = new Button(this);
|
|
|
+ //mIbScanner.setImageResource(R.drawable.scanner);
|
|
|
+ //mIbScanner.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
|
|
+ mRootLayout.addView(mIbScanner);
|
|
|
+ mIbScanner.setBackgroundResource(R.drawable.bscanner);
|
|
|
+ mIbScanner.setText("Scanner");
|
|
|
+ mIbScanner.setTextColor(getResources().getColor(R.color.dull_4));
|
|
|
+ mIbScanner.setTextSize(22);
|
|
|
+ mIbScanner.setOnClickListener(this);
|
|
|
+
|
|
|
+ moveView(mIbScanner, mWidth/2-mHeight/8, mHeight/2-mHeight/8, mHeight/4, mHeight/4);
|
|
|
+
|
|
|
+ mBBriefing = newButton("Briefing");
|
|
|
+ mBInvotory = newButton("Inventaire");
|
|
|
+ mBMap = newButton("Carte");
|
|
|
+ mBOptions = newButton("Options");
|
|
|
+ mBMenu = newButton("Menu Principal");
|
|
|
+
|
|
|
+ mBSend = newButton("Envoyer les données");
|
|
|
+ moveView(mBMenu, 0, 0, mWidth, mHeight/8);
|
|
|
+ //mBSend = newButton("Envoyer");
|
|
|
+
|
|
|
+
|
|
|
+ setUpStyle();
|
|
|
+ mCustomHandler.postDelayed(updateTimerThread, 10);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void onOptionsClick(View v)
|
|
|
+ {
|
|
|
+ Intent intent = new Intent(this, SettingsActivity.class);
|
|
|
+ intent.putExtra("game", mGame);
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void onCarteClick(View v)
|
|
|
+ {
|
|
|
+ Intent intent = new Intent(this, ViewerActivity.class);
|
|
|
+ intent.putExtra("map", mGame.getName()+"_map");
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void onScannerClick(View v)
|
|
|
+ {
|
|
|
+ Intent intent = new Intent(this, ARActivity.class);
|
|
|
+ intent.putExtra("game", mGame);
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void onInventaireClick(View v)
|
|
|
+ {
|
|
|
+ Intent intent = new Intent(this, ResourceListActivity.class);
|
|
|
+ intent.putExtra("game", mGame);
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void onInfoClick(View v) {
|
|
|
+ Intent intent = new Intent(this, ViewerActivity.class);
|
|
|
+ Stage s = mGame.getCurrentStageObj();
|
|
|
+ Resource r = (s!=null)?s.getResource(): null;
|
|
|
+ intent.putExtra("resource", r );
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void onSendClick(View v)
|
|
|
+ {
|
|
|
+ //TODO : Transmssion des donnes
|
|
|
+ boolean finished = mGame.nextStage();
|
|
|
+
|
|
|
+ Stage s = mGame.getCurrentStageObj();
|
|
|
+ Resource stageRes = s.getResource();
|
|
|
+
|
|
|
+ if(finished)
|
|
|
+ {
|
|
|
+ Log.e("--____", "Here");
|
|
|
+ Intent intent2 = new Intent(this, EndActivity.class);
|
|
|
+ startActivity(intent2);
|
|
|
+ }
|
|
|
+
|
|
|
+ Intent intent = new Intent(this, ViewerActivity.class);
|
|
|
+ intent.putExtra("resource", stageRes );
|
|
|
+ startActivity(intent);
|
|
|
+
|
|
|
+
|
|
|
+ Intent intent2 = new Intent(this, TransferActivity.class);
|
|
|
+ startActivity(intent2);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ if(view == mBBriefing) onInfoClick(view);
|
|
|
+ else if(view == mIbScanner) onScannerClick(view);
|
|
|
+ else if(view == mBMap) onCarteClick(view);
|
|
|
+ else if(view == mBSend) onSendClick(view);
|
|
|
+ else if(view == mBInvotory) onInventaireClick(view);
|
|
|
+ else if(view == mBOptions) onOptionsClick(view);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void onResume()
|
|
|
+ {
|
|
|
+ super.onResume();
|
|
|
+ setUpStyle();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendVisibility()
|
|
|
+ {
|
|
|
+ if(mGame.canSendData()) mBSend.setVisibility(View.VISIBLE);
|
|
|
+ else mBSend.setVisibility(View.INVISIBLE);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Runnable updateTimerThread = new Runnable() {
|
|
|
+
|
|
|
+ public void run() {
|
|
|
+
|
|
|
+ mCustomHandler.postDelayed(this, 10);
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+}
|