Middle Europe Productions Library  alpha 1.3.3
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MEP::Template::Application Class Referenceabstract

A basic class for the Application. More...

#include <Application.h>

Inheritance diagram for MEP::Template::Application:
MEP::WindowData MEP::Resources MEP::WindowStats MEP::BaseManager MEPtools::GroupManager< MEP::Object > MEPtools::GroupManager< MEP::Font > MEP::NonCopyable MEPtools::GroupManager< BaseWindow, std::shared_ptr< BaseWindow > >

Public Member Functions

 Application (const char *title, const char *resPath, const sf::Vector2u &mainResolution={ 1280, 720 }, U_int32 style=sf::Style::Default, sf::ContextSettings settings=sf::ContextSettings())
 
virtual ~Application ()
 
void setWindowTransparent ()
 
void setWindowTransparency (unsigned char alpha)
 
void initApp ()
 
virtual bool run ()
 
virtual void createResources ()=0
 
virtual void createWindows ()=0
 
- Public Member Functions inherited from MEP::WindowData
 WindowData (const char *title, const sf::Vector2u &mainResolution={ 1280, 720 }, U_int32 style=sf::Style::Default, sf::ContextSettings settings=sf::ContextSettings())
 
void initWindow ()
 
sf::RenderWindow & getRenderWindow ()
 
sf::ContextSettings & getContext ()
 
sf::View & getMepView ()
 
void changeResolution (const sf::Vector2u &newRes)
 
const sf::Vector2u & getLaunchResolution () const
 
const sf::Vector2u getWindowSize () const
 
void setResolution (const sf::Vector2u &res)
 
sf::Vector2u getResolution () const
 
- Public Member Functions inherited from MEP::Resources
 Resources (const std::string &path)
 
template<typename ... Values>
void initResources (Values &&... values)
 
bool isLoaded () const
 
ObjectgetObject (const U_int32 ID, const U_int32 group=-1)
 
sf::Font & getFont (const U_int32 ID, const U_int32 group=-1)
 
template<typename T >
T & get (const U_int32 ID, const U_int32 group=-1)
 
void deleteObject (const U_int32 ID, const U_int32 group=-1)
 
void deleteObjectsGroup (const U_int32 group)
 
void deleteFont (const U_int32 ID, const U_int32 group=-1)
 
void deleteFontGroup (const U_int32 group)
 
virtual ~Resources ()
 
- Public Member Functions inherited from MEP::WindowStats
 WindowStats ()=default
 
void updateStatistics (sf::Time dt)
 
unsigned int getFrameRate () const
 
sf::Time & getGlobalTime ()
 
 ~WindowStats ()=default
 
- Public Member Functions inherited from MEP::BaseManager
 BaseManager ()=default
 
BaseWindowgetWindow (MEP::U_int32 ID, MEP::U_int32 group=-1)
 
std::map< MEP::U_int32, std::shared_ptr< BaseWindow > > & getWindowGroup (MEP::U_int32 group=-1)
 
void deleteWindow (MEP::U_int32 ID, MEP::U_int32 group=-1)
 
void deleteWindowGroup (MEP::U_int32 group=-1)
 
void addWindow (BaseWindow *window, MEP::U_int32 group=-1)
 
BaseWindowlatestWindow ()
 
template<typename Method >
void execute (Method method)
 
template<typename Method >
void execute (Method method, MEP::U_int32 group)
 

Protected Member Functions

virtual void update ()
 
virtual void handleEvents ()
 
virtual void render ()
 
virtual void onResize ()
 
- Protected Member Functions inherited from MEP::NonCopyable
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 

Protected Attributes

bool isInit = false
 
- Protected Attributes inherited from MEP::WindowData
sf::View m_view
 
sf::Vector2u m_resolution
 
const sf::Vector2u m_launchResolution
 
sf::ContextSettings m_settings
 
sf::Color m_backgroundColor = sf::Color::Black
 
std::string m_title
 
U_int32 m_style
 

Detailed Description

A basic class for the Application.

MEP::Window::Teample::Application features: Window management. Resource management. Exceptions management. Main loop management. Inheriting this class u are able to generate a fully functional application window.

Constructor & Destructor Documentation

◆ Application()

MEP::Template::Application::Application ( const char *  title,
const char *  resPath,
const sf::Vector2u &  mainResolution = { 1280, 720 },
U_int32  style = sf::Style::Default,
sf::ContextSettings  settings = sf::ContextSettings() 
)
inline

Base constructor for the Application.

Parameters
[in]title: Title of the window.
[in]resPath: Path to the resorces.
[in]mainResolution: Resolution of the window.
[in]style: Style of a window. Use sf::Style here.
[in]settings: Have a look on sf::ContextSettings for the information.

◆ ~Application()

virtual MEP::Template::Application::~Application ( )
inlinevirtual

Member Function Documentation

◆ createResources()

virtual void MEP::Template::Application::createResources ( )
pure virtual

Creates the game resources. Method needs to be overwritten

◆ createWindows()

virtual void MEP::Template::Application::createWindows ( )
pure virtual

Creates the game resources. Method needs to be overwritten

◆ handleEvents()

virtual void MEP::Template::Application::handleEvents ( )
inlineprotectedvirtual

Main update events method, all of the imputs to the program are analyzed here. The update method in executed only for MEP::Window::BaseWindow with a status == BaseWindow::Status::Main furthermore, the individual imput will be handled separately for all of the BaseWindow::Status::Main windows.

◆ initApp()

void MEP::Template::Application::initApp ( )
inline

Initialization of an Application Two methods are executed: createResources() createWindows() (in the following order) The method can throw a MEP::Window::WindowException exception if something is not right inside of the aforementioned methods.

◆ onResize()

virtual void MEP::Template::Application::onResize ( )
inlineprotectedvirtual

Overrides the on resize method. A little hint is that SFML only executes this method when actual size of the window was changed so you dont need to check that.

Reimplemented from MEP::WindowData.

◆ render()

virtual void MEP::Template::Application::render ( )
inlineprotectedvirtual

Main render method, all of the drawing are done here. Method is supporting custom views from the MEP::Window::BaseWindow and it renders all of the MEP::Window::BaseWindow with a status == BaseWindow::Status::Main

◆ run()

virtual bool MEP::Template::Application::run ( )
inlinevirtual

Main loop. Just use it to run an application. The method can throw a MEP::Window::WindowException.

◆ setWindowTransparency()

void MEP::Template::Application::setWindowTransparency ( unsigned char  alpha)
inline

Method changes the transparency level up to 255 of a window. It is a PLATFORM dependent method.

◆ setWindowTransparent()

void MEP::Template::Application::setWindowTransparent ( )
inline

Method sets the sf::Color::Transparent to a real transparent color. It is a PLATFORM dependent method.

◆ update()

virtual void MEP::Template::Application::update ( )
inlineprotectedvirtual

Main update method, all of the program logic is executed here. The update method in executed only for MEP::Window::BaseWindow with a status != BaseWindow::Status::NullAction

Member Data Documentation

◆ isInit

bool MEP::Template::Application::isInit = false
protected

Status of an initialization.