Bug in adding a tree leaf

Started by Rulaman, Sun 30/06/2013 15:13:42

Previous topic - Next topic

Rulaman

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

#1
I never did this myself, but looking into the editor's interfaces I found this:

Code: csharp

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


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: csharp

public void StartFromNode(IEditorComponent plugin, string id)
{
    TreeNode[] results = _projectTree.Nodes.Find(id, true);
    if (results.Length > 0)
    {
       _lastAddedNode = results[0];
    }

Rulaman

Thanks,

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

SMF spam blocked by CleanTalk