当前位置: 首页>>代码示例>>Java>>正文


Java XmlReader类代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.XmlReader的典型用法代码示例。如果您正苦于以下问题:Java XmlReader类的具体用法?Java XmlReader怎么用?Java XmlReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmlReader类属于com.badlogic.gdx.utils包,在下文中一共展示了XmlReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readAttr

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
private static void readAttr(Group parentGroup, XmlReader.Element element){
    if (element.getName().equals("Stage")){
        XmlUtils.parseGenAttr(parentGroup,element);
        if (element.getChildCount()>0){
            for (int i = 0;i<element.getChildCount();i++){
                readAttr(parentGroup,element.getChild(i));
            }
        }
    }else if (element.getName().equals("Group")){
        Group group = new Group();
        XmlUtils.parseGenAttr(group,element);
        parentGroup.addActor(group);
        if (element.getChildCount()>0){
            for (int i = 0;i<element.getChildCount();i++){
                readAttr(group,element.getChild(i));
            }
        }
    }else {
        Actor actor = getActorByName(element.getName());
        parentGroup.addActor(actor);
        XmlUtils.parseGenAttr(actor,element);
        XmlUtils.parseUqAttr(actor,element);
    }

}
 
开发者ID:whitecostume,项目名称:libgdx_ui_editor,代码行数:26,代码来源:XmlUtils.java

