mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 01:26:50 -04:00
Android: Fix immediately exiting if try to start game with invalid IP/port. Also clicking 'quit game' returns to main menu instead of exiting.
This commit is contained in:
parent
c5da3f42d0
commit
e4d6455ffe
24
src/Game.c
24
src/Game.c
@ -670,33 +670,13 @@ static void Game_RunLoop(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CC_BUILD_ANDROID
|
#ifdef CC_BUILD_ANDROID
|
||||||
static cc_bool winCreated;
|
extern cc_bool Window_RemakeSurface(void);
|
||||||
static void OnWindowCreated(void* obj) { winCreated = true; }
|
|
||||||
|
|
||||||
static cc_bool SwitchToGame() {
|
static cc_bool SwitchToGame() {
|
||||||
JNIEnv* env;
|
|
||||||
JavaGetCurrentEnv(env);
|
|
||||||
|
|
||||||
/* Reset components */
|
/* Reset components */
|
||||||
Platform_LogConst("undoing components");
|
Platform_LogConst("undoing components");
|
||||||
Drawer2D_Component.Free();
|
Drawer2D_Component.Free();
|
||||||
//Http_Component.Free();
|
//Http_Component.Free();
|
||||||
|
return Window_RemakeSurface();
|
||||||
/* Force window to be destroyed and re-created */
|
|
||||||
/* (see comments in setupForGame for why this has to be done) */
|
|
||||||
JavaCallVoid(env, "setupForGame", "()V", NULL);
|
|
||||||
Event_Register_(&WindowEvents.Created, NULL, OnWindowCreated);
|
|
||||||
Platform_LogConst("Entering wait for window loop..");
|
|
||||||
|
|
||||||
/* Loop until window gets created async */
|
|
||||||
while (WindowInfo.Exists && !winCreated) {
|
|
||||||
Window_ProcessEvents();
|
|
||||||
Thread_Sleep(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform_LogConst("OK I'm starting the game..");
|
|
||||||
Event_Unregister_(&WindowEvents.Created, NULL, OnWindowCreated);
|
|
||||||
return winCreated;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1145,9 +1145,6 @@ void Http_UrlEncodeUrl(String* dst, const String* src) {
|
|||||||
*-----------------------------------------------------Http component------------------------------------------------------*
|
*-----------------------------------------------------Http component------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static void OnInit(void) {
|
static void OnInit(void) {
|
||||||
#ifdef CC_BUILD_ANDROID
|
|
||||||
if (workerThread) return;
|
|
||||||
#endif
|
|
||||||
Http_WorkerInit();
|
Http_WorkerInit();
|
||||||
ScheduledTask_Add(30, Http_CleanCacheTask);
|
ScheduledTask_Add(30, Http_CleanCacheTask);
|
||||||
RequestList_Init(&pendingReqs);
|
RequestList_Init(&pendingReqs);
|
||||||
|
@ -308,7 +308,16 @@ void Launcher_Run(void) {
|
|||||||
|
|
||||||
#ifdef CC_BUILD_ANDROID
|
#ifdef CC_BUILD_ANDROID
|
||||||
extern int Program_Run(int argc, char** argv);
|
extern int Program_Run(int argc, char** argv);
|
||||||
if (Launcher_ShouldExit) Program_Run(0, NULL);
|
extern cc_bool Window_RemakeSurface(void);
|
||||||
|
|
||||||
|
if (Launcher_ShouldExit) {
|
||||||
|
Launcher_ShouldExit = false;
|
||||||
|
Http_Component.Free();
|
||||||
|
|
||||||
|
Program_Run(0, NULL);
|
||||||
|
Window_RemakeSurface();
|
||||||
|
Launcher_Run();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (Launcher_ShouldUpdate) {
|
if (Launcher_ShouldUpdate) {
|
||||||
const char* action;
|
const char* action;
|
||||||
|
@ -114,6 +114,7 @@ GfxResourceID Atlas2D_LoadTile(TextureLoc texLoc) {
|
|||||||
static void Atlas2D_Free(void) {
|
static void Atlas2D_Free(void) {
|
||||||
Mem_Free(Atlas2D.Bmp.scan0);
|
Mem_Free(Atlas2D.Bmp.scan0);
|
||||||
Atlas2D.Bmp.scan0 = NULL;
|
Atlas2D.Bmp.scan0 = NULL;
|
||||||
|
Atlas2D.RowsCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Atlas1D_Free(void) {
|
static void Atlas1D_Free(void) {
|
||||||
|
24
src/Window.c
24
src/Window.c
@ -3789,6 +3789,30 @@ void Window_Create(int width, int height) {
|
|||||||
/* actual window creation is done when processSurfaceCreated is received */
|
/* actual window creation is done when processSurfaceCreated is received */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cc_bool winCreated;
|
||||||
|
static void OnWindowCreated(void* obj) { winCreated = true; }
|
||||||
|
cc_bool Window_RemakeSurface(void) {
|
||||||
|
JNIEnv* env;
|
||||||
|
JavaGetCurrentEnv(env);
|
||||||
|
winCreated = false;
|
||||||
|
|
||||||
|
/* Force window to be destroyed and re-created */
|
||||||
|
/* (see comments in setupForGame for why this has to be done) */
|
||||||
|
JavaCallVoid(env, "setupForGame", "()V", NULL);
|
||||||
|
Event_Register_(&WindowEvents.Created, NULL, OnWindowCreated);
|
||||||
|
Platform_LogConst("Entering wait for window exist loop..");
|
||||||
|
|
||||||
|
/* Loop until window gets created async */
|
||||||
|
while (WindowInfo.Exists && !winCreated) {
|
||||||
|
Window_ProcessEvents();
|
||||||
|
Thread_Sleep(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform_LogConst("OK window created..");
|
||||||
|
Event_Unregister_(&WindowEvents.Created, NULL, OnWindowCreated);
|
||||||
|
return winCreated;
|
||||||
|
}
|
||||||
|
|
||||||
void Window_SetTitle(const String* title) {
|
void Window_SetTitle(const String* title) {
|
||||||
/* TODO: Implement this somehow */
|
/* TODO: Implement this somehow */
|
||||||
/* Maybe https://stackoverflow.com/questions/2198410/how-to-change-title-of-activity-in-android */
|
/* Maybe https://stackoverflow.com/questions/2198410/how-to-change-title-of-activity-in-android */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user