Merging Source v1.7.2: window changes
This commit is contained in:
parent
735af276c8
commit
33db534e25
|
@ -20,8 +20,11 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
|
|||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
|
||||
public class IconTitle extends Component {
|
||||
|
||||
|
@ -34,6 +37,13 @@ public class IconTitle extends Component {
|
|||
|
||||
public IconTitle() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IconTitle( Item item ) {
|
||||
this(
|
||||
new ItemSprite( item.image(), item.glowing() ),
|
||||
Utils.capitalize( item.toString() ) );
|
||||
|
||||
}
|
||||
|
||||
public IconTitle( Image icon, String label ) {
|
||||
|
|
|
@ -1,7 +1,89 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 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.windows;
|
||||
|
||||
/**
|
||||
* Created by Evan on 18/10/2014.
|
||||
*/
|
||||
public class WndChallenges {
|
||||
}
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.CheckBox;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
|
||||
public class WndChallenges extends Window {
|
||||
|
||||
private static final int WIDTH = 108;
|
||||
private static final int BTN_HEIGHT = 20;
|
||||
private static final int GAP = 2;
|
||||
|
||||
private static final String TITLE = "Challenges";
|
||||
|
||||
private boolean editable;
|
||||
private ArrayList<CheckBox> boxes;
|
||||
|
||||
public WndChallenges( int checked, boolean editable ) {
|
||||
|
||||
super();
|
||||
|
||||
this.editable = editable;
|
||||
|
||||
BitmapText title = PixelScene.createText( TITLE, 9 );
|
||||
title.hardlight( TITLE_COLOR );
|
||||
title.measure();
|
||||
title.x = PixelScene.align( camera, (WIDTH - title.width()) / 2 );
|
||||
add( title );
|
||||
|
||||
boxes = new ArrayList<CheckBox>();
|
||||
|
||||
float pos = title.height() + GAP;
|
||||
for (int i=0; i < Challenges.NAMES.length; i++) {
|
||||
|
||||
CheckBox cb = new CheckBox( Challenges.NAMES[i] );
|
||||
cb.checked( (checked & Challenges.MASKS[i]) != 0 );
|
||||
cb.active = editable;
|
||||
|
||||
if (i > 0) {
|
||||
pos += GAP;
|
||||
}
|
||||
cb.setRect( 0, pos, WIDTH, BTN_HEIGHT );
|
||||
pos = cb.bottom();
|
||||
|
||||
add( cb );
|
||||
boxes.add( cb );
|
||||
}
|
||||
|
||||
resize( WIDTH, (int)pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
||||
if (editable) {
|
||||
int value = 0;
|
||||
for (int i=0; i < boxes.size(); i++) {
|
||||
if (boxes.get( i ).checked()) {
|
||||
value |= Challenges.MASKS[i];
|
||||
}
|
||||
}
|
||||
ShatteredPixelDungeon.challenges( value );
|
||||
}
|
||||
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,199 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2014 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.windows;
|
||||
|
||||
/**
|
||||
* Created by Evan on 18/10/2014.
|
||||
*/
|
||||
public class WndClass {
|
||||
}
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
|
||||
public class WndClass extends WndTabbed {
|
||||
|
||||
private static final String TXT_MASTERY = "Mastery";
|
||||
|
||||
private static final int WIDTH = 110;
|
||||
|
||||
private static final int TAB_WIDTH = 50;
|
||||
|
||||
private HeroClass cl;
|
||||
|
||||
private PerksTab tabPerks;
|
||||
private MasteryTab tabMastery;
|
||||
|
||||
public WndClass( HeroClass cl ) {
|
||||
|
||||
super();
|
||||
|
||||
this.cl = cl;
|
||||
|
||||
tabPerks = new PerksTab();
|
||||
add( tabPerks );
|
||||
|
||||
Tab tab = new RankingTab( Utils.capitalize( cl.title() ), tabPerks );
|
||||
tab.setSize( TAB_WIDTH, tabHeight() );
|
||||
add( tab );
|
||||
|
||||
if (Badges.isUnlocked( cl.masteryBadge() )) {
|
||||
tabMastery = new MasteryTab();
|
||||
add( tabMastery );
|
||||
|
||||
tab = new RankingTab( TXT_MASTERY, tabMastery );
|
||||
tab.setSize( TAB_WIDTH, tabHeight() );
|
||||
add( tab );
|
||||
|
||||
resize(
|
||||
(int)Math.max( tabPerks.width, tabMastery.width ),
|
||||
(int)Math.max( tabPerks.height, tabMastery.height ) );
|
||||
} else {
|
||||
resize( (int)tabPerks.width, (int)tabPerks.height );
|
||||
}
|
||||
|
||||
select( 0 );
|
||||
}
|
||||
|
||||
private class RankingTab extends LabeledTab {
|
||||
|
||||
private Group page;
|
||||
|
||||
public RankingTab( String label, Group page ) {
|
||||
super( label );
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void select( boolean value ) {
|
||||
super.select( value );
|
||||
if (page != null) {
|
||||
page.visible = page.active = selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PerksTab extends Group {
|
||||
|
||||
private static final int MARGIN = 4;
|
||||
private static final int GAP = 4;
|
||||
|
||||
private static final String DOT = "\u007F";
|
||||
|
||||
public float height;
|
||||
public float width;
|
||||
|
||||
public PerksTab() {
|
||||
super();
|
||||
|
||||
float dotWidth = 0;
|
||||
|
||||
String[] items = cl.perks();
|
||||
float pos = MARGIN;
|
||||
|
||||
for (int i=0; i < items.length; i++) {
|
||||
|
||||
if (i > 0) {
|
||||
pos += GAP;
|
||||
}
|
||||
|
||||
BitmapText dot = PixelScene.createText( DOT, 6 );
|
||||
dot.x = MARGIN;
|
||||
dot.y = pos;
|
||||
if (dotWidth == 0) {
|
||||
dot.measure();
|
||||
dotWidth = dot.width();
|
||||
}
|
||||
add( dot );
|
||||
|
||||
BitmapTextMultiline item = PixelScene.createMultiline( items[i], 6 );
|
||||
item.x = dot.x + dotWidth;
|
||||
item.y = pos;
|
||||
item.maxWidth = (int)(WIDTH - MARGIN * 2 - dotWidth);
|
||||
item.measure();
|
||||
add( item );
|
||||
|
||||
pos += item.height();
|
||||
float w = item.width();
|
||||
if (w > width) {
|
||||
width = w;
|
||||
}
|
||||
}
|
||||
|
||||
width += MARGIN + dotWidth;
|
||||
height = pos + MARGIN;
|
||||
}
|
||||
}
|
||||
|
||||
private class MasteryTab extends Group {
|
||||
|
||||
private static final int MARGIN = 4;
|
||||
|
||||
private BitmapTextMultiline normal;
|
||||
private BitmapTextMultiline highlighted;
|
||||
|
||||
public float height;
|
||||
public float width;
|
||||
|
||||
public MasteryTab() {
|
||||
super();
|
||||
|
||||
String text = null;
|
||||
switch (cl) {
|
||||
case WARRIOR:
|
||||
text = HeroSubClass.GLADIATOR.desc() + "\n\n" + HeroSubClass.BERSERKER.desc();
|
||||
break;
|
||||
case MAGE:
|
||||
text = HeroSubClass.BATTLEMAGE.desc() + "\n\n" + HeroSubClass.WARLOCK.desc();
|
||||
break;
|
||||
case ROGUE:
|
||||
text = HeroSubClass.FREERUNNER.desc() + "\n\n" + HeroSubClass.ASSASSIN.desc();
|
||||
break;
|
||||
case HUNTRESS:
|
||||
text = HeroSubClass.SNIPER.desc() + "\n\n" + HeroSubClass.WARDEN.desc();
|
||||
break;
|
||||
}
|
||||
|
||||
Highlighter hl = new Highlighter( text );
|
||||
|
||||
normal = PixelScene.createMultiline( hl.text, 6 );
|
||||
normal.maxWidth = WIDTH - MARGIN * 2;
|
||||
normal.measure();
|
||||
normal.x = MARGIN;
|
||||
normal.y = MARGIN;
|
||||
add( normal );
|
||||
|
||||
if (hl.isHighlighted()) {
|
||||
normal.mask = hl.inverted();
|
||||
|
||||
highlighted = PixelScene.createMultiline( hl.text, 6 );
|
||||
highlighted.maxWidth = normal.maxWidth;
|
||||
highlighted.measure();
|
||||
highlighted.x = normal.x;
|
||||
highlighted.y = normal.y;
|
||||
add( highlighted );
|
||||
|
||||
highlighted.mask = hl.mask;
|
||||
highlighted.hardlight( TITLE_COLOR );
|
||||
}
|
||||
|
||||
height = normal.y + normal.height() + MARGIN;
|
||||
width = normal.x + normal.width() + MARGIN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
|
||||
import com.watabou.noosa.Game;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.RankingsScene;
|
||||
|
@ -32,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
|||
public class WndGame extends Window {
|
||||
|
||||
private static final String TXT_SETTINGS = "Settings";
|
||||
private static final String TXT_CHALLEGES = "Challenges";
|
||||
private static final String TXT_RANKINGS = "Rankings";
|
||||
private static final String TXT_START = "Start New Game";
|
||||
private static final String TXT_MENU = "Main Menu";
|
||||
|
@ -55,15 +57,27 @@ public class WndGame extends Window {
|
|||
GameScene.show( new WndSettings( true ) );
|
||||
}
|
||||
} );
|
||||
|
||||
// Restart
|
||||
if (!Dungeon.hero.isAlive()) {
|
||||
|
||||
// Challenges window
|
||||
if (Dungeon.challenges > 0) {
|
||||
addButton( new RedButton( TXT_CHALLEGES ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
hide();
|
||||
GameScene.show( new WndChallenges( Dungeon.challenges, false ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// Restart
|
||||
if (!Dungeon.hero.isAlive()) {
|
||||
|
||||
RedButton btnStart;
|
||||
addButton( btnStart = new RedButton( TXT_START ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
Dungeon.hero = null;
|
||||
ShatteredPixelDungeon.challenges( Dungeon.challenges );
|
||||
InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
|
||||
InterlevelScene.noStory = true;
|
||||
Game.switchScene( InterlevelScene.class );
|
||||
|
|
|
@ -28,12 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
|||
|
||||
public class WndInfoMob extends WndTitledMessage {
|
||||
|
||||
private static final String TXT_SLEEPNIG = "\n\nThis %s is sleeping.";
|
||||
private static final String TXT_HUNTING = "\n\nThis %s is hunting.";
|
||||
private static final String TXT_WANDERING = "\n\nThis %s is wandering.";
|
||||
private static final String TXT_FLEEING = "\n\nThis %s is fleeing.";
|
||||
private static final String TXT_PASSIVE = "\n\nThe %s is passive.";
|
||||
|
||||
public WndInfoMob( Mob mob ) {
|
||||
|
||||
super( new MobTitle( mob ), desc( mob ) );
|
||||
|
@ -43,24 +37,8 @@ public class WndInfoMob extends WndTitledMessage {
|
|||
private static String desc( Mob mob ) {
|
||||
|
||||
StringBuilder builder = new StringBuilder( mob.description() );
|
||||
|
||||
switch (mob.state) {
|
||||
case SLEEPING:
|
||||
builder.append( String.format( TXT_SLEEPNIG, mob.name ) );
|
||||
break;
|
||||
case HUNTING:
|
||||
builder.append( String.format( TXT_HUNTING, mob.name ) );
|
||||
break;
|
||||
case WANDERING:
|
||||
builder.append( String.format( TXT_WANDERING, mob.name ) );
|
||||
break;
|
||||
case FLEEING:
|
||||
builder.append( String.format( TXT_FLEEING, mob.name ) );
|
||||
break;
|
||||
case PASSIVE:
|
||||
builder.append( String.format( TXT_PASSIVE, mob.name ) );
|
||||
break;
|
||||
}
|
||||
|
||||
builder.append( "\n\n" + mob.state.status() + "." );
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
|
||||
public class WndQuest extends WndTitledMessage {
|
||||
|
||||
public WndQuest( Mob.NPC questgiver, String text ) {
|
||||
super( questgiver.sprite(), Utils.capitalize( questgiver.name ), text );
|
||||
}
|
||||
|
||||
public WndQuest( NPC questgiver, String text ) {
|
||||
super( questgiver.sprite(), Utils.capitalize( questgiver.name ), text );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.*;
|
||||
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.Game;
|
||||
|
@ -35,6 +35,12 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BadgesList;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
|
||||
public class WndRanking extends WndTabbed {
|
||||
|
@ -139,7 +145,9 @@ public class WndRanking extends WndTabbed {
|
|||
private static final int GAP = 4;
|
||||
|
||||
private static final String TXT_TITLE = "Level %d %s";
|
||||
|
||||
|
||||
private static final String TXT_CHALLENGES = "Challenges";
|
||||
|
||||
private static final String TXT_HEALTH = "Health";
|
||||
private static final String TXT_STR = "Strength";
|
||||
|
||||
|
@ -165,7 +173,22 @@ public class WndRanking extends WndTabbed {
|
|||
title.setRect( 0, 0, WIDTH, 0 );
|
||||
add( title );
|
||||
|
||||
float pos = title.bottom() + GAP + GAP;
|
||||
float pos = title.bottom();
|
||||
|
||||
if (Dungeon.challenges > 0) {
|
||||
RedButton btnCatalogus = new RedButton( TXT_CHALLENGES ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
Game.scene().add( new WndChallenges( Dungeon.challenges, false ) );
|
||||
}
|
||||
};
|
||||
btnCatalogus.setRect( 0, pos + GAP, btnCatalogus.reqWidth() + 2, btnCatalogus.reqHeight() + 2 );
|
||||
add( btnCatalogus );
|
||||
|
||||
pos = btnCatalogus.bottom();
|
||||
}
|
||||
|
||||
pos += GAP + GAP;
|
||||
|
||||
pos = statSlot( this, TXT_STR, Integer.toString( Dungeon.hero.STR ), pos );
|
||||
pos = statSlot( this, TXT_HEALTH, Integer.toString( Dungeon.hero.HT ), pos );
|
||||
|
|
|
@ -33,6 +33,7 @@ public class WndSettings extends Window {
|
|||
private static final String TXT_ZOOM_DEFAULT = "Default Zoom";
|
||||
|
||||
private static final String TXT_SCALE_UP = "Scale up UI";
|
||||
private static final String TXT_IMMERSIVE = "Immersive mode";
|
||||
|
||||
private static final String TXT_MUSIC = "Music";
|
||||
|
||||
|
@ -52,7 +53,9 @@ public class WndSettings extends Window {
|
|||
|
||||
public WndSettings( boolean inGame ) {
|
||||
super();
|
||||
|
||||
|
||||
CheckBox btnImmersive = null;
|
||||
|
||||
if (inGame) {
|
||||
int w = BTN_HEIGHT;
|
||||
|
||||
|
@ -94,8 +97,20 @@ public class WndSettings extends Window {
|
|||
btnScaleUp.setRect( 0, 0, WIDTH, BTN_HEIGHT );
|
||||
btnScaleUp.checked( ShatteredPixelDungeon.scaleUp() );
|
||||
add( btnScaleUp );
|
||||
|
||||
}
|
||||
|
||||
btnImmersive = new CheckBox( TXT_IMMERSIVE ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
ShatteredPixelDungeon.immerse( checked() );
|
||||
}
|
||||
};
|
||||
btnImmersive.setRect( 0, btnScaleUp.bottom() + GAP, WIDTH, BTN_HEIGHT );
|
||||
btnImmersive.checked( ShatteredPixelDungeon.immersed() );
|
||||
btnImmersive.enable( android.os.Build.VERSION.SDK_INT >= 19 );
|
||||
add( btnImmersive );
|
||||
|
||||
}
|
||||
|
||||
CheckBox btnMusic = new CheckBox( TXT_MUSIC ) {
|
||||
@Override
|
||||
|
@ -104,7 +119,7 @@ public class WndSettings extends Window {
|
|||
ShatteredPixelDungeon.music(checked());
|
||||
}
|
||||
};
|
||||
btnMusic.setRect( 0, BTN_HEIGHT + GAP, WIDTH, BTN_HEIGHT );
|
||||
btnMusic.setRect( 0, (btnImmersive != null ? btnImmersive.bottom() : BTN_HEIGHT) + GAP, WIDTH, BTN_HEIGHT );
|
||||
btnMusic.checked( ShatteredPixelDungeon.music() );
|
||||
add( btnMusic );
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user