mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 00:56:40 -04:00
fix very rare case where launcher process wouldn't terminate after closing the window
This commit is contained in:
parent
fbbe626a97
commit
0da489e82a
@ -18,7 +18,7 @@
|
|||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
|
|
||||||
#ifndef CC_BUILD_WEB
|
#ifndef CC_BUILD_WEB
|
||||||
struct LScreen* Launcher_Screen;
|
static struct LScreen* activeScreen;
|
||||||
Rect2D Launcher_Dirty;
|
Rect2D Launcher_Dirty;
|
||||||
Bitmap Launcher_Framebuffer;
|
Bitmap Launcher_Framebuffer;
|
||||||
cc_bool Launcher_ClassicBackground;
|
cc_bool Launcher_ClassicBackground;
|
||||||
@ -32,8 +32,8 @@ static char hashBuffer[STRING_SIZE];
|
|||||||
String Launcher_AutoHash = String_FromArray(hashBuffer);
|
String Launcher_AutoHash = String_FromArray(hashBuffer);
|
||||||
|
|
||||||
void Launcher_SetScreen(struct LScreen* screen) {
|
void Launcher_SetScreen(struct LScreen* screen) {
|
||||||
if (Launcher_Screen) Launcher_Screen->Free(Launcher_Screen);
|
if (activeScreen) activeScreen->Free(activeScreen);
|
||||||
Launcher_Screen = screen;
|
activeScreen = screen;
|
||||||
if (!screen->numWidgets) screen->Init(screen);
|
if (!screen->numWidgets) screen->Init(screen);
|
||||||
|
|
||||||
screen->Show(screen);
|
screen->Show(screen);
|
||||||
@ -161,7 +161,7 @@ static void OnResize(void* obj) {
|
|||||||
Window_FreeFramebuffer(&Launcher_Framebuffer);
|
Window_FreeFramebuffer(&Launcher_Framebuffer);
|
||||||
InitFramebuffer();
|
InitFramebuffer();
|
||||||
|
|
||||||
if (Launcher_Screen) Launcher_Screen->Layout(Launcher_Screen);
|
if (activeScreen) activeScreen->Layout(activeScreen);
|
||||||
Launcher_Redraw();
|
Launcher_Redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,28 +178,28 @@ static cc_bool IsShutdown(int key) {
|
|||||||
|
|
||||||
static void OnInputDown(void* obj, int key, cc_bool was) {
|
static void OnInputDown(void* obj, int key, cc_bool was) {
|
||||||
if (IsShutdown(key)) Launcher_ShouldExit = true;
|
if (IsShutdown(key)) Launcher_ShouldExit = true;
|
||||||
Launcher_Screen->KeyDown(Launcher_Screen, key, was);
|
activeScreen->KeyDown(activeScreen, key, was);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnKeyPress(void* obj, int c) {
|
static void OnKeyPress(void* obj, int c) {
|
||||||
Launcher_Screen->KeyPress(Launcher_Screen, c);
|
activeScreen->KeyPress(activeScreen, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnMouseWheel(void* obj, float delta) {
|
static void OnMouseWheel(void* obj, float delta) {
|
||||||
Launcher_Screen->MouseWheel(Launcher_Screen, delta);
|
activeScreen->MouseWheel(activeScreen, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnPointerDown(void* obj, int idx) {
|
static void OnPointerDown(void* obj, int idx) {
|
||||||
Launcher_Screen->MouseDown(Launcher_Screen, 0);
|
activeScreen->MouseDown(activeScreen, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnPointerUp(void* obj, int idx) {
|
static void OnPointerUp(void* obj, int idx) {
|
||||||
Launcher_Screen->MouseUp(Launcher_Screen, 0);
|
activeScreen->MouseUp(activeScreen, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnPointerMove(void* obj, int idx, int deltaX, int deltaY) {
|
static void OnPointerMove(void* obj, int idx, int deltaX, int deltaY) {
|
||||||
if (!Launcher_Screen) return;
|
if (!activeScreen) return;
|
||||||
Launcher_Screen->MouseMove(Launcher_Screen, deltaX, deltaY);
|
activeScreen->MouseMove(activeScreen, deltaX, deltaY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -257,8 +257,8 @@ static void Launcher_Free(void) {
|
|||||||
Font_Free(&Launcher_TextFont);
|
Font_Free(&Launcher_TextFont);
|
||||||
Font_Free(&Launcher_HintFont);
|
Font_Free(&Launcher_HintFont);
|
||||||
|
|
||||||
Launcher_Screen->Free(Launcher_Screen);
|
activeScreen->Free(activeScreen);
|
||||||
Launcher_Screen = NULL;
|
activeScreen = NULL;
|
||||||
Window_FreeFramebuffer(&Launcher_Framebuffer);
|
Window_FreeFramebuffer(&Launcher_Framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ void Launcher_Run(void) {
|
|||||||
Window_ProcessEvents();
|
Window_ProcessEvents();
|
||||||
if (!WindowInfo.Exists || Launcher_ShouldExit) break;
|
if (!WindowInfo.Exists || Launcher_ShouldExit) break;
|
||||||
|
|
||||||
Launcher_Screen->Tick(Launcher_Screen);
|
activeScreen->Tick(activeScreen);
|
||||||
if (Launcher_Dirty.Width) Launcher_Display();
|
if (Launcher_Dirty.Width) Launcher_Display();
|
||||||
Thread_Sleep(10);
|
Thread_Sleep(10);
|
||||||
}
|
}
|
||||||
@ -539,7 +539,7 @@ void Launcher_ResetPixels(void) {
|
|||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (Launcher_Screen && Launcher_Screen->hidesTitlebar) {
|
if (activeScreen && activeScreen->hidesTitlebar) {
|
||||||
Launcher_ResetArea(0, 0, WindowInfo.Width, WindowInfo.Height);
|
Launcher_ResetArea(0, 0, WindowInfo.Width, WindowInfo.Height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -566,7 +566,7 @@ void Launcher_ResetPixels(void) {
|
|||||||
|
|
||||||
void Launcher_Redraw(void) {
|
void Launcher_Redraw(void) {
|
||||||
Launcher_ResetPixels();
|
Launcher_ResetPixels();
|
||||||
Launcher_Screen->Draw(Launcher_Screen);
|
activeScreen->Draw(activeScreen);
|
||||||
Launcher_MarkAllDirty();
|
Launcher_MarkAllDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
struct LScreen;
|
struct LScreen;
|
||||||
struct FontDesc;
|
struct FontDesc;
|
||||||
|
|
||||||
/* Currently active screen/menu. */
|
|
||||||
extern struct LScreen* Launcher_Screen;
|
|
||||||
/* The area/region of the window that needs to be redrawn and presented to the screen. */
|
/* The area/region of the window that needs to be redrawn and presented to the screen. */
|
||||||
/* If width is 0, means no area needs to be redrawn. */
|
/* If width is 0, means no area needs to be redrawn. */
|
||||||
extern Rect2D Launcher_Dirty;
|
extern Rect2D Launcher_Dirty;
|
||||||
|
@ -118,19 +118,15 @@ static int Program_Run(int argc, char** argv) {
|
|||||||
RunGame();
|
RunGame();
|
||||||
#else
|
#else
|
||||||
Launcher_Run();
|
Launcher_Run();
|
||||||
|
/* :hash to auto join server with the given hash */
|
||||||
|
} else if (argsCount == 1 && args[0].buffer[0] == ':') {
|
||||||
|
args[0] = String_UNSAFE_SubstringAt(&args[0], 1);
|
||||||
|
String_Copy(&Launcher_AutoHash, &args[0]);
|
||||||
|
Launcher_Run();
|
||||||
#endif
|
#endif
|
||||||
} else if (argsCount == 1) {
|
} else if (argsCount == 1) {
|
||||||
#ifndef CC_BUILD_WEB
|
|
||||||
/* :hash to auto join server with the given hash */
|
|
||||||
if (args[0].buffer[0] == ':') {
|
|
||||||
args[0] = String_UNSAFE_SubstringAt(&args[0], 1);
|
|
||||||
String_Copy(&Launcher_AutoHash, &args[0]);
|
|
||||||
Launcher_Run();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
String_Copy(&Game_Username, &args[0]);
|
String_Copy(&Game_Username, &args[0]);
|
||||||
RunGame();
|
RunGame();
|
||||||
} else if (argsCount < 4) {
|
} else if (argsCount < 4) {
|
||||||
ExitMissingArgs(argsCount, args);
|
ExitMissingArgs(argsCount, args);
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user