示例2: TiledObjectTypes

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
public TiledObjectTypes(String file) {
	xml_reader = new XmlReader();
	try {
		root = xml_reader.parse(Gdx.files.internal(file));
	} catch (IOException e) {
		e.printStackTrace();
	}
	types = new ObjectMap<String, TiledObjectTypes.TiledObjectType>();
	
	if(root == null)
		throw new GdxRuntimeException(String.format("Unable to parse file %s. make sure it is the correct path.", file));
	Array<Element> types = root.getChildrenByName("objecttype");
	for (Element element : types) {
		TiledObjectType tot = new TiledObjectType(element.get("name"));
		Array<Element> properties  = element.getChildrenByName("property");
		for (int i = 0; i < properties.size; i++) {
			Element element2 = properties.get(i);
			TypeProperty property = new TypeProperty(element2.get("name"), element2.get("type"), element2.hasAttribute("default")?element2.get("default"):"");
			tot.addProperty(property);
		}
		this.types.put(tot.name, tot);
	}
	
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:25,代码来源:TiledObjectTypes.java

示例3: awake

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
@Override
	public void awake() {
		if(skin == null) skin = new Skin(Gdx.files.internal(skinPath));
		XmlReader reader = new XmlReader();
		Element element = null;
		try {
			element = reader.parse(Gdx.files.internal(xmlPath));
		} catch (IOException e) {
			e.printStackTrace();
			return;
		}

		Table table = new Table(skin);
		rootActor = table;

		parseTable(element, table);
		addChildrens(element, table);
		actorsMap.put(table.getName(), table);

//		Gdx.app.log("JXmlUi", "Parsing complete");

		actorComponent = new ActorComponent();
		actorComponent.setActor(rootActor);
		addNativeComponent(actorComponent);
	}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:26,代码来源:JXmlUi.java

示例4: getOwnerCharacterName

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
private String getOwnerCharacterName() {
	if (ownerCharacterName == null && s_ownerCharacterId != null) {
		try {
			GameObject go = GameState.getGameObjectById(s_ownerCharacterId);
			if (go instanceof GameCharacter) {
				ownerCharacterName =  ((GameCharacter) go).getName();
			} else {
				XmlReader xmlReader = new XmlReader();
				Element root = xmlReader.parse(Gdx.files
						.internal(Configuration.getFolderCharacters()
								+ s_ownerCharacterId + ".xml"));
				ownerCharacterName = root.getChildByName(
						XMLUtil.XML_PROPERTIES).get(
						XMLUtil.XML_ATTRIBUTE_NAME);
			}
		} catch (SerializationException e) {
			throw new GdxRuntimeException("Could not determine the owner with type "+s_ownerCharacterId, e);
		}
		if (ownerCharacterName == null) {
			throw new GdxRuntimeException("Could not determine the owner with type "+s_ownerCharacterId);
		}
	}
	return Strings.getString(ownerCharacterName);
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:25,代码来源:ItemOwner.java

示例5: loadFromXMLNoInit

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
@Override
public void loadFromXMLNoInit(FileHandle file) throws IOException {
	XmlReader xmlReader = new XmlReader();
	Element root = xmlReader.parse(file);
	XMLUtil.handleImports(this, file, root);
	
	isModifier = root.getName().endsWith(MODIFIER_SUFFIX);
	XMLUtil.readPrimitiveMembers(this,
			root);
	createPools();
	Element weatherEffects = root.getChildByName(XML_WEATHER_EFFECTS);
	if (weatherEffects != null) {
		readAllSounds(weatherEffects.getChildByName(XML_RAIN), continuousSoundsRain, randomSoundsRain);
		readAllSounds(weatherEffects.getChildByName(XML_SNOW), continuousSoundsSnow, randomSoundsSnow);
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:17,代码来源:WeatherProfile.java

示例6: GameOptions

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
private GameOptions(final FileHandle file) throws IOException {
	final XmlReader xmlReader = new XmlReader();
	final Element root = xmlReader.parse(file);
	XMLUtil.readPrimitiveMembers(this, root);
	Element keyBindingsElement = root.getChildByName(XML_KEY_BINDINGS);
	if (keyBindingsElement != null) {
		for (int i = 0; i < keyBindingsElement.getChildCount(); ++i) {
			Element bindingElement = keyBindingsElement.getChild(i);
			KeyBindings binding = KeyBindings.valueOf(bindingElement.getName().toUpperCase(Locale.ENGLISH));
			binding.getKeys().clear();
			Array<Integer> newKeys = new Array<Integer>();
			if (bindingElement.getText() != null) {
				for (String key : bindingElement.getText().split(",")) {
					newKeys.add(Integer.valueOf(key));
				}
			}
			binding.getKeys().addAll(newKeys);
		}
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:21,代码来源:Configuration.java

示例7: getDependencies

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, ProjectileTypeParameter parameter) {
	XmlReader xmlReader = new XmlReader();
	try {
		Array<AssetDescriptor>  returnValue = new Array<AssetDescriptor>();
		Element root = xmlReader.parse(file);
		LoaderUtil.handleImports(this, parameter, returnValue, file, root);
		String animationFile = root.get(ProjectileType.XML_ANIMATION_FILE, null);
		if (animationFile != null) {
			returnValue.add(new AssetDescriptor<Texture>(Configuration.addModulePath(animationFile), Texture.class));
		}
		Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
		if (soundsElement != null) {
			addSoundDependency(soundsElement, ProjectileType.XML_ON_START, returnValue);
			addSoundDependency(soundsElement, ProjectileType.XML_ON_HIT, returnValue);
			addSoundDependency(soundsElement, ProjectileType.XML_DURING, returnValue);
		}
		if (returnValue.size > 0) {
			return returnValue;
		}
	} catch (IOException e) {
		throw new GdxRuntimeException(e);
	}
	return null;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:27,代码来源:ProjectileTypeLoader.java

示例8: getDependencies

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, WeatherProfileParameter parameter) {
	Array<AssetDescriptor> returnValue = new Array<AssetDescriptor>();
	try {
		XmlReader xmlReader = new XmlReader();
		Element root = xmlReader.parse(file);
		LoaderUtil.handleImports(this, parameter, returnValue, file, root);
		Array<Element> trackElements = root.getChildrenByNameRecursively(WeatherProfile.XML_TRACK);
		for (Element trackElement : trackElements) {
			String trackFileName = Configuration.addModulePath(trackElement.get(XMLUtil.XML_ATTRIBUTE_FILENAME));
			returnValue.add(new AssetDescriptor(trackFileName, WeatherProfile.XML_CONTINOUS.equalsIgnoreCase(trackElement.getParent().getName()) ? Music.class : Sound.class)); 
		}
	} catch (IOException e) {
		throw new GdxRuntimeException(e);
	}
	
	return returnValue;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:20,代码来源:WeatherProfileLoader.java

示例9: getDependencies

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, TrapParameter parameter) {
	XmlReader xmlReader = new XmlReader();
	try {
		Array<AssetDescriptor>  returnValue = new Array<AssetDescriptor>();
		Element root = xmlReader.parse(file);
		LoaderUtil.handleImports(this, parameter, returnValue, file, root);
		Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
		if (soundsElement != null) {
			addSoundDependency(soundsElement, TrapType.XML_DISARMED, returnValue);
			addSoundDependency(soundsElement, TrapType.XML_SPRUNG, returnValue);
		}
		if (returnValue.size > 0) {
			return returnValue;
		}
	} catch (IOException e) {
		throw new GdxRuntimeException(e);
	}
	return null;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:22,代码来源:TrapLoader.java

示例10: parseNonCLosing

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
/**
 * Parses the supplied InputStream without closing it at the end using the
 * supplied XmlReader.
 * 
 * @param inStream
 * @return
 */
public static Element parseNonCLosing(XmlReader parser, InputStream inStream) {
	try {
		InputStreamReader inReader = new InputStreamReader(inStream, "UTF-8");
		char[] data = new char[1024];
		int offset = 0;
		while (true) {
			int length = inReader.read(data, offset, data.length - offset);
			if (length == -1)
				break;
			if (length == 0) {
				char[] newData = new char[data.length * 2];
				System.arraycopy(data, 0, newData, 0, data.length);
				data = newData;
			} else
				offset += length;
		}
		return parser.parse(data, 0, offset);
	} catch (IOException ex) {
		throw new SerializationException(ex);
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:29,代码来源:XMLUtil.java

示例11: QuestManager

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
public QuestManager()
{
	XmlReader reader = new XmlReader();
	XmlReader.Element xml = null;

	try
	{
		xml = reader.parse( Gdx.files.internal( "Quests/QuestList.xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	for (int i = 0; i < xml.getChildCount(); i++)
	{
		XmlReader.Element questEl = xml.getChild( i );
		Quest quest = Quest.load( questEl.getText() );
		availableQuests.add( quest );
	}
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:22,代码来源:QuestManager.java

示例12: load

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
public static AbstractQuestInput load( XmlReader.Element xml )
{
	Class<AbstractQuestInput> c = ClassMap.get( xml.getName().toUpperCase() );
	AbstractQuestInput type = null;

	try
	{
		type = ClassReflection.newInstance( c );
	}
	catch ( Exception e )
	{
		System.err.println(xml.getName());
		e.printStackTrace();
	}

	type.parse( xml );

	return type;
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:20,代码来源:AbstractQuestInput.java

示例13: parse

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
public void parse( XmlReader.Element xml )
{
	key = xml.getName().toLowerCase();
	data = xml.get( "Data", "true" ).toLowerCase();
	runFlag = xml.getBooleanAttribute( "RunFlag", false );
	defer = xml.getBooleanAttribute( "Defer", true );

	XmlReader.Element conditionsElement = xml.getChildByName( "Conditions" );
	if (conditionsElement != null)
	{
		for (int i = 0; i < conditionsElement.getChildCount(); i++ )
		{
			XmlReader.Element conditionElement = conditionsElement.getChild( i );
			AbstractQuestOutputCondition condition = AbstractQuestOutputCondition.load( conditionElement );
			conditions.add( condition );
		}
	}
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:19,代码来源:QuestOutput.java

示例14: load

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
public static AbstractQuestOutputCondition load( XmlReader.Element xml )
{
	Class<AbstractQuestOutputCondition> c = ClassMap.get( xml.getName().toUpperCase() );
	AbstractQuestOutputCondition type = null;

	try
	{
		type = ClassReflection.newInstance( c );
	}
	catch ( Exception e )
	{
		System.err.println(xml.getName());
		e.printStackTrace();
	}

	type.parse( xml );

	return type;
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:20,代码来源:AbstractQuestOutputCondition.java

示例15: load

import com.badlogic.gdx.utils.XmlReader; //导入依赖的package包/类
public static Quest load(String name)
{
	Quest quest = new Quest();
	quest.path = name;

	XmlReader reader = new XmlReader();
	XmlReader.Element xml = null;

	try
	{
		xml = reader.parse( Gdx.files.internal( "Quests/" + name + ".xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	quest.parse( xml );

	return quest;
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:22,代码来源:Quest.java


注:本文中的com.badlogic.gdx.utils.XmlReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。