diff --git a/common/arch/sdl/window.cpp b/common/arch/sdl/window.cpp index 7b5f5c46f..af962be37 100644 --- a/common/arch/sdl/window.cpp +++ b/common/arch/sdl/window.cpp @@ -18,6 +18,7 @@ #include "window.h" #include "u_mem.h" #include "dxxerror.h" +#include "event.h" struct window { diff --git a/common/include/event.h b/common/include/event.h index 090b3eabe..75052db2a 100644 --- a/common/include/event.h +++ b/common/include/event.h @@ -6,13 +6,14 @@ */ // Event header file -#ifndef _EVENT_H -#define _EVENT_H +#pragma once + +#include "fwd-event.h" #include "maths.h" #ifdef __cplusplus -typedef enum event_type +enum event_type : unsigned { EVENT_IDLE = 0, EVENT_QUIT, @@ -45,7 +46,7 @@ typedef enum event_type EVENT_UI_LISTBOX_MOVED, EVENT_UI_LISTBOX_SELECTED, EVENT_UI_USERBOX_DRAGGED -} event_type; +}; // A vanilla event. Cast to the correct type of event according to 'type'. struct d_event @@ -62,7 +63,7 @@ struct d_change_event : d_event { int citem; d_change_event(const int c) : - d_event(d_event{EVENT_NEWMENU_CHANGED}), citem(c) + d_event{EVENT_NEWMENU_CHANGED}, citem(c) { } }; @@ -71,40 +72,11 @@ struct d_select_event : d_event { int citem; d_select_event(const int c) : - d_event(d_event{EVENT_NEWMENU_SELECTED}), citem(c) + d_event{EVENT_NEWMENU_SELECTED}, citem(c) { } }; -int event_init(); - -// Sends input events to event handlers -void event_poll(); -void event_flush(); - -// Set and call the default event handler -int call_default_handler(const d_event &event); - -// Send an event to the front window as first priority, then to the windows behind if it's not modal (editor), then the default handler -void event_send(const d_event &event); - -// Sends input, idle and draw events to event handlers -void event_process(); - -void event_enable_focus(); -void event_disable_focus(); -static inline void event_toggle_focus(int activate_focus) -{ - if (activate_focus) - event_enable_focus(); - else - event_disable_focus(); -} - -// See how long we were idle for -void event_reset_idle_seconds(); fix event_get_idle_seconds(); #endif - -#endif diff --git a/common/include/fwd-event.h b/common/include/fwd-event.h new file mode 100644 index 000000000..6e107b3c9 --- /dev/null +++ b/common/include/fwd-event.h @@ -0,0 +1,47 @@ +/* + * This file is part of the DXX-Rebirth project . + * It is copyright by its individual contributors, as recorded in the + * project's Git history. See COPYING.txt at the top level for license + * terms and a link to the Git history. + */ + +#pragma once + +struct d_event; +struct d_create_event; +struct d_change_event; +struct d_select_event; + +#ifdef __cplusplus + +enum event_type : unsigned; + +int event_init(); + +// Sends input events to event handlers +void event_poll(); +void event_flush(); + +// Set and call the default event handler +int call_default_handler(const d_event &event); + +// Send an event to the front window as first priority, then to the windows behind if it's not modal (editor), then the default handler +void event_send(const d_event &event); + +// Sends input, idle and draw events to event handlers +void event_process(); + +void event_enable_focus(); +void event_disable_focus(); +static inline void event_toggle_focus(int activate_focus) +{ + if (activate_focus) + event_enable_focus(); + else + event_disable_focus(); +} + +// See how long we were idle for +void event_reset_idle_seconds(); + +#endif diff --git a/common/include/key.h b/common/include/key.h index cc8fec734..836372cf5 100644 --- a/common/include/key.h +++ b/common/include/key.h @@ -29,7 +29,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #include "pstypes.h" #include "maths.h" -#include "event.h" +#include "fwd-event.h" #define KEY_BUFFER_SIZE 16 #define KEY_REPEAT_DELAY 400 diff --git a/common/include/mouse.h b/common/include/mouse.h index 47d299e7d..a5928a6d0 100644 --- a/common/include/mouse.h +++ b/common/include/mouse.h @@ -18,6 +18,7 @@ #ifdef __cplusplus #include #include "window.h" +#include "event.h" struct SDL_MouseButtonEvent; struct SDL_MouseMotionEvent; diff --git a/common/include/ui.h b/common/include/ui.h index a7ba4d056..ce6ca358c 100644 --- a/common/include/ui.h +++ b/common/include/ui.h @@ -26,7 +26,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #pragma once #include "dxxsconf.h" -#include "event.h" +#include "fwd-event.h" #include "fmtcheck.h" #include "u_mem.h" diff --git a/common/include/window.h b/common/include/window.h index dda1befcf..82c839bc7 100644 --- a/common/include/window.h +++ b/common/include/window.h @@ -16,7 +16,7 @@ #pragma once -#include "event.h" +#include "fwd-event.h" #include "gr.h" #include "console.h" diff --git a/common/main/inferno.h b/common/main/inferno.h index 17bde31b8..f7c4c6fcf 100644 --- a/common/main/inferno.h +++ b/common/main/inferno.h @@ -23,14 +23,11 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. * */ -#ifndef _INFERNO_H -#define _INFERNO_H +#pragma once -#include +#include "fwd-event.h" #include "ntstring.h" -struct d_event; - #if defined(__APPLE__) || defined(macintosh) #define KEY_MAC(x) x #else @@ -73,5 +70,3 @@ extern int MacHog; // Default event handler for everything except the editor int standard_handler(const d_event &event); - -#endif diff --git a/common/main/newmenu.h b/common/main/newmenu.h index a9c8d669a..a9cc8988f 100644 --- a/common/main/newmenu.h +++ b/common/main/newmenu.h @@ -25,7 +25,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #pragma once -#include "event.h" +#include "fwd-event.h" #ifdef __cplusplus #include diff --git a/d1x-rebirth/editor/ehostage.cpp b/d1x-rebirth/editor/ehostage.cpp index 6ad515a06..ca6559d0f 100644 --- a/d1x-rebirth/editor/ehostage.cpp +++ b/d1x-rebirth/editor/ehostage.cpp @@ -51,6 +51,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "centers.h" #include "piggy.h" #include "u_mem.h" +#include "event.h" #include "compiler-make_unique.h" diff --git a/d2x-rebirth/main/escort.cpp b/d2x-rebirth/main/escort.cpp index b6a0a154f..2f3821af6 100644 --- a/d2x-rebirth/main/escort.cpp +++ b/d2x-rebirth/main/escort.cpp @@ -51,6 +51,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "hudmsg.h" #include "cntrlcen.h" #include "gauges.h" +#include "event.h" #include "key.h" #include "fuelcen.h" #include "sounds.h" diff --git a/similar/editor/centers.cpp b/similar/editor/centers.cpp index e6ae8ef2b..3506038d8 100644 --- a/similar/editor/centers.cpp +++ b/similar/editor/centers.cpp @@ -31,6 +31,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "fuelcen.h" #include "screens.h" #include "inferno.h" +#include "event.h" #include "segment.h" #include "editor.h" #include "editor/esegment.h" diff --git a/similar/editor/eswitch.cpp b/similar/editor/eswitch.cpp index 132873564..eccbf8a64 100644 --- a/similar/editor/eswitch.cpp +++ b/similar/editor/eswitch.cpp @@ -35,6 +35,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "eswitch.h" #include "segment.h" #include "dxxerror.h" +#include "event.h" #include "gameseg.h" #include "wall.h" #include "medwall.h" diff --git a/similar/editor/info.cpp b/similar/editor/info.cpp index 7861a6b08..cfc56e004 100644 --- a/similar/editor/info.cpp +++ b/similar/editor/info.cpp @@ -31,6 +31,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "inferno.h" #include "window.h" #include "segment.h" +#include "event.h" #include "gr.h" #include "ui.h" #include "editor.h" diff --git a/similar/editor/medrobot.cpp b/similar/editor/medrobot.cpp index b4db55756..e9de9231b 100644 --- a/similar/editor/medrobot.cpp +++ b/similar/editor/medrobot.cpp @@ -31,6 +31,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "screens.h" #include "inferno.h" #include "segment.h" +#include "event.h" #include "editor.h" #include "editor/esegment.h" #include "editor/medmisc.h" diff --git a/similar/editor/medwall.cpp b/similar/editor/medwall.cpp index a1662183e..5cac1063a 100644 --- a/similar/editor/medwall.cpp +++ b/similar/editor/medwall.cpp @@ -34,6 +34,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "editor/esegment.h" #include "segment.h" #include "dxxerror.h" +#include "event.h" #include "gameseg.h" #include "textures.h" #include "screens.h" diff --git a/similar/editor/objpage.cpp b/similar/editor/objpage.cpp index 890380b47..25d623f95 100644 --- a/similar/editor/objpage.cpp +++ b/similar/editor/objpage.cpp @@ -31,6 +31,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gr.h" // For canves, font stuff #include "ui.h" // For UI_GADGET stuff #include "object.h" // For robot_bms +#include "event.h" #include "dxxerror.h" #include "objpage.h" #include "bm.h" diff --git a/similar/editor/texpage.cpp b/similar/editor/texpage.cpp index 8f78751d3..60daf8ad1 100644 --- a/similar/editor/texpage.cpp +++ b/similar/editor/texpage.cpp @@ -37,6 +37,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "textures.h" // For NumTextures #include "dxxerror.h" #include "key.h" +#include "event.h" #include "gamesave.h" #include "mission.h" diff --git a/similar/main/console.cpp b/similar/main/console.cpp index 148066a1d..0bd0eb672 100644 --- a/similar/main/console.cpp +++ b/similar/main/console.cpp @@ -18,6 +18,7 @@ #include #include #include "window.h" +#include "event.h" #include "console.h" #include "args.h" #include "gr.h" diff --git a/similar/main/gameseq.cpp b/similar/main/gameseq.cpp index f5666ca94..7d7dcaa73 100644 --- a/similar/main/gameseq.cpp +++ b/similar/main/gameseq.cpp @@ -50,6 +50,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "timer.h" #include "render.h" #include "laser.h" +#include "event.h" #include "screens.h" #include "textures.h" #include "slew.h" diff --git a/similar/main/mission.cpp b/similar/main/mission.cpp index 10566807b..1fd694cf6 100644 --- a/similar/main/mission.cpp +++ b/similar/main/mission.cpp @@ -50,6 +50,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "physfsx.h" #include "physfs_list.h" #include "bm.h" +#include "event.h" #if defined(DXX_BUILD_DESCENT_II) #include "movie.h" #endif diff --git a/similar/main/net_udp.cpp b/similar/main/net_udp.cpp index 9e83f1c9f..14479b7ef 100644 --- a/similar/main/net_udp.cpp +++ b/similar/main/net_udp.cpp @@ -51,6 +51,7 @@ #include "hudmsg.h" #include "switch.h" #include "automap.h" +#include "event.h" #include "playsave.h" #include "gamefont.h" #include "rbaudio.h" diff --git a/similar/main/state.cpp b/similar/main/state.cpp index 0d37ba1c2..6d6a96bd6 100644 --- a/similar/main/state.cpp +++ b/similar/main/state.cpp @@ -51,6 +51,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "weapon.h" #include "render.h" #include "gameseq.h" +#include "event.h" #include "robot.h" #include "gauges.h" #include "newdemo.h"