Jump to content
Sign in to follow this  
R3vo

[Solved] Recent change made to combo box control

Recommended Posts

I just noticed that my custom combo boxes do not display the title anymore on dev branch, was there any change made recently?

Share this post


Link to post
Share on other sites

Still couldn't figure out why the title is not displayed anymore and why custom controls seem to be deleted when used as mission attribute. If someone wants to take closer look, here's the control and the attribute itself.

 

Control:

class GarrisonCoverageCombo: Title
{
    attributeLoad = "\
        _ctrl = _this controlsGroupCtrl 100;\
        _attCtrl = getText( _config >> 'control' );\
        _staticItemsCfg = configFile >> 'Cfg3DEN' >> 'Attributes' >> _attCtrl >> 'Controls' >> 'Value' >> 'items';\
        \
        _fnc_setValues = {\
            private [ '_index' ];\
            params[ '_path', [ '_apply', true ] ];\
            {\
                _cfg = _x;\
                if ( _apply ) then {\
                    _index = _ctrl lbAdd getText( _cfg >> 'text' );\
                    _ctrl lbSetData [ _index, getText( _cfg >> 'data' ) ];\
                }else{\
                    _index = _foreachindex;\
                };\
                if ( !( _value isEqualType '' ) ) then {\
                    if ( _index isEqualTo _value ) then {\
                        _ctrl lbSetCurSel _index;\
                    };\
                }else{\
                    if ( _value == getText( _cfg >> 'data' ) ) then {\
                        _ctrl lbSetCurSel _index;\
                    };\
                };\
            }forEach configProperties [_path,'isclass _x'];\
        };\
        if ( isClass _staticItemsCfg ) then {\
            [ _staticItemsCfg, false ] call _fnc_setValues;\
        };\
        \
        _dynamicItemsCfg = configFile >> 'Cfg3DEN' >> 'Attributes' >> _attCtrl >> 'Controls' >> 'Value' >> 'ItemsConfig';\
        if ( isNumber( _dynamicItemsCfg >> 'localConfig' ) && { getNumber( _dynamicItemsCfg >> 'localConfig' ) > 0 } ) then {\
            _class = getArray( _dynamicItemsCfg >> 'path' ) select 0;\
            _path = missionConfigFile >> _class;\
            if ( isClass _path ) then {\
                _path call _fnc_setValues;\
            };\
        };\
    ";

    attributeSave = "\
        _ctrl = (_this controlsGroupCtrl 100);\
        _value = _ctrl lbData lbCurSel _ctrl;\
        _att = getText( _config >> 'property' );\
        collect3DENHistory {\
            {\
                _x set3DENAttribute [_att,_value];\
            } forEach ( get3DENSelected 'object' );\
        };\
    ";

    class Controls {
        class Title: Title{};
        class Value: ctrlCombo
        {
            idc = 100;
            x = ATTRIBUTE_TITLE_W * GRID_W;
            w = ATTRIBUTE_CONTENT_W * GRID_W;
            h = SIZE_M * GRID_H;

            class Items
            {
                class coverage_100
                {
                    text = "100 %";
                    data = 1;
                    default = 1;
                };
                class coverage_50
                {
                    text = "50 %";
                    data = 2;
                };
                class coverage_30
                {
                    text = "30 %";
                    data = 3;
                };
                class coverage_10
                {
                    text = "10 %";
                    data = 10;
                };        
            };
        };
    };
};

Attributes

class GarrisonBuildings
{
    collapsed = 0;
    displayName = "Garrison Settings";
    class attributes
    {
        class BuildingCoverage
        {
            displayName = "Coverage of selected Buildings";
            tooltip = "Set how many of the selected buildings will be garrisoned";
            property = "3E_coverageBuildings";
            control = "GarrisonCoverageCombo";
            expression = "";
            defaultValue = 1;
            typeName = "NUMBER";
        };
        class BuildingPosCoverage: BuildingCoverage
        {
            displayName = "Coverage of Building Positions";
            tooltip = "Set how many building positions should be garrisoned";
            property = "3E_coverageBuildingsPos";
            typeName = "NUMBER";
        };
        class GarrisonFaction
        {
            displayName = "Faction";
            tooltip = "Set what faction should garrison the building";
            property = "3E_garrisonFaction";
            control = "GarrisonFactionCombo";
            expression = "";
            defaultValue = "NATO";
            typeName = "STRING";
        };
    };
};

 

Share this post


Link to post
Share on other sites

Could it be because you have

class Controls
instead of

class Controls: Controls

Share this post


Link to post
Share on other sites

The title(displayName) is shown now again, but as soon as I hit save in the preferences, the controls disappear again.

Share this post


Link to post
Share on other sites

So I took another look at the code executed when the attribute is saved and I realised that the code there was completely obsolete and was additionally causing the control to disappear.

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
Sign in to follow this  

×