From 535de98c15b20009dfe1f0a3a6eeebd8a0d84a0b Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 26 Aug 2023 01:30:58 +0200 Subject: [PATCH] Reduce Eden export size, and split it into multiple parts if estimated size is too big --- @ArmaMapStudio/addons/eden/XEH_PREP.hpp | 3 +- .../addons/eden/functions/fnc_copyPart.sqf | 15 +++++++ .../addons/eden/functions/fnc_export.sqf | 40 +++++++++++++++---- @ArmaMapStudio/addons/eden/stringtable.xml | 8 ++++ @ArmaMapStudio/addons/main/script_version.hpp | 2 +- 5 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 @ArmaMapStudio/addons/eden/functions/fnc_copyPart.sqf diff --git a/@ArmaMapStudio/addons/eden/XEH_PREP.hpp b/@ArmaMapStudio/addons/eden/XEH_PREP.hpp index 55e17cfe..8c8f3f00 100644 --- a/@ArmaMapStudio/addons/eden/XEH_PREP.hpp +++ b/@ArmaMapStudio/addons/eden/XEH_PREP.hpp @@ -2,4 +2,5 @@ PREP(export); PREP(getPosWrp); PREP(recreateHidden); PREP(transformObject); -PREP(editObject); \ No newline at end of file +PREP(editObject); +PREP(copyPart); \ No newline at end of file diff --git a/@ArmaMapStudio/addons/eden/functions/fnc_copyPart.sqf b/@ArmaMapStudio/addons/eden/functions/fnc_copyPart.sqf new file mode 100644 index 00000000..9a6e1724 --- /dev/null +++ b/@ArmaMapStudio/addons/eden/functions/fnc_copyPart.sqf @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +copyToClipboard (GVAR(results) # GVAR(current)); +GVAR(current) = GVAR(current) + 1; +systemChat (format ["Part %1 on %2 copied", GVAR(current), count GVAR(results)]); + +if ( GVAR(current) < count GVAR(results)) then { + [ + format [LLSTRING(NextPartMessage),GVAR(current), count GVAR(results)], + LLSTRING(ExportToGrmStudio), + [LLSTRING(NextPartButton),{ 0 spawn { sleep 0.1; call FUNC(copyPart); }; }] + ] call BIS_fnc_3DENShowMessage; +} else { + [LLSTRING(ExportDone), 0, 5] call BIS_fnc_3DENNotification; +} \ No newline at end of file diff --git a/@ArmaMapStudio/addons/eden/functions/fnc_export.sqf b/@ArmaMapStudio/addons/eden/functions/fnc_export.sqf index 13a13c14..55a51a21 100644 --- a/@ArmaMapStudio/addons/eden/functions/fnc_export.sqf +++ b/@ArmaMapStudio/addons/eden/functions/fnc_export.sqf @@ -15,14 +15,14 @@ private _toRemoveLayer = if ( count _existingLayers > 0 ) then { _existingLayer private _progress = 0; private _progressTotal = count _objects + count _systems; -_data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorlds" >> worldName >> "grma3_revision")]; +private _prelude = (str [".map", worldName, worldSize, getNumber (configFile >> "CfgWorlds" >> worldName >> "grma3_revision")]); { if ( _x isKindOf "ModuleHideTerrainObjects_F" ) then { _x set3DENLayer _toRemoveLayer; private _hidden = _x getVariable ["#objects",[]]; { - _data pushBack [".hide", (getModelInfo _x) select 1, getPosWorld _x, [_x] call FUNC(getPosWrp), vectorUp _x, vectorDir _x, surfaceNormal (getPosASL _x), getObjectScale _x, getObjectID _x]; + _data pushBack [".hide", (getModelInfo _x) select 1, [], [_x] call FUNC(getPosWrp), vectorUp _x, vectorDir _x, surfaceNormal (getPosASL _x), getObjectScale _x, getObjectID _x]; } foreach _hidden; }; @@ -31,7 +31,7 @@ _data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorld if ( _value == 5 ) then { private _building = _x getVariable ["#building", objNull]; if ( !isNull _building ) then { - _data pushBack [".hide", (getModelInfo _building) select 1, getPosWorld _building, [_building] call FUNC(getPosWrp), vectorUp _building, vectorDir _building, surfaceNormal (getPosASL _building), getObjectScale _building, getObjectID _building]; + _data pushBack [".hide", (getModelInfo _building) select 1, [], [_building] call FUNC(getPosWrp), vectorUp _building, vectorDir _building, surfaceNormal (getPosASL _building), getObjectScale _building, getObjectID _building]; }; _x set3DENLayer _toRemoveLayer; }; @@ -42,6 +42,8 @@ _data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorld } foreach _systems; +private _deleteCount = count _data; + { if (_x get3DENAttribute "GRMA3_Exclude" select 0) then { // Ignored @@ -74,7 +76,7 @@ _data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorld _classes set [_class,_classData]; }; if ( _classData select 0 ) then { - _data pushBack [".add", _class, getPosWorld _x, [_x] call FUNC(getPosWrp), vectorUp _x, vectorDir _x, surfaceNormal (getPosASL _x), getObjectScale _x]; + _data pushBack [".add", _class, [], [_x] call FUNC(getPosWrp), vectorUp _x, vectorDir _x, surfaceNormal (getPosASL _x), getObjectScale _x]; _x set3DENLayer _toRemoveLayer; }; }; @@ -85,20 +87,42 @@ _data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorld } foreach _objects; + +private _addCount = (count _data) - _deleteCount - (count _classes); +private _elevationCount = 0; + // Deformer related data if ( !isNil "GF_gridMap") then { - _data pushBack [".dhmap", GF_gridMap apply { [_x#0, _x#1, _y#0] }]; + toFixed 3; + private _hmap = GF_gridMap apply { [_x#0, _x#1, _y#0] }; + _elevationCount = count _hmap; + for "_i" from 0 to (count _hmap) step 25 do { + _data pushBack ((str [".dhmap", _hmap select [_i, 25] ]) regexReplace ["\.000/gio", ""]); + }; }; endloadingscreen; + INFO_1("%1 items", count _data); +private _results = []; + toFixed 20; -private _result = _data joinString endl; +for "_i" from 0 to (count _data) step 20000 do { + _results pushBack (([_prelude] + (_data select [_i, 20000])) joinString endl); +}; toFixed -1; -copyToClipboard _result; +systemChat (format ["Total: %1 deletes, %2 adds, %3 elevation changes", _deleteCount, _addCount, _elevationCount]); -[LLSTRING(ExportDone), 0, 5] call BIS_fnc_3DENNotification; +if ( count _results <= 1 ) then { + copyToClipboard (_results # 0); + [LLSTRING(ExportDone), 0, 5] call BIS_fnc_3DENNotification; +} +else { + GVAR(results) = _results; + GVAR(current) = 0; + call FUNC(copyPart); +}; diff --git a/@ArmaMapStudio/addons/eden/stringtable.xml b/@ArmaMapStudio/addons/eden/stringtable.xml index 1cb3865f..fee62f66 100644 --- a/@ArmaMapStudio/addons/eden/stringtable.xml +++ b/@ArmaMapStudio/addons/eden/stringtable.xml @@ -25,5 +25,13 @@ Edit object Modifier l'objet + + Next Part + Suivant + + + Part %1 on %2 of export have been copied. Import it in GameRealisticMap Studio, and then click on Next Part button to continue. + Partie %1 sur %2 de l'export a été copié. Importer le dans GameRealisticMap Studio, puis ensuite cliquer sur le bouton Suivant pour continuer. + diff --git a/@ArmaMapStudio/addons/main/script_version.hpp b/@ArmaMapStudio/addons/main/script_version.hpp index 71222cca..93fdede1 100644 --- a/@ArmaMapStudio/addons/main/script_version.hpp +++ b/@ArmaMapStudio/addons/main/script_version.hpp @@ -1,4 +1,4 @@ #define MAJOR 0 #define MINOR 3 -#define PATCH 0 +#define PATCH 1 #define BUILD 0