import (Config): Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "{{SideTOC}}" to "{{TOC|side}}")
m (Text replacement - "<syntaxhighlight lang=cpp>" to "<syntaxhighlight lang="cpp">")
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{TOC|side}}
{{TOC|side}}
{{Feature|arma3| Available since <tt>v2.01.146644</tt>.}}
{{GVI|arma3|2.01.146644}}


== <b>import</b> keyword ==
== <b>import</b> keyword ==
Line 8: Line 8:
The keyword tells parser to copy given class during parsing of the mission config so the imported class will be placed where the keyword <tt>import</tt> was placed. For example if one needs to inherit from <tt>RscText</tt>, the <tt>import RscText;</tt> should precede the inheritance:
The keyword tells parser to copy given class during parsing of the mission config so the imported class will be placed where the keyword <tt>import</tt> was placed. For example if one needs to inherit from <tt>RscText</tt>, the <tt>import RscText;</tt> should precede the inheritance:


<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
import RscText;
import RscText;
class MyText: RscText  
class MyText: RscText  
Line 18: Line 18:
The <tt>import</tt> keyword tells the engine to look for the base class in main config, which means classes in base directory. However, it is also possible to look in other dirs using <tt>from</tt> keyword.
The <tt>import</tt> keyword tells the engine to look for the base class in main config, which means classes in base directory. However, it is also possible to look in other dirs using <tt>from</tt> keyword.


==<b>from</b> keyword==
== <b>from</b> keyword ==


The <tt>from</tt> keyword is used to indicate specific config path from where the class should be imported. For example, one can do things like this, not that one will even need this particular usage:
The <tt>from</tt> keyword is used to indicate specific config path from where the class should be imported. For example, one can do things like this, not that one will even need this particular usage:


<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
import Default from CfgTasks;
import Default from CfgTasks;


Line 34: Line 34:
</syntaxhighlight>
</syntaxhighlight>


==Modifying properties==
== Modifying properties ==
The properties override is done in the same way it is done for modding.  
The properties override is done in the same way it is done for modding.  


<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
import RscText;
import RscText;
class MyText: RscText  
class MyText: RscText  
Line 47: Line 47:
When property is inside another class, this is how it could be done:
When property is inside another class, this is how it could be done:


<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
import RscStructuredText;
import RscStructuredText;
class MyText: RscStructuredText
class MyText: RscStructuredText
Line 60: Line 60:
Here is example of overriding the color of vignette:
Here is example of overriding the color of vignette:


<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
import RscDisplayEmpty;
import RscDisplayEmpty;
class MyRscDisplayEmpty: RscDisplayEmpty
class MyRscDisplayEmpty: RscDisplayEmpty
Line 78: Line 78:
[[Image:vignette_modified.jpg|600px]]
[[Image:vignette_modified.jpg|600px]]


==Checking imported classes==
== Checking imported classes ==


In debug console type [[Arma_3_Utilities#Print_Config |<tt>utils 2</tt>]], LOCAL EXEC, and select mission config from drop down menu. The mission config will be displayed including imported classes
In debug console type [[Arma_3_Utilities#Print_Config |<tt>utils 2</tt>]], LOCAL EXEC, and select mission config from drop down menu. The mission config will be displayed including imported classes

Revision as of 16:23, 19 June 2021

Arma 3 logo black.png2.01.146644

import keyword

The import keyword can only be used in mission config, pretty much like class keyword, in order to import a class from main config into mission config. Useful for UI creation as UI controls have a lot of properties which are already defined in main config, so if only some tweaks are required, it could be easily done after importing the class.

The keyword tells parser to copy given class during parsing of the mission config so the imported class will be placed where the keyword import was placed. For example if one needs to inherit from RscText, the import RscText; should precede the inheritance:

import RscText;
class MyText: RscText 
{
...
};

The import keyword tells the engine to look for the base class in main config, which means classes in base directory. However, it is also possible to look in other dirs using from keyword.

from keyword

The from keyword is used to indicate specific config path from where the class should be imported. For example, one can do things like this, not that one will even need this particular usage:

import Default from CfgTasks;

class CfgTasks
{
    class MyAwesomeTask: Default
    {
        name = "My Awesome Task";
    };
};

Modifying properties

The properties override is done in the same way it is done for modding.

import RscText;
class MyText: RscText 
{
	style = 2;
};

When property is inside another class, this is how it could be done:

import RscStructuredText;	
class MyText: RscStructuredText
{
	class Attributes: Attributes
	{
		align = "right";
	};
};

Here is example of overriding the color of vignette:

import RscDisplayEmpty;	
class MyRscDisplayEmpty: RscDisplayEmpty
{
	class controls: controls
	{
		class CA_Vignette: CA_Vignette
		{
			colorText[] = {1,0,0,1};
		};
	};
};

And the result, after executing findDisplay 46 createDisplay "MyRscDisplayEmpty"; in debug console:

vignette modified.jpg

Checking imported classes

In debug console type utils 2, LOCAL EXEC, and select mission config from drop down menu. The mission config will be displayed including imported classes