Search in sources :

Example 6 with Archs

use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon by watabou.

the class RankingsScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    Music.INSTANCE.volume(1f);
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    Rankings.INSTANCE.load();
    if (Rankings.INSTANCE.records.size() > 0) {
        float rowHeight = PixelDungeon.landscape() ? ROW_HEIGHT_L : ROW_HEIGHT_P;
        float left = (w - Math.min(MAX_ROW_WIDTH, w)) / 2 + GAP;
        float top = align((h - rowHeight * Rankings.INSTANCE.records.size()) / 2);
        BitmapText title = PixelScene.createText(TXT_TITLE, 9);
        title.hardlight(Window.TITLE_COLOR);
        title.measure();
        title.x = align((w - title.width()) / 2);
        title.y = align(top - title.height() - GAP);
        add(title);
        int pos = 0;
        for (Rankings.Record rec : Rankings.INSTANCE.records) {
            Record row = new Record(pos, pos == Rankings.INSTANCE.lastRecord, rec);
            row.setRect(left, top + pos * rowHeight, w - left * 2, rowHeight);
            add(row);
            pos++;
        }
        if (Rankings.INSTANCE.totalNumber >= Rankings.TABLE_SIZE) {
            BitmapText label = PixelScene.createText(TXT_TOTAL, 8);
            label.hardlight(DEFAULT_COLOR);
            label.measure();
            add(label);
            BitmapText won = PixelScene.createText(Integer.toString(Rankings.INSTANCE.wonNumber), 8);
            won.hardlight(Window.TITLE_COLOR);
            won.measure();
            add(won);
            BitmapText total = PixelScene.createText("/" + Rankings.INSTANCE.totalNumber, 8);
            total.hardlight(DEFAULT_COLOR);
            total.measure();
            total.x = align((w - total.width()) / 2);
            total.y = align(top + pos * rowHeight + GAP);
            add(total);
            float tw = label.width() + won.width() + total.width();
            label.x = align((w - tw) / 2);
            won.x = label.x + label.width();
            total.x = won.x + won.width();
            label.y = won.y = total.y = align(top + pos * rowHeight + GAP);
        }
    } else {
        BitmapText title = PixelScene.createText(TXT_NO_GAMES, 8);
        title.hardlight(DEFAULT_COLOR);
        title.measure();
        title.x = align((w - title.width()) / 2);
        title.y = align((h - title.height()) / 2);
        add(title);
    }
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    fadeIn();
}
Also used : Archs(com.watabou.pixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) Rankings(com.watabou.pixeldungeon.Rankings)

Example 7 with Archs

use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon by watabou.

the class TitleScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    Music.INSTANCE.volume(1f);
    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 + (PixelDungeon.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() {
            PixelDungeon.switchNoFade(BadgesScene.class);
        }
    };
    add(btnBadges);
    DashboardItem btnAbout = new DashboardItem(TXT_ABOUT, 1) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(AboutScene.class);
        }
    };
    add(btnAbout);
    DashboardItem btnPlay = new DashboardItem(TXT_PLAY, 0) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(StartScene.class);
        }
    };
    add(btnPlay);
    DashboardItem btnHighscores = new DashboardItem(TXT_HIGHSCORES, 2) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(RankingsScene.class);
        }
    };
    add(btnHighscores);
    if (PixelDungeon.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, font1x);
    version.measure();
    version.hardlight(0x888888);
    version.x = w - version.width();
    version.y = h - version.height();
    add(version);
    PrefsButton btnPrefs = new PrefsButton();
    btnPrefs.setPos(0, 0);
    add(btnPrefs);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(w - btnExit.width(), 0);
    add(btnExit);
    fadeIn();
}
Also used : Archs(com.watabou.pixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) PrefsButton(com.watabou.pixeldungeon.ui.PrefsButton) Image(com.watabou.noosa.Image)

Example 8 with Archs

use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon by watabou.

