v0.9.3: improved the visuals for WndOptions

This commit is contained in:
Evan Debenham 2021-04-29 20:08:04 -04:00
parent e5a760f671
commit 4bef7c7d04
21 changed files with 93 additions and 113 deletions

View File

@ -113,7 +113,8 @@ public class BrokenSeal extends Item {
} else if (armor.glyph != null && seal.getGlyph() != null
&& armor.glyph.getClass() != seal.getGlyph().getClass()) {
GameScene.show(new WndOptions(Messages.get(BrokenSeal.class, "choose_title"),
GameScene.show(new WndOptions(new ItemSprite(seal),
Messages.get(BrokenSeal.class, "choose_title"),
Messages.get(BrokenSeal.class, "choose_desc"),
armor.glyph.name(),
seal.getGlyph().name()){

View File

@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
@ -84,7 +85,8 @@ public abstract class KindofMisc extends EquipableItem {
}
GameScene.show(
new WndOptions(Messages.get(KindofMisc.class, "unequip_title"),
new WndOptions(new ItemSprite(this),
Messages.get(KindofMisc.class, "unequip_title"),
Messages.get(KindofMisc.class, "unequip_message"),
miscs[0] == null ? "---" : Messages.titleCase(miscs[0].toString()),
miscs[1] == null ? "---" : Messages.titleCase(miscs[1].toString()),

View File

@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLivingEarth;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
@ -67,7 +68,8 @@ public class ChaliceOfBlood extends Artifact {
if (damage > hero.HP*0.75) {
GameScene.show(
new WndOptions(Messages.titleCase(Messages.get(this, "name")),
new WndOptions(new ItemSprite(this),
Messages.titleCase(name()),
Messages.get(this, "prick_warn"),
Messages.get(this, "yes"),
Messages.get(this, "no")) {

View File

@ -35,6 +35,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEnergy;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
@ -89,7 +90,8 @@ public class TimekeepersHourglass extends Artifact {
} else if (charge <= 0) GLog.i( Messages.get(this, "no_charge") );
else if (cursed) GLog.i( Messages.get(this, "cursed") );
else GameScene.show(
new WndOptions( Messages.get(this, "name"),
new WndOptions(new ItemSprite(this),
Messages.titleCase(name()),
Messages.get(this, "prompt"),
Messages.get(this, "stasis"),
Messages.get(this, "freeze")) {

View File

@ -41,6 +41,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTransmutat
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ExoticScroll;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
@ -140,7 +141,7 @@ public class UnstableSpellbook extends Artifact {
final ExploitHandler handler = Buff.affect(hero, ExploitHandler.class);
handler.scroll = scroll;
GameScene.show(new WndOptions(
GameScene.show(new WndOptions(new ItemSprite(this),
Messages.get(this, "prompt"),
Messages.get(this, "read_empowered"),
scroll.trueName(),

View File

@ -238,7 +238,8 @@ public class Potion extends Item {
if (isKnown() && mustThrowPots.contains(getClass())) {
GameScene.show(
new WndOptions( Messages.get(Potion.class, "harmful"),
new WndOptions(new ItemSprite(this),
Messages.get(Potion.class, "harmful"),
Messages.get(Potion.class, "sure_drink"),
Messages.get(Potion.class, "yes"), Messages.get(Potion.class, "no") ) {
@Override
@ -265,7 +266,8 @@ public class Potion extends Item {
&& !canThrowPots.contains(this.getClass())) {
GameScene.show(
new WndOptions( Messages.get(Potion.class, "beneficial"),
new WndOptions(new ItemSprite(this),
Messages.get(Potion.class, "beneficial"),
Messages.get(Potion.class, "sure_throw"),
Messages.get(Potion.class, "yes"), Messages.get(Potion.class, "no") ) {
@Override

View File

@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.noosa.audio.Sample;
@ -48,8 +49,11 @@ public abstract class InventoryScroll extends Scroll {
}
private void confirmCancelation() {
GameScene.show( new WndOptions( Messages.titleCase(name()), Messages.get(this, "warning"),
Messages.get(this, "yes"), Messages.get(this, "no") ) {
GameScene.show( new WndOptions(new ItemSprite(this),
Messages.titleCase(name()),
Messages.get(this, "warning"),
Messages.get(this, "yes"),
Messages.get(this, "no") ) {
@Override
protected void onSelect( int index ) {
switch (index) {

View File

@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
@ -65,7 +66,8 @@ public class ScrollOfEnchantment extends ExoticScroll {
enchants[1] = Weapon.Enchantment.randomUncommon( existing );
enchants[2] = Weapon.Enchantment.random( existing, enchants[0].getClass(), enchants[1].getClass());
GameScene.show(new WndOptions(Messages.titleCase(ScrollOfEnchantment.this.name()),
GameScene.show(new WndOptions(new ItemSprite(ScrollOfEnchantment.this),
Messages.titleCase(ScrollOfEnchantment.this.name()),
Messages.get(ScrollOfEnchantment.class, "weapon") +
"\n\n" +
Messages.get(ScrollOfEnchantment.class, "cancel_warn"),
@ -102,7 +104,8 @@ public class ScrollOfEnchantment extends ExoticScroll {
glyphs[1] = Armor.Glyph.randomUncommon( existing );
glyphs[2] = Armor.Glyph.random( existing, glyphs[0].getClass(), glyphs[1].getClass());
GameScene.show(new WndOptions(Messages.titleCase(ScrollOfEnchantment.this.name()),
GameScene.show(new WndOptions( new ItemSprite(ScrollOfEnchantment.this),
Messages.titleCase(ScrollOfEnchantment.this.name()),
Messages.get(ScrollOfEnchantment.class, "armor") +
"\n\n" +
Messages.get(ScrollOfEnchantment.class, "cancel_warn"),

View File

@ -59,7 +59,8 @@ public class BeaconOfReturning extends Spell {
if (returnDepth == -1){
setBeacon(hero);
} else {
GameScene.show(new WndOptions(Messages.titleCase(name()),
GameScene.show(new WndOptions(new ItemSprite(this),
Messages.titleCase(name()),
Messages.get(BeaconOfReturning.class, "wnd_body"),
Messages.get(BeaconOfReturning.class, "wnd_set"),
Messages.get(BeaconOfReturning.class, "wnd_return")){

View File

@ -64,6 +64,7 @@ import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.TargetHealthIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
@ -371,7 +372,12 @@ public class CursedWand {
return cursedEffect(origin, user, targetPos);
} else {
GameScene.show(
new WndOptions("CURSED WAND ERROR", "this application will now self-destruct", "abort", "retry", "fail") {
new WndOptions(Icons.get(Icons.WARNING),
"CURSED WAND ERROR",
"this application will now self-destruct",
"abort",
"retry",
"fail") {
@Override
protected void onSelect(int index) {

View File

@ -382,7 +382,8 @@ public class WandOfWarding extends Wand {
Game.runOnRenderThread(new Callback() {
@Override
public void call() {
GameScene.show(new WndOptions( Messages.get(Ward.this, "dismiss_title"),
GameScene.show(new WndOptions( sprite(),
Messages.get(Ward.this, "dismiss_title"),
Messages.get(Ward.this, "dismiss_body"),
Messages.get(Ward.this, "dismiss_confirm"),
Messages.get(Ward.this, "dismiss_cancel") ){

View File

@ -44,6 +44,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
@ -403,7 +404,8 @@ public class MagesStaff extends MeleeWeapon {
}
GameScene.show(
new WndOptions("",
new WndOptions(new ItemSprite(item),
Messages.titleCase(item.name()),
bodyText,
Messages.get(MagesStaff.class, "yes"),
Messages.get(MagesStaff.class, "no")) {

View File

@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWea
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
@ -200,7 +201,8 @@ public class Dart extends MissileWeapon {
TippedDart tipResult = TippedDart.getTipped((Plant.Seed) item, 1);
GameScene.show(new WndOptions(Messages.get(Dart.class, "tip_title"),
GameScene.show(new WndOptions( new ItemSprite(item),
Messages.titleCase(item.name()),
Messages.get(Dart.class, "tip_desc", tipResult.name()) + "\n\n" + tipResult.desc(),
options){

View File

@ -45,6 +45,7 @@ import com.shatteredpixel.shatteredpixeldungeon.plants.Stormvine;
import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass;
import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.utils.Reflection;
@ -74,7 +75,8 @@ public abstract class TippedDart extends Dart {
super.execute(hero, action);
if (action.equals( AC_CLEAN )){
GameScene.show(new WndOptions(Messages.get(this, "clean_title"),
GameScene.show(new WndOptions(new ItemSprite(this),
Messages.titleCase(name()),
Messages.get(this, "clean_desc"),
Messages.get(this, "clean_all"),
Messages.get(this, "clean_one"),

View File

@ -44,6 +44,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.noosa.Camera;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
@ -57,7 +58,8 @@ public class Chasm implements Hero.Doom {
@Override
public void call() {
GameScene.show(
new WndOptions( Messages.get(Chasm.class, "chasm"),
new WndOptions( new Image(Dungeon.level.tilesTex(), 48, 48, 16, 16),
Messages.get(Chasm.class, "chasm"),
Messages.get(Chasm.class, "jump"),
Messages.get(Chasm.class, "yes"),
Messages.get(Chasm.class, "no") ) {

View File

@ -80,6 +80,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Banner;
import com.shatteredpixel.shatteredpixeldungeon.ui.BusyIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.CharHealthIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.ResumeIndicator;
@ -1137,8 +1138,10 @@ public class GameScene extends PixelScene {
} else if (objects.size() == 1){
examineObject(objects.get(0));
} else {
GameScene.show(new WndOptions(Messages.get(GameScene.class, "choose_examine"),
Messages.get(GameScene.class, "multiple_examine"), names.toArray(new String[names.size()])){
GameScene.show(new WndOptions(Icons.get(Icons.INFO),
Messages.get(GameScene.class, "choose_examine"),
Messages.get(GameScene.class, "multiple_examine"),
names.toArray(new String[names.size()])){
@Override
protected void onSelect(int index) {
examineObject(objects.get(index));

View File

@ -287,6 +287,7 @@ public class TitleScene extends PixelScene {
AvailableUpdateData update = Updates.updateData();
ShatteredPixelDungeon.scene().addToFront( new WndOptions(
Icons.get(Icons.CHANGES),
update.versionName == null ? Messages.get(this,"title") : Messages.get(this,"versioned_title", update.versionName),
update.desc == null ? Messages.get(this,"desc") : update.desc,
Messages.get(this,"update"),

View File

@ -1,81 +0,0 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2021 Evan Debenham
*
* 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.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.services.updates.AvailableUpdateData;
import com.shatteredpixel.shatteredpixeldungeon.services.updates.Updates;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.noosa.Game;
public class UpdateNotification extends StyledButton {
public UpdateNotification(){
super( Chrome.Type.GREY_BUTTON_TR, Messages.get(UpdateNotification.class, "title") );
textColor( Window.SHPX_COLOR );
visible = false;
Updates.checkForUpdate();
}
@Override
public void update() {
super.update();
if (Updates.updateAvailable()){
bg.alpha((float) (0.7f + Math.sin(Game.timeTotal*2)*0.3f));
text.alpha((float) (0.7f + Math.sin(Game.timeTotal*2)*0.3f));
visible = true;
} else {
visible = false;
}
}
@Override
protected void onClick() {
if (Updates.updateAvailable()){
ShatteredPixelDungeon.scene().addToFront( new WndUpdate( Updates.updateData() ) );
}
}
public static class WndUpdate extends WndOptions {
private AvailableUpdateData update;
public WndUpdate( AvailableUpdateData update ){
super(
update.versionName == null ? Messages.get(WndUpdate.class,"title") : Messages.get(WndUpdate.class,"versioned_title", update.versionName),
update.desc == null ? Messages.get(WndUpdate.class,"desc") : update.desc,
Messages.get(WndUpdate.class,"button"));
this.update = update;
}
@Override
protected void onSelect(int index) {
if (index == 0) {
Updates.launchUpdate(update);
}
}
}
}

View File

@ -138,7 +138,7 @@ public class WndGameInProgress extends Window {
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.scene().add(new WndOptions(
ShatteredPixelDungeon.scene().add(new WndOptions(Icons.get(Icons.WARNING),
Messages.get(WndGameInProgress.class, "erase_warn_title"),
Messages.get(WndGameInProgress.class, "erase_warn_body"),
Messages.get(WndGameInProgress.class, "erase_warn_yes"),

View File

@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.noosa.Image;
public class WndOptions extends Window {
@ -32,7 +33,24 @@ public class WndOptions extends Window {
private static final int WIDTH_L = 144;
private static final int MARGIN = 2;
private static final int BUTTON_HEIGHT = 20;
private static final int BUTTON_HEIGHT = 18;
public WndOptions(Image icon, String title, String message, String... options) {
super();
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
float pos = 0;
if (title != null) {
IconTitle tfTitle = new IconTitle(icon, title);
tfTitle.setRect(0, pos, width, 0);
add(tfTitle);
pos = tfTitle.bottom() + 2*MARGIN;
}
layoutBody(pos, message, options);
}
public WndOptions( String title, String message, String... options ) {
super();
@ -47,16 +65,22 @@ public class WndOptions extends Window {
tfTitle.maxWidth(width - MARGIN * 2);
add(tfTitle);
pos = tfTitle.bottom() + 3*MARGIN;
pos = tfTitle.bottom() + 2*MARGIN;
}
layoutBody(pos, message, options);
}
private void layoutBody(float pos, String message, String... options){
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
RenderedTextBlock tfMesage = PixelScene.renderTextBlock( 6 );
tfMesage.text(message, width - MARGIN * 2);
tfMesage.setPos( MARGIN, pos );
tfMesage.text(message, width);
tfMesage.setPos( 0, pos );
add( tfMesage );
pos = tfMesage.bottom() + 2*MARGIN;
for (int i=0; i < options.length; i++) {
final int index = i;
RedButton btn = new RedButton( options[i] ) {
@ -67,13 +91,13 @@ public class WndOptions extends Window {
}
};
btn.enable(enabled(i));
btn.setRect( MARGIN, pos, width - MARGIN * 2, BUTTON_HEIGHT );
btn.setRect( 0, pos, width, BUTTON_HEIGHT );
add( btn );
pos += BUTTON_HEIGHT + MARGIN;
}
resize( width, (int)pos );
resize( width, (int)(pos - MARGIN) );
}
protected boolean enabled( int index ){

View File

@ -230,7 +230,7 @@ public class WndSettings extends WndTabbed {
super.onClick();
if (checked()) {
checked(!checked());
ShatteredPixelDungeon.scene().add(new WndOptions(
ShatteredPixelDungeon.scene().add(new WndOptions(Icons.get(Icons.DISPLAY),
Messages.get(DisplayTab.class, "saver"),
Messages.get(DisplayTab.class, "saver_desc"),
Messages.get(DisplayTab.class, "okay"),