Author Topic: Bug in adding a tree leaf  (Read 816 times)

Bug in adding a tree leaf
« on: 30 Jun 2013, 15:13 »
Hi,

I am developing at the moment a plugin for the editor and I think, I found a bug.

I added in the project tree an new Node (in: public Component(IAGSEditor editor))
_editor.GUIController.ProjectTree.AddTreeRoot(this, CONTROL_ID_ROOT_NODE, "FontEditor", "FontEditorIcon");

in the line after I try to add a leaf
_editor.GUIController.ProjectTree.AddTreeLeaf(this, "sdfh", "Test", "FontEditorIcon", false);      
this doesn't work.


When I click on my node (in: void IEditorComponent.CommandClick(string controlID)) I try to add a leaf
_editor.GUIController.ProjectTree.AddTreeLeaf(this, "sdfh4", "Test4", "FontEditorIcon", false);
this doesn't work either. It shows unter Translations

And when i try to add my leaf when the editor opens a game (in: void IEditorComponent.RefreshDataFromGame())
_editor.GUIController.ProjectTree.AddTreeLeaf(this, "sdfh3", "Test3", "FontEditorIcon", false);
it shows under Scripts

I suppose the problem is in the following function:
public IProjectTreeItem AddTreeLeaf(IEditorComponent component, string id, string name, string iconKey, bool greyedOut)

if (_lastAddedNode != null)
{
            {newNode = _lastAddedNode.Nodes.Add(id, name, iconKey, iconKey);







This is a very strage behaviour.

(Tested with 3.2.1 and the newest BETA 3.3.0.1132)

http://postimg.org/image/wa9mhyq83/

Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Bug in adding a tree leaf
« Reply #1 on: 30 Jun 2013, 16:01 »
I never did this myself, but looking into the editor's interfaces I found this:

Code: C#
  1. /// Sets the project tree's internal marker to the specified node.
  2. /// Any AddTreeLeaf commands will add them as children of this node.
  3. /// </summary>
  4. void StartFromNode(IEditorComponent component, string id);
  5.  

Maybe it should be called before adding leaves?
Otherwise, there's no other obvious way to tell it where to add leaves.

E: The implementation sets _lastAddedNode:
Code: C#
  1. public void StartFromNode(IEditorComponent plugin, string id)
  2. {
  3.     TreeNode[] results = _projectTree.Nodes.Find(id, true);
  4.     if (results.Length > 0)
  5.     {
  6.        _lastAddedNode = results[0];
  7.     }
  8.  
« Last Edit: 30 Jun 2013, 16:04 by Crimson Wizard »

Re: Bug in adding a tree leaf
« Reply #2 on: 01 Jul 2013, 18:29 »
Thanks,

this code helped. It was exactly, what I needed.
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.