project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/NetRoomActivity.java
author koda
Tue, 15 Oct 2013 01:15:39 +0200
changeset 9543 1826b5315369
parent 7586 33924ff4af50
child 10017 de822cd3df3a
permissions -rw-r--r--
Fix bug #656 by using the right resolution values
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7584
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
     1
/*
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
     2
 * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
     3
 * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
     4
 *
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
     5
 * This program is free software; you can redistribute it and/or
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
     6
 * modify it under the terms of the GNU General Public License
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
     7
 * as published by the Free Software Foundation; either version 2
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
     8
 * of the License, or (at your option) any later version.
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
     9
 *
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    13
 * GNU General Public License for more details.
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    14
 *
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    15
 * You should have received a copy of the GNU General Public License
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    16
 * along with this program; if not, write to the Free Software
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    18
 */
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    19
7508
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    20
package org.hedgewars.hedgeroid;
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    21
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    22
import org.hedgewars.hedgeroid.R;
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    23
import org.hedgewars.hedgeroid.Datastructures.GameConfig;
7485
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents: 7476
diff changeset
    24
import org.hedgewars.hedgeroid.Datastructures.Team;
7568
75ba91f14ed5 Hedgeroid:
Medo <smaxein@googlemail.com>
parents: 7508
diff changeset
    25
