Java Code Examples for com.watabou.noosa.Game#reportException()

The following examples show how to use com.watabou.noosa.Game#reportException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BitmapCache.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static Pixmap get( String layerName, String assetName ) {
	
	Layer layer;
	if (!layers.containsKey( layerName )) {
		layer = new Layer();
		layers.put( layerName, layer );
	} else {
		layer = layers.get( layerName );
	}
	
	if (layer.containsKey( assetName )) {
		return layer.get( assetName );
	} else {
		
		try {
			Pixmap bmp = new Pixmap( Gdx.files.internal(assetName) );
			layer.put( assetName, bmp );
			return bmp;
		} catch (Exception e) {
			Game.reportException( e );
			return null;
		}
		
	}
}
 
Example 2
Source File: Bundle.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
public Class[] getClassArray( String key ) {
	try {
		JSONArray array = data.getJSONArray( key );
		int length = array.length();
		Class[] result = new Class[length];
		for (int i=0; i < length; i++) {
			String clName = array.getString( i ).replace("class ", "");
			if (aliases.containsKey( clName )) {
				clName = aliases.get( clName );
			}
			Class cl = Reflection.forName( clName );
			result[i] = cl;
		}
		return result;
	} catch (JSONException e) {
		Game.reportException(e);
		return null;
	}
}
 
Example 3
Source File: Bundle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public Collection<Bundlable> getCollection( String key ) {
	
	ArrayList<Bundlable> list = new ArrayList<>();
	
	try {
		JSONArray array = data.getJSONArray( key );
		for (int i=0; i < array.length(); i++) {
			Bundlable O = new Bundle( array.getJSONObject( i ) ).get();
			if (O != null) list.add( O );
		}
	} catch (JSONException e) {
		Game.reportException(e);
	}
	
	return list;
}
 
Example 4
Source File: Bundle.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
public Collection<Bundlable> getCollection( String key ) {
	
	ArrayList<Bundlable> list = new ArrayList<>();
	
	try {
		JSONArray array = data.getJSONArray( key );
		for (int i=0; i < array.length(); i++) {
			Bundlable O = new Bundle( array.getJSONObject( i ) ).get();
			if (O != null) list.add( O );
		}
	} catch (JSONException e) {
		Game.reportException(e);
	}
	
	return list;
}
 
