Jump to content
Sign in to follow this  
SilentSpike

createDialog and class inheritance

Recommended Posts

Below is snippet from an addon I'm working on. As you can see CBBCM_RscDialogSliderListBox is inheriting from CBBCM_RscDialogListBox.

My goal here is to create the exact same dialog but add a slider to it (which I haven't done yet). Whenever I use createDialog on CBBCM_RscDialogSliderListBox I get the TitleBar control in the controlsBackground of CBBCM_RscBaseDialog but none of the controls from CBBCM_RscDialogListBox. However, when viewing CBBCM_RscDialogSliderListBox in the config viewer I can see all of the inherited controls as I expected.

Am I doing something wrong here or is this simply a limitation of the createDialog command?

class RscButtonMenuCancel;
class RscButtonMenuOK;
class RscListbox;
class RscSlider;
class RscText;


class CBBCM_RscBaseDialog
{
   idd = -1;
   movingEnable = true;
   onLoad = "\
       [] spawn {\
           while {dialog} do {\
               if !(alive player) then {\
                   closeDialog 0;\
               };\
           };\
       };\
   ";
   class controlsBackground
   {
       class TitleBar: RscText
       {
           idc = 100;
           x = safezoneX+safezoneW*0.4;
           y = safezoneY+safezoneH*0.3;
           w = 0.2*safezoneW;
           h = 0.0225*safezoneH;
           colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.69])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.75])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.5])",0.8};
           moving = true;
       };
   };
};


class CBBCM_RscDialogListBox: CBBCM_RscBaseDialog
{
   class controls
   {
       class BackgroundBox: RscText
       {
           x = safezoneX+safezoneW*0.4;
           y = safezoneY+safezoneH*0.325;
           w = 0.2*safezoneW;
           h = 0.165*safezoneH;
           colorBackground[] = {0,0,0,0.7};
       };
       class Listbox: RscListbox
       {
           idc = 101;
           x = safezoneX+safezoneW*0.405;
           y = safezoneY+safezoneH*0.33;
           w = 0.19*safezoneW;
           h = 0.155*safezoneH;
           colorBackground[] = {0,0,0,0.5};
       };
       class ButtonCancel: RscButtonMenuCancel
       {
           action = "closeDialog 0;";
           x = safezoneX+safezoneW*0.44;
           y = safezoneY+safezoneH*0.495;
           w = 0.05*safezoneW;
           h = 0.025*safezoneH;
       };
       class ButtonOK: RscButtonMenuOK
       {
           action = "(uiNamespace getVariable ['CBBCM_ActivatedCuratorModule',objNull]) setVariable ['DialogReturnValue',lbData [101,lbCurSel 101]]; closeDialog 0;";
           x = safezoneX+safezoneW*0.51;
           y = safezoneY+safezoneH*0.495;
           w = 0.05*safezoneW;
           h = 0.025*safezoneH;
       };
   };
};


class CBBCM_RscDialogSliderListBox: CBBCM_RscDialogListBox
{
   class controls: controls
   {
       class ButtonOK: ButtonOK
       {
           action = "(uiNamespace getVariable ['CBBCM_ActivatedCuratorModule',objNull]) setVariable ['DialogReturnValue',[lbData [101,lbCurSel 101],sliderPosition 102]]; closeDialog 0;";
       };
   };
};

Share this post


Link to post
Share on other sites

After much faffing around trying to even get your base example working as for me the buttons where not showing up even in CBBCM_RscDialogListBox.

I found i had to export the baseClasses list and specify inheritance for both the RscButtonMenuCancel and RscButtonMenuOK, which seem as standard to be missing, the classes are present, they just dont inherit properly back to RscButtonMenu : RscShortcutButton.

Anyway it seems as though if you make any changes to an inherited child you need to specifically inherit other children even though there are no changes to them. e.g

class LARs_Test : CBBCM_RscDialogListBox {};

As expected this is a one for one copy.

On that assumption you would think..

class LARs_Test : CBBCM_RscDialogListBox {
class controls : controls {}; 
};

would work. Inherit a child of CBBCM_RscDialogListBox but make no changes to it, but no this totally breaks it and no controls will show. The title bar still shows but as we have not made any changes to the controlsBackground child it works just fine.

On using any child from within an inherited class it seems you then have to specify each inherited subClass even if there are no changes.

So this works for me...

class CBBCM_RscDialogSliderListBox: CBBCM_RscDialogListBox
{
class controls: controls
{
	class BackgroundBox: BackgroundBox{};
	class Listbox: Listbox{};
	class ButtonCancel: ButtonCancel {};
	class ButtonOK: ButtonOK
	{
		action = "(uiNamespace getVariable ['CBBCM_ActivatedCuratorModule',objNull]) setVariable ['DialogReturnValue',[lbData [101,lbCurSel 101],sliderPosition 102]]; closeDialog 0;";
	};
};
};

Im really not that proficient with Arma UI's, made a few simple ones for testing stuff but thats about it. This definitely opened my eyes to something that like you i presumed you would not have to do. If someone with more UI experience knows of a better way or can see something wrong please chip in otherwise thankyou SilentSpike you made me learn somehting new ;)

Share this post


Link to post
Share on other sites

Ah, that's interesting for sure. Thanks for finding that out, I'm sure it would have taken me a while.

(Were you setting up the dialog using a mission? I think the base class inheritance I used will only work in the context of an addon because all the config stuff is merged at runtime.)

Edit: I wonder if this is actually a bug in the createDialog command. I believe that all the examples you gave will show up correctly in the config viewer and from my experience with configs the inheritance should work as we both originally expected.

Edited by SilentSpike

Share this post


Link to post
Share on other sites
(Were you setting up the dialog using a mission? I think the base class inheritance I used will only work in the context of an addon because all the config stuff is merged at runtime.)
Yes i was testing this via a mission. Makes sense as the configs are seperate configFile vs missionConfigFile.

The main point of my little prepost rant (to myself) was more the fact that ctrl+p to output the baseClasses from the GUI editor seems to have a few broken classes. After spending a while trying to work out what was wrong I finally realized RscButtonMenuOK/Cancel get output with no inheritance so dont show up. You have to edit the baseClass list so they both inherit from RscButtonMenu and this also inherits from RscShortcutButton. Was a frustrating half hour, Im all good now had several coffees :D

Edit: I wonder if this is actually a bug in the createDialog command. I believe that all the examples you gave will show up correctly in the config viewer and from my experience with configs the inheritance should work as we both originally expected.
I see what you mean, all the properties are there yet they dont display :/

Share this post


Link to post
Share on other sites

Wow, thank you for finding this bug! I was about to go mad because I was trying to add another control to a class and that made all of the inherited controls dissapear.

This bug leads to even-uglier-than-usual UI code, so I'd love to see it fixed soon - hopefully it's just a simple mistake in how createDialog reads out Resources.

Edited by ImperialAlex

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  

×