载入中...
搜索中...
未找到
PcgScreenshotSavedNotice.cpp
浏览该文件的文档.
6Result<void> PcgScreenshotSavedNotice::configure(bool enabled,float seconds){if(!std::isfinite(seconds)||seconds<0)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"show duration must be finite and non-negative","ui.pcgScreenshotSavedNotice"));enabled_=enabled;duration_=seconds;if(!enabled_){visible_=false;pending_=false;}return Result<void>::success();}
7Result<void> PcgScreenshotSavedNotice::request(const std::string& path){if(path.find('\0')!=std::string::npos)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"saved path contains a null character","ui.pcgScreenshotSavedNotice"));visible_=false;pending_=false;if(!enabled_)return Result<void>::success();path_=path;pending_=true;return Result<void>::success();}
8Result<void> PcgScreenshotSavedNotice::endFrame(float now){if(!std::isfinite(now)||now<0)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"time must be finite and non-negative","ui.pcgScreenshotSavedNotice"));if(pending_&&enabled_){pending_=false;visible_=true;hideAt_=now+duration_;}return Result<void>::success();}
9Result<void> PcgScreenshotSavedNotice::tick(float now){if(!std::isfinite(now)||now<0)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"time must be finite and non-negative","ui.pcgScreenshotSavedNotice"));if(visible_&&now>=hideAt_)visible_=false;return Result<void>::success();}
10void exposePcgScreenshotSavedNoticeBindings(ssq::Table&t){auto c=t.addClass("PcgScreenshotSavedNotice",ssq::Class::Ctor<PcgScreenshotSavedNotice()>());auto vm=t.getHandle();c.addFunc("configure",[vm](PcgScreenshotSavedNotice*s,bool e,float d){return eve::script::projectResult(vm,s->configure(e,d));});c.addFunc("request",[vm](PcgScreenshotSavedNotice*s,const std::string&p){return eve::script::projectResult(vm,s->request(p));});c.addFunc("endFrame",[vm](PcgScreenshotSavedNotice*s,float n){return eve::script::projectResult(vm,s->endFrame(n));});c.addFunc("tick",[vm](PcgScreenshotSavedNotice*s,float n){return eve::script::projectResult(vm,s->tick(n));});c.addFunc("getVisible",[](const PcgScreenshotSavedNotice*s){return s->getVisible();});c.addFunc("getPathVisible",[](const PcgScreenshotSavedNotice*s){return s->getPathVisible();});c.addFunc("getPath",[](const PcgScreenshotSavedNotice*s){return s->getPath();});c.addFunc("getPending",[](const PcgScreenshotSavedNotice*s){return s->getPending();});}
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 notification state ported from Pcg ScreenshotSavedManager.
Definition PcgScreenshotSavedNotice.h:9
Result< void > configure(bool enabled, float showSeconds)
Configure enable state and visible duration atomically.
Definition PcgScreenshotSavedNotice.cpp:6
Result< void > tick(float unscaledNow)
Advance expiration using explicit unscaled time.
Definition PcgScreenshotSavedNotice.cpp:9
Result< void > endFrame(float unscaledNow)
Publish a pending notice after rendering this frame.
Definition PcgScreenshotSavedNotice.cpp:8
Result< void > request(const std::string &savedPath)
Cancel an old notice and schedule a new one for the next end-of-frame.
Definition PcgScreenshotSavedNotice.cpp:7
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 exposePcgScreenshotSavedNoticeBindings(ssq::Table &t)
Register Pcg screenshot-notice bindings.
Definition PcgScreenshotSavedNotice.cpp:10
@ InvalidArgument