jubilant-funicular
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nta::ScreenManager Class Reference

#include <ScreenManager.h>

Collaboration diagram for nta::ScreenManager:
Collaboration graph
[legend]

Public Member Functions

 ScreenManager (crstring title, float maxFPS, int width=640, int height=480)
 sets the max fps and the window to use
 
 ~ScreenManager ()
 basic destructor
 
ScreengetCurrScreen () const
 returns the active screen More...
 
const WindowgetWindow () const
 returns the window
 
const InputManagergetInput () const
 returns the InputManager
 
ContextDatagetContextData ()
 returns the ContextData
 
float getFPS () const
 returns the current fps
 
bool owns_event (const SDL_Event &event) const
 
void setResourceFolders (const utils::Path &tex_fldr, const utils::Path &glsl_fldr, const utils::Path &font_fldr)
 Sets the location of textures, shaders, and fonts.
 
void addScreen (Screen *newScreen, int escIndex=-1, int xIndex=-1, crstring title="")
 adds a screen and sets some of its properties
 
void switchScreen (int newIndex)
 switches the to a new screen
 
void destroy ()
 destroys screens
 
void run (void *initFocusData=nullptr)
 

Private Member Functions

void update_input ()
 Updates the state of m_input.
 

Private Attributes

std::vector< Screen * > m_screens
 the screens
 
ContextData m_context_data
 GLTextures and GLSLPrograms and whatnot.
 
InputManager m_input
 Keeps track of all input received in this window.
 
FPSLimiter m_limiter
 used to cap the FPS
 
Windowm_window
 the main window used by the manager
 
int m_currScreen = -1
 the index of the currently active screen
 

Static Private Attributes

static std::mutex m_window_creation_lock
 
static std::mutex m_event_lock
 Lock for access the event queue.
 

Detailed Description

Manages a collection of screens

Todo:
(?) Move m_glslMap and m_input to Window?

Definition at line 16 of file ScreenManager.h.

Member Function Documentation

◆ getCurrScreen()

Screen * nta::ScreenManager::getCurrScreen ( ) const

returns the active screen

Todo:
write log error if m_currScreen is out of range

Definition at line 28 of file ScreenManager.cpp.

Referenced by run(), switchScreen(), and update_input().

◆ owns_event()

bool nta::ScreenManager::owns_event ( const SDL_Event &  event) const

returns true if this manager is responsible for handling the event

Todo:
CamelCase

Definition at line 79 of file ScreenManager.cpp.

Referenced by update_input().

◆ run()

void nta::ScreenManager::run ( void *  initFocusData = nullptr)

runs screen logic (render, update, handleInput, etc.)

initFocusData is the input to onFocus for the first screen

Definition at line 141 of file ScreenManager.cpp.


The documentation for this class was generated from the following files: