project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/StartGameActivity.java
author Xeli
Sun, 21 Aug 2011 18:14:49 +0200
branchhedgeroid
changeset 5625 9add7b92c5f0
parent 5621 ea796c83ea47
child 5627 ce2d92589cbc
permissions -rw-r--r--
Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5621
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
     1
/*
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
     2
 * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
     3
 * Copyright (c) 2011 Richard Deurwaarder <xeli@xelification.com>
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
     4
 *
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
     8
 *
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    12
 * GNU General Public License for more details.
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    13
 *
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    14
 * You should have received a copy of the GNU General Public License
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    15
 * along with this program; if not, write to the Free Software
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    17
 */
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    18
ea796c83ea47 added licenses
Xeli
parents: 5607
diff changeset
    19
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    20
package org.hedgewars.mobile;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    21
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    22
import org.hedgewars.mobile.EngineProtocol.FrontendDataUtils;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    23
import org.hedgewars.mobile.EngineProtocol.GameConfig;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    24
import org.hedgewars.mobile.EngineProtocol.Map;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    25
import org.hedgewars.mobile.EngineProtocol.Scheme;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    26
import org.hedgewars.mobile.EngineProtocol.Team;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    27
import org.hedgewars.mobile.EngineProtocol.Weapon;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    28
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    29
import android.app.Activity;
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    30
import android.content.Intent;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    31
import android.graphics.drawable.Drawable;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    32
import android.os.Bundle;
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    33
import android.os.Parcelable;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    34
import android.view.View;
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    35
import android.view.View.OnClickListener;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    36
import android.widget.AdapterView;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    37
import android.widget.AdapterView.OnItemSelectedListener;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    38
import android.widget.ArrayAdapter;
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    39
import android.widget.ImageButton;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    40
import android.widget.ImageView;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    41
import android.widget.Spinner;
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    42
import android.widget.Toast;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    43
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    44
public class StartGameActivity extends Activity {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    45
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    46
	public static final int ACTIVITY_TEAM_SELECTOR = 0;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    47
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    48
	private GameConfig config = null;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    49
	private ImageButton start, back, team;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    50
	private Spinner maps, gameplay, gamescheme, weapons, themes;
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    51
	private ImageView themeIcon, mapPreview;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    52
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    53
	public void onCreate(Bundle savedInstanceState){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    54
		super.onCreate(savedInstanceState);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    55
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    56
		//SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    57
		//Copy all the xml files to the device TODO only do first time launch of the app...
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    58
		Utils.resRawToFilesDir(this,R.array.schemes, Scheme.DIRECTORY_SCHEME);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    59
		Utils.resRawToFilesDir(this, R.array.weapons, Weapon.DIRECTORY_WEAPON);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    60
		Scheme.parseBasicFlags(this);
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    61
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    62
		config = new GameConfig();
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    63
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    64
		setContentView(R.layout.starting_game);
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    65
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    66
		back = (ImageButton) findViewById(R.id.btnBack);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    67
		team = (ImageButton) findViewById(R.id.btnTeams);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    68
		start = (ImageButton) findViewById(R.id.btnStart);
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    69
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    70
		maps = (Spinner) findViewById(R.id.spinMaps);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    71
		gameplay = (Spinner) findViewById(R.id.spinGameplay);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    72
		gamescheme = (Spinner) findViewById(R.id.spinGamescheme);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    73
		weapons = (Spinner) findViewById(R.id.spinweapons);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    74
		themes = (Spinner) findViewById(R.id.spinTheme);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    75
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    76
		themeIcon = (ImageView) findViewById(R.id.imgTheme);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    77
		mapPreview = (ImageView) findViewById(R.id.mapPreview);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    78
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    79
		start.setOnClickListener(startClicker);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    80
		back.setOnClickListener(backClicker);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    81
		team.setOnClickListener(teamClicker);
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    82
5607
d3a3e80ad1da Added several graphics
Xeli
parents: 5471
diff changeset
    83
		ArrayAdapter<?> adapter = new ArrayAdapter<Map>(this, R.layout.listview_item, FrontendDataUtils.getMaps(this));
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    84
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    85
		maps.setAdapter(adapter);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    86
		maps.setOnItemSelectedListener(mapsClicker);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    87
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    88
		adapter = new ArrayAdapter<String>(this, R.layout.listview_item, FrontendDataUtils.getGameplay(this));
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    89
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    90
		gameplay.setAdapter(adapter);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    91
		gameplay.setOnItemSelectedListener(gameplayClicker);
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    92
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    93
		adapter = new ArrayAdapter<Scheme>(this, R.layout.listview_item, FrontendDataUtils.getSchemes(this));
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    94
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    95
		gamescheme.setAdapter(adapter);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    96
		gamescheme.setOnItemSelectedListener(schemeClicker);
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    97
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    98
		adapter = new ArrayAdapter<Weapon>(this, R.layout.listview_item, FrontendDataUtils.getWeapons(this));
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    99
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   100
		weapons.setAdapter(adapter);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   101
		weapons.setOnItemSelectedListener(weaponClicker);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   102
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   103
		adapter = new ArrayAdapter<String>(this, R.layout.listview_item, FrontendDataUtils.getThemes(this));
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   104
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   105
		themes.setAdapter(adapter);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   106
		themes.setOnItemSelectedListener(themesClicker);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   107
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   108
	}
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   109
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   110
	private void startTeamsActivity(){
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   111
		Intent i = new Intent(StartGameActivity.this, TeamSelectionActivity.class);
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   112
		i.putParcelableArrayListExtra("teams", config.teams);
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   113
		startActivityForResult(i, ACTIVITY_TEAM_SELECTOR);
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   114
	}
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   115
	
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   116
	public void onActivityResult(int requestCode, int resultCode, Intent data){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   117
		switch(requestCode){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   118
		case ACTIVITY_TEAM_SELECTOR:
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   119
			if(resultCode == Activity.RESULT_OK){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   120
				Parcelable[] parcelables = (Parcelable[])data.getParcelableArrayExtra("teams");
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   121
				config.teams.clear();
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   122
				for(Parcelable t : parcelables){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   123
					config.teams.add((Team)t);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   124
				}
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   125
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   126
			}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   127
			break;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   128
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   129
	}
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   130
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   131
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   132
	private OnItemSelectedListener themesClicker = new OnItemSelectedListener(){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   133
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   134
		public void onItemSelected(AdapterView<?> arg0, View view, int position, long rowId) {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   135
			String themeName = (String) arg0.getAdapter().getItem(position);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   136
			Drawable themeIconDrawable = Drawable.createFromPath(Utils.getDownloadPath(StartGameActivity.this) + "Themes/" + themeName + "/icon@2X.png");
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   137
			themeIcon.setImageDrawable(themeIconDrawable);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   138
			config.theme = themeName;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   139
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   140
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   141
		public void onNothingSelected(AdapterView<?> arg0) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   142
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   143
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   144
	};
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   145
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   146
	private OnItemSelectedListener mapsClicker = new OnItemSelectedListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   147
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   148
		public void onItemSelected(AdapterView<?> arg0, View view, int position,long rowId) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   149
			Map map = (Map)arg0.getAdapter().getItem(position);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   150
			mapPreview.setImageDrawable(map.getDrawable());
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   151
			config.map = map;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   152
		}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   153
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   154
		public void onNothingSelected(AdapterView<?> arg0) {
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   155
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   156
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   157
	};
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   158
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   159
	private OnItemSelectedListener weaponClicker = new OnItemSelectedListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   160
		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   161
			config.weapon = (Weapon)arg0.getAdapter().getItem(arg2);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   162
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   163
		public void onNothingSelected(AdapterView<?> arg0) {
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   164
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   165
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   166
	};
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   167
	private OnItemSelectedListener schemeClicker = new OnItemSelectedListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   168
		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   169
			config.scheme = (Scheme)arg0.getAdapter().getItem(arg2);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   170
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   171
		public void onNothingSelected(AdapterView<?> arg0) {
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   172
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   173
		}
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   174
	};
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   175
	private OnItemSelectedListener gameplayClicker = new OnItemSelectedListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   176
		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   177
			//config = ()arg0.getAdapter().getItem(arg2);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   178
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   179
		public void onNothingSelected(AdapterView<?> arg0) {
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   180
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   181
		}
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   182
	};
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   183
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   184
	private OnClickListener startClicker = new OnClickListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   185
		public void onClick(View v) {
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   186
			if(config.teams.size() < 2){
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   187
				Toast.makeText(StartGameActivity.this, R.string.not_enough_teams, Toast.LENGTH_LONG).show();
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   188
				startTeamsActivity();
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   189
			}
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   190
			else{
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   191
				Intent i = new Intent(StartGameActivity.this, SDLActivity.class);
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   192
				i.putExtra("config", config);
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   193
				startActivity(i);}
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   194
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   195
	};
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   196
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   197
	private OnClickListener backClicker = new OnClickListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   198
		public void onClick(View v) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   199
			finish();
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   200
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   201
	};
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   202
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   203
	private OnClickListener teamClicker = new OnClickListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   204
		public void onClick(View v) {
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   205
			startTeamsActivity();
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   206
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   207
	};
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   208
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   209
}