v0.3.1d: removed strict pixel align pt.1
there is no need to enforce whole interger positions for UI elements. Especially with the recent font changes this was causing alignment problems on high resolution displays. Elements with non-whole number sizes and positions should be used sparingly, but there's no reason to strictly align them.
This commit is contained in:
@@ -530,8 +530,8 @@ public class GameScene extends PixelScene {
|
|||||||
|
|
||||||
private void showBanner( Banner banner ) {
|
private void showBanner( Banner banner ) {
|
||||||
banner.camera = uiCamera;
|
banner.camera = uiCamera;
|
||||||
banner.x = align( uiCamera, (uiCamera.width - banner.width) / 2 );
|
banner.x = (uiCamera.width - banner.width) / 2 ;
|
||||||
banner.y = align( uiCamera, (uiCamera.height - banner.height) / 3 );
|
banner.y = (uiCamera.height - banner.height) / 3 ;
|
||||||
add( banner );
|
add( banner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,19 +188,9 @@ public class PixelScene extends Scene {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float align( Camera camera, float pos ) {
|
|
||||||
return ((int)(pos * camera.zoom)) / camera.zoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This one should be used for UI elements
|
// This one should be used for UI elements
|
||||||
public static float align( float pos ) {
|
public static float align( float pos ) {
|
||||||
return ((int)(pos * defaultZoom)) / defaultZoom;
|
return pos;
|
||||||
}
|
|
||||||
|
|
||||||
public static void align( Visual v ) {
|
|
||||||
Camera c = v.camera();
|
|
||||||
v.x = align( c, v.x );
|
|
||||||
v.y = align( c, v.y );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean noFade = false;
|
public static boolean noFade = false;
|
||||||
@@ -219,8 +209,8 @@ public class PixelScene extends Scene {
|
|||||||
public static void showBadge( Badges.Badge badge ) {
|
public static void showBadge( Badges.Badge badge ) {
|
||||||
BadgeBanner banner = BadgeBanner.show( badge.image );
|
BadgeBanner banner = BadgeBanner.show( badge.image );
|
||||||
banner.camera = uiCamera;
|
banner.camera = uiCamera;
|
||||||
banner.x = align( banner.camera, (banner.camera.width - banner.width) / 2 );
|
banner.x = (banner.camera.width - banner.width) / 2 ;
|
||||||
banner.y = align( banner.camera, (banner.camera.height - banner.height) / 3 );
|
banner.y = (banner.camera.height - banner.height) / 3 ;
|
||||||
Game.scene().add( banner );
|
Game.scene().add( banner );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,8 +270,8 @@ public class PixelScene extends Scene {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateMatrix() {
|
protected void updateMatrix() {
|
||||||
float sx = align( this, scroll.x + shakeX );
|
float sx = scroll.x + shakeX;
|
||||||
float sy = align( this, scroll.y + shakeY );
|
float sy = scroll.y + shakeY;
|
||||||
|
|
||||||
matrix[0] = +zoom * invW2;
|
matrix[0] = +zoom * invW2;
|
||||||
matrix[5] = -zoom * invH2;
|
matrix[5] = -zoom * invH2;
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ public class AttackIndicator extends Tag {
|
|||||||
if (sprite != null) {
|
if (sprite != null) {
|
||||||
sprite.x = x + (width - sprite.width()) / 2;
|
sprite.x = x + (width - sprite.width()) / 2;
|
||||||
sprite.y = y + (height - sprite.height()) / 2;
|
sprite.y = y + (height - sprite.height()) / 2;
|
||||||
PixelScene.align( sprite );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +142,6 @@ public class AttackIndicator extends Tag {
|
|||||||
|
|
||||||
sprite.x = x + (width - sprite.width()) / 2 + 1;
|
sprite.x = x + (width - sprite.width()) / 2 + 1;
|
||||||
sprite.y = y + (height - sprite.height()) / 2;
|
sprite.y = y + (height - sprite.height()) / 2;
|
||||||
PixelScene.align( sprite );
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ public class CheckBox extends RedButton {
|
|||||||
|
|
||||||
float margin = (height - text.baseLine()) / 2;
|
float margin = (height - text.baseLine()) / 2;
|
||||||
|
|
||||||
text.x = PixelScene.align( PixelScene.uiCamera, x + margin );
|
text.x = x + margin;
|
||||||
text.y = PixelScene.align( PixelScene.uiCamera, y + margin );
|
text.y = y + margin;
|
||||||
|
|
||||||
margin = (height - icon.height) / 2;
|
margin = (height - icon.height) / 2;
|
||||||
|
|
||||||
icon.x = PixelScene.align( PixelScene.uiCamera, x + width - margin - icon.width );
|
icon.x = x + width - margin - icon.width;
|
||||||
icon.y = PixelScene.align( PixelScene.uiCamera, y + margin );
|
icon.y = y + margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checked() {
|
public boolean checked() {
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ public class RedButton extends Button {
|
|||||||
bg.y = y;
|
bg.y = y;
|
||||||
bg.size( width, height );
|
bg.size( width, height );
|
||||||
|
|
||||||
text.x = x + (int)(width - text.width()) / 2;
|
text.x = x + (width - text.width()) / 2;
|
||||||
text.y = y + (int)(height - text.baseLine()) / 2;
|
text.y = y + (height - text.baseLine()) / 2;
|
||||||
|
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
icon.x = x + text.x - icon.width() - 2;
|
icon.x = x + text.x - icon.width() - 2;
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ public class ResumeIndicator extends Tag {
|
|||||||
protected void layout() {
|
protected void layout() {
|
||||||
super.layout();
|
super.layout();
|
||||||
|
|
||||||
icon.x = PixelScene.align( PixelScene.uiCamera, x+1 + (width - icon.width) / 2 );
|
icon.x = x+1 + (width - icon.width) / 2;
|
||||||
icon.y = PixelScene.align( PixelScene.uiCamera, y + (height - icon.height) / 2 );
|
icon.y = y + (height - icon.height) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ public class StatusPane extends Component {
|
|||||||
|
|
||||||
shield.size( width, shield.height );
|
shield.size( width, shield.height );
|
||||||
|
|
||||||
avatar.x = PixelScene.align( camera(), shield.x + 15 - avatar.width / 2 );
|
avatar.x = shield.x + 15 - avatar.width / 2;
|
||||||
avatar.y = PixelScene.align( camera(), shield.y + 16 - avatar.height / 2 );
|
avatar.y = shield.y + 16 - avatar.height / 2;
|
||||||
|
|
||||||
compass.x = avatar.x + avatar.width / 2 - compass.origin.x;
|
compass.x = avatar.x + avatar.width / 2 - compass.origin.x;
|
||||||
compass.y = avatar.y + avatar.height / 2 - compass.origin.y;
|
compass.y = avatar.y + avatar.height / 2 - compass.origin.y;
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ public class Toast extends Component {
|
|||||||
|
|
||||||
text.x = close.left() - MARGIN_HOR - text.width();
|
text.x = close.left() - MARGIN_HOR - text.width();
|
||||||
text.y = y + (height - text.height()) / 2;
|
text.y = y + (height - text.height()) / 2;
|
||||||
PixelScene.align( text );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void text( String txt ) {
|
public void text( String txt ) {
|
||||||
|
|||||||
@@ -81,13 +81,12 @@ public class IconTitle extends Component {
|
|||||||
imIcon.x = x;
|
imIcon.x = x;
|
||||||
imIcon.y = y;
|
imIcon.y = y;
|
||||||
|
|
||||||
tfLabel.x = PixelScene.align( PixelScene.uiCamera, imIcon.x + imIcon.width() + GAP );
|
tfLabel.x = imIcon.x + imIcon.width() + GAP;
|
||||||
tfLabel.maxWidth = (int)(width - tfLabel.x);
|
tfLabel.maxWidth = (int)(width - tfLabel.x);
|
||||||
tfLabel.measure();
|
tfLabel.measure();
|
||||||
tfLabel.y = PixelScene.align( PixelScene.uiCamera,
|
tfLabel.y = imIcon.height > tfLabel.height() ?
|
||||||
imIcon.height > tfLabel.height() ?
|
|
||||||
imIcon.y + (imIcon.height() - tfLabel.baseLine()) / 2 :
|
imIcon.y + (imIcon.height() - tfLabel.baseLine()) / 2 :
|
||||||
imIcon.y );
|
imIcon.y;
|
||||||
|
|
||||||
if (health.visible) {
|
if (health.visible) {
|
||||||
health.setRect( tfLabel.x, Math.max( tfLabel.y + tfLabel.height(), imIcon.y + imIcon.height() - health.height() ), tfLabel.maxWidth, 0 );
|
health.setRect( tfLabel.x, Math.max( tfLabel.y + tfLabel.height(), imIcon.y + imIcon.height() - health.height() ), tfLabel.maxWidth, 0 );
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class WndCatalogus extends WndTabbed {
|
|||||||
|
|
||||||
txtTitle.text( Utils.format( TXT_TITLE, showPotions ? TXT_POTIONS : TXT_SCROLLS ) );
|
txtTitle.text( Utils.format( TXT_TITLE, showPotions ? TXT_POTIONS : TXT_SCROLLS ) );
|
||||||
txtTitle.measure();
|
txtTitle.measure();
|
||||||
txtTitle.x = PixelScene.align( PixelScene.uiCamera, (width - txtTitle.width()) / 2 );
|
txtTitle.x = (width - txtTitle.width()) / 2;
|
||||||
|
|
||||||
items.clear();
|
items.clear();
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ public class WndChallenges extends Window {
|
|||||||
BitmapText title = PixelScene.createText( TITLE, 9 );
|
BitmapText title = PixelScene.createText( TITLE, 9 );
|
||||||
title.hardlight( TITLE_COLOR );
|
title.hardlight( TITLE_COLOR );
|
||||||
title.measure();
|
title.measure();
|
||||||
title.x = PixelScene.align( camera, (WIDTH - title.width()) / 2 );
|
title.x = (WIDTH - title.width()) / 2;
|
||||||
title.y = PixelScene.align( camera, (TTL_HEIGHT - title.height()) / 2 );
|
title.y = (TTL_HEIGHT - title.height()) / 2;
|
||||||
add( title );
|
add( title );
|
||||||
|
|
||||||
boxes = new ArrayList<CheckBox>();
|
boxes = new ArrayList<CheckBox>();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class WndJournal extends Window {
|
|||||||
txtTitle = PixelScene.createText( TXT_TITLE, 9 );
|
txtTitle = PixelScene.createText( TXT_TITLE, 9 );
|
||||||
txtTitle.hardlight( Window.TITLE_COLOR );
|
txtTitle.hardlight( Window.TITLE_COLOR );
|
||||||
txtTitle.measure();
|
txtTitle.measure();
|
||||||
txtTitle.x = PixelScene.align( PixelScene.uiCamera, (WIDTH - txtTitle.width()) / 2 );
|
txtTitle.x = (WIDTH - txtTitle.width()) / 2;
|
||||||
add( txtTitle );
|
add( txtTitle );
|
||||||
|
|
||||||
Component content = new Component();
|
Component content = new Component();
|
||||||
|
|||||||
Reference in New Issue
Block a user