Fix position/hacks status still showing in top-left even when in menus

This commit is contained in:
UnknownShadow200 2019-08-21 20:26:38 +10:00
parent 15b67e1b02
commit ac7e02208c
4 changed files with 16 additions and 13 deletions

View File

@ -19,7 +19,6 @@ bool Gui_ClickableChat, Gui_TabAutocomplete, Gui_ShowFPS;
GfxResourceID Gui_GuiTex, Gui_GuiClassicTex, Gui_IconsTex;
struct Screen* Gui_Status;
struct Screen* Gui_HUD;
struct Screen* Gui_Active;
struct Screen* Gui_Screens[GUI_MAX_SCREENS];
int Gui_ScreensCount;
static uint8_t priorities[GUI_MAX_SCREENS];
@ -152,10 +151,6 @@ struct IGameComponent Gui_Component = {
NULL, /* OnNewMapLoaded */
};
struct Screen* Gui_GetActiveScreen(void) {
return Gui_Active ? Gui_Active : Gui_HUD;
}
void Gui_RefreshAll(void) {
Gui_ContextLost(NULL);
Gui_ContextRecreated(NULL);
@ -236,6 +231,8 @@ void Gui_Replace(struct Screen* s, int priority) {
for (i = Gui_ScreensCount - 1; i >= 0; i--) {
if (priorities[i] == priority) Gui_RemoveCore(Gui_Screens[i]);
}
Gui_AddCore(s, priority);
Gui_OnScreensChanged();
}

View File

@ -107,7 +107,6 @@ enum GuiPriority {
extern struct Screen* Gui_Status;
extern struct Screen* Gui_HUD;
extern struct Screen* Gui_Active;
#define GUI_MAX_SCREENS 10
extern struct Screen* Gui_Screens[GUI_MAX_SCREENS];
extern int Gui_ScreensCount;
@ -117,9 +116,6 @@ extern int Gui_ScreensCount;
int Gui_CalcPos(uint8_t anchor, int offset, int size, int axisLen);
/* Returns whether the given rectangle contains the given point. */
bool Gui_Contains(int recX, int recY, int width, int height, int x, int y);
/* Gets the screen that the user is currently interacting with. */
/* This means if an overlay is active, it will be over the top of other screens. */
struct Screen* Gui_GetActiveScreen(void);
/* Returns index of the given screen in the screens list, -1 if not */
int Gui_Index(struct Screen* screen);

View File

@ -105,7 +105,7 @@ static int Program_Run(int argc, char** argv) {
int argsCount = Platform_GetCommandLineArgs(argc, argv, args);
/* NOTE: Make sure to comment this out before pushing a commit */
//String rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565");
/* String rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565"); */
String rawArgs = String_FromConst("UnknownShadow200");
argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4);

View File

@ -49,7 +49,6 @@ struct HUDScreen {
struct Texture chatTextures[TEXTGROUPWIDGET_MAX_LINES];
};
static bool Screen_FKey(void* elem, Key key) { return false; }
static bool Screen_FKeyPress(void* elem, char keyChar) { return false; }
static bool Screen_FMouseScroll(void* elem, float delta) { return false; }
@ -62,6 +61,17 @@ static bool Screen_TMouseScroll(void* screen, float delta) { return true; }
static bool Screen_TMouse(void* screen, int x, int y, int btn) { return true; }
static void Screen_NullFunc(void* screen) { }
CC_NOINLINE static bool IsOnlyHudActive(void) {
struct Screen* s;
int i;
for (i = 0; i < Gui_ScreensCount; i++) {
s = Gui_Screens[i];
if (s->grabsInput && s != Gui_HUD) return false;
}
return true;
}
/*########################################################################################################################*
*-----------------------------------------------------InventoryScreen-----------------------------------------------------*
@ -385,7 +395,7 @@ static void StatusScreen_Render(void* screen, double delta) {
if (Game_ClassicMode) {
Elem_Render(&s->line2, delta);
} else if (!Gui_Active && Gui_ShowFPS) {
} else if (IsOnlyHudActive() && Gui_ShowFPS) {
if (StatusScreen_HacksChanged(s)) { StatusScreen_UpdateHackState(s); }
StatusScreen_DrawPosition(s);
Elem_Render(&s->line2, delta);
@ -1175,7 +1185,7 @@ static void HUDScreen_Render(void* screen, double delta) {
if (!showMinimal) { Elem_Render(&s->hotbar, delta); }
HUDScreen_DrawChat(s, delta);
if (s->showingList && Gui_GetActiveScreen() == (struct Screen*)s) {
if (s->showingList && IsOnlyHudActive()) {
s->playerList.active = s->grabsInput;
Elem_Render(&s->playerList, delta);
/* NOTE: Should usually be caught by KeyUp, but just in case. */