|
| 1 | +using ResoniteModLoader; |
| 2 | + |
| 3 | +namespace ViveStreamingFaceTrackingForResonite; |
| 4 | + |
| 5 | +/// <summary> |
| 6 | +/// Manages configuration keys for displaying ViveStreaming connection status information. |
| 7 | +/// </summary> |
| 8 | +public sealed class ViveStreamingFaceTrackingConfigManager |
| 9 | +{ |
| 10 | + private readonly ModConfiguration _config; |
| 11 | + private readonly ModConfigurationKey<string> _connectionStatusKey; |
| 12 | + private readonly ModConfigurationKey<string> _hmdModelKey; |
| 13 | + private readonly ModConfigurationKey<string> _eyeTrackingStatusKey; |
| 14 | + private readonly ModConfigurationKey<string> _mouthTrackingStatusKey; |
| 15 | + private readonly ModConfigurationKey<int> _eyeDataCountKey; |
| 16 | + private readonly ModConfigurationKey<int> _mouthDataCountKey; |
| 17 | + private readonly ModConfigurationKey<int> _frameRateKey; |
| 18 | + |
| 19 | + private string _connectionStatus = "Disconnected"; |
| 20 | + private string _hmdModel = "Unknown"; |
| 21 | + private string _eyeTrackingStatus = "Disconnected"; |
| 22 | + private string _mouthTrackingStatus = "Disconnected"; |
| 23 | + private int _eyeDataCount; |
| 24 | + private int _mouthDataCount; |
| 25 | + private int _frameRate = -1; |
| 26 | + |
| 27 | + /// <summary> |
| 28 | + /// Gets or sets the connection status. |
| 29 | + /// </summary> |
| 30 | + public string ConnectionStatus |
| 31 | + { |
| 32 | + get => _connectionStatus; |
| 33 | + set |
| 34 | + { |
| 35 | + if (_connectionStatus != value) |
| 36 | + { |
| 37 | + _connectionStatus = value; |
| 38 | + _config.Set(_connectionStatusKey, value); |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// Gets or sets the HMD model name. |
| 45 | + /// </summary> |
| 46 | + public string HmdModel |
| 47 | + { |
| 48 | + get => _hmdModel; |
| 49 | + set |
| 50 | + { |
| 51 | + if (_hmdModel != value) |
| 52 | + { |
| 53 | + _hmdModel = value; |
| 54 | + _config.Set(_hmdModelKey, value); |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// Gets or sets the eye tracking status. |
| 61 | + /// </summary> |
| 62 | + public string EyeTrackingStatus |
| 63 | + { |
| 64 | + get => _eyeTrackingStatus; |
| 65 | + set |
| 66 | + { |
| 67 | + if (_eyeTrackingStatus != value) |
| 68 | + { |
| 69 | + _eyeTrackingStatus = value; |
| 70 | + _config.Set(_eyeTrackingStatusKey, value); |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + /// <summary> |
| 76 | + /// Gets or sets the mouth tracking status. |
| 77 | + /// </summary> |
| 78 | + public string MouthTrackingStatus |
| 79 | + { |
| 80 | + get => _mouthTrackingStatus; |
| 81 | + set |
| 82 | + { |
| 83 | + if (_mouthTrackingStatus != value) |
| 84 | + { |
| 85 | + _mouthTrackingStatus = value; |
| 86 | + _config.Set(_mouthTrackingStatusKey, value); |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + /// <summary> |
| 92 | + /// Gets or sets the number of active eye data points. |
| 93 | + /// </summary> |
| 94 | + public int EyeDataCount |
| 95 | + { |
| 96 | + get => _eyeDataCount; |
| 97 | + set |
| 98 | + { |
| 99 | + if (_eyeDataCount != value) |
| 100 | + { |
| 101 | + _eyeDataCount = value; |
| 102 | + _config.Set(_eyeDataCountKey, value); |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + /// <summary> |
| 108 | + /// Gets or sets the number of active mouth data points. |
| 109 | + /// </summary> |
| 110 | + public int MouthDataCount |
| 111 | + { |
| 112 | + get => _mouthDataCount; |
| 113 | + set |
| 114 | + { |
| 115 | + if (_mouthDataCount != value) |
| 116 | + { |
| 117 | + _mouthDataCount = value; |
| 118 | + _config.Set(_mouthDataCountKey, value); |
| 119 | + } |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + /// <summary> |
| 124 | + /// Gets or sets the tracking frame rate. |
| 125 | + /// </summary> |
| 126 | + public int FrameRate |
| 127 | + { |
| 128 | + get => _frameRate; |
| 129 | + set |
| 130 | + { |
| 131 | + if (_frameRate != value) |
| 132 | + { |
| 133 | + _frameRate = value; |
| 134 | + _config.Set(_frameRateKey, value); |
| 135 | + } |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | + /// <summary> |
| 140 | + /// Initializes a new instance of the <see cref="ViveStreamingFaceTrackingConfigManager"/> class. |
| 141 | + /// </summary> |
| 142 | + /// <param name="config">The mod configuration instance.</param> |
| 143 | + /// <param name="connectionStatusKey">Configuration key for connection status.</param> |
| 144 | + /// <param name="hmdModelKey">Configuration key for HMD model.</param> |
| 145 | + /// <param name="eyeTrackingStatusKey">Configuration key for eye tracking status.</param> |
| 146 | + /// <param name="mouthTrackingStatusKey">Configuration key for mouth tracking status.</param> |
| 147 | + /// <param name="eyeDataCountKey">Configuration key for eye data count.</param> |
| 148 | + /// <param name="mouthDataCountKey">Configuration key for mouth data count.</param> |
| 149 | + /// <param name="frameRateKey">Configuration key for frame rate.</param> |
| 150 | + public ViveStreamingFaceTrackingConfigManager( |
| 151 | + ModConfiguration config, |
| 152 | + ModConfigurationKey<string> connectionStatusKey, |
| 153 | + ModConfigurationKey<string> hmdModelKey, |
| 154 | + ModConfigurationKey<string> eyeTrackingStatusKey, |
| 155 | + ModConfigurationKey<string> mouthTrackingStatusKey, |
| 156 | + ModConfigurationKey<int> eyeDataCountKey, |
| 157 | + ModConfigurationKey<int> mouthDataCountKey, |
| 158 | + ModConfigurationKey<int> frameRateKey) |
| 159 | + { |
| 160 | + _config = config; |
| 161 | + _connectionStatusKey = connectionStatusKey; |
| 162 | + _hmdModelKey = hmdModelKey; |
| 163 | + _eyeTrackingStatusKey = eyeTrackingStatusKey; |
| 164 | + _mouthTrackingStatusKey = mouthTrackingStatusKey; |
| 165 | + _eyeDataCountKey = eyeDataCountKey; |
| 166 | + _mouthDataCountKey = mouthDataCountKey; |
| 167 | + _frameRateKey = frameRateKey; |
| 168 | + |
| 169 | + InitializeValues(); |
| 170 | + } |
| 171 | + |
| 172 | + private void InitializeValues() |
| 173 | + { |
| 174 | + // 初期値を設定(プロパティを使用して自動的にconfigに反映) |
| 175 | + ConnectionStatus = _connectionStatus; |
| 176 | + HmdModel = _hmdModel; |
| 177 | + EyeTrackingStatus = _eyeTrackingStatus; |
| 178 | + MouthTrackingStatus = _mouthTrackingStatus; |
| 179 | + EyeDataCount = _eyeDataCount; |
| 180 | + MouthDataCount = _mouthDataCount; |
| 181 | + FrameRate = _frameRate; |
| 182 | + } |
| 183 | +} |
0 commit comments