summaryrefslogtreecommitdiff
path: root/core/src/main/java/kz/ilotterytea/frogartha/FrogarthaGame.java
blob: 1f79cfe86aa19032de42418f41807c66f3717103 (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
package kz.ilotterytea.frogartha;

import com.badlogic.gdx.Application;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.assets.AssetManager;
import kz.ilotterytea.frogartha.assets.AssetUtils;
import kz.ilotterytea.frogartha.screens.SplashScreen;
import kz.ilotterytea.frogartha.sessions.IdentityClient;
import kz.ilotterytea.frogartha.sessions.SessionClient;

/**
 * {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms.
 */
public class FrogarthaGame extends Game {
    private static FrogarthaGame instance;

    private AssetManager assetManager;

    private IdentityClient identityClient;
    private SessionClient sessionClient;

    @Override
    public void create() {
        assetManager = new AssetManager();
        AssetUtils.setup(assetManager);
        AssetUtils.queue(assetManager);

        identityClient = new IdentityClient(Gdx.app.getPreferences("kz.ilotterytea.SigninIdentity"));
        sessionClient = new SessionClient();

        // preventing space key from triggering scrolling
        if (Gdx.app.getType() == Application.ApplicationType.WebGL) {
            Gdx.input.setCatchKey(Input.Keys.SPACE, true);
            Gdx.input.setCatchKey(Input.Keys.F3, true);
        }
        setScreen(new SplashScreen());
    }

    @Override
    public void dispose() {
        super.dispose();
        assetManager.dispose();
        sessionClient.close();
    }

    public static FrogarthaGame getInstance() {
        if (instance == null) instance = new FrogarthaGame();
        return instance;
    }

    public SessionClient getSessionClient() {
        return sessionClient;
    }

    public IdentityClient getIdentityClient() {
        return identityClient;
    }

    public AssetManager getAssetManager() {
        return assetManager;
    }
}