com.watabou.utils.BitmapCache Java Examples

The following examples show how to use com.watabou.utils.BitmapCache. 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: Game.java    From PD-classes with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate( Bundle savedInstanceState ) {
	super.onCreate( savedInstanceState );
	
	BitmapCache.context = TextureCache.context = instance = this;
	
	DisplayMetrics m = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics( m );
	density = m.density;
	
	try {
		version = getPackageManager().getPackageInfo( getPackageName(), 0 ).versionName;
	} catch (NameNotFoundException e) {
		version = "???";
	}
	
	setVolumeControlStream( AudioManager.STREAM_MUSIC );
	
	view = new GLSurfaceView( this );
	view.setEGLContextClientVersion( 2 );
	view.setEGLConfigChooser( false );
	view.setRenderer( this );
	view.setOnTouchListener( this );
	setContentView( view );
}
 
Example #2
Source File: Game.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate( Bundle savedInstanceState ) {
	super.onCreate( savedInstanceState );
	
	BitmapCache.context = TextureCache.context = instance = this;
	
	DisplayMetrics m = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics( m );
	density = m.density;
	
	try {
		version = getPackageManager().getPackageInfo( getPackageName(), 0 ).versionName;
		versionNum = getPackageManager().getPackageInfo( getPackageName(), 0 ).versionCode;
	} catch (NameNotFoundException e) {
		version = "???";
           versionNum = 0;
	}
	
	setVolumeControlStream( AudioManager.STREAM_MUSIC );
	
	view = new GLSurfaceView( this );
	view.setEGLContextClientVersion( 2 );
	view.setEGLConfigChooser( false );
	view.setRenderer( this );
	view.setOnTouchListener( this );
	setContentView( view );
}
 
Example #3
Source File: PixelScene.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
static private void createFonts() {
	if (font1x == null) {
		// 3x5 (6)
		font1x = Font.colorMarked(BitmapCache.get(Assets.FONTS1X),
				0x00000000, Font.LATIN_FULL);
		font1x.baseLine = 6;
		font1x.tracking = -1;
		
		// 7x12 (15)
		font25x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, Font.ALL_CHARS);
		font25x.baseLine = 13;
		font25x.tracking = -1;
	}
}
 
Example #4
Source File: PixelScene.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	
	super.create();
	
	GameScene.scene = null;
	
	float minWidth, minHeight;
	if (YetAnotherPixelDungeon.landscape()) {
		minWidth = MIN_WIDTH_L;
		minHeight = MIN_HEIGHT_L;
	} else {
		minWidth = MIN_WIDTH_P;
		minHeight = MIN_HEIGHT_P;
	}
	
	defaultZoom = (int)Math.ceil( Game.density * 2.5 );
	while ((
		Game.width / defaultZoom < minWidth || 
		Game.height / defaultZoom < minHeight
		) && defaultZoom > 1) {
		
		defaultZoom--;
	}
		
	if (YetAnotherPixelDungeon.scaleUp()) {
		while (
			Game.width / (defaultZoom + 1) >= minWidth && 
			Game.height / (defaultZoom + 1) >= minHeight) {
			
			defaultZoom++;
		}	
	}
	minZoom = 1;
	maxZoom = defaultZoom * 2;	
	
	Camera.reset( new PixelCamera( defaultZoom ) );
	
	float uiZoom = defaultZoom;
	uiCamera = Camera.createFullscreen( uiZoom );
	Camera.add( uiCamera );
	
	if (font1x == null) {
		
		// 3x5 (6)
		font1x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS1X ), 0x00000000, BitmapText.Font.LATIN_FULL );
		font1x.baseLine = 6;
		font1x.tracking = -1;
		
		// 5x8 (10)
		font15x = Font.colorMarked( 
				BitmapCache.get( Assets.FONTS15X ), 12, 0x00000000, BitmapText.Font.LATIN_FULL );
		font15x.baseLine = 9;
		font15x.tracking = -1;
		
		// 6x10 (12)
		font2x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS2X ), 14, 0x00000000, BitmapText.Font.LATIN_FULL );
		font2x.baseLine = 11;
		font2x.tracking = -1;
		
		// 7x12 (15)
		font25x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, BitmapText.Font.LATIN_FULL );
		font25x.baseLine = 13;
		font25x.tracking = -1;
		
		// 9x15 (18)
		font3x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS3X ), 22, 0x00000000, BitmapText.Font.LATIN_FULL );
		font3x.baseLine = 17;
		font3x.tracking = -2;
	}
}
 
Example #5
Source File: PixelScene.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	
	super.create();
	
	GameScene.scene = null;

	float minWidth, minHeight;
	if (ShatteredPixelDungeon.landscape()) {
		minWidth = MIN_WIDTH_L;
		minHeight = MIN_HEIGHT_L;
	} else {
		minWidth = MIN_WIDTH_P;
		minHeight = MIN_HEIGHT_P;
	}

	defaultZoom = (int)Math.ceil( Game.density * 2.5 );
	while ((
		Game.width / defaultZoom < minWidth ||
		Game.height / defaultZoom < minHeight
		) && defaultZoom > 1) {
		
		defaultZoom--;
	}
		
	while (
			Game.width / (defaultZoom + 1) >= minWidth &&
			Game.height / (defaultZoom + 1) >= minHeight) {
		defaultZoom++;
	}

	minZoom = 1;
	maxZoom = defaultZoom * 2;
		
	
	Camera.reset( new PixelCamera( defaultZoom ) );
	
	float uiZoom = defaultZoom;
	uiCamera = Camera.createFullscreen( uiZoom );
	Camera.add( uiCamera );
	
	if (font1x == null) {
		
		// 3x5 (6)
		font1x = Font.colorMarked(
			BitmapCache.get( Assets.FONTS1X ), 0x00000000, BitmapText.Font.LATIN_FULL );
		font1x.baseLine = 6;
		font1x.tracking = -1;
		
		// 5x8 (10)
		font15x = Font.colorMarked(
				BitmapCache.get( Assets.FONTS15X ), 12, 0x00000000, BitmapText.Font.LATIN_FULL );
		font15x.baseLine = 9;
		font15x.tracking = -1;
		
		// 6x10 (12)
		font2x = Font.colorMarked(
			BitmapCache.get( Assets.FONTS2X ), 14, 0x00000000, BitmapText.Font.LATIN_FULL );
		font2x.baseLine = 11;
		font2x.tracking = -1;
		
		// 7x12 (15)
		font25x = Font.colorMarked(
			BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, BitmapText.Font.LATIN_FULL );
		font25x.baseLine = 13;
		font25x.tracking = -1;
		
		// 9x15 (18)
		font3x = Font.colorMarked(
			BitmapCache.get( Assets.FONTS3X ), 22, 0x00000000, BitmapText.Font.LATIN_FULL );
		font3x.baseLine = 17;
		font3x.tracking = -2;
	}
}
 
Example #6
Source File: PixelScene.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	
	super.create();
	
	GameScene.scene = null;
	
	float minWidth, minHeight;
	if (PixelDungeon.landscape()) {
		minWidth = MIN_WIDTH_L;
		minHeight = MIN_HEIGHT_L;
	} else {
		minWidth = MIN_WIDTH_P;
		minHeight = MIN_HEIGHT_P;
	}
	
	defaultZoom = (int)Math.ceil( Game.density * 2.5 );
	while ((
		Game.width / defaultZoom < minWidth || 
		Game.height / defaultZoom < minHeight
		) && defaultZoom > 1) {
		
		defaultZoom--;
	}
		
	if (PixelDungeon.scaleUp()) {
		while (
			Game.width / (defaultZoom + 1) >= minWidth && 
			Game.height / (defaultZoom + 1) >= minHeight) {
			
			defaultZoom++;
		}	
	}
	minZoom = 1;
	maxZoom = defaultZoom * 2;	
	
	Camera.reset( new PixelCamera( defaultZoom ) );
	
	float uiZoom = defaultZoom;
	uiCamera = Camera.createFullscreen( uiZoom );
	Camera.add( uiCamera );
	
	if (font1x == null) {
		
		// 3x5 (6)
		font1x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS1X ), 0x00000000, BitmapText.Font.LATIN_FULL );
		font1x.baseLine = 6;
		font1x.tracking = -1;
		
		// 5x8 (10)
		font15x = Font.colorMarked( 
				BitmapCache.get( Assets.FONTS15X ), 12, 0x00000000, BitmapText.Font.LATIN_FULL );
		font15x.baseLine = 9;
		font15x.tracking = -1;
		
		// 6x10 (12)
		font2x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS2X ), 14, 0x00000000, BitmapText.Font.LATIN_FULL );
		font2x.baseLine = 11;
		font2x.tracking = -1;
		
		// 7x12 (15)
		font25x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS25X ), 17, 0x00000000, BitmapText.Font.LATIN_FULL );
		font25x.baseLine = 13;
		font25x.tracking = -1;
		
		// 9x15 (18)
		font3x = Font.colorMarked( 
			BitmapCache.get( Assets.FONTS3X ), 22, 0x00000000, BitmapText.Font.LATIN_FULL );
		font3x.baseLine = 17;
		font3x.tracking = -2;
	}
}
 
