summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java
blob: 427a938a6098cea4cceea13d555a528fa51f33a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package ch.asynk.rustanddust.menu;

import com.badlogic.gdx.graphics.g2d.Batch;

import ch.asynk.rustanddust.ui.Bg;
import ch.asynk.rustanddust.ui.Label;
import ch.asynk.rustanddust.ui.Patch;
import ch.asynk.rustanddust.RustAndDust;

public class TutorialsMenu extends Patch implements MenuCtrl.Panel
{
    public static int PADDING = 60;
    public static int TITLE_PADDING = 30;

    private final RustAndDust game;

    private Label title;
    private Label msg;
    protected Bg okBtn;

    public TutorialsMenu(RustAndDust game)
    {
        super(game.bgPatch);
        this.game = game;
        this.okBtn = new Bg(game.getUiRegion(game.UI_OK));
        this.title = new Label("- Tutorials", game.font);
        this.msg = new Label("Not implemented yet.\nPlease Visit:\nhttp://rustanddust.ch", game.font);
    }

    @Override
    public MenuCtrl.MenuType postAnswer(boolean ok) { return MenuCtrl.MenuType.NONE; }

    @Override
    public String getAsk() { return null; }

    @Override
    public MenuCtrl.MenuType prepare() { return MenuCtrl.MenuType.TUTORIALS; }

    @Override
    public void computePosition()
    {
        float h = (title.getHeight() + TITLE_PADDING + (2 * PADDING));
        h += msg.getHeight();

        float w = title.getWidth();
        if (msg.getWidth() > w)
            w = msg.getWidth();
        w += (2 * PADDING);

        float x = position.getX(w);
        float y = position.getY(h);
        setPosition(x, y, w, h);

        setBottomRight(okBtn);

        y += PADDING;
        x += PADDING;

        msg.setPosition(x, y);

        y += (msg.getHeight() + TITLE_PADDING);
        title.setPosition(x, y);
    }

    @Override
    public boolean drag(float x, float y, int dx, int dy) { return true; }

    @Override
    public MenuCtrl.MenuType touch(float x, float y)
    {
        if (rect.contains(x, y) || okBtn.hit(x, y)) {
            game.playEnter();
            return MenuCtrl.MenuType.MAIN;
        }

        return MenuCtrl.MenuType.NONE;
    }

    @Override
    public void dispose()
    {
        super.dispose();
        title.dispose();
        msg.dispose();
        okBtn.dispose();
    }

    @Override
    public void draw(Batch batch)
    {
        super.draw(batch);
        title.draw(batch);
        msg.draw(batch);
        okBtn.draw(batch);
    }
}