VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtPlayerCreationPalette Class Reference

Detailed Description

DtPlayerCreationPalette serves as a catalog of all entities and roles that can be played in VR-Engage. It loads entity definitions from simulation model sets (SMS) files and provides methods for accessing role configurations, display layouts, and other metadata necessary for creating player stations.

This class maintains its own thread-safe access to role definition files and provides asynchronous loading capabilities for better performance.

#include <playerCreationPalette.h>

Classes

struct  DtPaletteEntry
 

Public Types

using DtEntityMap = std::map<DtEntityType, std::shared_ptr<DtPaletteEntry>>
 
using DtIterator = DtEntityMap::iterator
 

Public Member Functions

 DtPlayerCreationPalette (DtPlayerStationApp *app)
 
virtual ~DtPlayerCreationPalette ()
 
virtual void tick ()
 
virtual void setSmsList (const std::vector< DtFilename > &smsList)
 
virtual DtIterator getIterator ()
 
virtual bool getNext (DtIterator &iter, DtEntityType *nextType=NULL, std::shared_ptr< DtPaletteEntry > *nextEntry=NULL)
 
std::shared_ptr< DtPaletteEntryfindEntry (const DtEntityType &type)
 
virtual bool isValid (const DtEntityType &type, const std::string &role="", const std::string &display="")
 
virtual const std::vector< std::string > getRoleList (const DtEntityType &type)
 
virtual std::string findRoleForSlot (const DtEntityType &type, const std::string &slotName)
 
virtual std::string findSlotForRole (const DtEntityType &type, const std::string &roleName)
 
virtual std::shared_ptr< DtEntityRoleDescriptorgetRoleDescriptor (const DtEntityType &type, const std::string &role)
 
virtual DtInitTable getRoleTemplate (const DtEntityType &type, const std::string &role)
 
virtual DtInitTable getPlayerConfiguration (const DtEntityType &type, const std::string &role, const std::string &display)
 
virtual const std::set< std::string > & categories () const
 
virtual const std::set< std::string > & countries () const
 
virtual void reloadRoleConfig (const DtEntityType &entityType)
 
virtual const std::vector< DtFilename > & getSMSList () const
 
virtual DtFilename findFile (const std::string &file)
 
virtual DtInitializerinitializer ()
 

Protected Member Functions

virtual void buildFromSMSAsync ()
 
virtual bool buildFromSMS (DtPlayerStationApp *, const std::vector< DtFilename > &smsList)
 
void setDataPathsForSms (std::vector< std::string > paths)
 
void appendDataPathsForSms (std::string path)
 
void clearDataPathsForSms ()
 
virtual void getSMSList (std::vector< DtString > &smsList) const
 
virtual void getSMSSearchPaths (std::vector< DtFilename > &searchPaths) const
 
virtual std::shared_ptr< makVre::DtVreModelSetEntryloadModelSetEntry (const std::string &filename)
 
std::shared_ptr< DtEntityRoleDescriptorfindRole (const DtPaletteEntry &entry, const std::string &role)
 
std::shared_ptr< DtEntityRoleDescriptorfindRole (const DtPaletteEntry &entry)
 

Static Protected Member Functions

static int getDataPathsForSms (lua_State *L)
 

Protected Attributes

DtEntityMap myCreationPaletteMap
 
std::shared_ptr< DtPaletteEntrymyDefaultPaletteEntry
 
std::set< std::string > myAllCategories
 
std::set< std::string > myAllCountries
 
DtPlayerStationAppmyApp
 
DtInitializermyInitializer
 
std::vector< DtFilename > mySmsList
 
std::vector< DtFilename > myIncomingSmsList
 
tbb::mutex myBuildMutex
 
bool myAsyncBuilding
 
std::unique_ptr< SmsLoadCompleteMessagemySmsLoadCompleteMessage
 
tbb::task_arena myArena
 

Static Protected Attributes

static std::vector< std::string > theSmsRoleSearchPaths
 

Member Typedef Documentation

◆ DtEntityMap

using makVre::DtPlayerCreationPalette::DtEntityMap = std::map<DtEntityType, std::shared_ptr<DtPaletteEntry>>

Type definition for a map of entity types to palette entries.

◆ DtIterator

using makVre::DtPlayerCreationPalette::DtIterator = DtEntityMap::iterator

Type definition for an iterator over the entity map.

Constructor & Destructor Documentation

◆ DtPlayerCreationPalette()

