mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:40:06 +00:00 
			
		
		
		
	Save loop delay, speed, and time to settings on shutdown
This commit is contained in:
		
							parent
							
								
									8f0afbcd1c
								
							
						
					
					
						commit
						e8e3032dcd
					
				
					 11 changed files with 138 additions and 19 deletions
				
			
		|  | @ -33,6 +33,9 @@ public: | |||
|       defaultAlertAction_.SetDefault(defaultDefaultAlertActionValue); | ||||
|       defaultRadarSite_.SetDefault("KLSX"); | ||||
|       fontSizes_.SetDefault({16}); | ||||
|       loopDelay_.SetDefault(2500); | ||||
|       loopSpeed_.SetDefault(5.0); | ||||
|       loopTime_.SetDefault(30); | ||||
|       gridWidth_.SetDefault(1); | ||||
|       gridHeight_.SetDefault(1); | ||||
|       mapProvider_.SetDefault(defaultMapProviderValue); | ||||
|  | @ -48,6 +51,12 @@ public: | |||
|       gridWidth_.SetMaximum(2); | ||||
|       gridHeight_.SetMinimum(1); | ||||
|       gridHeight_.SetMaximum(2); | ||||
|       loopDelay_.SetMinimum(0); | ||||
|       loopDelay_.SetMaximum(15000); | ||||
|       loopSpeed_.SetMinimum(1.0); | ||||
|       loopSpeed_.SetMaximum(99.99); | ||||
|       loopTime_.SetMinimum(1); | ||||
|       loopTime_.SetMaximum(1440); | ||||
| 
 | ||||
|       defaultAlertAction_.SetValidator( | ||||
|          [](const std::string& value) | ||||
|  | @ -101,6 +110,9 @@ public: | |||
|    SettingsContainer<std::vector<std::int64_t>> fontSizes_ {"font_sizes"}; | ||||
|    SettingsVariable<std::int64_t>               gridWidth_ {"grid_width"}; | ||||
|    SettingsVariable<std::int64_t>               gridHeight_ {"grid_height"}; | ||||
|    SettingsVariable<std::int64_t>               loopDelay_ {"loop_delay"}; | ||||
|    SettingsVariable<double>                     loopSpeed_ {"loop_speed"}; | ||||
|    SettingsVariable<std::int64_t>               loopTime_ {"loop_time"}; | ||||
|    SettingsVariable<std::string>                mapProvider_ {"map_provider"}; | ||||
|    SettingsVariable<std::string> mapboxApiKey_ {"mapbox_api_key"}; | ||||
|    SettingsVariable<std::string> maptilerApiKey_ {"maptiler_api_key"}; | ||||
|  | @ -116,6 +128,9 @@ GeneralSettings::GeneralSettings() : | |||
|                       &p->fontSizes_, | ||||
|                       &p->gridWidth_, | ||||
|                       &p->gridHeight_, | ||||
|                       &p->loopDelay_, | ||||
|                       &p->loopSpeed_, | ||||
|                       &p->loopTime_, | ||||
|                       &p->mapProvider_, | ||||
|                       &p->mapboxApiKey_, | ||||
|                       &p->maptilerApiKey_, | ||||
|  | @ -159,6 +174,21 @@ SettingsVariable<std::int64_t>& GeneralSettings::grid_width() const | |||
|    return p->gridWidth_; | ||||
| } | ||||
| 
 | ||||
| SettingsVariable<std::int64_t>& GeneralSettings::loop_delay() const | ||||
| { | ||||
|    return p->loopDelay_; | ||||
| } | ||||
| 
 | ||||
| SettingsVariable<double>& GeneralSettings::loop_speed() const | ||||
| { | ||||
|    return p->loopSpeed_; | ||||
| } | ||||
| 
 | ||||
| SettingsVariable<std::int64_t>& GeneralSettings::loop_time() const | ||||
| { | ||||
|    return p->loopTime_; | ||||
| } | ||||
| 
 | ||||
