载入中...
搜索中...
未找到
PcgLoadingScreen.cpp
浏览该文件的文档.
11bool validName(const std::string& value) { return !value.empty() && value.find('\0') == std::string::npos; }
16 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "fade-out speed must be finite and non-negative", {}, {},
29 if (!std::isfinite(progress)) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "load progress must be finite", {}, {},
48Result<int> PcgLoadingScreen::addMissingScene(const std::string& terrainName, const std::string& impostorName) {
59Result<void> PcgLoadingScreen::addReference(int sceneIndex, const std::string& objectName, bool impostor) {
60 if (!timeoutOpen_ || sceneIndex < 0 || static_cast<size_t>(sceneIndex) >= pendingMissingScenes_.size() ||
62 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "an open timeout, valid scene index and nonempty object name are required", {}, {},
69Result<void> PcgLoadingScreen::addRegularReference(int sceneIndex, const std::string& objectName) {
73Result<void> PcgLoadingScreen::addImpostorReference(int sceneIndex, const std::string& objectName) {
78 if (!timeoutOpen_) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "beginTimeout must be called before endTimeout", {}, {},
81 message += "If you feel that there is no error but the terrain loading simply needs more time, try to increase the Timeout value in the Terrain Loader Manager.\r\n";
103 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "frame delta time must be finite and non-negative", {}, {},
122 c.addFunc("onLoadProgressStarted", [](PcgLoadingScreen* self) { self->onLoadProgressStarted(); });
133 c.addFunc("addRegularReference", [vm](PcgLoadingScreen* self, int index, const std::string& name) {
136 c.addFunc("addImpostorReference", [vm](PcgLoadingScreen* self, int index, const std::string& name) {
145 c.addFunc("getCanvasVisible", [](const PcgLoadingScreen* self) { return self->getCanvasVisible(); });
146 c.addFunc("getProgressVisible", [](const PcgLoadingScreen* self) { return self->getProgressVisible(); });
147 c.addFunc("getTextVisible", [](const PcgLoadingScreen* self) { return self->getTextVisible(); });
150 c.addFunc("getBackgroundAlpha", [](const PcgLoadingScreen* self) { return self->getBackgroundAlpha(); });
151 c.addFunc("getTimeoutMessage", [](const PcgLoadingScreen* self) { return self->getTimeoutMessage(); });
The single Squirrel projection for common Result, Status and Value.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Caller-owned loading-screen state driven by Pcg terrain load-progress events.
Definition PcgLoadingScreen.h:28
Result< void > tick(float deltaTime)
Advance background fade using explicit frame delta time.
Definition PcgLoadingScreen.cpp:101
void beginTimeout() noexcept
Start a transactional missing-scene diagnostic.
Definition PcgLoadingScreen.cpp:43
Result< void > endTimeout()
Publish the timeout warning and begin fade-out.
Definition PcgLoadingScreen.cpp:77
Result< int > addMissingScene(const std::string &terrainName, const std::string &impostorName)
Append one missing terrain scene and return its stable index in the pending diagnostic.
Definition PcgLoadingScreen.cpp:48
void onLoadProgressStarted() noexcept
Reset canvas, background alpha and progress when load tracking starts.
Definition PcgLoadingScreen.cpp:22
float getProgress() const noexcept
Return current progress without clamping Pcg's event value.
Definition PcgLoadingScreen.h:60
const std::string & getTimeoutMessage() const noexcept
Return the most recently published timeout warning.
Definition PcgLoadingScreen.h:64
void onLoadProgressEnded() noexcept
Hide progress/text and begin fading the background.
Definition PcgLoadingScreen.cpp:37
bool getTextVisible() const noexcept
Return whether the loading text is enabled.
Definition PcgLoadingScreen.h:56
Result< void > onLoadProgressUpdated(float progress)
Publish progress; values at least one automatically begin fade-out.
Definition PcgLoadingScreen.cpp:28
Result< void > addRegularReference(int sceneIndex, const std::string &objectName)
Append a regular referencing object name to a pending scene.
Definition PcgLoadingScreen.cpp:69
Result< void > configure(float fadeOutSpeed)
Set the alpha units removed per second.
Definition PcgLoadingScreen.cpp:14
Result< void > addImpostorReference(int sceneIndex, const std::string &objectName)
Append an impostor referencing object name to a pending scene.
Definition PcgLoadingScreen.cpp:73
float getBackgroundAlpha() const noexcept
Return current background alpha.
Definition PcgLoadingScreen.h:62
bool getCanvasVisible() const noexcept
Return whether the loading canvas is enabled.
Definition PcgLoadingScreen.h:52
bool getProgressVisible() const noexcept
Return whether the progress bar is active.
Definition PcgLoadingScreen.h:54
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:470
Definition Component.cpp:5
void exposePcgLoadingScreenBindings(ssq::Table &table)
Register Pcg loading-screen bindings.
Definition PcgLoadingScreen.cpp:116
WidgetDesc progress(float fraction, std::string id, std::string overlay)
Progress bar; fraction is clamped to [0,1].
Definition Widget.cpp:395
@ InvalidArgument