From c6ae73d6d2a2232f2f9561a17c500a5a2be72c7e Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Sat, 16 Jul 2022 18:13:53 +0800 Subject: [PATCH] - Expose ConsoleState to scripts - Make ConsoleState uint8_t sized --- src/common/console/c_console.cpp | 4 +++- src/common/console/c_console.h | 7 +++---- src/common/platform/posix/cocoa/i_input.mm | 2 +- src/common/platform/posix/sdl/i_input.cpp | 2 +- wadsrc/static/zscript/engine/base.zs | 9 +++++++++ 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/common/console/c_console.cpp b/src/common/console/c_console.cpp index fb7fe077d..ca8540dd4 100644 --- a/src/common/console/c_console.cpp +++ b/src/common/console/c_console.cpp @@ -104,7 +104,9 @@ bool vidactive = false; bool cursoron = false; int ConBottom, ConScroll, RowAdjust; uint64_t CursorTicker; -constate_e ConsoleState = c_up; +uint8_t ConsoleState = c_up; + +DEFINE_GLOBAL(ConsoleState) static int TopLine, InsertLine; diff --git a/src/common/console/c_console.h b/src/common/console/c_console.h index 2d79992bf..8fff823b4 100644 --- a/src/common/console/c_console.h +++ b/src/common/console/c_console.h @@ -41,11 +41,10 @@ struct event_t; -typedef enum cstate_t +enum cstate_t : uint8_t { c_up=0, c_down=1, c_falling=2, c_rising=3 -} -constate_e; +}; enum { @@ -53,7 +52,7 @@ enum }; extern int PrintColors[PRINTLEVELS + 2]; -extern constate_e ConsoleState; +extern uint8_t ConsoleState; // Initialize the console void C_InitConsole (int width, int height, bool ingame); diff --git a/src/common/platform/posix/cocoa/i_input.mm b/src/common/platform/posix/cocoa/i_input.mm index f53ae8ebc..51eaec9fd 100644 --- a/src/common/platform/posix/cocoa/i_input.mm +++ b/src/common/platform/posix/cocoa/i_input.mm @@ -56,7 +56,7 @@ CVAR(Bool, use_mouse, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) extern int paused, chatmodeon; -extern constate_e ConsoleState; +extern uint8_t ConsoleState; extern bool ToggleFullscreen; bool GUICapture; diff --git a/src/common/platform/posix/sdl/i_input.cpp b/src/common/platform/posix/sdl/i_input.cpp index 66c1c2523..8c5c4e5c9 100644 --- a/src/common/platform/posix/sdl/i_input.cpp +++ b/src/common/platform/posix/sdl/i_input.cpp @@ -57,7 +57,7 @@ CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) extern int WaitingForKey, chatmodeon; -extern constate_e ConsoleState; +extern uint8_t ConsoleState; static const SDL_Keycode DIKToKeySym[256] = { diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index a55c0fabd..8ede0417a 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -143,6 +143,14 @@ enum EPrintLevel PRINT_NOLOG = 2048, // Flag - do not print to log file }; +enum EConsoleState +{ + c_up = 0, + c_down = 1, + c_falling = 2, + c_rising = 3 +}; + /* // These are here to document the intrinsic methods and fields available on // the built-in ZScript types @@ -211,6 +219,7 @@ struct _ native // These are the global variables, the struct is only here to av native readonly int consoleplayer; native readonly double NotifyFontScale; native readonly int paused; + native readonly ui uint8 ConsoleState; } struct System native