diff --git a/src/Chat.c b/src/Chat.c index 956f6212e..1d5dc624f 100644 --- a/src/Chat.c +++ b/src/Chat.c @@ -590,6 +590,14 @@ void Chat_Send(const cc_string* text, cc_bool logUsage) { Event_RaiseChat(&ChatEvents.ChatSending, text, 0); if (logUsage) StringsBuffer_Add(&Chat_InputLog, text); +#ifdef CC_BUILD_WEB + if (String_CaselessEqualsConst(text, "/client debug")) { + Chat_AddRaw("DEBUG CANNON ENGAGED"); + extern int Window_Debug; + Window_Debug = true; + } +#endif + if (Commands_IsCommandPrefix(text)) { Commands_Execute(text); } else { diff --git a/src/Screens.c b/src/Screens.c index b409530b4..662dc0d12 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -795,6 +795,7 @@ static cc_bool ChatScreen_ChatUpdateFont(struct ChatScreen* s) { Math_Clamp(size, 8, 60); /* don't recreate font if possible */ + /* TODO: Add function for this, don't use Display_ScaleY (Drawer2D_SameFontSize ??) */ if (Display_ScaleY(size) == s->chatFont.size) return false; ChatScreen_FreeChatFonts(s); Drawer2D_MakeFont(&s->chatFont, size, FONT_FLAGS_NONE); diff --git a/src/Window.c b/src/Window.c index b2aad8233..4ca354b11 100644 --- a/src/Window.c +++ b/src/Window.c @@ -3520,7 +3520,33 @@ void Window_Close(void) { UnhookEvents(); } +#include "Chat.h" +static void LogStuff(void) { + char buffer[256]; cc_string str = String_FromArray(buffer); + int width, height; + double css_width, css_height; + + width = GetCanvasWidth(); + height = GetCanvasHeight(); + String_Format2(&str, "Size: %ix%i", &width, &height); + Chat_AddOf(&str, MSG_TYPE_STATUS_1); + str.length = 0; + + width = EM_ASM_INT_V({ return window.innerHeight; }); + height = EM_ASM_INT_V({ return window.outerHeight; }); + String_Format2(&str, "I:%i O:%i", &width, &height); + Chat_AddOf(&str, MSG_TYPE_STATUS_2); + str.length = 0; + + width = GetScreenWidth(); + height = GetScreenHeight(); + String_Format2(&str, "Dims: %ix%i", &width, &height); + Chat_AddOf(&str, MSG_TYPE_STATUS_3); +} + +int Window_Debug; void Window_ProcessEvents(void) { + if (Window_Debug) LogStuff(); if (!needResize) return; needResize = false;