fn_setInterfacePosition.sqf 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Name: cTab_fnc_setInterfacePosition
  3. Author(s):
  4. Gundy
  5. Description:
  6. Move the whole interface by a provided offset
  7. Parameters:
  8. 0: STRING - uiNamespace variable name of interface
  9. 1: ARRAY - offset in the form of [x,y]
  10. Returns:
  11. BOOLEAN - TRUE
  12. Example:
  13. ["cTab_Tablet_dlg",[0.2,0.1]] call cTab_fnc_setInterfacePosition;
  14. */
  15. private ["_displayName","_xOffset","_yOffset","_display","_isDialog","_backgroundCtrl","_backgroundClassName","_displayConfigContainers","_displayConfigClasses","_idc","_ctrl","_ctrlPosition"];
  16. disableSerialization;
  17. _displayName = _this select 0;
  18. _xOffset = _this select 1 select 0;
  19. _yOffset = _this select 1 select 1;
  20. _display = uiNamespace getVariable _displayName;
  21. _isDialog = [_displayName] call cTab_fnc_isDialog;
  22. // get both classes "controls" and "controlsBackground" if they exist
  23. _displayConfigContainers = if (_isDialog) then {
  24. "true" configClasses (configFile >> _displayName)
  25. } else {
  26. "true" configClasses (configFile >> "RscTitles" >> _displayName)
  27. };
  28. {
  29. if (isClass _x) then {
  30. _displayConfigClasses = "true" configClasses _x;
  31. {
  32. if (isClass _x) then {
  33. if (isNumber (_x >> "idc")) then {
  34. _idc = getNumber (_x >> "idc");
  35. if (_idc > 0) then {
  36. _ctrl = _display displayCtrl _idc;
  37. _ctrlPosition = ctrlPosition _ctrl;
  38. _ctrlPosition set [0,(_ctrlPosition select 0) + _xOffset];
  39. _ctrlPosition set [1,(_ctrlPosition select 1) + _yOffset];
  40. _ctrl ctrlSetPosition _ctrlPosition;
  41. _ctrl ctrlCommit 0;
  42. } else {diag_log str ["invalid IDC",_x]};
  43. } else {diag_log str ["missing IDC",_x]};
  44. };
  45. } forEach _displayConfigClasses;
  46. };
  47. } forEach _displayConfigContainers;
  48. true