Magic_Ling_Pixel_Dungeon/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java

75 lines
2.4 KiB
Java
Raw Normal View History

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/>
*/
package com.shatteredpixel.shatteredpixeldungeon.windows;
2014-07-27 13:39:07 +00:00
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
2014-07-27 13:39:07 +00:00
public class WndOptions extends Window {
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();
int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P;
RenderedTextMultiline tfTitle = PixelScene.renderMultiline( title, 9 );
2014-07-27 13:39:07 +00:00
tfTitle.hardlight( TITLE_COLOR );
tfTitle.setPos(MARGIN, MARGIN);
tfTitle.maxWidth(width - MARGIN * 2);
2014-07-27 13:39:07 +00:00
add( tfTitle );
RenderedTextMultiline tfMesage = PixelScene.renderMultiline( 6 );
tfMesage.text(message, width - MARGIN * 2);
tfMesage.setPos( MARGIN, tfTitle.top() + tfTitle.height() + MARGIN );
2014-07-27 13:39:07 +00:00
add( tfMesage );
float pos = tfMesage.bottom() + MARGIN;
2014-07-27 13:39:07 +00:00
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 );
}
};
btn.setRect( MARGIN, pos, width - MARGIN * 2, BUTTON_HEIGHT );
2014-07-27 13:39:07 +00:00
add( btn );
pos += BUTTON_HEIGHT + MARGIN;
}
resize( width, (int)pos );
2014-07-27 13:39:07 +00:00
}
protected void onSelect( int index ) {};
}