v0.2.4: reworked welcome scene

This commit is contained in:
Evan Debenham 2015-02-23 00:51:50 -05:00
parent a1837d77ae
commit 00abba9cef
2 changed files with 41 additions and 66 deletions

View File

@ -1,17 +1,20 @@
//TODO: update this class with relevant info as new versions come out.
package com.shatteredpixel.shatteredpixeldungeon.scenes; package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.Rankings; import com.shatteredpixel.shatteredpixeldungeon.Rankings;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.Camera; import com.watabou.noosa.Camera;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.noosa.NinePatch;
import com.watabou.noosa.ui.Component;
//FIXME: overhaul this in this update //TODO: update this class with relevant info as new versions come out.
public class WelcomeScene extends PixelScene { public class WelcomeScene extends PixelScene {
private static final String TTL_Welcome = "Welcome!"; private static final String TTL_Welcome = "Welcome!";
@ -56,8 +59,8 @@ public class WelcomeScene extends PixelScene {
final int gameversion = ShatteredPixelDungeon.version(); final int gameversion = ShatteredPixelDungeon.version();
BitmapTextMultiline text;
BitmapTextMultiline title; BitmapTextMultiline title;
BitmapTextMultiline text;
if (gameversion == 0) { if (gameversion == 0) {
@ -81,21 +84,44 @@ public class WelcomeScene extends PixelScene {
} }
int w = Camera.main.width;
int h = Camera.main.height;
text.maxWidth = 120; int pw = w - 10;
text.measure(); int ph = h - 50;
add( text );
text.x = align( (Camera.main.width - text.width()) / 2 ); title.maxWidth = pw;
text.y = align( (Camera.main.height - text.height()) / 2 );
title.maxWidth = text.maxWidth;
title.measure(); title.measure();
title.hardlight(Window.TITLE_COLOR); title.hardlight(Window.SHPX_COLOR);
title.x = align( (w - title.width()) / 2 );
title.y = align( 8 );
add( title ); add( title );
title.x = align( (Camera.main.width - title.width()) / 2 ); NinePatch panel = Chrome.get(Chrome.Type.WINDOW);
title.y = align( text.y - title.height() - 10 ); panel.size( pw, ph );
panel.x = (w - pw) / 2;
panel.y = (h - ph) / 2;
add( panel );
ScrollPane list = new ScrollPane( new Component() );
add( list );
list.setRect(
panel.x + panel.marginLeft(),
panel.y + panel.marginTop(),
panel.innerWidth(),
panel.innerHeight());
list.scrollTo( 0, 0 );
Component content = list.content();
content.clear();
text.maxWidth = (int) panel.innerWidth();
text.measure();
content.add(text);
content.setSize( panel.innerWidth(), text.height() );
RedButton okay = new RedButton("Okay!") { RedButton okay = new RedButton("Okay!") {
@Override @Override
@ -119,7 +145,7 @@ public class WelcomeScene extends PixelScene {
} }
}; };
/* to be added in a later update /*
okay.setRect(text.x, text.y + text.height() + 5, 55, 18); okay.setRect(text.x, text.y + text.height() + 5, 55, 18);
add(okay); add(okay);
@ -133,10 +159,9 @@ public class WelcomeScene extends PixelScene {
changes.setRect(text.x + 65, text.y + text.height() + 5, 55, 18); changes.setRect(text.x + 65, text.y + text.height() + 5, 55, 18);
add(changes);*/ add(changes);*/
okay.setRect(text.x, text.y + text.height() + 5, text.width(), 18); okay.setRect((w - pw) / 2, h - 22, pw, 18);
add(okay); add(okay);
Archs archs = new Archs(); Archs archs = new Archs();
archs.setSize( Camera.main.width, Camera.main.height ); archs.setSize( Camera.main.width, Camera.main.height );
addToBack( archs ); addToBack( archs );

View File

@ -1,50 +0,0 @@
package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.ui.Component;
/**
* Created by debenhame on 14/10/2014.
*/
//TODO: this is completely broken at the moment. Implement soon if it's needed!
public class WndChanges extends Window {
private static final int WIDTH = 112;
private static final int HEIGHT = 160;
private static final String TXT_TITLE = "Changes";
private static final String TXT_CHANGES = "test test test test test test test test test test test test test test test" +
"\n\n test test test test test test test test test test test test test test test\ntest test test test " +
"test test test test test test\n\n\ntest test test test testtest test test test test";
private BitmapText txtTitle;
private ScrollPane text;
public WndChanges() {
super();
resize( WIDTH, HEIGHT );
txtTitle = PixelScene.createText(TXT_TITLE, 9);
txtTitle.hardlight( Window.SHPX_COLOR );
txtTitle.measure();
txtTitle.x = PixelScene.align( PixelScene.uiCamera, (WIDTH - txtTitle.width()) / 2 );
add( txtTitle );
BitmapTextMultiline txtChanges = PixelScene.createMultiline(TXT_CHANGES, 9);
Component content = new Component();
content.add(txtChanges);
text = new ScrollPane( content ) {
};
add( text );
text.setRect( 0, txtTitle.height(), WIDTH, HEIGHT - txtTitle.height() );
}
}