From 00abba9cef29d321ccf1df0704a2e991beeb3660 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 23 Feb 2015 00:51:50 -0500 Subject: [PATCH] v0.2.4: reworked welcome scene --- .../scenes/WelcomeScene.java | 57 +++++++++++++------ .../windows/WndChanges.java | 50 ---------------- 2 files changed, 41 insertions(+), 66 deletions(-) delete mode 100644 src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChanges.java diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java index 481ce1544..7f5a42978 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java @@ -1,17 +1,20 @@ -//TODO: update this class with relevant info as new versions come out. package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.shatteredpixel.shatteredpixeldungeon.Badges; +import com.shatteredpixel.shatteredpixeldungeon.Chrome; import com.shatteredpixel.shatteredpixeldungeon.Rankings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; +import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.Camera; 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 { private static final String TTL_Welcome = "Welcome!"; @@ -56,8 +59,8 @@ public class WelcomeScene extends PixelScene { final int gameversion = ShatteredPixelDungeon.version(); - BitmapTextMultiline text; BitmapTextMultiline title; + BitmapTextMultiline text; 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; - text.measure(); - add( text ); + int pw = w - 10; + int ph = h - 50; - text.x = align( (Camera.main.width - text.width()) / 2 ); - text.y = align( (Camera.main.height - text.height()) / 2 ); - - title.maxWidth = text.maxWidth; + title.maxWidth = pw; 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 ); - title.x = align( (Camera.main.width - title.width()) / 2 ); - title.y = align( text.y - title.height() - 10 ); + NinePatch panel = Chrome.get(Chrome.Type.WINDOW); + 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!") { @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); add(okay); @@ -133,10 +159,9 @@ public class WelcomeScene extends PixelScene { changes.setRect(text.x + 65, text.y + text.height() + 5, 55, 18); 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); - Archs archs = new Archs(); archs.setSize( Camera.main.width, Camera.main.height ); addToBack( archs ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChanges.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChanges.java deleted file mode 100644 index 59b5552db..000000000 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChanges.java +++ /dev/null @@ -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() ); - } -}