makVre::DtPlayerCreationPalette::DtPlayerCreationPalette ( DtPlayerStationApp * app)

Constructor.

Parameters
appPointer to the player station application

Creates a new palette instance associated with the application. Initializes the palette but does not load entity data automatically.

◆ ~DtPlayerCreationPalette()

virtual makVre::DtPlayerCreationPalette::~DtPlayerCreationPalette ( )
virtual

Virtual destructor.

Cleans up resources, including the initializer and any loaded entity data.

Member Function Documentation

◆ tick()

virtual void makVre::DtPlayerCreationPalette::tick ( )
virtual

Updates the palette state.

Called once per frame to update the palette, handling any asynchronous loading operations and processing completed loads.

◆ setSmsList()

virtual void makVre::DtPlayerCreationPalette::setSmsList ( const std::vector< DtFilename > & smsList)
virtual

Sets the list of simulation model sets (SMS) to load.

Parameters
smsListVector of SMS filenames to load

Updates the list of simulation model sets from which to load entity definitions. This will trigger an asynchronous reload of the palette.

◆ getIterator()

virtual DtIterator makVre::DtPlayerCreationPalette::getIterator ( )
virtual

Gets an iterator to the beginning of the entity map.

Returns
Iterator positioned at the start of the entity map

Returns an iterator for traversing all entities in the palette.

◆ getNext()

virtual bool makVre::DtPlayerCreationPalette::getNext ( DtIterator & iter,
DtEntityType * nextType = NULL,
std::shared_ptr< DtPaletteEntry > * nextEntry = NULL )
virtual

Advances to the next entity in the palette.

Parameters
iterIterator to advance
nextTypeOptional pointer to receive the next entity type
nextEntryOptional pointer to receive the next palette entry
Returns
True if advanced successfully, false if reached the end

Advances the iterator to the next entity and optionally retrieves the type and entry information for that entity.

◆ findEntry()

std::shared_ptr< DtPaletteEntry > makVre::DtPlayerCreationPalette::findEntry ( const DtEntityType & type)

Finds an entity by its type.

Parameters
typeEntity type to search for
Returns
Shared pointer to the palette entry, or null if not found

Looks up an entity in the palette by its entity type identifier.

◆ isValid()

virtual bool makVre::DtPlayerCreationPalette::isValid ( const DtEntityType & type,
const std::string & role = "",
const std::string & display = "" )
virtual

Checks if an entity type, role, and display layout combination is valid.

Parameters
typeEntity type to check
roleOptional role name to check (empty to check only entity type)
displayOptional display layout to check (empty to check only entity and role)
Returns
True if the combination is valid, false otherwise

Verifies whether a specific entity type exists in the palette and optionally whether it supports the specified role and display layout.

◆ getRoleList()

virtual const std::vector< std::string > makVre::DtPlayerCreationPalette::getRoleList ( const DtEntityType & type)
virtual

Gets the list of available roles for an entity type.

Parameters
typeEntity type to get roles for
Returns
Vector of role names available for the entity

Returns a list of all roles that can be played for the specified entity type.

◆ findRoleForSlot()

virtual std::string makVre::DtPlayerCreationPalette::findRoleForSlot ( const DtEntityType & type,
const std::string & slotName )
virtual

Finds a role that corresponds to a slot name.

Parameters
typeEntity type to search in
slotNameName of the slot to find the role for
Returns
Role name that corresponds to the slot, or empty string if not found

Maps from a slot name (used in embarkation) to the corresponding role name.

◆ findSlotForRole()

virtual std::string makVre::DtPlayerCreationPalette::findSlotForRole ( const DtEntityType & type,
const std::string & roleName )
virtual

Finds a slot that corresponds to a role name.

Parameters
typeEntity type to search in
roleNameName of the role to find the slot for
Returns
Slot name that corresponds to the role, or empty string if not found

Maps from a role name to the corresponding slot name (used in embarkation).

◆ getRoleDescriptor()

virtual std::shared_ptr< DtEntityRoleDescriptor > makVre::DtPlayerCreationPalette::getRoleDescriptor ( const DtEntityType & type,
const std::string & role )
virtual

Gets the descriptor for a specific role.

Parameters
typeEntity type to look up
roleRole name to get the descriptor for
Returns
Shared pointer to the role descriptor, or null if not found

Returns detailed information about a specific role, including file paths, display layouts, and other configuration metadata.

◆ getRoleTemplate()

