mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Expand actions treeview on the current action when editing
This commit is contained in:
@@ -274,7 +274,7 @@ void ChoixAction::RefreshAllLists()
|
||||
RefreshList();
|
||||
}
|
||||
|
||||
wxTreeItemId ChoixAction::GetGroupItem(wxTreeCtrl * treeCtrl, wxTreeItemId parent, std::string groupStr)
|
||||
wxTreeItemId ChoixAction::GetGroupItem(wxTreeCtrl * treeCtrl, wxTreeItemId parent, std::string groupStr, bool insertIfNotExist)
|
||||
{
|
||||
std::vector<std::string> groups = SplitString<string>(groupStr, '/');
|
||||
|
||||
@@ -290,8 +290,12 @@ wxTreeItemId ChoixAction::GetGroupItem(wxTreeCtrl * treeCtrl, wxTreeItemId paren
|
||||
if ( treeCtrl->HasChildren(groupItem) ) latestGroupPos++;
|
||||
groupItem = treeCtrl->GetNextSibling(groupItem);
|
||||
}
|
||||
if ( !groupItem.IsOk() )
|
||||
if ( !groupItem.IsOk() && insertIfNotExist)
|
||||
groupItem = treeCtrl->InsertItem(parent, latestGroupPos, groups[i], 0);
|
||||
else if( !groupItem.IsOk() && !insertIfNotExist)
|
||||
{
|
||||
return groupItem;
|
||||
}
|
||||
|
||||
parent = groupItem;
|
||||
}
|
||||
@@ -299,6 +303,55 @@ wxTreeItemId ChoixAction::GetGroupItem(wxTreeCtrl * treeCtrl, wxTreeItemId paren
|
||||
return parent;
|
||||
}
|
||||
|
||||
void ChoixAction::SelectAction(const std::string &type)
|
||||
{
|
||||
const gd::InstructionMetadata & instructionMetadata = gd::MetadataProvider::GetActionMetadata(game.GetCurrentPlatform(), type);
|
||||
|
||||
//Select the action in the treectrl
|
||||
wxTreeItemId groupItem = GetGroupItem(ActionsTree, ActionsTree->GetRootItem(), instructionMetadata.GetGroup(), false);
|
||||
if(groupItem.IsOk())
|
||||
{
|
||||
wxTreeItemIdValue cookie;
|
||||
for(wxTreeItemId instructionItem = ActionsTree->GetFirstChild(groupItem, cookie); instructionItem.IsOk(); instructionItem = ActionsTree->GetNextChild(groupItem, cookie))
|
||||
{
|
||||
gd::TreeItemStringData *itemData = dynamic_cast<gd::TreeItemStringData*>(ActionsTree->GetItemData(instructionItem));
|
||||
if(itemData == NULL)
|
||||
continue;
|
||||
|
||||
if(itemData->GetString() == type)
|
||||
{
|
||||
//It's the current action item
|
||||
ActionsTree->EnsureVisible(instructionItem);
|
||||
ActionsTree->SelectItem(instructionItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
wxTreeItemIdValue cookie2;
|
||||
for(wxTreeItemId extensionItem = ActionsTree->GetFirstChild(ActionsTree->GetRootItem(), cookie2); extensionItem.IsOk(); extensionItem = ActionsTree->GetNextChild(ActionsTree->GetRootItem(), cookie2))
|
||||
{
|
||||
wxTreeItemId groupItem = GetGroupItem(ActionsTree, extensionItem, instructionMetadata.GetGroup(), false);
|
||||
if(groupItem.IsOk())
|
||||
{
|
||||
wxTreeItemIdValue cookie;
|
||||
for(wxTreeItemId instructionItem = ActionsTree->GetFirstChild(groupItem, cookie); instructionItem.IsOk(); instructionItem = ActionsTree->GetNextChild(groupItem, cookie))
|
||||
{
|
||||
gd::TreeItemStringData *itemData = dynamic_cast<gd::TreeItemStringData*>(ActionsTree->GetItemData(instructionItem));
|
||||
if(itemData == NULL)
|
||||
continue;
|
||||
|
||||
if(itemData->GetString() == type)
|
||||
{
|
||||
//It's the current action item
|
||||
ActionsTree->EnsureVisible(instructionItem);
|
||||
ActionsTree->SelectItem(instructionItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the list of actions
|
||||
*/
|
||||
@@ -597,6 +650,9 @@ void ChoixAction::RefreshFromAction()
|
||||
|
||||
const gd::InstructionMetadata & instructionMetadata = gd::MetadataProvider::GetActionMetadata(game.GetCurrentPlatform(), Type);
|
||||
|
||||
//Select the current selected action
|
||||
SelectAction(Type);
|
||||
|
||||
//Display action main properties
|
||||
NomActionTxt->SetLabel( instructionMetadata.GetFullName() );
|
||||
NomActionTxt->Wrap( 450 );
|
||||
|
@@ -135,7 +135,9 @@ private:
|
||||
void RefreshObjectActionsList();
|
||||
void OnABtClick(wxCommandEvent& event);
|
||||
void OnFacClicked(wxCommandEvent& event);
|
||||
wxTreeItemId GetGroupItem(wxTreeCtrl * treeCtrl, wxTreeItemId parent, std::string groupStr);
|
||||
|
||||
void SelectAction(const std::string &type);
|
||||
wxTreeItemId GetGroupItem(wxTreeCtrl * treeCtrl, wxTreeItemId parent, std::string groupStr, bool insertIfNotExist = true);
|
||||
|
||||
wxImageList * imageList;
|
||||
std::string selectedObject;
|
||||
|
Reference in New Issue
Block a user