No more compile errors but still completely broken

This commit is contained in:
UnknownShadow200 2019-08-11 21:37:11 +10:00
parent 1308acaa71
commit 347fdd0ffc
5 changed files with 13 additions and 19 deletions

View File

@ -636,10 +636,7 @@ static void Game_RenderFrame(double delta) {
Game_Vertices = 0;
Camera.Active->UpdateMouse(delta);
if (!Window_Focused && !Gui_GetInputGrab()) {
Gui_FreeActive();
Gui_SetActive(PauseScreen_MakeInstance());
}
if (!Window_Focused && !Gui_GetInputGrab()) PauseScreen_Show();
if (KeyBind_IsPressed(KEYBIND_ZOOM_SCROLL) && !Gui_GetInputGrab()) {
InputHandler_SetFOV(Game_ZoomFov);

View File

@ -481,7 +481,7 @@ static void InputHandler_KeyDown(void* obj, int key, bool was) {
Game_ScreenshotRequested = true; return;
} else if (Elem_HandlesKeyDown(active, key, was)) {
return;
} else if ((key == KEY_ESCAPE || key == KEY_PAUSE) && !active->handlesAllInput) {
} else if ((key == KEY_ESCAPE || key == KEY_PAUSE) && !Gui_GetInputGrab()) {
#ifdef CC_BUILD_WEB
/* Can't do this in KeyUp, because pressing escape without having */
/* explicitly disabled mouse lock means a KeyUp event isn't sent. */
@ -490,8 +490,7 @@ static void InputHandler_KeyDown(void* obj, int key, bool was) {
/* closes the pause screen. Hence why the next KeyUp must be supressed. */
suppressEscape = true;
#endif
Gui_FreeActive();
Gui_SetActive(PauseScreen_MakeInstance()); return;
PauseScreen_Show(); return;
}
/* These should not be triggered multiple times when holding down */

View File

@ -324,7 +324,7 @@ static PackedCol Menu_HexCol(const String* str) { PackedCol v; PackedCol_TryPars
#define Menu_ReplaceActive(screen) Gui_FreeActive(); Gui_SetActive(screen);
static void Menu_SwitchOptions(void* a, void* b) { Menu_ReplaceActive(OptionsGroupScreen_MakeInstance()); }
static void Menu_SwitchPause(void* a, void* b) { Menu_ReplaceActive(PauseScreen_MakeInstance()); }
static void Menu_SwitchPause(void* a, void* b) { PauseScreen_Show(); }
static void Menu_SwitchClassicOptions(void* a, void* b) { Menu_ReplaceActive(ClassicOptionsScreen_MakeInstance()); }
static void Menu_SwitchKeysClassic(void* a, void* b) { Menu_ReplaceActive(ClassicKeyBindingsScreen_MakeInstance()); }
@ -671,7 +671,7 @@ static struct ScreenVTABLE PauseScreen_VTABLE = {
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
Menu_OnResize, Menu_ContextLost, PauseScreen_ContextRecreated,
};
struct Screen* PauseScreen_MakeInstance(void) {
void PauseScreen_Show(void) {
static struct Widget* widgets[8];
struct PauseScreen* s = &PauseScreen_Instance;
@ -681,7 +681,7 @@ struct Screen* PauseScreen_MakeInstance(void) {
s->widgetsCount = Array_Elems(widgets);
s->VTABLE = &PauseScreen_VTABLE;
return (struct Screen*)s;
Gui_Replace((struct Screen*)s, GUI_PRIORITY_MENU);
}
@ -1267,8 +1267,7 @@ static void SaveLevelScreen_SaveMap(struct SaveLevelScreen* s, const String* pat
if (res) { Logger_Warn2(res, "closing", path); return; }
Chat_Add1("&eSaved map to: %s", path);
Gui_FreeActive();
Gui_SetActive(PauseScreen_MakeInstance());
PauseScreen_Show();
}
static void SaveLevelScreen_Save(void* screen, void* widget, const char* ext) {

View File

@ -7,7 +7,7 @@
*/
struct Screen;
struct Screen* PauseScreen_MakeInstance(void);
void PauseScreen_Show(void);
struct Screen* OptionsGroupScreen_MakeInstance(void);
struct Screen* ClassicOptionsScreen_MakeInstance(void);

View File

@ -564,7 +564,7 @@ static void LoadingScreen_Free(void* screen) {
Event_UnregisterFloat(&WorldEvents.Loading, s, LoadingScreen_MapLoading);
}
CC_NOINLINE static void LoadingScreen_Reset(const String* title, const String* message) {
CC_NOINLINE static void LoadingScreen_ShowCommon(const String* title, const String* message) {
struct LoadingScreen* s = &LoadingScreen_Instance;
s->lastState = NULL;
s->progress = 0.0f;
@ -576,6 +576,7 @@ CC_NOINLINE static void LoadingScreen_Reset(const String* title, const String* m
s->grabsInput = true;
s->blocksWorld = true;
Gui_Replace((struct Screen*)s, GUI_PRIORITY_LOADING);
}
static struct ScreenVTABLE LoadingScreen_VTABLE = {
@ -585,9 +586,8 @@ static struct ScreenVTABLE LoadingScreen_VTABLE = {
LoadingScreen_OnResize, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated,
};
void LoadingScreen_Show(const String* title, const String* message) {
LoadingScreen_Reset(title, message);
LoadingScreen_Instance.VTABLE = &LoadingScreen_VTABLE;
Gui_Replace((struct Screen*)&LoadingScreen_Instance, GUI_PRIORITY_LOADING);
LoadingScreen_ShowCommon(title, message);
}
struct Screen* LoadingScreen_UNSAFE_RawPointer = (struct Screen*)&LoadingScreen_Instance;
@ -659,9 +659,8 @@ void GeneratingScreen_Show(void) {
static const String title = String_FromConst("Generating level");
static const String message = String_FromConst("Generating..");
LoadingScreen_Reset(&title, &message);
LoadingScreen_Instance.VTABLE = &GeneratingScreen_VTABLE;
Gui_Replace((struct Screen*)&LoadingScreen_Instance, GUI_PRIORITY_LOADING);
LoadingScreen_ShowCommon(&title, &message);
}
@ -1218,7 +1217,7 @@ static void HUDScreen_Render(void* screen, double delta) {
HUDScreen_DrawChat(s, delta);
if (s->showingList && Gui_GetActiveScreen() == (struct Screen*)s) {
s->playerList.active = s->handlesAllInput;
s->playerList.active = s->grabsInput;
Elem_Render(&s->playerList, delta);
/* NOTE: Should usually be caught by KeyUp, but just in case. */
if (!KeyBind_IsPressed(KEYBIND_PLAYER_LIST)) {