MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / OptionSize

Function OptionSize

cli.cpp:756–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

754}
755
756bool OptionSize(std::vector<DeviceOptions>* current_devices, std::string argument, Options* /*options*/, std::vector<RGBController *>& rgb_controllers)
757{
758 const unsigned int new_size = std::stoi(argument);
759
760 ResourceManager::get()->WaitForDeviceDetection();
761
762 for(size_t i = 0; i < current_devices->size(); i++)
763 {
764 int current_device = current_devices->at(i).device;
765 int current_zone = current_devices->at(i).zone;
766
767 /*---------------------------------------------------------*\
768 | Fail out if device, zone, or size are out of range |
769 \*---------------------------------------------------------*/
770 if((current_device >= static_cast<int>(rgb_controllers.size())) || (current_device < 0))
771 {
772 std::cout << "Error: Device is out of range" << std::endl;
773 return false;
774 }
775 else if((current_zone >= static_cast<int>(rgb_controllers[current_device]->zones.size())) || (current_zone < 0))
776 {
777 std::cout << "Error: Zone is out of range" << std::endl;
778 return false;
779 }
780 else if((new_size < rgb_controllers[current_device]->zones[current_zone].leds_min) || (new_size > rgb_controllers[current_device]->zones[current_zone].leds_max))
781 {
782 std::cout << "Error: New size is out of range" << std::endl;
783 }
784
785 /*---------------------------------------------------------*\
786 | Resize the zone |
787 \*---------------------------------------------------------*/
788 rgb_controllers[current_device]->ResizeZone(current_zone, new_size);
789
790 /*---------------------------------------------------------*\
791 | Save the profile |
792 \*---------------------------------------------------------*/
793 ResourceManager::get()->GetProfileManager()->SaveProfile("sizes", true);
794 }
795
796 return true;
797}
798
799bool OptionProfile(std::string argument, std::vector<RGBController *>& rgb_controllers)
800{

Callers 1

ProcessOptionsFunction · 0.85

Calls 6

GetProfileManagerMethod · 0.80
getFunction · 0.50
sizeMethod · 0.45
ResizeZoneMethod · 0.45
SaveProfileMethod · 0.45

Tested by

no test coverage detected