Home   Help Search Login Register  

Author Topic: how to redefine onLoad script of existing GUI class from a mission  (Read 2747 times)

0 Members and 1 Guest are viewing this topic.

Offline takbal

  • Members
  • *
Hi all,

How to change an already defined script or an existing GUI class from a *mission* (not from an addon)? I am quite beginner, so probably the answer is perhaps simple.

I am modifying the warfare mission and I have to change a script which is called through the onLoad definition of an existing GUI class. I un-binned the CA UI's config.bin and looked into the class definitions. Unfortunately, the script looks like wired in by BIS using the 'ca\Warfare2\Scripts\Client\GUI\GUI_BuyGearMenu.sqf' absolute path in the 'RscDisplayBuyGear' class.

#1 idea: replace the existing script by some trick from the mission. I do not know whether it is possible at all, so I moved on.

#2 idea: as I can change which dialog class is used (in GUI_buyPrepareMenu.sqf), so lets modify the 'RscDisplayBuyGear' class to have my custom script named in the 'onLoad' part.

1. proposal for #2: inherit from the original RscDisplayBuyGear into a new RscDisplayBuyGearCustom class and use that. I tried to use the following:

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

class RscDisplayBuyUnits;

class RscDisplayBuyUnitsCustom : RscDisplayBuyUnits {
   onLoad = "[findDisplay 106, _buyType] execVM 'Scripts\Client\GUI\GUI_buyUnitsMenu.sqf'";
   idd = 5088;
   
   class Filters;
   class controlsBackground;
   class controls;
};

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

and I replace the following line in GUI_buyPrepareMenu.sqf:

 ...
 case 'units': {CreateGearDialog [player,"RscDisplayBuyUnitsCustom"];};
 ...

Then when the above script is called then it complains about

"Warning Message: No entry 'bin\config.bin.RscDisplayBuyUnitsCustom'."

and the dialog is dead.

2. proposal for #2: try to replace the original class partially and use the original GUI_buyPrepareMenu.sqf. I have seen a a way to do this in the stra_debug2.pbo addon.

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

class RscDisplayGear;

class RscDisplayBuyUnits : RscDisplayGear {
   onLoad = "[findDisplay 106, _buyType] execVM 'Scripts\Client\GUI\GUI_buyUnitsMenu.sqf'";
   idd = 5088;

   class Filters {   
      class All;
      class Primary;
      class Secondary;
      class HandGun;
      class Items;
   };   
   class controlsBackground
   {
      class Mainback;
   };
   class controls {
      class CA_Filter_Arrow_Left_L;
      class CA_Filter_Arrow_Left_R;
      class CA_Filter_Left_Icont_L;
      class CA_Filter_Right_Icon_R;
      class Gear_Title;
      class Unit_Title;
      class Available_items_Text;
      class CA_Filter_IconUnits;
      class CA_Filter_Icon1Units;
      class CA_ItemName;
      class CA_Money;
      class CA_Money_Value;
      class ListboxArrows {
         class VScrollbar;
         class HScrollbar;
         class controls {
            class Available_units;
            class Queued_units;
            class CA_B_Add;
         };
      };      
      class ButtonFilters;
      class ButtonContinue;
      class ButtonClose;
   };
};

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

Again, no effect - buy menu stays the same. The stra_debug2 addon uses its definition in a config.cpp, so probably I could do the same with making an addon and its config.cpp. My problem is I would like to have a mission without addons. I have tried to create a config.cpp in the mission folder and repeat in it what I had above, but it looks like being not used at all.

3. proposal for #2: Copy the entire class. Again, no effect.

#3 idea: perhaps the problem is with the new, ArmA2-introduced CreateGearDialog command, and it cannot read classes from description.ext, only from config.bins. Replaced it with CreateDialog and tried the solutions above again. Now the problem is that the class definition cannot see the base classes. So how to make description.ext aware of the classes defined in the UI's config.bin? Tried to look around the files, but no .hpp's to include.

Any ideas welcome...

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
You can't inherit from, or modify, any class in the configFile space (that is, from an addon config.cpp) using the missionConfigFile space (that is, in a mission description.ext). They are completely separate config systems.

This means you can't inherit the warfare class or modify its onLoad handler. Although you can modify most UI handlers once the display is open (displaySetEventHandler or displayAddEventHandler), you can't change the onLoad handler before the display is loaded...

What you could do is include the files directly in the description.ext (#include "\ca\...\whatever.hpp" or copy the entire files into your mission, edit out the bits you don't want and include those instead) which won't in any way affect the originals (which are still perfectly happy in the addon config space).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline takbal

  • Members
  • *
Thanks a lot!  :good:

If I understood correctly, then the root cause is that the new CreateGearDialog command works only within the configFile space and cannot use the description.ext. When I tried CreateGearDialog with a dialog defined entirely in description.ext, it still complained about missing it in a .bin file.

I tried to do your suggestion - turning the UI's config.bin into a UI.hpp file in the mission folder - but it threw a lot of errors when used.

If I create an addon with the following config.cpp:

///////

class CfgPatches
{
class RscDisplayBuyUnitsCustom
{
units[] = {};
weapons[] = {};
requiredVersion = 0.100000;
requiredAddons[] = {};
};
};

class RscDisplayBuyUnits;

class RscDisplayBuyUnitsCustom : RscDisplayBuyUnits {
onLoad = "[findDisplay 106, _buyType] execVM 'Scripts\Client\GUI\GUI_buyUnitsMenu.sqf'";
idd = 5088;
};

////////

it works. But come on - it is such a mess to force people to download and install a 450 BYTE (!!!) .pbo... but probably there is no other way to do this for now.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
I doubt that the problem is that CreateGearDialog only works on configFile data. After all, createDialog, title* and cut* commands work fine regardless. Issue is more that you can't inherit something across the "boundary".

i.e. you can do this in an addon config.cpp:
Code: [Select]
// Tell compiler that there is a RscDisplayBuyUnits defined elsewhere.
class RscDisplayBuyUnits;

// Inherit from already defined RscDisplayBuyUnits.
class RscDisplayBuyUnitsCustom : RscDisplayBuyUnits {

But try to do it in description.ext:
Code: [Select]
// Tell compiler that there is a RscDisplayBuyUnits defined elsewhere. However,
// there isn't one of these defined in the mission config space, even if there is in the addon config.
class RscDisplayBuyUnits;

// Inherit an undefined class...ack...burst...weep!
class RscDisplayBuyUnitsCustom : RscDisplayBuyUnits {

Regarding just including the whole config.bin in the mission, there are a number of issues with this. You literally just need the parts of this that you absolutely need. That is, class RscDisplayBuyUnitsCustom. Then you need to find all the configs for classes that it inherits (which will be elsewhere) and include those as well in your mission config.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline takbal

  • Members
  • *
I tried to use CreateGearDialog with a plain class which was defined entirely in the mission config space in "description.ext". It could not find it, and was complaining about missing config.bin\ClassName. Using CreateDialog in exactly the same position works fine. Looks like a bug?

If it is correct, I cannot achieve my goal by moving (parts of) the base classes into the mission config space, as whatever I do, CreateGearDialog cannot see them.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Ah, sorry, yes, if you can get createDialog to work properly like this, then your assumption that CreateGearDialog might only look in the addon config does seem reasonable. Shame if it is true!
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)