fn_userMenuSelect.sqf 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Name: cTab_fnc_userMenuSelect
  3. Author(s):
  4. Gundy, Riouken
  5. Description:
  6. Process user menu select events, initiated by "\ClonecTab\shared\cTab_markerMenu_controls.hpp"
  7. Parameters:
  8. 0: INTEGER - Type of user menu select event - if this doesn't match a valid type it will be considered to be an IDC
  9. Returns:
  10. BOOLEAN - TRUE
  11. Example:
  12. [1] call cTab_fnc_userMenuSelect;
  13. */
  14. #include "\ClonecTab\shared\cTab_gui_macros.hpp"
  15. private ["_type","_displayName","_display","_idcToShow","_control","_controlPos","_screenPos","_screenEdgeX","_screenEdgeY","_controlEdgeX","_controlEdgeY"];
  16. disableSerialization;
  17. _type = _this select 0;
  18. _displayName = cTabIfOpen select 1;
  19. _display = (uiNamespace getVariable _displayName);
  20. _idcToShow = 0;
  21. call {
  22. // send cTabUserSelIcon to server
  23. if (_type == 1) exitWith {
  24. cTabUserSelIcon pushBack cTab_player;
  25. [call cTab_fnc_getPlayerEncryptionKey,cTabUserSelIcon] call cTab_fnc_addUserMarker;
  26. };
  27. // Lock UAV cam to clicked position
  28. if (_type == 2) exitWith {
  29. [cTabUserSelIcon select 0] call cTab_fnc_lockUavCamTo;
  30. };
  31. _idcToShow = call {
  32. if (_type == 11) exitWith {3301};
  33. if (_type == 12) exitWith {3303};
  34. if (_type == 13) exitWith {3304};
  35. if (_type == 14) exitWith {
  36. if (cTabUserSelIcon select 1 != 0) then {
  37. cTabUserSelIcon set [2,0];
  38. 3304
  39. } else {3307};
  40. };
  41. if (_type == 21) exitWith {3305};
  42. if (_type == 31) exitWith {3306};
  43. _type;
  44. };
  45. };
  46. // Hide all menu controls
  47. {ctrlShow [_x,false];} count [3300,3301,3302,3303,3304,3305,3306,3307];
  48. // Bring the menu control we want to show into position and show it
  49. if (_idcToShow != 0) then {
  50. _control = _display displayCtrl _idcToShow;
  51. if !(isNull _control) then {
  52. _controlPos = ctrlPosition _control;
  53. // figure out screen edge positions and where the edges of the control would be if we were just to move it blindly to cTabUserPos
  54. _screenPos = ctrlPosition (_display displayCtrl IDC_CTAB_LOADINGTXT);
  55. _screenEdgeX = (_screenPos select 0) + (_screenPos select 2);
  56. _screenEdgeY = (_screenPos select 1) + (_screenPos select 3);
  57. _controlEdgeX = (cTabUserPos select 0) + (_controlPos select 2);
  58. _controlEdgeY = (cTabUserPos select 1) + (_controlPos select 3);
  59. // if control would be clipping the right edge, correct control position
  60. if (_controlEdgeX > _screenEdgeX) then {
  61. _controlPos set [0,_screenEdgeX - (_controlPos select 2)];
  62. } else {
  63. _controlPos set [0,cTabUserPos select 0];
  64. };
  65. // if control would be clipping the bottom edge, correct control position
  66. if (_controlEdgeY > _screenEdgeY) then {
  67. _controlPos set [1,_screenEdgeY - (_controlPos select 3)];
  68. } else {
  69. _controlPos set [1,cTabUserPos select 1];
  70. };
  71. // move to position and show
  72. _control ctrlSetPosition _controlPos;
  73. _control ctrlCommit 0;
  74. _control ctrlShow true;
  75. ctrlSetFocus _control;
  76. };
  77. };
  78. true