Split functionality for loading temporary controllers from a saved profile into its own function
This commit is contained in:
parent
24de16f77b
commit
da8c06756b
2 changed files with 133 additions and 93 deletions
|
|
@ -80,15 +80,12 @@ bool ProfileManager::LoadSizeFromProfile(std::string profile_name)
|
||||||
return(LoadProfileWithOptions(profile_name, true, false));
|
return(LoadProfileWithOptions(profile_name, true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::LoadProfileWithOptions
|
std::vector<RGBController*> ProfileManager::LoadProfileToList
|
||||||
(
|
(
|
||||||
std::string profile_name,
|
std::string profile_name
|
||||||
bool load_size,
|
|
||||||
bool load_settings
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::vector<RGBController*> temp_controllers;
|
std::vector<RGBController*> temp_controllers;
|
||||||
std::vector<bool> temp_controller_used;
|
|
||||||
unsigned int controller_size;
|
unsigned int controller_size;
|
||||||
unsigned int controller_offset = 0;
|
unsigned int controller_offset = 0;
|
||||||
bool ret_val = false;
|
bool ret_val = false;
|
||||||
|
|
@ -134,7 +131,6 @@ bool ProfileManager::LoadProfileWithOptions
|
||||||
temp_controller->ReadDeviceDescription(controller_data);
|
temp_controller->ReadDeviceDescription(controller_data);
|
||||||
|
|
||||||
temp_controllers.push_back(temp_controller);
|
temp_controllers.push_back(temp_controller);
|
||||||
temp_controller_used.push_back(false);
|
|
||||||
|
|
||||||
delete[] controller_data;
|
delete[] controller_data;
|
||||||
|
|
||||||
|
|
@ -143,6 +139,39 @@ bool ProfileManager::LoadProfileWithOptions
|
||||||
|
|
||||||
ret_val = true;
|
ret_val = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(temp_controllers);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProfileManager::LoadProfileWithOptions
|
||||||
|
(
|
||||||
|
std::string profile_name,
|
||||||
|
bool load_size,
|
||||||
|
bool load_settings
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<RGBController*> temp_controllers;
|
||||||
|
std::vector<bool> temp_controller_used;
|
||||||
|
bool ret_val = false;
|
||||||
|
|
||||||
|
std::string filename = profile_name;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Open input file in binary mode |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
temp_controllers = LoadProfileToList(profile_name);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Set up used flag vector |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
temp_controller_used.resize(temp_controllers.size());
|
||||||
|
|
||||||
|
for(unsigned int controller_idx = 0; controller_idx < temp_controller_used.size(); controller_idx++)
|
||||||
|
{
|
||||||
|
temp_controller_used[controller_idx] = false;
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------*\
|
/*---------------------------------------------------------*\
|
||||||
| Loop through all controllers. For each controller, search|
|
| Loop through all controllers. For each controller, search|
|
||||||
|
|
@ -243,7 +272,13 @@ bool ProfileManager::LoadProfileWithOptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Delete all temporary controllers |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
for(unsigned int controller_idx = 0; controller_idx < temp_controllers.size(); controller_idx++)
|
||||||
|
{
|
||||||
|
delete temp_controllers[controller_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
return(ret_val);
|
return(ret_val);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ public:
|
||||||
|
|
||||||
std::vector<std::string> profile_list;
|
std::vector<std::string> profile_list;
|
||||||
|
|
||||||
|
std::vector<RGBController*> ProfileManager::LoadProfileToList
|
||||||
|
(
|
||||||
|
std::string profile_name
|
||||||
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<RGBController *>& controllers;
|
std::vector<RGBController *>& controllers;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue