载入中...
搜索中...
未找到
PcgPhotoModeApplyPlan.cpp
浏览该文件的文档.
14 static const std::unordered_set<std::string> graphics={"m_lodBias","m_antiAliasing","m_shadowDistance","m_shadowResolution","m_shadowCascades"};
15 static const std::unordered_set<std::string> camera={"m_fieldOfView","m_pcgCullinDistance","m_cameraAperture","m_cameraFocalLength","m_cameraRoll","m_farClipPlane"};
24 if(n.starts_with("m_pcgWater")||n.starts_with("m_pcgReflections")||n.starts_with("m_pcgUnderwaterFog"))return PhotoModeDomain::Water;
25 if(n.starts_with("m_postFX")||n.starts_with("m_dof")||n=="m_autoDOFFocus"||n=="m_savedDofFocusMode")return PhotoModeDomain::PostFx;
31 n.starts_with("m_globalFog")||n.starts_with("m_globalShadow")||n.starts_with("m_overrideDensity")||
40 if(!audio)return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported,"audio capability is unavailable",{},{},"ui.pcgPhotoModeApply"));
42 if(!value)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"global volume requires a float value",{},{},"ui.pcgPhotoModeApply"));
47 if(!value)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"frame setting requires an integer value",{},{},"ui.pcgPhotoModeApply"));
49 if(*value<0||*value>2)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"VSync count must be in [0,2]",{},{},"ui.pcgPhotoModeApply"));
51 if(!presentation)return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported,"frame presentation capability is unavailable",{},{},"ui.pcgPhotoModeApply"));
53 if(!pacing)return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported,"frame pacing capability is unavailable",{},{},"ui.pcgPhotoModeApply"));
60 if(*value < -1 || *value > 240)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"target FPS must be in [-1,240]",{},{},"ui.pcgPhotoModeApply"));
62 if(!pacing)return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported,"frame pacing capability is unavailable",{},{},"ui.pcgPhotoModeApply"));
65 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported,"unknown frame setting: "+assignment.field,{},{},"ui.pcgPhotoModeApply"));
72 if(selected)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"multiple photo-mode providers accept field: "+assignment.field,{},{},"ui.pcgPhotoModeApply"));
76 if(!selected)return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported,"no photo-mode provider accepts field: "+assignment.field,{},{},"ui.pcgPhotoModeApply"));
90Result<void> PcgPhotoModeApplyPlan::compile(const PcgPhotoModeValues& before,const PcgPhotoModeValues& after) {
101Result<void> PcgPhotoModeApplyPlan::compileJson(const std::string& beforeJson,const std::string& afterJson) {
110 auto result=sink.applyPhotoModeAssignment({commands_[i].field,commands_[i].domain,commands_[i].after});
114 auto rollback=sink.applyPhotoModeAssignment({commands_[j-1].field,commands_[j-1].domain,commands_[j-1].before});
118 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,restored?"photo-mode assignment failed; applied assignments were rolled back":
130 if(index>=commands_.size())return Result<std::string>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode command index is out of range",{},{},"ui.pcgPhotoModeApply"));
134 if(index>=commands_.size())return Result<int>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode command index is out of range",{},{},"ui.pcgPhotoModeApply"));
138 auto vm=t.getHandle();auto c=t.addClass("PcgPhotoModeApplyPlan",ssq::Class::Ctor<PcgPhotoModeApplyPlan()>());
139 c.addFunc("compileJson",[vm](PcgPhotoModeApplyPlan*s,const std::string&a,const std::string&b){return script::projectResult(vm,s->compileJson(a,b));});
140 c.addFunc("executeRegistered",[vm](PcgPhotoModeApplyPlan*s){return script::projectResult(vm,s->executeRegistered());});
142 c.addFunc("getCommandField",[vm](const PcgPhotoModeApplyPlan*s,uint64_t i){return script::projectResult(vm,s->getCommandField(i),[](const std::string&v){return v;});});
143 c.addFunc("getCommandDomain",[vm](const PcgPhotoModeApplyPlan*s,uint64_t i){return script::projectResult(vm,s->getCommandDomain(i),[](int v){return v;});});
145 c.addFunc("getRollbackComplete",[](const PcgPhotoModeApplyPlan*s){return s->getRollbackComplete();});
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
virtual Result< void > applyPhotoModeAssignment(const PhotoModeAssignment &assignment)=0
Apply one atomic assignment to its authoritative domain.
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Stable, reversible difference between two complete Pcg photo-mode snapshots.
Definition PcgPhotoModeApplyPlan.h:10
Result< void > compile(const PcgPhotoModeValues &before, const PcgPhotoModeValues &after)
Compile all changed fields in source declaration order.
Definition PcgPhotoModeApplyPlan.cpp:90
Result< std::string > getCommandField(uint64_t index) const
Return a command field name.
Definition PcgPhotoModeApplyPlan.cpp:129
Result< void > executeRegistered()
Execute through the registered capability; absence is an observable failure.
Definition PcgPhotoModeApplyPlan.cpp:125
Result< void > execute(IPhotoModeApplySink &sink)
Execute through an explicit sink and roll back prior writes after a failure.
Definition PcgPhotoModeApplyPlan.cpp:107
Result< int > getCommandDomain(uint64_t index) const
Return a command domain.
Definition PcgPhotoModeApplyPlan.cpp:133
Result< void > compileJson(const std::string &beforeJson, const std::string &afterJson)
Compile two schema-1 JSON snapshots atomically.
Definition PcgPhotoModeApplyPlan.cpp:101
Complete typed value set from Pcg PhotoModeProfile with exact defaults.
Definition PcgPhotoModeValues.h:20
Result< void > restoreJson(const std::string &json)
Atomically restore schema 1 JSON; unknown or missing fields are rejected.
Definition PcgPhotoModeValues.cpp:142
uint64_t getFieldCount() const noexcept
Return stable schema field count.
Definition PcgPhotoModeValues.cpp:118
Result< PcgPhotoModeValue > getValue(const std::string &name) const
Read a field as its schema-declared native variant.
Definition PcgPhotoModeValues.cpp:130
Result< std::string > getFieldName(uint64_t index) const
Return schema field name by declaration order.
Definition PcgPhotoModeValues.cpp:119
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
std::variant< bool, int64_t, float, std::string, PcgPhotoModeColor > PcgPhotoModeValue
Definition PcgPhotoModeValues.h:16
void exposePcgPhotoModeApplyPlanBindings(ssq::Table &t)
Register Pcg photo-mode application-plan bindings.
Definition PcgPhotoModeApplyPlan.cpp:137
@ InvalidArgument
@ Unsupported
std::variant< bool, std::int64_t, float, std::string, PhotoModeColor > PhotoModeValue
Typed payload accepted by authoritative photo-mode domain owners.
Definition PcgPhotoModeApply.h:11
@ Accepted
PhotoModeDomain
Authoritative owner selected for a Pcg photo-mode field.
Definition PcgPhotoModeApply.h:13
@ Weather
@ Water
@ Lighting
@ Terrain
@ Camera
@ Grass
@ Streaming
@ PostFx
@ Audio
@ Photo
@ FramePacing
@ Graphics