| SettingsVariable<std::string>& GeneralSettings::map_provider() const | ||||
| { | ||||
|    return p->mapProvider_; | ||||
|  | @ -179,6 +209,18 @@ SettingsVariable<bool>& GeneralSettings::update_notifications_enabled() const | |||
|    return p->updateNotificationsEnabled_; | ||||
| } | ||||
| 
 | ||||
| bool GeneralSettings::Shutdown() | ||||
| { | ||||
|    bool dataChanged = false; | ||||
| 
 | ||||
|    // Commit settings that are managed separate from the settings dialog
 | ||||
|    dataChanged |= p->loopDelay_.Commit(); | ||||
|    dataChanged |= p->loopSpeed_.Commit(); | ||||
|    dataChanged |= p->loopTime_.Commit(); | ||||
| 
 | ||||
|    return dataChanged; | ||||
| } | ||||
| 
 | ||||
| bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs) | ||||
| { | ||||
|    return (lhs.p->debugEnabled_ == rhs.p->debugEnabled_ && | ||||
|  | @ -187,6 +229,9 @@ bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs) | |||
|            lhs.p->fontSizes_ == rhs.p->fontSizes_ && | ||||
|            lhs.p->gridWidth_ == rhs.p->gridWidth_ && | ||||
|            lhs.p->gridHeight_ == rhs.p->gridHeight_ && | ||||
|            lhs.p->loopDelay_ == rhs.p->loopDelay_ && | ||||
|            lhs.p->loopSpeed_ == rhs.p->loopSpeed_ && | ||||
|            lhs.p->loopTime_ == rhs.p->loopTime_ && | ||||
|            lhs.p->mapProvider_ == rhs.p->mapProvider_ && | ||||
|            lhs.p->mapboxApiKey_ == rhs.p->mapboxApiKey_ && | ||||
|            lhs.p->maptilerApiKey_ == rhs.p->maptilerApiKey_ && | ||||
|  |  | |||
|  | @ -33,6 +33,9 @@ public: | |||
|    SettingsContainer<std::vector<std::int64_t>>& font_sizes() const; | ||||
|    SettingsVariable<std::int64_t>&               grid_height() const; | ||||
|    SettingsVariable<std::int64_t>&               grid_width() const; | ||||
|    SettingsVariable<std::int64_t>&               loop_delay() const; | ||||
|    SettingsVariable<double>&                     loop_speed() const; | ||||
|    SettingsVariable<std::int64_t>&               loop_time() const; | ||||
|    SettingsVariable<std::string>&                map_provider() const; | ||||
|    SettingsVariable<std::string>&                mapbox_api_key() const; | ||||
|    SettingsVariable<std::string>&                maptiler_api_key() const; | ||||
|  | @ -41,6 +44,8 @@ public: | |||
|    friend bool operator==(const GeneralSettings& lhs, | ||||
|                           const GeneralSettings& rhs); | ||||
| 
 | ||||
|    bool Shutdown(); | ||||
| 
 | ||||
| private: | ||||
|    std::unique_ptr<GeneralSettingsImpl> p; | ||||
| }; | ||||
|  |  | |||
|  | @ -51,7 +51,8 @@ SettingsVariable<T>::operator=(SettingsVariable&&) noexcept = default; | |||
| template<class T> | ||||
| inline auto FormatParameter(const T& value) | ||||
| { | ||||
|    if constexpr (std::is_integral_v<T> || std::is_same_v<T, std::string>) | ||||
|    if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T> || | ||||
|                  std::is_same_v<T, std::string>) | ||||
|    { | ||||
|       return value; | ||||
|    } | ||||
|  |  | |||
|  | @ -208,6 +208,7 @@ private: | |||
| 
 | ||||
| #ifdef SETTINGS_VARIABLE_IMPLEMENTATION | ||||
| template class SettingsVariable<bool>; | ||||
| template class SettingsVariable<double>; | ||||
| template class SettingsVariable<std::int64_t>; | ||||
| template class SettingsVariable<std::string>; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat