Merging 1.7.5 Source: scenes changes
This commit is contained in:
@@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.watabou.input.Touchscreen;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.BitmapText.Font;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
@@ -38,16 +37,19 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner;
|
||||
import com.watabou.utils.BitmapCache;
|
||||
|
||||
public class PixelScene extends Scene {
|
||||
|
||||
public static final float MIN_WIDTH = 128;
|
||||
public static final float MIN_HEIGHT = 224;
|
||||
|
||||
|
||||
// Minimum virtual display size for portrait orientation
|
||||
public static final float MIN_WIDTH_P = 128;
|
||||
public static final float MIN_HEIGHT_P = 224;
|
||||
|
||||
// Minimum virtual display size for landscape orientation
|
||||
public static final float MIN_WIDTH_L = 224;
|
||||
public static final float MIN_HEIGHT_L = 160;
|
||||
|
||||
public static float defaultZoom = 0;
|
||||
public static float minZoom;
|
||||
public static float maxZoom;
|
||||
|
||||
public static boolean landscapeAvailable;
|
||||
|
||||
public static Camera uiCamera;
|
||||
|
||||
public static BitmapText.Font font1x;
|
||||
@@ -62,23 +64,30 @@ public class PixelScene extends Scene {
|
||||
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 < MIN_WIDTH ||
|
||||
Game.height / defaultZoom < MIN_HEIGHT
|
||||
Game.width / defaultZoom < minWidth ||
|
||||
Game.height / defaultZoom < minHeight
|
||||
) && defaultZoom > 1) {
|
||||
|
||||
defaultZoom--;
|
||||
}
|
||||
|
||||
landscapeAvailable =
|
||||
Game.height / defaultZoom >= MIN_WIDTH &&
|
||||
Game.width / defaultZoom >= MIN_HEIGHT;
|
||||
|
||||
if (ShatteredPixelDungeon.scaleUp()) {
|
||||
while ((Game.width / (defaultZoom + 1) >= MIN_WIDTH && Game.height / (defaultZoom + 1) >= MIN_HEIGHT)) {
|
||||
defaultZoom++;
|
||||
while (
|
||||
Game.width / (defaultZoom + 1) >= minWidth &&
|
||||
Game.height / (defaultZoom + 1) >= minHeight) {
|
||||
defaultZoom++;
|
||||
}
|
||||
}
|
||||
minZoom = 1;
|
||||
@@ -123,11 +132,6 @@ public class PixelScene extends Scene {
|
||||
font3x.baseLine = 17;
|
||||
font3x.tracking = -2;
|
||||
}
|
||||
|
||||
Sample.INSTANCE.load(
|
||||
Assets.SND_CLICK,
|
||||
Assets.SND_BADGE,
|
||||
Assets.SND_GOLD );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,9 +144,13 @@ public class PixelScene extends Scene {
|
||||
public static float scale;
|
||||
|
||||
public static void chooseFont( float size ) {
|
||||
|
||||
float pt = size * defaultZoom;
|
||||
|
||||
chooseFont( size, defaultZoom );
|
||||
}
|
||||
|
||||
public static void chooseFont( float size, float zoom ) {
|
||||
|
||||
float pt = size * zoom;
|
||||
|
||||
if (pt >= 19) {
|
||||
|
||||
scale = pt / 19;
|
||||
@@ -194,7 +202,7 @@ public class PixelScene extends Scene {
|
||||
|
||||
}
|
||||
|
||||
scale /= defaultZoom;
|
||||
scale /= zoom;
|
||||
}
|
||||
|
||||
public static BitmapText createText( float size ) {
|
||||
@@ -228,7 +236,8 @@ public class PixelScene extends Scene {
|
||||
public static float align( Camera camera, float pos ) {
|
||||
return ((int)(pos * camera.zoom)) / camera.zoom;
|
||||
}
|
||||
|
||||
|
||||
// This one should be used for UI elements
|
||||
public static float align( float pos ) {
|
||||
return ((int)(pos * defaultZoom)) / defaultZoom;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user