Member Controls

Goto page 1 2      Next
Developers > When there's no other BHAV...
pljonesLink to postposted: Fri May 04, 2007 6:30 pm
Avator for pljones

Member since:
 2005-04-02
From:
 London, UK
Posts:
 610

Quaxi,

 

PJSE has the following code in the BHAV editor for cloning a BHAV: 

private void TakeACopy()
{
    IPackedFileDescriptor npfd = wrapper.FileDescriptor.Clone();
    npfd.UserData = wrapper.Package.Read(wrapper.FileDescriptor).UncompressedData;
    currentPackage.Add(npfd, true);
}

This works perfectly well if there's already a BHAV in the package.  However, if there's no other BHAV, it fails!

 

The attached is a minimal example.  In the OBJf, click the Guardian BHAV link, then click the Import button and close the popup BHAV editor.  Back in the package, the BHAV hasn't been added.  If you import a BHAV (any BHAV) using the resource list "Add..." option - or create one - and then repeat the process, it works!

 

Any clues?  Is there something I've misunderstood? 

ClipAttachments:
NoBHAV.zip (203.00 byte, 323 downloads)
 
NewBHAV.zip (232.00 byte, 309 downloads)
And this one has an empty BHAV created in situ 
quaxiLink to postposted: Sat May 05, 2007 2:21 pm
Avator for quaxi

Member since:
 2006-04-28
Posts:
 3154
Thanks I'll look into it.
pljonesLink to postposted: Sun May 13, 2007 2:09 pm
Avator for pljones

Member since:
 2005-04-02
From:
 London, UK
Posts:
 610
It's raining here... any luck on this?  (Not that I'm looking for an excuse to stay inside or anything...)
TheoLink to postposted: Mon May 14, 2007 4:31 pm
Avator for Theo

Member since:
 2006-01-07
From:
 14.918246, -23.514862
Posts:
 75

There's this method signature:

    public void Add(IPackedFileDescriptor pfd, bool isnew)

 

If that doesn't work, then only quaxi can help you :P

quaxiLink to postposted: Wed May 16, 2007 9:48 pm
Avator for quaxi

Member since:
 2006-04-28
Posts:
 3154
Just to be clear.

If you have a package without a BHAV, how do you get the BHAV Plugin to show?
What resource does the wrapper hold? where does the FileDescriptor, and the Package Property point to? Wheres does currentPackage point to?

If you are adding a new Resource to a package, you should use (as you do) Add(pfd, true), as this will ensure, that the offset-property of the newly added descriptor, is set to the end of the package (preventing clashes with other descriptors that have the same TGI -Values).
pljonesLink to postposted: Wed May 16, 2007 11:42 pm
Avator for pljones

Member since:
 2005-04-02
From:
 London, UK
Posts:
 610
quaxi wrote:
If you have a package without a BHAV, how do you get the BHAV Plugin to show?
What resource does the wrapper hold? where does the FileDescriptor, and the Package Property point to? Wheres does currentPackage point to?
Create a new Package.  (Doesn't have to be a new package -- the package with no BHAV in I linked above works.)
Create a new GLOB.
Set the GLOB to a useful SemiGlobal group.
Create a new OBJf.
Set the Init Guardian to one of the SemiGlobal BHAVs using the resource chooser.
(This gets you to the point of the "no BHAV" package I linked above.)
 
Click the View BHAV link.
Click the "Import" button.
"currentPackage" is the package you have open for editing.
"wrapper" is BHAV being viewed -- the SemiGlobal.
"FileDescriptor" is the pfd for the BHAV wrapper being viewed. 
"Package" will be the package the view BHAV comes from -- objects.package, most likely. 
No effect.
 
Create a new BHAV.
(This gets you to the "new BHAV" package I linked.) 
 
Back into the OBJf and View BHAV again.
 
Click the "Import" button.
"currentPackage" is the package you have open for editing.
"wrapper" is BHAV being viewed -- the SemiGlobal.
"FileDescriptor" is the pfd for the BHAV wrapper being viewed.
"Package" will be the package the view BHAV comes from -- objects.package, most likely.
It works.
 
I think in my tests I did open the newly created BHAV just to check it was there before going on to try the import again.  I'll have to try without doing that. 
quaxiLink to postposted: Sat May 19, 2007 1:36 pm
Avator for quaxi

Member since:
 2006-04-28
Posts:
 3154

Hm, I have no Problems with that code.

 

I just downloaded the latest CVS Version of the PJSE.

When I opened the objf, and selected the guardian BHAV, the import button was disabled. So I modified ObjfForm::llBhav_LinkClicked and added the Line

 

BhavForm.currentPackage = wrapper.Package;

 

at the begining. That way the currentPackage was set correct, and I was able to use the Import button. When I clicked it, the BHAV was added to the package without Problem (at least none that I am aware of).

 

I have attached the resulting package file.

ClipAttachments:
QuaxiAddedBHAV.7z (352.00 byte, 277 downloads)
Added BHAV 
pljonesLink to postposted: Sat May 19, 2007 7:57 pm
Avator for pljones

Member since:
 2005-04-02
From:
 London, UK
Posts:
 610
quaxi wrote:
When I opened the objf, and selected the guardian BHAV, the import button was disabled.

That's changed...  I wonder how.  When I first posted, the Import button was enabled.  Not having a currentPackage in the BHAV wrapper would explain why adding the BHAV to the currentPackage wasn't working...  I shall give it a go.
Inge JonesLink to postposted: Sun May 20, 2007 10:26 am
Avator for Inge Jones

Member since:
 2005-03-06
Posts:
 1899
Well I was the person who noticed the problem, and how could I have found this was happening if the Import button was disabled?  I only found out by clicking it, and then seeing that no BHAV had been imported.   It becomes disabled after you click it, which was supposed to be the subtle indication that it had responded, rather than a pop-up saying "BHAV Imported" which then needs okaying.
quaxiLink to postposted: Sun May 20, 2007 11:12 am
Avator for quaxi

Member since:
 2006-04-28
Posts:
 3154
Maybe the CVS-Version is not up to date?

When you tried this Inge, did you open another BHAV in another package before, or did you try with a fresh started SimPE. Maybe the currentPackage was pointing to the last package you opened a BHAV in?
Goto page 1 2      Next


viewthread, 0, 0, When-theres-no-other-BHAV