23 import java.io.IOException; |
23 import java.io.IOException; |
24 |
24 |
25 import org.hedgewars.hedgeroid.Downloader.DownloadAssets; |
25 import org.hedgewars.hedgeroid.Downloader.DownloadAssets; |
26 import org.hedgewars.hedgeroid.Downloader.DownloadListActivity; |
26 import org.hedgewars.hedgeroid.Downloader.DownloadListActivity; |
27 import org.hedgewars.hedgeroid.frontlib.Flib; |
27 import org.hedgewars.hedgeroid.frontlib.Flib; |
28 import org.hedgewars.hedgeroid.netplay.LobbyActivity; |
|
29 import org.hedgewars.hedgeroid.netplay.Netplay; |
28 import org.hedgewars.hedgeroid.netplay.Netplay; |
30 import org.hedgewars.hedgeroid.netplay.Netplay.State; |
29 import org.hedgewars.hedgeroid.netplay.Netplay.State; |
|
30 import org.hedgewars.hedgeroid.util.FileUtils; |
31 |
31 |
32 import android.app.AlertDialog; |
32 import android.app.AlertDialog; |
33 import android.app.Dialog; |
33 import android.app.Dialog; |
34 import android.app.ProgressDialog; |
34 import android.app.ProgressDialog; |
35 import android.content.BroadcastReceiver; |
35 import android.content.BroadcastReceiver; |
63 Button startNetGame = (Button)findViewById(R.id.joinLobby); |
63 Button startNetGame = (Button)findViewById(R.id.joinLobby); |
64 |
64 |
65 startLocalGame.setOnClickListener(startGameListener); |
65 startLocalGame.setOnClickListener(startGameListener); |
66 startNetGame.setOnClickListener(startNetGameListener); |
66 startNetGame.setOnClickListener(startNetGameListener); |
67 |
67 |
68 if(!Utils.isDataPathAvailable()){ |
68 if(!FileUtils.isDataPathAvailable()){ |
69 showDialog(DIALOG_NO_SDCARD); |
69 showDialog(DIALOG_NO_SDCARD); |
70 } else { |
70 } else { |
71 String existingVersion = ""; |
71 String existingVersion = ""; |
72 try { |
72 try { |
73 File versionFile = new File(Utils.getCachePath(this), "assetsversion.txt"); |
73 File versionFile = new File(FileUtils.getCachePath(this), "assetsversion.txt"); |
74 existingVersion = Utils.readToString(new FileInputStream(versionFile)); |
74 existingVersion = FileUtils.readToString(new FileInputStream(versionFile)); |
75 } catch(IOException e) { |
75 } catch(IOException e) { |
76 } |
76 } |
77 |
77 |
78 String newVersion = ""; |
78 String newVersion = ""; |
79 try { |
79 try { |
80 newVersion = Utils.readToString(getAssets().open("assetsversion.txt")); |
80 newVersion = FileUtils.readToString(getAssets().open("assetsversion.txt")); |
81 } catch(IOException e) { |
81 } catch(IOException e) { |
82 } |
82 } |
83 |
83 |
84 if(!existingVersion.equals(newVersion)) { |
84 if(!existingVersion.equals(newVersion)) { |
85 DownloadAssets assetsAsyncTask = new DownloadAssets(this); |
85 DownloadAssets assetsAsyncTask = new DownloadAssets(this); |
123 startActivityForResult(new Intent(getApplicationContext(), DownloadListActivity.class), 0); |
123 startActivityForResult(new Intent(getApplicationContext(), DownloadListActivity.class), 0); |
124 return true; |
124 return true; |
125 case R.id.preferences: |
125 case R.id.preferences: |
126 Toast.makeText(this, R.string.not_implemented_yet, Toast.LENGTH_SHORT).show(); |
126 Toast.makeText(this, R.string.not_implemented_yet, Toast.LENGTH_SHORT).show(); |
127 return true; |
127 return true; |
|
128 case R.id.edit_weaponsets: |
|
129 startActivity(new Intent(getApplicationContext(), WeaponsetListActivity.class)); |
|
130 return true; |
128 default: |
131 default: |
129 return super.onOptionsItemSelected(item); |
132 return super.onOptionsItemSelected(item); |
130 } |
133 } |
131 } |
|
132 |
|
133 @Override |
|
134 protected void onStart() { |
|
135 super.onStart(); |
|
136 Netplay.getAppInstance(getApplicationContext()).requestFastTicks(); |
|
137 } |
|
138 |
|
139 @Override |
|
140 protected void onStop() { |
|
141 super.onStop(); |
|
142 Netplay.getAppInstance(getApplicationContext()).unrequestFastTicks(); |
|
143 } |
134 } |
144 |
135 |
145 public Dialog onCreateDialog(int id, Bundle args){ |
136 public Dialog onCreateDialog(int id, Bundle args){ |
146 switch(id) { |
137 switch(id) { |
147 case DIALOG_NO_SDCARD: |
138 case DIALOG_NO_SDCARD: |