6#include <unordered_set>
8#include <unordered_map>
87 static std::shared_ptr<Context>
89 const std::vector<std::string>& archivePaths = {},
90 const std::unordered_set<uint32_t>& validHashes = {}, uint32_t reservedThreadCount = 1,
91 AudioSettings audioSettings = {}, std::shared_ptr<Component> window =
nullptr,
92 std::shared_ptr<Component> controlDeck =
nullptr);
99 static std::shared_ptr<Context>
CreateInstance(
const std::string& name,
const std::string& shortName);
114 static std::shared_ptr<Context>
CreateInstance(
const std::string& name,
const std::string& shortName,
115 std::vector<std::shared_ptr<Component>> components);
154 Context(std::string name, std::string shortName);
190 std::string mShortName;
191 std::chrono::steady_clock::time_point mInitTime{};
192 double mElapsedTimeSeconds = 0.0;
195#ifdef COMPONENT_THREAD_SAFE
196 mutable std::mutex mTickableMutex;
int32_t EventID
Numeric identifier for an event. -1 is uninitialized, IDs < -1 are internally registered,...
Definition EventTypes.h:8
A named Part with a parent/child hierarchy and optional thread safety.
Definition Component.h:34
Central singleton context for the libultraship engine.
Definition Context.h:63
static std::shared_ptr< Context > CreateDefaultInstance(const std::string &name, const std::string &shortName, const std::string &configFilePath, const std::vector< std::string > &archivePaths={}, const std::unordered_set< uint32_t > &validHashes={}, uint32_t reservedThreadCount=1, AudioSettings audioSettings={}, std::shared_ptr< Component > window=nullptr, std::shared_ptr< Component > controlDeck=nullptr)
Creates and stores the global Context instance with the default set of components.
static std::shared_ptr< Context > CreateInstance(const std::string &name, const std::string &shortName, std::vector< std::shared_ptr< Component > > components)
Creates and stores the global Context instance with the given set of components.
static std::string GetPathRelativeToAppBundle(const std::string &path)
Resolves a path relative to the application bundle directory.
void Tick()
Runs the default frame sequence: Update, LateUpdate, then Draw.
static std::shared_ptr< Context > CreateInstance(const std::string &name, const std::string &shortName)
Creates and stores the global Context instance without adding any default components.
Context(std::string name, std::string shortName)
Constructs a Context with the given identifiers but does not initialize subsystems.
const TickableList & GetTickableComponents() const
const std::string & GetShortName() const
Returns the short application identifier.
double GetElapsedTimeSeconds() const
Returns elapsed time in seconds since this Context was initialized.
static std::string LocateFileAcrossAppDirs(const std::string &path, const std::string &appName="")
Searches common application directories for a file and returns its absolute path.
static std::string GetAppBundlePath()
Returns the platform-specific application bundle directory (e.g. the .app bundle on macOS).
static std::string GetAppDirectoryPath(const std::string &appName="")
Returns the platform-specific directory where the application stores its data.
static std::string GetPathRelativeToAppDirectory(const std::string &path, const std::string &appName="")
Resolves a path relative to the application data directory.
void UpdateElapsedTimeSeconds()
Recomputes elapsed time in seconds since this Context was initialized.
TickableList & GetTickableComponents()
void Tick(EventID eventId)
Drives one frame of all registered TickableComponents for a specific EventID.
Extends PartList<TickableComponent> with order-aware sorting.
Definition TickableList.h:18
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14