the class AboutScene method create.

@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(Touch touch) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://" + LNK));
            Game.instance.startActivity(intent);
        }
    };
    add(hotArea);
    Image wata = Icons.WATA.get();
    wata.x = align((Camera.main.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();
}
Also used : Flare(com.watabou.pixeldungeon.effects.Flare) TouchArea(com.watabou.noosa.TouchArea) Archs(com.watabou.pixeldungeon.ui.Archs) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) Intent(android.content.Intent) Touch(com.watabou.input.Touchscreen.Touch) Image(com.watabou.noosa.Image) BitmapTextMultiline(com.watabou.noosa.BitmapTextMultiline)

Example 9 with Archs

use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon by watabou.

the class SurfaceScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.HAPPY, true);
    Music.INSTANCE.volume(1f);
    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 = !Dungeon.nightMode;
    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);
    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();
}
Also used : Group(com.watabou.noosa.Group) Point(com.watabou.utils.Point) Touch(com.watabou.input.Touchscreen.Touch) Image(com.watabou.noosa.Image) Point(com.watabou.utils.Point) Archs(com.watabou.pixeldungeon.ui.Archs) TouchArea(com.watabou.noosa.TouchArea) Camera(com.watabou.noosa.Camera) RedButton(com.watabou.pixeldungeon.ui.RedButton) ColorBlock(com.watabou.noosa.ColorBlock)

Example 10 with Archs

use of com.watabou.pixeldungeon.ui.Archs in project pixel-dungeon-remix by NYRDS.

the class AboutScene method create.

@Override
public void create() {
    super.create();
    Text text = createText(getTXT(), null);
    text.camera = uiCamera;
    text.x = align((Camera.main.width - text.width()) / 2);
    text.y = align((Camera.main.height - text.height()) / 3);
    Text email = createTouchEmail(Game.getVar(R.string.AboutScene_Mail), text);
    Text visit = createText(Game.getVar(R.string.AboutScene_OurSite), email);
    Text site = createTouchLink(LNK, visit);
    createText("\n" + getTRN(), site);
    Image nyrdie = Icons.NYRDIE.get();
    nyrdie.x = align(text.x + (text.width() - nyrdie.width) / 2);
    nyrdie.y = text.y - nyrdie.height - 8;
    add(nyrdie);
    new Flare(7, 64).color(0x332211, true).show(nyrdie, 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();
}
Also used : Flare(com.watabou.pixeldungeon.effects.Flare) Archs(com.watabou.pixeldungeon.ui.Archs) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) Text(com.watabou.noosa.Text) Image(com.watabou.noosa.Image)

Aggregations

Archs (com.watabou.pixeldungeon.ui.Archs)14 ExitButton (com.watabou.pixeldungeon.ui.ExitButton)10 Image (com.watabou.noosa.Image)8 Text (com.watabou.noosa.Text)6 BitmapText (com.watabou.noosa.BitmapText)5 RedButton (com.watabou.pixeldungeon.ui.RedButton)5 Touch (com.watabou.input.Touchscreen.Touch)3 Group (com.watabou.noosa.Group)3 NinePatch (com.watabou.noosa.NinePatch)3 TouchArea (com.watabou.noosa.TouchArea)3 ScrollPane (com.watabou.pixeldungeon.ui.ScrollPane)3 BitmapTextMultiline (com.watabou.noosa.BitmapTextMultiline)2 Camera (com.watabou.noosa.Camera)2 ColorBlock (com.watabou.noosa.ColorBlock)2 Component (com.watabou.noosa.ui.Component)2 HeroClass (com.watabou.pixeldungeon.actors.hero.HeroClass)2 Flare (com.watabou.pixeldungeon.effects.Flare)2 PrefsButton (com.watabou.pixeldungeon.ui.PrefsButton)2 WndOptions (com.watabou.pixeldungeon.windows.WndOptions)2 Callback (com.watabou.utils.Callback)2