|
@@ -30,49 +30,33 @@ import app.brest.utils.app.brest.game.Game;
|
|
import app.brest.utils.app.brest.game.Resource;
|
|
import app.brest.utils.app.brest.game.Resource;
|
|
import app.brest.utils.app.brest.game.Stage;
|
|
import app.brest.utils.app.brest.game.Stage;
|
|
|
|
|
|
-public class NewMenuActivity extends Activity implements View.OnClickListener{
|
|
|
|
|
|
+public abstract class MenuActivity extends Activity implements View.OnClickListener{
|
|
|
|
|
|
- private int mWidth;
|
|
|
|
- private int mHeight;
|
|
|
|
|
|
+ protected int mWidth;
|
|
|
|
+ protected int mHeight;
|
|
protected Game mGame;
|
|
protected Game mGame;
|
|
|
|
|
|
- private RelativeLayout mRootLayout;
|
|
|
|
- private Handler mCustomHandler = new Handler();
|
|
|
|
|
|
+ protected RelativeLayout mRootLayout;
|
|
|
|
+ protected Handler mCustomHandler = new Handler();
|
|
//private final int COLOR_BACKGROUND = ;
|
|
//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 int mHOffset=0;
|
|
|
|
-
|
|
|
|
- private void setUpStyle()
|
|
|
|
- {
|
|
|
|
- mRootLayout.setBackgroundResource(R.drawable.background);
|
|
|
|
- int h4 = mHeight/3;
|
|
|
|
- int w4 = mWidth/3;
|
|
|
|
- int w = (int)(w4*1.25);
|
|
|
|
- int h = dpToPx((int)(mBBriefing.getTextSize()*1.5));
|
|
|
|
-
|
|
|
|
- moveView(mBBriefing, w4-2*w/3, mHOffset+h4-h,w,h);
|
|
|
|
- moveView(mBInvotory, 2*w4-w/3, mHOffset+h4-h,w,h);
|
|
|
|
- moveView(mBMap, w4-2*w/3, mHOffset+2*h4,w,h);
|
|
|
|
- moveView(mBOptions, 2*w4-w/3, mHOffset+2*h4,w,h);
|
|
|
|
- moveView(mBSend, mWidth/2-w, mHOffset+2*h4+4*h/3, 2*w, h);
|
|
|
|
- mBMenu.setTextSize(25);
|
|
|
|
- //mBMenu.setTypeface(null,Typeface.BOLD);
|
|
|
|
- sendVisibility();
|
|
|
|
|
|
+ protected final int COLOR_SHAPE = R.color.dull_2;
|
|
|
|
+ protected final int COLOR_BACKGROUND_SECOND = R.color.dull_3;
|
|
|
|
+ protected final int COLOR_OTHER = R.color.dull_4;
|
|
|
|
+ protected final int COLOR_TEXT = R.color.dull_5;
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ protected Button mIbScanner;
|
|
|
|
+ protected Button mBBriefing;
|
|
|
|
+ protected Button mBInvotory;
|
|
|
|
+ protected Button mBMap;
|
|
|
|
+ protected Button mBOptions;
|
|
|
|
+ protected View mBMenu;
|
|
|
|
+ protected Button mBSend;
|
|
|
|
+ protected int mHOffset=0;
|
|
|
|
|
|
|
|
|
|
|
|
+ protected void refreshMenuStyle(){}
|
|
|
|
+
|
|
|
|
+ protected void setUpMenuStyle(){}
|
|
|
|
|
|
private void updateSize()
|
|
private void updateSize()
|
|
{
|
|
{
|
|
@@ -122,85 +106,33 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
- setContentView(R.layout.activity_new_menu);
|
|
|
|
- mRootLayout = (RelativeLayout) findViewById(R.id.menu_root);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- Game g = Game.load(this);
|
|
|
|
- System.out.println( (g != null) + " == " + (mGame == null) );
|
|
|
|
- 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();
|
|
|
|
- Settings.setSettings(mGame.getmSettings());
|
|
|
|
-
|
|
|
|
- mIbScanner = new Button(this);
|
|
|
|
- //mIbScanner.setImageResource(R.drawable.scanner);
|
|
|
|
- //mIbScanner.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
|
|
|
- mRootLayout.addView(mIbScanner);
|
|
|
|
- mIbScanner.setBackgroundResource(R.drawable.uibuttoncircle);
|
|
|
|
- mIbScanner.setText("Scanner");
|
|
|
|
- mIbScanner.setTextColor(getResources().getColor(R.color.dull_4));
|
|
|
|
- mIbScanner.setTextSize(22);
|
|
|
|
- mIbScanner.setOnClickListener(this);
|
|
|
|
-
|
|
|
|
- moveView(mIbScanner, mWidth / 2 - mHeight / 8, mHOffset + mHeight / 2 - mHeight / 8, mHeight / 4, mHeight / 4);
|
|
|
|
-
|
|
|
|
- mBBriefing = newButton("Briefing");
|
|
|
|
- mBInvotory = newButton("Inventaire");
|
|
|
|
- mBMap = newButton("Carte");
|
|
|
|
- mBOptions = newButton("Options");
|
|
|
|
- mBMenu = newButton("Menu Principal");
|
|
|
|
- mBMenu.setBackgroundResource(R.drawable.title);
|
|
|
|
- mBSend = newButton("Envoyer les données");
|
|
|
|
- Resources r = getResources();
|
|
|
|
- float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, r.getDisplayMetrics());
|
|
|
|
- moveView(mBMenu, 0, 0, mWidth, (int) px);
|
|
|
|
- //mBSend = newButton("Envoyer");
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- setUpStyle();
|
|
|
|
- mCustomHandler.postDelayed(updateTimerThread, 10);
|
|
|
|
-
|
|
|
|
-/*
|
|
|
|
- mGame.pickResource("aa");
|
|
|
|
- mGame.pickResource("ab");
|
|
|
|
- mGame.pickResource("ac");
|
|
|
|
- mGame.pickResource("ad");
|
|
|
|
- mGame.pickResource("ae");
|
|
|
|
- mGame.pickResource("ag");
|
|
|
|
- mGame.pickResource("ah");
|
|
|
|
- mGame.pickResource("ai");
|
|
|
|
- mGame.nextStage();
|
|
|
|
- mGame.pickResource("ba");
|
|
|
|
- mGame.pickResource("bb");
|
|
|
|
- mGame.pickResource("bc");
|
|
|
|
- mGame.pickResource("bd");
|
|
|
|
- mGame.pickResource("be");
|
|
|
|
- mGame.pickResource("bf");
|
|
|
|
- mGame.pickResource("bg");
|
|
|
|
- mGame.pickResource("bh");
|
|
|
|
- mGame.nextStage();
|
|
|
|
- mGame.pickResource("ca");
|
|
|
|
- mGame.pickResource("cb");
|
|
|
|
- mGame.pickResource("cc");
|
|
|
|
- mGame.pickResource("cd");
|
|
|
|
- mGame.pickResource("ce");
|
|
|
|
- mGame.pickResource("cf");
|
|
|
|
- mGame.pickResource("cg");
|
|
|
|
- FontChangeCrawler.setFont(this);
|
|
|
|
-*/
|
|
|
|
|
|
+ setContentView(R.layout.activity_new_menu);
|
|
|
|
+ mRootLayout = (RelativeLayout) findViewById(R.id.menu_root);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Game g = Game.load(this);
|
|
|
|
+ System.out.println( (g != null) + " == " + (mGame == null) );
|
|
|
|
+ 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();
|
|
|
|
+ Settings.setSettings(mGame.getmSettings());
|
|
|
|
+
|
|
|
|
+ setUpMenuStyle();
|
|
|
|
+ refreshMenuStyle();
|
|
|
|
+
|
|
|
|
+ mCustomHandler.postDelayed(updateTimerThread, 10);
|
|
FontChangeCrawler.setFont(this);
|
|
FontChangeCrawler.setFont(this);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -292,10 +224,10 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
|
|
{
|
|
{
|
|
super.onResume();
|
|
super.onResume();
|
|
mGame = Game.game();
|
|
mGame = Game.game();
|
|
- setUpStyle();
|
|
|
|
|
|
+ refreshMenuStyle();
|
|
}
|
|
}
|
|
|
|
|
|
- private void sendVisibility()
|
|
|
|
|
|
+ protected void sendVisibility()
|
|
{
|
|
{
|
|
if(mGame.canSendData()) mBSend.setVisibility(View.VISIBLE);
|
|
if(mGame.canSendData()) mBSend.setVisibility(View.VISIBLE);
|
|
else mBSend.setVisibility(View.INVISIBLE);
|
|
else mBSend.setVisibility(View.INVISIBLE);
|
|
@@ -321,4 +253,5 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|