Created
July 9, 2016 00:16
-
-
Save jameslkingsley/eb2ce08e16811906d5b4a93a12ad1d9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Author: Kingsley | |
* | |
* | |
* Arguments: | |
* | |
* | |
* Return Value: | |
* | |
* | |
* Example: | |
* | |
* | |
* Public: | |
*/ | |
#include "script_component.hpp" | |
#include "\z\mars\addons\common\macros.hpp" | |
#define LINE_WIDTH GRID_W | |
params [["_init", false, [false]]]; | |
if (_init) exitWith { | |
private _display = GETUVAR(GVAR(interface),displayNull); | |
private _ctrl = _display ctrlCreate ["MARS_gui_ctrlStaticBackground", IDC_SELBOX]; | |
_ctrl ctrlSetBackgroundColor [COLOR_DEFAULT_RGB, 0.5]; | |
_ctrl ctrlSetPosition [GVAR(mousePos) select 0, GVAR(mousePos) select 1, 0, 0]; | |
_ctrl ctrlCommit 0; | |
GVAR(selectionBoxStartPos) = GVAR(mousePos); | |
GVAR(isSelectionBoxSpawned) = true; | |
#ifdef DEBUG_MODE_FULL | |
MARS_LOGINFO("Created box controls"); | |
#endif | |
}; | |
GVAR(mousePos) params ["_mouseX", "_mouseY"]; | |
GVAR(selectionBoxStartPos) params ["_startX", "_startY"]; | |
private _display = GETUVAR(GVAR(interface),displayNull); | |
private _ctrl = _display displayCtrl IDC_SELBOX; | |
private _xDiff = _startX - _mouseX; | |
private _yDiff = _startY - _mouseY; | |
private _endX = _xDiff * -1; | |
private _endY = _yDiff * -1; | |
if (_xDiff < _startX) then { | |
_startX = _mouseX; | |
_endX = _xDiff; | |
}; | |
if (_yDiff < _startY) then { | |
_startY = _mouseY; | |
_endY = _yDiff; | |
}; | |
_ctrl ctrlSetPosition [ | |
_startX, | |
_startY, | |
_endX, | |
_endY | |
]; | |
_ctrl ctrlCommit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment