# HG changeset patch # User Xeli # Date 1322936293 -3600 # Node ID c356ddebab843afa679c02e4db8eb1eb25c9f47f # Parent bd3c736c1eac0cda420b632c64c279a86e9dff7b android: moved the different objects representing the different game parameters to a different package diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java Sat Dec 03 19:18:13 2011 +0100 @@ -0,0 +1,216 @@ +/* + * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game + * Copyright (c) 2011 Richard Deurwaarder + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +package org.hedgewars.hedgeroid.Datastructures; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; + +import org.hedgewars.hedgeroid.R; +import org.hedgewars.hedgeroid.Utils; +import org.hedgewars.hedgeroid.Datastructures.Map.MapType; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; + +public class FrontendDataUtils { + + + public static ArrayList getMaps(Context c){ + File[] files = Utils.getFilesFromRelativeDir(c,"Maps"); + ArrayList ret = new ArrayList(); + + for(File f : files){ + if(Utils.hasFileWithSuffix(f, ".lua")){ + ret.add(new Map(f,MapType.TYPE_MISSION, c)); + }else{ + ret.add(new Map(f, MapType.TYPE_DEFAULT,c)); + } + } + Collections.sort(ret); + + return ret; + } + + public static List getGameplay(Context c){ + String[] files = Utils.getFileNamesFromRelativeDir(c, "Scripts/Multiplayer"); + ArrayList ret = new ArrayList(); + + for(int i = 0; i < files.length; i++){ + if(files[i].endsWith(".lua")){ + ret.add(files[i].replace('_', ' ').substring(0, files[i].length()-4)); //replace _ by a space and removed the last four characters (.lua) + } + } + ret.add(0,"None"); + Collections.sort(ret); + return ret; + } + + public static List getThemes(Context c){ + List list = Utils.getDirsWithFileSuffix(c, "Themes", "icon.png"); + Collections.sort(list); + return list; + } + + public static List getSchemes(Context c){ + List list = Scheme.getSchemes(c); + Collections.sort(list); + return list; + } + + public static List getWeapons(Context c){ + List list = Weapon.getWeapons(c); + Collections.sort(list); + return list; + } + + public static ArrayList> getGraves(Context c){ + String pathPrefix = Utils.getDataPath(c) + "Graphics/Graves/"; + ArrayList names = Utils.getFilesFromDirWithSuffix(c,"Graphics/Graves", ".png", true); + ArrayList> data = new ArrayList>(names.size()); + + for(String s : names){ + HashMap map = new HashMap(); + map.put("txt", s); + Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap + int width = b.getWidth(); + if(b.getHeight() > width){//some pictures contain more 'frames' underneath each other, if so we only use the first frame + Bitmap tmp = Bitmap.createBitmap(b, 0, 0, width, width); + b.recycle(); + b = tmp; + } + map.put("img", b); + data.add(map); + } + return data; + } + + public static ArrayList> getFlags(Context c){ + String pathPrefix = Utils.getDataPath(c) + "Graphics/Flags/"; + ArrayList names = Utils.getFilesFromDirWithSuffix(c, "Graphics/Flags", ".png", true); + ArrayList> data = new ArrayList>(names.size()); + + for(String s : names){ + HashMap map = new HashMap(); + map.put("txt", s); + Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap + map.put("img", b); + data.add(map); + } + return data; + } + + public static ArrayList getVoices(Context c){ + File[] files = Utils.getFilesFromRelativeDir(c, "Sounds/voices"); + ArrayList ret = new ArrayList(); + + for(File f : files){ + if(f.isDirectory()) ret.add(f.getName()); + } + return ret; + } + + public static ArrayList getForts(Context c){ + return Utils.getFilesFromDirWithSuffix(c,"Forts", "L.png", true); + } + public static ArrayList> getTypes(Context c){ + ArrayList> data = new ArrayList>(6); + String[] levels = {c.getString(R.string.human), c.getString(R.string.bot5), c.getString(R.string.bot4), c.getString(R.string.bot3), c.getString(R.string.bot2), c.getString(R.string.bot1)}; + int[] images = {R.drawable.human, R.drawable.bot5, R.drawable.bot4, R.drawable.bot3, R.drawable.bot2, R.drawable.bot1}; + + for(int i = 0; i < levels.length; i++){ + HashMap map = new HashMap(); + map.put("txt", levels[i]); + map.put("img", images[i]); + data.add(map); + } + + return data; + } + + public static ArrayList> getHats(Context c){ + ArrayList files = Utils.getFilesFromDirWithSuffix(c,"Graphics/Hats", ".png", true); + String pathPrefix = Utils.getDataPath(c) + "Graphics/Hats/"; + int size = files.size(); + ArrayList> data = new ArrayList>(size); + + HashMap hashmap; + for(String s : files){ + hashmap = new HashMap(); + hashmap.put("txt", s); + Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap + b = Bitmap.createBitmap(b, 0,0,b.getWidth()/2, b.getWidth()/2); + hashmap.put("img", b); + data.add(hashmap); + } + + return data; + } + + public static List> getTeams(Context c){ + List> ret = new ArrayList>(); + + File teamsDir = new File(c.getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS); + File[] teamFileNames = teamsDir.listFiles(); + if(teamFileNames != null){ + for(File s : teamFileNames){ + Team t = Team.getTeamFromXml(s.getAbsolutePath()); + if(t != null){ + t.file = s.getName(); + ret.add(teamToMap(t)); + } + } + } + return ret; + } + + public static HashMap teamToMap(Team t){ + HashMap hashmap = new HashMap(); + hashmap.put("team", t); + hashmap.put("txt", t.name); + hashmap.put("color", t.color); + hashmap.put("count", t.hogCount); + switch(t.levels[0]){ + case 0: + hashmap.put("img", R.drawable.human); + break; + case 1: + hashmap.put("img", R.drawable.bot5); + break; + case 2: + hashmap.put("img", R.drawable.bot4); + break; + case 3: + hashmap.put("img", R.drawable.bot3); + break; + case 4: + hashmap.put("img", R.drawable.bot2); + break; + default: + case 5: + hashmap.put("img", R.drawable.bot1); + break; + } + return hashmap; + } +} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/GameMode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/GameMode.java Sat Dec 03 19:18:13 2011 +0100 @@ -0,0 +1,24 @@ +/* + * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game + * Copyright (c) 2011 Richard Deurwaarder + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +package org.hedgewars.hedgeroid.Datastructures; + +public enum GameMode { + MODE_LOCAL, MODE_DEMO, MODE_NET, MODE_SAVE +} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Grave.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Grave.java Sat Dec 03 19:18:13 2011 +0100 @@ -0,0 +1,36 @@ +/* + * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game + * Copyright (c) 2011 Richard Deurwaarder + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +package org.hedgewars.hedgeroid.Datastructures; + +public class Grave{ + + public final String name; + public final String path; + + public Grave(String _name, String _path) { + name = _name; + path = _path; + } + + public String toString(){ + return name; + } + +} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Map.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Map.java Sat Dec 03 19:18:13 2011 +0100 @@ -0,0 +1,163 @@ +/* + * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game + * Copyright (c) 2011 Richard Deurwaarder + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +package org.hedgewars.hedgeroid.Datastructures; + +import java.io.File; +import java.io.IOException; + +import org.hedgewars.hedgeroid.EngineProtocol.EngineProtocolNetwork; + + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.os.Parcel; +import android.os.Parcelable; + +public class Map implements Comparable, Parcelable{ + + private static final String MISSION_PREFIX = "Mission: "; + + private String name; + private String path; + private String previewPath; + private MapType type; + + public Map(File mapDir, MapType _type, Context c){ + type = _type; + + name = mapDir.getName(); + path = mapDir.getAbsolutePath(); + previewPath = path + "/preview.png"; + + /*switch(type){ + case TYPE_DEFAULT: + + break; + case TYPE_GENERATED: + //TODO + break; + case TYPE_MISSION: + name = MISSION_PREFIX + mapDir.getName(); + path = mapDir.getAbsolutePath(); + break; + }*/ + + + } + + public Map(Parcel in){ + readFromParcel(in); + } + + public String toString(){ + switch(type){ + default: + case TYPE_DEFAULT: + return name; + case TYPE_GENERATED: + return "bla"; + case TYPE_MISSION: + return MISSION_PREFIX + name; + } + } + + public void sendToEngine(EngineProtocolNetwork epn) throws IOException{ + epn.sendToEngine(String.format("emap %s",name)); + } + + public MapType getType(){ + return type; + } + + public Drawable getDrawable(){ + switch(type){ + case TYPE_MISSION: + case TYPE_DEFAULT: + return Drawable.createFromPath(previewPath); + case TYPE_GENERATED: + + default: + return null; + } + } + + public int compareTo(Map another) { + switch(type){ + case TYPE_GENERATED: + switch(another.getType()){ + case TYPE_GENERATED: + return name.compareTo(another.name); + case TYPE_MISSION: + return -1; + case TYPE_DEFAULT: + return -1; + } + case TYPE_MISSION: + switch(another.getType()){ + case TYPE_GENERATED: + return 1; + case TYPE_MISSION: + return name.compareTo(another.name); + case TYPE_DEFAULT: + return -1; + } + case TYPE_DEFAULT: + switch(another.getType()){ + case TYPE_GENERATED: + return 1; + case TYPE_MISSION: + return 1; + case TYPE_DEFAULT: + return name.compareTo(another.name); + } + } + return 0;//default case this should never happen + } + + public enum MapType{ + TYPE_DEFAULT, TYPE_MISSION, TYPE_GENERATED + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(name); + dest.writeString(path); + dest.writeString(previewPath); + dest.writeString(type.name()); + } + + private void readFromParcel(Parcel src){ + name = src.readString(); + path = src.readString(); + previewPath = src.readString(); + type = MapType.valueOf(src.readString()); + } + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public Map createFromParcel(Parcel source) { + return new Map(source); + } + public Map[] newArray(int size) { + return new Map[size]; + } + + }; +} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Scheme.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Scheme.java Sat Dec 03 19:18:13 2011 +0100 @@ -0,0 +1,360 @@ +/* + * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game + * Copyright (c) 2011 Richard Deurwaarder + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +package org.hedgewars.hedgeroid.Datastructures; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; + +import org.hedgewars.hedgeroid.EngineProtocol.EngineProtocolNetwork; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlPullParserFactory; + +import android.content.Context; +import android.os.Parcel; +import android.os.Parcelable; + +public class Scheme implements Parcelable, Comparable{ + + public static final String DIRECTORY_SCHEME = "schemes"; + + private String name; + //private ArrayList basic; + private Integer gamemod; + private ArrayList basic;; + private static ArrayList> basicflags = new ArrayList>();//TODO why is it static? + + public Scheme(String _name, ArrayList _basic, int _gamemod){ + name = _name; + gamemod = _gamemod; + basic = _basic; + } + + public Scheme(Parcel in){ + readFromParcel(in); + } + + public void sendToEngine(EngineProtocolNetwork epn)throws IOException{ + epn.sendToEngine(String.format("e$gmflags %d", gamemod)); + + for(int pos = 0; pos < basic.size(); pos++){ + LinkedHashMap basicflag = basicflags.get(pos); + + String command = (String)basicflag.get("command"); + Integer value = basic.get(pos); + Boolean checkOverMax = (Boolean) basicflag.get("checkOverMax"); + Boolean times1000 = (Boolean) basicflag.get("times1000"); + Integer max = (Integer) basicflag.get("max"); + + if(checkOverMax && value >= max) value = max; + if(times1000) value *= 1000; + + epn.sendToEngine(String.format("%s %d", command, value)); + } + } + public String toString(){ + return name; + } + + + public static final int STATE_START = 0; + public static final int STATE_ROOT = 1; + public static final int STATE_NAME = 2; + public static final int STATE_BASICFLAGS = 3; + public static final int STATE_GAMEMOD = 4; + public static final int STATE_BASICFLAG_INTEGER = 5; + public static final int STATE_GAMEMOD_TRUE = 6; + public static final int STATE_GAMEMOD_FALSE = 7; + + public static ArrayList getSchemes(Context c) throws IllegalArgumentException{ + String dir = c.getFilesDir().getAbsolutePath() + '/' + DIRECTORY_SCHEME + '/'; + String[] files = new File(dir).list(fnf); + if(files == null) files = new String[]{}; + Arrays.sort(files); + ArrayList schemes = new ArrayList(); + + try { + XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); + XmlPullParser xmlPuller = xmlPullFactory.newPullParser(); + + for(String file : files){ + BufferedReader br = new BufferedReader(new FileReader(dir + file), 1024); + xmlPuller.setInput(br); + String name = null; + ArrayList basic = new ArrayList(); + Integer gamemod = 0; + int mask = 0x000000004; + + int eventType = xmlPuller.getEventType(); + int state = STATE_START; + while(eventType != XmlPullParser.END_DOCUMENT){ + switch(state){ + case STATE_START: + if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().equals("scheme")) state = STATE_ROOT; + else if(eventType != XmlPullParser.START_DOCUMENT) throwException(file, eventType); + break; + case STATE_ROOT: + if(eventType == XmlPullParser.START_TAG){ + if(xmlPuller.getName().equals("basicflags")) state = STATE_BASICFLAGS; + else if(xmlPuller.getName().toLowerCase().equals("gamemod")) state = STATE_GAMEMOD; + else if(xmlPuller.getName().toLowerCase().equals("name")) state = STATE_NAME; + else throwException(file, eventType); + }else if(eventType == XmlPullParser.END_TAG) state = STATE_START; + else throwException(xmlPuller.getText(), eventType); + break; + case STATE_BASICFLAGS: + if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().toLowerCase().equals("integer")) state = STATE_BASICFLAG_INTEGER; + else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; + else throwException(file, eventType); + break; + case STATE_GAMEMOD: + if(eventType == XmlPullParser.START_TAG){ + if(xmlPuller.getName().toLowerCase().equals("true")) state = STATE_GAMEMOD_TRUE; + else if(xmlPuller.getName().toLowerCase().equals("false")) state = STATE_GAMEMOD_FALSE; + else throwException(file, eventType); + }else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; + else throwException(file, eventType); + break; + case STATE_NAME: + if(eventType == XmlPullParser.TEXT) name = xmlPuller.getText().trim(); + else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; + else throwException(file, eventType); + break; + case STATE_BASICFLAG_INTEGER: + if(eventType == XmlPullParser.TEXT) basic.add(Integer.parseInt(xmlPuller.getText().trim())); + else if(eventType == XmlPullParser.END_TAG) state = STATE_BASICFLAGS; + else throwException(file, eventType); + break; + case STATE_GAMEMOD_FALSE: + if(eventType == XmlPullParser.TEXT) gamemod <<= 1; + else if(eventType == XmlPullParser.END_TAG) state = STATE_GAMEMOD; + else throwException(file, eventType); + break; + case STATE_GAMEMOD_TRUE: + if(eventType == XmlPullParser.TEXT){ + gamemod |= mask; + gamemod <<= 1; + }else if(eventType == XmlPullParser.END_TAG) state = STATE_GAMEMOD; + else throwException(file, eventType); + break; + } + eventType = getEventType(xmlPuller); + }//end while(eventtype != END_DOCUMENT + schemes.add(new Scheme(name, basic, gamemod)); + }//end for(string file : files + return schemes; + } catch (XmlPullParserException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return new ArrayList();//TODO handle correctly + } + + private static FilenameFilter fnf = new FilenameFilter(){ + public boolean accept(File dir, String filename) { + return filename.toLowerCase().startsWith("scheme_"); + } + }; + + /** + * This method will parse the basic flags from a prespecified xml file. + * I use a raw xml file rather than one parsed by aatp at compile time + * to keep it generic with other frontends, ie in the future we could + * use one provided by the Data folder. + */ + public static void parseBasicFlags(Context c){ + String filename = String.format("%s/%s/basicflags", c.getFilesDir().getAbsolutePath(), DIRECTORY_SCHEME); + + XmlPullParser xmlPuller = null; + BufferedReader br = null; + try { + XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); + xmlPuller = xmlPullFactory.newPullParser(); + br = new BufferedReader(new FileReader(filename), 1024); + xmlPuller.setInput(br); + + int eventType = getEventType(xmlPuller); + boolean continueParsing = true; + do{ + switch(eventType){ + + case XmlPullParser.START_TAG: + if(xmlPuller.getName().toLowerCase().equals("flag")){ + basicflags.add(parseFlag(xmlPuller)); + }else if(xmlPuller.getName().toLowerCase().equals("basicflags")){ + eventType = getEventType(xmlPuller); + }else{ + skipCurrentTag(xmlPuller); + eventType = getEventType(xmlPuller); + } + break; + case XmlPullParser.START_DOCUMENT://ignore all tags not being "flag" + case XmlPullParser.END_TAG: + case XmlPullParser.TEXT: + default: + continueParsing = true; + case XmlPullParser.END_DOCUMENT: + continueParsing = false; + } + }while(continueParsing); + + }catch(IOException e){ + e.printStackTrace(); + }catch (XmlPullParserException e) { + e.printStackTrace(); + }finally{ + if(br != null) + try { + br.close(); + } catch (IOException e) {} + } + + } + + /* + * * Parses a Tag structure from xml as example we use + * + * + * false + * + * + * + * It returns a LinkedHashMap with key/value pairs + */ + private static LinkedHashMap parseFlag(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{ + LinkedHashMap hash = new LinkedHashMap(); + + int eventType = xmlPuller.getEventType();//Get the event type which triggered this method + if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().toLowerCase().equals("flag")){//valid start of flag tag + String lcKey = null; + String lcType = null; + String value = null; + + eventType = getEventType(xmlPuller);// + while(eventType == XmlPullParser.START_TAG){ + lcKey = xmlPuller.getName();//checkOverMax + if(getEventType(xmlPuller) == XmlPullParser.START_TAG){// + lcType = xmlPuller.getName().toLowerCase(); + if(getEventType(xmlPuller) == XmlPullParser.TEXT){ + value = xmlPuller.getText(); + if(getEventType(xmlPuller) == XmlPullParser.END_TAG && // + getEventType(xmlPuller) == XmlPullParser.END_TAG){// + if(lcType.equals("boolean")) hash.put(lcKey, new Boolean(value)); + else if(lcType.equals("string"))hash.put(lcKey, value); + else if(lcType.equals("integer")){ + try{ + hash.put(lcKey, new Integer(value)); + }catch (NumberFormatException e){ + throw new XmlPullParserException("Wrong integer value in xml file"); + } + }else{ + throwException("basicflags", eventType); + } + }// / + }//if TEXT + }//if boolean + eventType = getEventType(xmlPuller);//start new loop + } + eventType = getEventType(xmlPuller);// + } + + return hash; + } + + private static void skipCurrentTag(XmlPullParser xmlPuller) throws XmlPullParserException, IOException{ + int eventType = xmlPuller.getEventType(); + if(eventType != XmlPullParser.START_TAG)return; + String tag = xmlPuller.getName().toLowerCase(); + + while(true){ + eventType = getEventType(xmlPuller);//getNext() + switch(eventType){ + case XmlPullParser.START_DOCUMENT://we're inside of a start tag so START_ or END_DOCUMENT is just wrong + case XmlPullParser.END_DOCUMENT: + throw new XmlPullParserException("invalid xml file"); + case XmlPullParser.START_TAG://if we get a new tag recursively handle it + skipCurrentTag(xmlPuller); + break; + case XmlPullParser.TEXT: + break; + case XmlPullParser.END_TAG: + if(!xmlPuller.getName().toLowerCase().equals(tag)){//if the end tag doesn't match the start tag + throw new XmlPullParserException("invalid xml file"); + }else{ + return;//skip completed + } + + } + } + } + + /** + * Skips whitespaces.. + */ + private static int getEventType(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{ + int eventType = xmlPuller.next(); + while(eventType == XmlPullParser.TEXT && xmlPuller.isWhitespace()){ + eventType = xmlPuller.next(); + } + return eventType; + } + private static void throwException(String file, int eventType){ + throw new IllegalArgumentException(String.format("Xml file: %s malformed with error: %d.", file, eventType)); + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(name); + dest.writeInt(gamemod); + dest.writeList(basic); + } + + public void readFromParcel(Parcel src){ + name = src.readString(); + gamemod = src.readInt(); + basic = src.readArrayList(ArrayList.class.getClassLoader()); + } + + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public Scheme createFromParcel(Parcel source) { + return new Scheme(source); + } + public Scheme[] newArray(int size) { + return new Scheme[size]; + } + + }; + + public int compareTo(Scheme another) { + return name.compareTo(another.name); + } +} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java Sat Dec 03 19:18:13 2011 +0100 @@ -0,0 +1,368 @@ +/* + * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game + * Copyright (c) 2011 Richard Deurwaarder + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +package org.hedgewars.hedgeroid.Datastructures; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; + +import org.hedgewars.hedgeroid.EngineProtocol.EngineProtocolNetwork; +import org.hedgewars.hedgeroid.EngineProtocol.PascalExports; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlPullParserFactory; +import org.xmlpull.v1.XmlSerializer; + +import android.content.Context; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.Xml; + +public class Team implements Parcelable{ + + public static final String DIRECTORY_TEAMS = "teams"; + private static final Integer[] TEAM_COLORS = { + 0xd12b42, /* red */ + 0x4980c1, /* blue */ + 0x6ab530, /* green */ + 0xbc64c4, /* purple */ + 0xe76d14, /* orange */ + 0x3fb6e6, /* cyan */ + 0xe3e90c, /* yellow */ + 0x61d4ac, /* mint */ + 0xf1c3e1, /* pink */ + /* add new colors here */ + }; + +// private static final Integer[] TEAM_COLORS = { +// 0xff0000, /* red */ +// 0x00ff00, /* blue */ +// 0x0000ff, /* green */ +// }; + + private static final int STATE_START = 0; + private static final int STATE_ROOT = 1; + private static final int STATE_HOG_ROOT = 2; + + public String name, grave, flag, voice, fort, hash; + public String file = null; + + public static int maxNumberOfHogs = 0; + public static int maxNumberOfTeams = 0; + + static{ + maxNumberOfHogs = PascalExports.HWgetMaxNumberOfHogs(); + maxNumberOfTeams = PascalExports.HWgetMaxNumberOfTeams(); + } + public String[] hats = new String[maxNumberOfHogs]; + public String[] hogNames = new String[maxNumberOfHogs]; + public int[] levels = new int[maxNumberOfHogs]; + + public int hogCount = 4; + public int color = TEAM_COLORS[0]; + + public Team(){ + } + + public Team(Parcel in){ + readFromParcel(in); + } + + public boolean equals(Object o){ + if(super.equals(o)) return true; + else if(o instanceof Team){ + Team t = (Team)o; + boolean ret = name.equals(t.name); + ret &= grave.equals(t.grave); + ret &= flag.equals(t.flag); + ret &= voice.equals(t.voice); + ret &= fort.equals(t.fort); + ret &= hash.equals(t.hash); + return ret; + }else{ + return false; + } + } + + public void setRandomColor(int[] illegalcolors){ + Integer[] colorsToPickFrom = TEAM_COLORS; + if(illegalcolors != null){ + ArrayList colors = new ArrayList(); + for(int color : TEAM_COLORS){ + boolean validColor = true; + for(int illegal : illegalcolors){ + if(color == illegal) validColor = false; + } + if(validColor) colors.add(color); + } + if(colors.size() != 0) colorsToPickFrom = colors.toArray(new Integer[1]); + } + int index = (int)Math.round(Math.random()*(colorsToPickFrom.length-1)); + color = colorsToPickFrom[index]; + } + + + public void sendToEngine(EngineProtocolNetwork epn, int hogCount, int health) throws IOException{ + epn.sendToEngine(String.format("eaddteam %s %d %s", hash, color, name)); + epn.sendToEngine(String.format("egrave %s", grave)); + epn.sendToEngine(String.format("efort %s", fort)); + epn.sendToEngine(String.format("evoicepack %s", voice)); + epn.sendToEngine(String.format("eflag %s", flag)); + + for(int i = 0; i < hogCount; i++){ + epn.sendToEngine(String.format("eaddhh %d %d %s", levels[i], health, hogNames[i])); + epn.sendToEngine(String.format("ehat %s", hats[i])); + } + } + + public void setFileName(Context c){ + if(file == null){ + file = validFileName(c, name); + } + } + private String validFileName(Context c, String fileName){ + String absolutePath = String.format("%s/%s", c.getFilesDir(), fileName); + File f = new File(absolutePath); + if(f.exists()){ + String newFileName = fileName + (int)(Math.random()*10); + return validFileName(c, newFileName); + }else{ + return fileName; + } + } + + /* + * XML METHODS + */ + + /** + * Read the xml file path and convert it to a Team object + * @param path absolute path to the xml file + * @return + */ + public static Team getTeamFromXml(String path){ + try { + XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); + XmlPullParser xmlPuller = xmlPullFactory.newPullParser(); + + BufferedReader br = new BufferedReader(new FileReader(path), 1024); + xmlPuller.setInput(br); + Team team = new Team(); + int hogCounter = 0; + + int eventType = xmlPuller.getEventType(); + int state = STATE_START; + while(eventType != XmlPullParser.END_DOCUMENT){ + switch(state){ + case STATE_START: + if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().equals("team")) state = STATE_ROOT; + else if(eventType != XmlPullParser.START_DOCUMENT) throwException(path, eventType); + break; + case STATE_ROOT: + if(eventType == XmlPullParser.START_TAG){ + if(xmlPuller.getName().toLowerCase().equals("name")){ + team.name = getXmlText(xmlPuller, "name"); + }else if(xmlPuller.getName().toLowerCase().equals("flag")){ + team.flag= getXmlText(xmlPuller, "flag"); + }else if(xmlPuller.getName().toLowerCase().equals("voice")){ + team.voice = getXmlText(xmlPuller, "voice"); + }else if(xmlPuller.getName().toLowerCase().equals("grave")){ + team.grave = getXmlText(xmlPuller, "grave"); + }else if(xmlPuller.getName().toLowerCase().equals("fort")){ + team.fort = getXmlText(xmlPuller, "fort"); + }else if(xmlPuller.getName().toLowerCase().equals("hash")){ + team.hash = getXmlText(xmlPuller, "hash"); + }else if(xmlPuller.getName().toLowerCase().equals("hog")){ + state = STATE_HOG_ROOT; + }else throwException(xmlPuller.getName(), eventType); + }else if(eventType == XmlPullParser.END_TAG) state = STATE_START; + else throwException(xmlPuller.getText(), eventType); + break; + case STATE_HOG_ROOT: + if(eventType == XmlPullParser.START_TAG){ + if(xmlPuller.getName().toLowerCase().equals("name")){ + team.hogNames[hogCounter] = getXmlText(xmlPuller, "name"); + }else if(xmlPuller.getName().toLowerCase().equals("hat")){ + team.hats[hogCounter] = getXmlText(xmlPuller, "hat"); + }else if(xmlPuller.getName().toLowerCase().equals("level")){ + team.levels[hogCounter] = Integer.parseInt(getXmlText(xmlPuller, "level")); + }else throwException(xmlPuller.getText(), eventType); + }else if(eventType == XmlPullParser.END_TAG){ + hogCounter++; + state = STATE_ROOT; + }else throwException(xmlPuller.getText(), eventType); + break; + } + eventType = getEventType(xmlPuller); + }//end while(eventtype != END_DOCUMENT + return team; + } catch (NumberFormatException e){ + e.printStackTrace(); + } catch (XmlPullParserException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + private static String getXmlText(XmlPullParser xmlPuller, String parentTag)throws XmlPullParserException, IOException{ + if(getEventType(xmlPuller) == XmlPullParser.TEXT){ + String txt = xmlPuller.getText(); + if(getEventType(xmlPuller) == XmlPullParser.END_TAG && xmlPuller.getName().toLowerCase().equals(parentTag)){ + return txt; + } + } + throw new XmlPullParserException("malformed xml file on string read from tag: " + parentTag); + } + + /** + * Skips whitespaces.. + */ + private static int getEventType(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{ + int eventType = xmlPuller.next(); + while(eventType == XmlPullParser.TEXT && xmlPuller.isWhitespace()){ + eventType = xmlPuller.next(); + } + return eventType; + } + + private static void throwException(String file, int eventType){ + throw new IllegalArgumentException(String.format("Xml file: %s malformed with error: %d.", file, eventType)); + } + + public void writeToXml(OutputStream os){ + XmlSerializer serializer = Xml.newSerializer(); + try{ + serializer.setOutput(os, "UTF-8"); + serializer.startDocument("UTF-8", true); + serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); + + serializer.startTag(null, "team"); + serializer.startTag(null, "name"); + serializer.text(name); + serializer.endTag(null, "name"); + serializer.startTag(null, "flag"); + serializer.text(flag); + serializer.endTag(null, "flag"); + serializer.startTag(null, "fort"); + serializer.text(fort); + serializer.endTag(null, "fort"); + serializer.startTag(null, "grave"); + serializer.text(grave); + serializer.endTag(null, "grave"); + serializer.startTag(null, "voice"); + serializer.text(voice); + serializer.endTag(null, "voice"); + serializer.startTag(null, "hash"); + serializer.text(hash); + serializer.endTag(null, "hash"); + + for(int i = 0; i < maxNumberOfHogs; i++){ + serializer.startTag(null, "hog"); + serializer.startTag(null, "name"); + serializer.text(hogNames[i]); + serializer.endTag(null, "name"); + serializer.startTag(null, "hat"); + serializer.text(hats[i]); + serializer.endTag(null, "hat"); + serializer.startTag(null, "level"); + serializer.text(String.valueOf(levels[i])); + serializer.endTag(null, "level"); + + serializer.endTag(null, "hog"); + } + serializer.endTag(null, "team"); + serializer.endDocument(); + serializer.flush(); + + } catch (IOException e) { + e.printStackTrace(); + }finally{ + try { + os.close(); + } catch (IOException e) {} + } + } + /* + * END XML METHODS + */ + + + + /* + * PARCABLE METHODS + */ + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(name); + dest.writeString(grave); + dest.writeString(flag); + dest.writeString(voice); + dest.writeString(fort); + dest.writeString(hash); + dest.writeStringArray(hats); + dest.writeStringArray(hogNames); + dest.writeIntArray(levels); + dest.writeInt(color); + dest.writeInt(hogCount); + dest.writeString(file); + } + + + public void readFromParcel(Parcel src){ + name = src.readString(); + grave = src.readString(); + flag = src.readString(); + voice = src.readString(); + fort = src.readString(); + hash = src.readString(); + src.readStringArray(hats); + src.readStringArray(hogNames); + src.readIntArray(levels); + color = src.readInt(); + hogCount = src.readInt(); + file = src.readString(); + } + + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public Team createFromParcel(Parcel source) { + return new Team(source); + } + public Team[] newArray(int size) { + return new Team[size]; + } + + }; + + /* + * END PARCABLE METHODS + */ + +} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Weapon.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Weapon.java Sat Dec 03 19:18:13 2011 +0100 @@ -0,0 +1,217 @@ +/* + * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game + * Copyright (c) 2011 Richard Deurwaarder + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +package org.hedgewars.hedgeroid.Datastructures; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; + +import org.hedgewars.hedgeroid.EngineProtocol.EngineProtocolNetwork; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlPullParserFactory; + +import android.content.Context; +import android.os.Parcel; +import android.os.Parcelable; + +public class Weapon implements Parcelable, Comparable{ + + public static final String DIRECTORY_WEAPON = "weapons"; + + private String name; + private String QT; + private String prob; + private String delay; + private String crate; + private static int maxWeapons; + + static{ + //maxWeapons = PascalExports.HWgetNumberOfWeapons(); + } + + public Weapon(String _name, String _QT, String _prob, String _delay, String _crate){ + name = _name; + + //Incase there's a newer ammoStore which is bigger we append with zeros + StringBuffer sb = new StringBuffer(); + while(_QT.length() + sb.length() < maxWeapons){ + sb.append('0'); + } + + QT = String.format("e%s %s%s", "ammloadt", _QT, sb); + prob = String.format("e%s %s%s", "ammprob", _prob, sb); + delay = String.format("e%s %s%s", "ammdelay", _delay, sb); + crate = String.format("e%s %s%s", "ammreinf", _crate, sb); + } + + public Weapon(Parcel in){ + readFromParcel(in); + } + + public String toString(){ + return name; + } + + public void sendToEngine(EngineProtocolNetwork epn, int teamsCount) throws IOException{ + epn.sendToEngine(QT);//command prefix is already in string + epn.sendToEngine(prob); + epn.sendToEngine(delay); + epn.sendToEngine(crate); + + for(int i = 0; i < teamsCount; i++){ + epn.sendToEngine("eammstore"); + } + } + + public static final int STATE_START = 0; + public static final int STATE_ROOT = 1; + public static final int STATE_NAME = 2; + public static final int STATE_QT = 3; + public static final int STATE_PROBABILITY = 4; + public static final int STATE_DELAY = 5; + public static final int STATE_CRATE = 6; + + public static ArrayList getWeapons(Context c) throws IllegalArgumentException{ + String dir = c.getFilesDir().getAbsolutePath() + '/' + DIRECTORY_WEAPON + '/'; + String[] files = new File(dir).list(); + if(files == null) files = new String[]{}; + + ArrayList weapons = new ArrayList(); + + try { + XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); + XmlPullParser xmlPuller = xmlPullFactory.newPullParser(); + + for(String file : files){ + BufferedReader br = new BufferedReader(new FileReader(dir + file), 1024); + xmlPuller.setInput(br); + String name = null; + String qt = null; + String prob = null; + String delay = null; + String crate = null; + + int eventType = xmlPuller.getEventType(); + int state = STATE_START; + while(eventType != XmlPullParser.END_DOCUMENT){ + switch(state){ + case STATE_START: + if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().equals("weapon")) state = STATE_ROOT; + else if(eventType != XmlPullParser.START_DOCUMENT) throwException(file, eventType); + break; + case STATE_ROOT: + if(eventType == XmlPullParser.START_TAG){ + if(xmlPuller.getName().toLowerCase().equals("qt")) state = STATE_QT; + else if(xmlPuller.getName().toLowerCase().equals("name")) state = STATE_NAME; + else if(xmlPuller.getName().toLowerCase().equals("probability")) state = STATE_PROBABILITY; + else if(xmlPuller.getName().toLowerCase().equals("delay")) state = STATE_DELAY; + else if(xmlPuller.getName().toLowerCase().equals("crate")) state = STATE_CRATE; + else throwException(file, eventType); + }else if(eventType == XmlPullParser.END_TAG) state = STATE_START; + else throwException(xmlPuller.getText(), eventType); + break; + case STATE_NAME: + if(eventType == XmlPullParser.TEXT) name = xmlPuller.getText().trim(); + else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; + else throwException(file, eventType); + break; + case STATE_QT: + if(eventType == XmlPullParser.TEXT) qt = xmlPuller.getText().trim(); + else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; + else throwException(file, eventType); + break; + case STATE_PROBABILITY: + if(eventType == XmlPullParser.TEXT) prob = xmlPuller.getText().trim(); + else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; + else throwException(file, eventType); + break; + case STATE_DELAY: + if(eventType == XmlPullParser.TEXT) delay = xmlPuller.getText().trim(); + else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; + else throwException(file, eventType); + break; + case STATE_CRATE: + if(eventType == XmlPullParser.TEXT) crate = xmlPuller.getText().trim(); + else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; + else throwException(file, eventType); + break; + } + eventType = xmlPuller.next(); + while(eventType == XmlPullParser.TEXT && xmlPuller.isWhitespace()){//Skip whitespaces + eventType = xmlPuller.next(); + } + }//end while(eventtype != END_DOCUMENT + weapons.add(new Weapon(name, qt, prob, delay, crate)); + }//end for(string file : files + return weapons; + + } catch (XmlPullParserException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return new ArrayList();//TODO handle correctly + } + + private static void throwException(String file, int eventType){ + throw new IllegalArgumentException(String.format("Xml file: %s malformed with eventType: %d.", file, eventType)); + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(name); + dest.writeString(QT); + dest.writeString(prob); + dest.writeString(delay); + dest.writeString(crate); + } + + private void readFromParcel(Parcel src){ + name = src.readString(); + QT = src.readString(); + prob = src.readString(); + delay = src.readString(); + crate = src.readString(); + } + + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public Weapon createFromParcel(Parcel source) { + return new Weapon(source); + } + public Weapon[] newArray(int size) { + return new Weapon[size]; + } + + }; + + public int compareTo(Weapon another) { + return name.compareTo(another.name); + } + + +} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/FrontendDataUtils.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/FrontendDataUtils.java Sat Dec 03 19:09:24 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,216 +0,0 @@ -/* - * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Richard Deurwaarder - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - - -package org.hedgewars.hedgeroid.EngineProtocol; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.hedgewars.hedgeroid.R; -import org.hedgewars.hedgeroid.Utils; -import org.hedgewars.hedgeroid.EngineProtocol.Map.MapType; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; - -public class FrontendDataUtils { - - - public static ArrayList getMaps(Context c){ - File[] files = Utils.getFilesFromRelativeDir(c,"Maps"); - ArrayList ret = new ArrayList(); - - for(File f : files){ - if(Utils.hasFileWithSuffix(f, ".lua")){ - ret.add(new Map(f,MapType.TYPE_MISSION, c)); - }else{ - ret.add(new Map(f, MapType.TYPE_DEFAULT,c)); - } - } - Collections.sort(ret); - - return ret; - } - - public static List getGameplay(Context c){ - String[] files = Utils.getFileNamesFromRelativeDir(c, "Scripts/Multiplayer"); - ArrayList ret = new ArrayList(); - - for(int i = 0; i < files.length; i++){ - if(files[i].endsWith(".lua")){ - ret.add(files[i].replace('_', ' ').substring(0, files[i].length()-4)); //replace _ by a space and removed the last four characters (.lua) - } - } - ret.add(0,"None"); - Collections.sort(ret); - return ret; - } - - public static List getThemes(Context c){ - List list = Utils.getDirsWithFileSuffix(c, "Themes", "icon.png"); - Collections.sort(list); - return list; - } - - public static List getSchemes(Context c){ - List list = Scheme.getSchemes(c); - Collections.sort(list); - return list; - } - - public static List getWeapons(Context c){ - List list = Weapon.getWeapons(c); - Collections.sort(list); - return list; - } - - public static ArrayList> getGraves(Context c){ - String pathPrefix = Utils.getDataPath(c) + "Graphics/Graves/"; - ArrayList names = Utils.getFilesFromDirWithSuffix(c,"Graphics/Graves", ".png", true); - ArrayList> data = new ArrayList>(names.size()); - - for(String s : names){ - HashMap map = new HashMap(); - map.put("txt", s); - Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap - int width = b.getWidth(); - if(b.getHeight() > width){//some pictures contain more 'frames' underneath each other, if so we only use the first frame - Bitmap tmp = Bitmap.createBitmap(b, 0, 0, width, width); - b.recycle(); - b = tmp; - } - map.put("img", b); - data.add(map); - } - return data; - } - - public static ArrayList> getFlags(Context c){ - String pathPrefix = Utils.getDataPath(c) + "Graphics/Flags/"; - ArrayList names = Utils.getFilesFromDirWithSuffix(c, "Graphics/Flags", ".png", true); - ArrayList> data = new ArrayList>(names.size()); - - for(String s : names){ - HashMap map = new HashMap(); - map.put("txt", s); - Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap - map.put("img", b); - data.add(map); - } - return data; - } - - public static ArrayList getVoices(Context c){ - File[] files = Utils.getFilesFromRelativeDir(c, "Sounds/voices"); - ArrayList ret = new ArrayList(); - - for(File f : files){ - if(f.isDirectory()) ret.add(f.getName()); - } - return ret; - } - - public static ArrayList getForts(Context c){ - return Utils.getFilesFromDirWithSuffix(c,"Forts", "L.png", true); - } - public static ArrayList> getTypes(Context c){ - ArrayList> data = new ArrayList>(6); - String[] levels = {c.getString(R.string.human), c.getString(R.string.bot5), c.getString(R.string.bot4), c.getString(R.string.bot3), c.getString(R.string.bot2), c.getString(R.string.bot1)}; - int[] images = {R.drawable.human, R.drawable.bot5, R.drawable.bot4, R.drawable.bot3, R.drawable.bot2, R.drawable.bot1}; - - for(int i = 0; i < levels.length; i++){ - HashMap map = new HashMap(); - map.put("txt", levels[i]); - map.put("img", images[i]); - data.add(map); - } - - return data; - } - - public static ArrayList> getHats(Context c){ - ArrayList files = Utils.getFilesFromDirWithSuffix(c,"Graphics/Hats", ".png", true); - String pathPrefix = Utils.getDataPath(c) + "Graphics/Hats/"; - int size = files.size(); - ArrayList> data = new ArrayList>(size); - - HashMap hashmap; - for(String s : files){ - hashmap = new HashMap(); - hashmap.put("txt", s); - Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap - b = Bitmap.createBitmap(b, 0,0,b.getWidth()/2, b.getWidth()/2); - hashmap.put("img", b); - data.add(hashmap); - } - - return data; - } - - public static List> getTeams(Context c){ - List> ret = new ArrayList>(); - - File teamsDir = new File(c.getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS); - File[] teamFileNames = teamsDir.listFiles(); - if(teamFileNames != null){ - for(File s : teamFileNames){ - Team t = Team.getTeamFromXml(s.getAbsolutePath()); - if(t != null){ - t.file = s.getName(); - ret.add(teamToMap(t)); - } - } - } - return ret; - } - - public static HashMap teamToMap(Team t){ - HashMap hashmap = new HashMap(); - hashmap.put("team", t); - hashmap.put("txt", t.name); - hashmap.put("color", t.color); - hashmap.put("count", t.hogCount); - switch(t.levels[0]){ - case 0: - hashmap.put("img", R.drawable.human); - break; - case 1: - hashmap.put("img", R.drawable.bot5); - break; - case 2: - hashmap.put("img", R.drawable.bot4); - break; - case 3: - hashmap.put("img", R.drawable.bot3); - break; - case 4: - hashmap.put("img", R.drawable.bot2); - break; - default: - case 5: - hashmap.put("img", R.drawable.bot1); - break; - } - return hashmap; - } -} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/GameConfig.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/GameConfig.java Sat Dec 03 19:09:24 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/GameConfig.java Sat Dec 03 19:18:13 2011 +0100 @@ -22,6 +22,12 @@ import java.util.ArrayList; import java.util.UUID; +import org.hedgewars.hedgeroid.Datastructures.GameMode; +import org.hedgewars.hedgeroid.Datastructures.Map; +import org.hedgewars.hedgeroid.Datastructures.Scheme; +import org.hedgewars.hedgeroid.Datastructures.Team; +import org.hedgewars.hedgeroid.Datastructures.Weapon; + import android.os.Parcel; import android.os.Parcelable; import android.util.Log; diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/GameMode.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/GameMode.java Sat Dec 03 19:09:24 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* - * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Richard Deurwaarder - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - - -package org.hedgewars.hedgeroid.EngineProtocol; - -public enum GameMode { - MODE_LOCAL, MODE_DEMO, MODE_NET, MODE_SAVE -} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Grave.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Grave.java Sat Dec 03 19:09:24 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Richard Deurwaarder - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - - -package org.hedgewars.hedgeroid.EngineProtocol; - -public class Grave{ - - public final String name; - public final String path; - - public Grave(String _name, String _path) { - name = _name; - path = _path; - } - - public String toString(){ - return name; - } - -} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Map.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Map.java Sat Dec 03 19:09:24 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -/* - * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Richard Deurwaarder - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -package org.hedgewars.hedgeroid.EngineProtocol; - -import java.io.File; -import java.io.IOException; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.os.Parcel; -import android.os.Parcelable; - -public class Map implements Comparable, Parcelable{ - - private static final String MISSION_PREFIX = "Mission: "; - - private String name; - private String path; - private String previewPath; - private MapType type; - - public Map(File mapDir, MapType _type, Context c){ - type = _type; - - name = mapDir.getName(); - path = mapDir.getAbsolutePath(); - previewPath = path + "/preview.png"; - - /*switch(type){ - case TYPE_DEFAULT: - - break; - case TYPE_GENERATED: - //TODO - break; - case TYPE_MISSION: - name = MISSION_PREFIX + mapDir.getName(); - path = mapDir.getAbsolutePath(); - break; - }*/ - - - } - - public Map(Parcel in){ - readFromParcel(in); - } - - public String toString(){ - switch(type){ - default: - case TYPE_DEFAULT: - return name; - case TYPE_GENERATED: - return "bla"; - case TYPE_MISSION: - return MISSION_PREFIX + name; - } - } - - public void sendToEngine(EngineProtocolNetwork epn) throws IOException{ - epn.sendToEngine(String.format("emap %s",name)); - } - - public MapType getType(){ - return type; - } - - public Drawable getDrawable(){ - switch(type){ - case TYPE_MISSION: - case TYPE_DEFAULT: - return Drawable.createFromPath(previewPath); - case TYPE_GENERATED: - - default: - return null; - } - } - - public int compareTo(Map another) { - switch(type){ - case TYPE_GENERATED: - switch(another.getType()){ - case TYPE_GENERATED: - return name.compareTo(another.name); - case TYPE_MISSION: - return -1; - case TYPE_DEFAULT: - return -1; - } - case TYPE_MISSION: - switch(another.getType()){ - case TYPE_GENERATED: - return 1; - case TYPE_MISSION: - return name.compareTo(another.name); - case TYPE_DEFAULT: - return -1; - } - case TYPE_DEFAULT: - switch(another.getType()){ - case TYPE_GENERATED: - return 1; - case TYPE_MISSION: - return 1; - case TYPE_DEFAULT: - return name.compareTo(another.name); - } - } - return 0;//default case this should never happen - } - - public enum MapType{ - TYPE_DEFAULT, TYPE_MISSION, TYPE_GENERATED - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(name); - dest.writeString(path); - dest.writeString(previewPath); - dest.writeString(type.name()); - } - - private void readFromParcel(Parcel src){ - name = src.readString(); - path = src.readString(); - previewPath = src.readString(); - type = MapType.valueOf(src.readString()); - } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public Map createFromParcel(Parcel source) { - return new Map(source); - } - public Map[] newArray(int size) { - return new Map[size]; - } - - }; -} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Scheme.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Scheme.java Sat Dec 03 19:09:24 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,359 +0,0 @@ -/* - * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Richard Deurwaarder - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -package org.hedgewars.hedgeroid.EngineProtocol; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashMap; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; - -import android.content.Context; -import android.os.Parcel; -import android.os.Parcelable; - -public class Scheme implements Parcelable, Comparable{ - - public static final String DIRECTORY_SCHEME = "schemes"; - - private String name; - //private ArrayList basic; - private Integer gamemod; - private ArrayList basic;; - private static ArrayList> basicflags = new ArrayList>();//TODO why is it static? - - public Scheme(String _name, ArrayList _basic, int _gamemod){ - name = _name; - gamemod = _gamemod; - basic = _basic; - } - - public Scheme(Parcel in){ - readFromParcel(in); - } - - public void sendToEngine(EngineProtocolNetwork epn)throws IOException{ - epn.sendToEngine(String.format("e$gmflags %d", gamemod)); - - for(int pos = 0; pos < basic.size(); pos++){ - LinkedHashMap basicflag = basicflags.get(pos); - - String command = (String)basicflag.get("command"); - Integer value = basic.get(pos); - Boolean checkOverMax = (Boolean) basicflag.get("checkOverMax"); - Boolean times1000 = (Boolean) basicflag.get("times1000"); - Integer max = (Integer) basicflag.get("max"); - - if(checkOverMax && value >= max) value = max; - if(times1000) value *= 1000; - - epn.sendToEngine(String.format("%s %d", command, value)); - } - } - public String toString(){ - return name; - } - - - public static final int STATE_START = 0; - public static final int STATE_ROOT = 1; - public static final int STATE_NAME = 2; - public static final int STATE_BASICFLAGS = 3; - public static final int STATE_GAMEMOD = 4; - public static final int STATE_BASICFLAG_INTEGER = 5; - public static final int STATE_GAMEMOD_TRUE = 6; - public static final int STATE_GAMEMOD_FALSE = 7; - - public static ArrayList getSchemes(Context c) throws IllegalArgumentException{ - String dir = c.getFilesDir().getAbsolutePath() + '/' + DIRECTORY_SCHEME + '/'; - String[] files = new File(dir).list(fnf); - if(files == null) files = new String[]{}; - Arrays.sort(files); - ArrayList schemes = new ArrayList(); - - try { - XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); - XmlPullParser xmlPuller = xmlPullFactory.newPullParser(); - - for(String file : files){ - BufferedReader br = new BufferedReader(new FileReader(dir + file), 1024); - xmlPuller.setInput(br); - String name = null; - ArrayList basic = new ArrayList(); - Integer gamemod = 0; - int mask = 0x000000004; - - int eventType = xmlPuller.getEventType(); - int state = STATE_START; - while(eventType != XmlPullParser.END_DOCUMENT){ - switch(state){ - case STATE_START: - if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().equals("scheme")) state = STATE_ROOT; - else if(eventType != XmlPullParser.START_DOCUMENT) throwException(file, eventType); - break; - case STATE_ROOT: - if(eventType == XmlPullParser.START_TAG){ - if(xmlPuller.getName().equals("basicflags")) state = STATE_BASICFLAGS; - else if(xmlPuller.getName().toLowerCase().equals("gamemod")) state = STATE_GAMEMOD; - else if(xmlPuller.getName().toLowerCase().equals("name")) state = STATE_NAME; - else throwException(file, eventType); - }else if(eventType == XmlPullParser.END_TAG) state = STATE_START; - else throwException(xmlPuller.getText(), eventType); - break; - case STATE_BASICFLAGS: - if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().toLowerCase().equals("integer")) state = STATE_BASICFLAG_INTEGER; - else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_GAMEMOD: - if(eventType == XmlPullParser.START_TAG){ - if(xmlPuller.getName().toLowerCase().equals("true")) state = STATE_GAMEMOD_TRUE; - else if(xmlPuller.getName().toLowerCase().equals("false")) state = STATE_GAMEMOD_FALSE; - else throwException(file, eventType); - }else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_NAME: - if(eventType == XmlPullParser.TEXT) name = xmlPuller.getText().trim(); - else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_BASICFLAG_INTEGER: - if(eventType == XmlPullParser.TEXT) basic.add(Integer.parseInt(xmlPuller.getText().trim())); - else if(eventType == XmlPullParser.END_TAG) state = STATE_BASICFLAGS; - else throwException(file, eventType); - break; - case STATE_GAMEMOD_FALSE: - if(eventType == XmlPullParser.TEXT) gamemod <<= 1; - else if(eventType == XmlPullParser.END_TAG) state = STATE_GAMEMOD; - else throwException(file, eventType); - break; - case STATE_GAMEMOD_TRUE: - if(eventType == XmlPullParser.TEXT){ - gamemod |= mask; - gamemod <<= 1; - }else if(eventType == XmlPullParser.END_TAG) state = STATE_GAMEMOD; - else throwException(file, eventType); - break; - } - eventType = getEventType(xmlPuller); - }//end while(eventtype != END_DOCUMENT - schemes.add(new Scheme(name, basic, gamemod)); - }//end for(string file : files - return schemes; - } catch (XmlPullParserException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return new ArrayList();//TODO handle correctly - } - - private static FilenameFilter fnf = new FilenameFilter(){ - public boolean accept(File dir, String filename) { - return filename.toLowerCase().startsWith("scheme_"); - } - }; - - /** - * This method will parse the basic flags from a prespecified xml file. - * I use a raw xml file rather than one parsed by aatp at compile time - * to keep it generic with other frontends, ie in the future we could - * use one provided by the Data folder. - */ - public static void parseBasicFlags(Context c){ - String filename = String.format("%s/%s/basicflags", c.getFilesDir().getAbsolutePath(), DIRECTORY_SCHEME); - - XmlPullParser xmlPuller = null; - BufferedReader br = null; - try { - XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); - xmlPuller = xmlPullFactory.newPullParser(); - br = new BufferedReader(new FileReader(filename), 1024); - xmlPuller.setInput(br); - - int eventType = getEventType(xmlPuller); - boolean continueParsing = true; - do{ - switch(eventType){ - - case XmlPullParser.START_TAG: - if(xmlPuller.getName().toLowerCase().equals("flag")){ - basicflags.add(parseFlag(xmlPuller)); - }else if(xmlPuller.getName().toLowerCase().equals("basicflags")){ - eventType = getEventType(xmlPuller); - }else{ - skipCurrentTag(xmlPuller); - eventType = getEventType(xmlPuller); - } - break; - case XmlPullParser.START_DOCUMENT://ignore all tags not being "flag" - case XmlPullParser.END_TAG: - case XmlPullParser.TEXT: - default: - continueParsing = true; - case XmlPullParser.END_DOCUMENT: - continueParsing = false; - } - }while(continueParsing); - - }catch(IOException e){ - e.printStackTrace(); - }catch (XmlPullParserException e) { - e.printStackTrace(); - }finally{ - if(br != null) - try { - br.close(); - } catch (IOException e) {} - } - - } - - /* - * * Parses a Tag structure from xml as example we use - * - * - * false - * - * - * - * It returns a LinkedHashMap with key/value pairs - */ - private static LinkedHashMap parseFlag(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{ - LinkedHashMap hash = new LinkedHashMap(); - - int eventType = xmlPuller.getEventType();//Get the event type which triggered this method - if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().toLowerCase().equals("flag")){//valid start of flag tag - String lcKey = null; - String lcType = null; - String value = null; - - eventType = getEventType(xmlPuller);// - while(eventType == XmlPullParser.START_TAG){ - lcKey = xmlPuller.getName();//checkOverMax - if(getEventType(xmlPuller) == XmlPullParser.START_TAG){// - lcType = xmlPuller.getName().toLowerCase(); - if(getEventType(xmlPuller) == XmlPullParser.TEXT){ - value = xmlPuller.getText(); - if(getEventType(xmlPuller) == XmlPullParser.END_TAG && // - getEventType(xmlPuller) == XmlPullParser.END_TAG){// - if(lcType.equals("boolean")) hash.put(lcKey, new Boolean(value)); - else if(lcType.equals("string"))hash.put(lcKey, value); - else if(lcType.equals("integer")){ - try{ - hash.put(lcKey, new Integer(value)); - }catch (NumberFormatException e){ - throw new XmlPullParserException("Wrong integer value in xml file"); - } - }else{ - throwException("basicflags", eventType); - } - }// / - }//if TEXT - }//if boolean - eventType = getEventType(xmlPuller);//start new loop - } - eventType = getEventType(xmlPuller);// - } - - return hash; - } - - private static void skipCurrentTag(XmlPullParser xmlPuller) throws XmlPullParserException, IOException{ - int eventType = xmlPuller.getEventType(); - if(eventType != XmlPullParser.START_TAG)return; - String tag = xmlPuller.getName().toLowerCase(); - - while(true){ - eventType = getEventType(xmlPuller);//getNext() - switch(eventType){ - case XmlPullParser.START_DOCUMENT://we're inside of a start tag so START_ or END_DOCUMENT is just wrong - case XmlPullParser.END_DOCUMENT: - throw new XmlPullParserException("invalid xml file"); - case XmlPullParser.START_TAG://if we get a new tag recursively handle it - skipCurrentTag(xmlPuller); - break; - case XmlPullParser.TEXT: - break; - case XmlPullParser.END_TAG: - if(!xmlPuller.getName().toLowerCase().equals(tag)){//if the end tag doesn't match the start tag - throw new XmlPullParserException("invalid xml file"); - }else{ - return;//skip completed - } - - } - } - } - - /** - * Skips whitespaces.. - */ - private static int getEventType(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{ - int eventType = xmlPuller.next(); - while(eventType == XmlPullParser.TEXT && xmlPuller.isWhitespace()){ - eventType = xmlPuller.next(); - } - return eventType; - } - private static void throwException(String file, int eventType){ - throw new IllegalArgumentException(String.format("Xml file: %s malformed with error: %d.", file, eventType)); - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(name); - dest.writeInt(gamemod); - dest.writeList(basic); - } - - public void readFromParcel(Parcel src){ - name = src.readString(); - gamemod = src.readInt(); - basic = src.readArrayList(ArrayList.class.getClassLoader()); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public Scheme createFromParcel(Parcel source) { - return new Scheme(source); - } - public Scheme[] newArray(int size) { - return new Scheme[size]; - } - - }; - - public int compareTo(Scheme another) { - return name.compareTo(another.name); - } -} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Team.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Team.java Sat Dec 03 19:09:24 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,366 +0,0 @@ -/* - * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Richard Deurwaarder - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -package org.hedgewars.hedgeroid.EngineProtocol; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; -import org.xmlpull.v1.XmlSerializer; - -import android.content.Context; -import android.os.Parcel; -import android.os.Parcelable; -import android.util.Xml; - -public class Team implements Parcelable{ - - public static final String DIRECTORY_TEAMS = "teams"; - private static final Integer[] TEAM_COLORS = { - 0xd12b42, /* red */ - 0x4980c1, /* blue */ - 0x6ab530, /* green */ - 0xbc64c4, /* purple */ - 0xe76d14, /* orange */ - 0x3fb6e6, /* cyan */ - 0xe3e90c, /* yellow */ - 0x61d4ac, /* mint */ - 0xf1c3e1, /* pink */ - /* add new colors here */ - }; - -// private static final Integer[] TEAM_COLORS = { -// 0xff0000, /* red */ -// 0x00ff00, /* blue */ -// 0x0000ff, /* green */ -// }; - - private static final int STATE_START = 0; - private static final int STATE_ROOT = 1; - private static final int STATE_HOG_ROOT = 2; - - public String name, grave, flag, voice, fort, hash; - public String file = null; - - public static int maxNumberOfHogs = 0; - public static int maxNumberOfTeams = 0; - - static{ - maxNumberOfHogs = PascalExports.HWgetMaxNumberOfHogs(); - maxNumberOfTeams = PascalExports.HWgetMaxNumberOfTeams(); - } - public String[] hats = new String[maxNumberOfHogs]; - public String[] hogNames = new String[maxNumberOfHogs]; - public int[] levels = new int[maxNumberOfHogs]; - - public int hogCount = 4; - public int color = TEAM_COLORS[0]; - - public Team(){ - } - - public Team(Parcel in){ - readFromParcel(in); - } - - public boolean equals(Object o){ - if(super.equals(o)) return true; - else if(o instanceof Team){ - Team t = (Team)o; - boolean ret = name.equals(t.name); - ret &= grave.equals(t.grave); - ret &= flag.equals(t.flag); - ret &= voice.equals(t.voice); - ret &= fort.equals(t.fort); - ret &= hash.equals(t.hash); - return ret; - }else{ - return false; - } - } - - public void setRandomColor(int[] illegalcolors){ - Integer[] colorsToPickFrom = TEAM_COLORS; - if(illegalcolors != null){ - ArrayList colors = new ArrayList(); - for(int color : TEAM_COLORS){ - boolean validColor = true; - for(int illegal : illegalcolors){ - if(color == illegal) validColor = false; - } - if(validColor) colors.add(color); - } - if(colors.size() != 0) colorsToPickFrom = colors.toArray(new Integer[1]); - } - int index = (int)Math.round(Math.random()*(colorsToPickFrom.length-1)); - color = colorsToPickFrom[index]; - } - - - public void sendToEngine(EngineProtocolNetwork epn, int hogCount, int health) throws IOException{ - epn.sendToEngine(String.format("eaddteam %s %d %s", hash, color, name)); - epn.sendToEngine(String.format("egrave %s", grave)); - epn.sendToEngine(String.format("efort %s", fort)); - epn.sendToEngine(String.format("evoicepack %s", voice)); - epn.sendToEngine(String.format("eflag %s", flag)); - - for(int i = 0; i < hogCount; i++){ - epn.sendToEngine(String.format("eaddhh %d %d %s", levels[i], health, hogNames[i])); - epn.sendToEngine(String.format("ehat %s", hats[i])); - } - } - - public void setFileName(Context c){ - if(file == null){ - file = validFileName(c, name); - } - } - private String validFileName(Context c, String fileName){ - String absolutePath = String.format("%s/%s", c.getFilesDir(), fileName); - File f = new File(absolutePath); - if(f.exists()){ - String newFileName = fileName + (int)(Math.random()*10); - return validFileName(c, newFileName); - }else{ - return fileName; - } - } - - /* - * XML METHODS - */ - - /** - * Read the xml file path and convert it to a Team object - * @param path absolute path to the xml file - * @return - */ - public static Team getTeamFromXml(String path){ - try { - XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); - XmlPullParser xmlPuller = xmlPullFactory.newPullParser(); - - BufferedReader br = new BufferedReader(new FileReader(path), 1024); - xmlPuller.setInput(br); - Team team = new Team(); - int hogCounter = 0; - - int eventType = xmlPuller.getEventType(); - int state = STATE_START; - while(eventType != XmlPullParser.END_DOCUMENT){ - switch(state){ - case STATE_START: - if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().equals("team")) state = STATE_ROOT; - else if(eventType != XmlPullParser.START_DOCUMENT) throwException(path, eventType); - break; - case STATE_ROOT: - if(eventType == XmlPullParser.START_TAG){ - if(xmlPuller.getName().toLowerCase().equals("name")){ - team.name = getXmlText(xmlPuller, "name"); - }else if(xmlPuller.getName().toLowerCase().equals("flag")){ - team.flag= getXmlText(xmlPuller, "flag"); - }else if(xmlPuller.getName().toLowerCase().equals("voice")){ - team.voice = getXmlText(xmlPuller, "voice"); - }else if(xmlPuller.getName().toLowerCase().equals("grave")){ - team.grave = getXmlText(xmlPuller, "grave"); - }else if(xmlPuller.getName().toLowerCase().equals("fort")){ - team.fort = getXmlText(xmlPuller, "fort"); - }else if(xmlPuller.getName().toLowerCase().equals("hash")){ - team.hash = getXmlText(xmlPuller, "hash"); - }else if(xmlPuller.getName().toLowerCase().equals("hog")){ - state = STATE_HOG_ROOT; - }else throwException(xmlPuller.getName(), eventType); - }else if(eventType == XmlPullParser.END_TAG) state = STATE_START; - else throwException(xmlPuller.getText(), eventType); - break; - case STATE_HOG_ROOT: - if(eventType == XmlPullParser.START_TAG){ - if(xmlPuller.getName().toLowerCase().equals("name")){ - team.hogNames[hogCounter] = getXmlText(xmlPuller, "name"); - }else if(xmlPuller.getName().toLowerCase().equals("hat")){ - team.hats[hogCounter] = getXmlText(xmlPuller, "hat"); - }else if(xmlPuller.getName().toLowerCase().equals("level")){ - team.levels[hogCounter] = Integer.parseInt(getXmlText(xmlPuller, "level")); - }else throwException(xmlPuller.getText(), eventType); - }else if(eventType == XmlPullParser.END_TAG){ - hogCounter++; - state = STATE_ROOT; - }else throwException(xmlPuller.getText(), eventType); - break; - } - eventType = getEventType(xmlPuller); - }//end while(eventtype != END_DOCUMENT - return team; - } catch (NumberFormatException e){ - e.printStackTrace(); - } catch (XmlPullParserException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } - - private static String getXmlText(XmlPullParser xmlPuller, String parentTag)throws XmlPullParserException, IOException{ - if(getEventType(xmlPuller) == XmlPullParser.TEXT){ - String txt = xmlPuller.getText(); - if(getEventType(xmlPuller) == XmlPullParser.END_TAG && xmlPuller.getName().toLowerCase().equals(parentTag)){ - return txt; - } - } - throw new XmlPullParserException("malformed xml file on string read from tag: " + parentTag); - } - - /** - * Skips whitespaces.. - */ - private static int getEventType(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{ - int eventType = xmlPuller.next(); - while(eventType == XmlPullParser.TEXT && xmlPuller.isWhitespace()){ - eventType = xmlPuller.next(); - } - return eventType; - } - - private static void throwException(String file, int eventType){ - throw new IllegalArgumentException(String.format("Xml file: %s malformed with error: %d.", file, eventType)); - } - - public void writeToXml(OutputStream os){ - XmlSerializer serializer = Xml.newSerializer(); - try{ - serializer.setOutput(os, "UTF-8"); - serializer.startDocument("UTF-8", true); - serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); - - serializer.startTag(null, "team"); - serializer.startTag(null, "name"); - serializer.text(name); - serializer.endTag(null, "name"); - serializer.startTag(null, "flag"); - serializer.text(flag); - serializer.endTag(null, "flag"); - serializer.startTag(null, "fort"); - serializer.text(fort); - serializer.endTag(null, "fort"); - serializer.startTag(null, "grave"); - serializer.text(grave); - serializer.endTag(null, "grave"); - serializer.startTag(null, "voice"); - serializer.text(voice); - serializer.endTag(null, "voice"); - serializer.startTag(null, "hash"); - serializer.text(hash); - serializer.endTag(null, "hash"); - - for(int i = 0; i < maxNumberOfHogs; i++){ - serializer.startTag(null, "hog"); - serializer.startTag(null, "name"); - serializer.text(hogNames[i]); - serializer.endTag(null, "name"); - serializer.startTag(null, "hat"); - serializer.text(hats[i]); - serializer.endTag(null, "hat"); - serializer.startTag(null, "level"); - serializer.text(String.valueOf(levels[i])); - serializer.endTag(null, "level"); - - serializer.endTag(null, "hog"); - } - serializer.endTag(null, "team"); - serializer.endDocument(); - serializer.flush(); - - } catch (IOException e) { - e.printStackTrace(); - }finally{ - try { - os.close(); - } catch (IOException e) {} - } - } - /* - * END XML METHODS - */ - - - - /* - * PARCABLE METHODS - */ - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(name); - dest.writeString(grave); - dest.writeString(flag); - dest.writeString(voice); - dest.writeString(fort); - dest.writeString(hash); - dest.writeStringArray(hats); - dest.writeStringArray(hogNames); - dest.writeIntArray(levels); - dest.writeInt(color); - dest.writeInt(hogCount); - dest.writeString(file); - } - - - public void readFromParcel(Parcel src){ - name = src.readString(); - grave = src.readString(); - flag = src.readString(); - voice = src.readString(); - fort = src.readString(); - hash = src.readString(); - src.readStringArray(hats); - src.readStringArray(hogNames); - src.readIntArray(levels); - color = src.readInt(); - hogCount = src.readInt(); - file = src.readString(); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public Team createFromParcel(Parcel source) { - return new Team(source); - } - public Team[] newArray(int size) { - return new Team[size]; - } - - }; - - /* - * END PARCABLE METHODS - */ - -} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Weapon.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/Weapon.java Sat Dec 03 19:09:24 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,217 +0,0 @@ -/* - * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Richard Deurwaarder - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -package org.hedgewars.hedgeroid.EngineProtocol; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; - -import android.content.Context; -import android.os.Parcel; -import android.os.Parcelable; -import android.util.Log; - -public class Weapon implements Parcelable, Comparable{ - - public static final String DIRECTORY_WEAPON = "weapons"; - - private String name; - private String QT; - private String prob; - private String delay; - private String crate; - private static int maxWeapons; - - static{ - //maxWeapons = PascalExports.HWgetNumberOfWeapons(); - } - - public Weapon(String _name, String _QT, String _prob, String _delay, String _crate){ - name = _name; - - //Incase there's a newer ammoStore which is bigger we append with zeros - StringBuffer sb = new StringBuffer(); - while(_QT.length() + sb.length() < maxWeapons){ - sb.append('0'); - } - - QT = String.format("e%s %s%s", "ammloadt", _QT, sb); - prob = String.format("e%s %s%s", "ammprob", _prob, sb); - delay = String.format("e%s %s%s", "ammdelay", _delay, sb); - crate = String.format("e%s %s%s", "ammreinf", _crate, sb); - } - - public Weapon(Parcel in){ - readFromParcel(in); - } - - public String toString(){ - return name; - } - - public void sendToEngine(EngineProtocolNetwork epn, int teamsCount) throws IOException{ - epn.sendToEngine(QT);//command prefix is already in string - epn.sendToEngine(prob); - epn.sendToEngine(delay); - epn.sendToEngine(crate); - - for(int i = 0; i < teamsCount; i++){ - epn.sendToEngine("eammstore"); - } - } - - public static final int STATE_START = 0; - public static final int STATE_ROOT = 1; - public static final int STATE_NAME = 2; - public static final int STATE_QT = 3; - public static final int STATE_PROBABILITY = 4; - public static final int STATE_DELAY = 5; - public static final int STATE_CRATE = 6; - - public static ArrayList getWeapons(Context c) throws IllegalArgumentException{ - String dir = c.getFilesDir().getAbsolutePath() + '/' + DIRECTORY_WEAPON + '/'; - String[] files = new File(dir).list(); - if(files == null) files = new String[]{}; - - ArrayList weapons = new ArrayList(); - - try { - XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); - XmlPullParser xmlPuller = xmlPullFactory.newPullParser(); - - for(String file : files){ - BufferedReader br = new BufferedReader(new FileReader(dir + file), 1024); - xmlPuller.setInput(br); - String name = null; - String qt = null; - String prob = null; - String delay = null; - String crate = null; - - int eventType = xmlPuller.getEventType(); - int state = STATE_START; - while(eventType != XmlPullParser.END_DOCUMENT){ - switch(state){ - case STATE_START: - if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().equals("weapon")) state = STATE_ROOT; - else if(eventType != XmlPullParser.START_DOCUMENT) throwException(file, eventType); - break; - case STATE_ROOT: - if(eventType == XmlPullParser.START_TAG){ - if(xmlPuller.getName().toLowerCase().equals("qt")) state = STATE_QT; - else if(xmlPuller.getName().toLowerCase().equals("name")) state = STATE_NAME; - else if(xmlPuller.getName().toLowerCase().equals("probability")) state = STATE_PROBABILITY; - else if(xmlPuller.getName().toLowerCase().equals("delay")) state = STATE_DELAY; - else if(xmlPuller.getName().toLowerCase().equals("crate")) state = STATE_CRATE; - else throwException(file, eventType); - }else if(eventType == XmlPullParser.END_TAG) state = STATE_START; - else throwException(xmlPuller.getText(), eventType); - break; - case STATE_NAME: - if(eventType == XmlPullParser.TEXT) name = xmlPuller.getText().trim(); - else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_QT: - if(eventType == XmlPullParser.TEXT) qt = xmlPuller.getText().trim(); - else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_PROBABILITY: - if(eventType == XmlPullParser.TEXT) prob = xmlPuller.getText().trim(); - else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_DELAY: - if(eventType == XmlPullParser.TEXT) delay = xmlPuller.getText().trim(); - else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_CRATE: - if(eventType == XmlPullParser.TEXT) crate = xmlPuller.getText().trim(); - else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - } - eventType = xmlPuller.next(); - while(eventType == XmlPullParser.TEXT && xmlPuller.isWhitespace()){//Skip whitespaces - eventType = xmlPuller.next(); - } - }//end while(eventtype != END_DOCUMENT - weapons.add(new Weapon(name, qt, prob, delay, crate)); - }//end for(string file : files - return weapons; - - } catch (XmlPullParserException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return new ArrayList();//TODO handle correctly - } - - private static void throwException(String file, int eventType){ - throw new IllegalArgumentException(String.format("Xml file: %s malformed with eventType: %d.", file, eventType)); - } - - public int describeContents() { - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(name); - dest.writeString(QT); - dest.writeString(prob); - dest.writeString(delay); - dest.writeString(crate); - } - - private void readFromParcel(Parcel src){ - name = src.readString(); - QT = src.readString(); - prob = src.readString(); - delay = src.readString(); - crate = src.readString(); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public Weapon createFromParcel(Parcel source) { - return new Weapon(source); - } - public Weapon[] newArray(int size) { - return new Weapon[size]; - } - - }; - - public int compareTo(Weapon another) { - return name.compareTo(another.name); - } - - -} diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/StartGameActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/StartGameActivity.java Sat Dec 03 19:09:24 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/StartGameActivity.java Sat Dec 03 19:18:13 2011 +0100 @@ -19,13 +19,13 @@ package org.hedgewars.hedgeroid; -import org.hedgewars.hedgeroid.EngineProtocol.FrontendDataUtils; +import org.hedgewars.hedgeroid.Datastructures.FrontendDataUtils; +import org.hedgewars.hedgeroid.Datastructures.Map; +import org.hedgewars.hedgeroid.Datastructures.Map.MapType; +import org.hedgewars.hedgeroid.Datastructures.Scheme; +import org.hedgewars.hedgeroid.Datastructures.Team; +import org.hedgewars.hedgeroid.Datastructures.Weapon; import org.hedgewars.hedgeroid.EngineProtocol.GameConfig; -import org.hedgewars.hedgeroid.EngineProtocol.Map; -import org.hedgewars.hedgeroid.EngineProtocol.Map.MapType; -import org.hedgewars.hedgeroid.EngineProtocol.Scheme; -import org.hedgewars.hedgeroid.EngineProtocol.Team; -import org.hedgewars.hedgeroid.EngineProtocol.Weapon; import android.app.Activity; import android.content.Intent; diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java Sat Dec 03 19:09:24 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java Sat Dec 03 19:18:13 2011 +0100 @@ -24,12 +24,11 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; -import org.hedgewars.hedgeroid.EngineProtocol.FrontendDataUtils; -import org.hedgewars.hedgeroid.EngineProtocol.Team; +import org.hedgewars.hedgeroid.Datastructures.FrontendDataUtils; +import org.hedgewars.hedgeroid.Datastructures.Team; import android.app.Activity; import android.graphics.Bitmap; diff -r bd3c736c1eac -r c356ddebab84 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamSelectionActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamSelectionActivity.java Sat Dec 03 19:09:24 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamSelectionActivity.java Sat Dec 03 19:18:13 2011 +0100 @@ -24,8 +24,8 @@ import java.util.HashMap; import java.util.List; -import org.hedgewars.hedgeroid.EngineProtocol.FrontendDataUtils; -import org.hedgewars.hedgeroid.EngineProtocol.Team; +import org.hedgewars.hedgeroid.Datastructures.FrontendDataUtils; +import org.hedgewars.hedgeroid.Datastructures.Team; import android.app.Activity; import android.content.Intent;