summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/settings.h48
1 files changed, 9 insertions, 39 deletions
diff --git a/src/common/settings.h b/src/common/settings.h
index 4432b5ddd..69f4adaeb 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <algorithm>
7#include <array> 8#include <array>
8#include <atomic> 9#include <atomic>
9#include <chrono> 10#include <chrono>
@@ -168,15 +169,7 @@ public:
168 * @param value The desired value 169 * @param value The desired value
169 */ 170 */
170 void SetValue(const Type& value) override { 171 void SetValue(const Type& value) override {
171 Type temp; 172 this->global = std::clamp(value, minimum, maximum);
172 if (value < minimum) {
173 temp = minimum;
174 } else if (value > maximum) {
175 temp = maximum;
176 } else {
177 temp = value;
178 }
179 std::swap(this->global, temp);
180 } 173 }
181 174
182 /** 175 /**
@@ -186,15 +179,7 @@ public:
186 * @returns A reference to the setting's value 179 * @returns A reference to the setting's value
187 */ 180 */
188 const Type& operator=(const Type& value) override { 181 const Type& operator=(const Type& value) override {
189 Type temp; 182 this->global = std::clamp(value, minimum, maximum);
190 if (value < minimum) {
191 temp = minimum;
192 } else if (value > maximum) {
193 temp = maximum;
194 } else {
195 temp = value;
196 }
197 std::swap(this->global, temp);
198 return this->global; 183 return this->global;
199 } 184 }
200 185
@@ -342,19 +327,11 @@ public:
342 * @param value The desired value 327 * @param value The desired value
343 */ 328 */
344 void SetValue(const Type& value) override { 329 void SetValue(const Type& value) override {
345 Type temp; 330 const Type temp = std::clamp(value, this->minimum, this->maximum);
346 if (value < this->minimum) {
347 temp = this->minimum;
348 } else if (value > this->maximum) {
349 temp = this->maximum;
350 } else {
351 temp = value;
352 }
353 if (this->use_global) { 331 if (this->use_global) {
354 std::swap(this->global, temp); 332 this->global = temp;
355 } else {
356 std::swap(this->custom, temp);
357 } 333 }
334 this->custom = temp;
358 } 335 }
359 336
360 /** 337 /**
@@ -365,19 +342,12 @@ public:
365 * @returns A reference to the setting's value 342 * @returns A reference to the setting's value
366 */ 343 */
367 const Type& operator=(const Type& value) override { 344 const Type& operator=(const Type& value) override {
368 Type temp; 345 const Type temp = std::clamp(value, this->minimum, this->maximum);
369 if (value < this->minimum) {
370 temp = this->minimum;
371 } else if (value > this->maximum) {
372 temp = this->maximum;
373 } else {
374 temp = value;
375 }
376 if (this->use_global) { 346 if (this->use_global) {
377 std::swap(this->global, temp); 347 this->global = temp;
378 return this->global; 348 return this->global;
379 } 349 }
380 std::swap(this->custom, temp); 350 this->custom = temp;
381 return this->custom; 351 return this->custom;
382 } 352 }
383}; 353};