virtual DtInitTable makVre::DtPlayerCreationPalette::getRoleTemplate ( const DtEntityType & type,
const std::string & role )
virtual

Gets the base template for a role.

Parameters
typeEntity type to look up
roleRole name to get the template for
Returns
Initialization table containing the role template

Returns the base template configuration for a role before any display-specific settings are applied.

◆ getPlayerConfiguration()

virtual DtInitTable makVre::DtPlayerCreationPalette::getPlayerConfiguration ( const DtEntityType & type,
const std::string & role,
const std::string & display )
virtual

Gets the complete configuration for a player station.

Parameters
typeEntity type to configure
roleRole name to configure
displayDisplay layout to use
Returns
Initialization table with the complete player configuration

Returns the complete configuration for a player station, combining the role template with display-specific settings and other overrides.

◆ categories()

virtual const std::set< std::string > & makVre::DtPlayerCreationPalette::categories ( ) const
inlinevirtual

Gets all categories in the palette.

Returns
Reference to the set of all categories

Returns a set of all unique categories across all entities in the palette. Categories are used for filtering and organizing entities in the UI.

References myAllCategories.

◆ countries()

virtual const std::set< std::string > & makVre::DtPlayerCreationPalette::countries ( ) const
inlinevirtual

Gets all countries in the palette.

Returns
Reference to the set of all countries

Returns a set of all unique countries across all entities in the palette. Countries are used for filtering and organizing entities in the UI.

References myAllCountries.

◆ reloadRoleConfig()

virtual void makVre::DtPlayerCreationPalette::reloadRoleConfig ( const DtEntityType & entityType)
virtual

Reloads the role configuration for an entity type.

Parameters
entityTypeEntity type to reload

Reloads the role configuration data found in the .entity file for a specific entity type. This is used for hot-reloading when entity files are modified.

◆ getSMSList() [1/2]

virtual const std::vector< DtFilename > & makVre::DtPlayerCreationPalette::getSMSList ( ) const
virtual

Gets the current list of simulation model sets.

Returns
Reference to the vector of SMS filenames

Returns the list of simulation model set (SMS) files that are currently being used to populate the palette.

◆ findFile()

virtual DtFilename makVre::DtPlayerCreationPalette::findFile ( const std::string & file)
virtual

Finds a file in the SMS directories.

Parameters
fileName of the file to find
Returns
Full path to the file, or empty if not found

Searches for a file in all SMS directories and returns its full path. This is used to locate role definition files, entity files, and other resources.

◆ initializer()

virtual DtInitializer * makVre::DtPlayerCreationPalette::initializer ( )
virtual

Gets the palette's initializer.

Returns
Pointer to the initializer

Returns a pointer to the DtInitializer owned by this class, which is used for interfacing with Lua role definitions. This initializer can be accessed from both the player creation palette and the choose role panel.

◆ buildFromSMSAsync()

virtual void makVre::DtPlayerCreationPalette::buildFromSMSAsync ( )
protectedvirtual

Initiates asynchronous building of the palette from SMS files.

Starts an asynchronous task to rebuild the palette from the current set of SMS files. This is used to avoid blocking the main thread during palette loading.

◆ buildFromSMS()

virtual bool makVre::DtPlayerCreationPalette::buildFromSMS ( DtPlayerStationApp * ,
const std::vector< DtFilename > & smsList )
protectedvirtual

Builds the palette from SMS files.

Parameters
appPointer to the player station application
smsListList of SMS files to load from
Returns
True if building was successful, false otherwise

Loads all entity definitions from the specified SMS files and populates the palette with the resulting entities and roles.

◆ getDataPathsForSms()

static int makVre::DtPlayerCreationPalette::getDataPathsForSms ( lua_State * L)
staticprotected

Lua callback to get data paths for SMS.

Parameters
LLua state pointer
Returns
Number of return values on the Lua stack

Callback function for Lua to retrieve the SMS data paths.

◆ setDataPathsForSms()

void makVre::DtPlayerCreationPalette::setDataPathsForSms ( std::vector< std::string > paths)
protected

Sets the data paths for SMS.

Parameters
pathsVector of path strings to set

Sets the list of data paths used for locating SMS resources.

◆ appendDataPathsForSms()

void makVre::DtPlayerCreationPalette::appendDataPathsForSms ( std::string path)
protected

Adds a data path for SMS.

Parameters
pathPath string to add

