Android Open Source - Gloomy-Dungeons-3D Menu Activity






From Project

Back to project page Gloomy-Dungeons-3D.

License

The source code is released under:

MIT License

If you think the Android project Gloomy-Dungeons-3D listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package zame.game;
/*from   w  w w. ja v a  2 s.c o  m*/
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import zame.game.engine.Game;
import zame.game.views.MenuView;

public class MenuActivity extends Activity
{
  public static boolean justLoaded = false;  // or just saved, or just new game started
  public static MenuActivity self;

  private boolean justAfterPause = false;
  private boolean soundAlreadyStopped = false; // fix multi-activity issues
  private Dialog dialogToShow = null;

  public boolean instantMusicPause = true;
  public MenuView.Data menuViewData = new MenuView.Data();

  @Override
  protected void onCreate(Bundle state)
  {
    super.onCreate(state);
    self = this;

    SoundManager.init(getApplicationContext(), getAssets(), true);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    Game.initPaths(getApplicationContext());
    setContentView(R.layout.menu);

    MenuView.onActivityCreate(this);
    ZameApplication.trackPageView("/menu");
  }

  @Override
  public void onWindowFocusChanged(boolean hasFocus)
  {
    super.onWindowFocusChanged(hasFocus);

    if (hasFocus) {
      // moved from onResume, because onResume called even when app is not visible, but lock screen is visible
      if (!justAfterPause) {
        SoundManager.setPlaylist(SoundManager.LIST_MAIN);
        SoundManager.onStart();
        soundAlreadyStopped = false;
      }
    } else {
      // moved from onPause, because onPause is not called when task manager is on screen
      if (!soundAlreadyStopped) {
        SoundManager.onPause(instantMusicPause);
        soundAlreadyStopped = true;
      }

      instantMusicPause = true;
    }
  }

  @Override
  protected void onResume()
  {
    super.onResume();
    justAfterPause = false;
  }

  @Override
  public void onPause()
  {
    super.onPause();
    justAfterPause = true;

    if (!soundAlreadyStopped) {
      SoundManager.onPause(instantMusicPause);
      soundAlreadyStopped = true;
    }

    instantMusicPause = true;
  }

  @Override
  protected void onDestroy()
  {
    super.onDestroy();
    self = null;
  }

  @Override
  public void onBackPressed()
  {
    if (MenuActivityHelper.onBackPressed(this)) {
      super.onBackPressed();
    }
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu)
  {
    super.onCreateOptionsMenu(menu);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item)
  {
    switch (item.getItemId())
    {
      case R.id.menu_options:
        startActivity(new Intent(MenuActivity.this, GamePreferencesActivity.class));
        return true;
    }

    return MenuView.onOptionsItemSelected(this, item);
  }

  @SuppressWarnings("deprecation")
  @Override
  protected Dialog onCreateDialog(int id)
  {
    return MenuView.onCreateDialog(this, id);
  }
}




Java Source Code List

zame.game.AppConfig.java
zame.game.AppConfig.java
zame.game.Common.java
zame.game.ConfigZeemote.java
zame.game.ConfigZeemote.java
zame.game.Config.java
zame.game.GameActivityZeemoteHelper.java
zame.game.GameActivityZeemoteHelper.java
zame.game.GameActivity.java
zame.game.GamePreferencesActivity.java
zame.game.GamePreferencesActivity.java
zame.game.MenuActivityHelper.java
zame.game.MenuActivityHelper.java
zame.game.MenuActivity.java
zame.game.Renderer.java
zame.game.SoundManager.java
zame.game.ZameApplicationAnalyticsHelper.java
zame.game.ZameApplicationAnalyticsHelper.java
zame.game.ZameApplication.java
zame.game.ZameGame.java
zame.game.ZameJniRenderer.java
zame.game.engine.Action.java
zame.game.engine.AutoWall.java
zame.game.engine.Controls.java
zame.game.engine.Door.java
zame.game.engine.GameHelper.java
zame.game.engine.GameHelper.java
zame.game.engine.Game.java
zame.game.engine.Labels.java
zame.game.engine.LevelConfig.java
zame.game.engine.LevelRenderer.java
zame.game.engine.Level.java
zame.game.engine.Mark.java
zame.game.engine.Monster.java
zame.game.engine.Overlay.java
zame.game.engine.PortalTracer.java
zame.game.engine.State.java
zame.game.engine.Stats.java
zame.game.engine.TextureLoader.java
zame.game.engine.Weapons.java
zame.game.views.EndLevelView.java
zame.game.views.GameOverView.java
zame.game.views.GameView.java
zame.game.views.IZameView.java
zame.game.views.MenuViewHelper.java
zame.game.views.MenuViewHelper.java
zame.game.views.MenuView.java
zame.game.views.PreLevelView.java
zame.game.views.ZameGameView.java
zame.libs.FrameLayout.java
zame.libs.GLSurfaceView21.java
zame.libs.Grid.java
zame.libs.KeyMapPreference.java
zame.libs.LabelMaker.java
zame.libs.ListPreference.java
zame.libs.NumericSprite.java
zame.libs.SeekBarPreference.java
zame.promo.PromoView.java