Adventure Game Studio

AGS Development => Editor Development => Topic started by: Rulaman on Sun 30/06/2013 15:13:42

Title: Bug in adding a tree leaf
Post by: Rulaman on Sun 30/06/2013 15:13:42
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/
(http://s21.postimg.org/wa9mhyq83/Bild2.jpg) (http://postimg.org/image/wa9mhyq83/)
Title: Re: Bug in adding a tree leaf
Post by: Crimson Wizard on Sun 30/06/2013 16:01:28
I never did this myself, but looking into the editor's interfaces I found this:

Code (csharp) Select

/// 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) Select

public void StartFromNode(IEditorComponent plugin, string id)
{
    TreeNode[] results = _projectTree.Nodes.Find(id, true);
    if (results.Length > 0)
    {
       _lastAddedNode = results[0];
    }
Title: Re: Bug in adding a tree leaf
Post by: Rulaman on Mon 01/07/2013 18:29:14
Thanks,

this code helped. It was exactly, what I needed.