2014-07-27 13:39:07 +00:00
|
|
|
/*
|
|
|
|
* Pixel Dungeon
|
2015-06-12 20:44:04 +00:00
|
|
|
* Copyright (C) 2012-2015 Oleg Dolya
|
|
|
|
*
|
|
|
|
* Shattered Pixel Dungeon
|
|
|
|
* Copyright (C) 2014-2015 Evan Debenham
|
2014-07-27 13:39:07 +00:00
|
|
|
*
|
|
|
|
* 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/>
|
|
|
|
*/
|
2014-08-03 18:46:22 +00:00
|
|
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
2014-07-27 13:39:07 +00:00
|
|
|
|
2016-01-13 05:53:17 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
|
2015-12-31 19:52:11 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
2016-01-13 05:53:17 +00:00
|
|
|
import com.watabou.noosa.BitmapText;
|
|
|
|
import com.watabou.noosa.Image;
|
|
|
|
import com.watabou.noosa.RenderedText;
|
|
|
|
import com.watabou.noosa.ui.Component;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Journal;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
public class WndJournal extends Window {
|
2015-02-06 06:07:22 +00:00
|
|
|
|
|
|
|
private static final int WIDTH = 112;
|
|
|
|
private static final int HEIGHT_P = 160;
|
|
|
|
private static final int HEIGHT_L = 144;
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
private static final int ITEM_HEIGHT = 18;
|
|
|
|
|
2016-01-13 05:53:17 +00:00
|
|
|
private RenderedText txtTitle;
|
2014-07-27 13:39:07 +00:00
|
|
|
private ScrollPane list;
|
|
|
|
|
|
|
|
public WndJournal() {
|
|
|
|
|
|
|
|
super();
|
2015-02-06 06:07:22 +00:00
|
|
|
resize( WIDTH, ShatteredPixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P );
|
|
|
|
|
2016-01-13 05:53:17 +00:00
|
|
|
txtTitle = PixelScene.renderText( Messages.get(this, "title"), 9 );
|
2014-07-27 13:39:07 +00:00
|
|
|
txtTitle.hardlight( Window.TITLE_COLOR );
|
2015-09-10 23:29:25 +00:00
|
|
|
txtTitle.x = (WIDTH - txtTitle.width()) / 2;
|
2014-07-27 13:39:07 +00:00
|
|
|
add( txtTitle );
|
|
|
|
|
|
|
|
Component content = new Component();
|
|
|
|
|
|
|
|
Collections.sort( Journal.records );
|
|
|
|
|
|
|
|
float pos = 0;
|
|
|
|
for (Journal.Record rec : Journal.records) {
|
|
|
|
ListItem item = new ListItem( rec.feature, rec.depth );
|
|
|
|
item.setRect( 0, pos, WIDTH, ITEM_HEIGHT );
|
|
|
|
content.add( item );
|
|
|
|
|
|
|
|
pos += item.height();
|
|
|
|
}
|
|
|
|
|
|
|
|
content.setSize( WIDTH, pos );
|
|
|
|
|
|
|
|
list = new ScrollPane( content );
|
|
|
|
add( list );
|
2015-02-06 06:07:22 +00:00
|
|
|
|
|
|
|
list.setRect( 0, txtTitle.height(), WIDTH, height - txtTitle.height() );
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static class ListItem extends Component {
|
|
|
|
|
2016-01-13 05:53:17 +00:00
|
|
|
private RenderedText feature;
|
2014-07-27 13:39:07 +00:00
|
|
|
private BitmapText depth;
|
|
|
|
|
|
|
|
private Image icon;
|
|
|
|
|
|
|
|
public ListItem( Journal.Feature f, int d ) {
|
|
|
|
super();
|
|
|
|
|
2015-12-31 05:13:13 +00:00
|
|
|
feature.text( f.desc() );
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
depth.text( Integer.toString( d ) );
|
|
|
|
depth.measure();
|
|
|
|
|
|
|
|
if (d == Dungeon.depth) {
|
|
|
|
feature.hardlight( TITLE_COLOR );
|
|
|
|
depth.hardlight( TITLE_COLOR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void createChildren() {
|
2016-01-13 05:53:17 +00:00
|
|
|
feature = PixelScene.renderText( 9 );
|
2014-07-27 13:39:07 +00:00
|
|
|
add( feature );
|
|
|
|
|
2015-07-20 01:40:11 +00:00
|
|
|
depth = new BitmapText( PixelScene.pixelFont);
|
2014-07-27 13:39:07 +00:00
|
|
|
add( depth );
|
|
|
|
|
|
|
|
icon = Icons.get( Icons.DEPTH );
|
|
|
|
add( icon );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void layout() {
|
|
|
|
|
|
|
|
icon.x = width - icon.width;
|
|
|
|
|
|
|
|
depth.x = icon.x - 1 - depth.width();
|
2015-09-11 00:06:14 +00:00
|
|
|
depth.y = y + (height - depth.height()) / 2;
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
icon.y = depth.y - 1;
|
|
|
|
|
2015-09-11 00:06:14 +00:00
|
|
|
feature.y = depth.y + depth.baseLine() - feature.baseLine();
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|