Merging 1.7.5 Source: ui changes
This commit is contained in:
parent
4499685b09
commit
894f7d9d06
|
@ -38,8 +38,10 @@ public class CheckBox extends RedButton {
|
|||
text.x = PixelScene.align( PixelScene.uiCamera, x + margin );
|
||||
text.y = PixelScene.align( PixelScene.uiCamera, y + margin );
|
||||
|
||||
margin = (height - icon.height) / 2;
|
||||
|
||||
icon.x = PixelScene.align( PixelScene.uiCamera, x + width - margin - icon.width );
|
||||
icon.y = PixelScene.align( PixelScene.uiCamera, y + (height - icon.height()) / 2 );
|
||||
icon.y = PixelScene.align( PixelScene.uiCamera, y + margin );
|
||||
}
|
||||
|
||||
public boolean checked() {
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
|
||||
public class HealthBar extends Component {
|
||||
|
||||
private static final int COLOR_BG = 0xFFCC0000;
|
||||
private static final int COLOR_LVL = 0xFF00EE00;
|
||||
|
||||
private static final int HEIGHT = 2;
|
||||
|
||||
private ColorBlock hpBg;
|
||||
private ColorBlock hpLvl;
|
||||
|
||||
private float level;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
hpBg = new ColorBlock( 1, 1, COLOR_BG );
|
||||
add( hpBg );
|
||||
|
||||
hpLvl = new ColorBlock( 1, 1, COLOR_LVL );
|
||||
add( hpLvl );
|
||||
|
||||
height = HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
|
||||
hpBg.x = hpLvl.x = x;
|
||||
hpBg.y = hpLvl.y = y;
|
||||
|
||||
hpBg.size( width, HEIGHT );
|
||||
hpLvl.size( width * level, HEIGHT );
|
||||
|
||||
height = HEIGHT;
|
||||
}
|
||||
|
||||
public void level( float value ) {
|
||||
level = value;
|
||||
layout();
|
||||
}
|
||||
}
|
|
@ -50,8 +50,9 @@ public class ItemSlot extends Button {
|
|||
private static final String TXT_KEY_DEPTH = "\u007F%d";
|
||||
|
||||
private static final String TXT_LEVEL = "%+d";
|
||||
private static final String TXT_CURSED = "";//"-";
|
||||
|
||||
// Special items for containers
|
||||
// Special "virtual items"
|
||||
public static final Item CHEST = new Item() {
|
||||
public int image() { return ItemSpriteSheet.CHEST; };
|
||||
};
|
||||
|
@ -172,7 +173,7 @@ public class ItemSlot extends Button {
|
|||
int level = item.visiblyUpgraded();
|
||||
|
||||
if (level != 0) {
|
||||
bottomRight.text( item.levelKnown ? Utils.format( TXT_LEVEL, level ) : "" );
|
||||
bottomRight.text( item.levelKnown ? Utils.format( TXT_LEVEL, level ) : TXT_CURSED );
|
||||
bottomRight.measure();
|
||||
bottomRight.hardlight( level > 0 ? UPGRADED : DEGRADED );
|
||||
} else {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class LootIndicator extends Tag {
|
|||
if (heap != null) {
|
||||
|
||||
Item item =
|
||||
heap.type == Heap.Type.CHEST ? ItemSlot.CHEST :
|
||||
heap.type == Heap.Type.CHEST || heap.type == Heap.Type.MIMIC ? ItemSlot.CHEST :
|
||||
heap.type == Heap.Type.LOCKED_CHEST ? ItemSlot.LOCKED_CHEST :
|
||||
heap.type == Heap.Type.CRYSTAL_CHEST ? ItemSlot.CRYSTAL_CHEST :
|
||||
heap.type == Heap.Type.TOMB ? ItemSlot.TOMB :
|
||||
|
|
|
@ -66,18 +66,18 @@ public class RedButton extends Button {
|
|||
icon.x = x + text.x - icon.width() - 2;
|
||||
icon.y = y + (height - icon.height()) / 2;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
bg.brightness( 1.2f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
bg.resetColor();
|
||||
};
|
||||
}
|
||||
|
||||
public void enable( boolean value ) {
|
||||
active = value;
|
||||
|
@ -90,6 +90,10 @@ public class RedButton extends Button {
|
|||
layout();
|
||||
}
|
||||
|
||||
public void textColor( int value ) {
|
||||
text.hardlight( value );
|
||||
}
|
||||
|
||||
public void icon( Image icon ) {
|
||||
if (this.icon != null) {
|
||||
remove( this.icon );
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.noosa.Image;
|
||||
|
||||
/**
|
||||
|
@ -22,15 +23,17 @@ public class ResumeIndicator extends Tag {
|
|||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
icon = Icons.get(Icons.RESUME);
|
||||
add(icon);
|
||||
|
||||
icon = Icons.get( Icons.RESUME );
|
||||
add( icon );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
super.layout();
|
||||
icon.x = x + (width - icon.width()) / 2;
|
||||
icon.y = y + (height - icon.height()) / 2;
|
||||
|
||||
icon.x = PixelScene.align( PixelScene.uiCamera, x+1 + (width - icon.width) / 2 );
|
||||
icon.y = PixelScene.align( PixelScene.uiCamera, y + (height - icon.height) / 2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -110,9 +110,7 @@ public class ScrollPane extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
// true if dragging is in progress
|
||||
private boolean dragging = false;
|
||||
// last touch coords
|
||||
private PointF lastPos = new PointF();
|
||||
|
||||
@Override
|
||||
|
|
|
@ -120,12 +120,12 @@ public class StatusPane extends Component {
|
|||
danger = new DangerIndicator();
|
||||
add( danger );
|
||||
|
||||
resume = new ResumeIndicator();
|
||||
add ( resume );
|
||||
|
||||
loot = new LootIndicator();
|
||||
add( loot );
|
||||
|
||||
resume = new ResumeIndicator();
|
||||
add ( resume );
|
||||
|
||||
buffs = new BuffIndicator( Dungeon.hero );
|
||||
add( buffs );
|
||||
}
|
||||
|
@ -151,21 +151,49 @@ public class StatusPane extends Component {
|
|||
|
||||
keys.y = 6;
|
||||
|
||||
danger.setPos( width - danger.width(), 20 );
|
||||
|
||||
loot.setPos( width - loot.width(), danger.bottom() + 2 );
|
||||
|
||||
resume.setPos( width - resume.width(), (loot.visible ? loot.bottom() : danger.bottom()) + 2 );
|
||||
layoutTags();
|
||||
|
||||
buffs.setPos( 32, 11 );
|
||||
|
||||
btnMenu.setPos( width - btnMenu.width(), 1 );
|
||||
}
|
||||
|
||||
private void layoutTags() {
|
||||
|
||||
float pos = 18;
|
||||
|
||||
if (tagDanger) {
|
||||
danger.setPos( width - danger.width(), pos );
|
||||
pos = danger.bottom() + 1;
|
||||
}
|
||||
|
||||
if (tagLoot) {
|
||||
loot.setPos( width - loot.width(), pos );
|
||||
pos = loot.bottom() + 1;
|
||||
}
|
||||
|
||||
if (tagResume) {
|
||||
resume.setPos( width - resume.width(), pos );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean tagDanger = false;
|
||||
private boolean tagLoot = false;
|
||||
private boolean tagResume = false;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (tagDanger != danger.visible || tagLoot != loot.visible || tagResume != resume.visible) {
|
||||
|
||||
tagDanger = danger.visible;
|
||||
tagLoot = loot.visible;
|
||||
tagResume = resume.visible;
|
||||
|
||||
layoutTags();
|
||||
}
|
||||
|
||||
float health = (float)Dungeon.hero.HP / Dungeon.hero.HT;
|
||||
|
||||
if (health == 0) {
|
||||
|
@ -211,8 +239,6 @@ public class StatusPane extends Component {
|
|||
lastTier = tier;
|
||||
avatar.copy( HeroSprite.avatar( Dungeon.hero.heroClass, tier ) );
|
||||
}
|
||||
|
||||
resume.setPos( width - resume.width(), (loot.visible ? loot.bottom() : danger.bottom()) + 2 );
|
||||
}
|
||||
|
||||
private static class MenuButton extends Button {
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.watabou.noosa.Group;
|
|||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.ShadowBox;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.utils.Signal;
|
||||
|
||||
|
@ -38,6 +39,7 @@ public class Window extends Group implements Signal.Listener<Key> {
|
|||
protected int height;
|
||||
|
||||
protected TouchArea blocker;
|
||||
protected ShadowBox shadow;
|
||||
protected NinePatch chrome;
|
||||
|
||||
public static final int TITLE_COLOR = 0xFFFF44;
|
||||
|
@ -73,6 +75,12 @@ public class Window extends Group implements Signal.Listener<Key> {
|
|||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
shadow = new ShadowBox();
|
||||
shadow.am = 0.5f;
|
||||
shadow.camera = PixelScene.uiCamera.visible ?
|
||||
PixelScene.uiCamera : Camera.main;
|
||||
add( shadow );
|
||||
|
||||
chrome.x = -chrome.marginLeft();
|
||||
chrome.y = -chrome.marginTop();
|
||||
chrome.size(
|
||||
|
@ -89,6 +97,11 @@ public class Window extends Group implements Signal.Listener<Key> {
|
|||
camera.scroll.set( chrome.x, chrome.y );
|
||||
Camera.add( camera );
|
||||
|
||||
shadow.boxRect(
|
||||
camera.x / camera.zoom,
|
||||
camera.y / camera.zoom,
|
||||
chrome.width(), chrome.height );
|
||||
|
||||
Keys.event.add( this );
|
||||
}
|
||||
|
||||
|
@ -103,6 +116,8 @@ public class Window extends Group implements Signal.Listener<Key> {
|
|||
camera.resize( (int)chrome.width, (int)chrome.height );
|
||||
camera.x = (int)(Game.width - camera.screenWidth()) / 2;
|
||||
camera.y = (int)(Game.height - camera.screenHeight()) / 2;
|
||||
|
||||
shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height );
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user