blob: 7381b6d8627dd59b16234562d768af525f4d9e8b (
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
package kz.ilotterytea.maxon;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import kz.ilotterytea.maxon.localization.LocalizationManager;
import kz.ilotterytea.maxon.pets.PetManager;
import kz.ilotterytea.maxon.screens.SplashScreen;
import kz.ilotterytea.maxon.session.IdentityClient;
import kz.ilotterytea.maxon.session.SessionClient;
import kz.ilotterytea.maxon.utils.GameUpdater;
public class MaxonGame extends Game {
public SpriteBatch batch;
public AssetManager assetManager;
public Preferences prefs;
private LocalizationManager locale;
private PetManager petManager;
private DiscordActivityClient discordActivityClient;
private IdentityClient identityClient;
private SessionClient sessionClient;
private static MaxonGame instance;
public static MaxonGame getInstance() {
if (instance == null) {
instance = new MaxonGame();
}
return instance;
}
public PetManager getPetManager() {
return petManager;
}
public DiscordActivityClient getDiscordActivityClient() {
return discordActivityClient;
}
public IdentityClient getIdentityClient() {
return identityClient;
}
public SessionClient getSessionClient() {
return sessionClient;
}
public LocalizationManager getLocale() {
return locale;
}
public void setLocale(LocalizationManager locale) {
this.locale = locale;
}
@Override
public void create() {
// Check the latest version
new GameUpdater().checkLatestUpdate();
identityClient = new IdentityClient(Gdx.app.getPreferences("kz.ilotterytea.SigninIdentity"));
sessionClient = new SessionClient();
batch = new SpriteBatch();
prefs = Gdx.app.getPreferences(MaxonConstants.GAME_APP_PACKAGE);
locale = new LocalizationManager(Gdx.files.internal("i18n/" + prefs.getString("lang", "en_us") + ".json"));
Gdx.graphics.setVSync(prefs.getBoolean("vsync", true));
if (prefs.getBoolean("fullscreen", false)) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
} else if (
prefs.contains("width") ||
prefs.contains("height")
) {
int width = prefs.getInteger("width", 800);
if (width < 800) {
width = 800;
prefs.putInteger("width", width);
}
int height = prefs.getInteger("height", 600);
if (height < 600) {
height = 600;
prefs.putInteger("height", height);
}
prefs.flush();
Gdx.graphics.setWindowedMode(width, height);
}
assetManager = new AssetManager();
petManager = new PetManager(assetManager);
discordActivityClient = new DiscordActivityClient();
this.setScreen(new SplashScreen());
}
@Override
public void dispose() {
batch.dispose();
for (String name : assetManager.getAssetNames()) {
assetManager.unload(name);
}
assetManager.dispose();
discordActivityClient.dispose();
}
}
|