This commit is contained in:
PabstMirror 2015-03-27 20:51:30 -05:00
parent 63b7f0a755
commit 24bba5dea6
10 changed files with 254 additions and 163 deletions

View File

@ -1,4 +1,3 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));

View File

@ -1,4 +1,19 @@
// stuff taken from bohemia, edited by commy2
/*
* Author: BIS, commy2
* Sets up the marker placement
* Replaces \a3\ui_f\scripts\GUI\RscDisplayInsertMarker.sqf
*
* Arguments:
* 0: RscDisplayInsertMarker <DISPLAY>
*
* Return Value:
* Nothing
*
* Example:
* [onLoad] call ace_markers_fnc_initInsertMarker;
*
* Public: No
*/
#include "script_component.hpp"
#define BORDER 0.005
@ -7,15 +22,15 @@
disableserialization;
_display = _this select 0;
//Prevent Captive Players from placing markers
/*if (ACE_player getVariable ["ACE_isCaptive", false]) exitWith {
//Can't place markers when can't interact
if (!([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith))) exitWith {
_display closeDisplay 2; //emulate "Cancel" button
};*/
};
// prevent vanilla key input
_display displayAddEventHandler ["KeyDown", {(_this select 1) in [200, 208]}];
//BIS Controlls:
//BIS Controls:
_text = _display displayctrl 101;
_picture = _display displayctrl 102;
_channel = _display displayctrl 103;
@ -25,13 +40,13 @@
_title = _display displayctrl 1001;
_descriptionChannel = _display displayctrl 1101;
//ACE Controlls:
//ACE Controls:
// _sizeX = _display displayctrl 1200;
// _sizeY = _display displayctrl 1201;
_shape = _display displayctrl 1210;
_color = _display displayctrl 1211;
_angle = _display displayctrl 1220;
_angleText = _display displayctrl 1221;
_aceShapeLB = _display displayctrl 1210;
_aceColorLB = _display displayctrl 1211;
_aceAngleSlider = _display displayctrl 1220;
_aceAngleSliderText = _display displayctrl 1221;
ctrlSetFocus _text;
@ -41,7 +56,7 @@
_posY = _pos select 1;
_posW = _pos select 2;
_posH = _pos select 3;
_posY = _posY min ((safeZoneH + safeZoneY) - (6 * _posH + 8 * BORDER)); //prevent buttons being placed below bottom edge of screen
_posY = _posY min ((safeZoneH + safeZoneY) - (8 * _posH + 8 * BORDER)); //prevent buttons being placed below bottom edge of screen
_pos set [0,_posX];
_pos set [1,_posY];
_text ctrlsetposition _pos;
@ -65,29 +80,29 @@
_pos set [1,_posY + 1 * _posH + 2 * BORDER];
_pos set [2,_posW];
_pos set [3,_posH];
_shape ctrlsetposition _pos;
_shape ctrlcommit 0;
_aceShapeLB ctrlsetposition _pos;
_aceShapeLB ctrlcommit 0;
//--- Color
_pos set [1,_posY + 2 * _posH + 3 * BORDER];
_pos set [2,_posW];
_color ctrlsetposition _pos;
_color ctrlcommit 0;
_aceColorLB ctrlsetposition _pos;
_aceColorLB ctrlcommit 0;
//--- Angle
_pos set [1,_posY + 3 * _posH + 4 * BORDER];
_pos set [2,_posW];
_angle ctrlsetposition _pos;
_angle ctrlcommit 0;
_aceAngleSlider ctrlsetposition _pos;
_aceAngleSlider ctrlcommit 0;
//--- Angle Text
_pos set [1,_posY + 4 * _posH + 5 * BORDER];
_pos set [2,_posW];
_angleText ctrlsetposition _pos;
_angleText ctrlcommit 0;
_aceAngleSliderText ctrlsetposition _pos;
_aceAngleSliderText ctrlcommit 0;
_offsetButtons = 0;
if (ismultiplayer) then {
if (isMultiplayer) then {
_pos set [1,_posY + 5 * _posH + 7 * BORDER];
_pos set [3,_posH];
_descriptionChannel ctrlsetstructuredtext parsetext format ["<t size='0.8'>%1</t>", (localize "str_a3_cfgvehicles_modulerespawnposition_f_arguments_marker_0") + ":"];
@ -132,56 +147,41 @@
// init marker shape lb
lbClear _aceShapeLB;
{
_shape lbAdd (_x select 0);
_shape lbSetValue [_forEachIndex, _x select 1];
_shape lbSetPicture [_forEachIndex, _x select 2];
_aceShapeLB lbAdd (_x select 0);
_aceShapeLB lbSetValue [_forEachIndex, _x select 1];
_aceShapeLB lbSetPicture [_forEachIndex, _x select 2];
} forEach GVAR(MarkersCache);
_shape ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedShape)}];
_curSelShape = GETGVAR(curSelMarkerShape,0);
_shape lbSetCurSel _curSelShape;
_data = _shape lbValue _curSelShape;
_config = (configfile >> "CfgMarkers") select _data;
_icon = getText (_config >> "icon");
_picture ctrlSetText _icon;
_aceShapeLB lbSetCurSel _curSelShape;
//Update now and add eventHandler:
[_aceShapeLB, _curSelShape] call FUNC(onLBSelChangedShape);
_aceShapeLB ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedShape)}];
// init marker color lb
lbClear _aceColorLB;
{
_color lbAdd (_x select 0);
_color lbSetValue [_forEachIndex, _x select 1];
_color lbSetPicture [_forEachIndex, _x select 2];
_aceColorLB lbAdd (_x select 0);
_aceColorLB lbSetValue [_forEachIndex, _x select 1];
_aceColorLB lbSetPicture [_forEachIndex, _x select 2];
} forEach GVAR(MarkerColorsCache);
_color ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedColor)}];
_curSelColor = GETGVAR(curSelMarkerColor,0);
_color lbSetCurSel _curSelColor;
_data = _color lbValue _curSelColor;
_config = (configfile >> "CfgMarkerColors") select _data;
_rgba = getArray (_config >> "color");
{
if (typeName _x != "SCALAR") then {
_rgba set [_forEachIndex, call compile _x];
};
} forEach _rgba;
_picture ctrlSetTextColor _rgba;
_aceColorLB lbSetCurSel _curSelColor;
//Update now and add eventHandler:
[_aceColorLB, _curSelColor] call FUNC(onLBSelChangedColor);
_aceColorLB ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedColor)}];
// init marker angle slider
_angle sliderSetRange [-180, 180];
_angle ctrlAddEventHandler ["SliderPosChanged", {_this call FUNC(onSliderPosChangedAngle)}];
_curSelAngle = GETGVAR(curSelMarkerAngle,0);
_angle sliderSetPosition _curSelAngle;
_curSelAngle = round _curSelAngle;
if (_curSelAngle < 0) then {
_curSelAngle = _curSelAngle + 360;
};
_angleText ctrlSetText format [localize "STR_ACE_Markers_MarkerDirection", _curSelAngle];
_aceAngleSlider sliderSetRange [-180, 180];
_curSelAngle = GETGVAR(currentMarkerAngle,0);
_aceAngleSlider sliderSetPosition _curSelAngle;
//Update now and add eventHandler:
[_aceAngleSlider, _curSelAngle] call FUNC(onSliderPosChangedAngle);
_aceAngleSlider ctrlAddEventHandler ["SliderPosChanged", {_this call FUNC(onSliderPosChangedAngle)}];
}, _this] call EFUNC(common,execNextFrame);

