author | Medo <smaxein@googlemail.com> |
Sat, 18 Aug 2012 18:11:04 +0200 | |
changeset 7568 | 75ba91f14ed5 |
parent 7508 | 763d3961400b |
permissions | -rw-r--r-- |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1 |
package org.hedgewars.hedgeroid; |
7449 | 2 |
|
3 |
import org.hedgewars.hedgeroid.R; |
|
7485 | 4 |
import org.hedgewars.hedgeroid.Datastructures.Team; |
7568 | 5 |
import org.hedgewars.hedgeroid.Datastructures.TeamInGame; |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
6 |
import org.hedgewars.hedgeroid.NetplayStateFragment.NetplayStateListener; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
7 |
import org.hedgewars.hedgeroid.netplay.Netplay; |
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
8 |
import org.hedgewars.hedgeroid.netplay.Netplay.State; |
7449 | 9 |
|
10 |
import android.os.Bundle; |
|
11 |
import android.support.v4.app.FragmentActivity; |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
12 |
import android.support.v4.app.FragmentTransaction; |
7449 | 13 |
import android.widget.TabHost; |
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
14 |
import android.widget.Toast; |
7449 | 15 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
16 |
public class RoomActivity extends FragmentActivity implements NetplayStateListener, TeamAddDialog.Listener, RoomStateManager.Provider { |
7449 | 17 |
private TabHost tabHost; |
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
18 |
private Netplay netplay; |
7449 | 19 |
|
20 |
@Override |
|
21 |
protected void onCreate(Bundle icicle) { |
|
22 |
super.onCreate(icicle); |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
23 |
netplay = Netplay.getAppInstance(getApplicationContext()); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
24 |
|
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
25 |
setContentView(R.layout.activity_netroom); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
26 |
ChatFragment chatFragment = (ChatFragment)getSupportFragmentManager().findFragmentById(R.id.chatFragment); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
27 |
chatFragment.setInRoom(true); |
7449 | 28 |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
29 |
FragmentTransaction trans = getSupportFragmentManager().beginTransaction(); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
30 |
trans.add(new NetplayStateFragment(), "netplayFragment"); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
31 |
trans.commit(); |
7449 | 32 |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
33 |
/*tabHost = (TabHost)findViewById(android.R.id.tabhost); |
7449 | 34 |
if(tabHost != null) { |
35 |
tabHost.setup(); |
|
36 |
tabHost.getTabWidget().setOrientation(LinearLayout.VERTICAL); |
|
37 |
||
38 |
//tabHost.addTab(tabHost.newTabSpec("chat").setIndicator(createIndicatorView(tabHost, R.string.lobby_tab_chat, getResources().getDrawable(R.drawable.edit))).setContent(R.id.chatFragment)); |
|
39 |
//tabHost.addTab(tabHost.newTabSpec("players").setIndicator(createIndicatorView(tabHost, R.string.lobby_tab_players, getResources().getDrawable(R.drawable.human))).setContent(R.id.playerListFragment)); |
|
40 |
||
41 |
if (icicle != null) { |
|
42 |
tabHost.setCurrentTabByTag(icicle.getString("currentTab")); |
|
43 |
} |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
44 |
}*/ |
7449 | 45 |
} |
46 |
||
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
47 |
@Override |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
48 |
public void onBackPressed() { |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
49 |
netplay.sendLeaveRoom(null); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
50 |
} |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
51 |
|
7449 | 52 |
@Override |
53 |
protected void onSaveInstanceState(Bundle icicle) { |
|
54 |
super.onSaveInstanceState(icicle); |
|
55 |
if(tabHost != null) { |
|
56 |
icicle.putString("currentTab", tabHost.getCurrentTabTag()); |
|
57 |
} |
|
58 |
} |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
59 |
|
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
60 |
public void onNetplayStateChanged(State newState) { |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
61 |
switch(newState) { |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
62 |
case NOT_CONNECTED: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
63 |
case CONNECTING: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
64 |
case LOBBY: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
65 |
finish(); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
66 |
break; |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
67 |
case ROOM: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
68 |
// Do nothing |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
69 |
break; |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
70 |
case INGAME: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
71 |
//startActivity(new Intent(getApplicationContext(), RoomActivity.class)); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
72 |
Toast.makeText(getApplicationContext(), R.string.not_implemented_yet, Toast.LENGTH_SHORT).show(); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
73 |
break; |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
74 |
default: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
75 |
throw new IllegalStateException("Unknown connection state: "+newState); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
76 |
} |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
77 |
} |
7485 | 78 |
|
79 |
public void onTeamAddDialogSubmitted(Team newTeam) { |
|
7568 | 80 |
netplay.sendAddTeam(newTeam, TeamInGame.getUnusedOrRandomColorIndex(netplay.roomTeamlist.getMap().values())); |
7485 | 81 |
} |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
82 |
|
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
83 |
public RoomStateManager getRoomStateManager() { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
84 |
return netplay.getRoomStateManager(); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
85 |
} |
7449 | 86 |
} |