import org.hedgewars.hedgeroid.Datastructures.TeamInGame;
7508
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    26
import org.hedgewars.hedgeroid.NetplayStateFragment.NetplayStateListener;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    27
import org.hedgewars.hedgeroid.netplay.Netplay;
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    28
import org.hedgewars.hedgeroid.netplay.RunGameListener;
7461
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    29
import org.hedgewars.hedgeroid.netplay.Netplay.State;
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    30
import org.hedgewars.hedgeroid.util.UiUtils;
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    31
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    32
import android.content.Intent;
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    33
import android.os.Bundle;
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    34
import android.support.v4.app.FragmentActivity;
7461
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    35
import android.support.v4.app.FragmentTransaction;
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    36
import android.view.View;
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    37
import android.view.View.OnClickListener;
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    38
import android.widget.Button;
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    39
import android.widget.LinearLayout;
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    40
import android.widget.TabHost;
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    41
7584
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    42
/**
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    43
 * This activity is used to set up and start a game on the server.
7831c84cc644 License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents: 7582
diff changeset
    44
 */
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    45
public class NetRoomActivity extends FragmentActivity implements NetplayStateListener, TeamAddDialog.Listener, RoomStateManager.Provider, RunGameListener {
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    46
	private TabHost tabHost;
7461
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    47
	private Netplay netplay;
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    48
	private RoomStateManager stateManager;
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    49
	private Button startButton;
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    50
	
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    51
    @Override
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    52
    protected void onCreate(Bundle icicle) {
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    53
        super.onCreate(icicle);
7461
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    54
        netplay = Netplay.getAppInstance(getApplicationContext());
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    55
        netplay.registerRunGameListener(this);
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    56
        stateManager = netplay.getRoomStateManager();
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    57
        stateManager.addListener(roomStateChangeListener);
7461
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    58
        
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    59
        setContentView(R.layout.activity_netroom);
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    60
        startButton = (Button)findViewById(R.id.startGame);
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    61
        
7461
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    62
        ChatFragment chatFragment = (ChatFragment)getSupportFragmentManager().findFragmentById(R.id.chatFragment);
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    63
        chatFragment.setInRoom(true);
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    64
        
7461
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    65
        FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    66
        trans.add(new NetplayStateFragment(), "netplayFragment");
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    67
        trans.commit();
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    68
        
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    69
        startButton.setVisibility(netplay.isChief() ? View.VISIBLE : View.GONE);
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    70
        startButton.setOnClickListener(startButtonClickListener);
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    71
        
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    72
        // Set up a tabbed UI for medium and small screens
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    73
        tabHost = (TabHost)findViewById(android.R.id.tabhost);
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    74
        if(tabHost != null) {
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    75
	        tabHost.setup();
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    76
	        tabHost.getTabWidget().setOrientation(LinearLayout.VERTICAL);
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    77
7586
33924ff4af50 Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents: 7584
diff changeset
    78
	        tabHost.addTab(tabHost.newTabSpec("map").setIndicator(UiUtils.createVerticalTabIndicator(tabHost, R.string.room_tab_map, 0)).setContent(R.id.mapFragment));
33924ff4af50 Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents: 7584
diff changeset
    79
	        tabHost.addTab(tabHost.newTabSpec("settings").setIndicator(UiUtils.createVerticalTabIndicator(tabHost, R.string.room_tab_settings, 0)).setContent(R.id.settingsFragment));
33924ff4af50 Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents: 7584
diff changeset
    80
	        tabHost.addTab(tabHost.newTabSpec("teams").setIndicator(UiUtils.createVerticalTabIndicator(tabHost, R.string.room_tab_teams, 0)).setContent(R.id.teamlistFragment));
33924ff4af50 Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents: 7584
diff changeset
    81
	        tabHost.addTab(tabHost.newTabSpec("chat").setIndicator(UiUtils.createVerticalTabIndicator(tabHost, R.string.room_tab_chat, 0)).setContent(R.id.chatFragment));
33924ff4af50 Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents: 7584
diff changeset
    82
	        tabHost.addTab(tabHost.newTabSpec("players").setIndicator(UiUtils.createVerticalTabIndicator(tabHost, R.string.room_tab_players, 0)).setContent(R.id.playerListContainer));
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    83
	        
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    84
	        if (icicle != null) {
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    85
	            tabHost.setCurrentTabByTag(icicle.getString("currentTab"));
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    86
	        }
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    87
        }
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    88
    }
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
    89
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    90
    @Override
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    91
    protected void onDestroy() {
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    92
    	super.onDestroy();
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    93
    	stateManager.removeListener(roomStateChangeListener);
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    94
    	netplay.unregisterRunGameListener(this);
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    95
    }
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
    96
    
7461
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    97
	@Override
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    98
	public void onBackPressed() {
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
    99
		netplay.sendLeaveRoom(null);
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   100
	}
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   101
    
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
   102
    @Override
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
   103
    protected void onSaveInstanceState(Bundle icicle) {
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
   104
        super.onSaveInstanceState(icicle);
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
   105
        if(tabHost != null) {
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
   106
        	icicle.putString("currentTab", tabHost.getCurrentTabTag());
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
   107
        }
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
   108
    }
7461
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   109
    
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   110
    public void onNetplayStateChanged(State newState) {
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   111
    	switch(newState) {
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   112
    	case NOT_CONNECTED:
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   113
    	case CONNECTING:
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   114
    	case LOBBY:
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   115
    		finish();
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   116
    		break;
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   117
    	case ROOM:
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   118
    		// Do nothing
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   119
    		break;
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   120
		default:
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   121
			throw new IllegalStateException("Unknown connection state: "+newState);
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   122
    	}
38acbfdb484f Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents: 7449
diff changeset
   123
    }
7485
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents: 7476
diff changeset
   124
    
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents: 7476
diff changeset
   125
	public void onTeamAddDialogSubmitted(Team newTeam) {
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   126
		stateManager.requestAddTeam(newTeam, TeamInGame.getUnusedOrRandomColorIndex(stateManager.getTeams().values()));
7485
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents: 7476
diff changeset
   127
	}
7508
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
   128
	
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
   129
	public RoomStateManager getRoomStateManager() {
7582
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   130
		return stateManager;
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   131
	}
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   132
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   133
	private final OnClickListener startButtonClickListener = new OnClickListener() {
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   134
		public void onClick(View v) {
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   135
			netplay.sendStartGame();
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   136
		}
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   137
	};
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   138
	
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   139
	private final RoomStateManager.Listener roomStateChangeListener = new RoomStateManager.ListenerAdapter() {
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   140
		@Override
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   141
		public void onChiefStatusChanged(boolean isChief) {
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   142
			startButton.setVisibility(isChief ? View.VISIBLE : View.GONE);
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   143
		}
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   144
	};
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   145
	
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   146
	public void runGame(GameConfig config) {
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   147
		SDLActivity.startConfig = config;
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   148
		SDLActivity.startNetgame = true;
714310efad8f Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents: 7568
diff changeset
   149
		startActivity(new Intent(this, SDLActivity.class));
7508
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
   150
	}
7449
2e63537b44f3 Hedgeroid: Room screen WIP
Medo <smaxein@googlemail.com>
parents:
diff changeset
   151
}