Appends a new data path to the list of SMS resource locations.

◆ clearDataPathsForSms()

void makVre::DtPlayerCreationPalette::clearDataPathsForSms ( )
protected

Removes all SMS data paths.

Clears the list of data paths used for locating SMS resources.

◆ getSMSList() [2/2]

virtual void makVre::DtPlayerCreationPalette::getSMSList ( std::vector< DtString > & smsList) const
protectedvirtual

Gets the list of SMS files to search.

Parameters
smsListVector to populate with SMS file names

Populates the provided vector with the list of SMS files to search when loading an entity file. Returns the contents of mySmsList if specified, or the app's default SMS list otherwise.

◆ getSMSSearchPaths()

virtual void makVre::DtPlayerCreationPalette::getSMSSearchPaths ( std::vector< DtFilename > & searchPaths) const
protectedvirtual

Gets the search paths for model set entries.

Parameters
searchPathsVector to populate with search paths

Populates the provided vector with the list of SMS paths (including inherited ones) to search when loading a model set entry.

◆ loadModelSetEntry()

virtual std::shared_ptr< makVre::DtVreModelSetEntry > makVre::DtPlayerCreationPalette::loadModelSetEntry ( const std::string & filename)
protectedvirtual

Loads a model set entry.

Parameters
filenameName of the file to load
Returns
Shared pointer to the loaded model set entry

Loads and parses a model set entry from the specified filename.

◆ findRole() [1/2]

std::shared_ptr< DtEntityRoleDescriptor > makVre::DtPlayerCreationPalette::findRole ( const DtPaletteEntry & entry,
const std::string & role )
protected

Finds a role in a palette entry by name.

Parameters
entryPalette entry to search in
roleName of the role to find
Returns
Shared pointer to the role descriptor, or null if not found

Searches for a specific role within a palette entry by name.

◆ findRole() [2/2]

std::shared_ptr< DtEntityRoleDescriptor > makVre::DtPlayerCreationPalette::findRole ( const DtPaletteEntry & entry)
protected

Finds any role in a palette entry.

Parameters
entryPalette entry to search in
Returns
Shared pointer to the first role descriptor, or null if none exist

Returns the first available role within a palette entry.

Member Data Documentation

◆ theSmsRoleSearchPaths

std::vector<std::string> makVre::DtPlayerCreationPalette::theSmsRoleSearchPaths
staticprotected

Static instance of SMS role search paths (for Lua access)

◆ myCreationPaletteMap

DtEntityMap makVre::DtPlayerCreationPalette::myCreationPaletteMap
protected

Map of entity types to palette entries.

◆ myDefaultPaletteEntry

std::shared_ptr<DtPaletteEntry> makVre::DtPlayerCreationPalette::myDefaultPaletteEntry
protected

Default palette entry (used when a specific entry is not found)

◆ myAllCategories

std::set<std::string> makVre::DtPlayerCreationPalette::myAllCategories
protected

Set of all unique categories across all entities.

Referenced by categories().

◆ myAllCountries

std::set<std::string> makVre::DtPlayerCreationPalette::myAllCountries
protected

Set of all unique countries across all entities.

Referenced by countries().

◆ myApp

DtPlayerStationApp* makVre::DtPlayerCreationPalette::myApp
protected

Pointer to the player station application.

◆ myInitializer

DtInitializer* makVre::DtPlayerCreationPalette::myInitializer
protected

Initializer for Lua role definitions.

◆ mySmsList

std::vector<DtFilename> makVre::DtPlayerCreationPalette::mySmsList
protected

Current list of SMS files to load from.

◆ myIncomingSmsList

std::vector<DtFilename> makVre::DtPlayerCreationPalette::myIncomingSmsList
protected

Incoming list of SMS files for the next rebuild.

◆ myBuildMutex

tbb::mutex makVre::DtPlayerCreationPalette::myBuildMutex
protected

Mutex for synchronizing build operations.

◆ myAsyncBuilding

bool makVre::DtPlayerCreationPalette::myAsyncBuilding
protected

Flag indicating whether an asynchronous build is in progress.

◆ mySmsLoadCompleteMessage

std::unique_ptr<SmsLoadCompleteMessage> makVre::DtPlayerCreationPalette::mySmsLoadCompleteMessage
protected

Message to send when SMS loading completes.

◆ myArena

tbb::task_arena makVre::DtPlayerCreationPalette::myArena
protected

Task arena for asynchronous operations.


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