@Override protected void layout() { height = 32; shield.size(width, shield.height); avatar.x = PixelScene.align(camera(), shield.x + 15 - avatar.width / 2); avatar.y = PixelScene.align(camera(), shield.y + 16 - avatar.height / 2); compass.x = avatar.x + avatar.width / 2 - compass.origin.x; compass.y = avatar.y + avatar.height / 2 - compass.origin.y; hp.x = 30; hp.y = 3; depth.x = width - 24 - depth.width() - 18; depth.y = 6; keys.y = 6; danger.setPos(width - danger.width(), 18); buffs.setPos(31, 9); btnMenu.setPos(width - btnMenu.width(), 1); }
@Override protected void layout() { super.layout(); shield.x = x; shield.y = y + (height - shield.height) / 2; position.x = align(shield.x + (shield.width - position.width()) / 2); position.y = align(shield.y + (shield.height - position.height()) / 2 + 1); if (flare != null) { flare.point(shield.center()); } classIcon.x = align(x + width - classIcon.width); classIcon.y = shield.y; level.x = align(classIcon.x + (classIcon.width - level.width()) / 2); level.y = align(classIcon.y + (classIcon.height - level.height()) / 2 + 1); steps.x = align(x + width - steps.width - classIcon.width); steps.y = shield.y; depth.x = align(steps.x + (steps.width - depth.width()) / 2); depth.y = align(steps.y + (steps.height - depth.height()) / 2 + 1); desc.x = shield.x + shield.width + GAP; desc.maxWidth = (int) (steps.x - desc.x); desc.measure(); desc.y = align(shield.y + (shield.height - desc.height()) / 2 + 1); }
@Override protected void layout() { super.layout(); image.x = x + 2; image.y = y + 2; }
public WndBadge(Badges.Badge badge) { super(); Image icon = BadgeBanner.image(badge.image); icon.scale.set(2); add(icon); BitmapTextMultiline info = PixelScene.createMultiline(badge.description, 8); info.maxWidth = WIDTH - MARGIN * 2; info.measure(); float w = Math.max(icon.width(), info.width()) + MARGIN * 2; icon.x = (w - icon.width()) / 2; icon.y = MARGIN; float pos = icon.y + icon.height() + MARGIN; for (BitmapText line : info.new LineSplitter().split()) { line.measure(); line.x = PixelScene.align((w - line.width()) / 2); line.y = PixelScene.align(pos); add(line); pos += line.height(); } resize((int) w, (int) (pos + MARGIN)); BadgeBanner.highlight(icon, badge.image); }
public WndRanking(final String gameFile) { super(); resize(WIDTH, HEIGHT); thread = new Thread() { @Override public void run() { try { Badges.loadGlobal(); Dungeon.loadGame(gameFile); } catch (Exception e) { error = TXT_ERROR; } } }; thread.start(); busy = Icons.BUSY.get(); busy.origin.set(busy.width / 2, busy.height / 2); busy.angularSpeed = 720; busy.x = (WIDTH - busy.width) / 2; busy.y = (HEIGHT - busy.height) / 2; add(busy); }
public WndBadge(Badges.Badge badge) { super(); Image icon = BadgeBanner.image(badge.image); icon.scale.set(2); add(icon); // TODO: this used to be centered, should probably figure that out. RenderedTextMultiline info = PixelScene.renderMultiline(badge.desc(), 8); info.maxWidth(WIDTH - MARGIN * 2); PixelScene.align(info); add(info); float w = Math.max(icon.width(), info.width()) + MARGIN * 2; icon.x = (w - icon.width()) / 2f; icon.y = MARGIN; PixelScene.align(icon); info.setPos((w - info.width()) / 2, icon.y + icon.height() + MARGIN); resize((int) w, (int) (info.bottom() + MARGIN)); BadgeBanner.highlight(icon, badge.image); }
@Override public void update() { super.update(); if (target != null && target.isAlive() && target.sprite.visible) { CharSprite sprite = target.sprite; bg.scale.x = sprite.width; level.scale.x = sprite.width * target.HP / target.HT; bg.x = level.x = sprite.x; bg.y = level.y = sprite.y - HEIGHT - 1; visible = true; } else { visible = false; } }
@Override protected void layout() { super.layout(); image.x = x + (width - image.width()) / 2; image.y = y; label.x = x + (width - label.width()) / 2; label.y = image.y + image.height() + 2; }
@Override protected void layout() { icon.x = width - icon.width; depth.x = icon.x - 1 - depth.width(); depth.y = PixelScene.align(y + (height - depth.height()) / 2); icon.y = depth.y - 1; feature.y = PixelScene.align(depth.y + depth.baseLine() - feature.baseLine()); }
@Override public void create() { super.create(); BitmapTextMultiline text = createMultiline(TXT, 8); text.maxWidth = Math.min(Camera.main.width, 120); text.measure(); add(text); text.x = align((Camera.main.width - text.width()) / 2); text.y = align((Camera.main.height - text.height()) / 2); BitmapTextMultiline link = createMultiline(LNK, 8); link.maxWidth = Math.min(Camera.main.width, 120); link.measure(); link.hardlight(Window.TITLE_COLOR); add(link); link.x = text.x; link.y = text.y + text.height(); TouchArea hotArea = new TouchArea(link) { @Override protected void onClick(NoosaInputProcessor.Touch touch) { Gdx.net.openURI("http://" + LNK); } }; add(hotArea); Image wata = Icons.WATA.get(); wata.x = align(text.x + (text.width() - wata.width) / 2); wata.y = text.y - wata.height - 8; add(wata); new Flare(7, 64).color(0x112233, true).show(wata, 0).angularSpeed = +20; Archs archs = new Archs(); archs.setSize(Camera.main.width, Camera.main.height); addToBack(archs); ExitButton btnExit = new ExitButton(); btnExit.setPos(Camera.main.width - btnExit.width(), 0); add(btnExit); fadeIn(); }
@Override protected void layout() { clear(); SparseArray<Image> newIcons = new SparseArray<Image>(); for (Buff buff : ch.buffs()) { int icon = buff.icon(); if (icon != NONE) { Image img = new Image(texture); img.frame(film.get(icon)); img.x = x + members.size() * (SIZE + 2); img.y = y; add(img); newIcons.put(icon, img); } } for (Integer key : icons.keyArray()) { if (newIcons.get(key) == null) { Image icon = icons.get(key); icon.origin.set(SIZE / 2); add(icon); add( new AlphaTweener(icon, 0, 0.6f) { @Override protected void updateValues(float progress) { super.updateValues(progress); image.scale.set(1 + 5 * progress); }; }); } } icons = newIcons; }
@Override public void create() { super.create(); Music.INSTANCE.play(Assets.HAPPY, true); Music.INSTANCE.volume(ShatteredPixelDungeon.musicVol() / 10f); uiCamera.visible = false; int w = Camera.main.width; int h = Camera.main.height; Archs archs = new Archs(); archs.reversed = true; archs.setSize(w, h); add(archs); float vx = align((w - SKY_WIDTH) / 2); float vy = align((h - SKY_HEIGHT - BUTTON_HEIGHT) / 2); Point s = Camera.main.cameraToScreen(vx, vy); viewport = new Camera(s.x, s.y, SKY_WIDTH, SKY_HEIGHT, defaultZoom); Camera.add(viewport); Group window = new Group(); window.camera = viewport; add(window); boolean dayTime = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 7; Sky sky = new Sky(dayTime); sky.scale.set(SKY_WIDTH, SKY_HEIGHT); window.add(sky); if (!dayTime) { for (int i = 0; i < NSTARS; i++) { float size = Random.Float(); ColorBlock star = new ColorBlock(size, size, 0xFFFFFFFF); star.x = Random.Float(SKY_WIDTH) - size / 2; star.y = Random.Float(SKY_HEIGHT) - size / 2; star.am = size * (1 - star.y / SKY_HEIGHT); window.add(star); } } float range = SKY_HEIGHT * 2 / 3; for (int i = 0; i < NCLOUDS; i++) { Cloud cloud = new Cloud((NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float(range / NCLOUDS), dayTime); window.add(cloud); } int nPatches = (int) (sky.width() / GrassPatch.WIDTH + 1); for (int i = 0; i < nPatches * 4; i++) { GrassPatch patch = new GrassPatch((i - 0.75f) * GrassPatch.WIDTH / 4, SKY_HEIGHT + 1, dayTime); patch.brightness(dayTime ? 0.7f : 0.4f); window.add(patch); } Avatar a = new Avatar(Dungeon.hero.heroClass); // Removing semitransparent contour a.am = 2; a.aa = -1; a.x = PixelScene.align((SKY_WIDTH - a.width) / 2); a.y = SKY_HEIGHT - a.height; window.add(a); final Pet pet = new Pet(); pet.rm = pet.gm = pet.bm = 1.2f; pet.x = SKY_WIDTH / 2 + 2; pet.y = SKY_HEIGHT - pet.height; window.add(pet); window.add( new TouchArea(sky) { protected void onClick(Touch touch) { pet.jump(); }; }); for (int i = 0; i < nPatches; i++) { GrassPatch patch = new GrassPatch((i - 0.5f) * GrassPatch.WIDTH, SKY_HEIGHT, dayTime); patch.brightness(dayTime ? 1.0f : 0.8f); window.add(patch); } Image frame = new Image(Assets.SURFACE); frame.frame(0, 0, FRAME_WIDTH, FRAME_HEIGHT); frame.x = vx - FRAME_MARGIN_X; frame.y = vy - FRAME_MARGIN_TOP; add(frame); if (dayTime) { a.brightness(1.2f); pet.brightness(1.2f); } else { frame.hardlight(0xDDEEFF); } RedButton gameOver = new RedButton("Game Over") { protected void onClick() { Game.switchScene(TitleScene.class); } }; gameOver.setSize(SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT); gameOver.setPos(frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4); add(gameOver); Badges.validateHappyEnd(); fadeIn(); }
@Override public void create() { super.create(); BitmapTextMultiline text = null; if (!noText) { text = createMultiline(TXT, 8); text.maxWidth = WIDTH; text.measure(); add(text); } amulet = new Image(Assets.AMULET); add(amulet); RedButton btnExit = new RedButton(TXT_EXIT) { @Override protected void onClick() { Dungeon.win(ResultDescriptions.WIN); Dungeon.deleteGame(Dungeon.hero.heroClass, true); Game.switchScene(noText ? TitleScene.class : RankingsScene.class); } }; btnExit.setSize(WIDTH, BTN_HEIGHT); add(btnExit); RedButton btnStay = new RedButton(TXT_STAY) { @Override protected void onClick() { onBackPressed(); } }; btnStay.setSize(WIDTH, BTN_HEIGHT); add(btnStay); float height; if (noText) { height = amulet.height + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); amulet.x = align((Camera.main.width - amulet.width) / 2); amulet.y = align((Camera.main.height - height) / 2); btnExit.setPos( (Camera.main.width - btnExit.width()) / 2, amulet.y + amulet.height + LARGE_GAP); btnStay.setPos(btnExit.left(), btnExit.bottom() + SMALL_GAP); } else { height = amulet.height + LARGE_GAP + text.height() + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); amulet.x = align((Camera.main.width - amulet.width) / 2); amulet.y = align((Camera.main.height - height) / 2); text.x = align((Camera.main.width - text.width()) / 2); text.y = amulet.y + amulet.height + LARGE_GAP; btnExit.setPos((Camera.main.width - btnExit.width()) / 2, text.y + text.height() + LARGE_GAP); btnStay.setPos(btnExit.left(), btnExit.bottom() + SMALL_GAP); } new Flare(8, 48).color(0xFFDDBB, true).show(amulet, 0).angularSpeed = +30; fadeIn(); }
@Override public void create() { super.create(); Music.INSTANCE.play(Assets.THEME, true); Music.INSTANCE.volume(ShatteredPixelDungeon.musicVol() / 10f); uiCamera.visible = false; int w = Camera.main.width; int h = Camera.main.height; Archs archs = new Archs(); archs.setSize(w, h); add(archs); Image title = BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON); add(title); float height = title.height + (ShatteredPixelDungeon.landscape() ? DashboardItem.SIZE : DashboardItem.SIZE * 2); title.x = (w - title.width()) / 2; title.y = (h - height) / 2; placeTorch(title.x + 18, title.y + 20); placeTorch(title.x + title.width - 18, title.y + 20); Image signs = new Image(BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON_SIGNS)) { private float time = 0; @Override public void update() { super.update(); am = (float) Math.sin(-(time += Game.elapsed)); } @Override public void draw() { GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE); super.draw(); GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); } }; signs.x = title.x; signs.y = title.y; add(signs); DashboardItem btnBadges = new DashboardItem(TXT_BADGES, 3) { @Override protected void onClick() { ShatteredPixelDungeon.switchNoFade(BadgesScene.class); } }; add(btnBadges); DashboardItem btnAbout = new DashboardItem(TXT_ABOUT, 1) { @Override protected void onClick() { ShatteredPixelDungeon.switchNoFade(AboutScene.class); } }; add(btnAbout); DashboardItem btnPlay = new DashboardItem(TXT_PLAY, 0) { @Override protected void onClick() { ShatteredPixelDungeon.switchNoFade(StartScene.class); } }; add(btnPlay); DashboardItem btnHighscores = new DashboardItem(TXT_HIGHSCORES, 2) { @Override protected void onClick() { ShatteredPixelDungeon.switchNoFade(RankingsScene.class); } }; add(btnHighscores); if (ShatteredPixelDungeon.landscape()) { float y = (h + height) / 2 - DashboardItem.SIZE; btnHighscores.setPos(w / 2 - btnHighscores.width(), y); btnBadges.setPos(w / 2, y); btnPlay.setPos(btnHighscores.left() - btnPlay.width(), y); btnAbout.setPos(btnBadges.right(), y); } else { btnBadges.setPos(w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE); btnAbout.setPos(w / 2, (h + height) / 2 - DashboardItem.SIZE); btnPlay.setPos(w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE); btnHighscores.setPos(w / 2, btnPlay.top()); } BitmapText version = new BitmapText("v " + Game.version + "", pixelFont); version.measure(); version.hardlight(0xCCCCCC); version.x = w - version.width(); version.y = h - version.height(); add(version); Button changes = new ChangesButton(); changes.setPos(w - changes.width(), h - version.height() - changes.height()); add(changes); PrefsButton btnPrefs = new PrefsButton(); btnPrefs.setPos(0, 0); add(btnPrefs); ExitButton btnExit = new ExitButton(); btnExit.setPos(w - btnExit.width(), 0); add(btnExit); int gameversion = ShatteredPixelDungeon.version(); if (gameversion != Game.versionCode) { if (gameversion < 65) { // TODO special code for 0.3.2 update to notify people about mastery book changes. Remove // when not needed Badges.loadGlobal(); if (Badges.isUnlocked(Badges.Badge.MASTERY_WARRIOR) || Badges.isUnlocked(Badges.Badge.MASTERY_ROGUE) || Badges.isUnlocked(Badges.Badge.MASTERY_MAGE) || Badges.isUnlocked(Badges.Badge.MASTERY_HUNTRESS)) { add( new WndHardNotification( new ItemSprite(ItemSpriteSheet.MASTERY, null), "Mastery Book Changes", "v0.3.2 brings new prison content and some big balance changes to subclasses:\n" + "\n" + "_The Book of Mastery is no longer given at floor 1, it is only dropped by Tengu._\n" + "\n" + "There have been balance tweaks to accommodate this, so the difficulty should be similar.\n" + "\n" + "This change is necessary to allow for more interesting subclasses in the future, " + "apologies for any frustration.", "See All Changes", 10) { @Override public void hide() { super.hide(); Game.switchScene(WelcomeScene.class); } }); } else { Game.switchScene(WelcomeScene.class); return; } } else { Game.switchScene(WelcomeScene.class); return; } } fadeIn(); }
@Override protected void layout() { image.x = x; image.y = y; }