#include <periapsis_app.hpp>
Definition at line 43 of file periapsis_app.hpp.
Public Member Functions | |
void | init () |
This function is called by the constructor. Do not call it yourself. | |
periapsis_app (const gsgl::string &title, const int &argc, const char **argv) | |
void | update () |
This function is called after every frame. Do not call it yourself. | |
~periapsis_app () | |
Virtual Functions | |
virtual void | cleanup () |
This function when the application ends. Do not call it yourself. | |
virtual bool | draw () |
This function is called for every frame. Do not call it yourself. If it returns false and the sim pointer is valid, the sim's draw function is called. | |
virtual bool | handle_event (const SDL_Event &e) |
Handles SDL events. | |
Accessors | |
platform::display * | get_console () |
widget * | get_focus_widget () |
Return the widget with the current keyboard focus. | |
platform::budget * | get_global_budget () |
scenegraph::node * | get_global_scenery () |
void | get_mousedown_info (int &button, int &x, int &y) |
scenegraph::simulation * | get_simulation () |
string & | get_title () |
data::simple_stack< widget * > & | get_widgets () |
Game Lifecycle Functions | |
const gsgl::data::list < package * > & | get_loaded_packages () const |
void | load_and_run_simulation (const string &fname, gsgl::scenegraph::context *c) |
Loads and runs a simulation. This will set the top widget to be invisible. | |
void | load_package (const string &fname) |
Load a game package containing specifications for shared libraries, scenery, and vehicles. | |
void | load_scenery (platform::synchronized< string > &status_string) |
void | quit_application () |
Quits the application. Unloads and quits any simulation loaded. | |
void | run () |
void | unload_and_quit_simulation () |
Unloads and quits a simulation. This will set the top widget to be visible, so make sure that any extra widgets have been popped off the stack. | |
void | unload_scenery () |
Static Public Member Functions | |
static T * | global_instance () |
Static Public Attributes | |
System Configuration Variables | |
static data::config_variable < gsgl::string > | EVENT_MAP_PATH |
The program's event map. | |
static data::config_variable < gsgl::string > | PROGRAM_PATH |
The path that the program is running in. | |
static data::config_variable < gsgl::string > | SYS_DATA_PATH |
The directory of the system data. | |
static data::config_variable < gsgl::string > | USER_CONFIG_PATH |
The program's user config file. | |
static data::config_variable < gsgl::string > | USER_DATA_PATH |
The user's data directory. | |
Protected Types | |
enum | app_state { APP_NO_STATE = 0, APP_INITIALIZING, APP_UI_RUNNING, APP_SIM_LOADING, APP_SIM_RUNNING, APP_QUITTING, APP_DEAD } |
Protected Attributes | |
widget * | focus_widget |
platform::budget * | global_budget |
platform::display * | global_console |
scenegraph::context * | global_context |
scenegraph::event_map * | global_mapper |
scenegraph::node * | global_scenery |
scenegraph::simulation * | global_simulation |
data::list< package * > | loaded_packages |
platform::texture * | splash_screen |
app_state | state |
gsgl::string | title |
data::simple_stack< widget * > | widgets |
enum app_state [protected, inherited] |
APP_NO_STATE | |
APP_INITIALIZING | |
APP_UI_RUNNING | |
APP_SIM_LOADING | |
APP_SIM_RUNNING | |
APP_QUITTING | |
APP_DEAD |
Definition at line 90 of file application.hpp.
periapsis_app | ( | const gsgl::string & | title, | |
const int & | argc, | |||
const char ** | argv | |||
) |
Definition at line 55 of file periapsis_app.cpp.
~periapsis_app | ( | ) |
Definition at line 61 of file periapsis_app.cpp.
void cleanup | ( | ) | [virtual, inherited] |
This function when the application ends. Do not call it yourself.
Implement this if cleanup is needed after the main loop terminates.
Definition at line 613 of file application.cpp.
Referenced by application::quit_application().
bool draw | ( | ) | [virtual, inherited] |
This function is called for every frame. Do not call it yourself. If it returns false and the sim pointer is valid, the sim's draw function is called.
Implement this to draw the simulation in a custom manner.
If this is not implemented or returns false, the sim will be updated and drawn automatically.
Definition at line 601 of file application.cpp.
Referenced by application::run().
platform::display* get_console | ( | ) | [inline, inherited] |
widget* get_focus_widget | ( | ) | [inline, inherited] |
platform::budget* get_global_budget | ( | ) | [inline, inherited] |
Definition at line 147 of file application.hpp.
scenegraph::node* get_global_scenery | ( | ) | [inline, inherited] |
Definition at line 144 of file application.hpp.
const gsgl::data::list<package *>& get_loaded_packages | ( | ) | const [inline, inherited] |
Definition at line 160 of file application.hpp.
void get_mousedown_info | ( | int & | button, | |
int & | x, | |||
int & | y | |||
) | [inherited] |
Definition at line 945 of file application.cpp.
References application::mouse_button_pressed, application::mouse_button_x, and application::mouse_button_y.
scenegraph::simulation* get_simulation | ( | ) | [inline, inherited] |
Definition at line 146 of file application.hpp.
string& get_title | ( | ) | [inline, inherited] |
data::simple_stack<widget *>& get_widgets | ( | ) | [inline, inherited] |
Definition at line 149 of file application.hpp.
static T* global_instance | ( | ) | [inline, static, inherited] |
Reimplemented in broker, global_register, logger, global_register< gsgl::data::broker_creator, gsgl::data::dictionary< gsgl::data::broker_creator *, gsgl::string > >, global_register< gsgl::data::log_target, gsgl::data::list< gsgl::data::log_target * > >, and global_register< gsgl::data::log_target >.
Definition at line 70 of file singleton.hpp.
Referenced by widget::button_down_here(), font::font(), tabbox::handle_event(), material::material(), model_part::model_part(), and texture::texture().
bool handle_event | ( | const SDL_Event & | e | ) | [virtual, inherited] |
Handles SDL events.
Implement this to handle SDL events other than through the default scene graph event handler.
Does not normally need to be reimplemented, as UI elements and scenegraph events will propagate by default.
If it returns true, the scene graph event handler will NOT be called. If it returns false, and the current simulation pointer is valid, then the event mapper will be called with the simulation's set event targets.
Definition at line 587 of file application.cpp.
Referenced by application::run().
void init | ( | ) | [virtual] |
This function is called by the constructor. Do not call it yourself.
Implement this if initialization is needed prior to the main loop.
Reimplemented from application.
Definition at line 67 of file periapsis_app.cpp.
References application::get_console(), display::get_height(), application::get_title(), display::get_width(), main_window::HEIGHT, application::widgets, and main_window::WIDTH.
void load_and_run_simulation | ( | const string & | fname, | |
gsgl::scenegraph::context * | c | |||
) | [inherited] |
Loads and runs a simulation. This will set the top widget to be invisible.
Definition at line 216 of file application.cpp.
References application::APP_SIM_LOADING, application::APP_SIM_RUNNING, assert, application::global_console, application::global_context, application::global_scenery, application::global_simulation, simulation::init(), gsgl::log(), application::state, application::unload_and_quit_simulation(), widget::WIDGET_INVISIBLE, and application::widgets.
void load_package | ( | const string & | fname | ) | [inherited] |
Load a game package containing specifications for shared libraries, scenery, and vehicles.
Definition at line 204 of file application.cpp.
References application::loaded_packages, and string::w_string().
Referenced by application::application().
void load_scenery | ( | platform::synchronized< string > & | status_string | ) | [inherited] |
Definition at line 792 of file application.cpp.
References node::add_child(), list::append(), list::clear(), node::get_children(), config_record::get_children(), config_record::get_name(), application::global_scenery, countable::is_empty(), iterable::iter(), application::load_objects(), application::loaded_packages, list::size(), and string::w_string().
void quit_application | ( | ) | [inherited] |
Quits the application. Unloads and quits any simulation loaded.
This contains the main event loop of the application. It clears the screen, calls draw(), draws UI elements, and flips the buffers.
Definition at line 276 of file application.cpp.
References application::APP_QUITTING, application::cleanup(), application::global_simulation, application::state, and application::unload_and_quit_simulation().
Referenced by application::run().
void run | ( | ) | [inherited] |
Definition at line 286 of file application.cpp.
References application::APP_DEAD, application::APP_INITIALIZING, application::APP_NO_STATE, application::APP_QUITTING, application::APP_SIM_RUNNING, application::APP_UI_RUNNING, CHECK_GL_ERRORS, simulation::draw(), application::draw(), application::draw_budget(), application::draw_splash_screen(), application::draw_ui(), simulation::get_context(), display::get_height(), display::get_width(), application::global_budget, application::global_console, application::global_mapper, application::global_simulation, event_map::handle_event(), application::handle_event(), application::handle_ui_event(), application::init(), simulation::is_running(), simulation::pre_draw(), application::quit_application(), context::render_flags, context::RENDER_UNLIT, context::RENDER_UNTEXTURED, context::RENDER_WIREFRAME, budget::reset(), application::splash_screen, application::state, application::unload_and_quit_simulation(), application::update(), simulation::update(), widget::WIDGET_INVISIBLE, and application::widgets.
Referenced by SDL_main().
void unload_and_quit_simulation | ( | ) | [inherited] |
Unloads and quits a simulation. This will set the top widget to be visible, so make sure that any extra widgets have been popped off the stack.
Definition at line 241 of file application.cpp.
References application::APP_UI_RUNNING, simulation::cleanup(), application::global_context, application::global_scenery, application::global_simulation, gsgl::log(), application::remove_viewpoint_nodes(), application::state, widget::WIDGET_INVISIBLE, and application::widgets.
Referenced by application::load_and_run_simulation(), application::quit_application(), and application::run().
void unload_scenery | ( | ) | [inherited] |
void update | ( | ) | [virtual] |
This function is called after every frame. Do not call it yourself.
Reimplemented from application.
Definition at line 79 of file periapsis_app.cpp.
config_variable< string > EVENT_MAP_PATH [static, inherited] |
The program's event map.
Definition at line 134 of file application.hpp.
Referenced by application::application(), and application::get_config_overrides().
widget* focus_widget [protected, inherited] |
platform::budget* global_budget [protected, inherited] |
Definition at line 121 of file application.hpp.
Referenced by application::application(), application::draw_budget(), application::run(), and application::~application().
platform::display* global_console [protected, inherited] |
Definition at line 118 of file application.hpp.
Referenced by application::application(), application::draw_budget(), application::draw_splash_screen(), application::handle_ui_event(), application::load_and_run_simulation(), application::run(), and application::~application().
scenegraph::context* global_context [protected, inherited] |
Definition at line 114 of file application.hpp.
Referenced by application::load_and_run_simulation(), application::unload_and_quit_simulation(), and application::~application().
scenegraph::event_map* global_mapper [protected, inherited] |
Definition at line 119 of file application.hpp.
Referenced by application::application(), application::run(), and application::~application().
scenegraph::node* global_scenery [protected, inherited] |
Definition at line 115 of file application.hpp.
Referenced by application::load_and_run_simulation(), application::load_scenery(), application::unload_and_quit_simulation(), application::unload_scenery(), and application::~application().
scenegraph::simulation* global_simulation [protected, inherited] |
Definition at line 116 of file application.hpp.
Referenced by application::load_and_run_simulation(), application::quit_application(), application::run(), application::unload_and_quit_simulation(), and application::~application().
data::list<package *> loaded_packages [protected, inherited] |
Definition at line 106 of file application.hpp.
Referenced by application::load_package(), and application::load_scenery().
config_variable< string > PROGRAM_PATH [static, inherited] |
The path that the program is running in.
Definition at line 131 of file application.hpp.
Referenced by package::package().
platform::texture* splash_screen [protected, inherited] |
Definition at line 107 of file application.hpp.
Referenced by application::application(), application::draw_splash_screen(), application::run(), and application::~application().
Definition at line 101 of file application.hpp.
Referenced by application::load_and_run_simulation(), application::quit_application(), application::run(), and application::unload_and_quit_simulation().
config_variable< string > SYS_DATA_PATH [static, inherited] |
The directory of the system data.
Definition at line 132 of file application.hpp.
Referenced by application::application(), application::get_config_overrides(), lithosphere_quadtree::lithosphere_quadtree(), and stellar_db::stellar_db().
gsgl::string title [protected, inherited] |
Definition at line 103 of file application.hpp.
Referenced by application::get_config_overrides(), and application::get_user_dir().
config_variable< string > USER_CONFIG_PATH [static, inherited] |
The program's user config file.
Definition at line 135 of file application.hpp.
Referenced by application::get_config_overrides().
config_variable< string > USER_DATA_PATH [static, inherited] |
The user's data directory.
Definition at line 133 of file application.hpp.
Referenced by application::get_config_overrides().
data::simple_stack<widget *> widgets [protected, inherited] |
Definition at line 110 of file application.hpp.
Referenced by periapsis_app::init(), application::load_and_run_simulation(), application::run(), application::unload_and_quit_simulation(), and application::~application().