| 905 | } |
| 906 | |
| 907 | void IDrawableModule::AddUIControl(IUIControl* control) |
| 908 | { |
| 909 | try |
| 910 | { |
| 911 | std::string name = control->Name(); |
| 912 | if (CanModuleTypeSaveState() && name.empty() == false) |
| 913 | { |
| 914 | IUIControl* dupe = FindUIControl(name.c_str(), false); |
| 915 | if (dupe != nullptr) |
| 916 | { |
| 917 | if (dynamic_cast<ClickButton*>(control) != nullptr && dynamic_cast<ClickButton*>(dupe) != nullptr) |
| 918 | { |
| 919 | //they're both just buttons, this is fine |
| 920 | } |
| 921 | else if (!dupe->GetShouldSaveState()) |
| 922 | { |
| 923 | //we're duplicating the name of a non-saving ui control, assume that we are also not saving (hopefully that's true), and this is fine |
| 924 | } |
| 925 | else |
| 926 | { |
| 927 | assert(false); //can't have multiple ui controls with the same name! |
| 928 | } |
| 929 | } |
| 930 | } |
| 931 | } |
| 932 | catch (UnknownUIControlException& e) |
| 933 | { |
| 934 | } |
| 935 | |
| 936 | mUIControls.push_back(control); |
| 937 | FloatSlider* slider = dynamic_cast<FloatSlider*>(control); |
| 938 | if (slider) |
| 939 | { |
| 940 | mSliderMutex.lock(); |
| 941 | mFloatSliders.push_back(slider); |
| 942 | mSliderMutex.unlock(); |
| 943 | } |
| 944 | } |
| 945 | |
| 946 | void IDrawableModule::RemoveUIControl(IUIControl* control, bool cleanUpReferences /* = true */) |
| 947 | { |
no test coverage detected