project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/EngineProtocol/Scheme.java
author Xeli
Sun, 21 Aug 2011 16:25:18 +0200
branchhedgeroid
changeset 5621 ea796c83ea47
parent 5508 dcf1b3645af6
child 5657 4dad72a8f514
permissions -rw-r--r--
added licenses
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5621
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     1
/*
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     2
 * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     3
 * Copyright (c) 2011 Richard Deurwaarder <xeli@xelification.com>
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     4
 *
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     8
 *
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    12
 * GNU General Public License for more details.
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    13
 *
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    14
 * You should have received a copy of the GNU General Public License
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    15
 * along with this program; if not, write to the Free Software
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    17
 */
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    18
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    19
package org.hedgewars.mobile.EngineProtocol;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    20
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    21
import java.io.BufferedReader;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    22
import java.io.File;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    23
import java.io.FileNotFoundException;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    24
import java.io.FileReader;
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    25
import java.io.FilenameFilter;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    26
import java.io.IOException;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    27
import java.util.ArrayList;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    28
import java.util.Arrays;
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    29
import java.util.LinkedHashMap;
5433
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
import org.xmlpull.v1.XmlPullParser;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    32
import org.xmlpull.v1.XmlPullParserException;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    33
import org.xmlpull.v1.XmlPullParserFactory;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    34
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    35
import android.content.Context;
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    36
import android.os.Parcel;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    37
import android.os.Parcelable;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    38
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    39
public class Scheme implements Parcelable{
5433
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
	public static final String DIRECTORY_SCHEME = "schemes";
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    42
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    43
	private String name;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    44
	//private ArrayList<Integer> basic;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    45
	private Integer gamemod;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    46
	private ArrayList<Integer> basic;;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    47
	private static ArrayList<LinkedHashMap<String, ?>> basicflags = new ArrayList<LinkedHashMap<String, ?>>();
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    48
	
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    49
	public Scheme(String _name, ArrayList<Integer> _basic, int _gamemod){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    50
		name = _name;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    51
		gamemod = _gamemod;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    52
		basic = _basic;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    53
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    54
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    55
	
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    56
	public Scheme(Parcel in){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    57
		readFromParcel(in);
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    58
	}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    59
5508
dcf1b3645af6 Fixed IPC provide gameconfig
Xeli
parents: 5463
diff changeset
    60
	public void sendToEngine(EngineProtocolNetwork epn)throws IOException{ 
dcf1b3645af6 Fixed IPC provide gameconfig
Xeli
parents: 5463
diff changeset
    61
		epn.sendToEngine(String.format("e$gmflags %d", gamemod));
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    62
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    63
		for(int pos = 0; pos < basic.size(); pos++){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    64
			LinkedHashMap<String, ?> basicflag = basicflags.get(pos);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    65
			
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    66
			String command = (String)basicflag.get("command");
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    67
			Integer value = basic.get(pos);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    68
			Boolean checkOverMax = (Boolean) basicflag.get("checkOverMax");
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    69
			Boolean times1000 = (Boolean) basicflag.get("times1000");
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    70
			Integer max = (Integer) basicflag.get("max");
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    71
			
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    72
			if(checkOverMax && value >= max) value = max;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    73
			if(times1000) value *= 1000;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    74
			
5508
dcf1b3645af6 Fixed IPC provide gameconfig
Xeli
parents: 5463
diff changeset
    75
			epn.sendToEngine(String.format("%s %d", command, value));
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    76
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    77
	}
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    78
	public String toString(){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    79
		return name;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    80
	}
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    81
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    82
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    83
	public static final int STATE_START = 0;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    84
	public static final int STATE_ROOT = 1;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    85
	public static final int STATE_NAME = 2;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    86
	public static final int STATE_BASICFLAGS = 3;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    87
	public static final int STATE_GAMEMOD = 4;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    88
	public static final int STATE_BASICFLAG_INTEGER = 5;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    89
	public static final int STATE_GAMEMOD_TRUE = 6;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    90
	public static final int STATE_GAMEMOD_FALSE = 7;
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    91
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    92
	public static ArrayList<Scheme> getSchemes(Context c) throws IllegalArgumentException{
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    93
		String dir = c.getFilesDir().getAbsolutePath() + '/' + DIRECTORY_SCHEME + '/';
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    94
		String[] files = new File(dir).list(fnf);
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    95
		if(files == null) files = new String[]{};
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    96
		Arrays.sort(files);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    97
		ArrayList<Scheme> schemes = new ArrayList<Scheme>();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    98
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    99
		try {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   100
			XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   101
			XmlPullParser xmlPuller = xmlPullFactory.newPullParser();
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   102
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   103
			for(String file : files){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   104
				BufferedReader br = new BufferedReader(new FileReader(dir + file), 1024);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   105
				xmlPuller.setInput(br);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   106
				String name = null;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   107
				ArrayList<Integer> basic = new ArrayList<Integer>();
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   108
				Integer gamemod = 0;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   109
				int mask = 0x000000004;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   110
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   111
				int eventType = xmlPuller.getEventType();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   112
				int state = STATE_START;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   113
				while(eventType != XmlPullParser.END_DOCUMENT){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   114
					switch(state){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   115
					case STATE_START:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   116
						if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().equals("scheme")) state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   117
						else if(eventType != XmlPullParser.START_DOCUMENT) throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   118
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   119
					case STATE_ROOT:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   120
						if(eventType == XmlPullParser.START_TAG){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   121
							if(xmlPuller.getName().equals("basicflags")) state = STATE_BASICFLAGS;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   122
							else if(xmlPuller.getName().toLowerCase().equals("gamemod")) state = STATE_GAMEMOD;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   123
							else if(xmlPuller.getName().toLowerCase().equals("name")) state = STATE_NAME;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   124
							else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   125
						}else if(eventType == XmlPullParser.END_TAG) state = STATE_START;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   126
						else throwException(xmlPuller.getText(), eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   127
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   128
					case STATE_BASICFLAGS:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   129
						if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().toLowerCase().equals("integer")) state = STATE_BASICFLAG_INTEGER;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   130
						else if(eventType == XmlPullParser.END_TAG)	state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   131
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   132
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   133
					case STATE_GAMEMOD:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   134
						if(eventType == XmlPullParser.START_TAG){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   135
							if(xmlPuller.getName().toLowerCase().equals("true")) state = STATE_GAMEMOD_TRUE;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   136
							else if(xmlPuller.getName().toLowerCase().equals("false")) state = STATE_GAMEMOD_FALSE;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   137
							else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   138
						}else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   139
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   140
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   141
					case STATE_NAME:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   142
						if(eventType == XmlPullParser.TEXT) name = xmlPuller.getText().trim();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   143
						else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   144
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   145
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   146
					case STATE_BASICFLAG_INTEGER:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   147
						if(eventType == XmlPullParser.TEXT) basic.add(Integer.parseInt(xmlPuller.getText().trim()));
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   148
						else if(eventType == XmlPullParser.END_TAG) state = STATE_BASICFLAGS;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   149
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   150
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   151
					case STATE_GAMEMOD_FALSE:
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   152
						if(eventType == XmlPullParser.TEXT) gamemod <<= 1;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   153
						else if(eventType == XmlPullParser.END_TAG) state = STATE_GAMEMOD;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   154
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   155
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   156
					case STATE_GAMEMOD_TRUE:
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   157
						if(eventType == XmlPullParser.TEXT){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   158
							gamemod |= mask;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   159
							gamemod <<= 1;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   160
						}else if(eventType == XmlPullParser.END_TAG) state = STATE_GAMEMOD;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   161
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   162
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   163
					}
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   164
					eventType = getEventType(xmlPuller);
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   165
				}//end while(eventtype != END_DOCUMENT
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   166
				schemes.add(new Scheme(name, basic, gamemod));
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   167
			}//end for(string file : files
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   168
			return schemes;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   169
		} catch (XmlPullParserException e) {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   170
			e.printStackTrace();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   171
		} catch (FileNotFoundException e) {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   172
			e.printStackTrace();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   173
		} catch (IOException e) {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   174
			e.printStackTrace();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   175
		}
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   176
		return new ArrayList<Scheme>();//TODO handle correctly
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   177
	}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   178
	
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   179
	private static FilenameFilter fnf = new FilenameFilter(){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   180
		public boolean accept(File dir, String filename) {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   181
			return filename.toLowerCase().startsWith("scheme_");
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   182
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   183
	};
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   184
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   185
	/**
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   186
	 * This method will parse the basic flags from a prespecified xml file.
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   187
	 * I use a raw xml file rather than one parsed by aatp at compile time
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   188
	 * to keep it generic with other frontends, ie in the future we could 
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   189
	 * use one provided by the Data folder.
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   190
	 */
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   191
	public static void parseBasicFlags(Context c){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   192
		String filename = String.format("%s/%s/basicflags", c.getFilesDir().getAbsolutePath(), DIRECTORY_SCHEME);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   193
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   194
		XmlPullParser xmlPuller = null;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   195
		BufferedReader br = null;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   196
		try {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   197
			XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   198
			xmlPuller = xmlPullFactory.newPullParser();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   199
			br = new BufferedReader(new FileReader(filename), 1024);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   200
			xmlPuller.setInput(br);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   201
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   202
			int eventType = getEventType(xmlPuller);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   203
			boolean continueParsing = true;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   204
			do{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   205
				switch(eventType){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   206
				
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   207
				case XmlPullParser.START_TAG:
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   208
					if(xmlPuller.getName().toLowerCase().equals("flag")){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   209
						basicflags.add(parseFlag(xmlPuller));
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   210
					}else if(xmlPuller.getName().toLowerCase().equals("basicflags")){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   211
						eventType = getEventType(xmlPuller);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   212
					}else{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   213
						skipCurrentTag(xmlPuller);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   214
						eventType = getEventType(xmlPuller);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   215
					}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   216
					break;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   217
				case XmlPullParser.START_DOCUMENT://ignore all tags not being "flag"
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   218
				case XmlPullParser.END_TAG:
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   219
				case XmlPullParser.TEXT:
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   220
				default:
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   221
					continueParsing = true;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   222
				case XmlPullParser.END_DOCUMENT:
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   223
					continueParsing = false;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   224
				}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   225
			}while(continueParsing);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   226
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   227
		}catch(IOException e){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   228
			e.printStackTrace();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   229
		}catch (XmlPullParserException e) {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   230
			e.printStackTrace();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   231
		}finally{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   232
			if(br != null)
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   233
				try {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   234
					br.close();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   235
				} catch (IOException e) {}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   236
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   237
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   238
	}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   239
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   240
	/*
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   241
	 * * Parses a Tag structure from xml as example we use
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   242
	 *<flag>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   243
	 *   <checkOverMax>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   244
	 *       <boolean>false</boolean>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   245
	 *   </checkOverMax>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   246
	 *</flag>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   247
	 *
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   248
	 * It returns a LinkedHashMap with key/value pairs
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   249
	 */
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   250
	private static LinkedHashMap<String, Object> parseFlag(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   251
		LinkedHashMap<String, Object> hash = new LinkedHashMap<String, Object>();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   252
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   253
		int eventType = xmlPuller.getEventType();//Get the event type which triggered this method
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   254
		if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().toLowerCase().equals("flag")){//valid start of flag tag
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   255
			String lcKey = null;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   256
			String lcType = null;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   257
			String value = null;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   258
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   259
			eventType = getEventType(xmlPuller);//<checkOverMax>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   260
			while(eventType == XmlPullParser.START_TAG){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   261
				lcKey = xmlPuller.getName();//checkOverMax
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   262
				if(getEventType(xmlPuller) == XmlPullParser.START_TAG){//<boolean>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   263
					lcType = xmlPuller.getName().toLowerCase();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   264
					if(getEventType(xmlPuller) == XmlPullParser.TEXT){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   265
						value = xmlPuller.getText();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   266
						if(getEventType(xmlPuller) == XmlPullParser.END_TAG && //</boolean> 
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   267
								getEventType(xmlPuller) == XmlPullParser.END_TAG){//</checkOverMax>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   268
							if(lcType.equals("boolean")) hash.put(lcKey, new Boolean(value));
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   269
							else if(lcType.equals("string"))hash.put(lcKey, value);							
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   270
							else if(lcType.equals("integer")){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   271
								try{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   272
									hash.put(lcKey, new Integer(value));
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   273
								}catch (NumberFormatException e){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   274
									throw new XmlPullParserException("Wrong integer value in xml file");
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   275
								}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   276
							}else{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   277
								throwException("basicflags", eventType);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   278
							}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   279
						}//</boolean> / </checkOverMax>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   280
					}//if TEXT
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   281
				}//if boolean
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   282
				eventType = getEventType(xmlPuller);//start new loop
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   283
			}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   284
			eventType = getEventType(xmlPuller);//</flag>
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   285
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   286
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   287
		return hash;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   288
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   289
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   290
	private static void skipCurrentTag(XmlPullParser xmlPuller) throws XmlPullParserException, IOException{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   291
		int eventType = xmlPuller.getEventType();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   292
		if(eventType != XmlPullParser.START_TAG)return;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   293
		String tag = xmlPuller.getName().toLowerCase();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   294
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   295
		while(true){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   296
			eventType = getEventType(xmlPuller);//getNext()
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   297
			switch(eventType){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   298
			case XmlPullParser.START_DOCUMENT://we're inside of a start tag so START_ or END_DOCUMENT is just wrong
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   299
			case XmlPullParser.END_DOCUMENT:
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   300
				throw new XmlPullParserException("invalid xml file");
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   301
			case XmlPullParser.START_TAG://if we get a new tag recursively handle it
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   302
				skipCurrentTag(xmlPuller);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   303
				break;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   304
			case XmlPullParser.TEXT:
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   305
				break;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   306
			case XmlPullParser.END_TAG:
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   307
				if(!xmlPuller.getName().toLowerCase().equals(tag)){//if the end tag doesn't match the start tag
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   308
					throw new XmlPullParserException("invalid xml file");
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   309
				}else{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   310
					return;//skip completed	
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   311
				}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   312
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   313
			}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   314
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   315
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   316
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   317
	/**
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   318
	 * Skips whitespaces..
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   319
	 */
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   320
	private static int getEventType(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   321
		int eventType = xmlPuller.next();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   322
		while(eventType == XmlPullParser.TEXT && xmlPuller.isWhitespace()){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   323
			eventType = xmlPuller.next();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   324
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   325
		return eventType;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   326
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   327
	private static void throwException(String file, int eventType){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   328
		throw new IllegalArgumentException(String.format("Xml file: %s malformed with error: %d.", file, eventType));
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   329
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   330
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   331
	@Override
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   332
	public int describeContents() {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   333
		// TODO Auto-generated method stub
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   334
		return 0;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   335
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   336
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   337
	public void writeToParcel(Parcel dest, int flags) {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   338
		dest.writeString(name);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   339
		dest.writeInt(gamemod);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   340
		dest.writeList(basic);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   341
		
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   342
	}
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   343
	
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   344
	public void readFromParcel(Parcel src){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   345
		name = src.readString();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   346
		gamemod = src.readInt();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   347
		basic = src.readArrayList(ArrayList.class.getClassLoader());
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   348
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   349
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   350
	public static final Parcelable.Creator<Scheme> CREATOR = new Parcelable.Creator<Scheme>() {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   351
		public Scheme createFromParcel(Parcel source) {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   352
			return new Scheme(source);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   353
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   354
		public Scheme[] newArray(int size) {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   355
			return new Scheme[size];
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   356
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   357
		
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   358
	};
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   359
}