载入中...
搜索中...
未找到
PcgPhotoModeValues.cpp
浏览该文件的文档.
3#include "common/Value.h"
4#include <simplesquirrel/simplesquirrel.hpp>
5#include <cmath>
6#include <limits>
7namespace eve::ui { namespace {
8const std::vector<PcgPhotoModeField>& fields(){static const std::vector<PcgPhotoModeField> v={
9 {"m_isUsingPcgLighting", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
10 {"m_selectedPcgLightingProfile", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{-1}}},
11 {"m_lastSceneName", PcgPhotoModeValueType::String, PcgPhotoModeValue{std::string{}}},
12 {"m_screenshotResolution", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{0}}},
13 {"m_screenshotImageFormat", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{2}}},
14 {"m_loadSavedSettings", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{true}},
15 {"m_revertOnDisabled", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{true}},
17 {"m_showReticle", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
18 {"m_showRuleOfThirds", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
20 {"m_vSync", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{0}}},
21 {"m_targetFPS", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{-1}}},
22 {"m_antiAliasing", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{1}}},
23 {"m_shadowDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{512.0f}},
24 {"m_shadowResolution", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{3}}},
25 {"m_shadowCascades", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{4}}},
26 {"m_fieldOfView", PcgPhotoModeValueType::Float, PcgPhotoModeValue{60.0f}},
27 {"m_pcgCullinDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.0f}},
28 {"m_cameraAperture", PcgPhotoModeValueType::Float, PcgPhotoModeValue{19.0f}},
29 {"m_cameraFocalLength", PcgPhotoModeValueType::Float, PcgPhotoModeValue{50.0f}},
30 {"m_globalVolume", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
31 {"m_cameraRoll", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.0f}},
32 {"m_farClipPlane", PcgPhotoModeValueType::Float, PcgPhotoModeValue{2000.0f}},
33 {"m_pcgLoadRange", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1000.0f}},
34 {"m_pcgImpostorRange", PcgPhotoModeValueType::Float, PcgPhotoModeValue{2000.0f}},
35 {"m_pcgWeatherEnabled", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
36 {"m_pcgWeatherRain", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
37 {"m_pcgWeatherSnow", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
38 {"m_pcgWindSettingsOverride", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
39 {"m_pcgWindDirection", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.0f}},
40 {"m_pcgWindSpeed", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.35f}},
42 {"m_pcgTimeOfDayEnabled", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
43 {"m_pcgTimeScale", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
44 {"m_pcgAdditionalLinearFog", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.0f}},
45 {"m_pcgAdditionalExponentialFog", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.0f}},
46 {"m_sunRotation", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.0f}},
47 {"m_sunPitch", PcgPhotoModeValueType::Float, PcgPhotoModeValue{75.0f}},
48 {"m_fogOverride", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
49 {"m_fogMode", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{1}}},
50 {"m_fogColor", PcgPhotoModeValueType::Color, PcgPhotoModeValue{PcgPhotoModeColor{0,0,0,1}}},
51 {"m_fogDensity", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.01f}},
52 {"m_fogStart", PcgPhotoModeValueType::Float, PcgPhotoModeValue{100.0f}},
53 {"m_fogEnd", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1000.0f}},
54 {"m_skyboxOverride", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
55 {"m_skyboxRotation", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.0f}},
56 {"m_skyboxExposure", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
57 {"m_skyboxTint", PcgPhotoModeValueType::Color, PcgPhotoModeValue{PcgPhotoModeColor{0,0,0,1}}},
58 {"m_sunOverride", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
59 {"m_sunIntensity", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
60 {"m_sunColor", PcgPhotoModeValueType::Color, PcgPhotoModeValue{PcgPhotoModeColor{0,0,0,1}}},
61 {"m_sunKelvinValue", PcgPhotoModeValueType::Float, PcgPhotoModeValue{6500.0f}},
62 {"m_ambientIntensity", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
63 {"m_ambientSkyColor", PcgPhotoModeValueType::Color, PcgPhotoModeValue{PcgPhotoModeColor{0.7027151f,0.881016f,1.001631f,0.4192761f}}},
64 {"m_ambientEquatorColor", PcgPhotoModeValueType::Color, PcgPhotoModeValue{PcgPhotoModeColor{0.6302439f,0.7919513f,0.85f,0.0f}}},
65 {"m_ambientGroundColor", PcgPhotoModeValueType::Color, PcgPhotoModeValue{PcgPhotoModeColor{0.5f,0.4142857f,0.3321428f,0.0f}}},
66 {"m_globalLightIntensityMultiplier", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
67 {"m_globalFogDensityMultiplier", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
68 {"m_globalShadowDistanceMultiplier", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
69 {"m_pcgWaterReflectionEnabled", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{true}},
70 {"m_pcgWaterReflectionDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.0f}},
71 {"m_pcgWaterReflectionResolution", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{2}}},
72 {"m_pcgReflectionsLODBias", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
73 {"m_pcgUnderwaterFogColor", PcgPhotoModeValueType::Color, PcgPhotoModeValue{PcgPhotoModeColor{0,0,0,1}}},
74 {"m_pcgUnderwaterFogDensity", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.045f}},
75 {"m_pcgUnderwaterFogDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{45.0f}},
76 {"m_pcgUnderwaterVolume", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.5f}},
77 {"m_postFXExposure", PcgPhotoModeValueType::Float, PcgPhotoModeValue{13.5f}},
78 {"m_postFXExposureMode", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{0}}},
79 {"m_dofActive", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{true}},
80 {"m_autoDOFFocus", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{true}},
81 {"m_dofFocusDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{100.0f}},
82 {"m_dofAperture", PcgPhotoModeValueType::Float, PcgPhotoModeValue{16.0f}},
83 {"m_dofFocalLength", PcgPhotoModeValueType::Float, PcgPhotoModeValue{50.0f}},
84 {"m_dofKernelSize", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{1}}},
85 {"m_savedDofFocusMode", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{0}}},
86 {"m_dofFocusModeHDRP", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{0}}},
87 {"m_dofFocusModeURP", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{0}}},
88 {"m_dofQualityHDRP", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{1}}},
89 {"m_dofNearBlurStart", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.0f}},
90 {"m_dofNearBlurEnd", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.1f}},
91 {"m_dofFarBlurStart", PcgPhotoModeValueType::Float, PcgPhotoModeValue{200.0f}},
92 {"m_dofFarBlurEnd", PcgPhotoModeValueType::Float, PcgPhotoModeValue{2000.0f}},
93 {"m_dofStartBlurURP", PcgPhotoModeValueType::Float, PcgPhotoModeValue{2.0f}},
94 {"m_dofEndBlurURP", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1000.0f}},
95 {"m_dofMaxRadiusBlur", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
96 {"m_dofHighQualityURP", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
97 {"m_terrainDetailDensity", PcgPhotoModeValueType::Float, PcgPhotoModeValue{0.5f}},
98 {"m_terrainDetailDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{150.0f}},
99 {"m_terrainPixelError", PcgPhotoModeValueType::Float, PcgPhotoModeValue{5.0f}},
100 {"m_terrainBasemapDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1024.0f}},
101 {"m_drawInstanced", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{true}},
102 {"m_overrideDensityVolume", PcgPhotoModeValueType::Bool, PcgPhotoModeValue{false}},
103 {"m_densityVolumeAlbedoColor", PcgPhotoModeValueType::Color, PcgPhotoModeValue{PcgPhotoModeColor{1,1,1,1}}},
104 {"m_densityVolumeFogDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{250.0f}},
105 {"m_densityVolumeEffectType", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{1}}},
106 {"m_densityVolumeTilingResolution", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{3}}},
107 {"m_globalGrassDensity", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
108 {"m_globalGrassDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
109 {"m_cameraCellDistance", PcgPhotoModeValueType::Float, PcgPhotoModeValue{1.0f}},
110 {"m_cameraCellSubdivision", PcgPhotoModeValueType::Int, PcgPhotoModeValue{int64_t{0}}},
111 };return v;}
112const PcgPhotoModeField* field(const std::string&n){for(const auto&f:fields())if(f.name==n)return &f;return nullptr;}
113template<class T> Result<void> setTyped(std::unordered_map<std::string,PcgPhotoModeValue>&v,const std::string&n,PcgPhotoModeValueType t,T x){auto*f=field(n);if(!f)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"unknown photo-mode field: "+n,{}, {},"ui.pcgPhotoModeValues"));if(f->type!=t)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode field type mismatch: "+n,{}, {},"ui.pcgPhotoModeValues"));v[n]=std::move(x);return Result<void>::success();}
114template<class T> Result<T> getTyped(const std::unordered_map<std::string,PcgPhotoModeValue>&v,const std::string&n,PcgPhotoModeValueType t){auto*f=field(n);if(!f)return Result<T>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"unknown photo-mode field: "+n,{}, {},"ui.pcgPhotoModeValues"));if(f->type!=t)return Result<T>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode field type mismatch: "+n,{}, {},"ui.pcgPhotoModeValues"));return Result<T>::success(std::get<T>(v.at(n)));}
115}
117void PcgPhotoModeValues::resetDefaults(){std::unordered_map<std::string,PcgPhotoModeValue> next;for(const auto&f:fields())next.emplace(f.name,f.defaultValue);values_=std::move(next);selectedColor_={};}
118uint64_t PcgPhotoModeValues::getFieldCount()const noexcept{return fields().size();}
119Result<std::string> PcgPhotoModeValues::getFieldName(uint64_t i)const{if(i>=fields().size())return Result<std::string>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode field index is out of range",{}, {},"ui.pcgPhotoModeValues"));return Result<std::string>::success(fields()[i].name);}
120Result<int> PcgPhotoModeValues::getFieldType(const std::string&n)const{auto*f=field(n);if(!f)return Result<int>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"unknown photo-mode field: "+n,{}, {},"ui.pcgPhotoModeValues"));return Result<int>::success(static_cast<int>(f->type));}
121Result<void> PcgPhotoModeValues::setBool(const std::string&n,bool v){return setTyped(values_,n,PcgPhotoModeValueType::Bool,v);}
122Result<void> PcgPhotoModeValues::setInt(const std::string&n,int64_t v){return setTyped(values_,n,PcgPhotoModeValueType::Int,v);}
123Result<void> PcgPhotoModeValues::setFloat(const std::string&n,float v){if(!std::isfinite(v))return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode float must be finite",{}, {},"ui.pcgPhotoModeValues"));return setTyped(values_,n,PcgPhotoModeValueType::Float,v);}
124Result<void> PcgPhotoModeValues::setString(const std::string&n,const std::string&v){return setTyped(values_,n,PcgPhotoModeValueType::String,v);}
125Result<void> PcgPhotoModeValues::setColor(const std::string&n,float r,float g,float b,float a){if(!std::isfinite(r)||!std::isfinite(g)||!std::isfinite(b)||!std::isfinite(a))return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode color must be finite",{}, {},"ui.pcgPhotoModeValues"));return setTyped(values_,n,PcgPhotoModeValueType::Color,PcgPhotoModeColor{r,g,b,a});}
126Result<bool> PcgPhotoModeValues::getBool(const std::string&n)const{return getTyped<bool>(values_,n,PcgPhotoModeValueType::Bool);}
127Result<int64_t> PcgPhotoModeValues::getInt(const std::string&n)const{return getTyped<int64_t>(values_,n,PcgPhotoModeValueType::Int);}
128Result<float> PcgPhotoModeValues::getFloat(const std::string&n)const{return getTyped<float>(values_,n,PcgPhotoModeValueType::Float);}
129Result<std::string> PcgPhotoModeValues::getString(const std::string&n)const{return getTyped<std::string>(values_,n,PcgPhotoModeValueType::String);}
130Result<PcgPhotoModeValue> PcgPhotoModeValues::getValue(const std::string&n)const{if(!field(n))return Result<PcgPhotoModeValue>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"unknown photo-mode field: "+n,{}, {},"ui.pcgPhotoModeValues"));return Result<PcgPhotoModeValue>::success(values_.at(n));}
131Result<void> PcgPhotoModeValues::selectColor(const std::string&n){auto r=getTyped<PcgPhotoModeColor>(values_,n,PcgPhotoModeValueType::Color);if(!r)return Result<void>::failure(*r.error());selectedColor_=r.value();return Result<void>::success();}
133 Value::Object encoded;
134 for(const auto&f:fields()){const auto&v=values_.at(f.name);switch(f.type){
135 case PcgPhotoModeValueType::Bool:encoded[f.name]=std::get<bool>(v);break;
136 case PcgPhotoModeValueType::Int:encoded[f.name]=std::get<int64_t>(v);break;
137 case PcgPhotoModeValueType::Float:encoded[f.name]=double(std::get<float>(v));break;
138 case PcgPhotoModeValueType::String:encoded[f.name]=std::get<std::string>(v);break;
139 case PcgPhotoModeValueType::Color:{auto c=std::get<PcgPhotoModeColor>(v);encoded[f.name]=Value::Array{double(c.r),double(c.g),double(c.b),double(c.a)};break;}}}
140 return Value(Value::Object{{"schema","eve.ui.pcg-photo-mode-values"},{"values",std::move(encoded)},{"version",int64_t{1}}}).toJson();
141}
143 if(json.size()>1024U*1024U)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode values JSON exceeds size limit",{}, {},"ui.pcgPhotoModeValues"));
144 auto decoded=Value::fromJson(json);
145 if(!decoded.ok())return Result<void>::failure(decoded.status());
146 const auto*root=decoded.value().getIf<Value::Object>();if(!root||root->size()!=3||!root->contains("schema")||!root->contains("version")||!root->contains("values"))return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode values has missing or unknown root fields",{}, {},"ui.pcgPhotoModeValues"));
147 const auto*schema=root->at("schema").getIf<std::string>();const auto*version=root->at("version").getIf<int64_t>();const auto*object=root->at("values").getIf<Value::Object>();if(!schema||*schema!="eve.ui.pcg-photo-mode-values"||!version||*version!=1||!object||object->size()!=fields().size())return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode values has unsupported schema, version or field count",{}, {},"ui.pcgPhotoModeValues"));
148 PcgPhotoModeValues candidate;for(const auto&f:fields()){if(!object->contains(f.name))return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode values is missing field: "+f.name,{}, {},"ui.pcgPhotoModeValues"));const auto&v=object->at(f.name);switch(f.type){
149 case PcgPhotoModeValueType::Bool:{auto*x=v.getIf<bool>();if(!x)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"invalid bool field: "+f.name,{}, {},"ui.pcgPhotoModeValues"));candidate.values_[f.name]=*x;break;}
150 case PcgPhotoModeValueType::Int:{auto*x=v.getIf<int64_t>();if(!x)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"invalid int field: "+f.name,{}, {},"ui.pcgPhotoModeValues"));candidate.values_[f.name]=*x;break;}
151 case PcgPhotoModeValueType::Float:{auto*x=v.getIf<double>();if(!x||!std::isfinite(*x)||*x>std::numeric_limits<float>::max()||*x<-std::numeric_limits<float>::max())return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"invalid float field: "+f.name,{}, {},"ui.pcgPhotoModeValues"));candidate.values_[f.name]=float(*x);break;}
152 case PcgPhotoModeValueType::String:{auto*x=v.getIf<std::string>();if(!x)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"invalid string field: "+f.name,{}, {},"ui.pcgPhotoModeValues"));candidate.values_[f.name]=*x;break;}
153 case PcgPhotoModeValueType::Color:{auto*x=v.getIf<Value::Array>();if(!x||x->size()!=4)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"invalid color field: "+f.name,{}, {},"ui.pcgPhotoModeValues"));double c[4];for(int i=0;i<4;++i){auto*n=(*x)[i].getIf<double>();if(!n||!std::isfinite(*n))return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"invalid color component: "+f.name,{}, {},"ui.pcgPhotoModeValues"));c[i]=*n;}candidate.values_[f.name]=PcgPhotoModeColor{float(c[0]),float(c[1]),float(c[2]),float(c[3])};break;}}
154 }values_.swap(candidate.values_);selectedColor_={};return Result<void>::success();
155}
156void exposePcgPhotoModeValuesBindings(ssq::Table&t){auto vm=t.getHandle();auto c=t.addClass("PcgPhotoModeValues",ssq::Class::Ctor<PcgPhotoModeValues()>());c.addFunc("resetDefaults",[](PcgPhotoModeValues*s){s->resetDefaults();});c.addFunc("getFieldCount",[](const PcgPhotoModeValues*s){return s->getFieldCount();});c.addFunc("getFieldName",[vm](const PcgPhotoModeValues*s,uint64_t i){return eve::script::projectResult(vm,s->getFieldName(i),[](const std::string&v){return v;});});c.addFunc("getFieldType",[vm](const PcgPhotoModeValues*s,const std::string&n){return eve::script::projectResult(vm,s->getFieldType(n),[](int v){return v;});});c.addFunc("setBool",[vm](PcgPhotoModeValues*s,const std::string&n,bool v){return eve::script::projectResult(vm,s->setBool(n,v));});c.addFunc("setInt",[vm](PcgPhotoModeValues*s,const std::string&n,int64_t v){return eve::script::projectResult(vm,s->setInt(n,v));});c.addFunc("setFloat",[vm](PcgPhotoModeValues*s,const std::string&n,float v){return eve::script::projectResult(vm,s->setFloat(n,v));});c.addFunc("setString",[vm](PcgPhotoModeValues*s,const std::string&n,const std::string&v){return eve::script::projectResult(vm,s->setString(n,v));});c.addFunc("setColor",[vm](PcgPhotoModeValues*s,const std::string&n,float r,float g,float b,float a){return eve::script::projectResult(vm,s->setColor(n,r,g,b,a));});c.addFunc("getBool",[vm](const PcgPhotoModeValues*s,const std::string&n){return eve::script::projectResult(vm,s->getBool(n),[](bool v){return v;});});c.addFunc("getInt",[vm](const PcgPhotoModeValues*s,const std::string&n){return eve::script::projectResult(vm,s->getInt(n),[](int64_t v){return v;});});c.addFunc("getFloat",[vm](const PcgPhotoModeValues*s,const std::string&n){return eve::script::projectResult(vm,s->getFloat(n),[](float v){return v;});});c.addFunc("getString",[vm](const PcgPhotoModeValues*s,const std::string&n){return eve::script::projectResult(vm,s->getString(n),[](const std::string&v){return v;});});c.addFunc("selectColor",[vm](PcgPhotoModeValues*s,const std::string&n){return eve::script::projectResult(vm,s->selectColor(n));});c.addFunc("snapshotJson",[vm](const PcgPhotoModeValues*s){return eve::script::projectResult(vm,s->snapshotJson(),[](const std::string&v){return v;});});c.addFunc("restoreJson",[vm](PcgPhotoModeValues*s,const std::string&v){return eve::script::projectResult(vm,s->restoreJson(v));});c.addFunc("getColorR",[](const PcgPhotoModeValues*s){return s->getColorR();});c.addFunc("getColorG",[](const PcgPhotoModeValues*s){return s->getColorG();});c.addFunc("getColorB",[](const PcgPhotoModeValues*s){return s->getColorB();});c.addFunc("getColorA",[](const PcgPhotoModeValues*s){return s->getColorA();});}
157}
float x
Definition AnimClip.cpp:738
int root
Definition AnimSmr.cpp:119
const std::string & s
HSQUIRRELVM vm
Definition ECS.cpp:20
tensor::Graph g
Definition GpuGraph.cpp:7
glm::vec3 n
Definition Grass.cpp:63
double r
float v
std::int32_t c
std::string name
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float f
std::vector< std::string > fields
Definition PlayHost.cpp:111
float t
The single Squirrel projection for common Result, Status and Value.
Json object
float size
Definition TreeMesh.cpp:156
Owning, renderer-independent dynamic values.
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
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
std::map< std::string, Value > Object
Definition Value.h:34
std::vector< Value > Array
Definition Value.h:33
Complete typed value set from Pcg PhotoModeProfile with exact defaults.
Result< int > getFieldType(const std::string &name) const
Return field type: bool=0, int=1, float=2, string=3, color=4.
Result< bool > getBool(const std::string &name) const
Read a typed boolean field.
Result< void > setBool(const std::string &name, bool value)
Set a typed boolean field.
Result< void > restoreJson(const std::string &json)
Atomically restore schema 1 JSON; unknown or missing fields are rejected.
uint64_t getFieldCount() const noexcept
Return stable schema field count.
Result< std::string > snapshotJson() const
Encode schema 1 JSON containing every field.
Result< float > getFloat(const std::string &name) const
Read a typed float field.
Result< int64_t > getInt(const std::string &name) const
Read a typed integer field.
Result< PcgPhotoModeValue > getValue(const std::string &name) const
Read a field as its schema-declared native variant.
Result< void > setString(const std::string &name, const std::string &value)
Set a typed string field.
Result< void > selectColor(const std::string &name)
Select a color field for component reads.
Result< void > setColor(const std::string &name, float r, float g, float b, float a)
Set a finite typed RGBA field.
PcgPhotoModeValues()
Pcg photo mode values.
Result< void > setFloat(const std::string &name, float value)
Set a finite typed float field.
Result< void > setInt(const std::string &name, int64_t value)
Set a typed integer or enum field.
Result< std::string > getFieldName(uint64_t index) const
Return schema field name by declaration order.
Result< std::string > getString(const std::string &name) const
Read a typed string field.
void resetDefaults()
Restore all 102 Pcg defaults atomically.
const EditorValue * field(const EditorValue &value, const char *name)
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
void exposePcgPhotoModeValuesBindings(ssq::Table &t)
Register complete Pcg photo-mode value bindings.
std::variant< bool, int64_t, float, std::string, PcgPhotoModeColor > PcgPhotoModeValue
PcgPhotoModeValueType
PcgPhotoModeValueType public API.
PcgPhotoModeColor public API.