Jump to content
Smart Games

Possible to create a HUD with ctrlCreate?

Recommended Posts

Today I discovered the command CtrlCreate and saw that you can create a full UI with it via function and without description.ext.

But I wonder if it is also possible to create a HUD with this (or an unknown but similar) command.

My attempts so far have always failed, because by default you create a UI that you can interact with.

 

Many thanks, Jacob

 

Share this post


Link to post
Share on other sites

You can create new controls in the existing HUD with ctrlCreate, first you need to get handle to that GUI by finddisplay

Or you can create your own HUD and activate it by cutRsc

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Found a solution:

 

description.ext:

#include "Core\GuiBaseClasses.hpp"

class CfgFunctions {
  class JF {
    class Hud {

      class DynamicCreate {file = "Core\Scripts\DynamicCreate.sqf"};
      class DynamicChange {file = "Core\Scripts\DynamicChange.sqf"}
    };
  };
};

class RscTitles {

  class Ui_Dynamic {
    idd = -1;
    duration = 9999999;
    onLoad = "uiNamespace setVariable ['dynamic_ui', _this select 0]; [] spawn JF_fnc_DynamicCreate";
    onUnLoad = "uiNamespace setVariable ['dynamic_ui', nil]";
  };
};

 

DynamicCreate.sqf:

disableSerialization;

private _parent = uiNamespace getVariable "dynamic_ui";
private _ctrl = _parent ctrlCreate ["RscText", 111];

_ctrl ctrlSetPosition [0,0,1,0.04];
_ctrl ctrlSetBackgroundColor [0,0,0,1];
_ctrl ctrlSetText "Test";

 

DynamicChange.sqf:

disableSerialization;
params ["_text"];

private _parent = uiNamespace getVariable "dynamic_ui";
private _ctrl = _parent displayCtrl 111;

_ctrl ctrlSetText _text;

 

Got the base classes with: 

"Default" call BIS_fnc_exportGUIBaseClasses;

 

Call it with:

111 cutRsc ["Ui_Dynamic", "PLAIN"]

 

Edit it with:

["MyNewText"] call JF_fnc_DynamicChange

 

 

I really would like to know, wheter the creation via function could be more beneficial than the creation via .hpp file, or limiting.

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

If you are using ctrlCreate you don't need to have base classes defined. Also instead of BIS_fnc_exportGUIBaseClasses use the new import directive.

7 minutes ago, Smart Games said:

I really would like to know, wheter the creation via function could be more beneficial than the creation via .hpp file, or limiting.

For simple UIs: Go for it. Keep in mind though that some control attributes are not editable via script, like the rows of a CT_TOOLBOX.

  • Like 3

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

×