载入中...
搜索中...
未找到
PcgPhotoModePhoto.cpp
浏览该文件的文档.
2
3#include "common/Capability.h"
4
5#include <utility>
6
7namespace eve::ui {
8
10 if (authority_) cap::removeListener<IPhotoModeFieldSink>(this);
11}
12
14 if (enabled == authority_) return;
15 if (enabled) cap::addListener<IPhotoModeFieldSink>(this);
16 else cap::removeListener<IPhotoModeFieldSink>(this);
17 authority_ = enabled;
18}
19
21 const PhotoModeAssignment& assignment) const noexcept {
22 const bool lightingIdentity = assignment.domain == PhotoModeDomain::Lighting &&
23 (assignment.field == "m_isUsingPcgLighting" ||
24 assignment.field == "m_selectedPcgLightingProfile");
25 return assignment.domain == PhotoModeDomain::Photo || lightingIdentity
28}
29
31 auto next = state_;
32 const auto invalid = [&](const char* message) {
34 assignment.field, {}, "ui.pcgPhotoModePhoto"));
35 };
36 if (assignment.field == "m_isUsingPcgLighting") {
37 const auto* value = std::get_if<bool>(&assignment.value);
38 if (!value) return invalid("Pcg lighting identity requires a bool");
39 next.usingPcgLighting = *value;
40 } else if (assignment.field == "m_selectedPcgLightingProfile") {
41 const auto* value = std::get_if<int64_t>(&assignment.value);
42 if (!value || *value < -1) return invalid("Pcg lighting profile must be -1 or non-negative");
43 next.lightingProfile = static_cast<int>(*value);
44 } else if (assignment.field == "m_lastSceneName") {
45 const auto* value = std::get_if<std::string>(&assignment.value);
46 if (!value) return invalid("last scene name requires a string");
47 next.lastSceneName = *value;
48 } else if (assignment.field == "m_screenshotResolution") {
49 const auto* value = std::get_if<int64_t>(&assignment.value);
50 if (!value || *value < 0 || *value > 9) return invalid("screenshot resolution index must be in [0,9]");
51 next.screenshotResolution = static_cast<int>(*value);
52 } else if (assignment.field == "m_screenshotImageFormat") {
53 const auto* value = std::get_if<int64_t>(&assignment.value);
54 if (!value || *value < 0 || *value > 3) return invalid("screenshot format index must be in [0,3]");
55 next.screenshotFormat = static_cast<PcgScreenshotFormat>(*value);
56 } else {
57 const auto* value = std::get_if<bool>(&assignment.value);
58 if (!value) return invalid("photo option requires a bool");
59 if (assignment.field == "m_loadSavedSettings") next.loadSavedSettings = *value;
60 else if (assignment.field == "m_revertOnDisabled") next.revertOnDisabled = *value;
61 else if (assignment.field == "m_showFPS") next.showFps = *value;
62 else if (assignment.field == "m_showReticle") next.showReticle = *value;
63 else if (assignment.field == "m_showRuleOfThirds") next.showRuleOfThirds = *value;
64 else return invalid("unsupported Photo-domain field");
65 }
66 state_ = std::move(next);
67 return Result<void>::success();
68}
69
70bool PcgPhotoModePhotoAuthority::lightingProfileMatches(int currentProfile) const noexcept {
71 return state_.lightingProfile == currentProfile &&
72 state_.usingPcgLighting == (currentProfile >= 0);
73}
74
76 static constexpr PcgScreenshotSize sizes[] = {
77 {0, 0}, {640, 480}, {800, 600}, {1280, 720}, {1366, 768},
78 {1600, 900}, {1920, 1080}, {2560, 1440}, {3840, 2160}, {7680, 4320}};
79 return sizes[state_.screenshotResolution];
80}
81
83 static constexpr const char* extensions[] = {"exr", "jpg", "png", "tga"};
84 return extensions[static_cast<int>(state_.screenshotFormat)];
85}
86
87} // namespace eve::ui
double value
std::string message
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
void setAuthority(bool enabled)
Register or revoke this instance as the unique Photo-domain owner.
Result< void > applyPhotoModeField(const PhotoModeAssignment &assignment) override
Applies photo mode field.
bool lightingProfileMatches(int currentProfile) const noexcept
Test whether retained lighting identity matches the current scene profile.
PhotoModeFieldAcceptance acceptsPhotoModeField(const PhotoModeAssignment &assignment) const noexcept override
Accepts photo mode field.
~PcgPhotoModePhotoAuthority() override
Pcg photo mode photo authority.
PcgScreenshotSize screenshotSize() const noexcept
Resolve Pcg's fixed resolution index; index zero returns 0x0 for screen size.
const char * screenshotExtension() const noexcept
Return the lowercase extension for the retained screenshot format. @ownership The returned pointer bo...
PcgScreenshotFormat
Pcg screenshot output encoding.
PhotoModeFieldAcceptance
Capability implemented by the composition root that routes assignments to domain owners.
bool enabled
One reversible field assignment in a photo-mode transaction.
Resolved screenshot dimensions; zero means the current drawable size.