project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/StartGameActivity.java
author Xeli
Thu, 14 Jul 2011 15:55:28 +0200
branchhedgeroid
changeset 5433 8f82045953c1
child 5471 081bc0170623
permissions -rw-r--r--
Main class files for the start-local-game screen
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
     1
package org.hedgewars.mobile;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
     2
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
     3
import android.app.Activity;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
     4
import android.content.SharedPreferences;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
     5
import android.graphics.drawable.Drawable;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
     6
import android.os.Bundle;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
     7
import android.preference.PreferenceManager;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
     8
import android.view.View;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
     9
import android.widget.AdapterView;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    10
import android.widget.AdapterView.OnItemSelectedListener;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    11
import android.widget.ArrayAdapter;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    12
import android.widget.ImageView;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    13
import android.widget.Spinner;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    14
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    15
public class StartGameActivity extends Activity {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    16
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    17
	private Spinner maps, gameplay, gamescheme, weapons, themes;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    18
	private ImageView themeIcon;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    19
	
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    20
	public void onCreate(Bundle savedInstanceState){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    21
		super.onCreate(savedInstanceState);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    22
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    23
		setContentView(R.layout.starting_game);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    24
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    25
		maps = (Spinner) findViewById(R.id.spinMaps);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    26
		gameplay = (Spinner) findViewById(R.id.spinGameplay);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    27
		gamescheme = (Spinner) findViewById(R.id.spinGamescheme);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    28
		weapons = (Spinner) findViewById(R.id.spinweapons);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    29
		themes = (Spinner) findViewById(R.id.spinTheme);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    30
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    31
		themeIcon = (ImageView) findViewById(R.id.imgTheme);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    32
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    33
		ArrayAdapter<?> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, FrontendDataUtil.getMaps(this));
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    34
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    35
		maps.setAdapter(adapter);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    36
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    37
		adapter = new ArrayAdapter<String>(this, R.layout.listview_item, FrontendDataUtil.getGameplay(this));
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    38
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    39
		gameplay.setAdapter(adapter);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    40
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    41
		adapter = new ArrayAdapter<Scheme>(this, R.layout.listview_item, FrontendDataUtil.getSchemes(this));
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    42
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    43
		gamescheme.setAdapter(adapter);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    44
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    45
		adapter = new ArrayAdapter<Weapon>(this, R.layout.listview_item, FrontendDataUtil.getWeapons(this));
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    46
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    47
		weapons.setAdapter(adapter);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    48
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    49
		adapter = new ArrayAdapter<String>(this, R.layout.listview_item, FrontendDataUtil.getThemes(this));
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    50
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    51
		themes.setAdapter(adapter);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    52
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    53
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    54
		themes.setOnItemSelectedListener(themesClicker);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    55
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    56
		SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    57
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    58
		Utils.resRawToFilesDir(this,R.array.schemes, Scheme.DIRECTORY_SCHEME);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    59
		Utils.resRawToFilesDir(this, R.array.weapons, Weapon.DIRECTORY_WEAPON);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    60
	}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    61
	
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    62
	private OnItemSelectedListener themesClicker = new OnItemSelectedListener(){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    63
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    64
		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
    65
			String themeName = (String) arg0.getAdapter().getItem(position);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    66
			Drawable themeIconDrawable = Drawable.createFromPath(Utils.getDownloadPath(StartGameActivity.this) + "/Data/Themes/" + themeName + "/icon@2X.png");
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    67
			themeIcon.setImageDrawable(themeIconDrawable);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    68
		}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    69
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    70
		public void onNothingSelected(AdapterView<?> arg0) {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    71
			// TODO Auto-generated method stub
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    72
			
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    73
		}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    74
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    75
	};
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    76
	
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    77
}