v2.5.0: Substantially improved alchemy UI, mainly for larger screens
This commit is contained in:
+103
-50
@@ -53,8 +53,10 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RadialMenu;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.StyledButton;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.windows.IconTitle;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndEnergizeItem;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndEnergizeItem;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoItem;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoItem;
|
||||||
@@ -104,6 +106,9 @@ public class AlchemyScene extends PixelScene {
|
|||||||
private IconButton energyAdd;
|
private IconButton energyAdd;
|
||||||
private boolean energyAddBlinking = false;
|
private boolean energyAddBlinking = false;
|
||||||
|
|
||||||
|
private static boolean splitAlchGuide = false;
|
||||||
|
private static int centerW;
|
||||||
|
|
||||||
private static final int BTN_SIZE = 28;
|
private static final int BTN_SIZE = 28;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -151,26 +156,50 @@ public class AlchemyScene extends PixelScene {
|
|||||||
add( btnExit );
|
add( btnExit );
|
||||||
|
|
||||||
bubbleEmitter = new Emitter();
|
bubbleEmitter = new Emitter();
|
||||||
bubbleEmitter.pos(0, 0, Camera.main.width, Camera.main.height);
|
|
||||||
bubbleEmitter.autoKill = false;
|
|
||||||
add(bubbleEmitter);
|
add(bubbleEmitter);
|
||||||
|
|
||||||
lowerBubbles = new Emitter();
|
lowerBubbles = new Emitter();
|
||||||
add(lowerBubbles);
|
add(lowerBubbles);
|
||||||
|
|
||||||
RenderedTextBlock title = PixelScene.renderTextBlock( Messages.get(this, "title"), 9 );
|
IconTitle title = new IconTitle(Icons.ALCHEMY.get(), Messages.get(this, "title") );
|
||||||
title.hardlight(Window.TITLE_COLOR);
|
title.setSize(200, 0);
|
||||||
title.setPos(
|
title.setPos(
|
||||||
(Camera.main.width - title.width()) / 2f,
|
(Camera.main.width - title.reqWidth()) / 2f,
|
||||||
(20 - title.height()) / 2f
|
(20 - title.height()) / 2f
|
||||||
);
|
);
|
||||||
align(title);
|
align(title);
|
||||||
add(title);
|
add(title);
|
||||||
|
|
||||||
int w = 50 + Camera.main.width/2;
|
int w = Math.min(50 + Camera.main.width/2, 150);
|
||||||
int left = (Camera.main.width - w)/2;
|
int left = (Camera.main.width - w)/2;
|
||||||
|
|
||||||
int pos = (Camera.main.height - 100)/2;
|
centerW = left + w/2;
|
||||||
|
|
||||||
|
int pos = (Camera.main.height - 120)/2;
|
||||||
|
|
||||||
|
if (splitAlchGuide &&
|
||||||
|
Camera.main.width >= 300 &&
|
||||||
|
Camera.main.height >= PixelScene.MIN_HEIGHT_FULL){
|
||||||
|
w = Math.min(150, Camera.main.width/2);
|
||||||
|
left = (Camera.main.width/2 - w);
|
||||||
|
centerW = left + w/2;
|
||||||
|
|
||||||
|
NinePatch guideBG = Chrome.get(Chrome.Type.TOAST);
|
||||||
|
guideBG.size(126 + guideBG.marginHor(), Math.min(Camera.main.height - 18, 191 + guideBG.marginVer()));
|
||||||
|
guideBG.y = Math.max(17, (Camera.main.height - guideBG.height())/2f);
|
||||||
|
guideBG.x = Camera.main.width - left - guideBG.width();
|
||||||
|
add(guideBG);
|
||||||
|
|
||||||
|
WndJournal.AlchemyTab alchGuide = new WndJournal.AlchemyTab();
|
||||||
|
add(alchGuide);
|
||||||
|
alchGuide.setRect(guideBG.x + guideBG.marginLeft(),
|
||||||
|
guideBG.y + guideBG.marginTop(),
|
||||||
|
guideBG.width() - guideBG.marginHor(),
|
||||||
|
guideBG.height() - guideBG.marginVer());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
splitAlchGuide = false;
|
||||||
|
}
|
||||||
|
|
||||||
RenderedTextBlock desc = PixelScene.renderTextBlock(6);
|
RenderedTextBlock desc = PixelScene.renderTextBlock(6);
|
||||||
desc.maxWidth(w);
|
desc.maxWidth(w);
|
||||||
@@ -361,46 +390,23 @@ public class AlchemyScene extends PixelScene {
|
|||||||
|
|
||||||
pos += 10;
|
pos += 10;
|
||||||
|
|
||||||
lowerBubbles.pos(0, pos, Camera.main.width, Math.max(0, Camera.main.height-pos));
|
if (Camera.main.height >= 280){
|
||||||
|
//last elements get centered even with a split alch guide UI, as long as there's enough height
|
||||||
|
centerW = Camera.main.width/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bubbleEmitter.pos(0,
|
||||||
|
0,
|
||||||
|
2*centerW,
|
||||||
|
Camera.main.height);
|
||||||
|
bubbleEmitter.autoKill = false;
|
||||||
|
|
||||||
|
lowerBubbles.pos(0,
|
||||||
|
pos,
|
||||||
|
2*centerW,
|
||||||
|
Math.max(0, Camera.main.height-pos));
|
||||||
lowerBubbles.pour(Speck.factory( Speck.BUBBLE ), 0.1f );
|
lowerBubbles.pour(Speck.factory( Speck.BUBBLE ), 0.1f );
|
||||||
|
|
||||||
IconButton btnGuide = new IconButton( new ItemSprite(ItemSpriteSheet.ALCH_PAGE, null)){
|
|
||||||
@Override
|
|
||||||
protected void onClick() {
|
|
||||||
super.onClick();
|
|
||||||
clearSlots();
|
|
||||||
updateState();
|
|
||||||
AlchemyScene.this.addToFront(new Window(){
|
|
||||||
|
|
||||||
{
|
|
||||||
WndJournal.AlchemyTab t = new WndJournal.AlchemyTab();
|
|
||||||
int w, h;
|
|
||||||
if (landscape()) {
|
|
||||||
w = WndJournal.WIDTH_L; h = WndJournal.HEIGHT_L;
|
|
||||||
} else {
|
|
||||||
w = WndJournal.WIDTH_P; h = WndJournal.HEIGHT_P;
|
|
||||||
}
|
|
||||||
resize(w, h);
|
|
||||||
add(t);
|
|
||||||
t.setRect(0, 0, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GameAction keyAction() {
|
|
||||||
return SPDAction.JOURNAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String hoverText() {
|
|
||||||
return Messages.titleCase(Document.ALCHEMY_GUIDE.title());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
btnGuide.setRect(0, 0, 20, 20);
|
|
||||||
add(btnGuide);
|
|
||||||
|
|
||||||
String energyText = Messages.get(AlchemyScene.class, "energy") + " " + Dungeon.energy;
|
String energyText = Messages.get(AlchemyScene.class, "energy") + " " + Dungeon.energy;
|
||||||
if (toolkit != null){
|
if (toolkit != null){
|
||||||
energyText += "+" + toolkit.availableEnergy();
|
energyText += "+" + toolkit.availableEnergy();
|
||||||
@@ -408,7 +414,7 @@ public class AlchemyScene extends PixelScene {
|
|||||||
|
|
||||||
energyLeft = PixelScene.renderTextBlock(energyText, 9);
|
energyLeft = PixelScene.renderTextBlock(energyText, 9);
|
||||||
energyLeft.setPos(
|
energyLeft.setPos(
|
||||||
(Camera.main.width - energyLeft.width())/2,
|
centerW - energyLeft.width()/2,
|
||||||
Camera.main.height - 8 - energyLeft.height()
|
Camera.main.height - 8 - energyLeft.height()
|
||||||
);
|
);
|
||||||
energyLeft.hardlight(0x44CCFF);
|
energyLeft.hardlight(0x44CCFF);
|
||||||
@@ -460,7 +466,54 @@ public class AlchemyScene extends PixelScene {
|
|||||||
sparkEmitter.pos(energyLeft.left(), energyLeft.top(), energyLeft.width(), energyLeft.height());
|
sparkEmitter.pos(energyLeft.left(), energyLeft.top(), energyLeft.width(), energyLeft.height());
|
||||||
sparkEmitter.autoKill = false;
|
sparkEmitter.autoKill = false;
|
||||||
add(sparkEmitter);
|
add(sparkEmitter);
|
||||||
|
|
||||||
|
StyledButton btnGuide = new StyledButton( Chrome.Type.TOAST_TR, "Guide"){
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
super.onClick();
|
||||||
|
if (Camera.main.width >= 300 && Camera.main.height >= PixelScene.MIN_HEIGHT_FULL){
|
||||||
|
splitAlchGuide = !splitAlchGuide;
|
||||||
|
ShatteredPixelDungeon.seamlessResetScene();
|
||||||
|
} else {
|
||||||
|
clearSlots();
|
||||||
|
updateState();
|
||||||
|
AlchemyScene.this.addToFront(new Window() {
|
||||||
|
|
||||||
|
{
|
||||||
|
WndJournal.AlchemyTab t = new WndJournal.AlchemyTab();
|
||||||
|
int w, h;
|
||||||
|
if (landscape()) {
|
||||||
|
w = WndJournal.WIDTH_L;
|
||||||
|
h = WndJournal.HEIGHT_L+8;
|
||||||
|
} else {
|
||||||
|
w = WndJournal.WIDTH_P;
|
||||||
|
h = WndJournal.HEIGHT_P+10;
|
||||||
|
}
|
||||||
|
resize(w, h);
|
||||||
|
add(t);
|
||||||
|
t.setRect(0, 0, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameAction keyAction() {
|
||||||
|
return SPDAction.JOURNAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String hoverText() {
|
||||||
|
return Messages.titleCase(Document.ALCHEMY_GUIDE.title());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnGuide.icon(new ItemSprite(ItemSpriteSheet.ALCH_PAGE));
|
||||||
|
btnGuide.setSize(btnGuide.reqWidth()+4, 18);
|
||||||
|
btnGuide.setPos(centerW - btnGuide.width()/2f, energyAdd.top()- btnGuide.height()-2);
|
||||||
|
align(btnGuide);
|
||||||
|
add(btnGuide);
|
||||||
|
|
||||||
fadeIn();
|
fadeIn();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -623,7 +676,7 @@ public class AlchemyScene extends PixelScene {
|
|||||||
}
|
}
|
||||||
energyLeft.text(energyText);
|
energyLeft.text(energyText);
|
||||||
energyLeft.setPos(
|
energyLeft.setPos(
|
||||||
(Camera.main.width - energyLeft.width())/2,
|
centerW - energyLeft.width()/2,
|
||||||
Camera.main.height - 8 - energyLeft.height()
|
Camera.main.height - 8 - energyLeft.height()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -770,7 +823,7 @@ public class AlchemyScene extends PixelScene {
|
|||||||
}
|
}
|
||||||
energyLeft.text(energyText);
|
energyLeft.text(energyText);
|
||||||
energyLeft.setPos(
|
energyLeft.setPos(
|
||||||
(Camera.main.width - energyLeft.width())/2,
|
centerW - energyLeft.width()/2,
|
||||||
Camera.main.height - 8 - energyLeft.height()
|
Camera.main.height - 8 - energyLeft.height()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ public class WndJournal extends WndTabbed {
|
|||||||
protected void layout() {
|
protected void layout() {
|
||||||
super.layout();
|
super.layout();
|
||||||
|
|
||||||
if (PixelScene.landscape()){
|
if (width() >= 180){
|
||||||
float buttonWidth = width()/pageButtons.length;
|
float buttonWidth = width()/pageButtons.length;
|
||||||
for (int i = 0; i < NUM_BUTTONS; i++) {
|
for (int i = 0; i < NUM_BUTTONS; i++) {
|
||||||
pageButtons[i].setRect(x + i*buttonWidth, y, buttonWidth, ITEM_HEIGHT);
|
pageButtons[i].setRect(x + i*buttonWidth, y, buttonWidth, ITEM_HEIGHT);
|
||||||
|
|||||||
Reference in New Issue
Block a user