forked from Cold-Mint/GlimmerWorks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
81 lines (70 loc) · 2.07 KB
/
Copy pathmain.cpp
File metadata and controls
81 lines (70 loc) · 2.07 KB
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
#include <fstream>
#include "core/App.h"
#include "core/console/command/ConfigCommand.h"
#include "core/log/LogCat.h"
#include "core/mod/resourcePack/ResourcePackManager.h"
#include "core/scene/AppContext.h"
#include "core/scene/SceneManager.h"
#include "fmt/args.h"
#ifdef __ANDROID__
#include <jni.h>
#include <android/asset_manager_jni.h>
#include <SDL3/SDL_system.h>
#include "core/vfs/AndroidAssetsFileProvider.h"
#endif
using namespace glimmer;
namespace fs = std::filesystem;
int main() {
std::set_terminate([] {
try {
if (std::current_exception()) {
std::rethrow_exception(std::current_exception());
}
} catch (const std::exception &e) {
const std::string msg =
std::string("Oops! An unexpected error occurred in GlimmerWorks.\n\n") +
"Error details:\n" + e.what() + "\n\n" +
"The application needs to close.";
SDL_ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR,
"GlimmerWorks - Fatal Error",
msg.c_str(),
nullptr
);
} catch (...) {
std::cerr << "Unhandled non-standard exception" << std::endl;
}
std::abort();
});
SDL_SetAppMetadata(
PROJECT_NAME.c_str(), GAME_VERSION_STRING,
APP_PACKNAME);
AppContext appContext;
if (!appContext.InitSuccess()) {
return EXIT_FAILURE;
}
App app(&appContext);
if (!app.Init()) {
LogCat::e("Failed to init app");
return EXIT_FAILURE;
}
app.Run();
return EXIT_SUCCESS;
}
#ifdef __ANDROID__
extern "C" {
int SDL_main(int argc, char *argv[]) {
LogCat::i("SDL_main() called — entering main()");
int result = main();
LogCat::i("SDL_main() finished, result = ", result);
return result;
}
//Set whether to allow the Activity to be recreated
//设置是否允许Activity被重新创建
JNIEXPORT jboolean
JNICALL
Java_org_libsdl_app_SDLActivity_nativeAllowRecreateActivity(JNIEnv *, jclass) {
return JNI_TRUE;
}
}
#endif