View File

@ -1,17 +1,33 @@
// by commy2
/*
* Author: commy2
* When the color list box is changed.
*
* Arguments:
* 0: Color ListBox (idc 1211) <CONTROL>
* 1: Selected Index <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [ColorLB, 5] call ace_markers_fnc_onLBSelChangedColor;
*
* Public: No
*/
#include "script_component.hpp"
private ["_ctrl", "_data", "_config", "_color"];
private ["_data", "_config", "_color"];
_ctrl = _this select 0;
_data = _ctrl lbValue (_this select 1);
PARAMS_2(_ctrl,_index);
_data = _ctrl lbValue _index;
GVAR(curSelMarkerColor) = _this select 1;
GVAR(curSelMarkerColor) = _index;
_config = (configfile >> "CfgMarkerColors") select _data;
_color = getArray (_config >> "color");
//Array could be strings of code that need to be converted:
{
if (typeName _x != "SCALAR") then {
_color set [_forEachIndex, call compile _x];

View File

@ -1,12 +1,27 @@
// by commy2
/*
* Author: commy2
* When the shape list box is changed.
*
* Arguments:
* 0: Shape ListBox (idc 1210) <CONTROL>
* 1: Selected Index <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [ColorLB, 5] call ace_markers_fnc_onLBSelChangedShape;
*
* Public: No
*/
#include "script_component.hpp"
private ["_ctrl", "_data", "_config", "_icon"];
private ["_data", "_config", "_icon"];
_ctrl = _this select 0;
_data = _ctrl lbValue (_this select 1);
PARAMS_2(_ctrl,_index);
_data = _ctrl lbValue _index;
GVAR(curSelMarkerShape) = _this select 1;
GVAR(curSelMarkerShape) = _index;
_config = (configfile >> "CfgMarkers") select _data;

View File

@ -1,12 +1,24 @@
// by commy2
/*
* Author: commy2
* Angle Slider Pos changed
*
* Arguments:
* 0: Slider (idc 1210) <CONTROL>
* 1: Slider Data (angle: -180..180) <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [Slider, 2] call ace_markers_fnc_onSliderPosChangedAngle;
*
* Public: No
*/
#include "script_component.hpp"
private ["_ctrl", "_data", "_direction"];
private ["_direction"];
_ctrl = _this select 0;
_data = _this select 1;
GVAR(curSelMarkerAngle) = _data;
PARAMS_2(_ctrl,_data);
_direction = round _data;
if (_direction < 0) then {

View File

@ -1,46 +1,61 @@
// by commy2
/*
* Author: commy2
* MarkerPlacement closed
*
* Arguments:
* 0: RscDisplayInsertMarker <DISPLAY>
* 1: CloseNumber (1 = ButtonOk) <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [onUnloadEvent] call ace_markers_fnc_placeMarker;
*
* Public: No
*/
#include "script_component.hpp"
if (_this select 1 == 1) then {
PARAMS_2(_display,_closeNum);
if (_closeNum == 1) then {
disableserialization;
_display = _this select 0;
_pos = ctrlPosition (_display displayCtrl 102);
_pos = [
(_pos select 0) + (_pos select 2) / 2,
(_pos select 1) + (_pos select 3) / 2
(_pos select 0) + (_pos select 2) / 2,
(_pos select 1) + (_pos select 3) / 2
];
switch (true) do {
case (!isNull findDisplay 12): {
case (!isNull findDisplay 12): {
_pos = (findDisplay 12 displayCtrl 51) ctrlMapScreenToWorld _pos;
};
case (!isNull findDisplay 37): {
case (!isNull findDisplay 37): {
_pos = (findDisplay 37 displayCtrl 51) ctrlMapScreenToWorld _pos;
};
case (!isNull findDisplay 52): {
case (!isNull findDisplay 52): {
_pos = (findDisplay 52 displayCtrl 51) ctrlMapScreenToWorld _pos;
};
case (!isNull findDisplay 53): {
case (!isNull findDisplay 53): {
_pos = (findDisplay 53 displayCtrl 51) ctrlMapScreenToWorld _pos;
};
};
// set and send marker data the next frame. the actual marker isn't created yet
[
{
{
[QGVAR(setMarkerNetwork), [
allMapMarkers select (count allMapMarkers - 1), [
GETGVAR(currentMarkerConfigName,""),
GETGVAR(currentMarkerColorConfigName,""),
_this,
GETGVAR(currentMarkerAngle,0)
]
]] call EFUNC(common,globalEvent);
[QGVAR(setMarkerNetwork), [
allMapMarkers select (count allMapMarkers - 1), [
GETGVAR(currentMarkerConfigName,""),
GETGVAR(currentMarkerColorConfigName,""),
_this,
GETGVAR(currentMarkerAngle,0)
]
]] call EFUNC(common,globalEvent);
},
_pos
},
_pos
] call EFUNC(common,execNextFrame);
};

View File

@ -1,13 +1,25 @@
// by commy2
/*
* Author: commy2
* Server: Recives a dummy logic, sends marker data back to the owner.
*
* Arguments:
* 0: Logic <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [onUnloadEvent] call ace_markers_fnc_sendMarkerJIP;
*
* Public: No
*/
#include "script_component.hpp"
private "_logic";
PARAMS_1(_logic);
_logic = _this;
[QGVAR(setMarkerJIP), _logic, [
GETGVAR(allMapMarkers,[]),
GETGVAR(allMapMarkersProperties,[]),
_logic
]
[QGVAR(setMarkerJIP), [_logic], [
GETGVAR(allMapMarkers,[]),
GETGVAR(allMapMarkersProperties,[]),
_logic
]
] call EFUNC(common,targetEvent);

View File

@ -1,35 +1,49 @@
// by commy2
/*
* Author: commy2
* Client: Recives a marker data from server.
*
* Arguments:
* 0: Array of map marker names <ARRAY>
* 1: Array of map marker data <ARRAY>
* 2: Logic <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [[],[],dummyLogic] call ace_markers_fnc_setMarkerJIP;
*
* Public: No
*/
#include "script_component.hpp"
private ["_allMapMarkers", "_allMapMarkersProperties", "_index", "_data", "_config"];
private ["_index", "_data", "_config"];
_allMapMarkers = _this select 0;
_allMapMarkersProperties = _this select 1;
_logic = _this select 2;
PARAMS_3(_allMapMarkers,_allMapMarkersProperties,_logic);
{
_index = _allMapMarkers find _x;
_index = _allMapMarkers find _x;
if (_index != -1) then {
_data = _allMapMarkersProperties select _index;
if (_index != -1) then {
_data = _allMapMarkersProperties select _index;
_config = (configfile >> "CfgMarkers") >> (_data select 0);
if (!isClass _config) then {
WARNING("CfgMarker not found, changed to milDot");
_config == (configFile >> "CfgMarkers" >> "MilDot");
_config = (configfile >> "CfgMarkers") >> (_data select 0);
if (!isClass _config) then {
WARNING("CfgMarker not found, changed to milDot");
_config == (configFile >> "CfgMarkers" >> "MilDot");
};
_x setMarkerTypeLocal (configName _config);
_config = (configfile >> "CfgMarkerColors") >> (_data select 1);
if (!isClass _config) then {
WARNING("CfgMarkerColors not found, changed to Default");
_config == (configFile >> "CfgMarkerColors" >> "Default");
};
_x setMarkerColorLocal (configName _config);
_x setMarkerPosLocal (_data select 2);
_x setMarkerDirLocal (_data select 3);
};
_x setMarkerTypeLocal (configName _config);
_config = (configfile >> "CfgMarkerColors") >> (_data select 1);
if (!isClass _config) then {
WARNING("CfgMarkerColors not found, changed to Default");
_config == (configFile >> "CfgMarkerColors" >> "Default");
};
_x setMarkerColorLocal (configName _config);
_x setMarkerPosLocal (_data select 2);
_x setMarkerDirLocal (_data select 3);
};
} forEach allMapMarkers;
deleteVehicle _logic;

View File

@ -1,45 +1,61 @@
// by commy2
/*
* Author: commy2
* Sets newly placed marker
* Handles the QGVAR(setMarkerNetwork) event.
*
* Arguments:
* 0: Markername <STRING>
* 1: Marker Data <ARRAY>
*
* Return Value:
* Nothing
*
* Example:
* [[],[],dummyLogic] call ace_markers_fnc_setMarkerJIP;
*
* Public: No
*/
#include "script_component.hpp"
private ["_marker", "_data", "_config"];
private ["_config"];
_marker = _this select 0;
_data = _this select 1;
PARAMS_2(_marker,_data);
EXPLODE_4_PVT(_data,_markerClassname,_colorClassname,_markerPos,_markerDir);
_config = (configfile >> "CfgMarkers") >> (_data select 0);
_config = (configfile >> "CfgMarkers") >> _markerClassname;
if (!isClass _config) then {
WARNING("CfgMarker not found, changed to milDot");
_config == (configFile >> "CfgMarkers" >> "MilDot");
WARNING("CfgMarker not found, changed to milDot");
_config == (configFile >> "CfgMarkers" >> "MilDot");
};
_marker setMarkerTypeLocal (configName _config);
_config = (configfile >> "CfgMarkerColors") >> (_data select 1);
_config = (configfile >> "CfgMarkerColors") >> _colorClassname;
if (!isClass _config) then {
WARNING("CfgMarkerColors not found, changed to Default");
_config == (configFile >> "CfgMarkerColors" >> "Default");
WARNING("CfgMarkerColors not found, changed to Default");
_config == (configFile >> "CfgMarkerColors" >> "Default");
};
_marker setMarkerColorLocal configName _config;
_marker setMarkerPosLocal (_data select 2);
_marker setMarkerDirLocal (_data select 3);
_marker setMarkerPosLocal _markerPos;
_marker setMarkerDirLocal _markerDir;
// save properties on server machine for JIP, marker editing ready
if (isMultiplayer && {isServer}) then {
private ["_allMapMarkers", "_allMapMarkersProperties", "_index"];
private ["_allMapMarkers", "_allMapMarkersProperties", "_index"];
_allMapMarkers = GETMVAR(allMapMarkers,[]);
_allMapMarkersProperties = GETMVAR(allMapMarkersProperties,[]);
_allMapMarkers = GETMVAR(allMapMarkers,[]);
_allMapMarkersProperties = GETMVAR(allMapMarkersProperties,[]);
_index = _allMapMarkers find _marker;
_index = _allMapMarkers find _marker;
if (_index == -1) then {
_allMapMarkers pushBack _marker;
_allMapMarkersProperties pushBack _data;
} else {
_allMapMarkers set [_index, _marker];
_allMapMarkersProperties set [_index, _data];
};
if (_index == -1) then {
_allMapMarkers pushBack _marker;
_allMapMarkersProperties pushBack _data;
} else {
_allMapMarkers set [_index, _marker];
_allMapMarkersProperties set [_index, _data];
};
GVAR(allMapMarkers) = _allMapMarkers;
GVAR(allMapMarkersProperties) = _allMapMarkersProperties;
GVAR(allMapMarkers) = _allMapMarkers;
GVAR(allMapMarkersProperties) = _allMapMarkersProperties;
};

View File

@ -11,13 +11,5 @@
<Spanish>Dirección: %1°</Spanish>
<Russian>Направление: %1</Russian>
</Key>
<Key ID="STR_ACE_Markers_PlaceIn">
<English>Place in: %1</English>
<German>Platz in: %1</German>
<Spanish>Colocar en: %1</Spanish>
<Polish>Umieść na: %1</Polish>
<Czech>Umístit do: %1</Czech>
<Russian>Место в: %1</Russian>
</Key>
</Package>
</Project>