Simulant  21.12-1292
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
Public Member Functions | Protected Member Functions | Friends | List of all members
smlt::Application Class Referenceabstract
Inheritance diagram for smlt::Application:
smlt::test::TestApp

Public Member Functions

 Application (const AppConfig &config, void *platform_state=nullptr)
 
bool profiling_enabled () const
 
int32_t run ()
 
int32_t run (int argc, char *argv[])
 
bool initialized () const
 
ProcessID process_id () const
 
smlt::thread::ThreadID thread_id () const
 
int64_t ram_usage_in_bytes () const
 
bool run_frame ()
 
void run_update (float dt)
 
void run_fixed_updates ()
 
void request_frame_time (float ms)
 
void start_coroutine (std::function< void()> func)
 
void update_coroutines ()
 
void stop_all_coroutines ()
 
void stop_running ()
 
bool is_shutting_down () const
 
void shutdown ()
 
LoaderPtr loader_for (const Path &filename, LoaderHint hint=LOADER_HINT_NONE)
 
LoaderPtr loader_for (const std::string &loader_name, const Path &filename)
 
LoaderTypePtr loader_type (const std::string &loader_name) const
 
void register_loader (LoaderTypePtr loader_type)
 
bool activate_language (const std::string &language_code)
 
bool activate_language_from_arb_data (const uint8_t *data, std::size_t byte_size)
 
std::string active_language () const
 
unicode translated_text (const unicode &source_text)
 
void * platform_state ()
 
 S_DEFINE_PROPERTY (window, &Application::window_)
 
 S_DEFINE_PROPERTY (data, &Application::data_carrier_)
 
 S_DEFINE_PROPERTY (scenes, &Application::scene_manager_)
 
 S_DEFINE_PROPERTY (args, &Application::args_)
 
 S_DEFINE_PROPERTY (config, &Application::config_)
 
 S_DEFINE_PROPERTY (shared_assets, &Application::asset_manager_)
 
 S_DEFINE_PROPERTY (time_keeper, &Application::time_keeper_)
 
 S_DEFINE_PROPERTY (stats, &Application::stats_)
 
 S_DEFINE_PROPERTY (vfs, &Application::vfs_)
 
 S_DEFINE_PROPERTY (sound_driver, &Application::sound_driver_)
 
 S_DEFINE_PROPERTY (material_value_pool, &Application::pool_)
 
 S_DEFINE_PROPERTY (overlay, &Application::overlay_scene_)
 

Protected Member Functions

bool _call_init ()
 
virtual std::shared_ptr< Windowinstantiate_window ()
 

Friends

class Window
 
void cr_run_main (std::function< void()> func)
 
Applicationget_app ()
 

Member Function Documentation

◆ activate_language()

bool smlt::Application::activate_language ( const std::string &  language_code)

Activates a new language for UI widgets. This will search asset paths for an .arb file for the language using fallback logic (e.g. en-gb -> en). Codes are ISO 639-1 and should be lower-case. This function will return false if the .po file cannot be found or loaded.

◆ activate_language_from_arb_data()

bool smlt::Application::activate_language_from_arb_data ( const uint8_t *  data,
std::size_t  byte_size 
)

Activates a language from an ARB file that's already been loaded from disk. The language code is read from the ARB itself and no locale directories are searched.

◆ active_language()

std::string smlt::Application::active_language ( ) const
inline

Returns the currently active language

◆ is_shutting_down()

bool smlt::Application::is_shutting_down ( ) const

Returns true if the application is shutting down

◆ process_id()

ProcessID smlt::Application::process_id ( ) const

Returns the process ID for the application, or -1 if it's unavailable or unsupported

◆ ram_usage_in_bytes()

int64_t smlt::Application::ram_usage_in_bytes ( ) const

Returns an approximation of the ram usage of the current process. Returns -1 if an error occurs or not supported on the platform

◆ request_frame_time()

void smlt::Application::request_frame_time ( float  ms)

Request the target frame time - frames will delay to match it if the framerate would otherwise be too high

◆ run_fixed_updates()

void smlt::Application::run_fixed_updates ( )

Runs fixed_updates, you likely don't want to call this directly

◆ run_frame()

bool smlt::Application::run_frame ( )

Runs a single frame of the application. You likely don't want to call this!

◆ run_update()

void smlt::Application::run_update ( float  dt)

Runs the update and late_update methods on the active scene. You likely don't want to call this directly.

◆ S_DEFINE_PROPERTY()

smlt::Application::S_DEFINE_PROPERTY ( overlay  ,
&Application::overlay_scene_   
)

The overlay is a global scene that is always rendered with the highest priority over everything. It's used for adding things like FPS counters or performance graphs or persistent game version text etc.

◆ stop_running()

void smlt::Application::stop_running ( )

Stops the entire application

◆ thread_id()

thread::ThreadID smlt::Application::thread_id ( ) const

Returns the thread ID of the main process

◆ translated_text()

unicode smlt::Application::translated_text ( const unicode source_text)
inline

Returns the localised text for the active language. This will return source_text if no translation exists or the active language is the same as the default language in the AppConfig. This method is wrapped by the _T() helper macro and you should prefer to use that so that your translated strings can be detected by automated scanning.


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