Example #7
Source File: PixelScene.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {

	super.create();

	GameScene.scene = null;

	float minWidth, minHeight;
	if (landscape()) {
		minWidth = MIN_WIDTH_L;
		minHeight = MIN_HEIGHT_L;
	} else {
		minWidth = MIN_WIDTH_P;
		minHeight = MIN_HEIGHT_P;
	}

	maxDefaultZoom = (int)Math.min(Game.width/minWidth, Game.height/minHeight);
	maxScreenZoom = (int)Math.min(Game.dispWidth/minWidth, Game.dispHeight/minHeight);
	defaultZoom = SPDSettings.scale();

	if (defaultZoom < Math.ceil( Game.density * 2 ) || defaultZoom > maxDefaultZoom){
		defaultZoom = (int)Math.ceil( Game.density * 2.5 );
		while ((
			Game.width / defaultZoom < minWidth ||
			Game.height / defaultZoom < minHeight
		) && defaultZoom > 1) {
			defaultZoom--;
		}
	}

	minZoom = 1;
	maxZoom = defaultZoom * 2;

	Camera.reset( new PixelCamera( defaultZoom ) );

	float uiZoom = defaultZoom;
	uiCamera = Camera.createFullscreen( uiZoom );
	Camera.add( uiCamera );

	if (pixelFont == null) {

		// 3x5 (6)
		pixelFont = Font.colorMarked(
			BitmapCache.get( Assets.Fonts.PIXELFONT), 0x00000000, BitmapText.Font.LATIN_FULL );
		pixelFont.baseLine = 6;
		pixelFont.tracking = -1;
		
	}
	
	//set up the texture size which rendered text will use for any new glyphs.
	int renderedTextPageSize;
	if (defaultZoom <= 3){
		renderedTextPageSize = 256;
	} else if (defaultZoom <= 8){
		renderedTextPageSize = 512;
	} else {
		renderedTextPageSize = 1024;
	}
	//asian languages have many more unique characters, so increase texture size to anticipate that
	if (Messages.lang() == Languages.KOREAN ||
			Messages.lang() == Languages.CHINESE ||
			Messages.lang() == Languages.JAPANESE){
		renderedTextPageSize *= 2;
	}
	Game.platform.setupFontGenerators(renderedTextPageSize, SPDSettings.systemFont());
	
}
 
Example #8
Source File: PixelScene.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	
	super.create();
	
	GameScene.scene = null;
	
	float minWidth, minHeight;
	if (SPDSettings.landscape()) {
		minWidth = MIN_WIDTH_L;
		minHeight = MIN_HEIGHT_L;
	} else {
		minWidth = MIN_WIDTH_P;
		minHeight = MIN_HEIGHT_P;
	}
	
	maxDefaultZoom = (int)Math.min(Game.width/minWidth, Game.height/minHeight);
	defaultZoom = SPDSettings.scale();
	
	if (defaultZoom < Math.ceil( Game.density * 2 ) || defaultZoom > maxDefaultZoom){
		defaultZoom = (int)Math.round((Math.ceil( Game.density * 2 ) + maxDefaultZoom)/2);
		while ((
				Game.width / defaultZoom < minWidth ||
						Game.height / defaultZoom < minHeight
		) && defaultZoom > 1) {
			defaultZoom--;
		}
	}
	
	minZoom = 1;
	maxZoom = defaultZoom * 2;
	
	Camera.reset( new PixelCamera( defaultZoom ) );
	
	float uiZoom = defaultZoom;
	uiCamera = Camera.createFullscreen( uiZoom );
	Camera.add( uiCamera );
	
	if (pixelFont == null) {
		
		// 3x5 (6)
		pixelFont = Font.colorMarked(
				BitmapCache.get( Assets.PIXELFONT), 0x00000000, BitmapText.Font.LATIN_FULL );
		pixelFont.baseLine = 6;
		pixelFont.tracking = -1;
		
	}
	
}