fn_getBackgroundPosition.sqf 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. Name: cTab_fnc_getBackgroundPosition
  3. Author(s):
  4. Gundy
  5. Description:
  6. Get the current and config position of the interface background element
  7. Parameters:
  8. 0: STRING - uiNamespace variable name of interface
  9. Returns:
  10. ARRAY - interface position and config position
  11. 0: ARRAY - interface position in the form of [x,y,w,h]
  12. 1: ARRAY - interface config position in the form of [x,y,w,h], empty array if background could not be found
  13. Example:
  14. ["cTab_Tablet_dlg"] call cTab_fnc_getBackgroundPosition;
  15. */
  16. #include "\ClonecTab\shared\cTab_gui_macros.hpp"
  17. private ["_displayName","_display","_isDialog","_backgroundCtrl","_backgroundClassName","_backgroundPosition","_backgroundConfigPosition","_displayConfigContainers"];
  18. _displayName = _this select 0;
  19. _display = uiNamespace getVariable _displayName;
  20. _isDialog = [_displayName] call cTab_fnc_isDialog;
  21. // get both classes "controls" and "controlsBackground" if they exist
  22. _displayConfigContainers = if (_isDialog) then {
  23. "true" configClasses (configFile >> _displayName)
  24. } else {
  25. "true" configClasses (configFile >> "RscTitles" >> _displayName)
  26. };
  27. // get the class name and current position
  28. _backgroundCtrl = _display displayCtrl IDC_CTAB_BACKGROUND;
  29. _backgroundClassName = ctrlClassName _backgroundCtrl;
  30. _backgroundPosition = ctrlPosition _backgroundCtrl;
  31. // get the original position of the background control
  32. _backgroundConfigPosition = [];
  33. {
  34. if (isClass _x) then {
  35. if (isClass (_x >> _backgroundClassName)) exitWith {
  36. _backgroundConfigPosition = [
  37. getNumber (_x >> _backgroundClassName >> "x"),
  38. getNumber (_x >> _backgroundClassName >> "y"),
  39. getNumber (_x >> _backgroundClassName >> "w"),
  40. getNumber (_x >> _backgroundClassName >> "h")
  41. ];
  42. };
  43. };
  44. } forEach _displayConfigContainers;
  45. [_backgroundPosition,_backgroundConfigPosition]