Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subcomponent support to macros #1598

Merged
merged 9 commits into from
Sep 9, 2023
Merged

Add subcomponent support to macros #1598

merged 9 commits into from
Sep 9, 2023

Conversation

jonpas
Copy link
Member

@jonpas jonpas commented Sep 8, 2023

When merged this pull request will:

  • Add SUBCOMPONENT support with SUBADDON and SUBGVAR family.
  • Add nicer support for subcomponents/subconfigs.
  • Retain easy use of parent data by not changing any other macros. Instead we will be adding more as necessary for use in sub-components. Minimal need is expected beyond the ones this PR adds.

Example subcomponent setup with this PR:

// xeh/subcomponent/script_component.hpp
// define SUBCOMPONENT and include parent component's macros
#define SUBCOMPONENT ws
#include "\x\cba\addons\xeh_ws\script_component.hpp"

// xeh/subcomponent/config.cpp
// standard with addition of
class CfgPatches {
    class SUBADDON {
        requiredAddons[] = {"cba_xeh", ...};
    };
};

ACE3 would also include SUBCOMPONENT_BEAUTIFIED which does the same for beautified names. I didn't add this here as CBA uses stringtable component names, and no subcomponent adds additional classes that would cause them to add a mission dependency.


Tested with:

diff --git a/addons/xeh/xeh_ws/CfgVehicles.hpp b/addons/xeh/xeh_ws/CfgVehicles.hpp
index a39cf7f6..8d0cfa7b 100644
--- a/addons/xeh/xeh_ws/CfgVehicles.hpp
+++ b/addons/xeh/xeh_ws/CfgVehicles.hpp
@@ -57,4 +57,9 @@ class CfgVehicles {
     class Truck_02_aa_base_lxWS: Truck_02_base_F {
         XEH_ENABLED;
     };
+
+    // Test SUBCOMPONENT setup
+    class CBA_Test_Unit_XEH_WS: I_SFIA_Said_lxWS {
+        dlc = "cba";
+    };
 };
diff --git a/addons/xeh/xeh_ws/config.cpp b/addons/xeh/xeh_ws/config.cpp
index e986b47a..1692da1c 100644
--- a/addons/xeh/xeh_ws/config.cpp
+++ b/addons/xeh/xeh_ws/config.cpp
@@ -3,7 +3,7 @@
 class CfgPatches {
     class SUBADDON {
         name = CSTRING(component);
-        units[] = {};
+        units[] = {"CBA_Test_Unit_XEH_WS"};
         weapons[] = {};
         requiredVersion = REQUIRED_VERSION;
         requiredAddons[] = {"cba_xeh", "data_f_lxWS"};
@@ -14,7 +14,7 @@ class CfgPatches {
         VERSION_CONFIG;
 
         // this prevents any patched class from requiring XEH
-        addonRootClass = "A3_Characters_F";
+        //addonRootClass = "A3_Characters_F";
     };
 };

image

addons[]=
{
	"cba_xeh_ws"
};
class AddonsMetaData
{
	class List
	{
		items=1;
		class Item0
		{
			className="cba_xeh_ws";
			name="Community Base Addons - Extended Event Handlers";
			author="CBA Team";
			url="https://www.github.com/CBATeam/CBA_A3";
		};
	};
};

@jonpas jonpas added this to the 3.16.0 milestone Sep 8, 2023
@jonpas
Copy link
Member Author

jonpas commented Sep 8, 2023

Changed SUBCOMPONENT to only defined new SUBADDON and SUGVAR family. 90% of the use-cases are expected to need parent component data, and not really add prefixed data in subcomponents.

@PabstMirror PabstMirror merged commit eab161e into master Sep 9, 2023
4 checks passed
@PabstMirror PabstMirror deleted the subconfig-macro branch September 9, 2023 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants