载入中...
搜索中...
未找到
PcgColorPreviewSync.cpp
浏览该文件的文档.
14 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "source color must be finite",
43Result<void> PcgControllerSelection::add(const std::string& name, int type, const std::string& id) {
66 DiagnosticCode::InvalidArgument, "controller row index is out of range", "ui.pcgControllerSelection"));
72 DiagnosticCode::InvalidArgument, "controller row index is out of range", "ui.pcgControllerSelection"));
78 c.addFunc("add", [vm](PcgControllerSelection* s, const std::string& n, int type, const std::string& id) {
85 c.addFunc("getSelectedIndex", [](const PcgControllerSelection* s) { return s->getSelectedIndex(); });
99bool validName(const std::string& value) { return !value.empty() && value.find('\0') == std::string::npos; }
119 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "load progress must be finite",
138Result<int> PcgLoadingScreen::addMissingScene(const std::string& terrainName, const std::string& impostorName) {
151Result<void> PcgLoadingScreen::addReference(int sceneIndex, const std::string& objectName, bool impostor) {
152 if (!timeoutOpen_ || sceneIndex < 0 || static_cast<size_t>(sceneIndex) >= pendingMissingScenes_.size() ||
155 DiagnosticCode::InvalidArgument, "an open timeout, valid scene index and nonempty object name are required",
162Result<void> PcgLoadingScreen::addRegularReference(int sceneIndex, const std::string& objectName) {
166Result<void> PcgLoadingScreen::addImpostorReference(int sceneIndex, const std::string& objectName) {
220 c.addFunc("onLoadProgressStarted", [](PcgLoadingScreen* self) { self->onLoadProgressStarted(); });
226 c.addFunc("addMissingScene", [vm](PcgLoadingScreen* self, const std::string& terrain, const std::string& impostor) {
230 c.addFunc("addRegularReference", [vm](PcgLoadingScreen* self, int index, const std::string& name) {
233 c.addFunc("addImpostorReference", [vm](PcgLoadingScreen* self, int index, const std::string& name) {
239 [vm](PcgLoadingScreen* self, float dt) { return eve::script::projectResult(vm, self->tick(dt)); });
240 c.addFunc("getCanvasVisible", [](const PcgLoadingScreen* self) { return self->getCanvasVisible(); });
241 c.addFunc("getProgressVisible", [](const PcgLoadingScreen* self) { return self->getProgressVisible(); });
242 c.addFunc("getTextVisible", [](const PcgLoadingScreen* self) { return self->getTextVisible(); });
245 c.addFunc("getBackgroundAlpha", [](const PcgLoadingScreen* self) { return self->getBackgroundAlpha(); });
246 c.addFunc("getTimeoutMessage", [](const PcgLoadingScreen* self) { return self->getTimeoutMessage(); });
258bool PcgPhotoModeColorPicker::hdrActive() const noexcept { return hdr_ && (a_ > 1.f || a_ < 0.f); }
262 Diagnostic::error(DiagnosticCode::InvalidArgument, "color must be finite", "ui.pcgPhotoModeColorPicker"));
281 Diagnostic::error(DiagnosticCode::InvalidArgument, "color must be finite", "ui.pcgPhotoModeColorPicker"));
291 Diagnostic::error(DiagnosticCode::InvalidArgument, "color must be finite", "ui.pcgPhotoModeColorPicker"));
307float PcgPhotoModeColorPicker::getPreviewRed() const noexcept { return r_ * (hdrActive() ? a_ : 1.f); }
308float PcgPhotoModeColorPicker::getPreviewGreen() const noexcept { return g_ * (hdrActive() ? a_ : 1.f); }
309float PcgPhotoModeColorPicker::getPreviewBlue() const noexcept { return b_ * (hdrActive() ? a_ : 1.f); }
310float PcgPhotoModeColorPicker::getHdrSwatch() const noexcept { return std::clamp((a_ + 5.f) / 10.f, 0.f, 1.f); }
319 c.addFunc("open", [vm](PcgPhotoModeColorPicker* s, float r, float g, float b, float a, bool h) {
328 [vm](PcgPhotoModeColorPicker* s, float v) { return eve::script::projectResult(vm, s->setRed(v)); });
330 [vm](PcgPhotoModeColorPicker* s, float v) { return eve::script::projectResult(vm, s->setGreen(v)); });
332 [vm](PcgPhotoModeColorPicker* s, float v) { return eve::script::projectResult(vm, s->setBlue(v)); });
334 [vm](PcgPhotoModeColorPicker* s, float v) { return eve::script::projectResult(vm, s->setHdr(v)); });
340 c.addFunc("getPreviewRed", [](const PcgPhotoModeColorPicker* s) { return s->getPreviewRed(); });
341 c.addFunc("getPreviewGreen", [](const PcgPhotoModeColorPicker* s) { return s->getPreviewGreen(); });
342 c.addFunc("getPreviewBlue", [](const PcgPhotoModeColorPicker* s) { return s->getPreviewBlue(); });
344 c.addFunc("getHdrEnabled", [](const PcgPhotoModeColorPicker* s) { return s->getHdrEnabled(); });
346 c.addFunc("getFocusedName", [](const PcgPhotoModeColorPicker* s) { return s->getFocusedName(); });
347 c.addFunc("getChangeRevision", [](const PcgPhotoModeColorPicker* s) { return s->getChangeRevision(); });
349 [](PcgPhotoModeColorPicker* s) { return s->consumeBringToFront() == PcgUiRequestStatus::Requested; });
The single Squirrel projection for common Result, Status and Value.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Caller-owned highlighted-color snapshot ported from Pcg ColorPreviewSync.
Definition PcgColorPreviewSync.h:8
Result< void > sync(float red, float green, float blue, float alpha)
Synchronize from the source image color exactly as Pcg does on enable.
Definition PcgColorPreviewSync.cpp:12
Caller-owned visibility selection ported from Pcg UIControllerSelection.
Definition PcgControllerSelection.h:11
Result< bool > refresh(int currentController)
Select first matching type; no match preserves the previous visibility snapshot.
Definition PcgColorPreviewSync.cpp:51
Result< bool > getVisible(int index) const
Return row visibility.
Definition PcgColorPreviewSync.cpp:63
Result< void > add(const std::string &name, int controllerType, const std::string &widgetId)
Append one controller type and its stable UI widget id.
Definition PcgColorPreviewSync.cpp:43
Result< std::string > getWidgetId(int index) const
Return stable widget id.
Definition PcgColorPreviewSync.cpp:69
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 PcgColorPreviewSync.cpp:198
void beginTimeout() noexcept
Start a transactional missing-scene diagnostic.
Definition PcgColorPreviewSync.cpp:133
Result< void > endTimeout()
Publish the timeout warning and begin fade-out.
Definition PcgColorPreviewSync.cpp:170
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 PcgColorPreviewSync.cpp:138
void onLoadProgressStarted() noexcept
Reset canvas, background alpha and progress when load tracking starts.
Definition PcgColorPreviewSync.cpp:111
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 PcgColorPreviewSync.cpp:127
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 PcgColorPreviewSync.cpp:117
Result< void > addRegularReference(int sceneIndex, const std::string &objectName)
Append a regular referencing object name to a pending scene.
Definition PcgColorPreviewSync.cpp:162
Result< void > configure(float fadeOutSpeed)
Set the alpha units removed per second.
Definition PcgColorPreviewSync.cpp:102
Result< void > addImpostorReference(int sceneIndex, const std::string &objectName)
Append an impostor referencing object name to a pending scene.
Definition PcgColorPreviewSync.cpp:166
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
Caller-owned runtime model of Pcg PhotoModeColorPicker.
Definition PcgPhotoModeColorPicker.h:11
Result< void > open(float r, float g, float b, float a, bool hdr)
Open with a source color and preserve Pcg's HDR preprocessing.
Definition PcgColorPreviewSync.cpp:259
Result< void > setHdr(float v)
Set HDR alpha and publish one change.
Definition PcgColorPreviewSync.cpp:299
void setFocusedName(const std::string &name)
Set the focused display name, exposed with Pcg parentheses.
Definition PcgPhotoModeColorPicker.h:15
Result< void > setGreen(float v)
Set one raw channel and publish one change.
Definition PcgColorPreviewSync.cpp:297
float getPreviewRed() const noexcept
Return displayed/applied RGB after optional HDR multiplication.
Definition PcgColorPreviewSync.cpp:307
PcgUiRequestStatus consumeBringToFront() noexcept
Return and clear the SetAsLastSibling request.
Definition PcgColorPreviewSync.cpp:311
float getPreviewBlue() const noexcept
Definition PcgColorPreviewSync.cpp:309
float getPreviewGreen() const noexcept
Definition PcgColorPreviewSync.cpp:308
float getHdrSwatch() const noexcept
Return HDR slider grayscale swatch.
Definition PcgColorPreviewSync.cpp:310
void reset() noexcept
Restore last RGBA and reproduce four slider events plus explicit callback.
Definition PcgColorPreviewSync.cpp:300
Result< void > setRed(float v)
Set one raw channel and publish one change.
Definition PcgColorPreviewSync.cpp:296
Result< void > setLast(float r, float g, float b, float a)
Store the color restored by reset.
Definition PcgColorPreviewSync.cpp:278
Result< void > setBlue(float v)
Set one raw channel and publish one change.
Definition PcgColorPreviewSync.cpp:298
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:540
Definition Component.cpp:7
void exposePcgColorPreviewSyncBindings(ssq::Table &table)
Register Pcg color-preview bindings.
Definition PcgColorPreviewSync.cpp:27
void exposePcgLoadingScreenBindings(ssq::Table &table)
Register Pcg loading-screen bindings.
Definition PcgColorPreviewSync.cpp:214
void exposePcgPhotoModeColorPickerBindings(ssq::Table &t)
Register Pcg photo-mode color-picker bindings.
Definition PcgColorPreviewSync.cpp:316
PcgUiRequestStatus
Explicit status returned when consuming a one-shot Pcg UI request.
Definition PcgUiStatus.h:4
@ Requested
void exposePcgControllerSelectionBindings(ssq::Table &t)
Register Pcg controller-selection bindings.
Definition PcgColorPreviewSync.cpp:75
@ InvalidArgument