Jump to content
SonicJohnBH

Seeking guidance on custom display elements.

Recommended Posts

Hello all! I'm trying to learn the code behind some of the fantastic mods that include complex displays and huds. Chief amongst them is @pierremgi and his MGI tactical pack. 

 

I'm looking to get a display on the custom scope we're making that includes a compass, wind indicator and rangefinder. The last of those I've gotten somewhat figured out, but it disables the text on the base hud that indicates your current zeroing.

 

EVENTUALLY I'd like to get a autozeroing system working for the scope, akin to this:

 

 

I'm beginning to understand the basics of the rsc stuff, but it's still very confusing and I have little experience with scripting. Much more comfortable with configs.

 

Any help would be GREATLY appreciated.

 

Share this post


Link to post
Share on other sites

This mod allows you choices for multiple displays along with different possibilities. First of all you choices are saved in your profile name space. (So, you keep them between 2 Arma's games). Not mandatory.

I'm using cutRSC command for displays. You need to create a RSCTitles class in description.ext (for scenario) or in a .hpp or .cpp for a mod.

You can have a look at https://community.bistudio.com/wiki/GUI_Tutorial

So rscTitles is made of rsc classes you can display

For each rsc class you can set a variable for working on it, and define controls which are parts of your display.

Then, you can create a function (use cfgFunctions in a .hpp for example) which enable you some calculations and "animations" on your display.

 

So, as example, for a mod:

in your config.cpp :

#include your.hpp    // without ; at the end of the line

 

in your.hpp
 

Spoiler

 

/////////////////////////////////////////////////////////////

//////////// for inheritance //////////////////////

 

#define CT_STATIC                  0
#define CT_PROGRESS          8
#define ST_VERTICAL             1
#define ST_CENTER                2
#define ST_PICTURE              48
#define ST_KEEP_ASPECT_RATIO 2048


class RscText  // all following data can be modified
{
    access = 0;
    type = 0;
    idc = -1;
    colorBackground[] = {0, 0, 0, 0 };
    colorText[] = {1, 1, 1, 1 };
    text = "";
    fixedWidth = 0;
    x = 0;
    y = 0;
    h = 0.03;
    w = 0.1;
    style = 0;
    shadow = 0;
    colorShadow[] = {0.331,0.139,0.367,0.1 };
    font = "EtelkaMonospacePro";
    SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) )";
    linespacing = 1;
    tooltipColorText[] = {1, 1, 1, 1 };
    tooltipColorBox[] = {1, 1, 1, 1 };
    tooltipColorShade[] = {0, 0, 0, 0.65 };
};
class RscPicture
{
    access = 0;
    type = 0;
    idc = -1;
    style = 48;
    colorBackground[] = {0, 0, 0, 0 };
    colorText[] = {1, 1, 1, 1 };
    font = "TahomaB";
    sizeEx = 0;
    lineSpacing = 0;
    text = "";
    fixedWidth = 0;
    shadow = 0;
    x = 0;
    y = 0;
    w = 0.2;
    h = 0.15;
    tooltipColorText[] = {1, 1, 1, 1 };
    tooltipColorBox[] = {1, 1, 1, 1 };
    tooltipColorShade[] = {0, 0, 0, 0.65 };
};

 

///////////////////////////////////////////////////

class RscTitles
{
    titles[] = {"yourHUD","Default"};

    class yourHUD
    {
        idd = -1;
        duration = 100000;
        fadein = 0;
        fadeout = 0;
        name="blabla";
        onLoad = "uiNamespace setVariable ['workingDataOrElse', _this #0]";

        controls[]=
        {
            yourCtrl1,
            yourCtrl2,
            ....,
        };
        class yourCtrl1: RscPicture  // example of inheritance
        {
        idc = 123; // or any unused number

        // position and dimension below, examples
        x = 0.5 * safezoneW + safezoneX;
        y = 0.5 * safezoneH + safezoneY;
        w = 0.05 * safezoneW;
        h = 0.02 * safezoneH;
        };
        class yourCtrl2: RscText // for text
        {
        idc = 234;
        style = 0;
        SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 58)/ (getResolution select 5) )";  // good luck with that! Simplify if you can
        x = 0.55 * safezoneW + safezoneX;
        y = 0.5 * safezoneH + safezoneY;
        w = 0.05 * safezoneW;
        h = 0.02 * safezoneH;
        };

        class yourCtrl3: RscPicture
        {
        idc = 345;
        x = 0.58 * safezoneW + safezoneX;
        y = 0.49 * safezoneH + safezoneY;
        w = 0.052 * safezoneW;
        h = 0.02 * safezoneH;
        };
        .....
    };

    class Default
    {
    idd = -1;
    fadein = 0;
    fadeout = 0;
    duration = 0;
    };

};

 

 

So the variable here is workingDataOrElse in uiNameSpace, as example.

Now in a sqf (or function) you can call:

 

disableSerialization;
//_____________define local variable easy to work ___________________________
private _var1 = (uiNameSpace getVariable "workingDataOrElse") displayCtrl 123;
private _var2 = (uiNameSpace getVariable "workingDataOrElse") displayCtrl 234;
private _var3 = (uiNameSpace getVariable "workingDataOrElse") displayCtrl 345;
....

// all other variables you need
private _hud_rgba = if (sunOrMoon >0.5) then [{[1,1,0,0.7]},{[0.647,0,0,0.7]}];  // example for shifting HUD color at start

 

// then work like this:

_var2 ctrlSetTextColor _hud_rgba;  // color of the text
 

_var1 ctrlSetText  "A3\ui_f\data\IGUI\cfg\HelicopterHUD\airspeed_value_ca.paa", // that's one of my cursor for zeroing
 

// how I calculate the distance of what player aim (roughly same result as in laser designator):

private _ins = lineIntersectsSurfaces [AGLToASL positionCameraToWorld [0,0,0],AGLToASL positionCameraToWorld [0,0,5000],vehicle player,objNull,true,1,"VIEW","FIRE"];
private _cursor_distance = if (count _ins > 0) then [{(_ins select 0 select 0) vectorDistance (eyepos player)},{5000}];
private _aim_dist_txt = if (count _ins > 0) then [{str(round _cursor_distance)},{"---"}];

// then you can use it like this:
_var2 ctrlSetText _aim_dist_txt;

 

 

// you can move your cursor after some calculation about the delta position between the current zeroing (currentZeroing player) and the calculated distance
_var3 ctrlSetPosition  [(0.5+_some_delta_x)* safeZoneW + safeZoneX, (0.49 + 0.0005*_some_delta_z)* safezoneH + safezoneY];
_var3 ctrlCommit 0;

 

In an another sqf/function, you can set the conditions for displaying or not your HUD, like this:

 

if (someCondition) then {
  if (!isNull findDisplay 46 && whatYouWant) then {
      999 cutRsc ["yourHUD","PLAIN",0,false];

    } else {
      999 cutRsc ["default","PLAIN"];
    };
  };
};

 

That's for the main line. Don't focus on _var1, _var2, _var3, they are just examples.

 

 

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×