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
|
|
|
|
2015-12-17 05:58:16 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
2014-07-27 13:39:07 +00:00
|
|
|
import com.watabou.noosa.BitmapTextMultiline;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
public class WndOptions extends Window {
|
|
|
|
|
2015-12-17 05:58:16 +00:00
|
|
|
private static final int WIDTH_P = 120;
|
|
|
|
private static final int WIDTH_L = 144;
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
private static final int MARGIN = 2;
|
|
|
|
private static final int BUTTON_HEIGHT = 20;
|
|
|
|
|
|
|
|
public WndOptions( String title, String message, String... options ) {
|
|
|
|
super();
|
2015-12-17 05:58:16 +00:00
|
|
|
|
|
|
|
int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P;
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
BitmapTextMultiline tfTitle = PixelScene.createMultiline( title, 9 );
|
|
|
|
tfTitle.hardlight( TITLE_COLOR );
|
|
|
|
tfTitle.x = tfTitle.y = MARGIN;
|
2015-12-17 05:58:16 +00:00
|
|
|
tfTitle.maxWidth = width - MARGIN * 2;
|
2014-07-27 13:39:07 +00:00
|
|
|
tfTitle.measure();
|
|
|
|
add( tfTitle );
|
|
|
|
|
2015-12-01 22:52:22 +00:00
|
|
|
BitmapTextMultiline tfMesage = PixelScene.createMultiline( message, 6 );
|
2015-12-17 05:58:16 +00:00
|
|
|
tfMesage.maxWidth = width - MARGIN * 2;
|
2014-07-27 13:39:07 +00:00
|
|
|
tfMesage.measure();
|
|
|
|
tfMesage.x = MARGIN;
|
|
|
|
tfMesage.y = tfTitle.y + tfTitle.height() + MARGIN;
|
|
|
|
add( tfMesage );
|
|
|
|
|
|
|
|
float pos = tfMesage.y + tfMesage.height() + MARGIN;
|
|
|
|
|
|
|
|
for (int i=0; i < options.length; i++) {
|
|
|
|
final int index = i;
|
|
|
|
RedButton btn = new RedButton( options[i] ) {
|
|
|
|
@Override
|
|
|
|
protected void onClick() {
|
|
|
|
hide();
|
|
|
|
onSelect( index );
|
|
|
|
}
|
|
|
|
};
|
2015-12-17 05:58:16 +00:00
|
|
|
btn.setRect( MARGIN, pos, width - MARGIN * 2, BUTTON_HEIGHT );
|
2014-07-27 13:39:07 +00:00
|
|
|
add( btn );
|
|
|
|
|
|
|
|
pos += BUTTON_HEIGHT + MARGIN;
|
|
|
|
}
|
|
|
|
|
2015-12-17 05:58:16 +00:00
|
|
|
resize( width, (int)pos );
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void onSelect( int index ) {};
|
|
|
|
}
|