Merging Source v1.7.2: window changes
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user