From 2144a56be15544e54b289b0f1af7c972e2919b17 Mon Sep 17 00:00:00 2001 From: voiper Date: Tue, 11 Aug 2015 10:49:39 -0700 Subject: [PATCH] Fix attempt. --- addons/map/ACE_Settings.hpp | 4 + addons/map/CfgAmmo.hpp | 48 +++++++ addons/map/CfgSounds.hpp | 7 + addons/map/CfgVehicles.hpp | 29 +++- addons/map/XEH_postInitClient.sqf | 66 +++++++-- addons/map/XEH_preInit.sqf | 5 + addons/map/config.cpp | 2 + .../functions/fnc_blueForceTrackingModule.sqf | 9 +- .../functions/fnc_compileFlashlightMenu.sqf | 65 +++++++++ .../map/functions/fnc_determineMapLight.sqf | 4 +- addons/map/functions/fnc_flashlightGlow.sqf | 41 ++++++ .../map/functions/fnc_getUnitFlashlights.sqf | 29 ++++ addons/map/functions/fnc_moduleMap.sqf | 4 +- addons/map/functions/fnc_simulateMapLight.sqf | 136 ++++++++++++++++++ addons/map/functions/fnc_switchFlashlight.sqf | 25 ++++ addons/map/functions/fnc_updateMapEffects.sqf | 24 ++-- addons/map/stringtable.xml | 45 ++++-- 17 files changed, 502 insertions(+), 41 deletions(-) create mode 100644 addons/map/CfgAmmo.hpp create mode 100644 addons/map/CfgSounds.hpp create mode 100644 addons/map/functions/fnc_compileFlashlightMenu.sqf create mode 100644 addons/map/functions/fnc_flashlightGlow.sqf create mode 100644 addons/map/functions/fnc_getUnitFlashlights.sqf create mode 100644 addons/map/functions/fnc_simulateMapLight.sqf create mode 100644 addons/map/functions/fnc_switchFlashlight.sqf diff --git a/addons/map/ACE_Settings.hpp b/addons/map/ACE_Settings.hpp index 15e2a174e4..4e2a5d5706 100644 --- a/addons/map/ACE_Settings.hpp +++ b/addons/map/ACE_Settings.hpp @@ -15,6 +15,10 @@ class ACE_Settings { value = 1; typeName = "BOOL"; }; + class GVAR(mapGlow) { + value = 1; + typeName = "BOOL"; + }; class GVAR(mapShake) { value = 1; typeName = "BOOL"; diff --git a/addons/map/CfgAmmo.hpp b/addons/map/CfgAmmo.hpp new file mode 100644 index 0000000000..59d91d68f4 --- /dev/null +++ b/addons/map/CfgAmmo.hpp @@ -0,0 +1,48 @@ +class CfgAmmo { + + class FlareCore; + + class FlareBase: FlareCore {}; + class F_20mm_White: FlareBase {}; + + class ACE_FlashlightProxy_White: F_20mm_White { + model = ""; + effectFlare = "FlareShell"; + + triggerTime = 0; + intensity = 1; + flareSize = 1; + timeToLive = 10e10; + + lightColor[] = {1,1,1,1}; + + grenadeBurningSound[] = {}; + grenadeFireSound[] = {}; + soundTrigger[] = {}; + SmokeShellSoundHit1[] = {}; + SmokeShellSoundHit2[] = {}; + SmokeShellSoundHit3[] = {}; + SmokeShellSoundLoop1[] = {}; + SmokeShellSoundLoop2[] = {}; + }; + + class ACE_FlashlightProxy_Red: ACE_FlashlightProxy_White { + intensity = 2.5; + lightColor[] = {1,0,0,1}; + }; + + class ACE_FlashlightProxy_Green: ACE_FlashlightProxy_White { + intensity = 1.5; + lightColor[] = {0,1,0,1}; + }; + + class ACE_FlashlightProxy_Blue: ACE_FlashlightProxy_White { + intensity = 2.5; + lightColor[] = {0.25,0.25,1,1}; + }; + + class ACE_FlashlightProxy_Yellow: ACE_FlashlightProxy_White { + intensity = 1.5; + lightColor[] = {1,1,0.5,1}; + }; +}; \ No newline at end of file diff --git a/addons/map/CfgSounds.hpp b/addons/map/CfgSounds.hpp new file mode 100644 index 0000000000..ede59914a7 --- /dev/null +++ b/addons/map/CfgSounds.hpp @@ -0,0 +1,7 @@ +class CfgSounds { + class ACE_map_flashlightClick { + name = "ACE_map_flashlightClick"; + sound[] = {"\a3\sounds_f\weapons\Other\dry4.wss", 0.2, 2}; + titles[] = {}; + }; +}; \ No newline at end of file diff --git a/addons/map/CfgVehicles.hpp b/addons/map/CfgVehicles.hpp index 30cae96ef6..130df03af8 100644 --- a/addons/map/CfgVehicles.hpp +++ b/addons/map/CfgVehicles.hpp @@ -1,4 +1,20 @@ class CfgVehicles { + class Man; + class CAManBase: Man { + class ACE_SelfActions { + class ACE_MapFlashlight { + displayName = CSTRING(Action_Flashlights); + icon = QUOTE(\a3\ui_f\data\IGUI\Cfg\VehicleToggles\lightsiconon_ca.paa); + condition = QUOTE(GVAR(mapIllumination) && visibleMap && (count ([ACE_player] call FUNC(getUnitFlashlights)) > 0)); + statement = "true"; + exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; + insertChildren = QUOTE(_this call DFUNC(compileFlashlightMenu)); + showDisabled = 0; + priority = 99; + }; + }; + }; + class ACE_Module; class ACE_ModuleMap: ACE_Module { author = ECSTRING(common,ACETeam); @@ -15,6 +31,12 @@ class CfgVehicles { typeName = "BOOL"; defaultValue = 1; }; + class MapGlow { + displayName = CSTRING(MapGlow_DisplayName); + description = CSTRING(MapGlow_Description); + typeName = "BOOL"; + defaultValue = 1; + }; class MapShake { displayName = CSTRING(MapShake_DisplayName); description = CSTRING(MapShake_Description); @@ -39,13 +61,14 @@ class CfgVehicles { }; }; - class ACE_ModuleBlueForceTracking: ACE_Module { + class Module_F; + class ACE_ModuleBlueForceTracking: Module_F { author = ECSTRING(common,ACETeam); category = "ACE"; displayName = CSTRING(BFT_Module_DisplayName); function = QFUNC(blueForceTrackingModule); scope = 2; - isGlobal = 0; + isGlobal = 1; icon = PATHTOF(UI\Icon_Module_BFTracking_ca.paa); class Arguments { class Enabled { @@ -71,4 +94,4 @@ class CfgVehicles { description = CSTRING(BFT_Module_Description); }; }; -}; +}; \ No newline at end of file diff --git a/addons/map/XEH_postInitClient.sqf b/addons/map/XEH_postInitClient.sqf index 95f42db431..f358dcf944 100644 --- a/addons/map/XEH_postInitClient.sqf +++ b/addons/map/XEH_postInitClient.sqf @@ -1,23 +1,24 @@ #include "script_component.hpp" // Exit on Headless as well -if !(hasInterface) exitWith {}; +if (!hasInterface) exitWith {}; LOG(MSG_INIT); // Calculate the maximum zoom allowed for this map call FUNC(determineZoom); -// This spawn is probably worth keeping, as pfh don't work natively on the briefing screen and IDK how reliable the hack we implemented for them is. -// The thread dies as soon as the mission start, so it's not really compiting for scheduler space. -[] spawn { - // Wait until the map display is detected - waitUntil {(!isNull findDisplay 12)}; +[{ + if (isNull findDisplay 12) exitWith {}; GVAR(lastStillPosition) = ((findDisplay 12) displayCtrl 51) ctrlMapScreenToWorld [0.5, 0.5]; GVAR(lastStillTime) = ACE_time; GVAR(isShaking) = false; + //map sizes are multiples of 1280 + GVAR(worldSize) = worldSize / 1280; + GVAR(mousePos) = [0.5,0.5]; + //Allow panning the lastStillPosition while mapShake is active GVAR(rightMouseButtonLastPos) = []; ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {[] call FUNC(updateMapEffects);}]; @@ -42,13 +43,60 @@ call FUNC(determineZoom); GVAR(rightMouseButtonLastPos) = []; }; }]; -}; + + //get mouse position on map + ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", { + GVAR(mousePos) = (_this select 0) ctrlMapScreenToWorld [_this select 1, _this select 2]; + }]; + ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseHolding", { + GVAR(mousePos) = (_this select 0) ctrlMapScreenToWorld [_this select 1, _this select 2]; + }]; + + [_this select 1] call CBA_fnc_removePerFrameHandler; +}, 0] call CBA_fnc_addPerFrameHandler; ["SettingsInitialized", { // Start Blue Force Tracking if Enabled if (GVAR(BFT_Enabled)) then { - diag_log text "[ACE] Blue Force Tracking Enabled (client)"; GVAR(BFT_markers) = []; [FUNC(blueForceTrackingUpdate), GVAR(BFT_Interval), []] call CBA_fnc_addPerFrameHandler; }; -}] call EFUNC(common,addEventHandler); + + //illumination settings + if (GVAR(mapIllumination)) then { + GVAR(flashlightInUse) = ""; + GVAR(aceNVG) = ["ace_nightvision"] call EFUNC(common,isModLoaded); + GVAR(glow) = objNull; + + ["playerInventoryChanged", { + _flashlights = [ACE_player] call FUNC(getUnitFlashlights); + if ((GVAR(flashlightInUse) != "") && !(GVAR(flashlightInUse) in _flashlights)) then { + GVAR(flashlightInUse) = ""; + }; + }] call EFUNC(common,addEventHandler); + + if (GVAR(mapGlow)) then { + ["visibleMapChanged", { + params ["_player", "_mapOn"]; + if (_mapOn) then { + if (!alive _player && !isNull GVAR(glow)) then { + GVAR(flashlightInUse) = ""; + }; + if (GVAR(flashlightInUse) != "") then { + if (isNull GVAR(glow)) then { + [GVAR(flashlightInUse)] call FUNC(flashlightGlow); + }; + } else { + if (!isNull GVAR(glow)) then { + [""] call FUNC(flashlightGlow); + }; + }; + } else { + if (!isNull GVAR(glow)) then { + [""] call FUNC(flashlightGlow); + }; + }; + }] call EFUNC(common,addEventHandler); + }; + }; +}] call EFUNC(common,addEventHandler); \ No newline at end of file diff --git a/addons/map/XEH_preInit.sqf b/addons/map/XEH_preInit.sqf index c5645a52e7..9e123a3877 100644 --- a/addons/map/XEH_preInit.sqf +++ b/addons/map/XEH_preInit.sqf @@ -5,10 +5,15 @@ LOG(MSG_INIT); PREP(blueForceTrackingModule); PREP(blueForceTrackingUpdate); +PREP(compileFlashlightMenu); PREP(determineMapLight); PREP(determineZoom); +PREP(flashlightGlow); +PREP(getUnitFlashlights); PREP(moduleMap); PREP(onDrawMap); +PREP(simulateMapLight); +PREP(switchFlashlight); PREP(updateMapEffects); ADDON = true; diff --git a/addons/map/config.cpp b/addons/map/config.cpp index 078c06b41d..84ed030779 100644 --- a/addons/map/config.cpp +++ b/addons/map/config.cpp @@ -27,6 +27,8 @@ class RscEdit; #include "CfgEventHandlers.hpp" #include "CfgMarkers.hpp" #include "CfgVehicles.hpp" +#include "CfgAmmo.hpp" +#include "CfgSounds.hpp" class RscMapControl { maxSatelliteAlpha = 0.5; diff --git a/addons/map/functions/fnc_blueForceTrackingModule.sqf b/addons/map/functions/fnc_blueForceTrackingModule.sqf index 33049c38ca..bab776c9ab 100644 --- a/addons/map/functions/fnc_blueForceTrackingModule.sqf +++ b/addons/map/functions/fnc_blueForceTrackingModule.sqf @@ -12,12 +12,15 @@ #include "script_component.hpp" -if (!isServer) exitWith {}; +if !(hasInterface) exitWith {}; -PARAMS_1(_logic); +PARAMS_3(_logic,_units,_activated); + +if !(_activated) exitWith {}; [_logic, QGVAR(BFT_Enabled), "Enabled"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(BFT_Interval), "Interval"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(BFT_HideAiGroups), "HideAiGroups"] call EFUNC(common,readSettingFromModule); -diag_log text "[ACE]: Blue Force Tracking Module initialized. (server)"; +diag_log text "[ACE]: Blue Force Tracking Module initialized."; +TRACE_2("[ACE]: Blue Force Tracking Module initialized.", GVAR(BFT_Interval), GVAR(BFT_HideAiGroups)); diff --git a/addons/map/functions/fnc_compileFlashlightMenu.sqf b/addons/map/functions/fnc_compileFlashlightMenu.sqf new file mode 100644 index 0000000000..0d081bb57c --- /dev/null +++ b/addons/map/functions/fnc_compileFlashlightMenu.sqf @@ -0,0 +1,65 @@ +/* + * Author: voiper + * Compile list of flashlight classnames and add to the "Flashlight" parent menu. + * + * Arguments: + * 0: Vehicle + * 1: Player + * 3: Parameters + * + * Return value: + * None + * + * Example: + * [_player, _player, []] call ace_map_fnc_compileFlashlightMenu; + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_vehicle", "_player", "_parameters"]; + +_actions = []; +_flashlights = [_player] call FUNC(getUnitFlashlights); + +//add all carried flashlight menus and on/off submenu actions +{ + _displayName = getText (configFile >> "CfgWeapons" >> _x >> "displayName"); + _icon = getText (configFile >> "CfgWeapons" >> _x >> "picture"); + + _children = { + params ["_vehicle", "_player", "_flashlight"]; + _actions = []; + + _onAction = [ + (_flashlight + "_On"), + "On", + "", + {[_this select 2] call FUNC(switchFlashlight)}, + {GVAR(flashlightInUse) != (_this select 2)}, + {}, + _flashlight + ] call EFUNC(interact_menu,createAction); + + _offAction = [ + (_flashlight + "_Off"), + "Off", + "", + {[""] call FUNC(switchFlashlight)}, + {GVAR(flashlightInUse) == (_this select 2)}, + {}, + _flashlight + ] call EFUNC(interact_menu,createAction); + + _actions pushBack [_onAction, [], _player]; + _actions pushBack [_offAction, [], _player]; + + _actions + }; + + _parentAction = [_x, _displayName, _icon, {true}, {true}, _children, _x] call EFUNC(interact_menu,createAction); + _actions pushBack [_parentAction, [], _player]; +} forEach _flashlights; + +_actions \ No newline at end of file diff --git a/addons/map/functions/fnc_determineMapLight.sqf b/addons/map/functions/fnc_determineMapLight.sqf index 9c205299e6..8204b4b7f8 100644 --- a/addons/map/functions/fnc_determineMapLight.sqf +++ b/addons/map/functions/fnc_determineMapLight.sqf @@ -55,11 +55,13 @@ _fnc_calcColor = { _lightLevel = 0.04 + (0.96 * call EFUNC(common,ambientBrightness)); +/* // check if player has NVG enabled if (currentVisionMode _unit == 1) exitWith { // stick to nvg color [true, [154/255,253/255,177/255,0.5]] }; +*/ // Do not obscure the map if the ambient light level is above 0.95 if (_lightLevel > 0.95) exitWith { @@ -122,4 +124,4 @@ if (_lightLevel > 0.95) exitWith { }; // Calculate resulting map color -[true, [_lightTint, _lightLevel] call _fnc_calcColor] +[true, [_lightTint, _lightLevel] call _fnc_calcColor] \ No newline at end of file diff --git a/addons/map/functions/fnc_flashlightGlow.sqf b/addons/map/functions/fnc_flashlightGlow.sqf new file mode 100644 index 0000000000..76cc871232 --- /dev/null +++ b/addons/map/functions/fnc_flashlightGlow.sqf @@ -0,0 +1,41 @@ +/* + * Author: voiper + * Add or remove global flashlight glow for when player is looking at map. + * + * Arguments: + * 0: Flashlight classname ("" for off) + * + * Return value: + * None + * + * Example: + * ["ACE_Flashlight_MX991"] call ace_map_fnc_flashlightGlow; + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_flashlight"]; + +_light = GVAR(glow); +if (!isNull _light) then {deleteVehicle _light}; + +if (_flashlight != "") then { + _colour = getText (configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Colour"); + + _class = switch (_colour) do { + case "white": {"ACE_FlashlightProxy_White"}; + case "red": {"ACE_FlashlightProxy_Red"}; + case "green": {"ACE_FlashlightProxy_Green"}; + case "blue": {"ACE_FlashlightProxy_Blue"}; + case "yellow": {"ACE_FlashlightProxy_Yellow"}; + }; + + _light = _class createVehicle [0,0,0]; + _light attachTo [ACE_player, [0,0.5,-0.1], "head"]; +} else { + _light = objNull; +}; + +GVAR(glow) = _light; \ No newline at end of file diff --git a/addons/map/functions/fnc_getUnitFlashlights.sqf b/addons/map/functions/fnc_getUnitFlashlights.sqf new file mode 100644 index 0000000000..b7c4aa2e91 --- /dev/null +++ b/addons/map/functions/fnc_getUnitFlashlights.sqf @@ -0,0 +1,29 @@ +/* + * Author: voiper + * Check a unit for any flashlights that can be used on map. + * + * Arguments: + * 0: Unit to check + * + * Return value: + * Flashlight classnames (empty for none) + * + * Example: + * [unit] call ace_map_fnc_getUnitFlashlights; + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_unit"]; + +_flashlights = []; + +{ + if ((isText (configFile >> "CfgWeapons" >> _x >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Colour")) && !(_x in _flashlights)) then { + _flashlights pushBack _x; + }; +} forEach (items _unit); + +_flashlights \ No newline at end of file diff --git a/addons/map/functions/fnc_moduleMap.sqf b/addons/map/functions/fnc_moduleMap.sqf index 514d2af034..b763db7eea 100644 --- a/addons/map/functions/fnc_moduleMap.sqf +++ b/addons/map/functions/fnc_moduleMap.sqf @@ -8,15 +8,17 @@ * Return Value: * None */ + #include "script_component.hpp" if !(isServer) exitWith {}; -PARAMS_3(_logic,_units,_activated); +params ["_logic", "_units", "_activated"]; if !(_activated) exitWith {}; [_logic, QGVAR(mapIllumination), "MapIllumination" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(mapGlow), "MapGlow" ] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(mapShake), "MapShake" ] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(mapLimitZoom), "MapLimitZoom" ] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(mapShowCursorCoordinates), "MapShowCursorCoordinates"] call EFUNC(common,readSettingFromModule); diff --git a/addons/map/functions/fnc_simulateMapLight.sqf b/addons/map/functions/fnc_simulateMapLight.sqf new file mode 100644 index 0000000000..b4c64e6239 --- /dev/null +++ b/addons/map/functions/fnc_simulateMapLight.sqf @@ -0,0 +1,136 @@ +/* +* Author: voiper +* Draw sexy flashlight beams and NVG on main map. +* +* Arguments: +* 0: Map control (Control) +* 1: Map zoom level (Number) +* 2: Current map centre (Array) +* 3: Light level from ace_map_fnc_determineMapLight (Array) +* +* Return Value: +* None +* +* Public: No +*/ + +#include "script_component.hpp" + +params ["_mapCtrl", "_mapScale", "_mapCentre", "_lightLevel"]; + +_hmd = hmd ACE_player; +_nvgOn = (((getText (configFile >> 'CfgWeapons' >> _hmd >> 'simulation')) == 'NVGoggles') && (currentVisionMode ACE_player == 1)); +_aceNVG = GVAR(aceNVG); +_flashlight = GVAR(flashlightInUse); + +//map width (on screen) in pixels +_screenSize = 640 * safeZoneW; + +//resolution params (every frame in case resolution change) +getResolution params ["_resX", "_resY", "_viewPortX", "_viewPortY", "", "_uiScale"]; + +//engine rounds the viewport ratios, when they should be fractions; this can cause problems +_realViewPortY = _resY * _uiScale; +_realViewPortX = _realViewPortY * 4/3; + +//textures +_blackTex = "#(rgb,8,8,3)color(0,0,0,1)"; +_whiteTex = "#(rgb,8,8,3)color(1,1,1,1)"; + +//colour/alpha +_lightLevel params ["_r", "_g", "_b", "_a"]; +_colourAlpha = (_r + _g + _b) min _a; +_shadeAlpha = _a; + +if (_nvgOn) then { + _flashlightAdd = if (_flashlight != "") then {0.75} else {0}; + _shadeAlpha = 0.8 - _a + _flashlightAdd; + _fillTex = _whiteTex; + + if (_aceNVG) then { + _nvgAlpha = ACE_player getVariable [QEGVAR(nightvision,NVGBrightness), 0]; + + if (_nvgAlpha >= 0) then { + _shadeAlpha = _shadeAlpha + _nvgAlpha / 2; + } else { + //if flashlight off + if (_flashlight == "") then { + //if there's nearby light + if (_shadeAlpha > 0) then { + _shadeAlpha = _shadeAlpha + _nvgAlpha / 2; + } else { + _fillTex = _blackTex; + _shadeAlpha = -_nvgAlpha / 1.5; + }; + } else { + _shadeAlpha = _shadeAlpha + _nvgAlpha; + }; + }; + + _grainConfig = (configFile >> "CfgWeapons" >> _hmd >> "ACE_NightVision_grain"); + _grain = if (isNumber _grainConfig) then { + (getNumber _grainConfig) / 2 + } else { + 0 + }; + + if (_grain > 0) then { + _posX = (_mapCentre select 0) + (_mapScale * random 500); + _posY = (_mapCentre select 1) + (_mapScale * random 500); + _mapCtrl drawIcon [format["#(ai,2048,2048,1)perlinNoise(%1,%2,0,1)", _resX, _resX], [0.25,0.25,0.25,_grain], [_posX, _posY], _screenSize * 2.5, _screenSize * 2.5, 0, "", 0]; //noise + }; + }; + + _mapCtrl drawIcon ["#(rgb,8,8,3)color(0,0.5,0,1)", [1,1,1,0.5], _mapCentre, _screenSize, _screenSize, 0, "", 0]; //nvg green + _mapCtrl drawIcon [_fillTex, [1,1,1,_shadeAlpha], _mapCentre, _screenSize, _screenSize, 0, "", 0]; //alpha fill +} else { + _fillTex = _blackTex; + + _colourList = [_r, _g, _b]; + _colourList sort false; + _maxColour = _colourList select 0; + + //ambient colour fill + _mapCtrl drawIcon [format["#(rgb,8,8,3)color(%1,%2,%3,1)", _r / _maxColour, _g / _maxColour, _b / _maxColour], [1,1,1,_colourAlpha], _mapCentre, _screenSize, _screenSize, 0, "", 0]; + + if (_flashlight == "") then { + //ambient shade fill + _mapCtrl drawIcon [_fillTex, [1,1,1,_shadeAlpha], _mapCentre, _screenSize, _screenSize, 0, "", 0]; + } else { + //mouse pos + _mousePos = GVAR(mousePos); + + //flashlight settings + _colour = getText (configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Colour"); + _size = getNumber (configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Size"); + _flashTex = format[QUOTE(PATHTOF_SYS(ace,flashlights,UI\Flashlight_Beam_%1_ca.paa)), _colour]; + _beamSize = _screenSize / _size; + + //after 5x zoom, it's simulated to be fixed (it actually gets bigger relative to zoom) + if (_mapScale < 0.2) then {_beamSize = _beamSize / (_mapScale * (1 / 0.2))}; + + //assign corrective ratio to fix sub-pixel gaps/overlaps (symptom of viewport * X/Y resolution rounding) + _viewPortRatioFixY = if (_realViewPortY != _viewPortY) then { + _realViewPortX / (_realViewPortY / _viewPortY * _viewPortX) + } else { + if (_realViewPortX != _viewPortX) then { + _realViewPortX / _viewPortX + } else { + 1 + }; + }; + + //offset the elements + _offsetX = _mapScale * GVAR(worldSize) * (_screenSize * 2 + _beamSize); + _offsetYDown = _mapScale * GVAR(worldSize) * (_screenSize + _beamSize) * _viewPortRatioFixY; + //up is bigger because of a potential exploit + _offsetYUp = _mapScale * GVAR(worldSize) * (_screenSize * 4 + _beamSize) * _viewPortRatioFixY; + + //draw the matrix /whoa + _mapCtrl drawIcon [_flashTex, [1,1,1,_shadeAlpha], _mousePos, _beamSize, _beamSize, 0, "", 0]; //centre beam + _mapCtrl drawIcon [_fillTex, [1,1,1,_shadeAlpha], [(_mousePos select 0) - _offsetX, (_mousePos select 1)], _screenSize * 2, _beamSize, 0, "", 0]; //left + _mapCtrl drawIcon [_fillTex, [1,1,1,_shadeAlpha], [(_mousePos select 0) + _offsetX, (_mousePos select 1)], _screenSize * 2, _beamSize, 0, "", 0]; //right + _mapCtrl drawIcon [_fillTex, [1,1,1,_shadeAlpha], [(_mousePos select 0), (_mousePos select 1) - _offsetYDown], _screenSize * 4, _screenSize, 0, "", 0]; //down + _mapCtrl drawIcon [_fillTex, [1,1,1,_shadeAlpha], [(_mousePos select 0), (_mousePos select 1) + _offsetYUp], _screenSize * 4, _screenSize * 4, 0, "", 0]; //up + }; +}; \ No newline at end of file diff --git a/addons/map/functions/fnc_switchFlashlight.sqf b/addons/map/functions/fnc_switchFlashlight.sqf new file mode 100644 index 0000000000..e177f886fa --- /dev/null +++ b/addons/map/functions/fnc_switchFlashlight.sqf @@ -0,0 +1,25 @@ +/* + * Author: voioper + * Switch flashlight. + * + * Arguments: + * 0: Flashlight classname ("" for off) + * + * Return value: + * None + * + * Example: + * ["ACE_Flashlight_MX991"] call ace_map_fnc_switchFlashlight; + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_flashlight"]; + +GVAR(flashlightInUse) = _flashlight; +if (GVAR(mapGlow)) then { + [GVAR(flashlightInUse)] call FUNC(flashlightGlow); +}; +playSound "ACE_map_flashlightClick"; \ No newline at end of file diff --git a/addons/map/functions/fnc_updateMapEffects.sqf b/addons/map/functions/fnc_updateMapEffects.sqf index 3550df517c..72f5d0cec1 100644 --- a/addons/map/functions/fnc_updateMapEffects.sqf +++ b/addons/map/functions/fnc_updateMapEffects.sqf @@ -10,23 +10,21 @@ * * Public: No */ + #include "script_component.hpp" -private ["_mapCtrl","_mapScale"]; - -_mapCtrl = ((findDisplay 12) displayCtrl 51); +_mapCtrl = findDisplay 12 displayCtrl 51; _mapScale = ctrlMapScale _mapCtrl; +_mapCentre = _mapCtrl ctrlMapScreenToWorld [0.5, 0.5]; if (GVAR(mapIllumination)) then { - private ["_data","_darkenFill"]; + //get nearby lighting + _light = [[ACE_player], FUNC(determineMapLight), missionNamespace, QGVAR(mapLight), 0.1] call EFUNC(common,cachedCall); - // Calculate map illumination - _data = [[ACE_player], FUNC(determineMapLight), missionNamespace, QGVAR(mapLight), 0.1] call EFUNC(common,cachedCall); + _light params ["_applyLighting", "_lightLevel"]; - EXPLODE_2_PVT(_data,_darkenMap,_darkenColor); - if (_darkenMap) then { - _darkenFill = format["#(rgb,1,1,1)color(%1,%2,%3,%4)",_darkenColor select 0, _darkenColor select 1, _darkenColor select 2, _darkenColor select 3]; - _mapCtrl drawRectangle [(getArray(configFile >> 'CfgWorlds' >> worldName >> 'centerPosition')),80000,80000,0,_darkenColor,_darkenFill]; + if (_applyLighting) then { + [_mapCtrl, _mapScale, _mapCentre, _lightLevel] call FUNC(simulateMapLight); }; }; @@ -63,7 +61,7 @@ if (GVAR(mapShake)) then { GVAR(isShaking) = false; } else { // The map is still, store state - GVAR(lastStillPosition) = _mapCtrl ctrlMapScreenToWorld [0.5, 0.5]; + GVAR(lastStillPosition) = _mapCentre; GVAR(lastStillTime) = ACE_time; }; }; @@ -72,7 +70,7 @@ if (GVAR(mapShake)) then { if (GVAR(mapLimitZoom)) then { if (GVAR(minMapSize) >= _mapScale) then { ctrlMapAnimClear _mapCtrl; - _mapCtrl ctrlMapAnimAdd [0, GVAR(minMapSize) + 0.001, (_mapCtrl ctrlMapScreenToWorld [0.5, 0.5])]; + _mapCtrl ctrlMapAnimAdd [0, GVAR(minMapSize) + 0.001, _mapCentre]; ctrlMapAnimCommit _mapCtrl; }; -}; +}; \ No newline at end of file diff --git a/addons/map/stringtable.xml b/addons/map/stringtable.xml index 3f2d312fae..24cfa5fc7d 100644 --- a/addons/map/stringtable.xml +++ b/addons/map/stringtable.xml @@ -18,12 +18,13 @@ Iluminação do mapa? - Calculate dynamic map illumination based on light conditions? - Oblicza dynamiczne oświetlenie mapy bazujące na warunkach oświetleniowych - Calcula la iluminación dinámica del mapa basandose en las condiciones de luz - Berechne die Kartenauslichtung anhand des Umgebungslichts? - Vypočítat dynamické osvětlení mapy na základně světelných podmínek? - Calcular a iluminação dinâmica do mapa de acordo com as condições de luz? + Simulate map lighting based on ambient lighting and player's items? + + + Map flashlight glow? + + + Add external glow to players who use flashlight on map? Map shake? @@ -74,7 +75,7 @@ Mostrar as coordenadas de grade no ponteiro do mouse? - This module allows you to customize the map screen. + Moduł ten pozwala dostosować opcje widoku ekranu mapy. Dieses Modul erweitert die Kartenfunktionen. Tento modul umožňuje přizpůsobit mapu s obrazem. @@ -83,7 +84,7 @@ Blue Force Tracking Blue Force Tracking - Blue Force Tracking + Seguimiento de fuerzas amigas Blue Force Tracking Blue Force Tracking Rastreio de forças azuis @@ -93,14 +94,12 @@ RFA ativo Aktywuj BFT Povolit BFT - Activar BFT Enable Blue Force Tracking. Default: No Ativa Rastreio de Forças Azuis. Padrão: Não Aktywuj Blue Force Tracking. Domyślnie: Nie Povolit Blue Force Tracking. Výchozí: Ne - Activar Blue Force Tracking. Por defecto: No Interval @@ -135,11 +134,35 @@ Esconder marcadores que pertencem ao grupo de IA? - This module allows the tracking of allied units with BFT map markers. + Pozwala śledzić na mapie pozycje sojuszniczych jednostek za pomocą markerów BFT. Dieses Modul ermöglicht es verbündete Einheiten mit dem BFT auf der Karte zu verfolgen. Umožňuje sledovat přátelské jednokty na mapě v rámci BFT. Permite que você acompanhe as posições no mapa das unidades aliadas com marcadores RFA. + + Flashlights + Latarki + + + NVG + Noktowizja + + + On + Włącz + + + Off + Wyłącz + + + Increase Brightness + Zwiększ czułość + + + Decrease Brightness + Zmniejsz czułość + \ No newline at end of file