Example 5
Source File: Bundle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, float[] array ) {
	try {
		JSONArray jsonArray = new JSONArray();
		for (int i=0; i < array.length; i++) {
			jsonArray.put( i, array[i] );
		}
		data.put( key, jsonArray );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 6
Source File: Reflection.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static <T> T newInstance( Class<T> cls ){
	try {
		return ClassReflection.newInstance(cls);
	} catch (ReflectionException e) {
		Game.reportException(e);
		return null;
	}
}
 
Example 7
Source File: Bundle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, int[] array ) {
	try {
		JSONArray jsonArray = new JSONArray();
		for (int i=0; i < array.length; i++) {
			jsonArray.put( i, array[i] );
		}
		data.put( key, jsonArray );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 8
Source File: AndroidPlatformSupport.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BitmapFont getFont(int size, String text) {
	FreeTypeFontGenerator generator = getGeneratorForString(text);
	
	if (generator == null){
		return null;
	}
	
	if (!fonts.get(generator).containsKey(size)) {
		FreeTypeFontGenerator.FreeTypeFontParameter parameters = new FreeTypeFontGenerator.FreeTypeFontParameter();
		parameters.size = size;
		parameters.flip = true;
		parameters.borderWidth = parameters.size / 10f;
		parameters.renderCount = 3;
		parameters.hinting = FreeTypeFontGenerator.Hinting.None;
		parameters.spaceX = -(int) parameters.borderWidth;
		parameters.incremental = true;
		if (generator == basicFontGenerator){
			//if we're using latin/cyrillic, we can safely pre-generate some common letters
			//(we define common as >4% frequency in english)
			parameters.characters = "�etaoinshrdl";
		} else {
			parameters.characters = "�";
		}
		parameters.packer = packer;
		
		try {
			BitmapFont font = generator.generateFont(parameters);
			font.getData().missingGlyph = font.getData().getGlyph('�');
			fonts.get(generator).put(size, font);
		} catch ( Exception e ){
			Game.reportException(e);
			return null;
		}
	}
	
	return fonts.get(generator).get(size);
}
 
Example 9
Source File: DesktopPlatformSupport.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BitmapFont getFont(int size, String text) {
	FreeTypeFontGenerator generator = getGeneratorForString(text);
	
	if (generator == null){
		return null;
	}
	
	if (!fonts.get(generator).containsKey(size)) {
		FreeTypeFontGenerator.FreeTypeFontParameter parameters = new FreeTypeFontGenerator.FreeTypeFontParameter();
		parameters.size = size;
		parameters.flip = true;
		parameters.borderWidth = parameters.size / 10f;
		parameters.renderCount = 3;
		parameters.hinting = FreeTypeFontGenerator.Hinting.None;
		parameters.spaceX = -(int) parameters.borderWidth;
		parameters.incremental = true;
		if (generator == basicFontGenerator){
			//if we're using latin/cyrillic, we can safely pre-generate some common letters
			//(we define common as >4% frequency in english)
			parameters.characters = "�etaoinshrdl";
		} else {
			parameters.characters = "�";
		}
		parameters.packer = packer;
		
		try {
			BitmapFont font = generator.generateFont(parameters);
			font.getData().missingGlyph = font.getData().getGlyph('�');
			fonts.get(generator).put(size, font);
		} catch ( Exception e ){
			Game.reportException(e);
			return null;
		}
	}
	
	return fonts.get(generator).get(size);
}
 
Example 10
Source File: Bundle.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, Bundlable object ) {
	if (object != null) {
		try {
			Bundle bundle = new Bundle();
			bundle.put( CLASS_NAME, object.getClass().getName() );
			object.storeInBundle( bundle );
			data.put( key, bundle.data );
		} catch (JSONException e) {
			Game.reportException(e);
		}
	}
}
 
Example 11
Source File: Bundle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, String[] array ) {
	try {
		JSONArray jsonArray = new JSONArray();
		for (int i=0; i < array.length; i++) {
			jsonArray.put( i, array[i] );
		}
		data.put( key, jsonArray );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 12
Source File: Bundle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, float value ) {
	try {
		data.put( key, value );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 13
Source File: Bundle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, long value ) {
	try {
		data.put( key, value );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 14
Source File: Bundle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, int value ) {
	try {
		data.put( key, value );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 15
Source File: Bundle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, boolean[] array ) {
	try {
		JSONArray jsonArray = new JSONArray();
		for (int i=0; i < array.length; i++) {
			jsonArray.put( i, array[i] );
		}
		data.put( key, jsonArray );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 16
Source File: Reflection.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public static <T> T newInstance( Class<T> cls ){
	try {
		return ClassReflection.newInstance(cls);
	} catch (ReflectionException e) {
		Game.reportException(e);
		return null;
	}
}
 
Example 17
Source File: Bundle.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, Class[] array ){
	try {
		JSONArray jsonArray = new JSONArray();
		for (int i=0; i < array.length; i++) {
			jsonArray.put( i, array[i] );
		}
		data.put( key, jsonArray );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 18
Source File: Bundle.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, Bundle bundle ) {
	try {
		data.put( key, bundle.data );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 19
Source File: Bundle.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public void put( String key, boolean[] array ) {
	try {
		JSONArray jsonArray = new JSONArray();
		for (int i=0; i < array.length; i++) {
			jsonArray.put( i, array[i] );
		}
		data.put( key, jsonArray );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 20
Source File: TextureCache.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 3 votes vote down vote up
public static Pixmap getBitmap( Object src ) {
	
	try {
		if (src instanceof Integer){

			// FIXME
			throw new UnsupportedOperationException();
			
		} else if (src instanceof String) {
			
			return new Pixmap(Gdx.files.internal((String)src));
			
		} else if (src instanceof Pixmap) {
			
			return (Pixmap) src;
			
		} else {
			
			return null;
			
		}
	} catch (Exception e) {
		
		Game.reportException(e);
		return null;
		
	}
}