project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/StartGameActivity.java
author Xeli
Sun, 21 Aug 2011 19:40:01 +0200
branchhedgeroid
changeset 5627 ce2d92589cbc
parent 5625 9add7b92c5f0
permissions -rw-r--r--
Added a visual imageview to show how many teams have been selected, plus feedback when creating a new team:
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;
5627
ce2d92589cbc Added a visual imageview to show how many teams have been selected, plus feedback when creating a new team:
Xeli
parents: 5625
diff changeset
    51
	private ImageView themeIcon, mapPreview, teamCount;
5471
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);
5627
ce2d92589cbc Added a visual imageview to show how many teams have been selected, plus feedback when creating a new team:
Xeli
parents: 5625
diff changeset
    78
		teamCount = (ImageView) findViewById(R.id.imgTeamsCount);
ce2d92589cbc Added a visual imageview to show how many teams have been selected, plus feedback when creating a new team:
Xeli
parents: 5625
diff changeset
    79
		
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    80
		start.setOnClickListener(startClicker);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    81
		back.setOnClickListener(backClicker);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    82
		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
    83
5607
d3a3e80ad1da Added several graphics
Xeli
parents: 5471
diff changeset
    84
		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
    85
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    86
		maps.setAdapter(adapter);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    87
		maps.setOnItemSelectedListener(mapsClicker);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    88
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    89
		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
    90
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    91
		gameplay.setAdapter(adapter);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    92
		gameplay.setOnItemSelectedListener(gameplayClicker);
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    93
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    94
		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
    95
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    96
		gamescheme.setAdapter(adapter);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    97
		gamescheme.setOnItemSelectedListener(schemeClicker);
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    98
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
    99
		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
   100
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   101
		weapons.setAdapter(adapter);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   102
		weapons.setOnItemSelectedListener(weaponClicker);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   103
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   104
		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
   105
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   106
		themes.setAdapter(adapter);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   107
		themes.setOnItemSelectedListener(themesClicker);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   108
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   109
	}
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   110
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
   111
	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
   112
		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
   113
		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
   114
		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
   115
	}
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
   116
	
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   117
	public void onActivityResult(int requestCode, int resultCode, Intent data){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   118
		switch(requestCode){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   119
		case ACTIVITY_TEAM_SELECTOR:
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   120
			if(resultCode == Activity.RESULT_OK){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   121
				Parcelable[] parcelables = (Parcelable[])data.getParcelableArrayExtra("teams");
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   122
				config.teams.clear();
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   123
				for(Parcelable t : parcelables){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   124
					config.teams.add((Team)t);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   125
				}
5627
ce2d92589cbc Added a visual imageview to show how many teams have been selected, plus feedback when creating a new team:
Xeli
parents: 5625
diff changeset
   126
                teamCount.getDrawable().setLevel(config.teams.size());
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   127
			}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   128
			break;
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   129
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   130
	}
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
   131
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
   132
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   133
	private OnItemSelectedListener themesClicker = new OnItemSelectedListener(){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   134
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   135
		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
   136
			String themeName = (String) arg0.getAdapter().getItem(position);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   137
			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
   138
			themeIcon.setImageDrawable(themeIconDrawable);
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   139
			config.theme = themeName;
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
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   142
		public void onNothingSelected(AdapterView<?> arg0) {
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
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   147
	private OnItemSelectedListener mapsClicker = new OnItemSelectedListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   148
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   149
		public void onItemSelected(AdapterView<?> arg0, View view, int position,long rowId) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   150
			Map map = (Map)arg0.getAdapter().getItem(position);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   151
			mapPreview.setImageDrawable(map.getDrawable());
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   152
			config.map = map;
5433
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
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   155
		public void onNothingSelected(AdapterView<?> arg0) {
5471
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
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   158
	};
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
   159
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   160
	private OnItemSelectedListener weaponClicker = new OnItemSelectedListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   161
		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   162
			config.weapon = (Weapon)arg0.getAdapter().getItem(arg2);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   163
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   164
		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
   165
5471
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
	};
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   168
	private OnItemSelectedListener schemeClicker = new OnItemSelectedListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   169
		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   170
			config.scheme = (Scheme)arg0.getAdapter().getItem(arg2);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   171
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   172
		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
   173
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   174
		}
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   175
	};
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   176
	private OnItemSelectedListener gameplayClicker = new OnItemSelectedListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   177
		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   178
			//config = ()arg0.getAdapter().getItem(arg2);
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   179
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   180
		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
   181
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   182
		}
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   183
	};
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
   184
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   185
	private OnClickListener startClicker = new OnClickListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   186
		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
   187
			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
   188
				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
   189
				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
   190
			}
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
			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
   192
				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
   193
				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
   194
				startActivity(i);}
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   195
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   196
	};
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
   197
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   198
	private OnClickListener backClicker = new OnClickListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   199
		public void onClick(View v) {
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   200
			finish();
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   201
		}
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   202
	};
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
   203
5471
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   204
	private OnClickListener teamClicker = new OnClickListener(){
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   205
		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
   206
			startTeamsActivity();
5471
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
	};
081bc0170623 Main activity for starting a local game
Xeli
parents: 5433
diff changeset
   209
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   210
}