⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 community.java

📁 j2me编写的一个在线游戏
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        // Interpreted as an action, instead of an actual        //  view, like requests for Community.BACK.        // Like BACK, but potentially jumps back two views        // down the view stack instead of just one.  First        // BACK returns from the "Really exit?" or "Game        // Over" dialog to the maze game, second BACK returns        // from the maze game to whatever screen the user was        // on before they started.        else if (name.equals(MAZEEXIT)) {        	mazeRacer.gameOver( false);        	view = getView(BACK);        	// Only jump back two views if the view we were        	// on when a MAZEEXIT dialog popped up was the        	// MazeRacer game itself.  (This avoids edge-case        	// problems when we accidentally receive this event        	// after we've left the game view.)        	if (view==mazeRacer.getView()) {        		view = getView(BACK);        	}        }        // Username/Password screen (part of new account creation)        else if (name.equals(USER_PASS))            view = new UserPassView  ( this, USER_PASS);        // Email/Date-of-Birth screen (part of new account creation)        else if (name.equals(EMAIL_DOB))            view = new EmailDobView( this, EMAIL_DOB);        // Terms and conditions screen (part of new account creation)        else if (name.equals(TERMS)) {            TextBox textBox = new TextBox();            textBox.setText(  TermsView.TERMS_AND_CONDITIONS);            textBox.setBackground(0x00ffffff);            textBox.setForeground(0x00c0c0c0);            textBox.setFocusable(false);            textBox.setDimension(canvas.getWidth() - 10, 12 * textBox.getFont().getHeight() + TextBox.WIDTH_OFFSET);            view = new TermsView( this, TERMS, textBox);        }        // "Are you sure" logout dialog        else if (name.equals(LOGOUT)) {        	showDialog( "Log Out", "Are you sure you want to log out?",        			null, Community.REALLY_LOGOUT, Dialog.YES_NO        			);        }        // Action, instead of a View.  Logs the user out.        else if (name.equals(REALLY_LOGOUT)) {            view = null;            logout();        }        // "Are you sure" app exit dialog        else if (name.equals(EXIT)) {        	showDialog( "Exit", "Are you sure you want to exit?",        			null, Community.REALLY_EXIT, Dialog.YES_NO        			);        }        // Action, instead of a view.  Exits the MIDlet.        else if (name.equals(REALLY_EXIT)) {            view = null;            exit();        }        // Splash screen        else if (name.equals(SPLASH)) {            view = new SplashView(                this,                SPLASH,                null,                SPLASH_IMG,                WELCOME,                3000            );        }        // Message of the Day screen        if (name.equals(MOTD)) {        	view = motd = new TextView(                        this,                        MOTD,                        null,                        this,                        Community.HOME,                        Community.OK,                        null,                        Motd_txt,                        true                    );        }        // Offline main menu, which gives the option of going online,        // reading help/info, or playing single-player.        else if (name.equals(Community.WELCOME)) {            view = new ButtonListView(                this,                Community.WELCOME,                this,                null,                new String[] {Community.GO_ONLINE, Community.SINGLE_USER, Community.ABOUT, Community.HELP},                Community.SELECT,                Community.EXIT            );        }        // Online main menu (play, friends, rankings, help)        else if (name.equals(HOME)) {            view = new ButtonListView(                this,                HOME,                this,                buddyList,                new String[] {"play", "rankings", "friends", "help"},                Community.SELECT,                Community.LOGOUT            );        }        // Play menu (challenge or quick match)        else if (name.equals(PLAY)) {            view = new ButtonListView(                this,                PLAY,                this,                buddyList,                new String[] {"quick match", "challenge"},                Community.SELECT,                Community.BACK            );        }        // Waiting for quickmatch or challenge to complete, dialog        else if (name.equals(PENDING_GAMESTART)) {            view = new TextView(                this,                PENDING_GAMESTART,                buddyList,                this,                null,                null,                Community.CANCEL,                "Press 'cancel' to abort",                false            );        }        // Rankings menu (stats vs. my rankings)        else if (name.equals(RANKING)) {            view = new ButtonListView(                this,                RANKING,                this,                buddyList,                new String[] {Community.STATS, Community.MY_RANKINGS},                Community.SELECT,                Community.BACK            );        }        else if (name.equals(TOP_10)) {            SectionNavigator sn;            sn = new SectionNavigator(                SELECTED_SECTION,                new String[] {}            );            sn.setFont(LoginView.TEXTFIELD_FONT);            sn.setForeground(0x00c0c0c0);            view = new RankingView(                this,                TOP_10,                buddyList,                sn,                new String[] {"#", "Username", "Score"}            );        }        // Stats menu (lists game rankings categories)        else if (name.equals(STATS)) {            view = new ButtonListView(                this,                STATS,                this,                buddyList,                statList,                Community.SELECT,                Community.BACK            );        }        // My rankings view        else if (name.equals(MY_RANKINGS)) {            SectionNavigator sn;            sn = new SectionNavigator(                SELECTED_SECTION,                new String[] {}            );            sn.setFont(LoginView.TEXTFIELD_FONT);            sn.setForeground(0x00c0c0c0);            view = new RankingView(                this,                MY_RANKINGS,                buddyList,                sn,                new String[] {"Rnk", "Stat", "Score"}            );        }        // Main help menu        else if (name.equals(HELP)) {            view = new ButtonListView(                this,                Community.HELP,                this,                buddyList,                new String[] {"snap mobile", "game", "operator"},                Community.SELECT,                Community.BACK            );        }        // SNAP Mobile help screen        else if (name.equals(SM_HELP)) {            view = new TextView(                this,                SM_HELP,                buddyList,                this,                null,                null,                Community.BACK,                SM_Help_txt,                true            );        }        // Game help screen        else if (name.equals(GAME_HELP)) {            view = new TextView(                this,                GAME_HELP,                buddyList,                this,                null,                null,                Community.BACK,                Game_Help_txt,                true            );        }        // Operator help screen        else if (name.equals(OPERATOR_HELP)) {            view = new TextView(                this,                OPERATOR_HELP,                buddyList,                this,                null,                null,                Community.BACK,                Operator_Help_txt,                true            );        }        // About info screen        else if (name.equals(ABOUT)) {            view = new TextView(                this,                ABOUT,                null,                this,                null,                null,                Community.BACK,                About_txt,                true            );        }        // Login (and/or create new account) screen        else if (name.equals(LOGIN)) {            view = new LoginView(                this,                LOGIN,                this            );        }        // Chat screen        else if (name.equals(CHAT)) {            view = new Chat(                this,                CHAT,                buddyList            );        }        // Friends list screen        else if (name.equals(FRIENDS)) {            view = new BuddyView(                this,                FRIENDS,                buddyList                );        }        return view;    }    /**     * Tells GUI to instantiate (if necessary) and display a     * particular named view.  "back" and "exit" have special     * behavior (see <code>getView</code>).     *     * @param name Name of View to display     */    public void switchToView(String name) {//        System.out.println("Community.switchToView(), name = " + name);        switchToView(getView(name), !name.equals(BACK));    }    /**     * Tells GUI to instantiate (if necessary) and display a     * particular named view.  "back" and "exit" have special     * behavior (see <code>getView</code>).     *     * @param view View to display     * @param cache Caching flag; if <code>false</code>, current     *  view will not be preserved on the View stack (disabling     *  "back" behavior for that View)     */    public void switchToView(View view, boolean cache) {        View prev;        if (view == null) {//            System.out.println("NULL view !");            return;        }        prev = canvas.getView();        prev.setActive(false);        view.setActive(true);        canvas.setView(view);        if (cache) {            synchronized (viewList) {                // Removes loops in the "BACK" View stack. That is, looks back                // down the stack for the last entry of the view being added.                // If found, remove all Views above it in the stack.                while (viewList.contains( view)) {                    viewList.removeElementAt( viewList.size()-1);                }                viewList.addElement(view);            }        }    }    /**     * Searches for a particular named View in the View stack (cache).     *     * @param name Name of View to find     * @return Returns named View, if found     */    public View findView(String name) {        View view;        int i;        synchronized (viewList) {            for (i=viewList.size()-1; i>=0; i--) {                view = (View)viewList.elementAt(i);                if (name.equals(view.getName())) return view;            }        }        return null;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -