Scene Lab
An open source project by FPL.
 All Classes Namespaces Files Functions Pages
scene_lab::SceneLab Class Reference

Public Member Functions

void Initialize (const SceneLabConfig *config, fplbase::AssetManager *asset_manager, fplbase::InputSystem *input, fplbase::Renderer *renderer, flatui::FontManager *font_manager)
 Initialize Scene Lab once, when starting your game. More...
 
void SetEntitySystemAdapter (std::unique_ptr< EntitySystemAdapter > adapter)
 Set which entity system adapter to use.
 
EntitySystemAdapter * entity_system_adapter () const
 Accessor for entity system adapter, don't hold onto this pointer.
 
void AdvanceFrame (double delta_time_seconds)
 While Scene Lab is active, you must call this once a frame, every frame.
 
void Render (fplbase::Renderer *renderer)
 Render Scene Lab and its GUI; only call this when Scene Lab is active. More...
 
void Activate ()
 Activate Scene Lab. More...
 
void Deactivate ()
 Immediately deactivate Scene Lab. More...
 
void SetInitialCamera (const GenericCamera &initial_camera)
 When you activate the editor, you can pass in your game's camera so the user can seamlessly be positioned at the same place they were during the game. More...
 
void GetCamera (GenericCamera *camera)
 Get the Scene Lab camera, so you can render the scene properly or change its position. More...
 
void SelectEntity (const GenericEntityId &entity)
 Highlight the specified entity, so that you can change its properties.
 
void MoveEntityToCamera (const GenericEntityId &entity)
 Move the specified entity to directly in front of the camera.
 
bool SaveScene (bool to_disk)
 Save the current positions and properties of all entities. More...
 
void SaveScene ()
 Save the current positions and properties to disk. More...
 
void RequestExit ()
 Request that Scene Lab exit. More...
 
void AbortExit ()
 Abort a previously-requested exit, which hides the confirmation dialog.
 
bool IsReadyToExit ()
 Returns true if we are ready to exit Scene Lab (everything is saved or discarded, etc), or false if not. More...
 
void set_entities_modified (bool b)
 Externally mark that some entities have been modified. More...
 
bool entities_modified () const
 Have entities been modified? If so, prompt the user to save before exit.
 
void AddOnEnterEditorCallback (EditorCallback callback)
 Specify a callback to call when the editor is opened.
 
void AddOnExitEditorCallback (EditorCallback callback)
 Specify a callback to call when the editor is exited.
 
void AddOnCreateEntityCallback (EntityCallback callback)
 Specify a callback to call when an entity is created.
 
void AddOnUpdateEntityCallback (EntityCallback callback)
 Specify a callback to call when an entity's data is updated.
 
void AddOnDeleteEntityCallback (EntityCallback callback)
 Specify a callback to call when an entity is deleted.
 
void NotifyEnterEditor () const
 Call all 'EditorEnter' callbacks.
 
void NotifyExitEditor () const
 Call all 'EditorExit' callbacks.
 
void NotifyCreateEntity (const GenericEntityId &entity) const
 Call all 'EntityCreated' callbacks.
 
void NotifyUpdateEntity (const GenericEntityId &entity) const
 Call all 'EntityUpdated' callbacks.
 
void NotifyDeleteEntity (const GenericEntityId &entity) const
 Call all 'EntityDeleted' callbacks.
 
const std::string & version ()
 
const SceneLabConfig * config ()
 Config accessor, so you can access config options.
 
EditorGuigui ()
 GUI accessor, so you can poke into the EditorGui.
 

Protected Attributes

std::string version_
 

Member Function Documentation

void scene_lab::SceneLab::Activate ( )

Activate Scene Lab.

Once you call this, you should start calling AdvanceFrame and Render each frame, and stop calling EntityManager::UpdateComponents() yourself.

void scene_lab::SceneLab::Deactivate ( )

Immediately deactivate Scene Lab.

The preferred way to exit the editor is to use RequestExit, however, as that will give the user a chance to save their changes to the world.

void scene_lab::SceneLab::GetCamera ( GenericCamera *  camera)

Get the Scene Lab camera, so you can render the scene properly or change its position.

void scene_lab::SceneLab::Initialize ( const SceneLabConfig *  config,
fplbase::AssetManager *  asset_manager,
fplbase::InputSystem *  input,
fplbase::Renderer *  renderer,
flatui::FontManager *  font_manager 
)

Initialize Scene Lab once, when starting your game.

Call this function as soon as you have an entity manager and font manager. Consider giving Scene Lab a camera via SetCamera() as well.

bool scene_lab::SceneLab::IsReadyToExit ( )

Returns true if we are ready to exit Scene Lab (everything is saved or discarded, etc), or false if not.

Once it returns true, you can safely deactivate the editor.

void scene_lab::SceneLab::Render ( fplbase::Renderer *  renderer)

Render Scene Lab and its GUI; only call this when Scene Lab is active.

While Scene Lab is running, you are still responsible for rendering your own game world. Call GetCamera() to get the camera you should use for rendering.

Warning: if you are actively using FlatUI elsewhere in your code while Scene Lab is running, you will need to modify this function to not render the GUI here, and call EditorGui::StartRender(), EditorGui::DrawGui(), and EditorGui::FinishRender() yourself.

void scene_lab::SceneLab::RequestExit ( )

Request that Scene Lab exit.

If you haven't saved your changes, it will prompt you to do so, keep them in memory, or abandon them. Once Scene Lab decides it's okay to exit, IsReadyToExit() will return true.

After you've exited, you can always get back into Scene Lab by calling Activate() again.

bool scene_lab::SceneLab::SaveScene ( bool  to_disk)

Save the current positions and properties of all entities.

Returns true if successful or false if it failed.

If to_disk is true, save to .bin and .json files and update the entity factory's file cache. Otherwise, just update the file cache but don't physically save the files to disk.

If you are saving to disk, entities will be saved to the files they were initially loaded from.

void scene_lab::SceneLab::SaveScene ( )
inline

Save the current positions and properties to disk.

See SaveScene(bool to_disk) for more details.

void scene_lab::SceneLab::set_entities_modified ( bool  b)
inline

Externally mark that some entities have been modified.

Generally used by Scene Lab's GUI, but if you change an entity's properties some other way, call this function to ensure the user will be prompted to save on exiting the editor.

void scene_lab::SceneLab::SetInitialCamera ( const GenericCamera &  initial_camera)

When you activate the editor, you can pass in your game's camera so the user can seamlessly be positioned at the same place they were during the game.

Call this function before Activate().


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