Changeset d8cf709 in opengl-game for game-gui.hpp


Ignore:
Timestamp:
Feb 13, 2021, 11:41:39 PM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
c6f0793
Parents:
8b823e7
Message:

Change UIEvent to also include the original event from the UI library the game gui is currently using, such as SDL or GLFW.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • game-gui.hpp

    r8b823e7 rd8cf709  
    88   #include <vulkan/vulkan.h>
    99#endif
     10
     11// These are included here so I can implement the RawEvent union, which requires knowledge
     12// of the ui event types of all ui libraries I might use for any of the GameGui clases
     13// GLFW does not have its own event type though, so SDL is currently the only library this is done for
     14#include <SDL2/SDL.h>
    1015
    1116using namespace std;
     
    2530};
    2631
    27 struct WindowEvent {
    28    EventType type;
     32union RawEvent {
     33   SDL_Event sdl;
    2934};
    3035
     
    4550};
    4651
     52struct WindowEvent {
     53   EventType type;
     54};
     55
    4756struct WindowResizeEvent {
    4857   EventType type;
     
    5362struct UnknownEvent {
    5463   EventType type;
    55    unsigned int eventType;
    5664};
    5765
    5866// TODO: Switch from union to std::variant
    5967
    60 union UIEvent {
     68union GameEvent {
    6169   EventType type;
    6270   WindowEvent window;
     
    6573   WindowResizeEvent windowResize;
    6674   UnknownEvent unknown;
     75};
     76
     77struct UIEvent {
     78   RawEvent rawEvent;
     79   GameEvent event;
    6780};
    6881
     
    8093
    8194      virtual void processEvents() = 0;
    82       virtual int pollEvent(UIEvent* event) = 0;
     95      virtual int pollEvent(UIEvent* uiEvent) = 0;
    8396      virtual bool keyPressed(unsigned int key) = 0;
    8497
Note: See TracChangeset for help on using the changeset viewer.