Android Open Source - minecraft-connect-4 Main Menu






From Project

Back to project page minecraft-connect-4.

License

The source code is released under:

MIT License

If you think the Android project minecraft-connect-4 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

/* COPYRIGHT (C) 2014 Aleksandr Belkin. All Rights Reserved. */
package sq.squ1rr.mcc4;
/* w  w  w .  jav  a2  s  . c  om*/
import sq.squ1rr.mcc4.layout.LayoutManager;
import sq.squ1rr.mcc4.layout.LayoutManager.Theme;
import sq.squ1rr.mcc4.layout.McButton;
import sq.squ1rr.mcc4.MainMenuActivity.MenuId;
import android.view.View;
import android.view.View.OnClickListener;

/**
 * Main menu layout. Builds the layout and handles user interactions.
 * @author Aleksandr Belkin
 */
public class MainMenu extends MenuLayout {
    
    /** parent activity */
    private final MainMenuActivity activity;
    
    /*
     * Buttons
     */
    private McButton btnQuickGame = null;
    private McButton btnStartGame = null;
    private McButton btnStats = null;
    private McButton btnOptions = null;
    private McButton btnAbout = null;
    
    /**
     * Sets up theme
     */
    public MainMenu(MainMenuActivity _activity) {
        super(Theme.MAIN);
        activity = _activity;
    }
    
    /*
     * (non-Javadoc)
     * @see sq.squ1rr.mcc4.MenuLayout#build(sq.squ1rr.mcc4.layout.LayoutManager)
     */
    @Override
    public void build(LayoutManager layout) {        
        btnQuickGame = new McButton(activity);
            btnQuickGame.setOnClickListener(clickListener);
            btnQuickGame.setText(activity.getString(R.string.menu_quick_game));
            layout.add(btnQuickGame);
        
        btnStartGame = new McButton(activity);
            btnStartGame.setOnClickListener(clickListener);
            btnStartGame.setText(activity.getString(R.string.menu_start_game));
            btnStartGame.setEnabled(false);
            layout.add(btnStartGame);
            
        btnStats = new McButton(activity);
            btnStats.setOnClickListener(clickListener);
            btnStats.setText(activity.getString(R.string.menu_stats));
            layout.add(btnStats);
            
        btnOptions = new McButton(activity);
            btnOptions.setOnClickListener(clickListener);
            btnOptions.setText(activity.getString(R.string.menu_options));
            layout.add(btnOptions);
            
        btnAbout = new McButton(activity);
            btnAbout.setOnClickListener(clickListener);
            btnAbout.setText(activity.getString(R.string.menu_about));
            layout.add(btnAbout);
    }
    
    /**
     * Handles button clicks
     */
    private OnClickListener clickListener = new OnClickListener() {
        @Override
        public void onClick(View view) {
            if(view == btnQuickGame) {
                activity.showMenu(MenuId.QUICK_GAME);
            } else if(view == btnStats) {
                activity.showMenu(MenuId.STATS);
            } else if(view == btnOptions) {
                activity.showMenu(MenuId.OPTIONS);
            } else if(view == btnAbout) {
                activity.showMenu(MenuId.ABOUT);
            }
        }
    };
}




Java Source Code List

sq.squ1rr.mcc4.AboutMenu.java
sq.squ1rr.mcc4.BaseActivity.java
sq.squ1rr.mcc4.GameActivity.java
sq.squ1rr.mcc4.MainMenuActivity.java
sq.squ1rr.mcc4.MainMenu.java
sq.squ1rr.mcc4.MenuLayout.java
sq.squ1rr.mcc4.OptionsMenu.java
sq.squ1rr.mcc4.QuickGameMenu.java
sq.squ1rr.mcc4.StatsMenu.java
sq.squ1rr.mcc4.Stats.java
sq.squ1rr.mcc4.ai.Ai.java
sq.squ1rr.mcc4.ai.EasyAi.java
sq.squ1rr.mcc4.ai.HardAi.java
sq.squ1rr.mcc4.ai.NormalAi.java
sq.squ1rr.mcc4.ai.PeacefulAi.java
sq.squ1rr.mcc4.board.BoardDialogue.java
sq.squ1rr.mcc4.board.BoardLogic.java
sq.squ1rr.mcc4.board.BoardRenderer.java
sq.squ1rr.mcc4.board.BoardView.java
sq.squ1rr.mcc4.board.GameBoard.java
sq.squ1rr.mcc4.board.Texture.java
sq.squ1rr.mcc4.gl.Rectangle.java
sq.squ1rr.mcc4.gl.SpriteBatch.java
sq.squ1rr.mcc4.gl.SpriteString.java
sq.squ1rr.mcc4.gl.Sprite.java
sq.squ1rr.mcc4.layout.LayoutManager.java
sq.squ1rr.mcc4.layout.McButton.java
sq.squ1rr.mcc4.layout.McGroup.java
sq.squ1rr.mcc4.layout.McSelector.java
sq.squ1rr.mcc4.layout.McStyle.java
sq.squ1rr.mcc4.layout.McText.java
sq.squ1rr.mcc4.layout.McToggler.java
sq.squ1rr.mcc4.layout.McToken.java
sq.squ1rr.mcc4.rules.GameRules.java
sq.squ1rr.mcc4.rules.Player.java
sq.squ1rr.mcc4.rules.Rule.java
sq.squ1rr.mcc4.util.GlobalConstants.java