Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @Param 1 - ACTION:
- * STRING - String containing the action name, possible actions:
- * - init
- * - EH_KeyUp
- * - EH_KeyDown
- * - CreateDisplay
- * - DestroyDisplay
- * @Param 2 - PARAMETERS:
- * ARRAY, see:
- * @Action "init":
- * [
- * ARRAY - Array containing all valid KeysArrays for this action (KeyArray: [NIL, KeyToPress:SCALAR, ShiftState:BOOLEAN, CtrlState:BOOLEAN, AltState:BOOLEAN])
- * OBJECT - Object whichs vehicle partners are watches (most of the time should be player)
- * ]
- * @Action "EH_KeyUp", "EH_KeyDown":
- * [
- * ANY - Just added for simple compatibility with the displayEventHandlers (best to pass displayNull)
- * SCALAR - Key pressed
- * BOOLEAN - SHIFT state
- * BOOLEAN - CTRL state
- * BOOLEAN - ALT state
- * ]
- * @Action "CreateDisplay", "DestroyDisplay":
- * []
- */
- //Error Defines
- #define ERROR_COULD_NOT_CREATE_DISPLAY "Could not create display"
- #define ERROR_UNKNOWN_ACTION "Unknown action"
- //UI Defines
- #define uiPositionX 0.408837 * safezoneW + safezoneX
- #define uiPositionY 0.3834 * safezoneH + safezoneY
- #define uiPositionW 0.154687 * safezoneW
- #define uiPositionH 0.231 * safezoneH
- #define uiPosition [uiPositionX, uiPositionY, uiPositionW, uiPositionH]
- #define uiIDC 32001
- #define uiPictureColor [1, 1, 1, 1]
- //Macros
- #define uiVariable(VAR) (uiNamespace getVariable ["X39_XLib_var_VehicleDisplay", displayNull])
- private["_action"];
- _action = _this select 0;
- _this = _this select 1;
- switch(_action) do
- {
- case "init": {
- //Make sure the KeyArray passed has nil at first spot
- (_this select 0) set[0, nil];
- //Assign the different variables of this script
- X39_XLib_var_VehicleDisplay_ActionKeys = _this select 0;
- X39_XLib_var_VehicleDisplay_WatchedUnit = _this select 1;
- X39_XLib_var_VehicleDisplay_LastUnitsInVehicle = [];
- X39_XLib_var_VehicleDisplay_KeyEventHandler = [
- (findDisplay 46) displayAddEventHandler["KeyDown", {["EH_KeyDown", _this] call _fnc_scriptName;}],
- (findDisplay 46) displayAddEventHandler["KeyUp", {["EH_KeyUp", _this] call _fnc_scriptName;}]
- ];
- //Create the display element
- ["CreateDisplay", nil] call _fnc_scriptName;
- };
- case "EH_KeyUp": {
- //Clear display element and after that exit this function if it is not in our key list
- _this set[0, nil];
- if(!(_this in X39_XLib_var_VehicleDisplay_ActionKeys)) exitWith {};
- //Check if the vehicleDisplayUI has to be hidden
- if(ctrlShown uiVariable("X39_XLib_var_VehicleDisplay_UI")) then
- {
- uiVariable("X39_XLib_var_VehicleDisplay_UI") ctrlShow false;
- };
- };
- case "EH_KeyDown": {
- //Clear display element and after that exit this function if it is not in our key list
- _this set[0, nil];
- if(!(_this in X39_XLib_var_VehicleDisplay_ActionKeys)) exitWith {};
- private["_crew", "_index"];
- //check if we are currently in a vehicle and leave the script if we are not
- if(vehicle X39_XLib_var_VehicleDisplay_WatchedUnit == X39_XLib_var_VehicleDisplay_WatchedUnit) exitWith
- {
- if(ctrlShown uiVariable("X39_XLib_var_VehicleDisplay_UI")) then
- {
- uiVariable("X39_XLib_var_VehicleDisplay_UI") ctrlShow false;
- };
- };
- //get current crew of the vehicle and compare it to the last
- _crew = fullCrew vehicle X39_XLib_var_VehicleDisplay_WatchedUnit;
- if(!(X39_XLib_var_VehicleDisplay_LastUnitsInVehicle isEqualTo _crew)) then
- {
- //last crew differs from current crew, clear the listbox and update every crew entry
- X39_XLib_var_VehicleDisplay_LastUnitsInVehicle = _crew;
- lbClear uiVariable("X39_XLib_var_VehicleDisplay_UI");
- {
- _index = uiVariable("X39_XLib_var_VehicleDisplay_UI") lbAdd name (_x select 0);
- switch(toLower (_x select 1)) do
- {
- case "driver": {
- uiVariable("X39_XLib_var_VehicleDisplay_UI") lbSetPicture [_index, "a3\ui_f\data\IGUI\Cfg\Actions\getindriver_ca.paa"];
- };
- case "gunner"; case "turret": {
- uiVariable("X39_XLib_var_VehicleDisplay_UI") lbSetPicture [_index, "a3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa"];
- };
- case "commander": {
- uiVariable("X39_XLib_var_VehicleDisplay_UI") lbSetPicture [_index, "a3\ui_f\data\IGUI\Cfg\Actions\getincommander_ca.paa"];
- };
- default {
- uiVariable("X39_XLib_var_VehicleDisplay_UI") lbSetPicture [_index, "a3\ui_f\data\IGUI\Cfg\Actions\getincargo_ca.paa"];
- };
- };
- uiVariable("X39_XLib_var_VehicleDisplay_UI") lbSetPictureColor [_index, uiPictureColor];
- false
- }count _crew;
- };
- };
- case "CreateDisplay": {
- uiNamespace setVariable ["X39_XLib_var_VehicleDisplay_UI", (findDisplay 46) ctrlCreate ["RscListBox", uiIDC]];
- if(isNull uiVariable("X39_XLib_var_VehicleDisplay_UI")) then
- {
- throw ERROR_COULD_NOT_CREATE_DISPLAY;
- };
- uiVariable("X39_XLib_var_VehicleDisplay_UI") ctrlShow false;
- uiVariable("X39_XLib_var_VehicleDisplay_UI") ctrlSetPosition uiPosition;
- uiVariable("X39_XLib_var_VehicleDisplay_UI") ctrlCommit 0;
- };
- case "DestroyDisplay": {
- ctrlDelete uiVariable("X39_XLib_var_VehicleDisplay_UI");
- uiNamespace setVariable ["X39_XLib_var_VehicleDisplay_UI", nil];
- }:
- default {
- throw ERROR_UNKNOWN_ACTION;
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement